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

MEPTS - 1529 | Lista de Faltosos & Abandonos Diff in FGH DB #1296

Open
wants to merge 11 commits into
base: 2.x_develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@

CohortDefinition transferred = getPatientsTransferredOut(transferredOut, transferOutState);

CohortDefinition artPickup = getTransferredOutBetweenNextPickupDateFilaAndRecepcaoLevantou();
CohortDefinition artPickup =
getTransferredOutBetweenNextPickupDateFilaAndRecepcaoLevantou(true);

Check warning on line 431 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java#L430-L431

Added lines #L430 - L431 were not covered by tests

cd.addSearch(
"transferredOut",
Expand Down Expand Up @@ -876,7 +877,8 @@
*
* @return {@link CohortDefinition}
*/
public CohortDefinition getTransferredOutBetweenNextPickupDateFilaAndRecepcaoLevantou() {
public CohortDefinition getTransferredOutBetweenNextPickupDateFilaAndRecepcaoLevantou(
boolean endDate) {

SqlCohortDefinition definition = new SqlCohortDefinition();
definition.setName(
Expand Down Expand Up @@ -906,9 +908,13 @@
+ " AND e.voided = 0 "
+ " AND o.voided = 0 "
+ " AND e.encounter_type = ${18} "
+ " AND o.concept_id = ${5096} "
+ " AND e.encounter_datetime <= :endDate "
+ " AND e.location_id = :location "
+ " AND o.concept_id = ${5096} ";
query +=
endDate
? " AND e.encounter_datetime <= :endDate "
: " AND e.encounter_datetime <= CURRENT_DATE() ";
query +=

Check warning on line 916 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java#L916

Added line #L916 was not covered by tests
" AND e.location_id = :location "
+ " GROUP BY p.patient_id "
+ " UNION "
+ " SELECT p.patient_id, "
Expand All @@ -922,14 +928,21 @@
+ " AND e.voided = 0 "
+ " AND o.voided = 0 "
+ " AND e.encounter_type = ${52} "
+ " AND o.concept_id = ${23866} "
+ " AND o.value_datetime <= :endDate "
+ " AND e.location_id = :location "
+ " AND o.concept_id = ${23866} ";
query +=
endDate
? " AND e.encounter_datetime <= :endDate "
: " AND e.encounter_datetime <= CURRENT_DATE() ";
query +=

Check warning on line 936 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/HivCohortQueries.java#L936

Added line #L936 was not covered by tests
" AND e.location_id = :location "
+ " GROUP BY p.patient_id "
+ " ) considered_transferred "
+ " GROUP BY considered_transferred.patient_id "
+ " ) final "
+ " WHERE final.max_date <= :endDate ";
+ " ) final ";
query +=
endDate
? " WHERE final.max_date <= :endDate "
: " WHERE final.max_date <= CURRENT_DATE() ";

StringSubstitutor stringSubstitutor = new StringSubstitutor(valuesMap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@
valuesMap.put("165322", hivMetadata.getMdcState().getConceptId());
valuesMap.put("1256", hivMetadata.getStartDrugs().getConceptId());
valuesMap.put("1257", hivMetadata.getContinueRegimenConcept().getConceptId());
valuesMap.put("1267", hivMetadata.getCompletedConcept().getConceptId());

Check warning on line 475 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L475

Added line #L475 was not covered by tests

String query =
"SELECT dispensation.patient_id, "
Expand Down Expand Up @@ -515,6 +516,7 @@

StringSubstitutor sb = new StringSubstitutor(valuesMap);
sqlPatientDataDefinition.setQuery(sb.replace(query));
System.out.println(sqlPatientDataDefinition.getQuery());

Check warning on line 519 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L519

Added line #L519 was not covered by tests

return sqlPatientDataDefinition;
}
Expand All @@ -523,50 +525,65 @@
MDC1 {
@Override
public String getQuery() {
return " ( SELECT obs.value_coded "
+ "FROM obs "
+ "WHERE obs.encounter_id = dispensation.encounter_id "
+ " AND obs.concept_id = 165174 "
return " ( SELECT o1.value_coded "

Check warning on line 528 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L528

Added line #L528 was not covered by tests
+ "FROM obs o1 JOIN obs o2 ON o1.encounter_id = o2.encounter_id "
+ "WHERE o1.encounter_id = dispensation.encounter_id "
+ " AND o1.concept_id = ${165174} "
+ " AND o2.concept_id = ${165322} "
+ " AND o2.value_coded != ${1267} "
+ " AND o1.obs_group_id = o2.obs_group_id "
+ "LIMIT 1 ) MDC1 ";
}
},
MDC2 {
@Override
public String getQuery() {
return " ( SELECT obs.value_coded "
+ "FROM obs "
+ "WHERE obs.encounter_id = dispensation.encounter_id "
+ " AND obs.concept_id = 165174 "
+ "LIMIT 1,1 ) MDC2 ";
return "( SELECT o1.value_coded "

Check warning on line 541 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L541

Added line #L541 was not covered by tests
+ " FROM obs o1 JOIN obs o2 ON o1.encounter_id = o2.encounter_id "
+ " WHERE o1.encounter_id = dispensation.encounter_id "
+ " AND o1.concept_id = ${165174} "
+ " AND o2.concept_id = ${165322} "
+ " AND o2.value_coded != ${1267} "
+ " AND o1.obs_group_id = o2.obs_group_id "
+ " LIMIT 1,1 ) MDC2";
}
},
MDC3 {
@Override
public String getQuery() {
return " ( SELECT obs.value_coded "
+ "FROM obs "
+ "WHERE obs.encounter_id = dispensation.encounter_id "
+ " AND obs.concept_id = 165174 "
return " ( SELECT o1.value_coded "

Check warning on line 554 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L554

Added line #L554 was not covered by tests
+ "FROM obs o1 JOIN obs o2 ON o1.encounter_id = o2.encounter_id "
+ "WHERE o1.encounter_id = dispensation.encounter_id "
+ " AND o1.concept_id = ${165174} "
+ " AND o2.concept_id = ${165322} "
+ " AND o2.value_coded != ${1267} "
+ " AND o1.obs_group_id = o2.obs_group_id "
+ "LIMIT 2,1 ) MDC3 ";
}
},
MDC4 {
@Override
public String getQuery() {
return " ( SELECT obs.value_coded "
+ "FROM obs "
+ "WHERE obs.encounter_id = dispensation.encounter_id "
+ " AND obs.concept_id = 165174 "
return " ( SELECT o1.value_coded "

Check warning on line 567 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L567

Added line #L567 was not covered by tests
+ "FROM obs o1 JOIN obs o2 ON o1.encounter_id = o2.encounter_id "
+ "WHERE o1.encounter_id = dispensation.encounter_id "
+ " AND o1.concept_id = ${165174} "
+ " AND o2.concept_id = ${165322} "
+ " AND o2.value_coded != ${1267} "
+ " AND o1.obs_group_id = o2.obs_group_id "
+ "LIMIT 3,1 ) MDC4 ";
}
},
MDC5 {
@Override
public String getQuery() {
return " ( SELECT obs.value_coded "
+ "FROM obs "
+ "WHERE obs.encounter_id = dispensation.encounter_id "
+ " AND obs.concept_id = 165174 "
return " ( SELECT o1.value_coded "

Check warning on line 580 in api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ListOfPatientsCurrentlyOnArtWithoutTbScreeningCohortQueries.java#L580

Added line #L580 was not covered by tests
+ "FROM obs o1 JOIN obs o2 ON o1.encounter_id = o2.encounter_id "
+ "WHERE o1.encounter_id = dispensation.encounter_id "
+ " AND o1.concept_id = ${165174} "
+ " AND o2.concept_id = ${165322} "
+ " AND o2.value_coded != ${1267} "
+ " AND o1.obs_group_id = o2.obs_group_id "
+ "LIMIT 4,1 ) MDC5 ";
}
};
Expand Down
Loading