Search in sources :

Example 26 with StringParam

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());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 27 with StringParam

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)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 28 with StringParam

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()));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 29 with StringParam

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());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 30 with StringParam

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());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

StringParam (ca.uhn.fhir.rest.param.StringParam)271 Test (org.junit.Test)251 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)248 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)243 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)173 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)154 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)116 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)101 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)37 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)30 Practitioner (org.hl7.fhir.r4.model.Practitioner)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)21 Patient (org.hl7.fhir.r4.model.Patient)21 TokenParam (ca.uhn.fhir.rest.param.TokenParam)20 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)18 NumberParam (ca.uhn.fhir.rest.param.NumberParam)16 Observation (org.hl7.fhir.r4.model.Observation)16 Location (org.hl7.fhir.r4.model.Location)14 Person (org.hl7.fhir.r4.model.Person)14 SortSpec (ca.uhn.fhir.rest.api.SortSpec)13