Skip to content

Commit

Permalink
#1378 | Fix DEA general tab breaking due to voided eligible encounter…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
1t5j0y committed Nov 25, 2024
1 parent f1955c3 commit 3d28b27
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/common/mapper/EncounterMapper.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { get } from "lodash";
import { get, isNil } from "lodash";
import { Encounter } from "avni-models";
import { mapBasicEncounter } from "./BaseEncounterMapper";

export const getNewEligibleEncounters = (encounterTypes, eligibleEncounters) => {
const scheduledEncounters = get(eligibleEncounters, "scheduledEncounters", []).map(pe =>
mapBasicEncounter(new Encounter(), pe)
);
const unplannedEncounters = get(eligibleEncounters, "eligibleEncounterTypeUUIDs", []).map(
uuid => {
const encounter = new Encounter();
encounter.encounterType = encounterTypes.find(eT => eT.uuid === uuid);
encounter.name =
encounter.encounterType && encounter.encounterType.operationalEncounterTypeName;
return encounter;
}
);
const scheduledEncounters = get(eligibleEncounters, "scheduledEncounters", []).map(pe => mapBasicEncounter(new Encounter(), pe));
const unplannedEncounters = get(eligibleEncounters, "eligibleEncounterTypeUUIDs", [])
.map(uuid => {
const result = encounterTypes.find(eT => eT.uuid === uuid);
if (!isNil(result)) {
const encounter = new Encounter();
encounter.encounterType = result;
encounter.name = encounter.encounterType.operationalEncounterTypeName;
return encounter;
}
return null;
})
.filter(enc => !isNil(enc));
return { scheduledEncounters, unplannedEncounters };
};

0 comments on commit 3d28b27

Please sign in to comment.