-
Notifications
You must be signed in to change notification settings - Fork 2
DRC-7: Add missed appointments report as initial work for Treatment interruptions and loss of follow-up #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDescription() { | ||
| return "Missed Appointments Report"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Things I'm not quite clear how this report handles:
|
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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; | ||
There was a problem hiding this comment.
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(...))?