Skip to content

Commit

Permalink
Merge pull request #1003 from njorocs/version-18.1.3
Browse files Browse the repository at this point in the history
Revised vmmc by hiv status query
  • Loading branch information
patryllus authored Mar 22, 2022
2 parents 58aae5a + 33ce7fc commit e36e6a2
Showing 1 changed file with 28 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2720,10 +2720,20 @@ public CohortDefinition malesCircumcised() {
* @return
*/
public CohortDefinition testedHIVPositiveAtVMMCSite() {
String sqlQuery = "select e.patient_id from kenyaemr_etl.etl_vmmc_enrolment e\n" +
"left join (select h.patient_id,h.hiv_test_date from kenyaemr_etl.etl_vmmc_medical_history h where h.hiv_status = 703 and date(h.hiv_test_date) between date(:startDate) and date(:endDate)) h on e.patient_id = h.patient_id\n" +
"left join (select t.patient_id from kenyaemr_etl.etl_hts_test t where t.final_test_result = 'Positive' and t.test_type = 2 and t.hts_entry_point = 162223 and t.visit_date between date(:startDate) and date(:endDate)) t on e.patient_id = t.patient_id\n" +
"where (h.patient_id is not null or t.patient_id is not null) and e.visit_date <=date(h.hiv_test_date);";
String sqlQuery = "select e.patient_id\n" +
"from kenyaemr_etl.etl_vmmc_circumcision_procedure e\n" +
" left join (select h.patient_id, h.hiv_test_date\n" +
" from kenyaemr_etl.etl_vmmc_medical_history h\n" +
" where h.hiv_status = 703\n" +
" and date(h.hiv_test_date) between date(:startDate) and date(:endDate)) h\n" +
" on e.patient_id = h.patient_id\n" +
" left join (select t.patient_id,t.visit_date\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" where t.final_test_result = 'Positive'\n" +
" and t.test_type = 2\n" +
" and t.hts_entry_point = 162223\n" +
" and t.visit_date between date(:startDate) and date(:endDate)) t on e.patient_id = t.patient_id\n" +
"where e.visit_date between date(:startDate) and date(:endDate) and ((h.patient_id is not null and e.visit_date >= date(h.hiv_test_date)) or (t.patient_id is not null and e.visit_date >= date(t.visit_date)));";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("VMMC_SITE_HIV_POSITIVE");
cd.setQuery(sqlQuery);
Expand All @@ -2737,48 +2747,28 @@ public CohortDefinition testedHIVPositiveAtVMMCSite() {
* @return
*/
public CohortDefinition testedHIVNegativeAtVMMCSite() {
String sqlQuery = "select e.patient_id from kenyaemr_etl.etl_vmmc_enrolment e\n" +
" left join (select h.patient_id,h.hiv_test_date from kenyaemr_etl.etl_vmmc_medical_history h where h.hiv_status = 664 and date(h.hiv_test_date) between date(:startDate) and date(:endDate)) h on e.patient_id = h.patient_id\n" +
" left join (select t.patient_id from kenyaemr_etl.etl_hts_test t where t.final_test_result = 'Negative' and t.test_type = 1 and t.hts_entry_point = 162223 and t.visit_date between date(:startDate) and date(:endDate)) t on e.patient_id = t.patient_id\n" +
"where (h.patient_id is not null or t.patient_id is not null) and e.visit_date <=date(h.hiv_test_date);";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("VMMC_SITE_HIV_NEGATIVE");
cd.setQuery(sqlQuery);
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.setDescription("Number tested HIV NEGATIVE at VMMC site");
return cd;
}
/**
*Number tested HIV Indeterminate at VMMC site
* @return
*/
public CohortDefinition testedHIVIndeterminateAtVMMCSite() {
String sqlQuery = "select e.patient_id\n" +
"from kenyaemr_etl.etl_vmmc_enrolment e\n" +
"from kenyaemr_etl.etl_vmmc_circumcision_procedure e\n" +
" left join (select h.patient_id, h.hiv_test_date\n" +
" from kenyaemr_etl.etl_vmmc_medical_history h\n" +
" where (h.hiv_status = 1067 and date(h.hiv_test_date) between date(:startDate) and date(:endDate))\n" +
" or (h.hiv_status != 1067 and\n" +
" date(h.hiv_test_date) not between date(:startDate) and date(:endDate))) h\n" +
" where h.hiv_status = 664\n" +
" and date(h.hiv_test_date) between date(:startDate) and date(:endDate)) h\n" +
" on e.patient_id = h.patient_id\n" +
" left join (select t.patient_id\n" +
" left join (select t.patient_id,t.visit_date\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" where ((t.final_test_result = 'Inconclusive' and t.hts_entry_point = 162223 and\n" +
" t.visit_date between date(:startDate) and date(:endDate)) or\n" +
" (t.final_test_result in ('Negative', 'Positive')\n" +
" and t.hts_entry_point != 162223 and\n" +
" t.visit_date not between date(:startDate) and date(:endDate)))\n" +
") t on e.patient_id = t.patient_id\n" +
"where ((h.patient_id is not null and e.visit_date <= date(h.hiv_test_date)) or t.patient_id is not null);";
" where t.final_test_result = 'Negative'\n" +
" and t.hts_entry_point = 162223\n" +
" and t.visit_date between date(:startDate) and date(:endDate)) t on e.patient_id = t.patient_id\n" +
"where e.visit_date between date(:startDate) and date(:endDate) and ((h.patient_id is not null and e.visit_date >= date(h.hiv_test_date)) or (t.patient_id is not null and e.visit_date >= date(t.visit_date)));";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("VMMC_SITE_HIV_INDETERMINATE");
cd.setName("VMMC_SITE_HIV_NEGATIVE");
cd.setQuery(sqlQuery);
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.setDescription("Number tested HIV Indeterminate at VMMC site");
cd.setDescription("Number tested HIV NEGATIVE at VMMC site");
return cd;
}

/**
*Number of males circumcised and tested HIV positive at VMMC site
* @return
Expand Down Expand Up @@ -2814,8 +2804,9 @@ public CohortDefinition malesCircumcisedIndeterminateHIVResult() {
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.addSearch("malesCircumcised",ReportUtils.map(malesCircumcised(), "startDate=${startDate},endDate=${endDate}"));
cd.addSearch("testedHIVIndeterminateAtVMMCSite",ReportUtils.map(testedHIVIndeterminateAtVMMCSite(), "startDate=${startDate},endDate=${endDate}"));
cd.setCompositionString("malesCircumcised AND testedHIVIndeterminateAtVMMCSite");
cd.addSearch("testedHIVPositiveAtVMMCSite",ReportUtils.map(testedHIVPositiveAtVMMCSite(), "startDate=${startDate},endDate=${endDate}"));
cd.addSearch("testedHIVNegativeAtVMMCSite",ReportUtils.map(testedHIVNegativeAtVMMCSite(), "startDate=${startDate},endDate=${endDate}"));
cd.setCompositionString("malesCircumcised AND NOT (testedHIVPositiveAtVMMCSite OR testedHIVNegativeAtVMMCSite)");
return cd;
}
/**
Expand Down

0 comments on commit e36e6a2

Please sign in to comment.