use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptSource_shouldSaveAConceptSourceWithANullHl7Code.
@Test
public void saveConceptSource_shouldSaveAConceptSourceWithANullHl7Code() {
ConceptSource source = new ConceptSource();
String aNullString = null;
String sourceName = "A concept source with null HL7 code";
source.setName(sourceName);
source.setDescription("A concept source description");
source.setHl7Code(aNullString);
conceptService.saveConceptSource(source);
assertEquals("Did not save a ConceptSource with a null hl7Code", source, conceptService.getConceptSourceByName(sourceName));
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method getDrugByMapping_shouldFailIfMultipleDrugsAreFoundMatchingTheBestMapType.
/**
* @see ConceptService#getDrugByMapping(String, org.openmrs.ConceptSource, java.util.Collection
*/
@Test(expected = DAOException.class)
public void getDrugByMapping_shouldFailIfMultipleDrugsAreFoundMatchingTheBestMapType() {
executeDataSet(GET_DRUG_MAPPINGS);
ConceptSource source = conceptService.getConceptSource(1);
conceptService.getDrugByMapping("CD41003", source, Collections.singleton(conceptService.getConceptMapType(2)));
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method retireConceptSource_shouldRetireConceptSource.
/**
* @see ConceptService#retireConceptSource(ConceptSource,String)
*/
@Test
public void retireConceptSource_shouldRetireConceptSource() {
ConceptSource cs = conceptService.getConceptSource(3);
conceptService.retireConceptSource(cs, "dummy reason for retirement");
cs = conceptService.getConceptSource(3);
Assert.assertTrue(cs.getRetired());
Assert.assertEquals("dummy reason for retirement", cs.getRetireReason());
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptReferenceTerm_shouldUpdateChangesToTheConceptReferenceTermInTheDatabase.
/**
* @see ConceptService#saveConceptReferenceTerm(ConceptReferenceTerm)
*/
@Test
public void saveConceptReferenceTerm_shouldUpdateChangesToTheConceptReferenceTermInTheDatabase() {
ConceptReferenceTerm term = Context.getConceptService().getConceptReferenceTerm(1);
// sanity checks
Assert.assertEquals(Context.getConceptService().getConceptSource(1), term.getConceptSource());
Assert.assertNull(term.getChangedBy());
Assert.assertNull(term.getDateChanged());
term.setName("new name");
term.setCode("new code");
term.setDescription("new descr");
ConceptSource conceptSource2 = Context.getConceptService().getConceptSource(2);
term.setConceptSource(conceptSource2);
ConceptReferenceTerm editedTerm = Context.getConceptService().saveConceptReferenceTerm(term);
Context.flushSession();
Assert.assertEquals("new name", editedTerm.getName());
Assert.assertEquals("new code", editedTerm.getCode());
Assert.assertEquals("new descr", editedTerm.getDescription());
Assert.assertEquals(conceptSource2, editedTerm.getConceptSource());
// The auditable fields should have been set
Assert.assertNotNull(term.getChangedBy());
Assert.assertNotNull(term.getDateChanged());
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method getConceptSourceByUniqueId_shouldGetConceptSourceWithTheGivenUniqueId.
/**
* @see ConceptService#getConceptSourceByUniqueId(String)
*/
@Test
public void getConceptSourceByUniqueId_shouldGetConceptSourceWithTheGivenUniqueId() {
String existingUniqueId = "2.16.840.1.113883.6.96";
ConceptSource conceptSource = conceptService.getConceptSourceByUniqueId(existingUniqueId);
assertThat(conceptSource, is(not(nullValue())));
assertThat(conceptSource.getUniqueId(), is(existingUniqueId));
}
Aggregations