Search in sources :

Example 96 with Identifier

use of org.hl7.fhir.r4b.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());
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 97 with Identifier

use of org.hl7.fhir.r4b.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))))));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 98 with Identifier

use of org.hl7.fhir.r4b.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));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 99 with Identifier

use of org.hl7.fhir.r4b.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()));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 100 with Identifier

use of org.hl7.fhir.r4b.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));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)212 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)90 Test (org.junit.jupiter.api.Test)84 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)66 ArrayList (java.util.ArrayList)62 Reference (org.hl7.fhir.r4.model.Reference)57 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Patient (org.hl7.fhir.r4.model.Patient)55 Coding (org.hl7.fhir.r4.model.Coding)49 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)41 Practitioner (org.hl7.fhir.r4.model.Practitioner)41 Date (java.util.Date)40 List (java.util.List)40 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)34 Collectors (java.util.stream.Collectors)31