Search in sources :

Example 11 with ConceptSource

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));
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 12 with ConceptSource

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)));
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 13 with ConceptSource

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());
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 14 with ConceptSource

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());
}
Also used : ConceptSource(org.openmrs.ConceptSource) ConceptReferenceTerm(org.openmrs.ConceptReferenceTerm) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 15 with ConceptSource

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));
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptSource (org.openmrs.ConceptSource)39 Test (org.junit.Test)29 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)28 ConceptMapType (org.openmrs.ConceptMapType)6 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)6 BindException (org.springframework.validation.BindException)6 Errors (org.springframework.validation.Errors)6 Drug (org.openmrs.Drug)5 ArrayList (java.util.ArrayList)4 Concept (org.openmrs.Concept)4 Locale (java.util.Locale)3 Criteria (org.hibernate.Criteria)3 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptSearchResult (org.openmrs.ConceptSearchResult)2 GlobalProperty (org.openmrs.GlobalProperty)2 User (org.openmrs.User)2 ConceptBuilder (org.openmrs.module.metadatadeploy.builder.ConceptBuilder)2 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2