Skip to content

Commit

Permalink
Addition of Diagnosis column
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel090 committed Dec 13, 2024
1 parent 386da2c commit 58a2959
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ protected DataSetDefinition datasetColumns() {
nutritionCadreDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
nutritionCadreDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));

NutritionDiagnosisDataDefinition nutritionDiagnosisDataDefinition = new NutritionDiagnosisDataDefinition();
nutritionDiagnosisDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
nutritionDiagnosisDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));


PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT);

Expand Down Expand Up @@ -236,6 +240,7 @@ protected DataSetDefinition datasetColumns() {
dsd.addColumn("Metabolic Disorders", nutritionMetabolicDisordersDataDefinition, paramMapping);
dsd.addColumn("Latest CD4 Count", nutritionLatestCD4CountDataDefinition, paramMapping);
dsd.addColumn("Latest CD4 Count Date", nutritionLatestCD4CountDateDataDefinition, paramMapping);
dsd.addColumn("Diagnosis",nutritionDiagnosisDataDefinition,paramMapping);
dsd.addColumn("Maternal Nutrition", nutritionMaternalNutritionDataDefinition, paramMapping);
dsd.addColumn("Critical Nutrition Practices", nutritionCriticalNutritionPracticesDataDefinition, paramMapping);
dsd.addColumn("Therapeutic Foods", nutritionTherapeuticFoodsDataDefinition, paramMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ protected DataSetDefinition datasetColumns() {
nutritionCadreDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
nutritionCadreDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));

NutritionDiagnosisDataDefinition nutritionDiagnosisDataDefinition = new NutritionDiagnosisDataDefinition();
nutritionDiagnosisDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
nutritionDiagnosisDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));

PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT);

Expand Down Expand Up @@ -236,6 +239,7 @@ protected DataSetDefinition datasetColumns() {
dsd.addColumn("Latest CD4 Count", nutritionLatestCD4CountDataDefinition, paramMapping);
dsd.addColumn("Latest CD4 Count Date", nutritionLatestCD4CountDateDataDefinition, paramMapping);
dsd.addColumn("Maternal Nutrition", nutritionMaternalNutritionDataDefinition, paramMapping);
dsd.addColumn("Diagnosis",nutritionDiagnosisDataDefinition,paramMapping);
dsd.addColumn("Critical Nutrition Practices", nutritionCriticalNutritionPracticesDataDefinition, paramMapping);
dsd.addColumn("Therapeutic Foods", nutritionTherapeuticFoodsDataDefinition, paramMapping);
dsd.addColumn("Supplemental Foods", nutritionSupplementalFoodsDataDefinition, paramMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class NutritionCriticalNutritionPracticesDataEvaluator implements Encount
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context);

String qry = "SELECT encounter_id,\n" +
"(case critical_nutrition_practices when 1107 then 'None' when 163300 then 'Nutrition status assessment' when 161648 then 'Dietary/Energy needs' when 1906 then 'Sanitation' when 135797 then 'Positive living behaviour' when 159364 then 'Exercise' when 154358 then 'Safe drinking water' when 1611 then 'Prompt treatment for Opportunistic Infections' when 164377 then 'Drug food interactions side effects' else '' end) as critical_nutrition_practices\n" +
String qry = "SELECT encounter_id,critical_nutrition_practices\n" +
"FROM kenyaemr_etl.etl_nutrition\n" +
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" +
"GROUP BY encounter_id;";
Expand Down
Original file line number Diff line number Diff line change
@@ -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.nutrition;

import org.openmrs.annotation.Handler;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.nutrition.NutritionDiagnosisDataDefinition;
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;

/**
*
*/
@Handler(supports= NutritionDiagnosisDataDefinition.class, order=50)
public class NutritionDiagnosisDataEvaluator implements EncounterDataEvaluator {

@Autowired
private EvaluationService evaluationService;

public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context);

String qry = "select v.encounter_id,\n" +
"con.name as mnci_diagnosis\n" +
"from kenyaemr_etl.etl_nutrition 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);
Date startDate = (Date)context.getParameterValue("startDate");
Date endDate = (Date)context.getParameterValue("endDate");
queryBuilder.addParameter("endDate", endDate);
queryBuilder.addParameter("startDate", startDate);
Map<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context);
c.setData(data);
return c;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class NutritionMetabolicDisordersDataEvaluator implements EncounterDataEv
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context);

String qry = "SELECT encounter_id,\n" +
"(case metabolic_disorders when 1107 then 'None' when 135761 then 'Lypodystrophy' when 141623 then 'Dyslipidemia' when 142473 then 'Type II Diabetes' else '' end) as metabolic_disorders\n" +
String qry = "SELECT encounter_id,metabolic_disorders\n" +
"FROM kenyaemr_etl.etl_nutrition\n" +
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" +
"GROUP BY encounter_id;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class NutritionSupplementalFoodsDataEvaluator implements EncounterDataEva
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context);

String qry = "SELECT encounter_id,\n" +
"(case supplemental_food when 1107 then 'None' when 159597 then 'FBF' when 162758 then 'CSB' when 166382 then 'RUSF' when 165577 then 'Liquid nutrition supplements' when 5622 then 'Others' else '' end) as supplemental_food\n" +
String qry = "SELECT encounter_id,supplemental_food\n" +
"FROM kenyaemr_etl.etl_nutrition\n" +
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" +
"GROUP BY encounter_id;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class NutritionTherapeuticFoodsDataEvaluator implements EncounterDataEval
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context);

String qry = "SELECT encounter_id,\n" +
"(case therapeutic_food when 1107 then 'None' when 163394 then 'RUTF' when 163404 then 'F-75' when 167247 then 'F-100' when 159854 then 'Fiesmol' when 5622 then 'Others' else '' end) as therapeutic_food\n" +
String qry = "SELECT encounter_id, therapeutic_food\n" +
"FROM kenyaemr_etl.etl_nutrition\n" +
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" +
"GROUP BY encounter_id;";
Expand Down
Original file line number Diff line number Diff line change
@@ -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.nutrition;

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;

/**
*
*/
@Caching(strategy=ConfigurationPropertyCachingStrategy.class)
public class NutritionDiagnosisDataDefinition extends BaseDataDefinition implements EncounterDataDefinition {

public static final long serialVersionUID = 1L;

/**
* Default Constructor
*/
public NutritionDiagnosisDataDefinition() {
super();
}

/**
* Constructor to populate name only
*/
public NutritionDiagnosisDataDefinition(String name) {
super(name);
}

//***** INSTANCE METHODS *****

/**
* @see org.openmrs.module.reporting.data.DataDefinition#getDataType()
*/
public Class<?> getDataType() {
return Double.class;
}
}
Binary file modified omod/src/main/webapp/resources/reports/MOH407A.xls
Binary file not shown.
Binary file modified omod/src/main/webapp/resources/reports/MOH407B.xls
Binary file not shown.

0 comments on commit 58a2959

Please sign in to comment.