use of org.openmrs.module.fhir2.api.translators.PatientTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientGivenNameNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientGivenNameNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(PATIENT_GIVEN_NAME_NOT_MATCHED));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, 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, stringAndListParam, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), is(empty()));
}
use of org.openmrs.module.fhir2.api.translators.PatientTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnCollectionOfPatientWhenPatientDeathDateMatched.
@Test
public void searchForPatients_shouldReturnCollectionOfPatientWhenPatientDeathDateMatched() throws ParseException {
Date deathDate = dateFormatter.parse(DATE);
patient.setDeathDate(deathDate);
List<Patient> patients = new ArrayList<>();
patients.add(patient);
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(DATE).setUpperBound(DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
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, dateRangeParam, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
assertThat(get(results), not(empty()));
}
use of org.openmrs.module.fhir2.api.translators.PatientTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnCollectionOfPatientWhenLastUpdatedMatched.
@Test
public void searchForPatients_shouldReturnCollectionOfPatientWhenLastUpdatedMatched() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PATIENT_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(patient));
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, null, null, null, null, null, lastUpdated, null, null);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
assertThat(get(results), not(empty()));
}
use of org.openmrs.module.fhir2.api.translators.PatientTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnCollectionOfPatientWhenPatientStateMatched.
@Test
public void searchForPatients_shouldReturnCollectionOfPatientWhenPatientStateMatched() {
List<Patient> patients = new ArrayList<>();
patients.add(patient);
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(STATE));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "state", 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, null, stringAndListParam, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
assertThat(get(results), not(empty()));
}
use of org.openmrs.module.fhir2.api.translators.PatientTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientFamilyNameNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientFamilyNameNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(PATIENT_FAMILY_NAME_NOT_MATCHED));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, 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, stringAndListParam, null, null, null, null, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), is(empty()));
}
Aggregations