Skip to content

Commit

Permalink
Merge pull request #2060 from njorocs/KHP3-7098_99-MoH731
Browse files Browse the repository at this point in the history
Fixed Clients tested HIV+ and Positive at ANC 1 not populating
  • Loading branch information
patryllus authored Dec 20, 2024
2 parents 332fa6e + 836d8fa commit b8dea1a
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,17 @@ protected DataSetDefinition hivTestingAndCouselingDatasetDefinition() {
cohortDsd.addColumn("HV01-05", "Tested (KVP)", ReportUtils.map(moh731GreenCardIndicators.htsNumberTestedKVP(), indParams),"");

// 1.2 HIV Positive Results
EmrReportingUtils.addRow(cohortDsd, "HV01", "Tested Positive", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales(), indParams), htsMaleDisaggregation, Arrays.asList("06", "08", "10", "12", "14"));
EmrReportingUtils.addRow(cohortDsd, "HV01", "Tested Positive", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales(), indParams), htsFemaleDisaggregation, Arrays.asList("07", "09", "11", "13", "15"));
cohortDsd.addColumn( "HV01-06", "Tested Positive (2-9, Male)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales(2, 9), indParams),"");
cohortDsd.addColumn( "HV01-08", "Tested Positive (10-14, Male)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales(10, 14), indParams),"");
cohortDsd.addColumn( "HV01-10", "Tested Positive (15-19, Male)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales(15, 19), indParams),"");
cohortDsd.addColumn( "HV01-12", "Tested Positive (20-24, Male)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales(20, 24), indParams),"");
cohortDsd.addColumn( "HV01-14", "Tested Positive (25+, Male)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveMales25AndAbove(25), indParams),"");

cohortDsd.addColumn( "HV01-07", "Tested Positive (2-9, Female)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales(2, 9), indParams), "");
cohortDsd.addColumn( "HV01-09", "Tested Positive (10-14, Female)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales(10,14), indParams), "");
cohortDsd.addColumn( "HV01-11", "Tested Positive (15-19, Female)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales(15, 19), indParams), "");
cohortDsd.addColumn( "HV01-13", "Tested Positive (20-24, Female)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales(20, 24), indParams), "");
cohortDsd.addColumn( "HV01-15", "Tested Positive (25+, Female)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveFemales25AndAbove(25), indParams), "");
cohortDsd.addColumn("HV01-16", "Tested Positive (KVP)", ReportUtils.map(moh731GreenCardIndicators.htsPositiveKVP(), indParams),"");
EmrReportingUtils.addRow(cohortDsd, "HV01", "Tested Discordant", ReportUtils.map(moh731GreenCardIndicators.htsDiscordant(), indParams), genderDisaggregation, Arrays.asList("17", "18"));
//EmrReportingUtils.addRow(cohortDsd, "HV01", "Inconclusive", ReportUtils.map(moh731GreenCardIndicators.inconclusiveResults(), indParams), genderDisaggregation, Arrays.asList("47", "48"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,13 @@ public CohortDefinition testedHIVPositive() {
* HTS +ve tests for Males
* @return
*/
public CohortDefinition htsPositiveMales() {
public CohortDefinition htsPositiveMales(Integer minAge, Integer maxAge) {
String sqlQuery = "select t.encounter_id\n" +
"from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id\n" +
"where t.final_test_result = 'Positive' and Gender = 'M'\n" +
" and t.voided = 0\n" +
" and t.visit_date between date(:startDate) and date(:endDate);";
" from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id\n" +
" where t.final_test_result = 'Positive' and Gender = 'M'\n" +
" and t.voided = 0 and timestampdiff(YEAR, d.DOB, date(:endDate)) between " +minAge+ " and " +maxAge+ "\n" +
" and t.visit_date between date(:startDate) and date(:endDate);";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("htsPositiveMales");
cd.setQuery(sqlQuery);
Expand All @@ -1052,34 +1052,50 @@ public CohortDefinition htsPositiveMales() {
cd.setDescription("htsPositiveMales");
return cd;
}
public CohortDefinition htsPositiveMales25AndAbove(Integer minAge) {
String sqlQuery = "select t.encounter_id\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id\n" +
" where t.final_test_result = 'Positive' and Gender = 'M'\n" +
" and t.voided = 0 and timestampdiff(YEAR, d.DOB, date(:endDate)) >= "+minAge+"\n" +
" and t.visit_date between date(:startDate) and date(:endDate);";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("htsPositiveMales25+");
cd.setQuery(sqlQuery);
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.setDescription("htsPositiveMales25+");
return cd;
}

/**
* HTS +VE tests for females
* @return
*/
public CohortDefinition htsPositiveFemales() {
public CohortDefinition htsPositiveFemales(Integer minAge, Integer maxAge) {
String sqlQuery = "select encounter_id\n" +
"from ((select av.patient_id, av.encounter_id\n" +
" from kenyaemr_etl.etl_mch_antenatal_visit av\n" +
" where av.visit_date between date(:startDate) and date(:endDate)\n" +
" and av.final_test_result = 'Positive')\n" +
" union\n" +
" (select d.patient_id, d.encounter_id\n" +
" from kenyaemr_etl.etl_mchs_delivery d\n" +
" where d.visit_date between date(:startDate) and date(:endDate)\n" +
" and d.final_test_result = 'Positive')\n" +
" union\n" +
" (select p.patient_id, p.encounter_id\n" +
" from kenyaemr_etl.etl_mch_postnatal_visit p\n" +
" where p.visit_date between date(:startDate) and date(:endDate)\n" +
" and p.final_test_result = 'Positive')\n" +
" union\n" +
" (select t.patient_id, t.encounter_id\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id and d.Gender = 'F'\n" +
" where t.final_test_result = 'Positive'\n" +
" and t.voided = 0\n" +
" and t.visit_date between date(:startDate) and date(:endDate))) a;";
" from ((select av.patient_id, av.encounter_id\n" +
" from kenyaemr_etl.etl_mch_antenatal_visit av inner join kenyaemr_etl.etl_patient_demographics a on av.patient_id = a.patient_id\n" +
" where av.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, a.DOB, date(:endDate)) between "+minAge+" and "+maxAge+"\n" +
" and av.final_test_result = 'Positive')\n" +
" union\n" +
" (select d.patient_id, d.encounter_id\n" +
" from kenyaemr_etl.etl_mchs_delivery d inner join kenyaemr_etl.etl_patient_demographics a on a.patient_id = d.patient_id\n" +
" where d.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, a.DOB, date(:endDate)) between "+minAge+" and "+maxAge+"\n" +
" and d.final_test_result = 'Positive')\n" +
" union\n" +
" (select p.patient_id, p.encounter_id\n" +
" from kenyaemr_etl.etl_mch_postnatal_visit p inner join kenyaemr_etl.etl_patient_demographics d on p.patient_id = d.patient_id\n" +
" where p.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, d.DOB, date(:endDate)) between "+minAge+" and "+maxAge+"\n" +
" and p.final_test_result = 'Positive')\n" +
" union\n" +
" (select t.patient_id, t.encounter_id\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id and d.Gender = 'F'\n" +
" where timestampdiff(YEAR, d.DOB, date(:endDate)) between "+minAge+" and "+minAge+"\n" +
" and t.final_test_result = 'Positive'\n" +
" and t.voided = 0\n" +
" and t.visit_date between date(:startDate) and date(:endDate))) a;";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("htsPositiveFemales");
cd.setQuery(sqlQuery);
Expand All @@ -1089,6 +1105,43 @@ public CohortDefinition htsPositiveFemales() {
return cd;
}

/**
* Females tested HIV+ aged 25+
* @param minAge
* @return
*/
public CohortDefinition htsPositiveFemales25AndAbove(Integer minAge) {
String sqlQuery = "select encounter_id\n" +
"from ((select av.patient_id, av.encounter_id\n" +
" from kenyaemr_etl.etl_mch_antenatal_visit av inner join kenyaemr_etl.etl_patient_demographics a on av.patient_id = a.patient_id\n" +
" where av.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, a.DOB, date(:endDate)) >= "+minAge+"\n" +
" and av.final_test_result = 'Positive')\n" +
" union\n" +
" (select d.patient_id, d.encounter_id\n" +
" from kenyaemr_etl.etl_mchs_delivery d inner join kenyaemr_etl.etl_patient_demographics a on a.patient_id = d.patient_id\n" +
" where d.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, a.DOB, date(:endDate)) >= "+minAge+"\n" +
" and d.final_test_result = 'Positive')\n" +
" union\n" +
" (select p.patient_id, p.encounter_id\n" +
" from kenyaemr_etl.etl_mch_postnatal_visit p inner join kenyaemr_etl.etl_patient_demographics d on p.patient_id = d.patient_id\n" +
" where p.visit_date between date(:startDate) and date(:endDate) and timestampdiff(YEAR, d.DOB, date(:endDate)) >= "+minAge+"\n" +
" and p.final_test_result = 'Positive')\n" +
" union\n" +
" (select t.patient_id, t.encounter_id\n" +
" from kenyaemr_etl.etl_hts_test t\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on d.patient_id = t.patient_id and d.Gender = 'F'\n" +
" where timestampdiff(YEAR, d.DOB, date(:endDate)) >= "+minAge+"\n" +
" and t.final_test_result = 'Positive'\n" +
" and t.voided = 0\n" +
" and t.visit_date between date(:startDate) and date(:endDate))) a;";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("htsPositiveFemales25+");
cd.setQuery(sqlQuery);
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.setDescription("htsPositiveFemales25+");
return cd;
}
/**
* Number of cleints who tested HIV +VE
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ public CohortIndicator htsNumberTestedKVP() {
public CohortIndicator testedHIVPositive() {
return cohortIndicator("Tested HIV Positive", map(moh731Cohorts.testedHIVPositive(), "startDate=${startDate},endDate=${endDate}"));
}
public CohortIndicator htsPositiveMales() {
return cohortIndicator("HTS Positive males", map(moh731Cohorts.htsPositiveMales(), "startDate=${startDate},endDate=${endDate}"));
public CohortIndicator htsPositiveMales(Integer minAge, Integer maxAge) {
return cohortIndicator("HTS Positive males", map(moh731Cohorts.htsPositiveMales(minAge, maxAge), "startDate=${startDate},endDate=${endDate}"));
}
public CohortIndicator htsPositiveMales25AndAbove(Integer minAge) {
return cohortIndicator("HTS Positive males 25+", map(moh731Cohorts.htsPositiveMales25AndAbove(minAge), "startDate=${startDate},endDate=${endDate}"));
}

public CohortIndicator htsPositiveFemales() {
return cohortIndicator("HTS Positive females", map(moh731Cohorts.htsPositiveFemales(), "startDate=${startDate},endDate=${endDate}"));
public CohortIndicator htsPositiveFemales(Integer minAge, Integer maxAge) {
return cohortIndicator("HTS Positive females", map(moh731Cohorts.htsPositiveFemales(minAge, maxAge), "startDate=${startDate},endDate=${endDate}"));
}

public CohortIndicator htsPositiveFemales25AndAbove(Integer minAge) {
return cohortIndicator("HTS Positive Females 25+", map(moh731Cohorts.htsPositiveFemales25AndAbove(minAge), "startDate=${startDate},endDate=${endDate}"));
}
public CohortIndicator htsPositiveKVP() {
return cohortIndicator("HTS Positive KVP", map(moh731Cohorts.htsPositiveKVP(), "startDate=${startDate},endDate=${endDate}"));
}
Expand Down
Binary file modified omod/src/main/webapp/resources/reports/moh731_revised.xls
Binary file not shown.

0 comments on commit b8dea1a

Please sign in to comment.