Search in sources :

Example 26 with ConceptSource

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

the class HibernateConceptDAO method getConceptSourceByName.

/**
 * @see org.openmrs.api.db.ConceptDAO#getConceptSourceByName(java.lang.String)
 */
@Override
public ConceptSource getConceptSourceByName(String conceptSourceName) throws DAOException {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptSource.class, "source");
    criteria.add(Restrictions.eq("source.name", conceptSourceName));
    return (ConceptSource) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) ConceptSource(org.openmrs.ConceptSource)

Example 27 with ConceptSource

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

the class HibernateConceptDAO method getConceptSourceByUniqueId.

/**
 * @see org.openmrs.api.db.ConceptDAO#getConceptSourceByUniqueId(java.lang.String)
 */
@Override
public ConceptSource getConceptSourceByUniqueId(String uniqueId) {
    if (StringUtils.isBlank(uniqueId)) {
        return null;
    }
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptSource.class);
    criteria.add(Restrictions.eq("uniqueId", uniqueId));
    return (ConceptSource) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) ConceptSource(org.openmrs.ConceptSource)

Example 28 with ConceptSource

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

the class HibernateConceptDAO method getConceptSourceByHL7Code.

/**
 * @see org.openmrs.api.db.ConceptDAO#getConceptSourceByHL7Code(java.lang.String)
 */
@Override
public ConceptSource getConceptSourceByHL7Code(String hl7Code) {
    if (StringUtils.isBlank(hl7Code)) {
        return null;
    }
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptSource.class);
    criteria.add(Restrictions.eq("hl7Code", hl7Code));
    return (ConceptSource) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) ConceptSource(org.openmrs.ConceptSource)

Example 29 with ConceptSource

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

the class ConceptServiceTest method getDrugsByMapping_shouldGetAListOfAllDrugsThatMatchOnAllTheParameterValues.

/**
 * @see ConceptService#getDrugsByMapping(String, org.openmrs.ConceptSource,
 *      java.util.Collection, boolean)
 */
@Test
public void getDrugsByMapping_shouldGetAListOfAllDrugsThatMatchOnAllTheParameterValues() {
    executeDataSet(GET_DRUG_MAPPINGS);
    List<ConceptMapType> conceptMapTypeList = new ArrayList<>();
    conceptMapTypeList.add(conceptService.getConceptMapType(1));
    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) ArrayList(java.util.ArrayList) ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 30 with ConceptSource

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

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