Search in sources :

Example 21 with ConceptService

use of org.openmrs.api.ConceptService in project openmrs-core by openmrs.

the class ConceptDAOTest method getConcepts_shouldReturnCorrectResultsIfAConceptNameContainsSameWordMoreThanOnce.

/**
 * @see {@link
 *      ConceptDAO#getConcepts(String,List<Locale>,null,List<ConceptClass>,List<ConceptClass>,
 *      List<ConceptDatatype>,List<ConceptDatatype>,Concept,Integer,Integer)}
 */
@SuppressWarnings("unchecked")
@Test
@Ignore
public void getConcepts_shouldReturnCorrectResultsIfAConceptNameContainsSameWordMoreThanOnce() {
    ConceptService cs = Context.getConceptService();
    ConceptClass cc = cs.getConceptClass(1);
    Locale locale = Locale.ENGLISH;
    ConceptDatatype dt = cs.getConceptDatatype(4);
    Concept c1 = new Concept();
    ConceptName cn1a = new ConceptName("ONE TERM", locale);
    c1.addName(cn1a);
    c1.setConceptClass(cc);
    c1.setDatatype(dt);
    cs.saveConcept(c1);
    ConceptName cn1b = new ConceptName("ONE TO ONE", locale);
    cn1b.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
    cn1b.setLocalePreferred(true);
    c1.addName(cn1b);
    cs.saveConcept(c1);
    Assert.assertTrue(cn1a.isSynonym());
    Assert.assertTrue(cn1b.getConceptNameId() > cn1a.getConceptNameId());
    Concept c2 = new Concept();
    ConceptName cn2a = new ConceptName("ONE TO MANY", locale);
    c2.addName(cn2a);
    c2.setConceptClass(cc);
    c2.setDatatype(dt);
    cs.saveConcept(c2);
    updateSearchIndex();
    List<ConceptSearchResult> searchResults1 = dao.getConcepts("one", Collections.singletonList(locale), false, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, null, null, null);
    Assert.assertEquals(2, searchResults1.size());
    Assert.assertEquals(c1, searchResults1.get(0).getConcept());
    Assert.assertEquals(cn1b, searchResults1.get(0).getConceptName());
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptSearchResult(org.openmrs.ConceptSearchResult) ConceptService(org.openmrs.api.ConceptService) ConceptDatatype(org.openmrs.ConceptDatatype) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptService (org.openmrs.api.ConceptService)21 Test (org.junit.Test)11 Concept (org.openmrs.Concept)11 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)11 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 ArrayList (java.util.ArrayList)4 ConceptName (org.openmrs.ConceptName)4 Encounter (org.openmrs.Encounter)4 Patient (org.openmrs.Patient)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 CareSetting (org.openmrs.CareSetting)3 ConceptDescription (org.openmrs.ConceptDescription)3 OrderFrequency (org.openmrs.OrderFrequency)3 FileNotFoundException (java.io.FileNotFoundException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 Date (java.util.Date)2 StringTokenizer (java.util.StringTokenizer)2