Search in sources :

Example 26 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class HibernateConceptDAOTest method isConceptNameDuplicate_shouldNotFailIfConceptDoesNotHaveADefaultNameForLocale.

// TRUNK-4967
@Test
public void isConceptNameDuplicate_shouldNotFailIfConceptDoesNotHaveADefaultNameForLocale() {
    // given
    ConceptClass diagnosis = dao.getConceptClasses("Diagnosis").get(0);
    ConceptDatatype na = dao.getConceptDatatypeByName("N/A");
    Concept tuberculosis = new Concept();
    tuberculosis.addName(new ConceptName("Tuberculosis", Locale.US));
    tuberculosis.setDatatype(na);
    tuberculosis.setConceptClass(diagnosis);
    dao.saveConcept(tuberculosis);
    ConceptName shortName = new ConceptName("TB", Locale.FRANCE);
    shortName.setConceptNameType(ConceptNameType.SHORT);
    tuberculosis.addName(shortName);
    // when
    boolean duplicate = dao.isConceptNameDuplicate(shortName);
    // then
    // no NPE exception thrown
    assertThat(duplicate, is(false));
}
Also used : Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 27 with ConceptClass

use of org.openmrs.ConceptClass 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 28 with ConceptClass

use of org.openmrs.ConceptClass 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)

Example 29 with ConceptClass

use of org.openmrs.ConceptClass 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)

Example 30 with ConceptClass

use of org.openmrs.ConceptClass 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());
}
Also used : Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptMapType(org.openmrs.ConceptMapType) ConceptBuilder(org.openmrs.module.metadatadeploy.builder.ConceptBuilder) ConceptMapBuilder(org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder) ConceptSource(org.openmrs.ConceptSource) ConceptDatatype(org.openmrs.ConceptDatatype)

Aggregations

ConceptClass (org.openmrs.ConceptClass)55 Test (org.junit.Test)50 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)46 ConceptDatatype (org.openmrs.ConceptDatatype)38 ConceptName (org.openmrs.ConceptName)33 ConceptDescription (org.openmrs.ConceptDescription)31 Concept (org.openmrs.Concept)27 Locale (java.util.Locale)12 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)12 BindException (org.springframework.validation.BindException)9 Errors (org.springframework.validation.Errors)9 OrderType (org.openmrs.OrderType)5 HashSet (java.util.HashSet)4 ConceptMap (org.openmrs.ConceptMap)3 ConceptNumeric (org.openmrs.ConceptNumeric)3 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)3 ConceptComplex (org.openmrs.ConceptComplex)2 ConceptMapType (org.openmrs.ConceptMapType)2 ConceptSearchResult (org.openmrs.ConceptSearchResult)2 ConceptSource (org.openmrs.ConceptSource)2