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.
- Loading branch information
1 parent
386da2c
commit 58a2959
Showing
10 changed files
with
117 additions
and
8 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
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
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
57 changes: 57 additions & 0 deletions
57
...orting/data/converter/definition/evaluator/nutrition/NutritionDiagnosisDataEvaluator.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,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; | ||
} | ||
} |
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
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
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
47 changes: 47 additions & 0 deletions
47
...yaemr/reporting/data/converter/definition/nutrition/NutritionDiagnosisDataDefinition.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,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 not shown.
Binary file not shown.