Search in sources :

Example 6 with DispositionObs

use of org.openmrs.module.emrapi.disposition.DispositionObs 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));
}
Also used : Concept(org.openmrs.Concept) DispositionObs(org.openmrs.module.emrapi.disposition.DispositionObs) Obs(org.openmrs.Obs) ConceptBuilder(org.openmrs.module.emrapi.test.builder.ConceptBuilder) SimpleObject(org.openmrs.ui.framework.SimpleObject) Disposition(org.openmrs.module.emrapi.disposition.Disposition) ArrayList(java.util.ArrayList) DispositionObs(org.openmrs.module.emrapi.disposition.DispositionObs) SimpleObject(org.openmrs.ui.framework.SimpleObject) Location(org.openmrs.Location) Test(org.junit.Test)

Aggregations

DispositionObs (org.openmrs.module.emrapi.disposition.DispositionObs)6 Obs (org.openmrs.Obs)5 Disposition (org.openmrs.module.emrapi.disposition.Disposition)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Concept (org.openmrs.Concept)4 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)4 SimpleObject (org.openmrs.ui.framework.SimpleObject)4 Location (org.openmrs.Location)2 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 Visit (org.openmrs.Visit)1 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)1 Element (org.w3c.dom.Element)1