use of org.hl7.fhir.r5.model.Identifier in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldReturnEmptyCollectionByWrongIdentifier.
@Test
public void shouldReturnEmptyCollectionByWrongIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(WRONG_IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = practitionerService.searchForPractitioners(identifier, null, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.hl7.fhir.r5.model.Identifier in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldReturnServiceRequestsByParticipantIdentifier.
@Test
public void searchForServiceRequests_shouldReturnServiceRequestsByParticipantIdentifier() {
ReferenceAndListParam participantReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PARTICIPANT_IDENTIFIER).setChain(Practitioner.SP_IDENTIFIER)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resources = get(results);
assertThat(resources, notNullValue());
assertThat(resources, hasSize(equalTo(4)));
assertThat(resources, everyItem(hasProperty("requester", hasProperty("identifier", hasProperty("value", equalTo(PARTICIPANT_IDENTIFIER))))));
}
use of org.hl7.fhir.r5.model.Identifier in project openmrs-module-fhir2 by openmrs.
the class PractitionerSearchQueryTest method searchForPractitioners_shouldHandleComplexQuery.
@Test
public void searchForPractitioners_shouldHandleComplexQuery() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(PRACTITIONER_GIVEN_NAME)));
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(PRACTITIONER_IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name).addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((Practitioner) resultList.iterator().next()).getIdentifierFirstRep().getValue(), equalTo(PRACTITIONER_IDENTIFIER));
assertThat(resultList.iterator().next().getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID));
}
use of org.hl7.fhir.r5.model.Identifier in project openmrs-module-fhir2 by openmrs.
the class PractitionerSearchQueryTest method searchForPractitioners_shouldReturnEmptyCollectionWhenIdentifierNotMatched.
@Test
public void searchForPractitioners_shouldReturnEmptyCollectionWhenIdentifierNotMatched() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(NOT_FOUND_PRACTITIONER_IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, is(empty()));
}
use of org.hl7.fhir.r5.model.Identifier in project openmrs-module-fhir2 by openmrs.
the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByIdentifier.
@Test
public void searchForUsers_shouldReturnUsersByIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(USER_NAME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(IDENTIFIER_SEARCH_HANDLER, identifier);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
List<Practitioner> resultList = get(results);
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(USER_UUID));
}
Aggregations