use of org.openmrs.module.emrapi.disposition.Disposition in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjectsTest method testParsingDispositionWithAdmissionLocation.
@Test
public void testParsingDispositionWithAdmissionLocation() throws Exception {
Concept admit = new ConceptBuilder(null, conceptService.getConceptDatatypeByName("N/A"), conceptService.getConceptClassByName("Misc")).addName("Admit").get();
when(emrConceptService.getConcept("test:admit")).thenReturn(admit);
Obs dispositionObs = dispositionDescriptor.buildObsGroup(new Disposition("emrapi.admit", "Admit", "test:admit", Collections.<String>emptyList(), Collections.<DispositionObs>emptyList()), emrConceptService);
Obs admissionLocationObs = new Obs();
admissionLocationObs.setObsId(100);
admissionLocationObs.setConcept(dispositionDescriptor.getAdmissionLocationConcept());
admissionLocationObs.setValueText("3");
dispositionObs.addGroupMember(admissionLocationObs);
Location admissionLocation = new Location();
admissionLocation.setName("Outpatient clinic");
when(locationService.getLocation(3)).thenReturn(admissionLocation);
encounter.addObs(doNotGoToServiceToFormatMembers(dispositionObs));
ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
SimpleObject expectedAdmissionLocationObject = SimpleObject.create("obsId", admissionLocationObs.getObsId());
expectedAdmissionLocationObject.put("question", "Admission location");
expectedAdmissionLocationObject.put("answer", "Outpatient clinic");
List<SimpleObject> expectedAdditionalObsList = new ArrayList<SimpleObject>();
expectedAdditionalObsList.add(expectedAdmissionLocationObject);
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) "Admit"));
assertThat(path(parsed.getDispositions(), 0, "additionalObs"), is((Object) expectedAdditionalObsList));
}
use of org.openmrs.module.emrapi.disposition.Disposition in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjectsTest method testParsingDispositionWithDateOfDeath.
@Test
public void testParsingDispositionWithDateOfDeath() throws Exception {
Concept admit = new ConceptBuilder(null, conceptService.getConceptDatatypeByName("N/A"), conceptService.getConceptClassByName("Misc")).addName("Death").get();
when(emrConceptService.getConcept("test:death")).thenReturn(admit);
Obs dispositionObs = dispositionDescriptor.buildObsGroup(new Disposition("emrapi.death", "Death", "test:death", Collections.<String>emptyList(), Collections.<DispositionObs>emptyList()), emrConceptService);
Date dateOfDeath = new DateTime(2012, 2, 20, 10, 10, 10).toDate();
Obs dateOfDeathObs = new Obs();
dateOfDeathObs.setObsId(100);
dateOfDeathObs.setConcept(dispositionDescriptor.getDateOfDeathConcept());
dateOfDeathObs.setValueDate(dateOfDeath);
dispositionObs.addGroupMember(dateOfDeathObs);
encounter.addObs(doNotGoToServiceToFormatMembers(dispositionObs));
ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
SimpleObject expectedAdmissionLocationObject = SimpleObject.create("obsId", dateOfDeathObs.getObsId());
expectedAdmissionLocationObject.put("question", "Date of death");
expectedAdmissionLocationObject.put("answer", "20 Feb 2012 10:10 AM");
List<SimpleObject> expectedAdditionalObsList = new ArrayList<SimpleObject>();
expectedAdditionalObsList.add(expectedAdmissionLocationObject);
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) "Death"));
assertThat(path(parsed.getDispositions(), 0, "additionalObs"), is((Object) expectedAdditionalObsList));
}
use of org.openmrs.module.emrapi.disposition.Disposition in project openmrs-module-coreapps by openmrs.
the class ParserEncounterIntoSimpleObjectsTest method testParsingDispositions.
@Test
public void testParsingDispositions() throws Exception {
Concept admit = new ConceptBuilder(null, conceptService.getConceptDatatypeByName("N/A"), conceptService.getConceptClassByName("Misc")).addName("Admit").get();
when(emrConceptService.getConcept("test:admit")).thenReturn(admit);
Obs dispositionObs = dispositionDescriptor.buildObsGroup(new Disposition("emrapi.admit", "Admit", "test:admit", Collections.<String>emptyList(), Collections.<DispositionObs>emptyList()), emrConceptService);
encounter.addObs(doNotGoToServiceToFormatMembers(dispositionObs));
ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
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) "Admit"));
assertThat(path(parsed.getDispositions(), 0, "additionalObs"), is((Object) Collections.emptyList()));
}
use of org.openmrs.module.emrapi.disposition.Disposition in project openmrs-module-coreapps by openmrs.
the class EncounterDispositionTagHandler method doStartTag.
@Override
public boolean doStartTag(FormEntrySession session, PrintWriter out, Node parent, Node node) throws BadFormDesignException {
Set<Obs> exisitingDispositionObsGroup = null;
if (session.getContext().getExistingEncounter() != null && session.getContext().getExistingObsInGroups() != null) {
exisitingDispositionObsGroup = getObsGroupByGroupingConcept(session.getContext().getExistingObsInGroups(), HtmlFormEntryUtil.getConcept(EmrApiConstants.EMR_CONCEPT_SOURCE_NAME + ": " + EmrApiConstants.CONCEPT_CODE_DISPOSITION_CONCEPT_SET));
}
List<Disposition> dispositions = null;
VisitDomainWrapper visitDomainWrapper = session.getContext().getVisit() != null ? adtService.wrap((Visit) session.getContext().getVisit()) : null;
if (visitDomainWrapper == null) {
dispositions = dispositionService.getDispositions();
} else {
dispositions = dispositionService.getValidDispositions(visitDomainWrapper);
}
Element dispositionObsGroup = node.getOwnerDocument().createElement("obsgroup");
dispositionObsGroup.setAttribute("groupingConceptId", emrApiProperties.getEmrApiConceptSource().getName() + ":" + EmrApiConstants.CONCEPT_CODE_DISPOSITION_CONCEPT_SET);
// TODO: allow the label text to be overwritten, move the message code to the coreapps module
Element label = node.getOwnerDocument().createElement("label");
Element uimessageLabel = node.getOwnerDocument().createElement("uimessage");
uimessageLabel.setAttribute("code", "emr.consult.disposition");
label.appendChild(uimessageLabel);
dispositionObsGroup.appendChild(label);
// TODO: allow the id to be passed in from the form?
Element dispositionObs = node.getOwnerDocument().createElement("obs");
dispositionObs.setAttribute("id", "disposition-" + UUID.randomUUID().toString());
dispositionObs.setAttribute("style", "dropdown");
dispositionObs.setAttribute("conceptId", emrApiProperties.getEmrApiConceptSource().getName() + ":" + EmrApiConstants.CONCEPT_CODE_DISPOSITION);
if (((Element) node).hasAttribute("required") && ((Element) node).getAttribute("required").equalsIgnoreCase("true")) {
dispositionObs.setAttribute("required", "true");
}
// add the possible dispositions from the configured disposition retrieved from disposition factory
List<Control> controls = new ArrayList<Control>();
String answerConceptIds = "";
StringBuilder answerCodes = new StringBuilder();
Iterator<Disposition> i = dispositions.iterator();
while (i.hasNext()) {
Disposition disposition = i.next();
answerConceptIds = answerConceptIds + disposition.getConceptCode() + (i.hasNext() ? "," : "");
answerCodes.append(disposition.getName());
if (i.hasNext()) {
answerCodes.append(",");
}
// determine if there are any additional observations we need to collect for this disposition
if (disposition.getAdditionalObs() != null && disposition.getAdditionalObs().size() > 0) {
controls.add(buildNewControl(disposition, disposition.getAdditionalObs()));
}
}
dispositionObs.setAttribute("answerConceptIds", answerConceptIds);
dispositionObs.setAttribute("answerCodes", answerCodes.toString());
if (controls != null && controls.size() > 0) {
generateControlsElement(dispositionObs, controls);
}
dispositionObsGroup.appendChild(dispositionObs);
if (controls != null && controls.size() > 0) {
generateAdditionalObsElements(dispositionObsGroup, controls, exisitingDispositionObsGroup);
}
node.appendChild(dispositionObsGroup);
return true;
}
use of org.openmrs.module.emrapi.disposition.Disposition 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));
}
Aggregations