forked from I-TECH/openmrs-module-kenyaemr
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creation of 407A and 407B nutrition report
- Loading branch information
1 parent
0e01dfb
commit 3ebab9f
Showing
68 changed files
with
3,350 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
258 changes: 258 additions & 0 deletions
258
.../main/java/org/openmrs/module/kenyaemr/reporting/builder/common/MOH407BReportBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
181 changes: 157 additions & 24 deletions
181
.../org/openmrs/module/kenyaemr/reporting/builder/common/NutritionRegisterReportBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../openmrs/module/kenyaemr/reporting/cohort/definition/MOH407BRegisterCohortDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* 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; | ||
|
||
/** | ||
* NutritionRegister cohort definition | ||
*/ | ||
@Caching(strategy = ConfigurationPropertyCachingStrategy.class) | ||
@Localized("reporting.MOH407BRegisterCohortDefinition") | ||
public class MOH407BRegisterCohortDefinition extends BaseQuery<Encounter> implements EncounterQuery { | ||
@ConfigurationProperty | ||
private Date asOfDate; | ||
|
||
public MOH407BRegisterCohortDefinition() { | ||
} | ||
|
||
public Date getAsOfDate() { | ||
return asOfDate; | ||
} | ||
|
||
public void setAsOfDate(Date asOfDate) { | ||
this.asOfDate = asOfDate; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...yaemr/reporting/cohort/definition/evaluator/MOH407BRegisterCohortDefinitionEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* 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.MOH407BRegisterCohortDefinition; | ||
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 for Nutrition Register | ||
* | ||
*/ | ||
@Handler(supports = {MOH407BRegisterCohortDefinition.class}) | ||
public class MOH407BRegisterCohortDefinitionEvaluator 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 nt.encounter_id FROM kenyaemr_etl.etl_nutrition nt INNER JOIN kenyaemr_etl.etl_patient_demographics p \n" + | ||
"ON p.patient_id = nt.patient_id AND p.voided = 0\n" + | ||
"WHERE timestampdiff(YEAR, date(p.DOB), (SELECT MAX(nt2.visit_date) FROM kenyaemr_etl.etl_nutrition nt2 \n" + | ||
"WHERE nt2.patient_id = nt.patient_id)) <= 15 \n" + | ||
"AND date(nt.visit_date) BETWEEN date(:startDate) AND date(:endDate) AND nt.voided = 0;"; | ||
|
||
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<Integer> results = evaluationService.evaluateToList(builder, Integer.class, context); | ||
queryResult.getMemberIds().addAll(results); | ||
return queryResult; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...ing/data/converter/definition/evaluator/nutrition/NutritionAnaemiaLevelDataEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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.NutritionAnaemiaLevelDataDefinition; | ||
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= NutritionAnaemiaLevelDataDefinition.class, order=50) | ||
public class NutritionAnaemiaLevelDataEvaluator implements EncounterDataEvaluator { | ||
|
||
@Autowired | ||
private EvaluationService evaluationService; | ||
|
||
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { | ||
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); | ||
|
||
String qry = "SELECT encounter_id,\n" + | ||
"(case anaemia_level when 1118 then 'Not Done' when 1115 then 'Normal' when 1498 then 'Mild' when 1499 then 'Moderate' when 1500 then 'Severe' else '' end) as anaemia_level\n" + | ||
"FROM kenyaemr_etl.etl_nutrition\n" + | ||
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" + | ||
"GROUP BY 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<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); | ||
c.setData(data); | ||
return c; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../reporting/data/converter/definition/evaluator/nutrition/NutritionCadreDataEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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.NutritionCadreDataDefinition; | ||
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= NutritionCadreDataDefinition.class, order=50) | ||
public class NutritionCadreDataEvaluator implements EncounterDataEvaluator { | ||
|
||
@Autowired | ||
private EvaluationService evaluationService; | ||
|
||
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { | ||
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); | ||
|
||
String qry = "SELECT encounter_id,\n" + | ||
"(case cadre when 900009 then 'Nutritionist' when 1577 then 'Nurse' when 162591 then 'Doctor' when 1574 then 'Clinical Officer' when 5622 then 'Others' else '' end) as cadre\n" + | ||
"FROM kenyaemr_etl.etl_nutrition\n" + | ||
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" + | ||
"GROUP BY 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<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); | ||
c.setData(data); | ||
return c; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...nverter/definition/evaluator/nutrition/NutritionCoexialMedicalConditionDataEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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.NutritionCoexialMedicalConditionDataDefinition; | ||
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; | ||
|
||
/** | ||
* Nutrition Coexial Medical Condition | ||
*/ | ||
@Handler(supports= NutritionCoexialMedicalConditionDataDefinition.class, order=50) | ||
public class NutritionCoexialMedicalConditionDataEvaluator implements EncounterDataEvaluator { | ||
|
||
@Autowired | ||
private EvaluationService evaluationService; | ||
|
||
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { | ||
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); | ||
|
||
String qry = "SELECT encounter_id,\n" + | ||
"(case medication_condition when 112141 then 'TB' when 119481 then 'Diabetes' when 117399 then 'Hypertension' when 5622 then 'Other' else '' end) as medication_condition\n" + | ||
"FROM kenyaemr_etl.etl_nutrition\n" + | ||
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" + | ||
"GROUP BY 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<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); | ||
c.setData(data); | ||
return c; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../converter/definition/evaluator/nutrition/NutritionCriteriaForAdmissionDataEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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.NutritionCriteriaForAdmissionDataDefinition; | ||
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= NutritionCriteriaForAdmissionDataDefinition.class, order=50) | ||
public class NutritionCriteriaForAdmissionDataEvaluator implements EncounterDataEvaluator { | ||
|
||
@Autowired | ||
private EvaluationService evaluationService; | ||
|
||
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException { | ||
EvaluatedEncounterData c = new EvaluatedEncounterData(definition, context); | ||
|
||
String qry = "SELECT encounter_id,\n" + | ||
"(case criteria_for_admission when 1362 then 'Edema +' when 1363 then 'Edema ++' when 1364 then 'Edema +++' when 1343 then 'MUAC' when 162584 then 'WHZ' when 1342 then 'BMI for Age' else '' end) as criteria_for_admission\n" + | ||
"FROM kenyaemr_etl.etl_nutrition\n" + | ||
"WHERE DATE(visit_date) between date(:startDate) and date(:endDate)\n" + | ||
"GROUP BY 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<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context); | ||
c.setData(data); | ||
return c; | ||
} | ||
} |
Oops, something went wrong.