Search in sources :

Example 6 with ConceptBuilder

use of org.openmrs.module.emrapi.test.builder.ConceptBuilder 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)

Example 7 with ConceptBuilder

use of org.openmrs.module.emrapi.test.builder.ConceptBuilder in project openmrs-module-coreapps by openmrs.

the class EncounterDispositionTagHandlerComponentTest method testFormOnlyShowsDispositionsInDescriptor.

@Test
public void testFormOnlyShowsDispositionsInDescriptor() throws Exception {
    ConceptClass misc = conceptService.getConceptClassByName("Misc");
    ConceptDatatype naDatatype = conceptService.getConceptDatatypeByName("N/A");
    Concept dispositionConcept = dispositionService.getDispositionDescriptor().getDispositionConcept();
    dispositionConcept.addAnswer(new ConceptAnswer(new ConceptBuilder(conceptService, naDatatype, misc).addName("Should not be in option list").saveAndGet()));
    new RegressionTestHelper() {

        @Override
        public void testBlankFormHtml(String html) {
            assertThat(html, containsString("disposition.admission"));
            assertThat(html, containsString("disposition.transfer"));
            assertThat(html, containsString("disposition.discharge"));
            assertThat(html, not(containsString("Should not be in option list")));
        }

        @Override
        public String getXmlDatasetPath() {
            return "";
        }

        @Override
        public String getFormName() {
            return "encounterDispositionSimpleForm";
        }

        @Override
        public Map<String, Object> getFormEntrySessionAttributes() {
            Map<String, Object> attributes = new HashMap<String, Object>();
            attributes.put("uiUtils", new TestUiUtils());
            return attributes;
        }

        @Override
        public String[] widgetLabels() {
            return new String[] { "Date:", "Location:", "Provider:", "Disposition:", "Encounter Type:" };
        }
    }.run();
}
Also used : Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptBuilder(org.openmrs.module.emrapi.test.builder.ConceptBuilder) ConceptAnswer(org.openmrs.ConceptAnswer) TestUiUtils(org.openmrs.module.appui.TestUiUtils) Matchers.containsString(org.hamcrest.Matchers.containsString) ConceptDatatype(org.openmrs.ConceptDatatype) HashMap(java.util.HashMap) Map(java.util.Map) RegressionTestHelper(org.openmrs.module.htmlformentry.RegressionTestHelper) Test(org.junit.Test) BaseModuleWebContextSensitiveTest(org.openmrs.web.test.BaseModuleWebContextSensitiveTest)

Aggregations

Test (org.junit.Test)7 Concept (org.openmrs.Concept)7 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)7 SimpleObject (org.openmrs.ui.framework.SimpleObject)6 Obs (org.openmrs.Obs)4 Disposition (org.openmrs.module.emrapi.disposition.Disposition)4 DispositionObs (org.openmrs.module.emrapi.disposition.DispositionObs)4 ArrayList (java.util.ArrayList)3 ConceptClass (org.openmrs.ConceptClass)3 ConceptDatatype (org.openmrs.ConceptDatatype)3 Location (org.openmrs.Location)3 ObsBuilder (org.openmrs.module.emrapi.test.builder.ObsBuilder)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DateTime (org.joda.time.DateTime)1 ConceptAnswer (org.openmrs.ConceptAnswer)1 TestUiUtils (org.openmrs.module.appui.TestUiUtils)1 RegressionTestHelper (org.openmrs.module.htmlformentry.RegressionTestHelper)1