Search in sources :

Example 31 with ConceptMapType

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

the class ConceptServiceTest method unretireConceptMapType_shouldUnretireTheSpecifiedConceptMapTypeAndDropAllRetireRelatedFields.

/**
 * @see ConceptService#unretireConceptMapType(ConceptMapType)
 */
@Test
public void unretireConceptMapType_shouldUnretireTheSpecifiedConceptMapTypeAndDropAllRetireRelatedFields() {
    ConceptMapType mapType = Context.getConceptService().getConceptMapType(6);
    Assert.assertTrue(mapType.getRetired());
    Assert.assertNotNull(mapType.getRetiredBy());
    Assert.assertNotNull(mapType.getDateRetired());
    Assert.assertNotNull(mapType.getRetireReason());
    ConceptMapType unRetiredMapType = Context.getConceptService().unretireConceptMapType(mapType);
    Assert.assertFalse(unRetiredMapType.getRetired());
    Assert.assertNull(unRetiredMapType.getRetireReason());
    Assert.assertNull(unRetiredMapType.getRetiredBy());
    Assert.assertNull(unRetiredMapType.getDateRetired());
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 32 with ConceptMapType

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

the class ConceptServiceTest method getConceptMapTypes_shouldReturnSortedList.

/**
 * @see ConceptService#getConceptMapTypes(null,null)
 */
@Test
public void getConceptMapTypes_shouldReturnSortedList() {
    List<ConceptMapType> conceptMapTypes = Context.getConceptService().getConceptMapTypes(true, true);
    for (int i = 0; i < conceptMapTypes.size() - 1; i++) {
        ConceptMapType current = conceptMapTypes.get(i);
        ConceptMapType next = conceptMapTypes.get(i + 1);
        int currentWeight = ConceptMapTypeComparator.getConceptMapTypeSortWeight(current);
        int nextWeight = ConceptMapTypeComparator.getConceptMapTypeSortWeight(next);
        assertTrue(currentWeight <= nextWeight);
    }
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 33 with ConceptMapType

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

the class ConceptServiceTest method getDrugsByMapping_shouldExcludeDuplicateMatches.

/**
 * @see ConceptService#getDrugsByMapping(String, org.openmrs.ConceptSource,
 *      java.util.Collection, boolean)
 */
@Test
public void getDrugsByMapping_shouldExcludeDuplicateMatches() {
    executeDataSet(GET_DRUG_MAPPINGS);
    List<ConceptMapType> conceptMapTypeList = conceptService.getConceptMapTypes(false, true);
    // the expected matching drug has two mappings to different concept sources but same code
    // so this test also ensure that we can never get back duplicates
    ConceptSource source = conceptService.getConceptSource(1);
    List<Drug> drugs = conceptService.getDrugsByMapping("WGT234", source, conceptMapTypeList, false);
    assertEquals(1, drugs.size());
    assertTrue(containsId(drugs, 2));
}
Also used : Drug(org.openmrs.Drug) ConceptMapType(org.openmrs.ConceptMapType) ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 34 with ConceptMapType

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

the class ConceptServiceTest method getDrugsByMapping_shouldMatchOnTheMapTypes.

/**
 * @see ConceptService#getDrugsByMapping(String, ConceptSource, Collection, boolean)
 */
@Test
public void getDrugsByMapping_shouldMatchOnTheMapTypes() {
    executeDataSet(GET_DRUG_MAPPINGS);
    List<ConceptMapType> conceptMapTypeList = conceptService.getConceptMapTypes(false, true);
    ConceptSource source = conceptService.getConceptSource(1);
    List<Drug> drugs = conceptService.getDrugsByMapping(null, source, conceptMapTypeList, false);
    assertEquals(2, drugs.size());
    assertTrue(containsId(drugs, 2));
    assertTrue(containsId(drugs, 3));
    drugs = conceptService.getDrugsByMapping(null, source, conceptMapTypeList, true);
    assertEquals(3, drugs.size());
    assertTrue(containsId(drugs, 2));
    assertTrue(containsId(drugs, 3));
    assertTrue(containsId(drugs, 11));
}
Also used : Drug(org.openmrs.Drug) ConceptMapType(org.openmrs.ConceptMapType) ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptMapType (org.openmrs.ConceptMapType)34 Test (org.junit.Test)26 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)26 BindException (org.springframework.validation.BindException)10 Errors (org.springframework.validation.Errors)10 Drug (org.openmrs.Drug)8 ConceptSource (org.openmrs.ConceptSource)6 Criteria (org.hibernate.Criteria)3 ArrayList (java.util.ArrayList)2 Concept (org.openmrs.Concept)2 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)2 DrugReferenceMap (org.openmrs.DrugReferenceMap)2 DAOException (org.openmrs.api.db.DAOException)2 ConceptBuilder (org.openmrs.module.metadatadeploy.builder.ConceptBuilder)2 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 FlushMode (org.hibernate.FlushMode)1