use of org.openmrs.module.pihcore.reporting.encounter.definition.MultipleObsForEncounterDataDefinition in project openmrs-module-pihcore by PIH.
the class BaseEncounterDataSetManager method addSymptomPresentOrAbsentColumn.
protected void addSymptomPresentOrAbsentColumn(EncounterDataSetDefinition dsd, String columnName, String symptomPresentQuestion, String symptomAbsentQuestion, String symptomAnswer, Object valueIfPresent, Object valueIfAbsent) {
Concept presentConcept = Metadata.getConcept(symptomPresentQuestion);
Concept absentConcept = Metadata.getConcept(symptomAbsentQuestion);
Concept answerConcept = Metadata.getConcept(symptomAnswer);
MultipleObsForEncounterDataDefinition d = new MultipleObsForEncounterDataDefinition();
d.addQuestion(presentConcept);
d.addQuestion(absentConcept);
CodedObsConverter converter = new CodedObsConverter();
converter.addOption(presentConcept.getUuid(), answerConcept.getUuid(), valueIfPresent);
converter.addOption(absentConcept.getUuid(), answerConcept.getUuid(), valueIfAbsent);
addColumn(dsd, columnName, d, converter);
}
use of org.openmrs.module.pihcore.reporting.encounter.definition.MultipleObsForEncounterDataDefinition in project openmrs-module-pihcore by PIH.
the class MultipleObsForEncounterDataEvaluatorTest method addSymptomPresentOrAbsentColumn.
protected void addSymptomPresentOrAbsentColumn(EncounterDataSetDefinition dsd, String columnName, String symptomPresentQuestion, String symptomAbsentQuestion, String symptomAnswer, Object valueIfPresent, Object valueIfAbsent) {
Concept presentConcept = Metadata.getConcept(symptomPresentQuestion);
Concept absentConcept = Metadata.getConcept(symptomAbsentQuestion);
Concept answerConcept = Metadata.getConcept(symptomAnswer);
MultipleObsForEncounterDataDefinition d = new MultipleObsForEncounterDataDefinition();
d.addQuestion(presentConcept);
d.addQuestion(absentConcept);
CodedObsConverter converter = new CodedObsConverter();
converter.addOption(presentConcept.getUuid(), answerConcept.getUuid(), valueIfPresent);
converter.addOption(absentConcept.getUuid(), answerConcept.getUuid(), valueIfAbsent);
dsd.addColumn(columnName.toUpperCase(), d, "", converter);
}
use of org.openmrs.module.pihcore.reporting.encounter.definition.MultipleObsForEncounterDataDefinition in project openmrs-module-pihcore by PIH.
the class MultipleObsForEncounterDataEvaluator method evaluate.
@Override
public EvaluatedEncounterData evaluate(EncounterDataDefinition definition, EvaluationContext context) throws EvaluationException {
MultipleObsForEncounterDataDefinition def = (MultipleObsForEncounterDataDefinition) definition;
EvaluatedEncounterData data = new EvaluatedEncounterData();
HqlQueryBuilder q = new HqlQueryBuilder();
q.select("obs.encounter.encounterId, obs");
q.from(Obs.class, "obs");
q.whereIn("obs.concept", def.getQuestions());
q.whereIn("obs.valueCoded", def.getAnswers());
q.whereEncounterIn("obs.encounter.encounterId", context);
List<Object[]> result = Context.getService(EvaluationService.class).evaluateToList(q, context);
for (Object[] row : result) {
Integer encounterId = (Integer) row[0];
Obs obs = (Obs) row[1];
List l = (List) data.getData().get(encounterId);
if (l == null) {
l = new ArrayList();
data.getData().put(encounterId, l);
}
l.add(obs);
}
return data;
}
Aggregations