Skip to content

Commit

Permalink
Merge pull request #5 from emaposse/REPORT-104
Browse files Browse the repository at this point in the history
DSD-DENOMINATOR-ACTIVE-ELEG-DSD:Number of active patients on ART
  • Loading branch information
steliomo authored Nov 13, 2019
2 parents e5dab86 + 39e4a55 commit 59def50
Show file tree
Hide file tree
Showing 8 changed files with 1,258 additions and 420 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package org.openmrs.module.eptsreports.reporting.library.cohorts;

import java.util.Date;
import org.openmrs.Location;
import org.openmrs.module.eptsreports.reporting.library.queries.DsdQueriesInterface;
import org.openmrs.module.eptsreports.reporting.library.queries.TxCurrQueries;
import org.openmrs.module.eptsreports.reporting.utils.EptsReportUtils;
import org.openmrs.module.reporting.cohort.definition.CohortDefinition;
import org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition;
import org.openmrs.module.reporting.definition.library.DocumentedDefinition;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DSDCohortQueries {

@Autowired private GenericCohortQueries genericCohorts;

@DocumentedDefinition(value = "patientsActiveOnArtExcludingPregnantBreastfeedingAndTb")
public CohortDefinition getPatientsActiveOnArtExcludingPregnantBreastfeedingAndTb(
final String cohortName) {

final CompositionCohortDefinition dsd = new CompositionCohortDefinition();

dsd.setName(cohortName);
dsd.addParameter(new Parameter("startDate", "Start Date", Date.class));
dsd.addParameter(new Parameter("endDate", "End Date", Date.class));
dsd.addParameter(new Parameter("location", "location", Location.class));

String mappings = "startDate=${startDate},endDate=${endDate},location=${location}";

dsd.addSearch(
"IN-ART",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"IN-ART", TxCurrQueries.QUERY.findPatientsWhoAreCurrentlyEnrolledOnART),
mappings));

dsd.addSearch(
"PREGNANT-BRESTFEETING",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"PREGNANT-BRESTFEETING",
DsdQueriesInterface.QUERY
.findPregnantWomenRegisteredInTheLast9MonthsOrBrestfeetingWomenRegisteredInTheLast18Months),
mappings));

dsd.addSearch(
"TB",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"TB", DsdQueriesInterface.QUERY.findPatientsBeingOnTuberculosisTreatmentEndPeriod),
mappings));

dsd.setCompositionString("IN-ART NOT (PREGNANT-BRESTFEETING OR TB)");

return dsd;
}

@DocumentedDefinition(value = "patientsActiveInArtEligibleForDsd")
public CohortDefinition getPatientsActiveOnArtEligibleForDsd(final String cohortName) {

final CompositionCohortDefinition dsd = new CompositionCohortDefinition();

dsd.setName(cohortName);
dsd.addParameter(new Parameter("startDate", "Start Date", Date.class));
dsd.addParameter(new Parameter("endDate", "End Date", Date.class));
dsd.addParameter(new Parameter("location", "location", Location.class));

String mappings = "startDate=${startDate},endDate=${endDate},location=${location}";

dsd.addSearch(
"IN-ART",
EptsReportUtils.map(
getPatientsActiveOnArtExcludingPregnantBreastfeedingAndTb(""), mappings));

dsd.addSearch(
"STABLE",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"findPatientsInArtWhoAreStable",
DsdQueriesInterface.QUERY.findPatientsInArtWhoAreStable),
mappings));

dsd.addSearch(
"SARCOMA-KAPOSI",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"SARCOMA-KAPOSI",
DsdQueriesInterface.QUERY.findPatientsWhoHaveBeenNotifiedOfKaposiSarcoma),
mappings));

dsd.addSearch(
"ADVERSASE-REACTIONS",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"ADVERSASE-REACTIONS",
DsdQueriesInterface.QUERY
.findPatientsWithAdverseDrugReactionsRequiringRegularMonitoringNotifiedInLast6Months),
mappings));

dsd.setCompositionString("(IN-ART AND STABLE) NOT(ADVERSASE-REACTIONS OR SARCOMA-KAPOSI)");

return dsd;
}

@DocumentedDefinition(value = "patientsWhoNotElegibleDSD")
public CohortDefinition getPatientsActiveOnArtNotEligibleForDsd(final String cohortName) {

final CompositionCohortDefinition dsd = new CompositionCohortDefinition();

dsd.setName(cohortName);
dsd.addParameter(new Parameter("startDate", "Start Date", Date.class));
dsd.addParameter(new Parameter("endDate", "End Date", Date.class));
dsd.addParameter(new Parameter("location", "location", Location.class));

String mappings = "startDate=${startDate},endDate=${endDate},location=${location}";

dsd.addSearch(
"IN-ART",
EptsReportUtils.map(
getPatientsActiveOnArtExcludingPregnantBreastfeedingAndTb(""), mappings));

dsd.addSearch(
"STABLE",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"findPatientsInArtWhoAreStable",
DsdQueriesInterface.QUERY.findPatientsInArtWhoAreStable),
mappings));

dsd.addSearch(
"SARCOMA-KAPOSI",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"SARCOMA-KAPOSI",
DsdQueriesInterface.QUERY.findPatientsWhoHaveBeenNotifiedOfKaposiSarcoma),
mappings));

dsd.addSearch(
"ADVERSASE-REACTIONS",
EptsReportUtils.map(
this.genericCohorts.generalSql(
"ADVERSASE-REACTIONS",
DsdQueriesInterface.QUERY
.findPatientsWithAdverseDrugReactionsRequiringRegularMonitoringNotifiedInLast6Months),
mappings));

dsd.setCompositionString(
"IN-ART NOT((STABLE AND IN-ART) NOT(ADVERSASE-REACTIONS OR SARCOMA-KAPOSI))");

return dsd;
}
}
Loading

0 comments on commit 59def50

Please sign in to comment.