Created
July 19, 2021 06:34
-
-
Save dbaluku/6ab2bbcdee59cb32281a5de24bda25a5 to your computer and use it in GitHub Desktop.
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
private void processARTAccessData(JSONObject jsonObject,Patient patient){ | |
HashMap conceptsCaptured = getARTAccessRecordsConcepts(); | |
UserService userService = Context.getUserService(); | |
User user = userService.getUserByUuid("9bd6584f-33e0-11e7-9528-1866da16840d"); | |
Set<Obs> obsList =new HashSet<>(); | |
try { | |
String visit_date = getJSONObjectValue(jsonObject.getJSONObject("0"), "visit_date"); | |
String dateFormat = ugandaEMRSyncService.getDateFormat(visit_date); | |
Date startVisitDate = ugandaEMRSyncService.convertStringToDate(visit_date, "00:00:00", dateFormat); | |
Date stopVisitDate = ugandaEMRSyncService.convertStringToDate(visit_date, "23:59:59", dateFormat); | |
String next_visit_date = getJSONObjectValue(jsonObject.getJSONObject("1"), "next_visit_date"); | |
Date return_date = ugandaEMRSyncService.convertStringToDate(next_visit_date, "00:00:00", ugandaEMRSyncService.getDateFormat(next_visit_date)); | |
if(next_visit_date!=""&&next_visit_date!=null) { | |
addObs(obsList, next_visit_date, conceptService.getConcept((int) conceptsCaptured.get("next_visit_date")), null, return_date, null, patient, user, startVisitDate); | |
} | |
String adherence = getJSONObjectValue(jsonObject.getJSONObject("4"),"adherence"); | |
Concept adherence_concept = conceptService.getConcept((int)conceptsCaptured.get("adherence")); | |
Concept adherence_answer = convertAdherence(adherence); | |
addObs(obsList,adherence,adherence_concept, adherence_answer, null, null, patient, user, new Date()); | |
Visit visit =createVisit(patient,startVisitDate,stopVisitDate,user, pharmacyLocation); | |
Encounter encounter = createEncounter(patient,startVisitDate,user, pharmacyLocation); | |
encounter.setObs(obsList); | |
encounter.setVisit(visit); | |
encounterService.saveEncounter(encounter); | |
System.out.println("Visit for patient: "+ visit.getPatient().getId()+ "saved successfully"); | |
}catch (Exception e){ | |
System.out.println(e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment