use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.
the class ConceptServiceTest method getConcepts_shouldReturnPreferredNamesHigher.
/**
* @see ConceptService#getConcepts(String,List,boolean,List,List,List,List,Concept,Integer,Integer)
*/
@Test
public void getConcepts_shouldReturnPreferredNamesHigher() {
Concept hivProgram = conceptService.getConceptByName("hiv program");
ConceptName synonym = new ConceptName("synonym", Context.getLocale());
hivProgram.addName(synonym);
conceptService.saveConcept(hivProgram);
Concept mdrTbProgram = conceptService.getConceptByName("mdr-tb program");
synonym = new ConceptName("synonym", Context.getLocale());
synonym.setLocalePreferred(true);
mdrTbProgram.addName(synonym);
conceptService.saveConcept(mdrTbProgram);
updateSearchIndex();
List<ConceptSearchResult> concepts = conceptService.getConcepts("synonym", null, false, null, null, null, null, null, null, null);
assertThat(concepts, contains(hasConcept(is(mdrTbProgram)), hasConcept(is(hivProgram))));
}
use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.
the class ConceptServiceTest method getConcepts_shouldNotReturnConceptsWithMatchingNamesThatAreVoided.
/**
* @see ConceptService#getConcepts(String,List<Locale>,null,List<ConceptClass>,List<
* ConceptClass>,List<ConceptDatatype>,List<ConceptDatatype>,Concept,Integer,Integer)
*/
@Test
public void getConcepts_shouldNotReturnConceptsWithMatchingNamesThatAreVoided() {
Concept concept = conceptService.getConcept(7);
List<ConceptSearchResult> results = conceptService.getConcepts("VOIDED", Collections.singletonList(Locale.ENGLISH), false, null, null, null, null, null, null, null);
for (ConceptSearchResult result : results) {
assertThat(result.getConcept(), not(concept));
}
}
use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.
the class ConceptServiceTest method getConcepts_shouldFindConceptByFullCode.
/**
* @see ConceptService#getConcepts(String,List,boolean,List,List,List,List,Concept,Integer,Integer)
*/
@Test
public void getConcepts_shouldFindConceptByFullCode() {
// given
String code1 = "CD41003";
String code2 = "7345693";
Concept concept = conceptService.getConceptByMapping(code2, "SNOMED CT");
// when
List<ConceptSearchResult> concepts1 = conceptService.getConcepts(code1, Collections.singletonList(Context.getLocale()), false, null, null, null, null, null, null, null);
List<ConceptSearchResult> concepts2 = conceptService.getConcepts(code2, Collections.singletonList(Context.getLocale()), false, null, null, null, null, null, null, null);
// then
assertThat(concepts1, contains(hasConcept(is(concept))));
assertThat(concepts2, contains(hasConcept(is(concept))));
}
use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.
the class ConceptServiceTest method getConcepts_shouldReturnASearchResultForPhraseWithStopWords.
/**
* @see ConceptService#getConcepts(String, List, boolean, List, List, List, List, Concept, Integer, Integer)
*/
@Test
public void getConcepts_shouldReturnASearchResultForPhraseWithStopWords() {
executeDataSet("org/openmrs/api/include/ConceptServiceTest-names.xml");
conceptService.saveConceptStopWord(new ConceptStopWord("OF", Locale.US));
List<ConceptSearchResult> searchResults = conceptService.getConcepts("tuberculosis of knee", Collections.singletonList(new Locale("en", "US")), false, null, null, null, null, null, null, null);
Assert.assertEquals(1, searchResults.size());
Assert.assertEquals("Tuberculosis of Knee", searchResults.get(0).getConceptName().getName());
}
use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.
the class ConceptServiceTest method getConcepts_shouldPassWithAndOrNotWords.
/**
* @see ConceptService#getConcepts(String, List, boolean, List, List, List, List, Concept, Integer, Integer)
*/
@Test
public void getConcepts_shouldPassWithAndOrNotWords() {
executeDataSet("org/openmrs/api/include/ConceptServiceTest-names.xml");
// search phrase with AND
List<ConceptSearchResult> searchResults = conceptService.getConcepts("AND SALBUTAMOL INHALER", Collections.singletonList(new Locale("en", "US")), false, null, null, null, null, null, null, null);
Assert.assertEquals(1, searchResults.size());
assertThat(searchResults.get(0).getWord(), is("AND SALBUTAMOL INHALER"));
// search phrase with OR
searchResults = conceptService.getConcepts("SALBUTAMOL OR INHALER", Collections.singletonList(new Locale("en", "US")), false, null, null, null, null, null, null, null);
Assert.assertEquals(1, searchResults.size());
assertThat(searchResults.get(0).getWord(), is("SALBUTAMOL OR INHALER"));
// search phrase with NOT
searchResults = conceptService.getConcepts("SALBUTAMOL INHALER NOT", Collections.singletonList(new Locale("en", "US")), false, null, null, null, null, null, null, null);
Assert.assertEquals(1, searchResults.size());
assertThat(searchResults.get(0).getWord(), is("SALBUTAMOL INHALER NOT"));
}
Aggregations