Skip to content

Commit

Permalink
KHP3-285: KNH/KDO patient summary
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel090 committed Apr 8, 2022
1 parent d09244e commit ea2c578
Show file tree
Hide file tree
Showing 5 changed files with 2,084 additions and 1,681 deletions.
11 changes: 11 additions & 0 deletions api/src/main/distro/metadata/concepts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,16 @@
<ref key= "RESPIRATORY_RATE" uuid="5242AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<ref key= "OXYGEN_SATURATION" uuid="5092AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<ref key= "LMP" uuid="1427AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<ref key= "TB_START_DATE" uuid="1113AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<ref key= "TB_END_DATE" uuid="159431AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<ref key= "CACX_SCREENING" uuid="06398e78-0d3e-43d5-8017-f2fc3865e2e0" />
<ref key= "TB_SCREENING" uuid="cddbf6fe-4bcd-40b6-a7ea-8573e4080192" />
<ref key= "STI_SCREENING" uuid="ec1b6d72-728f-4ab0-a4e4-7335731075b9" />
<ref key= "KDOD_NUMBER" uuid="b51ffe55-3e76-44f8-89a2-14f5eaf11079" />
<ref key= "KDOD_CADRE" uuid="96a99acd-2f11-45bb-89f7-648dbcac5ddf" />
<ref key= "KDOD_RANK" uuid="9f1f8254-20ea-4be4-a14d-19201fe217bf" />
<ref key= "KDOD_UNIT" uuid="848f5688-41c6-464c-b078-ea6524a3e971" />



</refs>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* 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.calculation.library.hiv.art;
import org.openmrs.Obs;
import org.openmrs.Patient;
import org.openmrs.Program;
import org.openmrs.api.PatientService;
import org.openmrs.api.PersonService;
import org.openmrs.api.context.Context;
import org.openmrs.calculation.patient.PatientCalculationContext;
import org.openmrs.calculation.result.CalculationResultMap;
import org.openmrs.calculation.result.SimpleResult;
import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation;
import org.openmrs.module.kenyacore.calculation.Calculations;
import org.openmrs.module.kenyacore.calculation.Filters;
import org.openmrs.module.kenyaemr.Dictionary;
import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils;
import org.openmrs.module.kenyaemr.metadata.MchMetadata;
import org.openmrs.module.metadatadeploy.MetadataUtils;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
* Calculate the bmi at last visit
*/
public class BMICalculation extends AbstractPatientCalculation {

@Override
public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) {

CalculationResultMap weightMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.WEIGHT_KG), cohort, context);
CalculationResultMap heightMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.HEIGHT_CM), cohort, context);


PersonService service = Context.getPersonService();


CalculationResultMap ret = new CalculationResultMap();
for (Integer ptId : cohort) {

Double visitWeight = null;
Double visitHeight = null;
String bmiStr = null;

Obs lastWeightObs = EmrCalculationUtils.obsResultForPatient(weightMap, ptId);
Obs lastHeightObs = EmrCalculationUtils.obsResultForPatient(heightMap, ptId);
//find pregnancy obs

if (lastHeightObs !=null && lastWeightObs != null ){
visitHeight = lastHeightObs.getValueNumeric();
visitWeight = lastWeightObs.getValueNumeric();
Double bmi = visitWeight / ((visitHeight/100) * (visitHeight/100));
bmiStr = String.format("%.2f", bmi);
ret.put(ptId, new SimpleResult(bmiStr, this, context));
}
}
return ret;
}
}

Loading

0 comments on commit ea2c578

Please sign in to comment.