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

Patients on CRPDDP Program generated with field columns #323

Open
wants to merge 1 commit into
base: master
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 @@ -346,6 +346,14 @@ public PatientDataDefinition getExpectedReturnDateAtLocation(Concept question, L

}

public PatientDataDefinition getLatestARTVisitDate(Location location) {
EncountersForPatientDataDefinition def = PatientColumns.createEncountersForPatientDataDefinition(Arrays.asList(Dictionary.getEncounterType("8d5b2be0-c2cc-11de-8d13-0010c6dffd0f")), "onOrBefore");
def.setWhich(TimeQualifier.LAST);
def.setLocationList(Arrays.asList(location));
def.addParameter(new Parameter("onOrBefore", "On or Before", Date.class));
return createPatientDataDefinition(def, getEncounterDatetimeConverter(), "onOrBefore=endDate");
}

public PatientDataDefinition getObsDuringPeriod(Concept question, List<EncounterType> encounterTypes, TimeQualifier timeQualifier, String olderThan, DataConverter converter) {
ObsForPersonDataDefinition def = PatientColumns.createObsForPersonData(question, encounterTypes, Arrays.asList("onOrBefore", "onOrAfter"), timeQualifier);
String startDate = Parameters.createParameterBeforeDuration("onOrAfter", "startDate", olderThan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ public ProgramWorkflowState getThirdLineRegimenState() {
return Context.getProgramWorkflowService().getStateByUuid(Metadata.ProgramState.HIV_PROGRAM_STATE_THIRD_LINE_REGIMEN);
}

public ProgramWorkflowState getCRPDDPState() {
return Context.getProgramWorkflowService().getStateByUuid(Metadata.Concept.CDDP_PROGRAM_STATE_CRPDDP_STATE);
}

public List<EncounterType> getSMCEncounterType() {
List<EncounterType> l = new ArrayList<EncounterType>();
l.add(MetadataUtils.existing(EncounterType.class, "244da86d-f80e-48fe-aba9-067f241905ee"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ public static class Concept {
public static final String ASPHYXIA = "121397AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String SYPHILLS_TEST = "275a6f72-b8a4-4038-977a-727552f69cb8";
public static final String SYPHILLS_TEST_PARTNER = "d8bc9915-ed4b-4df9-9458-72ca1bc2cd06";
public static final String ANC_VISIT_NUMBER = "c0b1b5f1-a692-49d1-9a69-ff901e07fa27";

public final static String CDDP_PROGRAM_STATE_CRPDDP_STATE = "a6a0ab45-b7dc-43b2-b28c-45a91f968ebf";

public static final String ANC_VISIT_NUMBER = "c0b1b5f1-a692-49d1-9a69-ff901e07fa27";
public static final String FIRST_ANC_VISIT = "588ac57f-a4d0-47c2-9852-92502194ec4a";
public static final String SECOND_ANC_VISIT = "a3ff912e-8298-4743-84cb-62e267c91b58";
public static final String THIRD_ANC_VISIT = "6fd18b93-4c93-417c-9844-b53f467e9a13";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package org.openmrs.module.ugandaemrreports.reports;

import org.openmrs.Location;
import org.openmrs.module.reporting.cohort.definition.CohortDefinition;
import org.openmrs.module.reporting.common.TimeQualifier;
import org.openmrs.module.reporting.data.patient.library.BuiltInPatientDataLibrary;
import org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition;
import org.openmrs.module.reporting.evaluation.parameter.Mapped;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;
import org.openmrs.module.reporting.report.ReportDesign;
import org.openmrs.module.reporting.report.definition.ReportDefinition;
import org.openmrs.module.ugandaemrreports.definition.data.converter.BirthDateConverter;
import org.openmrs.module.ugandaemrreports.library.*;
import org.openmrs.module.ugandaemrreports.metadata.HIVMetadata;
import org.openmrs.module.ugandaemrreports.reporting.dataset.definition.SharedDataDefintion;
import org.openmrs.module.ugandaemrreports.reporting.metadata.Dictionary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
* Patients on ART Access CRPDDP Program
*/
@Component
public class SetUpPatientsOnARTAccessReport extends UgandaEMRDataExportManager {

@Autowired
private DataFactory df;

@Autowired
ARTClinicCohortDefinitionLibrary hivCohorts;

@Autowired
private BuiltInPatientDataLibrary builtInPatientData;

@Autowired
HIVCohortDefinitionLibrary hivCohortDefinitionLibrary;

@Autowired
SharedDataDefintion sdd;

@Autowired
private HIVPatientDataLibrary hivPatientData;

@Autowired
private HIVMetadata hivMetadata;

@Autowired
private CommonDimensionLibrary commonDimensionLibrary;

/**
* @return the uuid for the report design for exporting to Excel
*/
@Override
public String getExcelDesignUuid() {
return "3050a89b-a50f-47e8-b420-ef9ac761d033";
}

public String getCSVDesignUuid() {
return "3aa0f2d7-4172-498f-9794-b1e0e90da809";
}

@Override
public String getUuid() {
return "1cd3041d-5779-42c3-81b9-9617cba26be0";
}

@Override
public String getName() {
return "Patients on CRPDDP Program";
}

@Override
public String getDescription() {
return "List of Patients expected to be on CRPDDP Program";
}

@Override
public List<Parameter> getParameters() {
List<Parameter> l = new ArrayList<Parameter>();
l.add(df.getEndDateParameter());
return l;
}

public ReportDesign buildCSVReportDesign(ReportDefinition reportDefinition) {
ReportDesign rd = createCSVDesign(getCSVDesignUuid(), reportDefinition);
return rd;
}

@Override
public List<ReportDesign> constructReportDesigns(ReportDefinition reportDefinition) {
List<ReportDesign> l = new ArrayList<ReportDesign>();
l.add(buildReportDesign(reportDefinition));
l.add(buildCSVReportDesign(reportDefinition));
return l;
}

/**
* Build the report design for the specified report, this allows a user to override the report design by adding
* properties and other metadata to the report design
*
* @param reportDefinition
* @return The report design
*/
@Override

public ReportDesign buildReportDesign(ReportDefinition reportDefinition) {
ReportDesign rd = createExcelTemplateDesign(getExcelDesignUuid(), reportDefinition, "CRPDDP_PatientList.xls");
Properties props = new Properties();
props.put("repeatingSections", "sheet:1,row:3,dataset:CRPDDP");
props.put("sortWeight", "5000");
rd.setProperties(props);
return rd;
}

@Override
public ReportDefinition constructReportDefinition() {
ReportDefinition rd = new ReportDefinition();
rd.setUuid(getUuid());
rd.setName(getName());
rd.setDescription(getDescription());
rd.setParameters(getParameters());

PatientDataSetDefinition dsd = new PatientDataSetDefinition();
Location ART_Clinician = commonDimensionLibrary.getLocationByUuid("86863db4-6101-4ecf-9a86-5e716d6504e4");
Location Pharmacy = commonDimensionLibrary.getLocationByUuid("3ec8ff90-3ec1-408e-bf8c-22e4553d6e17");

CohortDefinition patientsOnCRPDDP = df.getWorkFlowStateCohortDefinition(hivMetadata.getCRPDDPState());
dsd.setName(getName());
dsd.setParameters(getParameters());
dsd.addRowFilter(Mapped.mapStraightThrough(patientsOnCRPDDP));
addColumn(dsd, "Clinic number", hivPatientData.getClinicNumber());
addColumn(dsd, "Surname", builtInPatientData.getPreferredFamilyName());
addColumn(dsd, "Given Name", builtInPatientData.getPreferredGivenName());
addColumn(dsd, "Sex", builtInPatientData.getGender());
dsd.addColumn("Birth Date", builtInPatientData.getBirthdate(), "", new BirthDateConverter());
addColumn(dsd, "Art Start Date", hivPatientData.getArtStartDate());
addColumn(dsd, "Current Regimen", hivPatientData.getCurrentRegimen());
addColumn(dsd,"Last Facility Visit Date", df.getLatestARTVisitDate(ART_Clinician));
addColumn(dsd,"Last Pharmacy Visit Date", df.getLatestARTVisitDate(Pharmacy));
addColumn(dsd,"Pharmacy Return Date", hivPatientData.getLastReturnDateByEndDate());
addColumn(dsd,"Next facility Return Date",df.getObsByEndDate(Dictionary.getConcept("f6c456f7-1ab4-4b4d-a3b4-e7417c81002a"), Arrays.asList(hivMetadata.getARTEncounterEncounterType()), TimeQualifier.LAST,df.getObsValueDatetimeConverter()));
addColumn(dsd,"refillPointCode",df.getObsByEndDate(Dictionary.getConcept("7a22cfcb-a272-4eff-968c-5e9467125a7b"), Arrays.asList(hivMetadata.getARTEncounterEncounterType()), TimeQualifier.LAST,df.getObsValueTextConverter()));
rd.addDataSetDefinition("CRPDDP", Mapped.mapStraightThrough(dsd));
rd.setBaseCohortDefinition(Mapped.mapStraightThrough(patientsOnCRPDDP));

return rd;
}

@Override
public String getVersion() {
return "0.1.4";
}
}
Binary file not shown.
8 changes: 8 additions & 0 deletions omod/src/main/resources/apps/ugandaemr_reports_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@
"url": "reportingui/runReport.page?reportDefinition=22a58e5e-2535-44f3-a710-3856154ca29f",
"order":15,
"requiredPrivilege": "App: ugandaemrreports.recencyHTSClientCardDataExport"
},{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why HTS Recency App Privileges

"id": "Patients on CRPDDP Program",
"extensionPointId": "org.openmrs.module.ugandaemr.integrationdataexports",
"type": "link",
"label": "Patients on CRPDDP Program",
"url": "reportingui/runReport.page?reportDefinition=1cd3041d-5779-42c3-81b9-9617cba26be0",
"order":15,
"requiredPrivilege": "App: ugandaemrreports.recencyHTSClientCardDataExport"
},
{
"id": "HMIS 105 Section 2",
Expand Down