Search in sources :

Example 1 with ConceptName

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;
}
Also used : Concept(org.openmrs.Concept) ConceptMapBuilder(org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder) ConceptName(org.openmrs.ConceptName)

Example 2 with ConceptName

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;
}
Also used : Concept(org.openmrs.Concept) ConceptMapBuilder(org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder) ConceptName(org.openmrs.ConceptName)

Example 3 with ConceptName

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;
}
Also used : ArrayList(java.util.ArrayList) ConceptName(org.openmrs.ConceptName) ConceptSearchResult(org.openmrs.ConceptSearchResult)

Example 4 with ConceptName

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());
}
Also used : Obs(org.openmrs.Obs) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) ConceptName(org.openmrs.ConceptName) Date(java.util.Date) LinkedList(java.util.LinkedList) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 5 with ConceptName

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());
}
Also used : Concept(org.openmrs.Concept) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) OrderFrequency(org.openmrs.OrderFrequency) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Aggregations

ConceptName (org.openmrs.ConceptName)100 Test (org.junit.Test)78 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)71 Concept (org.openmrs.Concept)62 ConceptDescription (org.openmrs.ConceptDescription)42 ConceptDatatype (org.openmrs.ConceptDatatype)34 ConceptClass (org.openmrs.ConceptClass)33 Locale (java.util.Locale)32 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)22 ArrayList (java.util.ArrayList)11 Date (java.util.Date)9 Obs (org.openmrs.Obs)9 BindException (org.springframework.validation.BindException)8 ConceptMap (org.openmrs.ConceptMap)7 Errors (org.springframework.validation.Errors)7 LinkedList (java.util.LinkedList)6 List (java.util.List)6 Patient (org.openmrs.Patient)6 Encounter (org.openmrs.Encounter)5 OrderFrequency (org.openmrs.OrderFrequency)5