use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptServiceTest method retireConceptMapType_shouldShouldSetTheDefaultRetireReasonIfNoneIsGiven.
/**
* @see ConceptService#retireConceptMapType(ConceptMapType,String)
*/
@Test
public void retireConceptMapType_shouldShouldSetTheDefaultRetireReasonIfNoneIsGiven() {
// sanity check
ConceptMapType mapType = Context.getConceptService().getConceptMapType(1);
Assert.assertNull(mapType.getRetireReason());
ConceptMapType retiredMapType = Context.getConceptService().retireConceptMapType(mapType, null);
Assert.assertNotNull(retiredMapType.getRetireReason());
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptServiceTest method getDefaultConceptMapType_shouldReturnSameAsByDefault.
/**
* @see ConceptService#getDefaultConceptMapType()
*/
@Test
public void getDefaultConceptMapType_shouldReturnSameAsByDefault() {
ConceptMapType conceptMapType = conceptService.getDefaultConceptMapType();
Assert.assertNotNull(conceptMapType);
Assert.assertEquals("same-as", conceptMapType.getName());
}
use of org.openmrs.ConceptMapType 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.ConceptMapType in project openmrs-core by openmrs.
the class ConceptServiceTest method getDrugByMapping_shouldReturnADrugThatMatchesTheCodeAndSourceAndTheBestMapType.
/**
* @see ConceptService#getDrugByMapping(String, org.openmrs.ConceptSource, java.util.Collection
*/
@Test
public void getDrugByMapping_shouldReturnADrugThatMatchesTheCodeAndSourceAndTheBestMapType() {
executeDataSet(GET_DRUG_MAPPINGS);
final Integer expectedDrugId = 2;
final ConceptSource source = conceptService.getConceptSource(2);
final ConceptMapType mapTypeWithMatch = conceptService.getConceptMapType(1);
final ConceptMapType mapTypeWithNoMatch = conceptService.getConceptMapType(2);
List<ConceptMapType> conceptMapTypeList = new ArrayList<>();
conceptMapTypeList.add(mapTypeWithMatch);
conceptMapTypeList.add(mapTypeWithNoMatch);
Drug drug = conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList);
assertEquals(expectedDrugId, drug.getDrugId());
// Lets switch the order is the map types in the list to make sure that
// if there is no match on the first map type, the logic matches on the second
// sanity check that actually there will be no match on the first map type in the list
conceptMapTypeList.clear();
conceptMapTypeList.add(mapTypeWithNoMatch);
assertNull(conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList));
conceptMapTypeList.add(mapTypeWithMatch);
drug = conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList);
assertEquals(expectedDrugId, drug.getDrugId());
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptServiceTest method getConceptMapTypeByName_shouldBeCaseInsensitive.
/**
* @see ConceptService#getConceptMapTypeByName(String)
*/
@Test
public void getConceptMapTypeByName_shouldBeCaseInsensitive() {
String name = "SAME-as";
ConceptMapType mt = Context.getConceptService().getConceptMapTypeByName(name);
Assert.assertNotNull(mt);
// sanity check in case the test dataset is edited
Assert.assertNotSame(name, mt.getName());
Assert.assertEquals(2, mt.getId().intValue());
}
Aggregations