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));
}
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"));
}
Aggregations