use of org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition in project openmrs-module-pihcore by PIH.
the class BmiEncounterDataEvaluator method evaluate.
@Override
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
ObsForEncounterDataDefinition weightDataDefinition = new ObsForEncounterDataDefinition();
weightDataDefinition.setQuestion(Metadata.getConcept("PIH:WEIGHT (KG)"));
weightDataDefinition.setSingleObs(true);
EvaluatedEncounterData weights = encounterDataService.evaluate(weightDataDefinition, context);
ObsForEncounterDataDefinition heightDataDefinition = new ObsForEncounterDataDefinition();
heightDataDefinition.setQuestion(Metadata.getConcept("PIH:HEIGHT (CM)"));
heightDataDefinition.setSingleObs(true);
EvaluatedEncounterData heights = encounterDataService.evaluate(heightDataDefinition, context);
EvaluatedEncounterData ret = new EvaluatedEncounterData(definition, context);
for (Map.Entry<Integer, Object> entry : weights.getData().entrySet()) {
Integer encId = entry.getKey();
Obs height = (Obs) heights.getData().get(encId);
Obs weight = (Obs) weights.getData().get(encId);
if (height != null && height.getValueNumeric() != null && weight != null && weight.getValueNumeric() != null) {
Double bmi = Math.rint((weight.getValueNumeric() / ((height.getValueNumeric() / 100) * (height.getValueNumeric() / 100))) * 10) / 10;
ret.addData(encId, bmi);
} else {
ret.addData(encId, null);
}
}
return ret;
}
use of org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition in project openmrs-module-pihcore by PIH.
the class PihEncounterDataLibrary method getSingleObsInEncounter.
@DocumentedDefinition
public EncounterDataDefinition getSingleObsInEncounter(Concept concept) {
ObsForEncounterDataDefinition d = new ObsForEncounterDataDefinition();
d.setQuestion(concept);
d.setSingleObs(true);
return d;
}
Aggregations