Search in sources :

Example 6 with ConceptMap

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

the class ConceptServiceTest method saveConcept_shouldCreateAReferenceTermForAConceptMappingOnTheFlyWhenEditingAConcept.

/**
 * @see ConceptService#saveConcept(Concept)
 */
@Test
public void saveConcept_shouldCreateAReferenceTermForAConceptMappingOnTheFlyWhenEditingAConcept() {
    int initialTermCount = conceptService.getAllConceptReferenceTerms().size();
    Concept concept = conceptService.getConcept(5497);
    ConceptMap map = new ConceptMap();
    map.getConceptReferenceTerm().setCode("unique code");
    map.getConceptReferenceTerm().setConceptSource(conceptService.getConceptSource(1));
    concept.addConceptMapping(map);
    conceptService.saveConcept(concept);
    Assert.assertEquals(initialTermCount + 1, conceptService.getAllConceptReferenceTerms().size());
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) ConceptMap(org.openmrs.ConceptMap) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 7 with ConceptMap

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

the class ConceptServiceTest method saveConcept_shouldCreateAReferenceTermForAConceptMappingOnTheFlyWhenCreatingAConcept.

/**
 * @see ConceptService#saveConcept(Concept)
 */
@Test
public void saveConcept_shouldCreateAReferenceTermForAConceptMappingOnTheFlyWhenCreatingAConcept() {
    int initialTermCount = conceptService.getAllConceptReferenceTerms().size();
    Concept concept = new Concept();
    concept.addName(new ConceptName("test name", Context.getLocale()));
    concept.setDatatype(new ConceptDatatype(1));
    concept.setConceptClass(new ConceptClass(1));
    ConceptMap map = new ConceptMap();
    map.getConceptReferenceTerm().setCode("unique code");
    map.getConceptReferenceTerm().setConceptSource(conceptService.getConceptSource(1));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.addConceptMapping(map);
    conceptService.saveConcept(concept);
    Assert.assertNotNull(concept.getId());
    Assert.assertEquals(initialTermCount + 1, conceptService.getAllConceptReferenceTerms().size());
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptMap(org.openmrs.ConceptMap) ConceptDatatype(org.openmrs.ConceptDatatype) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptMap (org.openmrs.ConceptMap)7 Test (org.junit.Test)6 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)6 ConceptName (org.openmrs.ConceptName)5 Concept (org.openmrs.Concept)4 ConceptClass (org.openmrs.ConceptClass)3 ConceptDatatype (org.openmrs.ConceptDatatype)3 ConceptDescription (org.openmrs.ConceptDescription)3 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)2 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 ConceptAnswer (org.openmrs.ConceptAnswer)1 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)1 DuplicateConceptNameException (org.openmrs.api.DuplicateConceptNameException)1