Skip to content

Commit

Permalink
added height in Active on ART Line list
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Apr 6, 2022
1 parent 5a4e479 commit ced397b
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ protected PatientDataSetDefinition activePatientsDataSetDefinition(String datase
dsd.addColumn("Age at reporting", ageAtReportingDataDefinition, "endDate=${endDate}");
//dsd.addColumn("Age", new AgeDataDefinition(), "", new DataConverter[0]);
dsd.addColumn("Weight", new WeightAtArtDataDefinition(), "");
dsd.addColumn("Height", new HeightAtArtDataDefinition(), "");
dsd.addColumn("Population Type", new ActivePatientsPopulationTypeDataDefinition(), "");
dsd.addColumn("Date confirmed positive", new CalculationDataDefinition("Date confirmed positive", new DateConfirmedHivPositiveCalculation()), "", new DateArtStartDateConverter());
dsd.addColumn("Enrollment Date", new CalculationDataDefinition("Enrollment Date", new DateOfEnrollmentArtCalculation()), "", new DateArtStartDateConverter());
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.art;

import org.openmrs.module.reporting.data.BaseDataDefinition;
import org.openmrs.module.reporting.data.person.definition.PersonDataDefinition;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;

/**
* Art Cohort Height Data Definition
*/
@Caching(strategy=ConfigurationPropertyCachingStrategy.class)
public class HeightAtArtDataDefinition extends BaseDataDefinition implements PersonDataDefinition {

public static final long serialVersionUID = 1L;

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

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

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

/**
* @see org.openmrs.module.reporting.data.DataDefinition#getDataType()
*/
public Class<?> getDataType() {
return Double.class;
}
}
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.evaluator.art;

import org.openmrs.annotation.Handler;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.HeightAtArtDataDefinition;
import org.openmrs.module.reporting.data.person.EvaluatedPersonData;
import org.openmrs.module.reporting.data.person.definition.PersonDataDefinition;
import org.openmrs.module.reporting.data.person.evaluator.PersonDataEvaluator;
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.Map;

/**
* Evaluates Current Height Data Definition
*/
@Handler(supports=HeightAtArtDataDefinition.class, order=50)
public class HeightAtArtDataEvaluator implements PersonDataEvaluator {

@Autowired
private EvaluationService evaluationService;

public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedPersonData c = new EvaluatedPersonData(definition, context);

String qry = "select t.patient_id,\n" +
" mid(max(concat(t.visit_date,t.height)),11) as height from kenyaemr_etl.etl_patient_triage t inner join kenyaemr_etl.etl_patient_hiv_followup f on t.patient_id = f.patient_id and t.visit_date = f.visit_date\n" +
"GROUP BY t.patient_id;";

SqlQueryBuilder queryBuilder = new SqlQueryBuilder();
queryBuilder.append(qry);
Map<Integer, Object> data = evaluationService.evaluateToMap(queryBuilder, Integer.class, Object.class, context);
c.setData(data);
return c;
}
}

0 comments on commit ced397b

Please sign in to comment.