Search in sources :

Example 86 with ResourceType

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

the class PatientFhirResourceProviderIntegrationTest method shouldReturnPatientTypeEverythingAsXml.

@Test
public void shouldReturnPatientTypeEverythingAsXml() throws Exception {
    MockHttpServletResponse response = get("/Patient/$everything").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle result = readBundleResponse(response);
    assertThat(result, notNullValue());
    assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(result, hasProperty("total", equalTo(46)));
    assertThat(result.getEntry(), hasSize(46));
    List<Bundle.BundleEntryComponent> entries = result.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/"))));
    assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 87 with ResourceType

use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project Gravity-SDOH-Exchange-RI by FHIR.

the class ResourceLoader method getResourcesBySystem.

public Map<Class<? extends Resource>, List<Resource>> getResourcesBySystem(IGenericClient client, String system, List<Reference> references) {
    if (references.isEmpty()) {
        return Collections.emptyMap();
    }
    Bundle loadResourcesBundle = new Bundle();
    loadResourcesBundle.setType(BundleType.TRANSACTION);
    references.stream().map(BaseReference::getReferenceElement).collect(Collectors.groupingBy(IIdType::getResourceType)).forEach((resourceType, referenceElements) -> {
        StringBuilder urlBuilder = new StringBuilder(resourceType).append("?").append("identifier").append("=");
        String searchParams = referenceElements.stream().map(element -> new StringBuilder(system).append("|").append(element.getIdPart())).map(StringBuilder::toString).collect(Collectors.joining(","));
        urlBuilder.append(searchParams);
        loadResourcesBundle.addEntry(FhirUtil.createGetEntry(urlBuilder.toString()));
    });
    return client.transaction().withBundle(loadResourcesBundle).execute().getEntry().stream().map(BundleEntryComponent::getResource).filter(Bundle.class::isInstance).map(Bundle.class::cast).map(Bundle::getEntry).flatMap(List::stream).map(BundleEntryComponent::getResource).collect(Collectors.groupingBy(Resource::getClass));
}
Also used : BaseReference(org.hl7.fhir.r4.model.BaseReference) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) List(java.util.List) IIdType(org.hl7.fhir.instance.model.api.IIdType)

Example 88 with ResourceType

use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project pathling by aehrc.

the class FhirServer method buildAggregateProviders.

@Nonnull
private List<IResourceProvider> buildAggregateProviders() {
    final List<IResourceProvider> providers = new ArrayList<>();
    // Instantiate an aggregate provider for every resource type in FHIR.
    for (final ResourceType resourceType : ResourceType.values()) {
        final IResourceProvider aggregateProvider = resourceProviderFactory.createAggregateResourceProvider(resourceType);
        providers.add(aggregateProvider);
    }
    return providers;
}
Also used : IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) ArrayList(java.util.ArrayList) ResourceType(org.hl7.fhir.r4.model.ResourceType) Nonnull(javax.annotation.Nonnull)

Example 89 with ResourceType

use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project pathling by aehrc.

the class FhirServer method buildExtractProviders.

@Nonnull
private List<IResourceProvider> buildExtractProviders() {
    final List<IResourceProvider> providers = new ArrayList<>();
    // Instantiate an extract provider for every resource type in FHIR.
    for (final ResourceType resourceType : ResourceType.values()) {
        final IResourceProvider extractProvider = resourceProviderFactory.createExtractResourceProvider(resourceType);
        providers.add(extractProvider);
    }
    return providers;
}
Also used : IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) ArrayList(java.util.ArrayList) ResourceType(org.hl7.fhir.r4.model.ResourceType) Nonnull(javax.annotation.Nonnull)

Example 90 with ResourceType

use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project pathling by aehrc.

the class FhirServer method buildSearchProviders.

@Nonnull
private List<IResourceProvider> buildSearchProviders() {
    final List<IResourceProvider> providers = new ArrayList<>();
    // Instantiate a search provider for every resource type in FHIR.
    for (final ResourceType resourceType : ResourceType.values()) {
        final IResourceProvider searchProvider = resourceProviderFactory.createSearchResourceProvider(resourceType);
        providers.add(searchProvider);
    }
    return providers;
}
Also used : IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) ArrayList(java.util.ArrayList) ResourceType(org.hl7.fhir.r4.model.ResourceType) Nonnull(javax.annotation.Nonnull)

Aggregations

JsonElement (com.google.gson.JsonElement)33 HashSet (java.util.HashSet)26 Bundle (org.hl7.fhir.r4.model.Bundle)24 ResourceType (org.hl7.fhir.r4.model.Enumerations.ResourceType)21 Test (org.junit.Test)20 Nonnull (javax.annotation.Nonnull)18 ArrayList (java.util.ArrayList)15 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)10 FhirContext (ca.uhn.fhir.context.FhirContext)9 File (java.io.File)9 Row (org.apache.spark.sql.Row)9 IdType (org.hl7.fhir.dstu3.model.IdType)9 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)9 JsonObject (com.google.gson.JsonObject)8 Test (org.junit.jupiter.api.Test)8 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)8 IOException (java.io.IOException)7 List (java.util.List)7 Bundle (org.hl7.fhir.dstu3.model.Bundle)7 Resource (org.hl7.fhir.r4.model.Resource)7