Search in sources :

Example 1 with ConceptBuilder

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

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

the class ParserEncounterIntoSimpleObjectsTest method testParsingSimpleObs.

@Test
public void testParsingSimpleObs() throws Exception {
    ConceptDatatype textDatatype = conceptService.getConceptDatatypeByName("Text");
    ConceptClass misc = conceptService.getConceptClassByName("Misc");
    // intentionally the same as what will result from capitalizeFirstLetter(consultNote)
    String consultNote = "Consult note";
    String valueText = "Patient is here for blah blah blah.";
    Concept consultComments = new ConceptBuilder(conceptService, textDatatype, misc).addName(consultNote).get();
    encounter.addObs(new ObsBuilder().setConcept(consultComments).setValue(valueText).get());
    ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
    assertThat(parsed.getDiagnoses().size(), is(0));
    assertThat(parsed.getDispositions().size(), is(0));
    assertThat(parsed.getObs().size(), is(1));
    assertThat(path(parsed.getObs(), 0, "question"), is((Object) consultNote));
    assertThat(path(parsed.getObs(), 0, "answer"), is((Object) valueText));
}
Also used : Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptBuilder(org.openmrs.module.emrapi.test.builder.ConceptBuilder) SimpleObject(org.openmrs.ui.framework.SimpleObject) ObsBuilder(org.openmrs.module.emrapi.test.builder.ObsBuilder) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test)

Example 3 with ConceptBuilder

use of org.openmrs.module.emrapi.test.builder.ConceptBuilder 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));
}
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) ArrayList(java.util.ArrayList) DispositionObs(org.openmrs.module.emrapi.disposition.DispositionObs) Date(java.util.Date) DateTime(org.joda.time.DateTime) Disposition(org.openmrs.module.emrapi.disposition.Disposition) SimpleObject(org.openmrs.ui.framework.SimpleObject) Test(org.junit.Test)

Example 4 with ConceptBuilder

use of org.openmrs.module.emrapi.test.builder.ConceptBuilder 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()));
}
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) Disposition(org.openmrs.module.emrapi.disposition.Disposition) DispositionObs(org.openmrs.module.emrapi.disposition.DispositionObs) SimpleObject(org.openmrs.ui.framework.SimpleObject) Test(org.junit.Test)

Example 5 with ConceptBuilder

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

the class ParserEncounterIntoSimpleObjectsTest method testParsingObsWithLocationAnswer.

@Test
public void testParsingObsWithLocationAnswer() throws Exception {
    ConceptDatatype textDatatype = conceptService.getConceptDatatypeByName("Text");
    ConceptClass misc = conceptService.getConceptClassByName("Misc");
    Location xanadu = new Location();
    xanadu.setName("Xanadu");
    when(locationService.getLocation(2)).thenReturn(xanadu);
    Concept someLocation = new ConceptBuilder(conceptService, textDatatype, misc).addName("Some location").get();
    encounter.addObs(new ObsBuilder().setConcept(someLocation).setValue("2").setComment("org.openmrs.Location").get());
    ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
    ;
    assertThat(parsed.getObs().size(), is(1));
    assertThat(path(parsed.getObs(), 0, "question"), is((Object) "Some location"));
    assertThat(path(parsed.getObs(), 0, "answer"), is((Object) "Xanadu"));
}
Also used : Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptBuilder(org.openmrs.module.emrapi.test.builder.ConceptBuilder) SimpleObject(org.openmrs.ui.framework.SimpleObject) ObsBuilder(org.openmrs.module.emrapi.test.builder.ObsBuilder) ConceptDatatype(org.openmrs.ConceptDatatype) Location(org.openmrs.Location) Test(org.junit.Test)

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