Search in sources :

Example 91 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class ConformanceProvider method buildSecurity.

@Nonnull
private CapabilityStatementRestSecurityComponent buildSecurity() {
    final CapabilityStatementRestSecurityComponent security = new CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    if (configuration.getAuth().isEnabled()) {
        final OidcConfiguration checkedConfig = checkPresent(oidcConfiguration);
        final CodeableConcept smart = new CodeableConcept(new Coding(RESTFUL_SECURITY_URI, RESTFUL_SECURITY_CODE, RESTFUL_SECURITY_CODE));
        smart.setText("OAuth2 using SMART-on-FHIR profile (see http://docs.smarthealthit.org)");
        security.getService().add(smart);
        final Optional<String> authUrl = checkedConfig.get(AUTH_URL);
        final Optional<String> tokenUrl = checkedConfig.get(TOKEN_URL);
        final Optional<String> revokeUrl = checkedConfig.get(REVOKE_URL);
        if (authUrl.isPresent() || tokenUrl.isPresent() || revokeUrl.isPresent()) {
            final Extension oauthUris = new Extension(SMART_OAUTH_URI);
            authUrl.ifPresent(url -> oauthUris.addExtension("authorize", new UriType(url)));
            tokenUrl.ifPresent(url -> oauthUris.addExtension("token", new UriType(url)));
            revokeUrl.ifPresent(url -> oauthUris.addExtension("revoke", new UriType(url)));
            security.addExtension(oauthUris);
        }
    }
    return security;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) OidcConfiguration(au.csiro.pathling.security.OidcConfiguration) Coding(org.hl7.fhir.r4.model.Coding) CapabilityStatementRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) UriType(org.hl7.fhir.r4.model.UriType) Nonnull(javax.annotation.Nonnull)

Example 92 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class ConformanceProvider method getServerConformance.

@Override
@Metadata(cacheMillis = 0)
public CapabilityStatement getServerConformance(@Nullable final HttpServletRequest httpServletRequest, @Nullable final RequestDetails requestDetails) {
    log.debug("Received request for server capabilities");
    final CapabilityStatement capabilityStatement = new CapabilityStatement();
    capabilityStatement.setUrl(getCapabilityUri());
    capabilityStatement.setVersion(version.getBuildVersion().orElse(UNKNOWN_VERSION));
    capabilityStatement.setTitle("Pathling FHIR API");
    capabilityStatement.setName("pathling-fhir-api");
    capabilityStatement.setStatus(PublicationStatus.ACTIVE);
    capabilityStatement.setExperimental(true);
    capabilityStatement.setPublisher("Australian e-Health Research Centre, CSIRO");
    capabilityStatement.setCopyright("Dedicated to the public domain via CC0: https://creativecommons.org/publicdomain/zero/1.0/");
    capabilityStatement.setKind(CapabilityStatementKind.INSTANCE);
    final CapabilityStatementSoftwareComponent software = new CapabilityStatementSoftwareComponent(new StringType("Pathling"));
    software.setVersion(version.getDescriptiveVersion().orElse(UNKNOWN_VERSION));
    capabilityStatement.setSoftware(software);
    final CapabilityStatementImplementationComponent implementation = new CapabilityStatementImplementationComponent(new StringType(configuration.getImplementationDescription()));
    final Optional<String> serverBase = getServerBase(Optional.ofNullable(httpServletRequest));
    serverBase.ifPresent(implementation::setUrl);
    capabilityStatement.setImplementation(implementation);
    capabilityStatement.setFhirVersion(FHIRVersion._4_0_1);
    capabilityStatement.setFormat(Arrays.asList(new CodeType("json"), new CodeType("xml")));
    capabilityStatement.setRest(buildRestComponent());
    return capabilityStatement;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) CapabilityStatementImplementationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) CapabilityStatementSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent) CodeType(org.hl7.fhir.r4.model.CodeType) Metadata(ca.uhn.fhir.rest.annotation.Metadata)

Example 93 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class FhirServer method buildUpdateProviders.

@Nonnull
private List<IResourceProvider> buildUpdateProviders() {
    final List<IResourceProvider> providers = new ArrayList<>();
    for (final ResourceType resourceType : ResourceType.values()) {
        final IResourceProvider updateProvider = resourceProviderFactory.createUpdateResourceProvider(resourceType);
        providers.add(updateProvider);
    }
    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 94 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class FhirServer method resourceTypeFromClass.

/**
 * @param resourceClass a class that extends {@link IBaseResource}
 * @return a {@link Enumerations.ResourceType} enum
 */
@Nonnull
public static Enumerations.ResourceType resourceTypeFromClass(@Nonnull final Class<? extends IBaseResource> resourceClass) {
    try {
        final Constructor<? extends IBaseResource> constructor = resourceClass.getConstructor();
        final IBaseResource instance = constructor.newInstance();
        return Enumerations.ResourceType.fromCode(instance.fhirType());
    } catch (final NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
        throw new RuntimeException("Problem determining FHIR type from resource class", e);
    }
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) Nonnull(javax.annotation.Nonnull)

Example 95 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class OperationDefinitionProvider method getOperationDefinitionById.

/**
 * Handles all read requests to the OperationDefinition resource.
 *
 * @param id the ID of the desired OperationDefinition
 * @return an {@link OperationDefinition} resource
 */
@Read
@SuppressWarnings("unused")
public OperationDefinition getOperationDefinitionById(@Nullable @IdParam final IIdType id) {
    checkUserInput(id != null, "Missing ID parameter");
    final String idString = id.getValue();
    final OperationDefinition resource = resources.get(idString);
    if (resource == null) {
        throw new ResourceNotFoundError("OperationDefinition not found: " + idString);
    }
    return resource;
}
Also used : ResourceNotFoundError(au.csiro.pathling.errors.ResourceNotFoundError) OperationDefinition(org.hl7.fhir.r4.model.OperationDefinition) Read(ca.uhn.fhir.rest.annotation.Read)

Aggregations

Test (org.junit.jupiter.api.Test)229 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)85 HashMap (java.util.HashMap)83 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)59 List (java.util.List)53 Bundle (org.hl7.fhir.dstu3.model.Bundle)50 Nonnull (javax.annotation.Nonnull)48 Patient (org.hl7.fhir.dstu3.model.Patient)46 Organization (org.hl7.fhir.dstu3.model.Organization)45 ArrayList (java.util.ArrayList)44 Bundle (org.hl7.fhir.r4.model.Bundle)41 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 UUID (java.util.UUID)38 Collectors (java.util.stream.Collectors)38 Coding (org.hl7.fhir.r4.model.Coding)34 FhirContext (ca.uhn.fhir.context.FhirContext)33 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)32 IParser (ca.uhn.fhir.parser.IParser)31 IOException (java.io.IOException)29 IdType (org.hl7.fhir.dstu3.model.IdType)28