use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientStateNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientStateNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(UNKNOWN_ADDRESS));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "state", stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, null, stringAndListParam, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldSearchForPatientsByGivenName.
@Test
public void searchForPatients_shouldSearchForPatientsByGivenName() {
List<Patient> patients = new ArrayList<>();
patients.add(patient);
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(PATIENT_GIVEN_NAME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PATIENT_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(patients);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(patientTranslator.toFhirResource(patient)).thenReturn(fhirPatient);
IBundleProvider results = patientService.searchForPatients(null, stringAndListParam, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
assertThat(get(results), not(empty()));
assertThat(get(results), hasSize(equalTo(1)));
}
use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnCollectionOfPatientWhenPatientCityMatched.
@Test
public void searchForPatients_shouldReturnCollectionOfPatientWhenPatientCityMatched() {
List<Patient> patients = new ArrayList<>();
patients.add(patient);
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(CITY));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "city", stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PATIENT_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(patients);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(patientTranslator.toFhirResource(patient)).thenReturn(fhirPatient);
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, stringAndListParam, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
assertThat(get(results), not(empty()));
}
use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientPostalCodeNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientPostalCodeNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(UNKNOWN_ADDRESS));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "postalCode", stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, null, null, stringAndListParam, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientCityNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientCityNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(UNKNOWN_ADDRESS));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "city", stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, stringAndListParam, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
Aggregations