-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1378 | Fix DEA general tab breaking due to voided eligible encounter…
… type
- Loading branch information
Showing
1 changed file
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
}; |