Search in sources :

Example 31 with ConceptSource

use of org.openmrs.ConceptSource 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)

Example 32 with ConceptSource

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

the class ConceptServiceTest method getConceptSourceByName_shouldGetConceptSourceWithTheGivenName.

@Test
public void getConceptSourceByName_shouldGetConceptSourceWithTheGivenName() {
    ConceptSource conceptSource = conceptService.getConceptSourceByName("SNOMED CT");
    assertEquals("Method did not retrieve ConceptSource by name", Integer.valueOf(2), conceptSource.getConceptSourceId());
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 33 with ConceptSource

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

the class ConceptServiceTest method getDrugsByMapping_shouldMatchOnTheCode.

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

Example 34 with ConceptSource

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

the class ConceptServiceTest method getConceptSourceByHL7Code_shouldGetConceptSourceWithTheGivenUniqueId.

/**
 * @see ConceptService#getConceptSourceByHL7Code(String)
 */
@Test
public void getConceptSourceByHL7Code_shouldGetConceptSourceWithTheGivenUniqueId() {
    String existinghl7Code = "SCT";
    ConceptSource conceptSource = conceptService.getConceptSourceByHL7Code(existinghl7Code);
    assertThat(conceptSource, is(not(nullValue())));
    assertThat(conceptSource.getHl7Code(), is(existinghl7Code));
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 35 with ConceptSource

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

the class ConceptServiceTest method saveConceptSource_shouldNotSetCreatorIfOneIsSuppliedAlready.

/**
 * @see ConceptService#saveConceptSource(ConceptSource)
 */
@Test
public void saveConceptSource_shouldNotSetCreatorIfOneIsSuppliedAlready() {
    // a user that isn't logged in now
    User expectedCreator = new User(501);
    ConceptSource newConceptSource = new ConceptSource();
    newConceptSource.setName("name");
    newConceptSource.setDescription("desc");
    newConceptSource.setHl7Code("hl7Code");
    newConceptSource.setCreator(expectedCreator);
    Context.getConceptService().saveConceptSource(newConceptSource);
    Assert.assertEquals(newConceptSource.getCreator(), expectedCreator);
}
Also used : User(org.openmrs.User) 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