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