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());
}
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);
}
}
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));
}
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));
}
Aggregations