diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/MOH240LabReportBuilder.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/MOH240LabReportBuilder.java new file mode 100644 index 0000000000..36cad609f0 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/MOH240LabReportBuilder.java @@ -0,0 +1,170 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.builder.common; + +import org.openmrs.PatientIdentifierType; +import org.openmrs.PersonAttributeType; +import org.openmrs.api.context.Context; +import org.openmrs.module.kenyacore.report.HybridReportDescriptor; +import org.openmrs.module.kenyacore.report.ReportDescriptor; +import org.openmrs.module.kenyacore.report.ReportUtils; +import org.openmrs.module.kenyacore.report.builder.AbstractHybridReportBuilder; +import org.openmrs.module.kenyacore.report.builder.AbstractReportBuilder; +import org.openmrs.module.kenyacore.report.builder.Builds; +import org.openmrs.module.kenyacore.report.data.patient.definition.CalculationDataDefinition; +import org.openmrs.module.kenyaemr.calculation.library.hiv.CountyAddressCalculation; +import org.openmrs.module.kenyaemr.calculation.library.hiv.SubCountyAddressCalculation; +import org.openmrs.module.kenyaemr.calculation.library.mchcs.PersonAddressCalculation; +import org.openmrs.module.kenyaemr.metadata.CommonMetadata; +import org.openmrs.module.kenyaemr.reporting.calculation.converter.RDQACalculationResultConverter; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.MOH204BRegisterCohortDefinition; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.MOH240LabRegisterCohortDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.CalculationResultConverter; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.HTSProviderDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.*; +import org.openmrs.module.metadatadeploy.MetadataUtils; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition; +import org.openmrs.module.reporting.common.SortCriteria; +import org.openmrs.module.reporting.data.DataDefinition; +import org.openmrs.module.reporting.data.converter.BirthdateConverter; +import org.openmrs.module.reporting.data.converter.DataConverter; +import org.openmrs.module.reporting.data.converter.DateConverter; +import org.openmrs.module.reporting.data.converter.ObjectFormatter; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDatetimeDataDefinition; +import org.openmrs.module.reporting.data.patient.definition.ConvertedPatientDataDefinition; +import org.openmrs.module.reporting.data.patient.definition.PatientIdDataDefinition; +import org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition; +import org.openmrs.module.reporting.data.person.definition.*; +import org.openmrs.module.reporting.dataset.definition.DataSetDefinition; +import org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition; +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.definition.ReportDefinition; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +@Component +@Builds({ "kenyaemr.ehrReports.report.240" }) +public class MOH240LabReportBuilder extends AbstractReportBuilder { + public static final String ENC_DATE_FORMAT = "yyyy/MM/dd"; + public static final String DATE_FORMAT = "dd/MM/yyyy"; + + @Override + protected List getParameters(ReportDescriptor reportDescriptor) { + return Arrays.asList( + new Parameter("startDate", "Start Date", Date.class), + new Parameter("endDate", "End Date", Date.class), + new Parameter("dateBasedReporting", "", String.class) + ); + } + + @Override + protected List> buildDataSets(ReportDescriptor reportDescriptor, ReportDefinition reportDefinition) { + return Arrays.asList( + ReportUtils.map(datasetColumns(), "startDate=${startDate},endDate=${endDate}") + ); + } + + protected DataSetDefinition datasetColumns() { + EncounterDataSetDefinition dsd = new EncounterDataSetDefinition(); + dsd.setName("MOH240"); + dsd.setDescription("OPD Lab Visit information"); + dsd.addSortCriteria("Visit Date", SortCriteria.SortDirection.ASC); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + DataConverter nameFormatter = new ObjectFormatter("{familyName}, {givenName} {middleName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", new PreferredNameDataDefinition(), nameFormatter); + PatientIdentifierType pcn = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.PATIENT_CLINIC_NUMBER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition patientClinicNo = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition(pcn.getName(), pcn), identifierFormatter); + + OPDDateSampleCollectedDataDefinition opdDateSampleCollectedDataDefinition = new OPDDateSampleCollectedDataDefinition(); + opdDateSampleCollectedDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdDateSampleCollectedDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDDateSampleReceivedDataDefinition opdDateSampleReceivedDataDefinition = new OPDDateSampleReceivedDataDefinition(); + opdDateSampleReceivedDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdDateSampleReceivedDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDLabResultsDataDefinition opdLabResultsDataDefinition = new OPDLabResultsDataDefinition(); + opdLabResultsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdLabResultsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDLabResultsDateDataDefinition opdLabResultsDateDataDefinition = new OPDLabResultsDateDataDefinition(); + opdLabResultsDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdLabResultsDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDClinicalDiagnosisDataDefinition opdClinicalDiagnosisDataDefinition = new OPDClinicalDiagnosisDataDefinition(); + opdClinicalDiagnosisDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdClinicalDiagnosisDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDPriorTreatmentsPrescribedDataDefinition opdPriorTreatmentsPrescribedDataDefinition = new OPDPriorTreatmentsPrescribedDataDefinition(); + opdPriorTreatmentsPrescribedDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdPriorTreatmentsPrescribedDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDLabReferralsDataDefinition opdLabReferralsDataDefinition = new OPDLabReferralsDataDefinition(); + opdLabReferralsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdLabReferralsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDLabRemarksDataDefinition opdLabRemarksDataDefinition = new OPDLabRemarksDataDefinition(); + opdLabRemarksDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdLabRemarksDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + OPDInvestigationRequiredDataDefinition opdInvestigationRequiredDataDefinition = new OPDInvestigationRequiredDataDefinition(); + opdInvestigationRequiredDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + opdInvestigationRequiredDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + + + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + + dsd.addColumn("Name", nameDef, ""); + dsd.addColumn("id", new PatientIdDataDefinition(), ""); + dsd.addColumn("Visit Date", new EncounterDatetimeDataDefinition(),"", new DateConverter(ENC_DATE_FORMAT)); + dsd.addColumn("OPD Reference No", patientClinicNo, ""); + dsd.addColumn("Age", new AgeDataDefinition(), ""); + dsd.addColumn("Sex", new GenderDataDefinition(), ""); + dsd.addColumn("Telephone No", new PersonAttributeDataDefinition(phoneNumber), ""); + dsd.addColumn("Visit Date", new EncounterDatetimeDataDefinition(),"", new DateConverter(ENC_DATE_FORMAT)); + dsd.addColumn("County",new CalculationDataDefinition("County", new CountyAddressCalculation()), "",new CalculationResultConverter()); + dsd.addColumn("Sub County", new CalculationDataDefinition("Subcounty", new SubCountyAddressCalculation()), "",new CalculationResultConverter()); + dsd.addColumn("Village", new CalculationDataDefinition("Village/Estate/Landmark", new PersonAddressCalculation()), "",new RDQACalculationResultConverter()); + + dsd.addColumn("Revisit", patientClinicNo, ""); + // dsd.addColumn("Lab Number", opdLabNumberDataDefinition, paramMapping); //TODO: missing as Specimen ID + dsd.addColumn("Clinical Diagnosis",opdClinicalDiagnosisDataDefinition, paramMapping); + dsd.addColumn("Prior Treatment",opdPriorTreatmentsPrescribedDataDefinition, paramMapping); + //dsd.addColumn("Type of Specimen",opdTreatmentPrescribedDataDefinition, paramMapping); //TODO: missing Specimen Type + //dsd.addColumn("Condition of Specimen",opdTreatmentPrescribedDataDefinition, paramMapping); //TODO: missing Specimen Condition + dsd.addColumn("Investigation required",opdInvestigationRequiredDataDefinition, paramMapping); + dsd.addColumn("Date Sample Collected",opdDateSampleCollectedDataDefinition, paramMapping, new DateConverter(ENC_DATE_FORMAT)); + //dsd.addColumn("Date Sample Received",opdDateSampleReceivedDataDefinition, paramMapping); + + dsd.addColumn("Clinician Name", new OPDOrderingClinicianDataDefinition(), null); + //dsd.addColumn("Date Sample Analysed",opdDateSampleReceivedDataDefinition, paramMapping); //TODO: missing Date sample analysed + + dsd.addColumn("Results",opdLabResultsDataDefinition, paramMapping); + //dsd.addColumn("Date results dispatched",opdLabResultsDateDataDefinition, paramMapping); //TODO: missing Date results dispatched + //dsd.addColumn("Amount charged",opdLabResultsDateDataDefinition, paramMapping); //TODO: missing Amount charged + //dsd.addColumn("Receipt number",opdLabResultsDateDataDefinition, paramMapping); //TODO: missing Receipt number + + + dsd.addColumn("Referred to",opdLabReferralsDataDefinition, paramMapping); + dsd.addColumn("Comments",opdLabRemarksDataDefinition, paramMapping); + dsd.addColumn("Analysing Officer",new OPDOrderingClinicianDataDefinition(), null); + + MOH240LabRegisterCohortDefinition cd = new MOH240LabRegisterCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/SetupMOH240LabReportBuilder.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/SetupMOH240LabReportBuilder.java deleted file mode 100644 index 8cd8227038..0000000000 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/common/SetupMOH240LabReportBuilder.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.kenyaemr.reporting.builder.common; - -import org.openmrs.PatientIdentifierType; -import org.openmrs.PersonAttributeType; -import org.openmrs.api.context.Context; -import org.openmrs.module.kenyacore.report.HybridReportDescriptor; -import org.openmrs.module.kenyacore.report.ReportDescriptor; -import org.openmrs.module.kenyacore.report.ReportUtils; -import org.openmrs.module.kenyacore.report.builder.AbstractHybridReportBuilder; -import org.openmrs.module.kenyacore.report.builder.Builds; -import org.openmrs.module.kenyacore.report.data.patient.definition.CalculationDataDefinition; -import org.openmrs.module.kenyaemr.calculation.library.mchcs.PersonAddressCalculation; -import org.openmrs.module.kenyaemr.metadata.CommonMetadata; -import org.openmrs.module.kenyaemr.reporting.calculation.converter.RDQACalculationResultConverter; -import org.openmrs.module.reporting.cohort.definition.CohortDefinition; -import org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition; -import org.openmrs.module.reporting.data.DataDefinition; -import org.openmrs.module.reporting.data.converter.BirthdateConverter; -import org.openmrs.module.reporting.data.converter.DataConverter; -import org.openmrs.module.reporting.data.converter.DateConverter; -import org.openmrs.module.reporting.data.converter.ObjectFormatter; -import org.openmrs.module.reporting.data.encounter.definition.EncounterDatetimeDataDefinition; -import org.openmrs.module.reporting.data.patient.definition.ConvertedPatientDataDefinition; -import org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition; -import org.openmrs.module.reporting.data.person.definition.*; -import org.openmrs.module.reporting.dataset.definition.DataSetDefinition; -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.definition.ReportDefinition; -import org.springframework.stereotype.Component; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -@Component -@Builds({ "kenyaemr.ehrReports.report.240" }) -public class SetupMOH240LabReportBuilder extends AbstractHybridReportBuilder { - - public static final String ENC_DATE_FORMAT = "yyyy/MM/dd"; - - @Override - protected Mapped buildCohort(HybridReportDescriptor hybridReportDescriptor, - PatientDataSetDefinition patientDataSetDefinition) { - return null; - } - - @Override - protected List> buildDataSets(ReportDescriptor descriptor, ReportDefinition report) { - PatientDataSetDefinition dsd = LabRegister(); - dsd.setName("lrr"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - report.setBaseCohortDefinition(ReportUtils.map(getLabOrderEncounter(), "startDate=${startDate},endDate=${endDate}")); - - return Arrays.asList(ReportUtils.map((DataSetDefinition) dsd, "startDate=${startDate},endDate=${endDate}")); - } - - @Override - protected List getParameters(ReportDescriptor reportDescriptor) { - return Arrays.asList(new Parameter("startDate", "Start Date", Date.class), new Parameter("endDate", "End Date", - Date.class), new Parameter("dateBasedReporting", "", String.class)); - } - - private PatientDataSetDefinition LabRegister() { - PatientDataSetDefinition dsd = new PatientDataSetDefinition(); - dsd.setName("lrr"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - dsd.addRowFilter(getLabOrderEncounter(), "startDate=${startDate},endDate=${endDate+23h}"); - DataConverter nameFormatter = new ObjectFormatter("{familyName}, {givenName}, {middleName}"); - DataDefinition nameDef = new ConvertedPersonDataDefinition("name", new PreferredNameDataDefinition(), nameFormatter); - - PersonAttributeType personAttributeType = Context.getPersonService().getPersonAttributeTypeByUuid(CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); - - PatientIdentifierType openmrsID = Context.getPatientService().getPatientIdentifierTypeByUuid("dfacd928-0370-4315-99d7-6ec1c9f7ae76"); - DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); - DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - openmrsID.getName(), openmrsID), identifierFormatter); - - dsd.addColumn("id", new PersonIdDataDefinition(), ""); - dsd.addColumn("identifier", identifierDef, ""); - //dsd.addColumn("Date", new EncounterDatetimeDataDefinition(),"", new DateConverter(ENC_DATE_FORMAT)); - dsd.addColumn("Name", nameDef, ""); - dsd.addColumn("Sex", new GenderDataDefinition(), "", null); - dsd.addColumn("DOB", new BirthdateDataDefinition(), "", new BirthdateConverter("yyyy-MM-dd")); - dsd.addColumn("age", new AgeDataDefinition(), ""); - dsd.addColumn("village", new CalculationDataDefinition("Village/Estate/Landmark", new PersonAddressCalculation()), "",new RDQACalculationResultConverter()); - dsd.addColumn("telephone", new PersonAttributeDataDefinition(personAttributeType), "", - null); - return dsd; - - } - - private CohortDefinition getLabOrderEncounter() { - SqlCohortDefinition sqlEncounterQuery = new SqlCohortDefinition(); - sqlEncounterQuery.setName("Get unique lab encounter types"); - sqlEncounterQuery.addParameter(new Parameter("startDate", "Start Date", Date.class)); - sqlEncounterQuery.addParameter(new Parameter("endDate", "End Date", Date.class)); - sqlEncounterQuery - .setQuery("SELECT d.patient_id FROM kenyaemr_etl.etl_patient_demographics d\n" + - " INNER JOIN kenyaemr_etl.etl_laboratory_extract x ON x.patient_id = d.patient_id\n" + - " AND date(x.visit_date) BETWEEN :startDate AND :endDate;"); - return sqlEncounterQuery; - } - -} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/MOH240LabRegisterCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/MOH240LabRegisterCohortDefinition.java new file mode 100644 index 0000000000..f5e1094dcf --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/MOH240LabRegisterCohortDefinition.java @@ -0,0 +1,43 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition; + +import org.openmrs.Encounter; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; +import org.openmrs.module.reporting.query.BaseQuery; +import org.openmrs.module.reporting.query.encounter.definition.EncounterQuery; + +import java.util.Date; + +/** + * MOH240 Lab Register cohort definition + * OPD Register + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.MOH240LabRegisterCohortDefinition") +public class MOH240LabRegisterCohortDefinition extends BaseQuery implements EncounterQuery { + @ConfigurationProperty + private Date asOfDate; + + public MOH240LabRegisterCohortDefinition() { + } + + public Date getAsOfDate() { + return asOfDate; + } + + public void setAsOfDate(Date asOfDate) { + this.asOfDate = asOfDate; + } + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/MOH240LabRegisterCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/MOH240LabRegisterCohortDefinitionEvaluator.java new file mode 100644 index 0000000000..689b9a73ab --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/MOH240LabRegisterCohortDefinitionEvaluator.java @@ -0,0 +1,61 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.MOH204BRegisterCohortDefinition; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.MOH240LabRegisterCohortDefinition; +import org.openmrs.module.reporting.common.ObjectUtil; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.openmrs.module.reporting.query.encounter.EncounterQueryResult; +import org.openmrs.module.reporting.query.encounter.definition.EncounterQuery; +import org.openmrs.module.reporting.query.encounter.evaluator.EncounterQueryEvaluator; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * Evaluator for patients MOH240 Lab Cohort Evaluator + * OPD Register + */ +@Handler(supports = {MOH240LabRegisterCohortDefinition.class}) +public class MOH240LabRegisterCohortDefinitionEvaluator implements EncounterQueryEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + @Autowired + EvaluationService evaluationService; + + public EncounterQueryResult evaluate(EncounterQuery definition, EvaluationContext context) throws EvaluationException { + context = ObjectUtil.nvl(context, new EvaluationContext()); + EncounterQueryResult queryResult = new EncounterQueryResult(definition, context); + + String qry = "SELECT le.encounter_id from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_patient_demographics p on p.patient_id = le.patient_id and p.voided = 0\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + builder.addParameter("endDate", endDate); + builder.addParameter("startDate", startDate); + + List results = evaluationService.evaluateToList(builder, Integer.class, context); + queryResult.getMemberIds().addAll(results); + return queryResult; + } + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDClinicalDiagnosisDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDClinicalDiagnosisDataEvaluator.java new file mode 100644 index 0000000000..eaff987d16 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDClinicalDiagnosisDataEvaluator.java @@ -0,0 +1,61 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDClinicalDiagnosisDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDDiagnosisDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Clinical Diagnosis + * MOH 240 Lab Register Register + */ +@Handler(supports= OPDClinicalDiagnosisDataDefinition.class, order=50) +public class OPDClinicalDiagnosisDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select\n" + + " le.encounter_id,\n" + + " dl.name as clinical_diagnosis\n" + + " from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join (select\n" + + " cn.name, ed.date_created, ed.dx_rank ,ed.patient_id\n" + + " from openmrs.encounter_diagnosis ed\n" + + " inner join openmrs.concept_name cn on cn.concept_id = ed.diagnosis_coded and cn.locale = 'en' and ed.dx_rank = 1\n" + + " ) dl on le.patient_id = dl.patient_id and date(dl.date_created) = date(le.visit_date)\n" + + " and date(le.visit_Date) between date(:startDate) and date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleCollectedDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleCollectedDataEvaluator.java new file mode 100644 index 0000000000..4ff674303f --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleCollectedDataEvaluator.java @@ -0,0 +1,54 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDDateSampleCollectedDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDSpecimenTypeDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Date sample collected + * OPD Lab Register + */ +@Handler(supports= OPDDateSampleCollectedDataDefinition.class, order=50) +public class OPDDateSampleCollectedDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "SELECT le.encounter_id, le.date_test_requested from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_patient_demographics p on p.patient_id = le.patient_id and p.voided = 0\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleReceivedDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleReceivedDataEvaluator.java new file mode 100644 index 0000000000..88dfdfab68 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDateSampleReceivedDataEvaluator.java @@ -0,0 +1,54 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDDateSampleCollectedDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDDateSampleReceivedDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Date sample collected + * OPD Lab Register + */ +@Handler(supports= OPDDateSampleReceivedDataDefinition.class, order=50) +public class OPDDateSampleReceivedDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "SELECT le.encounter_id, le.date_test_result_received from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_patient_demographics p on p.patient_id = le.patient_id and p.voided = 0\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDiagnosisDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDiagnosisDataEvaluator.java index 6d58c301ad..d694769c81 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDiagnosisDataEvaluator.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDDiagnosisDataEvaluator.java @@ -37,14 +37,15 @@ public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, Evalu EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); String qry = "select\n" + - " v.encounter_id,\n" + - " con.name as mnci_diagnosis\n" + - "from kenyaemr_etl.etl_clinical_encounter v\n" + - " inner join (select\n" + - " cn.name, cn.date_created, ed.patient_id\n" + - " from encounter_diagnosis ed\n" + - " inner join concept_name cn on cn.concept_id = ed.diagnosis_coded and cn.locale = 'en'\n" + - ") con on v.patient_id = con.patient_id and date(v.visit_Date) between date(:startDate) and date(:endDate);"; + " v.encounter_id,\n" + + " con.name as mnci_diagnosis\n" + + " from kenyaemr_etl.etl_clinical_encounter v\n" + + " inner join (select\n" + + " cn.name, cn.date_created, ed.patient_id\n" + + " from encounter_diagnosis ed\n" + + " inner join concept_name cn on cn.concept_id = ed.diagnosis_coded and cn.locale = 'en'\n" + + " and date(ed.date_created) between date(:startDate) and date(:endDate)\n" + + " ) con on v.patient_id = con.patient_id and date(v.visit_Date) between date(:startDate) and date(:endDate);"; SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); queryBuilder.append(qry); diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDInvestigationRequiredDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDInvestigationRequiredDataEvaluator.java new file mode 100644 index 0000000000..39952b2511 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDInvestigationRequiredDataEvaluator.java @@ -0,0 +1,57 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDClinicalDiagnosisDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDInvestigationRequiredDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Investigation Required + * MOH 240 Lab Register Register + */ +@Handler(supports= OPDInvestigationRequiredDataDefinition.class, order=50) +public class OPDInvestigationRequiredDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select le.encounter_id,\n" + + " cn.name as investigation_required\n" + + "from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join openmrs.concept_name cn on cn.concept_id = le.lab_test and cn.locale = 'en'\n" + + "where date(le.visit_date) between date(:startDate) and date(:endDate)\n" + + "group by le.encounter_id;"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabReferralsDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabReferralsDataEvaluator.java new file mode 100644 index 0000000000..5d0c0340fa --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabReferralsDataEvaluator.java @@ -0,0 +1,57 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabReferralsDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabResultsDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Lab referrals + * MOH 240 Lab Register + */ +@Handler(supports= OPDLabReferralsDataDefinition.class, order=50) +public class OPDLabReferralsDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select\n" + + "le.encounter_id,\n" + + " (case v.referral_to when 'This health facility' then 1 when 'Other health facility' then 2 when 'Community Unit' then 3 else '' end) as referred_to\n" + + " from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_clinical_encounter v on v.patient_id = le.patient_id and date(v.visit_date) = date(le.visit_date)\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabRemarksDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabRemarksDataEvaluator.java new file mode 100644 index 0000000000..33ffc35856 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabRemarksDataEvaluator.java @@ -0,0 +1,56 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabRemarksDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Lab remarks + * MOH 240 Lab Register + */ +@Handler(supports= OPDLabRemarksDataDefinition.class, order=50) +public class OPDLabRemarksDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select\n" + + " le.encounter_id,\n" + + " p.notes\n" + + "from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_progress_note p on p.patient_id = le.patient_id and date(p.visit_date) = date(le.visit_date)\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDataEvaluator.java new file mode 100644 index 0000000000..3c656b430b --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDataEvaluator.java @@ -0,0 +1,54 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDClinicalDiagnosisDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabResultsDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Lab results + * MOH 240 Lab Register + */ +@Handler(supports= OPDLabResultsDataDefinition.class, order=50) +public class OPDLabResultsDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "SELECT le.encounter_id, le.test_result FROM kenyaemr_etl.etl_laboratory_extract le\n" + + " INNER JOIN kenyaemr_etl.etl_patient_demographics p ON p.patient_id = le.patient_id AND p.voided = 0\n" + + "WHERE date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDateDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDateDataEvaluator.java new file mode 100644 index 0000000000..5abea5bd05 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDLabResultsDateDataEvaluator.java @@ -0,0 +1,54 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabResultsDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDLabResultsDateDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Lab results date + * MOH 240 Lab Register + */ +@Handler(supports= OPDLabResultsDateDataDefinition.class, order=50) +public class OPDLabResultsDateDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "SELECT le.encounter_id, le.date_test_result_received from kenyaemr_etl.etl_laboratory_extract le\n" + + " inner join kenyaemr_etl.etl_patient_demographics p on p.patient_id = le.patient_id and p.voided = 0\n" + + "where date(le.visit_date) BETWEEN date(:startDate) AND date(:endDate);"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDOrderingClinicianDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDOrderingClinicianDataEvaluator.java new file mode 100644 index 0000000000..9ccccad0aa --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDOrderingClinicianDataEvaluator.java @@ -0,0 +1,56 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDDateSampleReceivedDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDOrderingClinicianDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Date sample collected + * OPD Lab Register + */ +@Handler(supports= OPDOrderingClinicianDataDefinition.class, order=50) +public class OPDOrderingClinicianDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select e.encounter_id, concat_ws(' ', pn.family_name, pn.given_name, pn.middle_name) as creator \n" + + " from encounter e\n" + + " inner join encounter_provider ep on ep.encounter_id=e.encounter_id\n" + + " inner join provider p on ep.provider_id = p.provider_id\n" + + " inner join person_name pn on pn.person_id = p.person_id ;"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDPriorTreatmentsPrescribedDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDPriorTreatmentsPrescribedDataEvaluator.java new file mode 100644 index 0000000000..e70d2502f2 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDPriorTreatmentsPrescribedDataEvaluator.java @@ -0,0 +1,59 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDPriorTreatmentsPrescribedDataDefinition; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDTreatmentPrescribedDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates prior lab treatment prescribed + * OPD Register + */ +@Handler(supports= OPDPriorTreatmentsPrescribedDataDefinition.class, order=50) +public class OPDPriorTreatmentsPrescribedDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = "select le.encounter_id,\n" + + " d.drug_name\n" + + " from kenyaemr_etl.etl_laboratory_extract le\n" + + " INNER JOIN kenyaemr_etl.etl_drug_order d ON le.patient_id = d.patient_id\n" + + " and d.enc_name = 'Drug Order'\n" + + " and date(d.visit_date) = date(le.visit_date)\n" + + " where date(le.visit_date) between date(:startDate) and date(:endDate)\n" + + " group by d.encounter_id"; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDSpecimenTypeDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDSpecimenTypeDataEvaluator.java new file mode 100644 index 0000000000..2eee28a9c1 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/opd/OPDSpecimenTypeDataEvaluator.java @@ -0,0 +1,51 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.evaluator.opd; + +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd.OPDSpecimenTypeDataDefinition; +import org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.data.encounter.evaluator.EncounterDataEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.Map; + +/** + * Evaluates Specimen Type + * OPD Lab Register + */ +@Handler(supports= OPDSpecimenTypeDataDefinition.class, order=50) +public class OPDSpecimenTypeDataEvaluator implements EncounterDataEvaluator { + + @Autowired + private EvaluationService evaluationService; + + public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { + EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); + + String qry = ""; + + SqlQueryBuilder queryBuilder = new SqlQueryBuilder(); + queryBuilder.append(qry); + Date startDate = (Date)context.getParameterValue("startDate"); + Date endDate = (Date)context.getParameterValue("endDate"); + queryBuilder.addParameter("endDate", endDate); + queryBuilder.addParameter("startDate", startDate); + Map data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); + c.setData(data); + return c; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDClinicalDiagnosisDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDClinicalDiagnosisDataDefinition.java new file mode 100644 index 0000000000..09ecc2f5fb --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDClinicalDiagnosisDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Diagnosis + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDClinicalDiagnosisDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDClinicalDiagnosisDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDClinicalDiagnosisDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleCollectedDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleCollectedDataDefinition.java new file mode 100644 index 0000000000..ff6e3c4082 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleCollectedDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** +// * OPD labs Date sample collected Column + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDDateSampleCollectedDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDDateSampleCollectedDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDDateSampleCollectedDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleReceivedDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleReceivedDataDefinition.java new file mode 100644 index 0000000000..3053d10348 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDDateSampleReceivedDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** +// * OPD labs Date sample received Column + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDDateSampleReceivedDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDDateSampleReceivedDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDDateSampleReceivedDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDInvestigationRequiredDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDInvestigationRequiredDataDefinition.java new file mode 100644 index 0000000000..f6a427f295 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDInvestigationRequiredDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Investigation Required + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDInvestigationRequiredDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDInvestigationRequiredDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDInvestigationRequiredDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabReferralsDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabReferralsDataDefinition.java new file mode 100644 index 0000000000..e9c49e82e4 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabReferralsDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Lab Referrals + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDLabReferralsDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDLabReferralsDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDLabReferralsDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabRemarksDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabRemarksDataDefinition.java new file mode 100644 index 0000000000..01de4a3a86 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabRemarksDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Lab Remarks + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDLabRemarksDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDLabRemarksDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDLabRemarksDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDataDefinition.java new file mode 100644 index 0000000000..f7b1c52562 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Lab Results + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDLabResultsDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDLabResultsDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDLabResultsDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDateDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDateDataDefinition.java new file mode 100644 index 0000000000..545cf735dc --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDLabResultsDateDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * OPD Lab Results Date + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDLabResultsDateDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDLabResultsDateDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDLabResultsDateDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDOrderingClinicianDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDOrderingClinicianDataDefinition.java new file mode 100644 index 0000000000..7c2dda7f71 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDOrderingClinicianDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** +// * OPD labs Ordering clinician Column + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDOrderingClinicianDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDOrderingClinicianDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDOrderingClinicianDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDPriorTreatmentsPrescribedDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDPriorTreatmentsPrescribedDataDefinition.java new file mode 100644 index 0000000000..e9bdbb5e38 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDPriorTreatmentsPrescribedDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** +// * OPD Prior labs Treatment prescribed Column + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDPriorTreatmentsPrescribedDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDPriorTreatmentsPrescribedDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDPriorTreatmentsPrescribedDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDSpecimenTypeDataDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDSpecimenTypeDataDefinition.java new file mode 100644 index 0000000000..0b9303286a --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/opd/OPDSpecimenTypeDataDefinition.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.data.converter.definition.opd; + +import org.openmrs.module.reporting.data.BaseDataDefinition; +import org.openmrs.module.reporting.data.encounter.definition.EncounterDataDefinition; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** +// * OPD labs Specimen Type Column + */ +@Caching(strategy=ConfigurationPropertyCachingStrategy.class) +public class OPDSpecimenTypeDataDefinition extends BaseDataDefinition implements EncounterDataDefinition { + + public static final long serialVersionUID = 1L; + + /** + * Default Constructor + */ + public OPDSpecimenTypeDataDefinition() { + super(); + } + + /** + * Constructor to populate name only + */ + public OPDSpecimenTypeDataDefinition(String name) { + super(name); + } + + //***** INSTANCE METHODS ***** + + /** + * @see org.openmrs.module.reporting.data.DataDefinition#getDataType() + */ + public Class getDataType() { + return Double.class; + } +} diff --git a/api/src/main/resources/content/kenyaemr.common.xml b/api/src/main/resources/content/kenyaemr.common.xml index e2b3c8cf73..f32d15d200 100644 --- a/api/src/main/resources/content/kenyaemr.common.xml +++ b/api/src/main/resources/content/kenyaemr.common.xml @@ -1004,7 +1004,7 @@ - + diff --git a/omod/src/main/webapp/resources/reports/MOH240.xls b/omod/src/main/webapp/resources/reports/MOH240.xls index 4f45cb3180..2b038c3a27 100644 Binary files a/omod/src/main/webapp/resources/reports/MOH240.xls and b/omod/src/main/webapp/resources/reports/MOH240.xls differ