From 4df4a1e4069dfbb5f6818654d5dcb1206da6f2e3 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 11 Mar 2026 16:49:54 -0400 Subject: [PATCH 1/4] GL-7: Add ARCHITECTURE.md with domain boundary purity guidelines Establishes architectural rules for module boundaries: - Core modules (cqf-fhir-cr, cqf-fhir-cql, cqf-fhir-utility) must not import REST exceptions from ca.uhn.fhir.rest.server.exceptions - Exception translation belongs at the boundary (cqf-fhir-cr-hapi) - Includes correct/incorrect patterns and ArchUnit enforcement test Co-Authored-By: Claude Opus 4.6 --- ARCHITECTURE.md | 163 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 ARCHITECTURE.md diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 000000000..55bc3bb38 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,163 @@ +# Architecture Guidelines + +This document defines architectural principles for the clinical-reasoning library, with emphasis on module boundaries and domain purity. + +## Module Dependency Graph + +``` +cqf-fhir-utility (FHIR adapters, repositories, helpers) + ↑ +cqf-fhir-cql (CQL engine integration, LibraryEngine) + ↑ +cqf-fhir-cr (clinical reasoning operations: Measure, PlanDefinition, Questionnaire, etc.) + ↑ ↑ +cqf-fhir-cr-hapi cqf-fhir-cr-cli +(HAPI FHIR server (command-line interface, + integration layer) no REST context) +``` + +Arrows point from dependee to depender. A class should only reference concepts appropriate to the module it lives in. + +## Domain Boundary Purity + +### The Principle + +As you cross boundaries in an application, the primary domain model shifts. Each module has its own "frame" — the set of domain concepts that are natural and comprehensible within that module: + +| Module | Frame | Primary Domain Concepts | +|--------|-------|------------------------| +| `cqf-fhir-cr` | Clinical reasoning algorithms | FHIR resources, CQL expressions, Measure scoring, PlanDefinition logic | +| `cqf-fhir-cql` | CQL evaluation | CQL libraries, evaluation contexts, terminology | +| `cqf-fhir-utility` | FHIR infrastructure | Adapters, repositories, search, canonicals | +| `cqf-fhir-cr-hapi` | HAPI FHIR server integration | REST operations, request handling, HTTP semantics | +| `cqf-fhir-cr-cli` | Command-line execution | CLI arguments, file I/O, exit codes | + +**Rule: Keep the number of domain concepts small within each module.** A module that mixes clinical reasoning logic with HTTP status codes and REST exception types becomes harder to understand, test, and reuse. + +**Rule: Transition between frames happens at boundaries.** The boundary surface — where one module's API is integrated into another — is where translation logic belongs. Keep all transition logic colocated at the boundary. + +### Forbidden Imports in Core Modules + +The following modules MUST NOT import from `ca.uhn.fhir.rest.server.exceptions`: + +- `cqf-fhir-cr` +- `cqf-fhir-cql` +- `cqf-fhir-utility` + +These modules are used by the CLI, by Android clients, and by other non-REST consumers. REST/HTTP concepts do not belong here. + +### Exception Handling Pattern + +**Core modules** throw domain-appropriate exceptions: + +- `IllegalArgumentException` — caller passed invalid input (null, empty, wrong type) +- `IllegalStateException` — an internal invariant was violated (missing configuration, inconsistent state) +- `NullPointerException` via `Objects.requireNonNull()` — for required non-null parameters +- `UnsupportedOperationException` — for operations not supported in a given context/version + +These are standard Java exceptions that communicate *what went wrong* without encoding *how to respond to a client*. + +**Integration modules** (`cqf-fhir-cr-hapi`) catch domain exceptions and translate them to REST exceptions at the boundary: + +```java +// CORRECT: Translation at the boundary (in cqf-fhir-cr-hapi) +@Operation(name = "$evaluate-measure", type = Measure.class) +public MeasureReport evaluateMeasure(...) { + try { + return measureProcessor.evaluateMeasure(request); + } catch (IllegalArgumentException e) { + throw new InvalidRequestException(e.getMessage(), e); // HTTP 400 + } catch (IllegalStateException e) { + throw new InternalErrorException(e.getMessage(), e); // HTTP 500 + } +} +``` + +```java +// WRONG: REST exceptions thrown from core logic (in cqf-fhir-cr) +public class CqlEvaluationRequest { + public CqlEvaluationRequest(...) { + if (expression == null && content == null) { + // BAD: This class is used by CLI too — it should not know about HTTP 400 + throw new InvalidRequestException("expression or content required"); + } + } +} +``` + +```java +// CORRECT: Domain exception from core logic (in cqf-fhir-cr) +public class CqlEvaluationRequest { + public CqlEvaluationRequest(...) { + if (expression == null && content == null) { + // GOOD: Standard Java — the boundary layer translates this to HTTP 400 + throw new IllegalArgumentException( + "The $cql operation requires the expression parameter and/or content parameter"); + } + } +} +``` + +### Where the Boundary Lives + +For clinical-reasoning, the boundary is `cqf-fhir-cr-hapi`. Every operation provider class in this module is a boundary surface. These providers call into `cqf-fhir-cr` processors/services and translate exceptions. The translation can be centralized via a shared utility or handled per-provider. + +### Centralized Translation Utility + +To avoid repetitive try/catch blocks, use a shared boundary helper in `cqf-fhir-cr-hapi`: + +```java +package org.opencds.cqf.fhir.cr.hapi.common; + +public final class CrExceptionTranslator { + private CrExceptionTranslator() {} + + public static T execute(Supplier operation) { + try { + return operation.get(); + } catch (IllegalArgumentException e) { + throw new InvalidRequestException(e.getMessage(), e); + } catch (UnsupportedOperationException e) { + throw new NotImplementedOperationException(e.getMessage(), e); + } + // IllegalStateException and other RuntimeExceptions intentionally not caught: + // HAPI RestfulServer wraps them as InternalErrorException (HTTP 500) by default + } +} +``` + +Usage in providers: + +```java +@Operation(name = "$evaluate-measure", type = Measure.class) +public MeasureReport evaluateMeasure(...) { + return CrExceptionTranslator.execute( + () -> factory.create(requestDetails).evaluateMeasure(request)); +} +``` + +### Why Not Just Let RestfulServer Handle It? + +HAPI's `RestfulServer` already wraps unknown exceptions as `InternalErrorException` (HTTP 500). Explicit translation is still needed because: + +1. **Client errors become 400s instead of 500s.** An `IllegalArgumentException` for bad user input should be HTTP 400, not 500. Only explicit translation achieves this. +2. **OperationOutcome messages are preserved.** REST exceptions include the message in the FHIR OperationOutcome response body. Generic wrapping may lose context. +3. **CLI and non-REST consumers get clean stack traces.** Domain exceptions are standard Java — they work naturally in any context. + +## Enforcing the Boundary + +### ArchUnit Test + +Add an ArchUnit test in `cqf-fhir-cr` to prevent REST exception imports in core modules: + +```java +@AnalyzeClasses(packages = "org.opencds.cqf.fhir.cr") +class ArchitectureTest { + @ArchTest + static final ArchRule coreModuleMustNotUseRestExceptions = + noClasses() + .that().resideInAPackage("org.opencds.cqf.fhir.cr..") + .should().dependOnClassesThat() + .resideInAPackage("ca.uhn.fhir.rest.server.exceptions.."); +} +``` From 0ff43b5d3ae629865f45e60c013aad8c0759deb2 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 11 Mar 2026 18:25:56 -0400 Subject: [PATCH 2/4] GL-7: Add exception translation at REST boundary in cqf-fhir-cr-hapi Add CrExceptionTranslator utility that catches domain exceptions from core modules and translates them to HAPI FHIR REST exceptions at the boundary layer. IllegalArgumentException becomes InvalidRequestException (HTTP 400) and UnsupportedOperationException becomes NotImplementedOperationException (HTTP 501). IllegalStateException is intentionally not caught as HAPI's RestfulServer already wraps it as InternalErrorException (HTTP 500). Applied to all 51 @Operation-annotated provider methods across both R4 and DSTU3 packages using CrExceptionTranslator.execute() wrapper. Co-Authored-By: Claude Opus 4.6 --- .../cr/hapi/common/CrExceptionTranslator.java | 61 ++++++++ .../ActivityDefinitionApplyProvider.java | 9 +- .../cql/CqlExecutionOperationProvider.java | 5 +- .../LibraryDataRequirementsProvider.java | 8 +- .../library/LibraryEvaluateProvider.java | 9 +- .../dstu3/library/LibraryPackageProvider.java | 9 +- .../measure/MeasureOperationsProvider.java | 5 +- .../PlanDefinitionApplyProvider.java | 9 +- ...lanDefinitionDataRequirementsProvider.java | 8 +- .../PlanDefinitionPackageProvider.java | 9 +- ...QuestionnaireDataRequirementsProvider.java | 8 +- .../QuestionnairePackageProvider.java | 9 +- .../ValueSetDataRequirementsProvider.java | 7 +- .../valueset/ValueSetPackageProvider.java | 9 +- .../ActivityDefinitionApplyProvider.java | 9 +- .../r4/cql/CqlExecutionOperationProvider.java | 5 +- .../fhir/cr/hapi/r4/crmi/ApproveProvider.java | 5 +- .../fhir/cr/hapi/r4/crmi/DraftProvider.java | 3 +- .../crmi/InferManifestParametersProvider.java | 8 +- .../fhir/cr/hapi/r4/crmi/PackageProvider.java | 5 +- .../fhir/cr/hapi/r4/crmi/ReleaseProvider.java | 5 +- .../cr/hapi/r4/ecr/ERSDTransformProvider.java | 5 +- .../GraphDefinitionApplyProvider.java | 7 +- ...aphDefinitionDataRequirementsProvider.java | 8 +- .../GraphDefinitionPackageProvider.java | 9 +- .../ImplementationGuideDataRequirements.java | 9 +- .../ImplementationGuidePackageProvider.java | 9 +- .../ImplementationGuideReleaseProvider.java | 9 +- .../library/LibraryArtifactDiffProvider.java | 5 +- .../LibraryDataRequirementsProvider.java | 8 +- .../r4/library/LibraryDeleteProvider.java | 4 +- .../r4/library/LibraryEvaluateProvider.java | 9 +- .../r4/library/LibraryPackageProvider.java | 9 +- .../r4/library/LibraryReleaseProvider.java | 9 +- .../r4/library/LibraryRetireProvider.java | 4 +- .../r4/library/LibraryReviseProvider.java | 3 +- .../r4/library/LibraryWithdrawProvider.java | 5 +- .../r4/measure/CareGapsOperationProvider.java | 6 +- .../measure/CollectDataOperationProvider.java | 6 +- .../DataRequirementsOperationProvider.java | 5 +- .../r4/measure/MeasureOperationsProvider.java | 9 +- .../hapi/r4/measure/SubmitDataProvider.java | 4 +- .../PlanDefinitionApplyProvider.java | 17 +-- ...lanDefinitionDataRequirementsProvider.java | 8 +- .../PlanDefinitionPackageProvider.java | 9 +- ...QuestionnaireDataRequirementsProvider.java | 8 +- .../QuestionnairePackageProvider.java | 9 +- .../QuestionnairePopulateProvider.java | 9 +- .../QuestionnaireResponseExtractProvider.java | 10 +- ...uctureDefinitionQuestionnaireProvider.java | 9 +- .../ValueSetDataRequirementsProvider.java | 7 +- .../r4/valueset/ValueSetPackageProvider.java | 9 +- .../common/CrExceptionTranslatorTest.java | 131 ++++++++++++++++++ 53 files changed, 419 insertions(+), 154 deletions(-) create mode 100644 cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java create mode 100644 cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java new file mode 100644 index 000000000..b0fd590b2 --- /dev/null +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java @@ -0,0 +1,61 @@ +// Created by claude-opus-4-6 +package org.opencds.cqf.fhir.cr.hapi.common; + +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; +import java.util.function.Supplier; + +/** + * Translates domain exceptions from core modules into HAPI FHIR REST exceptions at the + * boundary layer. Core modules ({@code cqf-fhir-cr}, {@code cqf-fhir-cql}, + * {@code cqf-fhir-utility}) correctly throw standard Java exceptions; this utility catches + * them and re-throws the appropriate REST exception so clients receive proper HTTP status + * codes and OperationOutcome responses. + * + *

{@link IllegalStateException} and other {@link RuntimeException} subclasses are + * intentionally not caught — HAPI's {@code RestfulServer} already wraps them as + * {@code InternalErrorException} (HTTP 500). + */ +public final class CrExceptionTranslator { + private CrExceptionTranslator() {} + + /** + * Execute a supplier and translate domain exceptions to REST exceptions. + * + * @param operation the operation to execute + * @param the return type + * @return the result of the operation + * @throws InvalidRequestException if the operation throws {@link IllegalArgumentException} + * @throws NotImplementedOperationException if the operation throws {@link UnsupportedOperationException} + */ + public static T execute(Supplier operation) { + try { + return operation.get(); + } catch (IllegalArgumentException e) { + throw new InvalidRequestException(e.getMessage(), e); + } catch (UnsupportedOperationException e) { + var translated = new NotImplementedOperationException(e.getMessage()); + translated.initCause(e); + throw translated; + } + } + + /** + * Execute a void operation and translate domain exceptions to REST exceptions. + * + * @param operation the operation to execute + * @throws InvalidRequestException if the operation throws {@link IllegalArgumentException} + * @throws NotImplementedOperationException if the operation throws {@link UnsupportedOperationException} + */ + public static void executeVoid(Runnable operation) { + try { + operation.run(); + } catch (IllegalArgumentException e) { + throw new InvalidRequestException(e.getMessage(), e); + } catch (UnsupportedOperationException e) { + var translated = new NotImplementedOperationException(e.getMessage()); + translated.initCause(e); + throw translated; + } + } +} diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/activitydefinition/ActivityDefinitionApplyProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/activitydefinition/ActivityDefinitionApplyProvider.java index 7c3a124ad..b6b0f1506 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/activitydefinition/ActivityDefinitionApplyProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/activitydefinition/ActivityDefinitionApplyProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.activitydefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -90,7 +91,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return activityDefinitionProcessorFactory + return execute(() -> activityDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.forMiddle3(id), @@ -108,7 +109,7 @@ public IBaseResource apply( data, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -169,7 +170,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return activityDefinitionProcessorFactory + return execute(() -> activityDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, activityDefinition), @@ -187,6 +188,6 @@ public IBaseResource apply( data, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/cql/CqlExecutionOperationProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/cql/CqlExecutionOperationProvider.java index 00bdb5b21..1c23020e2 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/cql/CqlExecutionOperationProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/cql/CqlExecutionOperationProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.cql; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -127,7 +128,7 @@ public IBaseParameters evaluate( @OperationParam(name = "contentEndpoint", max = 1) ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint", max = 1) ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "content", max = 1) StringType content) { - return cqlProcessorFactory + return execute(() -> cqlProcessorFactory .create(requestDetails) .evaluate( getStringValue(subject), @@ -140,6 +141,6 @@ public IBaseParameters evaluate( getStringValue(content), getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryDataRequirementsProvider.java index 38f589f6c..96e6139d4 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public LibraryDataRequirementsProvider(ILibraryProcessorFactory libraryProcessor @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Library.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute( + () -> libraryProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Library.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "Library", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryEvaluateProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryEvaluateProvider.java index 9c124ee2e..a2a90b73e 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryEvaluateProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryEvaluateProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.newCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -125,7 +126,7 @@ public Parameters evaluate( var dataEndpointParam = getEndpoint(fhirVersion, dataEndpoint); var contentEndpointParam = getEndpoint(fhirVersion, contentEndpoint); var terminologyEndpointParam = getEndpoint(fhirVersion, terminologyEndpoint); - return (Parameters) libraryProcessorFactory + return execute(() -> (Parameters) libraryProcessorFactory .create(requestDetails) .evaluate( Eithers.forMiddle3(id), @@ -141,7 +142,7 @@ public Parameters evaluate( prefetchData, dataEndpointParam, contentEndpointParam, - terminologyEndpointParam); + terminologyEndpointParam)); } /** @@ -237,7 +238,7 @@ public Parameters evaluate( @OperationParam(name = "contentEndpoint") ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) { - return (Parameters) libraryProcessorFactory + return execute(() -> (Parameters) libraryProcessorFactory .create(requestDetails) .evaluate( Eithers.for3(newCanonicalType(fhirVersion, getStringValue(url)), null, library), @@ -253,6 +254,6 @@ public Parameters evaluate( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryPackageProvider.java index 4f507d059..b0f1859f5 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/library/LibraryPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -49,14 +50,14 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .packageLibrary( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -81,7 +82,7 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .packageLibrary( Eithers.for3( @@ -91,6 +92,6 @@ public IBaseBundle packagePlanDefinition( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/measure/MeasureOperationsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/measure/MeasureOperationsProvider.java index a6db93e2f..a699d3a60 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/measure/MeasureOperationsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/measure/MeasureOperationsProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import ca.uhn.fhir.context.FhirVersionEnum; @@ -72,7 +73,7 @@ public MeasureReport evaluateMeasure( RequestDetails requestDetails) throws InternalErrorException, FHIRException { var terminologyEndpointParam = (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint); - return dstu3MeasureProcessorFactory + return execute(() -> dstu3MeasureProcessorFactory .create(requestDetails) .evaluateMeasure( id, @@ -85,6 +86,6 @@ public MeasureReport evaluateMeasure( productLine, additionalData, parameters, - terminologyEndpointParam); + terminologyEndpointParam)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionApplyProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionApplyProvider.java index e3dcba68e..4890ce102 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionApplyProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionApplyProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.plandefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -92,7 +93,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.forMiddle3(id), @@ -111,7 +112,7 @@ public IBaseResource apply( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -173,7 +174,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, planDefinition), @@ -192,6 +193,6 @@ public IBaseResource apply( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionDataRequirementsProvider.java index f37ac2527..a48bc48e9 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.plandefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public PlanDefinitionDataRequirementsProvider(IPlanDefinitionProcessorFactory pl @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = PlanDefinition.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute(() -> + planDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = PlanDefinition.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "PlanDefinition", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionPackageProvider.java index 4262b83f4..2f34c717a 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/plandefinition/PlanDefinitionPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.plandefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -49,14 +50,14 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .packagePlanDefinition( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -81,7 +82,7 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .packagePlanDefinition( Eithers.for3( @@ -91,6 +92,6 @@ public IBaseBundle packagePlanDefinition( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnaireDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnaireDataRequirementsProvider.java index a681d6868..e243a4c41 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnaireDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnaireDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.questionnaire; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public QuestionnaireDataRequirementsProvider(IQuestionnaireProcessorFactory ques @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Questionnaire.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute( + () -> questionnaireFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Questionnaire.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireFactory + return execute(() -> questionnaireFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "Questionnaire", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnairePackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnairePackageProvider.java index 7fc2b14e8..220c5b70e 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnairePackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/questionnaire/QuestionnairePackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.questionnaire; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -46,14 +47,14 @@ public Bundle packageQuestionnaire( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) questionnaireProcessorFactory + return execute(() -> (Bundle) questionnaireProcessorFactory .create(requestDetails) .packageQuestionnaire( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -77,7 +78,7 @@ public Bundle packageQuestionnaire( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) questionnaireProcessorFactory + return execute(() -> (Bundle) questionnaireProcessorFactory .create(requestDetails) .packageQuestionnaire( Eithers.for3( @@ -87,6 +88,6 @@ public Bundle packageQuestionnaire( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetDataRequirementsProvider.java index b34c070b3..3bbcf6def 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.valueset; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,7 @@ public ValueSetDataRequirementsProvider(IValueSetProcessorFactory valueSetFactor @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = ValueSet.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return valueSetFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute(() -> valueSetFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = ValueSet.class) @@ -42,13 +43,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return valueSetFactory + return execute(() -> valueSetFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "ValueSet", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetPackageProvider.java index eefda5647..e8df6d7f9 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/dstu3/valueset/ValueSetPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.dstu3.valueset; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -46,14 +47,14 @@ public Bundle packageValueSet( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) valueSetProcessorFactory + return execute(() -> (Bundle) valueSetProcessorFactory .create(requestDetails) .packageValueSet( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -77,7 +78,7 @@ public Bundle packageValueSet( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) valueSetProcessorFactory + return execute(() -> (Bundle) valueSetProcessorFactory .create(requestDetails) .packageValueSet( Eithers.for3( @@ -87,6 +88,6 @@ public Bundle packageValueSet( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/activitydefinition/ActivityDefinitionApplyProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/activitydefinition/ActivityDefinitionApplyProvider.java index f74e30833..450081ec8 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/activitydefinition/ActivityDefinitionApplyProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/activitydefinition/ActivityDefinitionApplyProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.activitydefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -91,7 +92,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return activityDefinitionProcessorFactory + return execute(() -> activityDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.forMiddle3(id), @@ -109,7 +110,7 @@ public IBaseResource apply( data, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -171,7 +172,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return activityDefinitionProcessorFactory + return execute(() -> activityDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, activityDefinition), @@ -189,6 +190,6 @@ public IBaseResource apply( data, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/cql/CqlExecutionOperationProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/cql/CqlExecutionOperationProvider.java index c6dc8c875..5fe65fe20 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/cql/CqlExecutionOperationProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/cql/CqlExecutionOperationProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.cql; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -127,7 +128,7 @@ public IBaseParameters evaluate( @OperationParam(name = "contentEndpoint", max = 1) ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint", max = 1) ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "content", max = 1) StringType content) { - return cqlProcessorFactory + return execute(() -> cqlProcessorFactory .create(requestDetails) .evaluate( getStringValue(subject), @@ -140,6 +141,6 @@ public IBaseParameters evaluate( getStringValue(content), getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ApproveProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ApproveProvider.java index 252e58e5e..eab831698 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ApproveProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ApproveProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.crmi; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_APPROVE; @@ -75,7 +76,7 @@ public Bundle approveOperation( @OperationParam(name = "artifactAssessmentRelatedArtifact") CanonicalType artifactAssessmentRelatedArtifact, @OperationParam(name = "artifactAssessmentAuthor") Reference artifactAssessmentAuthor, RequestDetails requestDetails) { - return r4ApproveServiceFactory + return execute(() -> r4ApproveServiceFactory .create(requestDetails) .approve( id, @@ -84,6 +85,6 @@ public Bundle approveOperation( getStringValue(artifactAssessmentSummary), artifactAssessmentTarget, artifactAssessmentRelatedArtifact, - artifactAssessmentAuthor); + artifactAssessmentAuthor)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/DraftProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/DraftProvider.java index 2263cf4e3..2d1c2fe85 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/DraftProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/DraftProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.crmi; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import ca.uhn.fhir.model.api.annotation.Description; @@ -43,6 +44,6 @@ public DraftProvider(IDraftServiceFactory r4DraftServiceFactory) { @Description(shortDefinition = "$draft", value = "Create a new draft version of the reference artifact.") public Bundle draftOperation( @IdParam IdType id, @OperationParam(name = "version") StringType version, RequestDetails requestDetails) { - return r4DraftServiceFactory.create(requestDetails).draft(id, getStringValue(version)); + return execute(() -> r4DraftServiceFactory.create(requestDetails).draft(id, getStringValue(version))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/InferManifestParametersProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/InferManifestParametersProvider.java index e844a1aa6..fbed3b848 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/InferManifestParametersProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/InferManifestParametersProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.crmi; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -43,7 +45,8 @@ public InferManifestParametersProvider( shortDefinition = "$infer-manifest-parameters", value = "Infer manifest expansion parameters from a module-definition Library.") public Library inferManifestParameters(@IdParam IdType id, RequestDetails requestDetails) { - return r4InferManifestParametersServiceFactory.create(requestDetails).inferManifestParameters(id); + return execute(() -> + r4InferManifestParametersServiceFactory.create(requestDetails).inferManifestParameters(id)); } /** @@ -72,6 +75,7 @@ public Library inferManifestParameters(@IdParam IdType id, RequestDetails reques value = "Infer manifest expansion parameters from a module-definition Library.") public Library inferManifestParameters( @OperationParam(name = "library") Library library, RequestDetails requestDetails) { - return r4InferManifestParametersServiceFactory.create(requestDetails).inferManifestParameters(library); + return execute(() -> + r4InferManifestParametersServiceFactory.create(requestDetails).inferManifestParameters(library)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/PackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/PackageProvider.java index ab8115965..e7e3d8c26 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/PackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/PackageProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.crmi; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_PACKAGE; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -241,7 +242,7 @@ public Bundle packageOperation( @OperationParam(name = "terminologyEndpoint") Parameters.ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws FHIRException { - return r4PackageServiceFactory + return execute(() -> r4PackageServiceFactory .create(requestDetails) .packageOperation( id, @@ -262,6 +263,6 @@ public Bundle packageOperation( getStringValue(bundleType), packageOnly, artifactEndpointConfiguration, - (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint)); + (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ReleaseProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ReleaseProvider.java index 97bba2560..3edc8e3e3 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ReleaseProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/crmi/ReleaseProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.crmi; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_RELEASE; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -94,7 +95,7 @@ public Bundle releaseOperation( @OperationParam(name = "releaseLabel") StringType releaseLabel, RequestDetails requestDetails) throws FHIRException { - return r4ReleaseServiceFactory + return execute(() -> r4ReleaseServiceFactory .create(requestDetails) .release( id, @@ -103,6 +104,6 @@ public Bundle releaseOperation( latestFromTxServer, requireNonExperimental, (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint), - getStringValue(releaseLabel)); + getStringValue(releaseLabel))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/ecr/ERSDTransformProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/ecr/ERSDTransformProvider.java index 5d2a4b8dd..df5bbd089 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/ecr/ERSDTransformProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/ecr/ERSDTransformProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.ecr; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import ca.uhn.fhir.model.api.annotation.Description; @@ -37,8 +38,8 @@ public OperationOutcome eRSDV2ImportOperation( @OperationParam(name = "bundle") IBaseResource maybeBundle, @OperationParam(name = "appAuthoritativeUrl") StringType appAuthoritativeUrl) throws UnprocessableEntityException, FhirResourceExistsException { - return ersdv2ImportServiceFactory + return execute(() -> ersdv2ImportServiceFactory .create(requestDetails) - .eRSDV2ImportOperation(maybeBundle, getStringValue(appAuthoritativeUrl)); + .eRSDV2ImportOperation(maybeBundle, getStringValue(appAuthoritativeUrl))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionApplyProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionApplyProvider.java index 59b57cdc1..f90759514 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionApplyProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionApplyProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.graphdefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import ca.uhn.fhir.context.FhirVersionEnum; @@ -129,7 +130,8 @@ public IBaseResource apply( var applyRequest = applyRequestBuilder.buildApplyRequest(); - return graphDefinitionProcessorFactory.create(requestDetails).apply(applyRequest); + return execute( + () -> graphDefinitionProcessorFactory.create(requestDetails).apply(applyRequest)); } /** @@ -229,7 +231,8 @@ public IBaseResource apply( var applyRequest = applyRequestBuilder.buildApplyRequest(); - return graphDefinitionProcessorFactory.create(requestDetails).apply(applyRequest); + return execute( + () -> graphDefinitionProcessorFactory.create(requestDetails).apply(applyRequest)); } protected ZonedDateTime getZonedStartDateTime(StringType start, RequestDetails requestDetails) { diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionDataRequirementsProvider.java index 44ca1d748..8f8385c14 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.graphdefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public GraphDefinitionDataRequirementsProvider(IGraphDefinitionProcessorFactory @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = GraphDefinition.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return graphDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute(() -> + graphDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = GraphDefinition.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return graphDefinitionProcessorFactory + return execute(() -> graphDefinitionProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "GraphDefinition", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionPackageProvider.java index e5008149b..a6e69cece 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/graphdefinition/GraphDefinitionPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.graphdefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -49,14 +50,14 @@ public IBaseBundle packageGraphDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return graphDefinitionProcessorFactory + return execute(() -> graphDefinitionProcessorFactory .create(requestDetails) .packageGraphDefinition( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -81,7 +82,7 @@ public IBaseBundle packageGraphDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return graphDefinitionProcessorFactory + return execute(() -> graphDefinitionProcessorFactory .create(requestDetails) .packageGraphDefinition( Eithers.for3( @@ -91,6 +92,6 @@ public IBaseBundle packageGraphDefinition( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideDataRequirements.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideDataRequirements.java index 908a348ca..9d5bf2042 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideDataRequirements.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideDataRequirements.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.implementationguide; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.Resources.newBaseForVersion; @@ -63,10 +64,10 @@ public IBaseResource getDataRequirements( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .dataRequirements( - Eithers.forMiddle3(id), buildParameters(artifactEndpointConfiguration, terminologyEndpoint)); + Eithers.forMiddle3(id), buildParameters(artifactEndpointConfiguration, terminologyEndpoint))); } /** @@ -101,14 +102,14 @@ public IBaseResource getDataRequirements( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "ImplementationGuide", id), null), - buildParameters(artifactEndpointConfiguration, terminologyEndpoint)); + buildParameters(artifactEndpointConfiguration, terminologyEndpoint))); } private IBaseParameters buildParameters( diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuidePackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuidePackageProvider.java index 7424759dd..15499dbdb 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuidePackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuidePackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.implementationguide; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -51,14 +52,14 @@ public IBaseBundle packageImplementationGuide( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .packageImplementationGuide( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -83,7 +84,7 @@ public IBaseBundle packageImplementationGuide( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .packageImplementationGuide( Eithers.for3( @@ -93,6 +94,6 @@ public IBaseBundle packageImplementationGuide( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideReleaseProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideReleaseProvider.java index d09ddf684..291881498 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideReleaseProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/implementationguide/ImplementationGuideReleaseProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.implementationguide; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_RELEASE; @@ -57,7 +58,7 @@ public IBaseBundle releaseImplementationGuide( @OperationParam(name = "releaseLabel") StringType releaseLabel, RequestDetails requestDetails) throws FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .releaseImplementationGuide( Eithers.forMiddle3(id), @@ -67,7 +68,7 @@ public IBaseBundle releaseImplementationGuide( latestFromTxServer, requireNonExperimental, getEndpoint(fhirVersion, terminologyEndpoint), - getStringValue(releaseLabel))); + getStringValue(releaseLabel)))); } @Operation(name = CRMI_OPERATION_RELEASE, idempotent = true, global = true, type = ImplementationGuide.class) @@ -82,7 +83,7 @@ public IBaseBundle releaseImplementationGuide( @OperationParam(name = "releaseLabel") StringType releaseLabel, RequestDetails requestDetails) throws FHIRException { - return implementationGuideProcessorFactory + return execute(() -> implementationGuideProcessorFactory .create(requestDetails) .releaseImplementationGuide( Eithers.forMiddle3(getIdType(fhirVersion, "ImplementationGuide", id)), @@ -92,7 +93,7 @@ public IBaseBundle releaseImplementationGuide( latestFromTxServer, requireNonExperimental, getEndpoint(fhirVersion, terminologyEndpoint), - getStringValue(releaseLabel))); + getStringValue(releaseLabel)))); } private static Parameters getReleaseParameters( diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryArtifactDiffProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryArtifactDiffProvider.java index 149154c6a..233c16195 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryArtifactDiffProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryArtifactDiffProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_ARTIFACT_DIFF; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -40,13 +41,13 @@ public IBaseParameters crmiArtifactDiff( @OperationParam(name = "compareComputable", typeName = "Boolean") IPrimitiveType compareComputable, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint) throws UnprocessableEntityException, ResourceNotFoundException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .artifactDiff( Eithers.forMiddle3(getIdType(fhirVersion, "Library", source)), Eithers.forMiddle3(getIdType(fhirVersion, "Library", target)), compareComputable.getValue(), compareExecutable.getValue(), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDataRequirementsProvider.java index 5c7355f6b..bb92a1444 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public LibraryDataRequirementsProvider(ILibraryProcessorFactory libraryProcessor @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Library.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute( + () -> libraryProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Library.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "Library", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDeleteProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDeleteProvider.java index d676f5dad..9558071a8 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDeleteProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryDeleteProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_DELETE; import ca.uhn.fhir.context.FhirVersionEnum; @@ -36,6 +37,7 @@ public LibraryDeleteProvider(ILibraryProcessorFactory libraryProcessorFactory) { @Operation(name = CRMI_OPERATION_DELETE, idempotent = true, global = true, type = Library.class) @Description(shortDefinition = CRMI_OPERATION_DELETE, value = "Delete a retired artifact") public IBaseBundle deleteOperation(@IdParam IdType id, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory.create(requestDetails).deleteLibrary(Eithers.forMiddle3(id), new Parameters()); + return execute(() -> + libraryProcessorFactory.create(requestDetails).deleteLibrary(Eithers.forMiddle3(id), new Parameters())); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryEvaluateProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryEvaluateProvider.java index a30717af7..fe33fe742 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryEvaluateProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryEvaluateProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.newCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -119,7 +120,7 @@ public Parameters evaluate( @OperationParam(name = "contentEndpoint") ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) { - return (Parameters) libraryProcessorFactory + return execute(() -> (Parameters) libraryProcessorFactory .create(requestDetails) .evaluate( Eithers.forMiddle3(id), @@ -135,7 +136,7 @@ public Parameters evaluate( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -234,7 +235,7 @@ public Parameters evaluate( @OperationParam(name = "contentEndpoint") ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) { - return (Parameters) libraryProcessorFactory + return execute(() -> (Parameters) libraryProcessorFactory .create(requestDetails) .evaluate( Eithers.for3(newCanonicalType(fhirVersion, getStringValue(url)), null, library), @@ -250,6 +251,6 @@ public Parameters evaluate( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryPackageProvider.java index 9cac48421..48ccb459d 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -85,7 +86,7 @@ public IBaseBundle packageLibrary( List artifactEndpointConfigurationParam = artifactEndpointConfiguration == null ? null : artifactEndpointConfiguration.stream().map(p -> (IBase) p).collect(Collectors.toList()); - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .packageLibrary( Eithers.forMiddle3(id), @@ -102,7 +103,7 @@ public IBaseBundle packageLibrary( .collect(Collectors.toList()), artifactEndpointConfigurationParam, terminologyEndpointParam, - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -155,7 +156,7 @@ public IBaseBundle packageLibrary( List artifactEndpointConfigurationParam = artifactEndpointConfiguration == null ? null : artifactEndpointConfiguration.stream().map(p -> (IBase) p).collect(Collectors.toList()); - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .packageLibrary( Eithers.for3( @@ -175,6 +176,6 @@ public IBaseBundle packageLibrary( .collect(Collectors.toList()), artifactEndpointConfigurationParam, terminologyEndpointParam, - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReleaseProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReleaseProvider.java index 42e8dee86..6660bf997 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReleaseProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReleaseProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_RELEASE; @@ -56,7 +57,7 @@ public IBaseBundle releaseLibrary( @OperationParam(name = "releaseLabel") String releaseLabel, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .releaseLibrary( Eithers.forMiddle3(id), @@ -66,7 +67,7 @@ public IBaseBundle releaseLibrary( latestFromTxServer, requireNonExperimental, getEndpoint(fhirVersion, terminologyEndpoint), - releaseLabel)); + releaseLabel))); } @Operation(name = CRMI_OPERATION_RELEASE, idempotent = true, global = true, type = Library.class) @@ -81,7 +82,7 @@ public IBaseBundle releaseLibrary( @OperationParam(name = "releaseLabel") String releaseLabel, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory + return execute(() -> libraryProcessorFactory .create(requestDetails) .releaseLibrary( Eithers.forMiddle3(getIdType(fhirVersion, "Library", id)), @@ -91,7 +92,7 @@ public IBaseBundle releaseLibrary( latestFromTxServer, requireNonExperimental, getEndpoint(fhirVersion, terminologyEndpoint), - releaseLabel)); + releaseLabel))); } private static Parameters getReleaseParameters( diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryRetireProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryRetireProvider.java index 654c328dc..94d6a3e76 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryRetireProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryRetireProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_RETIRE; import ca.uhn.fhir.context.FhirVersionEnum; @@ -36,6 +37,7 @@ public LibraryRetireProvider(ILibraryProcessorFactory libraryProcessorFactory) { @Operation(name = CRMI_OPERATION_RETIRE, idempotent = true, global = true, type = Library.class) @Description(shortDefinition = CRMI_OPERATION_RETIRE, value = "Retire an existing active artifact") public IBaseBundle withdrawOperation(@IdParam IdType id, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory.create(requestDetails).retireLibrary(Eithers.forMiddle3(id), new Parameters()); + return execute(() -> + libraryProcessorFactory.create(requestDetails).retireLibrary(Eithers.forMiddle3(id), new Parameters())); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReviseProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReviseProvider.java index c8110db9b..b43a657ed 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReviseProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryReviseProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_REVISE; import ca.uhn.fhir.context.FhirVersionEnum; @@ -29,6 +30,6 @@ public IBaseResource reviseOperation( @OperationParam(name = "resource") IBaseResource resource, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory.create(requestDetails).reviseLibrary(resource); + return execute(() -> libraryProcessorFactory.create(requestDetails).reviseLibrary(resource)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryWithdrawProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryWithdrawProvider.java index 778fc8967..d53db2808 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryWithdrawProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/library/LibraryWithdrawProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.library; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.Constants.CRMI_OPERATION_WITHDRAW; import ca.uhn.fhir.context.FhirVersionEnum; @@ -38,6 +39,8 @@ public LibraryWithdrawProvider(ILibraryProcessorFactory libraryProcessorFactory) @Operation(name = CRMI_OPERATION_WITHDRAW, idempotent = true, global = true, type = Library.class) @Description(shortDefinition = CRMI_OPERATION_WITHDRAW, value = "Withdraw an existing draft artifact") public IBaseBundle withdrawOperation(@IdParam IdType id, RequestDetails requestDetails) throws FHIRException { - return libraryProcessorFactory.create(requestDetails).withdrawLibrary(Eithers.forMiddle3(id), new Parameters()); + return execute(() -> libraryProcessorFactory + .create(requestDetails) + .withdrawLibrary(Eithers.forMiddle3(id), new Parameters())); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CareGapsOperationProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CareGapsOperationProvider.java index d261f1585..6134fea44 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CareGapsOperationProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CareGapsOperationProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; @@ -84,7 +86,7 @@ public Parameters careGapsReport( @OperationParam(name = "measureUrl") List measureUrl, @OperationParam(name = "nonDocument") BooleanType nonDocument) { - return r4CareGapsProcessorFactory + return execute(() -> r4CareGapsProcessorFactory .create(requestDetails) .getCareGapsReport( stringTimePeriodHandler.getStartZonedDateTime(reriodStart, requestDetails), @@ -98,6 +100,6 @@ public Parameters careGapsReport( measureUrl, Optional.ofNullable(nonDocument) .map(BooleanType::getValue) - .orElse(false)); + .orElse(false))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CollectDataOperationProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CollectDataOperationProvider.java index 42feeec60..68a50f202 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CollectDataOperationProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/CollectDataOperationProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -56,13 +58,13 @@ public Parameters collectData( @OperationParam(name = "subject") String subject, @OperationParam(name = "practitioner") String practitioner, RequestDetails requestDetails) { - return r4CollectDataServiceFactory + return execute(() -> r4CollectDataServiceFactory .create(requestDetails) .collectData( id, stringTimePeriodHandler.getStartZonedDateTime(periodStart, requestDetails), stringTimePeriodHandler.getEndZonedDateTime(periodEnd, requestDetails), subject, - practitioner); + practitioner)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/DataRequirementsOperationProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/DataRequirementsOperationProvider.java index beea3503c..a20e990ce 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/DataRequirementsOperationProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/DataRequirementsOperationProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; @@ -38,6 +40,7 @@ public Library dataRequirements( @OperationParam(name = "periodStart") String periodStart, @OperationParam(name = "periodEnd") String periodEnd, RequestDetails requestDetails) { - return r4DataRequirementsServiceFactory.create(requestDetails).dataRequirements(id, periodStart, periodEnd); + return execute(() -> + r4DataRequirementsServiceFactory.create(requestDetails).dataRequirements(id, periodStart, periodEnd)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/MeasureOperationsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/MeasureOperationsProvider.java index 74fc59d3e..094ce037f 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/MeasureOperationsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/MeasureOperationsProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.fhir.cr.hapi.r4.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import ca.uhn.fhir.context.FhirVersionEnum; @@ -87,7 +88,7 @@ public MeasureReport evaluateMeasure( var contentEndpointParam = (Endpoint) getEndpoint(fhirVersion, contentEndpoint); var terminologyEndpointParam = (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint); var dataEndpointParam = (Endpoint) getEndpoint(fhirVersion, dataEndpoint); - return r4MeasureServiceFactory + return execute(() -> r4MeasureServiceFactory .create(requestDetails) .evaluate( Eithers.forMiddle3(id), @@ -102,7 +103,7 @@ public MeasureReport evaluateMeasure( additionalData, parameters, productLine, - practitioner); + practitioner)); } /** @@ -156,7 +157,7 @@ public Parameters evaluate( var contentEndpointParam = (Endpoint) getEndpoint(fhirVersion, contentEndpoint); var terminologyEndpointParam = (Endpoint) getEndpoint(fhirVersion, terminologyEndpoint); var dataEndpointParam = (Endpoint) getEndpoint(fhirVersion, dataEndpoint); - return r4MultiMeasureServiceFactory + return execute(() -> r4MultiMeasureServiceFactory .create(requestDetails) .evaluate( measureId, // List @@ -172,6 +173,6 @@ public Parameters evaluate( additionalData, parameters, productLine, - reporter); + reporter)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/SubmitDataProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/SubmitDataProvider.java index e7591147c..df4a432d5 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/SubmitDataProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/measure/SubmitDataProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.measure; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -55,6 +57,6 @@ public Bundle submitData( @IdParam IdType id, @OperationParam(name = "measureReport", min = 1, max = 1) MeasureReport report, @OperationParam(name = "resource") List resources) { - return r4SubmitDataProcessorFactory.create(requestDetails).submitData(report, resources); + return execute(() -> r4SubmitDataProcessorFactory.create(requestDetails).submitData(report, resources)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionApplyProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionApplyProvider.java index 7611a863d..d3b6ea6d3 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionApplyProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionApplyProvider.java @@ -2,6 +2,7 @@ import static ca.uhn.fhir.rest.annotation.OperationParam.MAX_UNLIMITED; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -96,7 +97,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.forMiddle3(id), @@ -115,7 +116,7 @@ public IBaseResource apply( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -179,7 +180,7 @@ public IBaseResource apply( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .apply( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, planDefinition), @@ -198,7 +199,7 @@ public IBaseResource apply( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -256,7 +257,7 @@ public IBaseResource applyR5( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .applyR5( Eithers.forMiddle3(id), @@ -275,7 +276,7 @@ public IBaseResource applyR5( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -339,7 +340,7 @@ public IBaseResource applyR5( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .applyR5( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, planDefinition), @@ -358,6 +359,6 @@ public IBaseResource applyR5( prefetchData, getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionDataRequirementsProvider.java index 19434f103..5dca916b2 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.plandefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public PlanDefinitionDataRequirementsProvider(IPlanDefinitionProcessorFactory pl @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = PlanDefinition.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute(() -> + planDefinitionProcessorFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = PlanDefinition.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "PlanDefinition", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionPackageProvider.java index f4cfee834..205d901d4 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/plandefinition/PlanDefinitionPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.plandefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -49,14 +50,14 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .packagePlanDefinition( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -81,7 +82,7 @@ public IBaseBundle packagePlanDefinition( @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return planDefinitionProcessorFactory + return execute(() -> planDefinitionProcessorFactory .create(requestDetails) .packagePlanDefinition( Eithers.for3( @@ -91,6 +92,6 @@ public IBaseBundle packagePlanDefinition( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnaireDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnaireDataRequirementsProvider.java index d07911e9e..077a841d9 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnaireDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnaireDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.questionnaire; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,8 @@ public QuestionnaireDataRequirementsProvider(IQuestionnaireProcessorFactory ques @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Questionnaire.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute( + () -> questionnaireFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = Questionnaire.class) @@ -42,13 +44,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireFactory + return execute(() -> questionnaireFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "Questionnaire", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePackageProvider.java index dc8b17460..b534f38c5 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.questionnaire; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -46,14 +47,14 @@ public Bundle packageQuestionnaire( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) questionnaireProcessorFactory + return execute(() -> (Bundle) questionnaireProcessorFactory .create(requestDetails) .packageQuestionnaire( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -77,7 +78,7 @@ public Bundle packageQuestionnaire( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) questionnaireProcessorFactory + return execute(() -> (Bundle) questionnaireProcessorFactory .create(requestDetails) .packageQuestionnaire( Eithers.for3( @@ -87,6 +88,6 @@ public Bundle packageQuestionnaire( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePopulateProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePopulateProvider.java index 2360db0ca..79c2d9e98 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePopulateProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaire/QuestionnairePopulateProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.questionnaire; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringOrReferenceValue; import static org.opencds.cqf.fhir.cr.hapi.common.ParameterHelper.getStringValue; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; @@ -81,7 +82,7 @@ public QuestionnaireResponse populate( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return (QuestionnaireResponse) questionnaireProcessorFactory + return execute(() -> (QuestionnaireResponse) questionnaireProcessorFactory .create(requestDetails) .populate( Eithers.forMiddle3(id), @@ -92,7 +93,7 @@ public QuestionnaireResponse populate( isUseServerData(local, useServerData), getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } /** @@ -140,7 +141,7 @@ public QuestionnaireResponse populate( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return (QuestionnaireResponse) questionnaireProcessorFactory + return execute(() -> (QuestionnaireResponse) questionnaireProcessorFactory .create(requestDetails) .populate( getQuestionnaireMonad(questionnaire, canonical, url, version), @@ -151,7 +152,7 @@ public QuestionnaireResponse populate( isUseServerData(local, useServerData), getEndpoint(fhirVersion, dataEndpoint), getEndpoint(fhirVersion, contentEndpoint), - getEndpoint(fhirVersion, terminologyEndpoint)); + getEndpoint(fhirVersion, terminologyEndpoint))); } private boolean isUseServerData(BooleanType local, BooleanType useServerData) { diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaireresponse/QuestionnaireResponseExtractProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaireresponse/QuestionnaireResponseExtractProvider.java index 327704569..97ee31496 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaireresponse/QuestionnaireResponseExtractProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/questionnaireresponse/QuestionnaireResponseExtractProvider.java @@ -1,5 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.questionnaireresponse; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; + import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; @@ -47,14 +49,14 @@ public IBaseBundle extract( @OperationParam(name = "data") Bundle data, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireResponseProcessorFactory + return execute(() -> questionnaireResponseProcessorFactory .create(requestDetails) .extract( Eithers.forLeft(id), questionnaire == null ? null : Eithers.forRight(questionnaire), parameters, data, - useServerData == null ? Boolean.TRUE : useServerData.booleanValue()); + useServerData == null ? Boolean.TRUE : useServerData.booleanValue())); } /** @@ -79,13 +81,13 @@ public IBaseBundle extract( @OperationParam(name = "data") Bundle data, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return questionnaireResponseProcessorFactory + return execute(() -> questionnaireResponseProcessorFactory .create(requestDetails) .extract( Eithers.forRight(questionnaireResponse), questionnaire == null ? null : Eithers.for2(null, questionnaire), parameters, data, - useServerData == null ? Boolean.TRUE : useServerData.booleanValue()); + useServerData == null ? Boolean.TRUE : useServerData.booleanValue())); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/structuredefinition/StructureDefinitionQuestionnaireProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/structuredefinition/StructureDefinitionQuestionnaireProvider.java index 94837b8e8..b65deff7c 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/structuredefinition/StructureDefinitionQuestionnaireProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/structuredefinition/StructureDefinitionQuestionnaireProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.structuredefinition; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import ca.uhn.fhir.context.FhirVersionEnum; @@ -53,7 +54,7 @@ public Questionnaire questionnaire( @OperationParam(name = "contentEndpoint") ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) { - return (Questionnaire) questionnaireProcessorFactory + return execute(() -> (Questionnaire) questionnaireProcessorFactory .create(requestDetails) .generateQuestionnaire( Eithers.forMiddle3(id), @@ -61,7 +62,7 @@ public Questionnaire questionnaire( requiredOnly == null ? Boolean.FALSE : requiredOnly.booleanValue(), getEndpoint(fhirVersion, contentEndpoint), getEndpoint(fhirVersion, terminologyEndpoint), - null); + null)); } /** @@ -93,7 +94,7 @@ public Questionnaire questionnaire( @OperationParam(name = "contentEndpoint") ParametersParameterComponent contentEndpoint, @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, RequestDetails requestDetails) { - return (Questionnaire) questionnaireProcessorFactory + return execute(() -> (Questionnaire) questionnaireProcessorFactory .create(requestDetails) .generateQuestionnaire( Eithers.for3(getCanonicalType(fhirVersion, canonical, url, version), null, profile), @@ -101,6 +102,6 @@ public Questionnaire questionnaire( requiredOnly == null ? Boolean.FALSE : requiredOnly.booleanValue(), getEndpoint(fhirVersion, contentEndpoint), getEndpoint(fhirVersion, terminologyEndpoint), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetDataRequirementsProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetDataRequirementsProvider.java index af0cc1ee5..b509a19a7 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetDataRequirementsProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetDataRequirementsProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.valueset; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import ca.uhn.fhir.context.FhirVersionEnum; @@ -31,7 +32,7 @@ public ValueSetDataRequirementsProvider(IValueSetProcessorFactory valueSetFactor @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = ValueSet.class) public IBaseResource getDataRequirements(@IdParam IdType id, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return valueSetFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null); + return execute(() -> valueSetFactory.create(requestDetails).dataRequirements(Eithers.forMiddle3(id), null)); } @Operation(name = ProviderConstants.CR_OPERATION_DATAREQUIREMENTS, idempotent = true, type = ValueSet.class) @@ -42,13 +43,13 @@ public IBaseResource getDataRequirements( @OperationParam(name = "version") StringType version, RequestDetails requestDetails) throws InternalErrorException, FHIRException { - return valueSetFactory + return execute(() -> valueSetFactory .create(requestDetails) .dataRequirements( Eithers.for3( getCanonicalType(fhirVersion, canonical, url, version), getIdType(fhirVersion, "ValueSet", id), null), - null); + null)); } } diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetPackageProvider.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetPackageProvider.java index 9dd36d028..aaa53f8bf 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetPackageProvider.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/r4/valueset/ValueSetPackageProvider.java @@ -1,6 +1,7 @@ package org.opencds.cqf.fhir.cr.hapi.r4.valueset; import static org.opencds.cqf.fhir.cr.hapi.common.CanonicalHelper.getCanonicalType; +import static org.opencds.cqf.fhir.cr.hapi.common.CrExceptionTranslator.execute; import static org.opencds.cqf.fhir.cr.hapi.common.IdHelper.getIdType; import static org.opencds.cqf.fhir.utility.EndpointHelper.getEndpoint; import static org.opencds.cqf.fhir.utility.PackageHelper.packageParameters; @@ -46,14 +47,14 @@ public Bundle packageValueSet( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) valueSetProcessorFactory + return execute(() -> (Bundle) valueSetProcessorFactory .create(requestDetails) .packageValueSet( Eithers.forMiddle3(id), packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } /** @@ -77,7 +78,7 @@ public Bundle packageValueSet( @OperationParam(name = "terminologyEndpoint") ParametersParameterComponent terminologyEndpoint, @OperationParam(name = "usePut") BooleanType usePut, RequestDetails requestDetails) { - return (Bundle) valueSetProcessorFactory + return execute(() -> (Bundle) valueSetProcessorFactory .create(requestDetails) .packageValueSet( Eithers.for3( @@ -87,6 +88,6 @@ public Bundle packageValueSet( packageParameters( fhirVersion, getEndpoint(fhirVersion, terminologyEndpoint), - usePut == null ? Boolean.FALSE : usePut.booleanValue())); + usePut == null ? Boolean.FALSE : usePut.booleanValue()))); } } diff --git a/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java b/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java new file mode 100644 index 000000000..7bb3e4f12 --- /dev/null +++ b/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java @@ -0,0 +1,131 @@ +// Created by claude-opus-4-6 +package org.opencds.cqf.fhir.cr.hapi.common; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; +import org.junit.jupiter.api.Test; + +class CrExceptionTranslatorTest { + + @Test + void execute_returnsResultOnSuccess() { + var result = CrExceptionTranslator.execute(() -> "hello"); + assertThat(result, is(equalTo("hello"))); + } + + @Test + void execute_translatesIllegalArgumentToInvalidRequest() { + var cause = new IllegalArgumentException("bad input"); + var thrown = assertThrows( + InvalidRequestException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown.getMessage(), containsString("bad input")); + assertThat(thrown.getCause(), is(sameInstance(cause))); + } + + @Test + void execute_translatesUnsupportedOperationToNotImplemented() { + var cause = new UnsupportedOperationException("not supported"); + var thrown = assertThrows( + NotImplementedOperationException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown.getMessage(), containsString("not supported")); + assertThat(thrown.getCause(), is(sameInstance(cause))); + } + + @Test + void execute_doesNotCatchIllegalState() { + var cause = new IllegalStateException("internal error"); + var thrown = assertThrows( + IllegalStateException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown, is(sameInstance(cause))); + } + + @Test + void execute_doesNotCatchNullPointer() { + var cause = new NullPointerException("null ref"); + var thrown = assertThrows( + NullPointerException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown, is(sameInstance(cause))); + } + + @Test + void execute_doesNotCatchBaseException() { + var cause = new RuntimeException("generic"); + var thrown = assertThrows( + RuntimeException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown, is(sameInstance(cause))); + } + + @Test + void execute_doesNotTranslateExistingRestExceptions() { + var cause = new InvalidRequestException("already translated"); + var thrown = assertThrows( + InvalidRequestException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown, is(sameInstance(cause))); + } + + @Test + void executeVoid_completesOnSuccess() { + CrExceptionTranslator.executeVoid(() -> {}); + } + + @Test + void executeVoid_translatesIllegalArgumentToInvalidRequest() { + var cause = new IllegalArgumentException("bad void input"); + var thrown = assertThrows( + InvalidRequestException.class, + () -> CrExceptionTranslator.executeVoid(() -> { + throw cause; + })); + assertThat(thrown.getMessage(), containsString("bad void input")); + assertThat(thrown.getCause(), is(sameInstance(cause))); + } + + @Test + void executeVoid_translatesUnsupportedOperationToNotImplemented() { + var cause = new UnsupportedOperationException("not supported void"); + var thrown = assertThrows( + NotImplementedOperationException.class, + () -> CrExceptionTranslator.executeVoid(() -> { + throw cause; + })); + assertThat(thrown.getMessage(), containsString("not supported void")); + assertThat(thrown.getCause(), is(sameInstance(cause))); + } + + @Test + void execute_preservesCauseType() { + var cause = new IllegalArgumentException("test"); + var thrown = assertThrows( + InvalidRequestException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown.getCause(), is(instanceOf(IllegalArgumentException.class))); + } +} From 642bb9ff8b73003bd803bc749f7c5d77938b1a17 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 11 Mar 2026 18:29:58 -0400 Subject: [PATCH 3/4] GL-7: Simplify clinical-reasoning boundary exception translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused executeVoid method and its tests from CrExceptionTranslator. All 51 provider methods use execute() with Supplier — no provider has a void return type requiring executeVoid. Co-Authored-By: Claude Opus 4.6 --- .../cr/hapi/common/CrExceptionTranslator.java | 19 ------------ .../common/CrExceptionTranslatorTest.java | 29 ------------------- 2 files changed, 48 deletions(-) diff --git a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java index b0fd590b2..57e7d6c60 100644 --- a/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java @@ -39,23 +39,4 @@ public static T execute(Supplier operation) { throw translated; } } - - /** - * Execute a void operation and translate domain exceptions to REST exceptions. - * - * @param operation the operation to execute - * @throws InvalidRequestException if the operation throws {@link IllegalArgumentException} - * @throws NotImplementedOperationException if the operation throws {@link UnsupportedOperationException} - */ - public static void executeVoid(Runnable operation) { - try { - operation.run(); - } catch (IllegalArgumentException e) { - throw new InvalidRequestException(e.getMessage(), e); - } catch (UnsupportedOperationException e) { - var translated = new NotImplementedOperationException(e.getMessage()); - translated.initCause(e); - throw translated; - } - } } diff --git a/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java b/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java index 7bb3e4f12..38184f9c1 100644 --- a/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java +++ b/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java @@ -89,35 +89,6 @@ void execute_doesNotTranslateExistingRestExceptions() { assertThat(thrown, is(sameInstance(cause))); } - @Test - void executeVoid_completesOnSuccess() { - CrExceptionTranslator.executeVoid(() -> {}); - } - - @Test - void executeVoid_translatesIllegalArgumentToInvalidRequest() { - var cause = new IllegalArgumentException("bad void input"); - var thrown = assertThrows( - InvalidRequestException.class, - () -> CrExceptionTranslator.executeVoid(() -> { - throw cause; - })); - assertThat(thrown.getMessage(), containsString("bad void input")); - assertThat(thrown.getCause(), is(sameInstance(cause))); - } - - @Test - void executeVoid_translatesUnsupportedOperationToNotImplemented() { - var cause = new UnsupportedOperationException("not supported void"); - var thrown = assertThrows( - NotImplementedOperationException.class, - () -> CrExceptionTranslator.executeVoid(() -> { - throw cause; - })); - assertThat(thrown.getMessage(), containsString("not supported void")); - assertThat(thrown.getCause(), is(sameInstance(cause))); - } - @Test void execute_preservesCauseType() { var cause = new IllegalArgumentException("test"); From 587aa09c723fcdee710c99b587c35fe705b5a75f Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 11 Mar 2026 18:49:17 -0400 Subject: [PATCH 4/4] GL-7: Scope ARCHITECTURE.md forbidden imports as aspirational Existing code has legacy violations of the REST exception import rule. Add note acknowledging these as tech debt to be migrated over time, not blockers for new contributions. Co-Authored-By: Claude Opus 4.6 --- ARCHITECTURE.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 55bc3bb38..2ec9645de 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -38,7 +38,7 @@ As you cross boundaries in an application, the primary domain model shifts. Each ### Forbidden Imports in Core Modules -The following modules MUST NOT import from `ca.uhn.fhir.rest.server.exceptions`: +**New code** in the following modules MUST NOT import from `ca.uhn.fhir.rest.server.exceptions`: - `cqf-fhir-cr` - `cqf-fhir-cql` @@ -46,6 +46,8 @@ The following modules MUST NOT import from `ca.uhn.fhir.rest.server.exceptions`: These modules are used by the CLI, by Android clients, and by other non-REST consumers. REST/HTTP concepts do not belong here. +> **Note:** Existing code has legacy violations of this rule. These should be migrated over time but are not blockers for new contributions. + ### Exception Handling Pattern **Core modules** throw domain-appropriate exceptions: