diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000000..2ec9645dea --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,165 @@ +# 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 + +**New code** in 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. + +> **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: + +- `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.."); +} +``` 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 0000000000..57e7d6c60d --- /dev/null +++ b/cqf-fhir-cr-hapi/src/main/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslator.java @@ -0,0 +1,42 @@ +// 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; + } + } +} 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 7c3a124ad7..b6b0f1506c 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 00bdb5b21f..1c23020e2f 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 38f589f6ce..96e6139d49 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 9c124ee2e1..a2a90b73e6 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 4f507d059e..b0f1859f52 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 a6db93e2fd..a699d3a603 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 e3dcba68e0..4890ce1029 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 f37ac2527d..a48bc48e99 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 4262b83f4a..2f34c717a4 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 a681d6868a..e243a4c417 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 7fc2b14e85..220c5b70e1 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 b34c070b39..3bbcf6def4 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 eefda5647c..e8df6d7f90 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 f74e308336..450081ec84 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 c6dc8c8754..5fe65fe20f 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 252e58e5e5..eab8316982 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 2263cf4e31..2d1c2fe85a 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 e844a1aa6c..fbed3b8485 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 ab81159659..e7e3d8c266 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 97bba25605..3edc8e3e3c 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 5d2a4b8ddd..df5bbd0891 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 59b57cdc11..f907595142 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 44ca1d7482..8f8385c14f 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 e5008149b6..a6e69cece0 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 908a348caa..9d5bf20425 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 7424759ddf..15499dbdbe 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 d09ddf6845..291881498c 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 149154c6a2..233c16195c 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 5c7355f6b0..bb92a1444c 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 d676f5dadb..9558071a83 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 a30717af77..fe33fe7420 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 9cac48421a..48ccb459df 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 42e8dee86e..6660bf9979 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 654c328dc7..94d6a3e762 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 c8110db9b9..b43a657eda 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 778fc89677..d53db28083 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 d261f15856..6134fea44e 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 42feeec608..68a50f2023 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 beea3503c8..a20e990ce0 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 74fc59d3ee..094ce037f1 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 e7591147cb..df4a432d56 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 7611a863dd..d3b6ea6d3d 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 19434f1037..5dca916b21 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 f4cfee834c..205d901d48 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 d07911e9ee..077a841d95 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 dc8b17460a..b534f38c5e 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 2360db0cae..79c2d9e98f 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 3277045698..97ee314967 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 94837b8e8a..b65deff7c3 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 af0cc1ee57..b509a19a77 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 9dd36d028b..aaa53f8bfb 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 0000000000..38184f9c11 --- /dev/null +++ b/cqf-fhir-cr-hapi/src/test/java/org/opencds/cqf/fhir/cr/hapi/common/CrExceptionTranslatorTest.java @@ -0,0 +1,102 @@ +// 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 execute_preservesCauseType() { + var cause = new IllegalArgumentException("test"); + var thrown = assertThrows( + InvalidRequestException.class, + () -> CrExceptionTranslator.execute(() -> { + throw cause; + })); + assertThat(thrown.getCause(), is(instanceOf(IllegalArgumentException.class))); + } +}