use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method simplify.
/**
* This is public so that it can be used by a fragment that needs to prepopulate a diagnoses widget that is normally
* populated with AJAX results from the #search method.
* @param result
* @param ui
* @param locale
* @return
* @throws Exception
*/
public SimpleObject simplify(ConceptSearchResult result, UiUtils ui, Locale locale) throws Exception {
SimpleObject simple = SimpleObject.fromObject(result, ui, "word", "conceptName.id", "conceptName.uuid", "conceptName.conceptNameType", "conceptName.name", "concept.id", "concept.uuid", "concept.conceptMappings.conceptMapType", "concept.conceptMappings.conceptReferenceTerm.code", "concept.conceptMappings.conceptReferenceTerm.name", "concept.conceptMappings.conceptReferenceTerm.conceptSource.name");
Concept concept = result.getConcept();
ConceptName conceptName = result.getConceptName();
ConceptName preferredName = getPreferredName(locale, concept);
PropertyUtils.setProperty(simple, "concept.preferredName", preferredName.getName());
return simple;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method search.
public List<SimpleObject> search(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 PatientPageController method controller.
public void controller(@RequestParam("patientId") Patient patient, UiUtils ui, UiSessionContext emrContext, PageModel model, @SpringBean("formService") FormService formService, @SpringBean("patientService") PatientService patientService, @SpringBean("adtService") AdtService adtService, @InjectBeans PatientDomainWrapper patientDomainWrapper) {
patientDomainWrapper.setPatient(patient);
SimpleObject appHomepageBreadcrumb = SimpleObject.create("label", ui.message("referenceapplication.app.capturevitals.title"), "link", ui.pageLink("coreapps", "findpatient/findPatient?app=referenceapplication.vitals"));
SimpleObject patientPageBreadcrumb = SimpleObject.create("label", patient.getFamilyName() + ", " + patient.getGivenName(), "link", ui.thisUrlWithContextPath());
Form vitalsForm = formService.getFormByUuid("a000cb34-9ec1-4344-a1c8-f692232f6edd");
Location visitLocation = adtService.getLocationThatSupportsVisits(emrContext.getSessionLocation());
VisitDomainWrapper activeVisit = adtService.getActiveVisit(patient, visitLocation);
List<Encounter> existingEncounters = new ArrayList<Encounter>();
if (activeVisit != null) {
for (Encounter encounter : activeVisit.getVisit().getEncounters()) {
if (!encounter.isVoided() && vitalsForm.equals(encounter.getForm())) {
existingEncounters.add(encounter);
}
}
}
model.addAttribute("visit", activeVisit != null ? activeVisit.getVisit() : null);
model.addAttribute("existingEncounters", existingEncounters);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("breadcrumbOverride", ui.toJson(Arrays.asList(appHomepageBreadcrumb, patientPageBreadcrumb)));
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjectsTest method testParsingDispositionWithTransferLocation.
@Test
public void testParsingDispositionWithTransferLocation() throws Exception {
Concept admit = new ConceptBuilder(null, conceptService.getConceptDatatypeByName("N/A"), conceptService.getConceptClassByName("Misc")).addName("Transfer").get();
when(emrConceptService.getConcept("test:transfer")).thenReturn(admit);
Obs dispositionObs = dispositionDescriptor.buildObsGroup(new Disposition("emrapi.transfer", "Transfer", "test:transfer", Collections.<String>emptyList(), Collections.<DispositionObs>emptyList()), emrConceptService);
Obs transferLocationObs = new Obs();
transferLocationObs.setObsId(100);
transferLocationObs.setConcept(dispositionDescriptor.getInternalTransferLocationConcept());
transferLocationObs.setValueText("3");
dispositionObs.addGroupMember(transferLocationObs);
Location transferLocation = new Location();
transferLocation.setName("Outpatient clinic");
when(locationService.getLocation(3)).thenReturn(transferLocation);
encounter.addObs(doNotGoToServiceToFormatMembers(dispositionObs));
ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
SimpleObject expectedTransferLocationObject = SimpleObject.create("obsId", transferLocationObs.getObsId());
expectedTransferLocationObject.put("question", "Transfer location");
expectedTransferLocationObject.put("answer", "Outpatient clinic");
List<SimpleObject> expectedAdditionalObsList = new ArrayList<SimpleObject>();
expectedAdditionalObsList.add(expectedTransferLocationObject);
assertThat(parsed.getDiagnoses().size(), is(0));
assertThat(parsed.getDispositions().size(), is(1));
assertThat(parsed.getObs().size(), is(0));
assertThat(path(parsed.getDispositions(), 0, "disposition"), is((Object) "Transfer"));
assertThat(path(parsed.getDispositions(), 0, "additionalObs"), is((Object) expectedAdditionalObsList));
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-coreapps by openmrs.
the class RetrospectiveVisitFragmentControllerTest method test_shouldReturnConflictingVisits.
@Test
public void test_shouldReturnConflictingVisits() throws Exception {
Patient patient = new Patient();
Location location = new Location();
Date startDate = new DateTime(2012, 1, 1, 12, 12, 12).toDate();
// should round to the time components to the start and end of the days, respectively
Date expectedStartDate = new DateTime(2012, 1, 1, 0, 0, 0, 0).toDate();
Date expectedStopDate = new DateTime(2012, 1, 1, 23, 59, 59, 999).toDate();
Visit conflictingVisit = new Visit();
conflictingVisit.setStartDatetime(new DateTime(2012, 1, 1, 0, 0, 0, 0).toDate());
conflictingVisit.setStopDatetime(new DateTime(2012, 1, 3, 0, 0, 0, 999).toDate());
when(adtService.createRetrospectiveVisit(patient, location, expectedStartDate, expectedStopDate)).thenThrow(ExistingVisitDuringTimePeriodException.class);
when(adtService.getVisits(patient, location, expectedStartDate, expectedStopDate)).thenReturn(Collections.singletonList(new VisitDomainWrapper(conflictingVisit)));
when(ui.format(any())).thenReturn("someDate");
List<SimpleObject> result = (List<SimpleObject>) controller.create(adtService, patient, location, startDate, null, request, ui);
assertThat(result.size(), is(1));
assertThat(result.get(0).toJson(), is("{\"startDate\":\"someDate\",\"stopDate\":\"someDate\",\"id\":null,\"uuid\":\"" + conflictingVisit.getUuid() + "\"}"));
}
Aggregations