Search in sources :

Example 1 with ObsBuilder

use of org.openmrs.module.emrapi.test.builder.ObsBuilder 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 2 with ObsBuilder

use of org.openmrs.module.emrapi.test.builder.ObsBuilder 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)2 Concept (org.openmrs.Concept)2 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)2 ObsBuilder (org.openmrs.module.emrapi.test.builder.ObsBuilder)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2 Location (org.openmrs.Location)1