use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirAllergyIntoleranceServiceImplTest method searchForAllergies_shouldSearchForAllergiesByClinicalStatus.
@Test
public void searchForAllergies_shouldSearchForAllergiesByClinicalStatus() {
List<Allergy> allergies = new ArrayList<>();
allergies.add(omrsAllergy);
TokenAndListParam status = new TokenAndListParam();
status.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue("active")));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.BOOLEAN_SEARCH_HANDLER, status);
when(allergyIntoleranceDao.getSearchResults(any(), any())).thenReturn(allergies);
when(allergyIntoleranceDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ALLERGY_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, allergyIntoleranceDao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(omrsAllergy)).thenReturn(fhirAllergy);
IBundleProvider results = service.searchForAllergies(null, null, null, null, null, status, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirAllergyIntoleranceServiceImplTest method searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude.
@Test
public void searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude() {
HashSet<Include> includes = new HashSet<>();
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
when(allergyIntoleranceDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(omrsAllergy));
when(allergyIntoleranceDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ALLERGY_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, allergyIntoleranceDao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(omrsAllergy)).thenReturn(fhirAllergy);
IBundleProvider results = service.searchForAllergies(null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirAllergyIntoleranceServiceImplTest method searchForAllergies_shouldSearchForAllergiesByPatientFamilyName.
@Test
public void searchForAllergies_shouldSearchForAllergiesByPatientFamilyName() {
List<Allergy> allergies = new ArrayList<>();
allergies.add(omrsAllergy);
ReferenceAndListParam patientParam = new ReferenceAndListParam();
ReferenceParam referenceParam = new ReferenceParam();
referenceParam.setValue("John");
referenceParam.setChain(Patient.SP_FAMILY);
patientParam.addValue(new ReferenceOrListParam().add(referenceParam));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientParam);
when(allergyIntoleranceDao.getSearchResults(any(), any())).thenReturn(allergies);
when(allergyIntoleranceDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ALLERGY_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, allergyIntoleranceDao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(omrsAllergy)).thenReturn(fhirAllergy);
IBundleProvider results = service.searchForAllergies(patientParam, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList, not(empty()));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirAllergyIntoleranceServiceImplTest method searchForAllergies_shouldSearchForAllergiesBySeverity.
@Test
public void searchForAllergies_shouldSearchForAllergiesBySeverity() {
List<Allergy> allergies = new ArrayList<>();
allergies.add(omrsAllergy);
TokenAndListParam severity = new TokenAndListParam();
severity.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(SEVERITY_CONCEPT_UUID)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.SEVERITY_SEARCH_HANDLER, severity);
when(allergyIntoleranceDao.getSearchResults(any(), any())).thenReturn(allergies);
when(allergyIntoleranceDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ALLERGY_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, allergyIntoleranceDao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(omrsAllergy)).thenReturn(fhirAllergy);
IBundleProvider results = service.searchForAllergies(null, null, null, severity, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirAllergyIntoleranceServiceImplTest method searchForAllergies_shouldSearchForAllergiesByAllergen.
@Test
public void searchForAllergies_shouldSearchForAllergiesByAllergen() {
List<Allergy> allergies = new ArrayList<>();
allergies.add(omrsAllergy);
TokenAndListParam allergen = new TokenAndListParam();
allergen.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODED_ALLERGEN_UUID)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ALLERGEN_SEARCH_HANDLER, allergen);
when(allergyIntoleranceDao.getSearchResults(any(), any())).thenReturn(allergies);
when(allergyIntoleranceDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ALLERGY_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, allergyIntoleranceDao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(omrsAllergy)).thenReturn(fhirAllergy);
IBundleProvider results = service.searchForAllergies(null, null, allergen, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList, not(empty()));
}
Aggregations