Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed defaulter tracing and ovc #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AMRSDefaulterTracing {
private String kenyaEmrPatientUuid;
private String kenyaEmrFormUuid;
private String responseCode;
private String visitId;
private String obsDatetime;

public Integer getId() {
return Id;
Expand Down Expand Up @@ -127,4 +129,20 @@ public String getResponseCode() {
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}

public String getVisitId() {
return visitId;
}

public void setVisitId(String visitId) {
this.visitId = visitId;
}

public String getObsDatetime() {
return obsDatetime;
}

public void setObsDatetime(String obsDatetime) {
this.obsDatetime = obsDatetime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface AMRSDefaulterTracingRepository extends JpaRepository<AMRSDefaul
List<AMRSDefaulterTracing> findFirstByOrderByIdDesc();
List<AMRSDefaulterTracing> findByResponseCodeIsNull();
List<AMRSDefaulterTracing> findByPatientId(String pid);
List<AMRSDefaulterTracing> findByVisitId(String vid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public interface AMRSOvcRepository extends JpaRepository<AMRSOvc, Long> {
List<AMRSOvc> findFirstByOrderByIdDesc();
List<AMRSOvc> findByResponseCodeIsNull();
List<AMRSOvc> findByPatientId(String pid);
List<AMRSOvc> findByVisitId(String vid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public List<AMRSDefaulterTracing> findByPatientId(String pid) {
return amrsDefaulterTracingRepository.findByPatientId(pid);
}

public List<AMRSDefaulterTracing> findByVisitId(String vid) {
return amrsDefaulterTracingRepository.findByVisitId(vid);
}

public AMRSDefaulterTracing save(AMRSDefaulterTracing dataset) {
return amrsDefaulterTracingRepository.save(dataset);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public List<AMRSOvc> findByPatientId(String pid) {
return amrsOvcRepository.findByPatientId(pid);
}

public List<AMRSOvc> findByVisitId(String vid) {
return amrsOvcRepository.findByVisitId(vid);
}

public AMRSOvc save(AMRSOvc dataset) {
return amrsOvcRepository.save(dataset);
}
Expand Down
165 changes: 73 additions & 92 deletions src/main/java/ampath/co/ke/amrs_kenyaemr/tasks/MigrateCareData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3572,22 +3572,26 @@ public static void artRefill(String server, String username, String password, St


public static void defaulterTracing(String server,String username,String password,String locations,String parentUUID,AMRSDefaulterTracingService amrsDefaulterTracingService,AMRSTranslater amrsTranslater,AMRSPatientServices amrsPatientServices,String url,String auth) throws IOException, SQLException, JSONException {
List<AMRSPatients> amrsPatientsList = amrsPatientServices.getAll();
String pidss = "";
for (int y = 0; y < amrsPatientsList.size(); y++) {
pidss += amrsPatientsList.get(y).getPersonId() + ",";
}
String pid = pidss.substring(0, pidss.length() - 1);

System.out.println("Patient Id " + pid);

// List<AMRSPatients> amrsPatientsList = amrsPatientServices.getAll();
// String pidss = "";
// for (int y = 0; y < amrsPatientsList.size(); y++) {
// pidss += amrsPatientsList.get(y).getPersonId() + ",";
// }
// String pid = pidss.substring(0, pidss.length() - 1);
//
// System.out.println("Patient Id " + pid);
//
//
// System.out.println("Patient Id " + pid);

System.out.println("Patient Id " + pid);
String samplePatientList = AMRSSamples.getPersonIdList();

String sql = "SELECT o.person_id as patient_id,\n" +
"e.form_id,\n" +
"o.concept_id,\n" +
" e.visit_id,\n"+
"o.encounter_id,\n" +
"e.encounter_datetime,\n" +
"cn.name question,\n" +
"case when o.value_datetime is not null then o.value_datetime\n" +
" when o.value_coded is not null then o.value_coded\n" +
Expand Down Expand Up @@ -3621,45 +3625,39 @@ public static void defaulterTracing(String server,String username,String passwor
String encounterId = rs.getString("encounter_id");
String question = rs.getString("question");
String value = rs.getString(("value"));
String visitId = rs.getString(("visit_id"));
String obsDatetime = rs.getString(("encounter_datetime"));

AMRSDefaulterTracing amrsDefaulterTracing = new AMRSDefaulterTracing();


amrsDefaulterTracing.setPatientId(patientId);
amrsDefaulterTracing.setFormId(formId);
amrsDefaulterTracing.setConceptId(conceptId);
amrsDefaulterTracing.setEncounterId(encounterId);
amrsDefaulterTracing.setQuestion(question);
amrsDefaulterTracing.setValue(value);

List<AMRSPatients> amrsPatients = amrsPatientServices.getByPatientID(patientId);
String kenyaemr_patient_uuid = "";
if (!amrsPatients.isEmpty()) {
kenyaemr_patient_uuid = amrsPatients.get(0).getKenyaemrpatientUUID();
amrsDefaulterTracing.setKenyaEmrPatientUuid(kenyaemr_patient_uuid);
} else {
kenyaemr_patient_uuid = "Not Found"; // add logic for missing patientkenyaemr_patient_uuid
}


String kenyaEmrEncounterUuid = "1495edf8-2df2-11e9-b210-d663bd873d93";
amrsDefaulterTracing.setKenyaEmrEncounterUuid(kenyaEmrEncounterUuid);



String kenyaEmrFormUuid = "a1a62d1e-2def-11e9-b210-d663bd873d93";
amrsDefaulterTracing.setKenyaEmrFormUuid(kenyaEmrFormUuid);

String kenyaEmrConceptUuid = "";
kenyaEmrConceptUuid = amrsTranslater.translater(conceptId);
amrsDefaulterTracing.setKenyaEmrConceptUuid(kenyaEmrConceptUuid);
List<AMRSDefaulterTracing> amrsDefaulterTracingList =amrsDefaulterTracingService.findByPatientIdAndEncounterIdAndConceptId(patientId,encounterId,conceptId);
if(amrsDefaulterTracingList.isEmpty()) {
AMRSDefaulterTracing amrsDefaulterTracing = new AMRSDefaulterTracing();
amrsDefaulterTracing.setPatientId(patientId);
amrsDefaulterTracing.setFormId(formId);
amrsDefaulterTracing.setConceptId(conceptId);
amrsDefaulterTracing.setEncounterId(encounterId);
amrsDefaulterTracing.setQuestion(question);
amrsDefaulterTracing.setValue(value);
amrsDefaulterTracing.setVisitId(visitId);
amrsDefaulterTracing.setObsDatetime(obsDatetime);

String kenyaEmrValueUuid = "";
kenyaEmrValueUuid = amrsTranslater.translater(value);
amrsDefaulterTracing.setKenyaEmrValueUuid(kenyaEmrValueUuid);
String kenyaemrPatientUuid = "";
kenyaemrPatientUuid = amrsTranslater.KenyaemrPatientUuid(patientId);
amrsDefaulterTracing.setKenyaEmrPatientUuid(kenyaemrPatientUuid);
String kenyaEmrEncounterUuid = "1495edf8-2df2-11e9-b210-d663bd873d93";
amrsDefaulterTracing.setKenyaEmrEncounterUuid(kenyaEmrEncounterUuid);
String kenyaEmrFormUuid = "a1a62d1e-2def-11e9-b210-d663bd873d93";
amrsDefaulterTracing.setKenyaEmrFormUuid(kenyaEmrFormUuid);
String kenyaEmrConceptUuid = "";
kenyaEmrConceptUuid = amrsTranslater.translater(conceptId);
amrsDefaulterTracing.setKenyaEmrConceptUuid(kenyaEmrConceptUuid);
String kenyaEmrValueUuid = "";
kenyaEmrValueUuid = amrsTranslater.translater(value);
amrsDefaulterTracing.setKenyaEmrValueUuid(kenyaEmrValueUuid);


amrsDefaulterTracingService.save(amrsDefaulterTracing);
amrsDefaulterTracingService.save(amrsDefaulterTracing);
}

// Call method to create and insert the payload
}
Expand Down Expand Up @@ -4083,60 +4081,43 @@ public static void ovc(String server,String username,String password,String loca
String encounterDatetime = rs.getString("encounter_datetime");



AMRSOvc amrsOvc = new AMRSOvc();


amrsOvc.setPatientId(patientId);
amrsOvc.setFormId(formId);
amrsOvc.setConceptId(conceptId);
amrsOvc.setEncounterId(encounterId);
amrsOvc.setQuestion(question);
amrsOvc.setValue(value);
amrsOvc.setVisitId(visitId);
amrsOvc.setObsDateTime(obsDatetime);
amrsOvc.setKenyaEmrEncounterDateTime(encounterDatetime);

// List<AMRSPatients> amrsPatients = amrsPatientServices.getByPatientID(patientId);
// String kenyaemr_patient_uuid = "";
// if (!amrsPatients.isEmpty()) {
// kenyaemr_patient_uuid = amrsPatients.get(0).getKenyaemrpatientUUID();
// amrsOvc.setKenyaemrPatientUuid(kenyaemr_patient_uuid);
// } else {
// kenyaemr_patient_uuid = "Not Found"; // add logic for missing patientkenyaemr_patient_uuid
// }
String kenyaEmrPatientUuid = "";
kenyaEmrPatientUuid = amrsTranslater.KenyaemrPatientUuid(patientId);
amrsOvc.setKenyaemrPatientUuid(kenyaEmrPatientUuid);


String kenyaEmrEncounterUuid = "5cf00d9e-09da-11ea-8d71-362b9e155667";
amrsOvc.setKenyaemrEncounterTypeUuid(kenyaEmrEncounterUuid);



String kenyaEmrFormUuid = "5cf013e8-09da-11ea-8d71-362b9e155667";
amrsOvc.setKenyaemrFormUuid(kenyaEmrFormUuid);

String kenyaemrVisitUuid = "";
kenyaemrVisitUuid = amrsTranslater.kenyaemrVisitUuid(visitId);
amrsOvc.setKenyaemrVisitUuid(kenyaemrVisitUuid);

String kenyaEmrConceptUuid = "";
kenyaEmrConceptUuid = amrsTranslater.translater(conceptId);
amrsOvc.setKenyaEmrConceptUuid(kenyaEmrConceptUuid);

String kenyaEmrValueUuid = "";
kenyaEmrValueUuid = amrsTranslater.translater(value);
amrsOvc.setKenyaEmrValue(kenyaEmrValueUuid);
List<AMRSOvc> amrsOvcList =amrsOvcService.findByPatientIdAndEncounterIdAndConceptId(patientId,encounterId,conceptId);
if(amrsOvcList.isEmpty()) {
AMRSOvc amrsOvc = new AMRSOvc();
amrsOvc.setPatientId(patientId);
amrsOvc.setFormId(formId);
amrsOvc.setConceptId(conceptId);
amrsOvc.setEncounterId(encounterId);
amrsOvc.setQuestion(question);
amrsOvc.setValue(value);
amrsOvc.setVisitId(visitId);
amrsOvc.setObsDateTime(obsDatetime);
amrsOvc.setKenyaEmrEncounterDateTime(encounterDatetime);
String kenyaEmrPatientUuid = "";
kenyaEmrPatientUuid = amrsTranslater.KenyaemrPatientUuid(patientId);
amrsOvc.setKenyaemrPatientUuid(kenyaEmrPatientUuid);
String kenyaEmrEncounterUuid = "5cf00d9e-09da-11ea-8d71-362b9e155667";
amrsOvc.setKenyaemrEncounterTypeUuid(kenyaEmrEncounterUuid);
String kenyaEmrFormUuid = "5cf013e8-09da-11ea-8d71-362b9e155667";
amrsOvc.setKenyaemrFormUuid(kenyaEmrFormUuid);
String kenyaemrVisitUuid = "";
kenyaemrVisitUuid = amrsTranslater.kenyaemrVisitUuid(visitId);
amrsOvc.setKenyaemrVisitUuid(kenyaemrVisitUuid);
String kenyaEmrConceptUuid = "";
kenyaEmrConceptUuid = amrsTranslater.translater(conceptId);
amrsOvc.setKenyaEmrConceptUuid(kenyaEmrConceptUuid);
String kenyaEmrValueUuid = "";
kenyaEmrValueUuid = amrsTranslater.translater(value);
amrsOvc.setKenyaEmrValue(kenyaEmrValueUuid);


amrsOvcService.save(amrsOvc);
amrsOvcService.save(amrsOvc);
}

// Call method to create and insert the payload
}

CareOpenMRSPayload.ovc(amrsOvcService, amrsPatientServices, url, auth);
CareOpenMRSPayload.ovc(amrsOvcService, amrsPatientServices, amrsTranslater, url, auth);
}

}
Expand Down
Loading