Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String getPatientLocation (Patient patient) {
- String patientLocation = null;
- EncounterService encounterService = Context.getEncounterService();
- List<Encounter> encounters = encounterService.getEncountersByPatient(patient);
- if (!encounters.isEmpty()) {
- Encounter lastEncounter = encounters.get(0);
- Location lastLocation = lastEncounter.getLocation();
- if (lastLocation.getName().startsWith("MTRH Module"))
- patientLocation = lastLocation.getName().replace("MTRH Module", "").trim();
- }
- if (patientLocation == null) {
- for (PatientIdentifier identifier : patient.getActiveIdentifiers()) {
- Location identifierLocation = identifier.getLocation();
- if (identifierLocation.getName().startsWith("MTRH Module")) {
- patientLocation = identifierLocation.getName().replace("MTRH Module", "").trim();
- break;
- }
- }
- }
- if (patientLocation == null) {
- String attributeName = "Health Center";
- PersonAttribute attribute = patient.getAttribute(attributeName);
- Location healthCenterLocation = (Location) attribute.getHydratedObject();
- if (healthCenterLocation.getName() != null &&
- healthCenterLocation.getName().startsWith("MTRH Module"))
- patientLocation = healthCenterLocation.getName().replace("MTRH Module", "").trim();
- }
- return patientLocation;
- }
Add Comment
Please, Sign In to add comment