use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method searchNonCoded.
public List<SimpleObject> searchNonCoded(UiSessionContext context, UiUtils ui, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("emrConceptService") EmrConceptService emrConceptService, @RequestParam("term") String query, @RequestParam(value = "start", defaultValue = "0") Integer start, @RequestParam(value = "size", defaultValue = "50") Integer size) throws Exception {
Collection<Concept> diagnosisSets = emrApiProperties.getDiagnosisSets();
Locale locale = context.getLocale();
List<ConceptSource> sources = emrApiProperties.getConceptSourcesForDiagnosisSearch();
List<ConceptSearchResult> hits = emrConceptService.conceptSearch(query, locale, null, diagnosisSets, sources, null);
List<SimpleObject> ret = new ArrayList<SimpleObject>();
for (ConceptSearchResult hit : hits) {
ret.add(simplify(hit, ui, locale));
}
return ret;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjects method parseObservations.
public ParsedObs parseObservations(Locale locale) {
DiagnosisMetadata diagnosisMetadata = emrApiProperties.getDiagnosisMetadata();
DispositionDescriptor dispositionDescriptor = null;
try {
dispositionDescriptor = dispositionService.getDispositionDescriptor();
} catch (IllegalStateException ex) {
// No problem. We do not require dispositions to be configured here
}
ParsedObs parsedObs = new ParsedObs();
for (Obs obs : encounter.getObsAtTopLevel(false)) {
if (diagnosisMetadata.isDiagnosis(obs)) {
parsedObs.getDiagnoses().add(parseDiagnosis(diagnosisMetadata, obs));
} else if (dispositionDescriptor != null && dispositionDescriptor.isDisposition(obs)) {
parsedObs.getDispositions().add(parseDisposition(dispositionDescriptor, obs, locale));
} else {
parsedObs.getObs().add(parseObs(obs, locale));
}
}
// just sort the obs by obsId--not perfect, but a decent "natural" object
Collections.sort(parsedObs.getObs(), new Comparator<SimpleObject>() {
@Override
public int compare(SimpleObject o1, SimpleObject o2) {
return (Integer) o1.get("obsId") < (Integer) o2.get("obsId") ? -1 : 1;
}
});
Collections.sort(parsedObs.getDiagnoses(), new Comparator<SimpleObject>() {
@Override
public int compare(SimpleObject o1, SimpleObject o2) {
Integer order1 = (Integer) o1.get("order");
Integer order2 = (Integer) o2.get("order");
return order1 - order2;
}
});
return parsedObs;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjects method parseObsWithLocationAnswer.
private SimpleObject parseObsWithLocationAnswer(Obs obs, Location location) {
SimpleObject simpleObject = SimpleObject.create("obsId", obs.getObsId());
simpleObject.put("question", capitalizeString(uiUtils.format(obs.getConcept())));
simpleObject.put("answer", uiUtils.format(location));
return simpleObject;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjects method parseDisposition.
private SimpleObject parseDisposition(DispositionDescriptor dispositionDescriptor, Obs obs, Locale locale) {
Obs dispositionObs = dispositionDescriptor.getDispositionObs(obs);
Obs admissionLocationObs = dispositionDescriptor.getAdmissionLocationObs(obs);
Obs internalTransferLocationObs = dispositionDescriptor.getInternalTransferLocationObs(obs);
Obs dateOfDeathObs = dispositionDescriptor.getDateOfDeathObs(obs);
List<Obs> additionalObs = dispositionDescriptor.getAdditionalObs(obs);
SimpleObject simpleObject = SimpleObject.create("obsId", obs.getObsId());
simpleObject.put("disposition", dispositionObs.getValueAsString(locale));
List<SimpleObject> simplifiedAdditionalObs = new ArrayList<SimpleObject>();
if (admissionLocationObs != null) {
simplifiedAdditionalObs.add(parseObsWithLocationAnswer(admissionLocationObs, dispositionDescriptor.getAdmissionLocation(obs, locationService)));
}
if (internalTransferLocationObs != null) {
simplifiedAdditionalObs.add(parseObsWithLocationAnswer(internalTransferLocationObs, dispositionDescriptor.getInternalTransferLocation(obs, locationService)));
}
if (dateOfDeathObs != null) {
simplifiedAdditionalObs.add(parseObs(dateOfDeathObs, locale));
}
for (Obs additional : additionalObs) {
simplifiedAdditionalObs.add(parseObs(additional, locale));
}
simpleObject.put("additionalObs", simplifiedAdditionalObs);
return simpleObject;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjects method parseOrders.
public List<SimpleObject> parseOrders() {
List<SimpleObject> orders = new ArrayList<SimpleObject>();
// hacky reflection to allow core 1.9 compatibility, which doesn't support order.orderNumber
Method getOrderNumber = null;
for (Method m : new Order().getClass().getMethods()) {
if (m.getName().equals("getOrderNumber")) {
getOrderNumber = m;
break;
}
}
for (Order order : encounter.getOrders()) {
try {
orders.add(SimpleObject.create("concept", uiUtils.format(order.getConcept()), "orderNumber", // prior to 1.10 we display accession number, 1.10+ we display order number
uiUtils.format(getOrderNumber != null ? getOrderNumber.invoke(order) : order.getAccessionNumber())));
}// fail softly for now
catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
}
return orders;
}
Aggregations