Search in sources :

Example 56 with Base

use of org.hl7.fhir.dstu2.model.Base in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ORUMessageTest method test_oru_with_multiple_reports.

// Suppress warnings about too many assertions in a test.  Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void test_oru_with_multiple_reports() throws IOException {
    String hl7message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|112^Final Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3068^JOHN^Paul^J|\r" + "OBX|1|ST|TS-F-01-007^Endocrine Disorders 7^L||obs report||||||F\r" + "OBX|2|ST|TS-F-01-008^Endocrine Disorders 8^L||ECHOCARDIOGRAPHIC REPORT||||||F\r" + "OBR|1||98^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|113^Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3065^Mahoney^Paul^J|\r" + "OBX|1|CWE|625-4^Bacteria identified in Stool by Culture^LN^^^^2.33^^result1|1|27268008^Salmonella^SCT^^^^20090731^^Salmonella species|||A^A^HL70078^^^^2.5|||P|||20120301|||^^^^^^^^Bacterial Culture||201203140957||||||\r" + "OBX|2|ST|TS-F-01-002^Endocrine Disorders^L||ECHOCARDIOGRAPHIC REPORT Group 2||||||F\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Verify that the right resources are being created
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patientResource).hasSize(1);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(4);
    List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    assertThat(practitionerResource).hasSize(2);
    List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    assertThat(diagnosticReport).hasSize(2);
    List<Resource> servReqResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    assertThat(servReqResource).hasSize(2);
    // Expecting only the above resources, no extras!
    assertThat(e).hasSize(11);
    // /////////////////////////////////////////
    // Now confirm content of the FIRST diagnosticReport because we don't have separate tests for DiagnosticReport
    // /////////////////////////////////////////
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
    // Verify status from OBR.25
    assertThat(diag.getStatus().toCode()).isEqualTo("final");
    // Verify category from OBR.24
    assertThat(diag.getCategory()).isEmpty();
    // Verify code from OBR.4
    assertThat(diag.hasCode()).isTrue();
    List<Coding> codings = diag.getCode().getCoding();
    assertThat(codings).hasSize(1);
    Coding coding = codings.get(0);
    assertThat(coding.hasDisplay()).isTrue();
    assertThat(coding.getDisplay()).hasToString("Final Echocardiogram Report");
    assertThat(coding.hasCode()).isTrue();
    assertThat(coding.getCode()).hasToString("112");
    assertThat(coding.hasSystem()).isFalse();
    // Verify encounter reference
    assertThat(diag.getEncounter().isEmpty()).isTrue();
    // Verify subject reference
    assertThat(diag.getSubject().isEmpty()).isFalse();
    // Verify effectiveDateTime from OBR.7 and OBR.8
    // This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
    assertThat(diag.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
    // Verify issued from OBR.22
    assertThat(diag.getIssued()).isNull();
    // Verify resultsInterpreter from OBR.32
    assertThat(diag.getResultsInterpreter()).hasSize(1);
    // Verify basedOn is ref to the ServiceRequest created for ORC or OBR
    assertThat(diag.getBasedOn()).hasSize(1);
    assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
    // Verify specimen reference
    assertThat(diag.getSpecimen()).isEmpty();
    // Verify result reference
    List<Reference> obsRef = diag.getResult();
    assertThat(obsRef).hasSize(2);
    assertThat(obsRef.get(0).isEmpty()).isFalse();
    // Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not of type TX.
    List<Attachment> attachments = diag.getPresentedForm();
    Assertions.assertEquals(0, attachments.size(), "Unexpected number of attachments");
    // /////////////////////////////////////////
    // Now confirm content of the SECOND diagnosticReport because we don't have separate tests for DiagnosticReport
    // /////////////////////////////////////////
    DiagnosticReport diag2 = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
    // Verify status from OBR.25
    assertThat(diag2.getStatus().toCode()).isEqualTo("final");
    // Verify category from OBR.24
    assertThat(diag2.getCategory()).isEmpty();
    // Verify code from OBR.4
    assertThat(diag2.hasCode()).isTrue();
    List<Coding> codings2 = diag2.getCode().getCoding();
    assertThat(codings2).hasSize(1);
    Coding coding2 = codings.get(0);
    assertThat(coding2.hasDisplay()).isTrue();
    assertThat(coding2.getDisplay()).hasToString("Final Echocardiogram Report");
    assertThat(coding2.hasCode()).isTrue();
    assertThat(coding2.getCode()).hasToString("112");
    assertThat(coding2.hasSystem()).isFalse();
    // Verify encounter reference
    assertThat(diag2.getEncounter().isEmpty()).isTrue();
    // Verify subject reference
    assertThat(diag2.getSubject().isEmpty()).isFalse();
    // Verify effectiveDateTime from OBR.7 and OBR.8
    // This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
    assertThat(diag2.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
    // Verify issued from OBR.22
    assertThat(diag2.getIssued()).isNull();
    // Verify resultsInterpreter from OBR.32
    assertThat(diag2.getResultsInterpreter()).hasSize(1);
    // Verify basedOn is ref to the ServiceRequest created for ORC or OBR
    assertThat(diag.getBasedOn()).hasSize(1);
    assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
    // Verify specimen reference
    assertThat(diag2.getSpecimen()).isEmpty();
    // Verify result reference
    List<Reference> obsRef2 = diag2.getResult();
    assertThat(obsRef2).hasSize(2);
    assertThat(obsRef2.get(0).isEmpty()).isFalse();
    // Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not type TX.
    List<Attachment> attachments2 = diag2.getPresentedForm();
    Assertions.assertEquals(0, attachments2.size(), "Unexpected number of attachments");
    // //////////////////////////////////
    for (Resource res : obsResource) {
        // Verify encounter reference is not set
        Observation obs = (Observation) res;
        assertThat(obs.getEncounter().isEmpty()).isTrue();
        // Verify subject reference to Patient exists
        Base subject = ResourceUtils.getValue(obs, "subject");
        assertThat(ResourceUtils.getValueAsString(subject, "reference").substring(0, 8)).isEqualTo("Patient/");
    }
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Attachment(org.hl7.fhir.r4.model.Attachment) Base(org.hl7.fhir.r4.model.Base) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test)

Example 57 with Base

use of org.hl7.fhir.dstu2.model.Base in project Gravity-SDOH-Exchange-RI by FHIR.

the class ProblemBundleToDtoConverter method conditionInfoToDto.

@Override
protected ProblemDto conditionInfoToDto(ConditionInfoBundleExtractor.ConditionInfoHolder conditionInfo) {
    // TODO refactor this. Avoid manual casting. Refactor the design of a base class instead.
    Assert.isInstanceOf(ProblemInfoBundleExtractor.ProblemInfoHolder.class, conditionInfo, "conditionInfo must be a ProblemInfoHolder.");
    ProblemInfoBundleExtractor.ProblemInfoHolder probleminfo = (ProblemInfoBundleExtractor.ProblemInfoHolder) conditionInfo;
    Condition condition = probleminfo.getCondition();
    ProblemDto problemDto = super.conditionInfoToDto(probleminfo);
    // Onset must be available for the problem list items.
    if (condition.getOnset() != null) {
        problemDto.setStartDate(FhirUtil.toLocalDateTime((DateTimeType) condition.getOnset()));
    } else {
        problemDto.getErrors().add("Condition is a problem-list-item but an onset property is missing or not of a DateTimeType " + "type.");
    }
    problemDto.getTasks().addAll(probleminfo.getTasks().stream().map(t -> new TaskInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
    problemDto.getGoals().addAll(probleminfo.getGoals().stream().map(t -> new GoalInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
    return problemDto;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) GoalInfoDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.GoalInfoDto) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) TaskInfoDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskInfoDto) ProblemInfoBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.ProblemInfoBundleExtractor) ProblemDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ProblemDto)

Example 58 with Base

use of org.hl7.fhir.dstu2.model.Base in project Gravity-SDOH-Exchange-RI by FHIR.

the class AuthorizationClient method getTokenResponse.

/**
 * Extract token endpoint url from the Authorization Server metadata endpoint and return token response after
 * successful authentication.
 *
 * @param authServerUrl Authorization Server Base URL
 * @param clientId      OAuth2 Client ID
 * @param secret        OAuth2 Client Secret
 * @param scope         OAuth2 Client Scope
 * @return {@link TokenResponse} entity
 * @throws AuthClientException will be thrown if token retrieval fails
 */
public TokenResponse getTokenResponse(URI authServerUrl, String clientId, String secret, String scope) throws AuthClientException {
    HttpEntity<MultiValueMap<String, String>> entity = createRequestEntity(clientId, secret, scope);
    String tokenEndpoint = getTokenEndpoint(authServerUrl);
    try {
        return restTemplate.exchange(tokenEndpoint, HttpMethod.POST, entity, TokenResponse.class).getBody();
    } catch (RestClientException e) {
        throw new AuthClientException(e.getMessage(), e);
    }
}
Also used : AuthClientException(org.hl7.gravity.refimpl.sdohexchange.exception.AuthClientException) RestClientException(org.springframework.web.client.RestClientException) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Example 59 with Base

use of org.hl7.fhir.dstu2.model.Base in project drug-formulary-ri by HL7-DaVinci.

the class JpaRestfulServer method initialize.

@SuppressWarnings("unchecked")
@Override
protected void initialize() throws ServletException {
    super.initialize();
    /*
     * Create a FhirContext object that uses the version of FHIR
     * specified in the properties file.
     */
    ApplicationContext appCtx = (ApplicationContext) getServletContext().getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
    // Customize supported resource types
    Set<String> supportedResourceTypes = HapiProperties.getSupportedResourceTypes();
    if (!supportedResourceTypes.isEmpty() && !supportedResourceTypes.contains("SearchParameter")) {
        supportedResourceTypes.add("SearchParameter");
    }
    if (!supportedResourceTypes.isEmpty()) {
        DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class);
        daoRegistry.setSupportedResourceTypes(supportedResourceTypes);
    }
    /*
     * ResourceProviders are fetched from the Spring context
     */
    FhirVersionEnum fhirVersion = HapiProperties.getFhirVersion();
    ResourceProviderFactory resourceProviders;
    Object systemProvider;
    if (fhirVersion == FhirVersionEnum.DSTU2) {
        resourceProviders = appCtx.getBean("myResourceProvidersDstu2", ResourceProviderFactory.class);
        systemProvider = appCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
    } else if (fhirVersion == FhirVersionEnum.DSTU3) {
        resourceProviders = appCtx.getBean("myResourceProvidersDstu3", ResourceProviderFactory.class);
        systemProvider = appCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
    } else if (fhirVersion == FhirVersionEnum.R4) {
        resourceProviders = appCtx.getBean("myResourceProvidersR4", ResourceProviderFactory.class);
        systemProvider = appCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class);
    } else if (fhirVersion == FhirVersionEnum.R5) {
        resourceProviders = appCtx.getBean("myResourceProvidersR5", ResourceProviderFactory.class);
        systemProvider = appCtx.getBean("mySystemProviderR5", JpaSystemProviderR5.class);
    } else {
        throw new IllegalStateException();
    }
    setFhirContext(appCtx.getBean(FhirContext.class));
    registerProviders(resourceProviders.createProviders());
    registerProvider(systemProvider);
    /*
     * The conformance provider exports the supported resources, search parameters,
     * etc for
     * this server. The JPA version adds resourceProviders counts to the exported
     * statement, so it
     * is a nice addition.
     *
     * You can also create your own subclass of the conformance provider if you need
     * to
     * provide further customization of your server's CapabilityStatement
     */
    IFhirSystemDao<org.hl7.fhir.r4.model.Bundle, org.hl7.fhir.r4.model.Meta> systemDao = appCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
    MetadataProvider metadata = new MetadataProvider(this, systemDao, appCtx.getBean(DaoConfig.class));
    // JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this,
    // systemDao,
    // appCtx.getBean(DaoConfig.class));
    metadata.setImplementationDescription("Da Vinci Drug Formulary Reference Server");
    setServerConformanceProvider(metadata);
    /*
     * ETag Support
     */
    setETagSupport(HapiProperties.getEtagSupport());
    /*
     * This server tries to dynamically generate narratives
     */
    FhirContext ctx = getFhirContext();
    ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
    /*
     * Default to JSON and pretty printing
     */
    setDefaultPrettyPrint(HapiProperties.getDefaultPrettyPrint());
    /*
     * Default encoding
     */
    setDefaultResponseEncoding(HapiProperties.getDefaultEncoding());
    /*
     * This configures the server to page search results to and from
     * the database, instead of only paging them to memory. This may mean
     * a performance hit when performing searches that return lots of results,
     * but makes the server much more scalable.
     */
    setPagingProvider(appCtx.getBean(DatabaseBackedPagingProvider.class));
    /*
     * This interceptor formats the output using nice colourful
     * HTML output when the request is detected to come from a
     * browser.
     */
    ResponseHighlighterInterceptor responseHighlighterInterceptor = new ResponseHighlighterInterceptor();
    this.registerInterceptor(responseHighlighterInterceptor);
    /*
     * Add Read Only Interceptor
     */
    ReadOnlyInterceptor readOnlyInterceptor = new ReadOnlyInterceptor();
    this.registerInterceptor(readOnlyInterceptor);
    /*
     * This interceptor handles the $export operation
     */
    ExportInterceptor exportInterceptor = new ExportInterceptor();
    this.registerInterceptor(exportInterceptor);
    /*
     * Add some logging for each request
     */
    LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
    loggingInterceptor.setLoggerName(HapiProperties.getLoggerName());
    loggingInterceptor.setMessageFormat(HapiProperties.getLoggerFormat());
    loggingInterceptor.setErrorMessageFormat(HapiProperties.getLoggerErrorFormat());
    loggingInterceptor.setLogExceptions(HapiProperties.getLoggerLogExceptions());
    this.registerInterceptor(loggingInterceptor);
    /*
     * Add Authorization interceptor
     */
    PatientAuthorizationInterceptor authorizationInterceptor = new PatientAuthorizationInterceptor();
    this.registerInterceptor(authorizationInterceptor);
    /*
     * If you are hosting this server at a specific DNS name, the server will try to
     * figure out the FHIR base URL based on what the web container tells it, but
     * this doesn't always work. If you are setting links in your search bundles
     * that
     * just refer to "localhost", you might want to use a server address strategy:
     */
    String serverAddress = HapiProperties.getServerAddress();
    if (serverAddress != null && serverAddress.length() > 0) {
        setServerAddressStrategy(new HardcodedServerAddressStrategy(serverAddress));
    }
    /*
     * If you are using DSTU3+, you may want to add a terminology uploader, which
     * allows
     * uploading of external terminologies such as Snomed CT. Note that this
     * uploader
     * does not have any security attached (any anonymous user may use it by
     * default)
     * so it is a potential security vulnerability. Consider using an
     * AuthorizationInterceptor
     * with this feature.
     */
    if (false) {
        // <-- DISABLED RIGHT NOW
        registerProvider(appCtx.getBean(TerminologyUploaderProvider.class));
    }
    // manual triggering of a subscription delivery, enable this provider
    if (false) {
        // <-- DISABLED RIGHT NOW
        SubscriptionTriggeringProvider retriggeringProvider = appCtx.getBean(SubscriptionTriggeringProvider.class);
        registerProvider(retriggeringProvider);
    }
    // to your specific needs
    if (HapiProperties.getCorsEnabled()) {
        CorsConfiguration config = new CorsConfiguration();
        config.addAllowedHeader(HttpHeaders.ORIGIN);
        config.addAllowedHeader(HttpHeaders.ACCEPT);
        config.addAllowedHeader(HttpHeaders.CONTENT_TYPE);
        config.addAllowedHeader(HttpHeaders.AUTHORIZATION);
        config.addAllowedHeader(HttpHeaders.CACHE_CONTROL);
        config.addAllowedHeader("x-fhir-starter");
        config.addAllowedHeader("X-Requested-With");
        config.addAllowedHeader("Prefer");
        String allAllowedCORSOrigins = HapiProperties.getCorsAllowedOrigin();
        Arrays.stream(allAllowedCORSOrigins.split(",")).forEach(o -> {
            config.addAllowedOrigin(o);
        });
        config.addAllowedOrigin(HapiProperties.getCorsAllowedOrigin());
        config.addExposedHeader("Location");
        config.addExposedHeader("Content-Location");
        config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "HEAD"));
        config.setAllowCredentials(HapiProperties.getCorsAllowedCredentials());
        // Create the interceptor and register it
        CorsInterceptor interceptor = new CorsInterceptor(config);
        registerInterceptor(interceptor);
    }
    // will activate them and match results against them
    if (HapiProperties.getSubscriptionWebsocketEnabled() || HapiProperties.getSubscriptionEmailEnabled() || HapiProperties.getSubscriptionRestHookEnabled()) {
        // Loads subscription interceptors (SubscriptionActivatingInterceptor,
        // SubscriptionMatcherInterceptor)
        // with activation of scheduled subscription
        SubscriptionInterceptorLoader subscriptionInterceptorLoader = appCtx.getBean(SubscriptionInterceptorLoader.class);
        subscriptionInterceptorLoader.registerInterceptors();
        // Subscription debug logging
        IInterceptorService interceptorService = appCtx.getBean(IInterceptorService.class);
        interceptorService.registerInterceptor(new SubscriptionDebugLogInterceptor());
    }
    // Cascading deletes
    DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class);
    IInterceptorBroadcaster interceptorBroadcaster = appCtx.getBean(IInterceptorBroadcaster.class);
    if (HapiProperties.getAllowCascadingDeletes()) {
        CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(daoRegistry, interceptorBroadcaster);
        getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
    }
    // Binary Storage
    if (HapiProperties.isBinaryStorageEnabled()) {
        BinaryStorageInterceptor binaryStorageInterceptor = appCtx.getBean(BinaryStorageInterceptor.class);
        getInterceptorService().registerInterceptor(binaryStorageInterceptor);
    }
    // Validation
    IValidatorModule validatorModule;
    switch(fhirVersion) {
        case DSTU2:
            validatorModule = appCtx.getBean("myInstanceValidatorDstu2", IValidatorModule.class);
            break;
        case DSTU3:
            validatorModule = appCtx.getBean("myInstanceValidatorDstu3", IValidatorModule.class);
            break;
        case R4:
            validatorModule = appCtx.getBean("myInstanceValidatorR4", IValidatorModule.class);
            break;
        case R5:
            validatorModule = appCtx.getBean("myInstanceValidatorR5", IValidatorModule.class);
            break;
        // These versions are not supported by HAPI FHIR JPA
        case DSTU2_HL7ORG:
        case DSTU2_1:
        default:
            validatorModule = null;
            break;
    }
    if (validatorModule != null) {
        if (HapiProperties.getValidateRequestsEnabled()) {
            RequestValidatingInterceptor interceptor = new RequestValidatingInterceptor();
            interceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
            interceptor.setValidatorModules(Collections.singletonList(validatorModule));
            registerInterceptor(interceptor);
        }
        if (HapiProperties.getValidateResponsesEnabled()) {
            ResponseValidatingInterceptor interceptor = new ResponseValidatingInterceptor();
            interceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
            interceptor.setValidatorModules(Collections.singletonList(validatorModule));
            registerInterceptor(interceptor);
        }
    }
    // GraphQL
    if (HapiProperties.getGraphqlEnabled()) {
        if (fhirVersion.isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
            registerProvider(appCtx.getBean(GraphQLProvider.class));
        }
    }
    if (!HapiProperties.getAllowedBundleTypes().isEmpty()) {
        String allowedBundleTypesString = HapiProperties.getAllowedBundleTypes();
        Set<String> allowedBundleTypes = new HashSet<>();
        Arrays.stream(allowedBundleTypesString.split(",")).forEach(o -> {
            BundleType type = BundleType.valueOf(o);
            allowedBundleTypes.add(type.toCode());
        });
        DaoConfig config = appCtx.getBean(DaoConfig.class);
        config.setBundleTypesAllowedForStorage(Collections.unmodifiableSet(new TreeSet<>(allowedBundleTypes)));
    }
    // Bulk Export
    if (HapiProperties.getBulkExportEnabled()) {
        registerProvider(appCtx.getBean(BulkDataExportProvider.class));
    }
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) FhirContext(ca.uhn.fhir.context.FhirContext) ResourceProviderFactory(ca.uhn.fhir.jpa.util.ResourceProviderFactory) SubscriptionDebugLogInterceptor(ca.uhn.fhir.jpa.subscription.module.interceptor.SubscriptionDebugLogInterceptor) BinaryStorageInterceptor(ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor) FhirVersionEnum(ca.uhn.fhir.context.FhirVersionEnum) SubscriptionTriggeringProvider(ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider) IInterceptorBroadcaster(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster) JpaSystemProviderR4(ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4) CorsInterceptor(ca.uhn.fhir.rest.server.interceptor.CorsInterceptor) ReadOnlyInterceptor(ca.uhn.fhir.jpa.starter.ReadOnlyInterceptor) ApplicationContext(org.springframework.context.ApplicationContext) BundleType(org.hl7.fhir.r4.model.Bundle.BundleType) ResponseHighlighterInterceptor(ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor) IValidatorModule(ca.uhn.fhir.validation.IValidatorModule) TreeSet(java.util.TreeSet) DefaultThymeleafNarrativeGenerator(ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator) TerminologyUploaderProvider(ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider) RequestValidatingInterceptor(ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor) HashSet(java.util.HashSet) BulkDataExportProvider(ca.uhn.fhir.jpa.bulk.BulkDataExportProvider) DaoConfig(ca.uhn.fhir.jpa.dao.DaoConfig) LoggingInterceptor(ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor) Bundle(org.hl7.fhir.dstu3.model.Bundle) IInterceptorService(ca.uhn.fhir.interceptor.api.IInterceptorService) DatabaseBackedPagingProvider(ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider) CascadingDeleteInterceptor(ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor) GraphQLProvider(ca.uhn.fhir.jpa.provider.GraphQLProvider) JpaSystemProviderDstu2(ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2) ResponseValidatingInterceptor(ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor) SubscriptionInterceptorLoader(ca.uhn.fhir.jpa.subscription.SubscriptionInterceptorLoader) CorsConfiguration(org.springframework.web.cors.CorsConfiguration) MetadataProvider(ca.uhn.fhir.jpa.starter.MetadataProvider) DaoRegistry(ca.uhn.fhir.jpa.dao.DaoRegistry) HardcodedServerAddressStrategy(ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy)

Example 60 with Base

use of org.hl7.fhir.dstu2.model.Base in project drug-formulary-ri by HL7-DaVinci.

the class PatientAuthorizationInterceptor method verify.

/**
 * Helper method to verify and decode the access token
 *
 * @param token       - the access token
 * @param fhirBaseUrl - the base url of this FHIR server
 * @return the base interface Patient ID datatype if the jwt token is verified
 *         and contains a patient ID in it claim, otherwise null.
 * @throws SignatureVerificationException
 * @throws TokenExpiredException
 * @throws JWTVerificationException
 */
private IIdType verify(String token, String fhirBaseUrl) throws SignatureVerificationException, TokenExpiredException, JWTVerificationException {
    Algorithm algorithm = Algorithm.RSA256(OauthEndpointController.getPublicKey(), null);
    logger.fine("Verifying JWT token iss and aud is " + fhirBaseUrl);
    JWTVerifier verifier = JWT.require(algorithm).withIssuer(fhirBaseUrl).withAudience(fhirBaseUrl).build();
    DecodedJWT jwt = verifier.verify(token);
    String patientId = jwt.getClaim("patient_id").asString();
    if (patientId != null)
        return new IdType("Patient", patientId);
    return null;
}
Also used : Algorithm(com.auth0.jwt.algorithms.Algorithm) JWTVerifier(com.auth0.jwt.JWTVerifier) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT) IIdType(org.hl7.fhir.instance.model.api.IIdType) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

ArrayList (java.util.ArrayList)324 FHIRException (org.hl7.fhir.exceptions.FHIRException)177 Base (org.hl7.fhir.r4b.model.Base)87 Base (org.hl7.fhir.r5.model.Base)87 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)76 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)70 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)66 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)64 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)55 NotImplementedException (org.apache.commons.lang3.NotImplementedException)47 Base (org.hl7.fhir.dstu2016may.model.Base)47 UcumException (org.fhir.ucum.UcumException)43 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)41 Base (org.hl7.fhir.dstu2.model.Base)40 BigDecimal (java.math.BigDecimal)39 IOException (java.io.IOException)37 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)34 FileOutputStream (java.io.FileOutputStream)29 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)28 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)28