use of org.openmrs.ConceptName in project openmrs-module-pihcore by PIH.
the class OrderEntryConceptsFromMetadataSharing method baseConcept.
private Concept baseConcept(String name) {
Concept concept = new Concept();
concept.addName(new ConceptName(name, Locale.ENGLISH));
concept.addConceptMapping(new ConceptMapBuilder(uuid()).type(sameAs).ensureTerm(pih, name).build());
return concept;
}
use of org.openmrs.ConceptName in project openmrs-module-pihcore by PIH.
the class ConceptsFromMetadataSharing method baseConcept.
private Concept baseConcept(String name) {
Concept concept = new Concept();
concept.addName(new ConceptName(name, Locale.ENGLISH));
concept.addConceptMapping(new ConceptMapBuilder(uuid()).type(sameAs).ensureTerm(pih, name).build());
return concept;
}
use of org.openmrs.ConceptName in project openmrs-core by openmrs.
the class HibernateConceptDAO method getConcepts.
/**
* @see ConceptDAO#getConcepts(String, List, boolean, List, List, List, List, Concept, Integer,
* Integer)
*/
@Override
public List<ConceptSearchResult> getConcepts(final String phrase, final List<Locale> locales, final boolean includeRetired, final List<ConceptClass> requireClasses, final List<ConceptClass> excludeClasses, final List<ConceptDatatype> requireDatatypes, final List<ConceptDatatype> excludeDatatypes, final Concept answersToConcept, final Integer start, final Integer size) throws DAOException {
LuceneQuery<ConceptName> query = newConceptNameLuceneQuery(phrase, true, locales, false, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, answersToConcept);
ListPart<ConceptName> names = query.listPart(start, size);
List<ConceptSearchResult> results = new ArrayList<>();
for (ConceptName name : names.getList()) {
results.add(new ConceptSearchResult(phrase, name.getConcept(), name));
}
return results;
}
use of org.openmrs.ConceptName in project openmrs-core by openmrs.
the class ObsServiceTest method getObservationCount_shouldReturnTheCountOfAllObservationsUsingTheSpecifiedConceptNamesAsAnswers.
/**
* @see ObsService#getObservationCount(List, boolean)
*/
@Test
public void getObservationCount_shouldReturnTheCountOfAllObservationsUsingTheSpecifiedConceptNamesAsAnswers() {
ObsService os = Context.getObsService();
Obs o = new Obs();
o.setConcept(Context.getConceptService().getConcept(3));
o.setPerson(new Patient(2));
o.setEncounter(new Encounter(3));
o.setObsDatetime(new Date());
o.setLocation(new Location(1));
ConceptName cn1 = new ConceptName(1847);
o.setValueCodedName(cn1);
os.saveObs(o, null);
Obs o2 = new Obs();
o2.setConcept(Context.getConceptService().getConcept(3));
o2.setPerson(new Patient(2));
o2.setEncounter(new Encounter(3));
o2.setObsDatetime(new Date());
o2.setLocation(new Location(1));
ConceptName cn2 = new ConceptName(2453);
o2.setValueCodedName(cn2);
os.saveObs(o2, null);
List<ConceptName> names = new LinkedList<>();
names.add(cn1);
names.add(cn2);
Assert.assertEquals(2, os.getObservationCount(names, true).intValue());
}
use of org.openmrs.ConceptName in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrderFrequency_shouldAddANewOrderFrequencyToTheDatabase.
/**
* @see OrderService#saveOrderFrequency(OrderFrequency)
*/
@Test
public void saveOrderFrequency_shouldAddANewOrderFrequencyToTheDatabase() {
Concept concept = new Concept();
concept.addName(new ConceptName("new name", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setDatatype(new ConceptDatatype(1));
concept.setConceptClass(conceptService.getConceptClassByName("Frequency"));
concept = conceptService.saveConcept(concept);
Integer originalSize = orderService.getOrderFrequencies(true).size();
OrderFrequency orderFrequency = new OrderFrequency();
orderFrequency.setConcept(concept);
orderFrequency.setFrequencyPerDay(2d);
orderFrequency = orderService.saveOrderFrequency(orderFrequency);
assertNotNull(orderFrequency.getId());
assertNotNull(orderFrequency.getUuid());
assertNotNull(orderFrequency.getCreator());
assertNotNull(orderFrequency.getDateCreated());
assertEquals(originalSize + 1, orderService.getOrderFrequencies(true).size());
}
Aggregations