Skip to content

Commit

Permalink
Merge pull request #2037 from makombe/heiOutcome-endpoint
Browse files Browse the repository at this point in the history
Add hei outcome encounter endpoint
  • Loading branch information
njorocs authored Oct 30, 2024
2 parents c2cb00e + c7975f8 commit 344baef
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,28 @@ public Object getFacilityName(@RequestParam("facilityCode") String facilityCode)
locationResponseObj.put("name", facility.getName());
return locationResponseObj;
}
/**
* Gets last hei outcome encounter
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/heiOutcomeEncounter")
@ResponseBody
public Object getHeiOutcomeEncounter(@RequestParam("patientUuid") String patientUuid) {
SimpleObject heiOutcomeResponseObj = new SimpleObject();
PatientIdentifierType heiNumber = MetadataUtils.existing(PatientIdentifierType.class, MchMetadata._PatientIdentifierType.HEI_ID_NUMBER);
Patient patient = Context.getPatientService().getPatientByUuid(patientUuid);
PatientIdentifier pi = heiNumber != null && patient != null ? patient.getPatientIdentifier(heiNumber) : null;
EncounterType heiOutcomeEncType = MetadataUtils.existing(EncounterType.class, MchMetadata._EncounterType.MCHCS_HEI_COMPLETION);
Form heiOutcomeForm = MetadataUtils.existing(Form.class, MchMetadata._Form.MCHCS_HEI_COMPLETION);
Encounter lastHeiOutcomeEnc = EmrUtils.lastEncounter(patient, heiOutcomeEncType, heiOutcomeForm);
if(pi.getIdentifier() != null) {
heiOutcomeResponseObj.put("heiNumber", pi.getIdentifier());
}
if(lastHeiOutcomeEnc != null) {
heiOutcomeResponseObj.put("heiOutcomeEncounterUuid", lastHeiOutcomeEnc.getUuid());
}
return heiOutcomeResponseObj;
}

/**
* Get a list of programs a patient is eligible for
Expand Down

0 comments on commit 344baef

Please sign in to comment.