Skip to content
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 @@ -77,7 +77,8 @@ public String getDescription() {

private Parameter getReportingDateParameter() {
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
return new Parameter("onOrBefore", MessageUtil.translate("commonreports.report.util.reportingEndDate"), Date.class, null, DateUtil.parseDate(today, "yyyy-MM-dd"));
return new Parameter("onOrBefore", MessageUtil.translate("commonreports.report.util.reportingEndDate"), Date.class,
null, DateUtil.parseDate(today, "yyyy-MM-dd"));
}

public static String col1 = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package org.openmrs.module.commonreports.reports;

import static org.openmrs.module.commonreports.common.Helper.getStringFromResource;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;

import org.openmrs.module.commonreports.ActivatedReportManager;
import org.openmrs.module.initializer.api.InitializerService;
import org.openmrs.module.reporting.common.MessageUtil;
import org.openmrs.module.reporting.dataset.definition.SqlDataSetDefinition;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;
import org.openmrs.module.reporting.evaluation.parameter.Mapped;
import org.openmrs.module.reporting.report.ReportDesign;
import org.openmrs.module.reporting.report.definition.ReportDefinition;
import org.openmrs.module.reporting.report.manager.ReportManagerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DRCMissedAppointmentReportManager extends ActivatedReportManager {

@Autowired
private InitializerService inizService;

@Override
public boolean isActivated() {
return true;
}

@Override
public String getVersion() {
return "1.0.0-SNAPSHOT";
}

@Override
public String getUuid() {
return "82a51c4b-acd3-4868-a0fb-74cf01c61479";
}

@Override
public String getName() {
return "Missed Appointments Report";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't these return the translatable strings (as in MessageUtil.translate(...))?

}

@Override
public String getDescription() {
return "Missed Appointments Report";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We do the translation here too

}

@Override
public List<Parameter> getParameters() {
return Arrays.asList(
new Parameter("startDate", MessageUtil.translate("commonreports.report.util.startDate"), Date.class),
new Parameter("endDate", MessageUtil.translate("commonreports.report.util.endDate"), Date.class));
}

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

SqlDataSetDefinition sqlDsd = new SqlDataSetDefinition();
sqlDsd.setName(MessageUtil.translate("commonreports.report.missedAppointments.datasetName"));
sqlDsd.setDescription(MessageUtil.translate("commonreports.report.missedAppointments.datasetDescription"));
String sql = getStringFromResource("org/openmrs/module/commonreports/sql/missedAppointments.sql");
sqlDsd.setSqlQuery(sql);
sqlDsd.addParameters(getParameters());

Map<String, Object> parameterMappings = new HashMap<String, Object>();
parameterMappings.put("startDate", "${startDate}");
parameterMappings.put("endDate", "${endDate}");

rd.addDataSetDefinition(getName(), sqlDsd, parameterMappings);
return rd;
}

@Override
public List<ReportDesign> constructReportDesigns(ReportDefinition reportDefinition) {
ReportDesign reportDesign = ReportManagerUtil.createCsvReportDesign("86cc3558-8181-4fc3-aac4-fdb738f7c888",
reportDefinition);
return Arrays.asList(reportDesign);
}
}
6 changes: 5 additions & 1 deletion api/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,8 @@ ${project.parent.artifactId}.report.appointments.datasetDescription=
commonreports.report.disbursement.reportName= Disbursement Report
commonreports.report.disbursement.reportDescription=
commonreports.report.disbursement.datasetName=Disbursement SQL Dataset
commonreports.report.disbursement.datasetDescription=
commonreports.report.disbursement.datasetDescription=

${project.parent.artifactId}.report.missedAppointments.reportDescription=Missed Appointments Report
${project.parent.artifactId}.report.missedAppointments.datasetName=Missed Appointments SQL Dataset
${project.parent.artifactId}.report.missedAppointments.datasetDescription=Missed Appointments SQL Dataset
4 changes: 4 additions & 0 deletions api/src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,7 @@ ${project.parent.artifactId}.report.appointments.reportDescription=Appointments

${project.parent.artifactId}.report.appointments.datasetName=Appointments SQL Dataset
${project.parent.artifactId}.report.appointments.datasetDescription=Appointments SQL Dataset

${project.parent.artifactId}.report.missedAppointments.reportDescription=Missed Appointments Report
${project.parent.artifactId}.report.missedAppointments.datasetName=Missed Appointments SQL Dataset
${project.parent.artifactId}.report.missedAppointments.datasetDescription=Missed Appointments SQL Dataset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Things I'm not quite clear how this report handles:

  1. Isn't there potentially some duplication between the "Next Appointment Date" and actual schedule appointments? How do we deduplicate those?
  2. Isn't this just a list of appointments? I.e., I don't see how this filters out appointments that have been attended (I wouldn't expect that this is done via voiding an appointment).
  3. How do we filter patients who have either died or have transferred out of care?

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
SELECT DISTINCT
p.patient_id,
pn.given_name,
pn.family_name,
per.gender,
per.birthdate,
o.value_datetime AS missed_date,
'Return visit date' AS source
FROM patient p
JOIN obs o ON p.patient_id = o.person_id
JOIN person per ON p.patient_id = per.person_id
JOIN person_name pn ON per.person_id = pn.person_id
WHERE o.concept_id = 211
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because of the way metadata is loaded, it is not safe to rely on concept_ids being consistent across instances of the same system.

AND o.voided = 0
AND p.voided = 0
AND o.value_datetime BETWEEN :startDate AND :endDate
AND pn.preferred = 1

UNION

SELECT DISTINCT
pa.patient_id,
pn.given_name,
pn.family_name,
per.gender,
per.birthdate,
pa.start_date_time AS missed_date,
'Appointment' AS source
FROM patient_appointment pa
JOIN patient p ON pa.patient_id = p.patient_id
JOIN person per ON p.patient_id = per.person_id
JOIN person_name pn ON per.person_id = pn.person_id
WHERE pa.start_date_time BETWEEN :startDate AND :endDate
AND pa.voided = 0
AND p.voided = 0
AND pn.preferred = 1;