Search in sources :

Example 66 with Practitioner

use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderTest method findPractitionersByIdentifier_shouldReturnMatchingBundleOfPractitioners.

@Test
public void findPractitionersByIdentifier_shouldReturnMatchingBundleOfPractitioners() {
    TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(PRACTITIONER_IDENTIFIER));
    when(practitionerService.searchForPractitioners(argThat(is(identifier)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(practitioner), PREFERRED_PAGE_SIZE, COUNT));
    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.iterator().next().fhirType(), is(FhirConstants.PRACTITIONER));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) Test(org.junit.Test)

Example 67 with Practitioner

use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderTest method findPractitionersByName_shouldReturnMatchingBundleOfPractitioners.

@Test
public void findPractitionersByName_shouldReturnMatchingBundleOfPractitioners() {
    StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(GIVEN_NAME)));
    when(practitionerService.searchForPractitioners(isNull(), argThat(is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(practitioner), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForPractitioners(nameParam, null, null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PRACTITIONER));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Test(org.junit.Test)

Example 68 with Practitioner

use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderTest method getPractitionerHistoryById_shouldReturnListOfResource.

@Test
public void getPractitionerHistoryById_shouldReturnListOfResource() {
    IdType id = new IdType();
    id.setValue(PRACTITIONER_UUID);
    when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
    List<Resource> resources = resourceProvider.getPractitionerHistoryById(id);
    assertThat(resources, Matchers.notNullValue());
    assertThat(resources, not(empty()));
    assertThat(resources.size(), Matchers.equalTo(2));
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.dstu3.model.Resource) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 69 with Practitioner

use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderTest method findPractitionersByGivenName_shouldReturnMatchingBundleOfPractitioners.

@Test
public void findPractitionersByGivenName_shouldReturnMatchingBundleOfPractitioners() {
    StringAndListParam givenName = new StringAndListParam().addAnd(new StringParam(PRACTITIONER_GIVEN_NAME));
    when(practitionerService.searchForPractitioners(isNull(), isNull(), argThat(is(givenName)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(practitioner), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForPractitioners(null, null, givenName, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PRACTITIONER));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.Test)

Example 70 with Practitioner

use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderTest method getPractitionerHistoryById_shouldReturnProvenanceResources.

@Test
public void getPractitionerHistoryById_shouldReturnProvenanceResources() {
    IdType id = new IdType();
    id.setValue(PRACTITIONER_UUID);
    when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
    List<Resource> resources = resourceProvider.getPractitionerHistoryById(id);
    assertThat(resources, not(empty()));
    assertThat(resources.stream().findAny().isPresent(), Matchers.is(true));
    assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.dstu3.model.Resource) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)185 Practitioner (org.hl7.fhir.r4.model.Practitioner)139 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)86 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)81 Test (org.junit.jupiter.api.Test)68 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)62 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)59 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)54 StringParam (ca.uhn.fhir.rest.param.StringParam)54 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)52 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 Identifier (org.hl7.fhir.r4.model.Identifier)32 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)30 Resource (org.hl7.fhir.r4.model.Resource)30 ArrayList (java.util.ArrayList)25 Reference (org.hl7.fhir.r4.model.Reference)24 Bundle (org.hl7.fhir.r4.model.Bundle)22 Date (java.util.Date)21 List (java.util.List)21 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20