-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be0dd7a
commit 0ea218f
Showing
4 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
api/src/main/java/org/openmrs/module/ugandaemrreports/reports/SetUpLostReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package org.openmrs.module.ugandaemrreports.reports; | ||
|
||
import org.openmrs.module.reporting.cohort.definition.CohortDefinition; | ||
import org.openmrs.module.reporting.data.patient.library.BuiltInPatientDataLibrary; | ||
import org.openmrs.module.reporting.data.person.definition.BirthdateDataDefinition; | ||
import org.openmrs.module.reporting.data.person.definition.GenderDataDefinition; | ||
import org.openmrs.module.reporting.data.person.definition.PreferredNameDataDefinition; | ||
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.library.*; | ||
import org.openmrs.module.ugandaemrreports.metadata.HIVMetadata; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Daily Appointments List report | ||
*/ | ||
@Component | ||
public class SetUpLostReport extends UgandaEMRDataExportManager { | ||
|
||
@Autowired | ||
private DataFactory df; | ||
|
||
@Autowired | ||
ARTClinicCohortDefinitionLibrary hivCohorts; | ||
|
||
@Autowired | ||
private BuiltInPatientDataLibrary builtInPatientData; | ||
|
||
@Autowired | ||
private HIVPatientDataLibrary hivPatientData; | ||
|
||
@Autowired | ||
private BasePatientDataLibrary basePatientData; | ||
|
||
@Autowired | ||
private HIVMetadata hivMetadata; | ||
|
||
@Autowired | ||
private HIVCohortDefinitionLibrary hivCohortDefinitionLibrary; | ||
|
||
|
||
/** | ||
* @return the uuid for the report design for exporting to Excel | ||
*/ | ||
@Override | ||
public String getExcelDesignUuid() { | ||
return "34213c70-36bd-4e7a-8e76-9ded9e8c8397"; | ||
} | ||
|
||
@Override | ||
public String getUuid() { | ||
return "6325ccbd-2d98-4e8c-bc1c-befc2eb0dfa5"; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "LOST CLIENTS"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "LOST CLIENTS"; | ||
} | ||
|
||
@Override | ||
public List<Parameter> getParameters() { | ||
List<Parameter> l = new ArrayList<Parameter>(); | ||
l.add(df.getStartDateParameter()); | ||
l.add(df.getEndDateParameter()); | ||
return l; | ||
} | ||
|
||
@Override | ||
public List<ReportDesign> constructReportDesigns(ReportDefinition reportDefinition) { | ||
List<ReportDesign> l = new ArrayList<ReportDesign>(); | ||
l.add(buildReportDesign(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, "Lost.xls"); | ||
Properties props = new Properties(); | ||
props.put("repeatingSections", "sheet:1,row:7,dataset:LOST_CLIENTS"); | ||
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()); | ||
|
||
|
||
CohortDefinition deadPatients = df.getDeadPatientsDuringPeriod(); | ||
CohortDefinition transferedOut = hivCohortDefinitionLibrary.getPatientsTransferredOutDuringPeriod(); | ||
CohortDefinition patientsDeadAndtransferedOut =df.getPatientsInAny(deadPatients,transferedOut); | ||
CohortDefinition allLostClients = df.getLostClients(); | ||
|
||
PatientDataSetDefinition dsd = new PatientDataSetDefinition(); | ||
|
||
CohortDefinition definition = df.getPatientsNotIn(allLostClients,patientsDeadAndtransferedOut); | ||
|
||
dsd.setName(getName()); | ||
dsd.setParameters(getParameters()); | ||
dsd.addRowFilter(Mapped.mapStraightThrough(definition)); | ||
dsd.addColumn("Patient Name", new PreferredNameDataDefinition(), (String) null); | ||
dsd.addColumn("Sex", new GenderDataDefinition(), (String) null); | ||
dsd.addColumn("Birth Date", new BirthdateDataDefinition(), (String) null); | ||
addColumn(dsd, "Age", builtInPatientData.getAgeAtStart()); | ||
addColumn(dsd, "Telephone", basePatientData.getTelephone()); | ||
addColumn(dsd, "HIV Enrolled Date", hivPatientData.getEnrollmentDate()); | ||
addColumn(dsd, "ART Start Date", hivPatientData.getArtStartDate()); | ||
addColumn(dsd, "Current Regimen",hivPatientData.getCurrentRegimen()); | ||
addColumn(dsd, "Last Visit Date",hivPatientData.getLastVisitDate()); | ||
addColumn(dsd, "Last Appointment",hivPatientData.getExpectedReturnDate()); | ||
|
||
rd.addDataSetDefinition("LOST_CLIENTS", Mapped.mapStraightThrough(dsd)); | ||
rd.setBaseCohortDefinition(Mapped.mapStraightThrough(definition)); | ||
|
||
return rd; | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return "0.4"; | ||
} | ||
} |
Binary file added
BIN
+71.5 KB
api/src/main/resources/org/openmrs/module/ugandaemrreports/reports/Lost.xls
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters