use of org.openmrs.ConceptDatatype 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"));
}
use of org.openmrs.ConceptDatatype 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();
}
use of org.openmrs.ConceptDatatype in project openmrs-module-pihcore by PIH.
the class FamilyHistoryRelativeCheckboxesTagHandlerTest method setupConcepts.
private void setupConcepts() throws Exception {
// copied from some pihcore concept setup, but tweaked to work with standardTestDataset.xml
ConceptDatatype coded = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.CODED);
ConceptDatatype text = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.TEXT);
ConceptDatatype notApplicable = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.N_A);
ConceptClass diagnosis = MetadataUtils.existing(ConceptClass.class, "938834bf-a745-4dbd-b611-f06a9a5a3060");
ConceptClass question = MetadataUtils.existing(ConceptClass.class, "a82ef63c-e4e4-48d6-988a-fdd74d7541a7");
ConceptClass misc = MetadataUtils.existing(ConceptClass.class, "ecdee8a7-d741-4fe7-8e01-f79cacbe97bc");
ConceptMapType sameAs = MetadataUtils.existing(ConceptMapType.class, CoreConceptMetadataBundle.ConceptMapTypes.SAME_AS);
// standardTestDataset actually has "is-a" instead of narrower than. Hopefully this works for our test
ConceptMapType narrowerThan = MetadataUtils.existing(ConceptMapType.class, "1ce7a784-7d8f-11e1-909d-c80aa9edcf4e");
ConceptSource ciel = conceptSource("CIEL", "Columbia International eHealth Laboratory concept ID", null, CoreConceptMetadataBundle.ConceptSources.CIEL);
conceptService.saveConceptSource(ciel);
// these are in standardTestDataset.xml
Concept no = conceptService.getConcept(8);
Concept unknown = conceptService.getConcept(22);
// need this to have a different UUID to match our dictionary
yes = conceptService.getConcept(7);
yes.setUuid(CommonConcepts.Concepts.YES);
conceptService.saveConcept(yes);
Concept famHxDiagnosis = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_DIAGNOSIS).datatype(coded).conceptClass(// CIEL says Diagnosis, but this is wrong
misc).name("109016BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history diagnosis", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).mapping(new ConceptMapBuilder("217715ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160592").build()).build());
// CIEL:1560 (Family Member) is both a question and an answer. At PIH we have two existing concepts for this purpose.
// This one is only used as a question, so we mark it as NARROWER-THAN CIEL:1560. (And we want to test this here.)
Concept famHxRelationship = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_RELATIONSHIP).datatype(coded).conceptClass(question).name("3e2256c6-26fe-102b-80cb-0017a47871b2", "RELATIONSHIP OF RELATIVE TO PATIENT", Locale.ENGLISH, // locale-preferred
ConceptNameType.FULLY_SPECIFIED).name("93bc0d72-07d4-102c-b5fa-0017a47871b2", "CONTACT_REL", Locale.ENGLISH, ConceptNameType.SHORT).name("f672a35a-d5db-102d-ad2a-000c29c2a5d7", "RELATION DU PARENT PAR RAPPORT AU PATIENT", Locale.FRENCH, // locale-preferred
null).description("ecf0bb66-07fe-102c-b5fa-0017a47871b2", "What is the relationship of this relative to this patient?", Locale.ENGLISH).mapping(new ConceptMapBuilder("e9335480-d593-11e4-9dcf-b36e1005e77b").type(narrowerThan).ensureTerm(ciel, "1560").build()).answers(// other options not needed for this test
father).build());
Concept famHxComment = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_COMMENT).datatype(text).conceptClass(question).name("109055BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history comment", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).mapping(new ConceptMapBuilder("217741ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160618").build()).build());
Concept isSymptomPresent = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_PRESENCE).datatype(coded).conceptClass(diagnosis).name("2009BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Sign/symptom present", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).answers(yes, no, unknown).mapping(new ConceptMapBuilder("171968ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "1729").build()).build());
Concept famHxConstruct = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_CONSTRUCT).datatype(notApplicable).conceptClass(// CIEL says Finding but that's not necessary for the test
misc).name("109017BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Patient's family history list", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).name("109019BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history list", Locale.ENGLISH, null).setMembers(famHxDiagnosis, famHxRelationship, isSymptomPresent, famHxComment).mapping(new ConceptMapBuilder("217716ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160593").build()).build());
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConcept_shouldSaveAConceptNumericAsAConcept.
/**
* @see ConceptService#saveConcept(Concept)
*/
@Test
public void saveConcept_shouldSaveAConceptNumericAsAConcept() {
executeDataSet(INITIAL_CONCEPTS_XML);
// This will automatically add the given locale to the list of allowed locales
Context.setLocale(Locale.US);
// this tests saving a previously conceptnumeric as just a concept
Concept c2 = new Concept(2);
ConceptName cn = new ConceptName("not a numeric anymore", Locale.US);
c2.addName(cn);
c2.addDescription(new ConceptDescription("some description", null));
c2.setDatatype(new ConceptDatatype(3));
c2.setConceptClass(new ConceptClass(1));
conceptService.saveConcept(c2);
Concept secondConcept = conceptService.getConcept(2);
// this will probably still be a ConceptNumeric object. what to do about that?
// revisit this problem when discriminators are in place
// assertFalse(secondConcept instanceof ConceptNumeric);
// this shouldn't think its a conceptnumeric object though
assertFalse(secondConcept.isNumeric());
assertEquals("not a numeric anymore", secondConcept.getName(Locale.US).getName());
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConcept_shouldNotUpdateConceptDataTypeIfConceptIsAttachedToAnObservation.
@Test(expected = ConceptInUseException.class)
public void saveConcept_shouldNotUpdateConceptDataTypeIfConceptIsAttachedToAnObservation() {
executeDataSet(INITIAL_CONCEPTS_XML);
Concept concept = conceptService.getConcept(2);
assertNotNull(concept);
ObsService obsService = Context.getObsService();
Obs obs = new Obs(Context.getPersonService().getPerson(1), concept, new Date(), Context.getLocationService().getLocation(1));
obs.setValueCoded(Context.getConceptService().getConcept(7));
obsService.saveObs(obs, "Creating a new observation with a concept");
ConceptDatatype newDatatype = conceptService.getConceptDatatypeByName("Text");
concept.setDatatype(newDatatype);
conceptService.saveConcept(concept);
}
Aggregations