From 699f863fe2f7646262bdd2bc885a796518b9ad74 Mon Sep 17 00:00:00 2001 From: jmarchionatto <60409882+jmarchionatto@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:31:32 -0400 Subject: [PATCH 1/4] Jm improve test server helper (#6281) * Improve docs as indexing is not the only function using extraction * Add providers map which to be able to add any kind of provider dynamically --------- Co-authored-by: juan.marchionatto --- .../extractor/ISearchParamExtractor.java | 6 ++--- .../test/utilities/RestServerR4Helper.java | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java index 77a43ddc2e5..e8d1755c780 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java @@ -44,13 +44,13 @@ public interface ISearchParamExtractor { /** * Constant for the {@literal theSearchParamFilter} parameters on this interface - * indicating that all search parameters should be indexed. + * indicating that all search parameters should be extracted. */ ISearchParamFilter ALL_PARAMS = t -> t; /** * Constant for the {@literal theSearchParamFilter} parameters on this interface - * indicating that no search parameters should be indexed. + * indicating that no search parameters should be extracted. */ ISearchParamFilter NO_PARAMS = t -> Collections.emptyList(); @@ -155,7 +155,7 @@ public interface ISearchParamExtractor { interface ISearchParamFilter { /** - * Given the list of search parameters for indexing, an implementation of this + * Given the list of search parameters for extracting, an implementation of this * interface may selectively remove any that it wants to remove (or can add if desired). *

* Implementations must not modify the list that is passed in. If changes are diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/RestServerR4Helper.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/RestServerR4Helper.java index 5ac8aa67343..435d000939c 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/RestServerR4Helper.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/RestServerR4Helper.java @@ -221,6 +221,28 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa myRestServer.setConceptMapResourceProvider(theResourceProvider); } + public HashMapResourceProvider getResourceProvider(Class theResourceType) { + @SuppressWarnings("unchecked") + HashMapResourceProvider resourceProvider = (HashMapResourceProvider) myRestServer.myResourceProvidersMap.get(theResourceType); + assert resourceProvider != null : "No resource provider defined for resource type: '" + theResourceType + "'" ; + return resourceProvider; + } + + public void setResourceProvider(HashMapResourceProvider theResourceProvider) { + assert theResourceProvider.getResourceType() != null : "resourceProvider doesn't have a resourceType"; + @SuppressWarnings("unchecked") + HashMapResourceProvider resourceProvider = (HashMapResourceProvider) myRestServer.myResourceProvidersMap.get(theResourceProvider.getResourceType()); + + if (resourceProvider != null) { + resourceProvider.getStoredResources().forEach(theResourceProvider::store); + myRestServer.unregisterProvider(resourceProvider); + } + + registerProvider(theResourceProvider); + myRestServer.myResourceProvidersMap.put(theResourceProvider.getResourceType(), theResourceProvider); + } + + public void setPagingProvider(IPagingProvider thePagingProvider) { myPagingProvider = thePagingProvider; } @@ -295,6 +317,8 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa private HashMapResourceProvider myConceptMapResourceProvider; private RestServerDstu3Helper.MyPlainProvider myPlainProvider; + private final Map, HashMapResourceProvider> myResourceProvidersMap = new HashMap<>(); + private final boolean myInitialTransactionLatchEnabled; private PagingHttpMethodEnum myPagingHttpMethod = PagingHttpMethodEnum.GET; From 02d38bce1467aefad359385d2052221808a376db Mon Sep 17 00:00:00 2001 From: TipzCM Date: Fri, 13 Sep 2024 12:33:40 -0400 Subject: [PATCH 2/4] removing unneeded fields from HRJ_RESOURCE table (#6284) --- ...e-unneeded-fields-from-resource-table.yaml | 10 +++++++ .../fhir/jpa/model/entity/ResourceTable.java | 30 ------------------- 2 files changed, 10 insertions(+), 30 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6283-remove-unneeded-fields-from-resource-table.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6283-remove-unneeded-fields-from-resource-table.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6283-remove-unneeded-fields-from-resource-table.yaml new file mode 100644 index 00000000000..a1e871a8656 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6283-remove-unneeded-fields-from-resource-table.yaml @@ -0,0 +1,10 @@ +--- +type: remove +issue: 6283 +title: "Hibernate Search Fulltext fields which were unused + have been removed from indexing. + This will reduce storage usage in Lucene and Elasticsearch. + The fields that were removed are: `myNarrativeTextEdgeNGram`, + `myNarrativeTextNGram`, `myNarrativeTextPhonetic`, `myContentTextEdgeNGram`, + `myContentTextNGram`, `myContentTextPhonetic`. +" diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java index e897ae71786..6163011eeb4 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java @@ -119,21 +119,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas searchable = Searchable.YES, projectable = Projectable.YES, analyzer = "standardAnalyzer") - @FullTextField( - name = "myContentTextEdgeNGram", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompleteEdgeAnalyzer") - @FullTextField( - name = "myContentTextNGram", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompleteNGramAnalyzer") - @FullTextField( - name = "myContentTextPhonetic", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompletePhoneticAnalyzer") @OptimisticLock(excluded = true) @IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion"))) private String myContentText; @@ -171,21 +156,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas searchable = Searchable.YES, projectable = Projectable.YES, analyzer = "standardAnalyzer") - @FullTextField( - name = "myNarrativeTextEdgeNGram", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompleteEdgeAnalyzer") - @FullTextField( - name = "myNarrativeTextNGram", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompleteNGramAnalyzer") - @FullTextField( - name = "myNarrativeTextPhonetic", - searchable = Searchable.YES, - projectable = Projectable.NO, - analyzer = "autocompletePhoneticAnalyzer") @OptimisticLock(excluded = true) @IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion"))) private String myNarrativeText; From 1fad912193ec1da9e41dc7c46473365075446fa5 Mon Sep 17 00:00:00 2001 From: Aditya Dave Date: Wed, 18 Sep 2024 10:01:17 -0400 Subject: [PATCH 3/4] 6262 cds hooks returns 400 when extension passed in the cdsservicerequestjson (#6274) * fail test * potential fix * spotless * alternative fix * spotless * remove the new method and replace usage for the old one * spotless * fix issue with context failing deserialization * add validation for context, hook and hook instance * spotless * add message codes * spotless * changelog * cleanup * spotless * bump version to 7.5.1-SNAPSHOT --- hapi-deployable-pom/pom.xml | 2 +- hapi-fhir-android/pom.xml | 2 +- hapi-fhir-base/pom.xml | 2 +- hapi-fhir-bom/pom.xml | 4 +- hapi-fhir-checkstyle/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-api/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-app/pom.xml | 2 +- hapi-fhir-cli/pom.xml | 2 +- hapi-fhir-client-okhttp/pom.xml | 2 +- hapi-fhir-client/pom.xml | 2 +- hapi-fhir-converter/pom.xml | 2 +- hapi-fhir-dist/pom.xml | 2 +- hapi-fhir-docs/pom.xml | 2 +- ...tion-when-extension-passed-in-request.yaml | 4 + hapi-fhir-jacoco/pom.xml | 2 +- hapi-fhir-jaxrsserver-base/pom.xml | 2 +- hapi-fhir-jpa/pom.xml | 2 +- hapi-fhir-jpaserver-base/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-jpaserver-hfql/pom.xml | 2 +- hapi-fhir-jpaserver-ips/pom.xml | 2 +- hapi-fhir-jpaserver-mdm/pom.xml | 2 +- hapi-fhir-jpaserver-model/pom.xml | 2 +- hapi-fhir-jpaserver-searchparam/pom.xml | 2 +- hapi-fhir-jpaserver-subscription/pom.xml | 2 +- hapi-fhir-jpaserver-test-dstu2/pom.xml | 2 +- hapi-fhir-jpaserver-test-dstu3/pom.xml | 2 +- hapi-fhir-jpaserver-test-r4/pom.xml | 2 +- hapi-fhir-jpaserver-test-r4b/pom.xml | 2 +- hapi-fhir-jpaserver-test-r5/pom.xml | 2 +- hapi-fhir-jpaserver-test-utilities/pom.xml | 2 +- hapi-fhir-jpaserver-uhnfhirtest/pom.xml | 2 +- hapi-fhir-server-cds-hooks/pom.xml | 2 +- .../cdshooks/api/ICdsServiceRegistry.java | 2 +- .../cdshooks/api/json/CdsHooksExtension.java | 2 + .../json/CdsServiceRequestContextJson.java | 2 + .../fhir/cdshooks/config/CdsHooksConfig.java | 5 +- .../controller/CdsHooksController.java | 3 +- .../CdsServiceRequestJsonDeserializer.java | 111 ++++++----- .../cdshooks/svc/CdsServiceRegistryImpl.java | 23 +-- .../controller/CdsHooksControllerTest.java | 15 +- ...CdsServiceRequestJsonDeserializerTest.java | 187 ++++++++++++------ .../svc/CdsServiceRegistryImplTest.java | 7 +- hapi-fhir-server-mdm/pom.xml | 2 +- hapi-fhir-server-openapi/pom.xml | 2 +- hapi-fhir-server/pom.xml | 2 +- .../hapi-fhir-caching-api/pom.xml | 2 +- .../hapi-fhir-caching-caffeine/pom.xml | 4 +- .../hapi-fhir-caching-guava/pom.xml | 2 +- .../hapi-fhir-caching-testing/pom.xml | 2 +- hapi-fhir-serviceloaders/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../hapi-fhir-spring-boot-samples/pom.xml | 2 +- .../hapi-fhir-spring-boot-starter/pom.xml | 2 +- hapi-fhir-spring-boot/pom.xml | 2 +- hapi-fhir-sql-migrate/pom.xml | 2 +- hapi-fhir-storage-batch2-jobs/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-storage-batch2/pom.xml | 2 +- hapi-fhir-storage-cr/pom.xml | 2 +- hapi-fhir-storage-mdm/pom.xml | 2 +- hapi-fhir-storage-test-utilities/pom.xml | 2 +- hapi-fhir-storage/pom.xml | 2 +- hapi-fhir-structures-dstu2.1/pom.xml | 2 +- hapi-fhir-structures-dstu2/pom.xml | 2 +- hapi-fhir-structures-dstu3/pom.xml | 2 +- hapi-fhir-structures-hl7org-dstu2/pom.xml | 2 +- hapi-fhir-structures-r4/pom.xml | 2 +- hapi-fhir-structures-r4b/pom.xml | 2 +- hapi-fhir-structures-r5/pom.xml | 2 +- hapi-fhir-test-utilities/pom.xml | 2 +- hapi-fhir-testpage-overlay/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-validation-resources-dstu2/pom.xml | 2 +- hapi-fhir-validation-resources-dstu3/pom.xml | 2 +- hapi-fhir-validation-resources-r4/pom.xml | 2 +- hapi-fhir-validation-resources-r4b/pom.xml | 2 +- hapi-fhir-validation-resources-r5/pom.xml | 2 +- hapi-fhir-validation/pom.xml | 2 +- hapi-tinder-plugin/pom.xml | 2 +- hapi-tinder-test/pom.xml | 2 +- pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- 88 files changed, 305 insertions(+), 214 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6262-fix-cds-hooks-invocation-when-extension-passed-in-request.yaml diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index b6007b191bb..a63d30df6f8 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index 53f3353e6a7..bbb4e7d9acb 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 6cec98a4b87..b845c698f1b 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index b18421ade9c..22b8724f7e8 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -4,7 +4,7 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT pom HAPI FHIR BOM @@ -12,7 +12,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml index 34b9a244edc..e3a44edd071 100644 --- a/hapi-fhir-checkstyle/pom.xml +++ b/hapi-fhir-checkstyle/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index d8ade0aa363..64ba6637ea2 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index 7997bade47d..c6e0de92d36 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index 6ad7cc96fd9..25ee977592a 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index d1d0a155112..5e6bb12d288 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index c0837508600..53a25a1d95d 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index 99cc8732e05..8ee8cee53fa 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index f9fdfc45a2c..ed0a4dd5507 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index 7659f76387a..095b30baec8 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6262-fix-cds-hooks-invocation-when-extension-passed-in-request.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6262-fix-cds-hooks-invocation-when-extension-passed-in-request.yaml new file mode 100644 index 00000000000..a68ee312359 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_6_0/6262-fix-cds-hooks-invocation-when-extension-passed-in-request.yaml @@ -0,0 +1,4 @@ +--- +type: fix +issue: 6262 +title: "Previously, when a `extension` was passed in as a part of the CDS hooks request, it would result in a `400 service not found`. This behaviour has now been fixed." diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index a104bf476fb..c15128beca5 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,7 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index dd8da0f3742..4346a3fd25d 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml index 85a9534d7d5..c01367fde30 100644 --- a/hapi-fhir-jpa/pom.xml +++ b/hapi-fhir-jpa/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 54888458cbf..4a7722fa96d 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml index 541c6bcf8e4..63278c80de9 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-hfql/pom.xml b/hapi-fhir-jpaserver-hfql/pom.xml index c3518186230..b645a59783e 100644 --- a/hapi-fhir-jpaserver-hfql/pom.xml +++ b/hapi-fhir-jpaserver-hfql/pom.xml @@ -3,7 +3,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-ips/pom.xml b/hapi-fhir-jpaserver-ips/pom.xml index c3bb21c52f4..854a185fe21 100644 --- a/hapi-fhir-jpaserver-ips/pom.xml +++ b/hapi-fhir-jpaserver-ips/pom.xml @@ -3,7 +3,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index c0b4ddef5d2..33f317dc5d5 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index 9ee46575c6e..3eb70e0326c 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index 7c33dcd01cc..1a24fcf3297 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 4e85901e5e9..ba09eed0ab5 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu2/pom.xml b/hapi-fhir-jpaserver-test-dstu2/pom.xml index fe968fe84cb..c3f924fd915 100644 --- a/hapi-fhir-jpaserver-test-dstu2/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu2/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu3/pom.xml b/hapi-fhir-jpaserver-test-dstu3/pom.xml index e8d0f1f6bb4..d665c0f3c97 100644 --- a/hapi-fhir-jpaserver-test-dstu3/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu3/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4/pom.xml b/hapi-fhir-jpaserver-test-r4/pom.xml index 548d7257155..86ac609723f 100644 --- a/hapi-fhir-jpaserver-test-r4/pom.xml +++ b/hapi-fhir-jpaserver-test-r4/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4b/pom.xml b/hapi-fhir-jpaserver-test-r4b/pom.xml index 37dad0b5380..dec34cddda1 100644 --- a/hapi-fhir-jpaserver-test-r4b/pom.xml +++ b/hapi-fhir-jpaserver-test-r4b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/pom.xml b/hapi-fhir-jpaserver-test-r5/pom.xml index 9922a18d6d9..32b02b3e1ad 100644 --- a/hapi-fhir-jpaserver-test-r5/pom.xml +++ b/hapi-fhir-jpaserver-test-r5/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 61c593d03cf..71e63e55591 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 47dd4ef075c..f62519f252c 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-server-cds-hooks/pom.xml b/hapi-fhir-server-cds-hooks/pom.xml index 5f52f9cdf23..1f396dc4fdc 100644 --- a/hapi-fhir-server-cds-hooks/pom.xml +++ b/hapi-fhir-server-cds-hooks/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsServiceRegistry.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsServiceRegistry.java index e385650dc25..e3002797b60 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsServiceRegistry.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsServiceRegistry.java @@ -45,7 +45,7 @@ public interface ICdsServiceRegistry { * @param theCdsServiceRequestJson the service request * @return the service response */ - CdsServiceResponseJson callService(String theServiceId, CdsServiceRequestJson theCdsServiceRequestJson); + CdsServiceResponseJson callService(String theServiceId, Object theCdsServiceRequestJson); /** * This is the REST method available at https://example.com/cds-services/{theServiceId}/feedback diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsHooksExtension.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsHooksExtension.java index adfbf119e5d..f4d41bc2189 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsHooksExtension.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsHooksExtension.java @@ -20,9 +20,11 @@ package ca.uhn.hapi.fhir.cdshooks.api.json; import ca.uhn.fhir.model.api.IModelJson; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; /** * Users can define CDS Hooks extensions by extending this class. * Implementors can extend this class for defining their custom extensions. */ +@JsonIgnoreProperties(ignoreUnknown = true) public class CdsHooksExtension implements IModelJson {} diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsServiceRequestContextJson.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsServiceRequestContextJson.java index de2988594c7..9fb8649e5ee 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsServiceRequestContextJson.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/json/CdsServiceRequestContextJson.java @@ -21,6 +21,7 @@ package ca.uhn.hapi.fhir.cdshooks.api.json; import ca.uhn.fhir.model.api.IModelJson; import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import org.hl7.fhir.instance.model.api.IBaseResource; import java.util.Collections; @@ -29,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +@JsonIgnoreProperties(ignoreUnknown = true) public class CdsServiceRequestContextJson extends BaseCdsServiceJson implements IModelJson { @JsonAnyGetter diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java index 37efd73711c..34f9b2258ab 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java @@ -31,6 +31,7 @@ import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService; import ca.uhn.hapi.fhir.cdshooks.api.ICdsHooksDaoAuthorizationSvc; import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceRegistry; import ca.uhn.hapi.fhir.cdshooks.module.CdsHooksObjectMapperFactory; +import ca.uhn.hapi.fhir.cdshooks.serializer.CdsServiceRequestJsonDeserializer; import ca.uhn.hapi.fhir.cdshooks.svc.CdsConfigServiceImpl; import ca.uhn.hapi.fhir.cdshooks.svc.CdsHooksContextBooter; import ca.uhn.hapi.fhir.cdshooks.svc.CdsServiceRegistryImpl; @@ -100,13 +101,15 @@ public class CdsHooksConfig { ICdsCrServiceFactory theCdsCrServiceFactory, ICrDiscoveryServiceFactory theCrDiscoveryServiceFactory, FhirContext theFhirContext) { + final CdsServiceRequestJsonDeserializer cdsServiceRequestJsonDeserializer = + new CdsServiceRequestJsonDeserializer(theFhirContext, theObjectMapper); return new CdsServiceRegistryImpl( theCdsHooksContextBooter, theCdsPrefetchSvc, theObjectMapper, theCdsCrServiceFactory, theCrDiscoveryServiceFactory, - theFhirContext); + cdsServiceRequestJsonDeserializer); } @Bean diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksController.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksController.java index 10896e2f74a..0ae202abec4 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksController.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksController.java @@ -21,7 +21,6 @@ package ca.uhn.hapi.fhir.cdshooks.controller; import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceRegistry; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceFeedbackJson; -import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServicesJson; import org.springframework.http.HttpStatus; @@ -73,7 +72,7 @@ public class CdsHooksController { method = {RequestMethod.POST}, consumes = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity cdsServiceRequest( - @PathVariable("cds_hook") String theCdsHook, @RequestBody CdsServiceRequestJson theCdsServiceRequestJson) { + @PathVariable("cds_hook") String theCdsHook, @RequestBody Object theCdsServiceRequestJson) { CdsServiceResponseJson response = myCdsServiceRegistry.callService(theCdsHook, theCdsServiceRequestJson); return ResponseEntity.status(200) .contentType(MediaType.APPLICATION_JSON) diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializer.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializer.java index 6019a3d114c..d64ff9c3964 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializer.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializer.java @@ -20,84 +20,60 @@ package ca.uhn.hapi.fhir.cdshooks.serializer; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.serializer.FhirResourceDeserializer; +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsHooksExtension; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestContextJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson; -import ca.uhn.hapi.fhir.cdshooks.svc.CdsServiceRegistryImpl; -import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.module.SimpleModule; +import jakarta.annotation.Nonnull; import org.hl7.fhir.instance.model.api.IBaseResource; -import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; -public class CdsServiceRequestJsonDeserializer extends StdDeserializer { - - private final CdsServiceRegistryImpl myCdsServiceRegistry; +public class CdsServiceRequestJsonDeserializer { private final ObjectMapper myObjectMapper; private final FhirContext myFhirContext; private final IParser myParser; - public CdsServiceRequestJsonDeserializer(CdsServiceRegistryImpl theCdsServiceRegistry, FhirContext theFhirContext) { - super(CdsServiceRequestJson.class); - myCdsServiceRegistry = theCdsServiceRegistry; + public CdsServiceRequestJsonDeserializer( + @Nonnull FhirContext theFhirContext, @Nonnull ObjectMapper theObjectMapper) { myFhirContext = theFhirContext; myParser = myFhirContext.newJsonParser().setPrettyPrint(true); - // We create a new ObjectMapper instead of using the one from the ApplicationContext to avoid an infinite loop - // during deserialization. - myObjectMapper = new ObjectMapper(); - configureObjectMapper(myObjectMapper); + myObjectMapper = theObjectMapper; } - @Override - public CdsServiceRequestJson deserialize(JsonParser theJsonParser, DeserializationContext theDeserializationContext) - throws IOException { - final JsonNode cdsServiceRequestJsonNode = theJsonParser.getCodec().readTree(theJsonParser); - final JsonNode hookNode = cdsServiceRequestJsonNode.get("hook"); - final JsonNode extensionNode = cdsServiceRequestJsonNode.get("extension"); - final JsonNode requestContext = cdsServiceRequestJsonNode.get("context"); - final CdsServiceRequestJson cdsServiceRequestJson = - myObjectMapper.treeToValue(cdsServiceRequestJsonNode, CdsServiceRequestJson.class); - if (extensionNode != null) { - CdsHooksExtension myRequestExtension = deserializeExtension(hookNode.textValue(), extensionNode.toString()); - cdsServiceRequestJson.setExtension(myRequestExtension); + public CdsServiceRequestJson deserialize( + @Nonnull CdsServiceJson theCdsServiceJson, @Nonnull Object theCdsServiceRequestJson) { + final JsonNode cdsServiceRequestJsonNode = + myObjectMapper.convertValue(theCdsServiceRequestJson, JsonNode.class); + final JsonNode contextNode = cdsServiceRequestJsonNode.get("context"); + validateHookInstance(cdsServiceRequestJsonNode.get("hookInstance")); + validateHook(cdsServiceRequestJsonNode.get("hook")); + validateContext(contextNode); + try { + final JsonNode extensionNode = cdsServiceRequestJsonNode.get("extension"); + final CdsServiceRequestJson cdsServiceRequestJson = + myObjectMapper.convertValue(cdsServiceRequestJsonNode, CdsServiceRequestJson.class); + LinkedHashMap map = myObjectMapper.readValue(contextNode.toString(), LinkedHashMap.class); + cdsServiceRequestJson.setContext(deserializeContext(map)); + if (extensionNode != null) { + CdsHooksExtension myRequestExtension = + deserializeExtension(theCdsServiceJson, extensionNode.toString()); + cdsServiceRequestJson.setExtension(myRequestExtension); + } + return cdsServiceRequestJson; + } catch (JsonProcessingException | IllegalArgumentException theEx) { + throw new InvalidRequestException(Msg.code(2551) + "Invalid CdsServiceRequest received. " + theEx); } - if (requestContext != null) { - LinkedHashMap map = - myObjectMapper.readValue(requestContext.toString(), LinkedHashMap.class); - cdsServiceRequestJson.setContext(deserializeRequestContext(map)); - } - return cdsServiceRequestJson; } - void configureObjectMapper(ObjectMapper theObjectMapper) { - SimpleModule module = new SimpleModule(); - module.addDeserializer(IBaseResource.class, new FhirResourceDeserializer(myFhirContext)); - theObjectMapper.registerModule(module); - // set this as we will need to ignore properties which are not defined by specific implementation. - theObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - CdsHooksExtension deserializeExtension(String theServiceId, String theExtension) throws JsonProcessingException { - final CdsServiceJson cdsServicesJson = myCdsServiceRegistry.getCdsServiceJson(theServiceId); - Class extensionClass = cdsServicesJson.getExtensionClass(); - if (extensionClass == null) { - return null; - } - return myObjectMapper.readValue(theExtension, extensionClass); - } - - CdsServiceRequestContextJson deserializeRequestContext(LinkedHashMap theMap) + CdsServiceRequestContextJson deserializeContext(LinkedHashMap theMap) throws JsonProcessingException { final CdsServiceRequestContextJson cdsServiceRequestContextJson = new CdsServiceRequestContextJson(); for (Map.Entry entry : theMap.entrySet()) { @@ -114,4 +90,31 @@ public class CdsServiceRequestJsonDeserializer extends StdDeserializer extensionClass = theCdsServiceJson.getExtensionClass(); + if (extensionClass == null) { + return null; + } + return myObjectMapper.readValue(theExtension, extensionClass); + } + + private void validateHook(JsonNode hookIdNode) { + if (hookIdNode == null) { + throw new InvalidRequestException(Msg.code(2549) + "hook cannot be null for a CdsServiceRequest."); + } + } + + private void validateHookInstance(JsonNode hookInstanceNode) { + if (hookInstanceNode == null) { + throw new InvalidRequestException(Msg.code(2548) + "hookInstance cannot be null for a CdsServiceRequest."); + } + } + + private void validateContext(JsonNode requestContextNode) { + if (requestContextNode == null) { + throw new InvalidRequestException(Msg.code(2550) + "context cannot be null for a CdsServiceRequest."); + } + } } diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImpl.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImpl.java index 720fca731d7..8613dee9554 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImpl.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImpl.java @@ -20,7 +20,6 @@ package ca.uhn.hapi.fhir.cdshooks.svc; import ca.uhn.fhir.context.ConfigurationException; -import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.hapi.fhir.cdshooks.api.ICdsMethod; @@ -38,7 +37,6 @@ import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICrDiscoveryServiceFactory; import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchSvc; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.annotations.VisibleForTesting; import jakarta.annotation.Nonnull; import jakarta.annotation.PostConstruct; @@ -50,7 +48,7 @@ import java.util.function.Function; public class CdsServiceRegistryImpl implements ICdsServiceRegistry { private static final Logger ourLog = LoggerFactory.getLogger(CdsServiceRegistryImpl.class); - + private final CdsServiceRequestJsonDeserializer myCdsServiceRequestJsonDeserializer; private CdsServiceCache myServiceCache; private final CdsHooksContextBooter myCdsHooksContextBooter; @@ -65,19 +63,13 @@ public class CdsServiceRegistryImpl implements ICdsServiceRegistry { ObjectMapper theObjectMapper, ICdsCrServiceFactory theCdsCrServiceFactory, ICrDiscoveryServiceFactory theCrDiscoveryServiceFactory, - FhirContext theFhirContext) { + CdsServiceRequestJsonDeserializer theCdsServiceRequestJsonDeserializer) { myCdsHooksContextBooter = theCdsHooksContextBooter; myCdsPrefetchSvc = theCdsPrefetchSvc; myObjectMapper = theObjectMapper; - // registering this deserializer here instead of - // CdsHooksObjectMapperFactory to avoid circular - // dependency - SimpleModule module = new SimpleModule(); - module.addDeserializer( - CdsServiceRequestJson.class, new CdsServiceRequestJsonDeserializer(this, theFhirContext)); - myObjectMapper.registerModule(module); myCdsCrServiceFactory = theCdsCrServiceFactory; myCrDiscoveryServiceFactory = theCrDiscoveryServiceFactory; + myCdsServiceRequestJsonDeserializer = theCdsServiceRequestJsonDeserializer; } @PostConstruct @@ -91,10 +83,13 @@ public class CdsServiceRegistryImpl implements ICdsServiceRegistry { } @Override - public CdsServiceResponseJson callService(String theServiceId, CdsServiceRequestJson theCdsServiceRequestJson) { + public CdsServiceResponseJson callService(String theServiceId, Object theCdsServiceRequestJson) { + final CdsServiceJson cdsServiceJson = getCdsServiceJson(theServiceId); + final CdsServiceRequestJson deserializedRequest = + myCdsServiceRequestJsonDeserializer.deserialize(cdsServiceJson, theCdsServiceRequestJson); ICdsServiceMethod serviceMethod = (ICdsServiceMethod) getCdsServiceMethodOrThrowException(theServiceId); - myCdsPrefetchSvc.augmentRequest(theCdsServiceRequestJson, serviceMethod); - Object response = serviceMethod.invoke(myObjectMapper, theCdsServiceRequestJson, theServiceId); + myCdsPrefetchSvc.augmentRequest(deserializedRequest, serviceMethod); + Object response = serviceMethod.invoke(myObjectMapper, deserializedRequest, theServiceId); return encodeServiceResponse(theServiceId, response); } diff --git a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksControllerTest.java b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksControllerTest.java index e6067fc16f4..22065764b41 100644 --- a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksControllerTest.java +++ b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/controller/CdsHooksControllerTest.java @@ -5,6 +5,7 @@ import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceRegistry; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceFeebackOutcomeEnum; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceFeedbackJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson; +import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestContextJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseCardJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseJson; @@ -118,6 +119,7 @@ public class CdsHooksControllerTest { request.setHookInstance(TEST_HOOK_INSTANCE); request.setHook(HelloWorldService.TEST_HOOK); request.setFhirServer(TEST_FHIR_SERVER); + request.setContext( withCdsServiceRequestContext()); String requestBody = myObjectMapper.writeValueAsString(request); @@ -142,8 +144,9 @@ public class CdsHooksControllerTest { CdsServiceRequestJson request = new CdsServiceRequestJson(); request.setExtension(requestExtension); request.setFhirServer(TEST_FHIR_SERVER); - request.setHook(HelloWorldService.TEST_HOOK_UNIVERSE_ID); - + request.setHook(HelloWorldService.TEST_HOOK); + request.setContext(withCdsServiceRequestContext()); + request.setHookInstance(UUID.randomUUID().toString()); String requestBody = myObjectMapper.writeValueAsString(request); @@ -163,6 +166,7 @@ public class CdsHooksControllerTest { request.setHookInstance(TEST_HOOK_INSTANCE); request.setHook(HelloWorldService.TEST_HOOK); request.setFhirServer(TEST_FHIR_SERVER); + request.setContext(withCdsServiceRequestContext()); String requestBody = myObjectMapper.writeValueAsString(request); @@ -268,4 +272,11 @@ public class CdsHooksControllerTest { return JsonUtil.serialize(input, true); } + @Nonnull + private static CdsServiceRequestContextJson withCdsServiceRequestContext() { + CdsServiceRequestContextJson cdsServiceRequestContextJson = new CdsServiceRequestContextJson(); + cdsServiceRequestContextJson.put("patientId", "Patient/123"); + return cdsServiceRequestContextJson; + } + } diff --git a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializerTest.java b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializerTest.java index 0e1e659cc8a..ecd8176ce6a 100644 --- a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializerTest.java +++ b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/serializer/CdsServiceRequestJsonDeserializerTest.java @@ -1,106 +1,152 @@ package ca.uhn.hapi.fhir.cdshooks.serializer; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.hapi.fhir.cdshooks.api.json.CdsHooksExtension; +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestContextJson; +import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson; import ca.uhn.hapi.fhir.cdshooks.custom.extensions.model.ExampleExtension; -import ca.uhn.hapi.fhir.cdshooks.svc.CdsServiceRegistryImpl; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.annotation.Nonnull; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; import java.util.LinkedHashMap; +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; +import static org.assertj.core.api.Assertions.assertThatThrownBy; -@ExtendWith(MockitoExtension.class) class CdsServiceRequestJsonDeserializerTest { - @Mock - private CdsServiceRegistryImpl myCdsServiceRegistry; + private static final String SERVICE_ID = "service-id"; + private static final String EXAMPLE_PROPERTY_VALUE = "example-value"; + private static final String EXAMPLE_PROPERTY_KEY = "example-property"; + private static final String HOOK_ID = "hook-id"; private final FhirContext myFhirContext = FhirContext.forR4(); + private final ObjectMapper myObjectMapper = new ObjectMapper(); private CdsServiceRequestJsonDeserializer myFixture; @BeforeEach() void setup() { - myFixture = new CdsServiceRequestJsonDeserializer(myCdsServiceRegistry, myFhirContext); + myFixture = new CdsServiceRequestJsonDeserializer(myFhirContext, myObjectMapper); } @Test - void configureObjectMapper() { + void deserialize_shouldDeserialize_whenValidCdsServiceRequestWithExtensionReceived() { // setup - ObjectMapper input = new ObjectMapper(); + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap extension = withExtension(); + final LinkedHashMap request = withRequest(extension); + request.put("context", withContext()); // execute - myFixture.configureObjectMapper(input); + final CdsServiceRequestJson actual = myFixture.deserialize(cdsServiceJson, request); // validate - assertThat(input.getRegisteredModuleIds()).hasSize(1); + assertThat(actual.getExtension()).isInstanceOf(ExampleExtension.class); + final ExampleExtension actualExtension = (ExampleExtension) actual.getExtension(); + assertThat(actualExtension.getExampleProperty()).isEqualTo(EXAMPLE_PROPERTY_VALUE); } @Test - void deserializeExtensionWhenClassFoundShouldDeserializeExtension() throws JsonProcessingException { + void deserialize_shouldIgnoreExtraFieldsInsideExtension_whenExtensionContainsMoreFieldsThanDefinedInClass() { + // setup + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap extension = withExtension(); + extension.put("example-extra-property", "example-extra-value"); + final LinkedHashMap request = withRequest(extension); + request.put("context", withContext()); + // execute + final CdsServiceRequestJson actual = myFixture.deserialize(cdsServiceJson, request); + // validate + assertThat(actual.getExtension()).isInstanceOf(ExampleExtension.class); + final ExampleExtension actualExtension = (ExampleExtension) actual.getExtension(); + assertThat(actualExtension.getExampleProperty()).isEqualTo(EXAMPLE_PROPERTY_VALUE); + assertThat(actual.getContext().get("encounterId")).isEqualTo("Encounter/123"); + } + + @Nonnull + private static LinkedHashMap withContext() { + final LinkedHashMap context = new LinkedHashMap<>(); + context.put("encounterId", "Encounter/123"); + return context; + } + + @Test + void deserialize_shouldThrow_whenCdsServiceRequestIncludesInvalidProperty() { + // setup + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap extension = withExtension(); + final LinkedHashMap request = withRequest(extension); + request.put("invalid-key", "some-value"); + request.put("context", withContext()); + // execute & validate + assertThatThrownBy( + () -> myFixture.deserialize(cdsServiceJson, request)) + .isInstanceOf(InvalidRequestException.class) + .hasMessageContaining("HAPI-2551:") + .hasMessageContaining("Invalid CdsServiceRequest received."); + } + + @Test + void deserialize_shouldReturnNullExtension_whenNotClassFound() { // setup - final String serviceId = "service-id"; - final String extension = """ - { - "example-property": "example-value" - } - """; final CdsServiceJson cdsServiceJson = new CdsServiceJson(); - cdsServiceJson.setId(serviceId); - cdsServiceJson.setExtensionClass(ExampleExtension.class); - doReturn(cdsServiceJson).when(myCdsServiceRegistry).getCdsServiceJson(serviceId); + cdsServiceJson.setId(SERVICE_ID); + final LinkedHashMap extension = withExtension(); + extension.put("example-extra-property", "example-extra-value"); + final LinkedHashMap request = withRequest(extension); + request.put("context", withContext()); // execute - final ExampleExtension actual = (ExampleExtension) myFixture.deserializeExtension(serviceId, extension); + final CdsServiceRequestJson actual = myFixture.deserialize(cdsServiceJson, request); // validate - assertThat(actual.getExampleProperty()).isEqualTo("example-value"); + assertThat(actual.getExtension()).isNull(); } @Test - void deserializeExtensionWhenClassFoundButExtensionHasExtraPropertiesShouldIgnoreExtraProperties() throws JsonProcessingException { + void deserialize_shouldThrow_whenHookNotFoundInRequest() { // setup - final String serviceId = "service-id"; - final String extension = """ - { - "example-property": "example-value", - "example-extra-property": "example-extra-value" - } - """; - final CdsServiceJson cdsServiceJson = new CdsServiceJson(); - cdsServiceJson.setId(serviceId); - cdsServiceJson.setExtensionClass(ExampleExtension.class); - doReturn(cdsServiceJson).when(myCdsServiceRegistry).getCdsServiceJson(serviceId); - // execute - final ExampleExtension actual = (ExampleExtension) myFixture.deserializeExtension(serviceId, extension); - // validate - assertThat(actual.getExampleProperty()).isEqualTo("example-value"); + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap request = new LinkedHashMap<>(); + request.put("context", withContext()); + request.put("hookInstance", UUID.randomUUID().toString()); + // execute and validate + assertThatThrownBy(() -> myFixture.deserialize(cdsServiceJson, request)) + .isInstanceOf(InvalidRequestException.class) + .hasMessageContaining("HAPI-2549:") + .hasMessageContaining("hook cannot be null for a CdsServiceRequest."); } @Test - void deserializeExtensionWhenNotClassFoundShouldReturnNull() throws JsonProcessingException { + void deserialize_shouldThrow_whenContextNotFoundInRequest() { // setup - final String serviceId = "service-id"; - final String extension = """ - { - "example-property": "example-value" - } - """; - final CdsServiceJson cdsServiceJson = new CdsServiceJson(); - cdsServiceJson.setId(serviceId); - doReturn(cdsServiceJson).when(myCdsServiceRegistry).getCdsServiceJson(serviceId); - // execute - final CdsHooksExtension actual = myFixture.deserializeExtension(serviceId, extension); - // validate - assertThat(actual).isNull(); + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap request = new LinkedHashMap<>(); + request.put("hook", HOOK_ID); + request.put("hookInstance", UUID.randomUUID().toString()); + // execute and validate + assertThatThrownBy(() -> myFixture.deserialize(cdsServiceJson, request)) + .isInstanceOf(InvalidRequestException.class) + .hasMessageContaining("HAPI-2550:") + .hasMessageContaining("context cannot be null for a CdsServiceRequest."); } @Test - void deserializeRequestContextShouldDeserializeValidContext() throws JsonProcessingException { + void deserialize_shouldThrow_whenHookInstanceNotFoundInRequest() { + // setup + final CdsServiceJson cdsServiceJson = withCdsServiceJsonIncludingExtensionClass(); + final LinkedHashMap request = new LinkedHashMap<>(); + request.put("context", withContext()); + request.put("hook", HOOK_ID); + // execute and validate + assertThatThrownBy(() -> myFixture.deserialize(cdsServiceJson, request)) + .isInstanceOf(InvalidRequestException.class) + .hasMessageContaining("HAPI-2548:") + .hasMessageContaining("hookInstance cannot be null for a CdsServiceRequest."); + } + + @Test + void deserializeRequestContext_shouldDeserialize_whenContextIsValid() throws JsonProcessingException { // setup final String encounterId = "123"; final Patient patientContext = new Patient(); @@ -109,9 +155,34 @@ class CdsServiceRequestJsonDeserializerTest { input.put("encounterId", encounterId); input.put("patient", patientContext); // execute - final CdsServiceRequestContextJson actual = myFixture.deserializeRequestContext(input); + final CdsServiceRequestContextJson actual = myFixture.deserializeContext(input); // validate assertThat(actual.get("encounterId")).isEqualTo(encounterId); assertThat(actual.get("patient")).usingRecursiveComparison().isEqualTo(patientContext); } + + @Nonnull + private static LinkedHashMap withExtension() { + final LinkedHashMap extension = new LinkedHashMap<>(); + extension.put(EXAMPLE_PROPERTY_KEY, EXAMPLE_PROPERTY_VALUE); + return extension; + } + + @Nonnull + private static CdsServiceJson withCdsServiceJsonIncludingExtensionClass() { + final CdsServiceJson cdsServiceJson = new CdsServiceJson(); + cdsServiceJson.setId(SERVICE_ID); + cdsServiceJson.setExtensionClass(ExampleExtension.class); + cdsServiceJson.setHook(HOOK_ID); + return cdsServiceJson; + } + + @Nonnull + private static LinkedHashMap withRequest(@Nonnull LinkedHashMap theExtension) { + final LinkedHashMap request = new LinkedHashMap<>(); + request.put("extension", theExtension); + request.put("hookInstance", UUID.randomUUID().toString()); + request.put("hook", HOOK_ID); + return request; + } } diff --git a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImplTest.java b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImplTest.java index 4bb7f699331..3ba49b9f5f6 100644 --- a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImplTest.java +++ b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceRegistryImplTest.java @@ -1,10 +1,10 @@ package ca.uhn.hapi.fhir.cdshooks.svc; import ca.uhn.fhir.context.ConfigurationException; -import ca.uhn.fhir.context.FhirContext; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceFeedbackJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseJson; +import ca.uhn.hapi.fhir.cdshooks.serializer.CdsServiceRequestJsonDeserializer; import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceFactory; import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICrDiscoveryServiceFactory; import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchSvc; @@ -33,13 +33,14 @@ class CdsServiceRegistryImplTest { private ICrDiscoveryServiceFactory myCrDiscoveryServiceFactory; @Mock private CdsServiceCache myCdsServiceCache; + @Mock + private CdsServiceRequestJsonDeserializer myCdsServiceRequestJsonDeserializer; private final ObjectMapper myObjectMapper = new ObjectMapper(); - private final FhirContext myFhirContext = FhirContext.forR4(); private CdsServiceRegistryImpl myFixture; @BeforeEach() void setup() { - myFixture = new CdsServiceRegistryImpl(myCdsHooksContextBooter, myCdsPrefetchSvc, myObjectMapper, myCdsCrServiceFactory, myCrDiscoveryServiceFactory, myFhirContext); + myFixture = new CdsServiceRegistryImpl(myCdsHooksContextBooter, myCdsPrefetchSvc, myObjectMapper, myCdsCrServiceFactory, myCrDiscoveryServiceFactory, myCdsServiceRequestJsonDeserializer); } @Test diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index 5e2b9ee3e05..95abe58fe85 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index 8850b3445eb..89e2600dd02 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 457cd28044c..be0015008a1 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml index cee8e510785..39836ddc8e4 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml index 428f89dc3d4..e8eae8ff086 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml @@ -21,7 +21,7 @@ ca.uhn.hapi.fhir hapi-fhir-caching-api - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml index 8dc3778e4ab..89e57090090 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml index f3a6f30fdc7..1d43c70ed0e 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml @@ -7,7 +7,7 @@ hapi-fhir ca.uhn.hapi.fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../pom.xml diff --git a/hapi-fhir-serviceloaders/pom.xml b/hapi-fhir-serviceloaders/pom.xml index dc407e19ef3..13859f26fee 100644 --- a/hapi-fhir-serviceloaders/pom.xml +++ b/hapi-fhir-serviceloaders/pom.xml @@ -5,7 +5,7 @@ hapi-deployable-pom ca.uhn.hapi.fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index 58fdac09a26..7301924dde5 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index 7a634812925..137bd075790 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index 7fd06fcf3bf..106a0cf80bf 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 1f735d48418..0c2e4ed2f08 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index 62f9c031867..6c62b628f06 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index b65824baf92..52a41c7dc64 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index d7c752647e1..4877a32ed4f 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index 429c1914686..08f9decc2d8 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-jobs/pom.xml b/hapi-fhir-storage-batch2-jobs/pom.xml index 6ad5389cf0f..bcab73f8584 100644 --- a/hapi-fhir-storage-batch2-jobs/pom.xml +++ b/hapi-fhir-storage-batch2-jobs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-test-utilities/pom.xml b/hapi-fhir-storage-batch2-test-utilities/pom.xml index c5433cf41b0..e695c5bed3f 100644 --- a/hapi-fhir-storage-batch2-test-utilities/pom.xml +++ b/hapi-fhir-storage-batch2-test-utilities/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2/pom.xml b/hapi-fhir-storage-batch2/pom.xml index 28434f97f04..682fa7b8e69 100644 --- a/hapi-fhir-storage-batch2/pom.xml +++ b/hapi-fhir-storage-batch2/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-cr/pom.xml b/hapi-fhir-storage-cr/pom.xml index 3cc3d4e2d6c..8d77500f0de 100644 --- a/hapi-fhir-storage-cr/pom.xml +++ b/hapi-fhir-storage-cr/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-mdm/pom.xml b/hapi-fhir-storage-mdm/pom.xml index 6075061dc6a..7f6779287ec 100644 --- a/hapi-fhir-storage-mdm/pom.xml +++ b/hapi-fhir-storage-mdm/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-test-utilities/pom.xml b/hapi-fhir-storage-test-utilities/pom.xml index db16c567f49..2496ea7f0ba 100644 --- a/hapi-fhir-storage-test-utilities/pom.xml +++ b/hapi-fhir-storage-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index b20baf0c3d7..dbf8d1ced1d 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index ad65f33ad54..9b0b6862b32 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index 891eb98b319..718c23b5326 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index cf3ae30aba5..99473d8ea42 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index dc22111adef..c93237fa349 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index 612e2dcfb14..fa613174e8a 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4b/pom.xml b/hapi-fhir-structures-r4b/pom.xml index a810259a2c7..4eb3c7bd63b 100644 --- a/hapi-fhir-structures-r4b/pom.xml +++ b/hapi-fhir-structures-r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index a3c7f077788..10380569b8a 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 23ef56c067d..f29a7f80edc 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 86cb5491962..fca8cd4ec66 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index 39a50f70244..2e4c696ee12 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index 1cd6e7487ec..138e7289d27 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index f50bea30960..e0004b8c837 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index f0c88093297..c6ab551404a 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4b/pom.xml b/hapi-fhir-validation-resources-r4b/pom.xml index 75b31d7a730..325d05648e8 100644 --- a/hapi-fhir-validation-resources-r4b/pom.xml +++ b/hapi-fhir-validation-resources-r4b/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index 97ca30bf0c8..b853d0cc3ab 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index 64edc13bbe8..49d73daa1e0 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index 78c7469c56f..94029265a48 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index c8b8229c4ba..466e9d27784 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index a7cae721347..e6f098ceece 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index ed8ad2356a4..f69c2fd2d79 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 7e5d062d647..991c29eff82 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index 487e1f73df6..4e278702a42 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.5.0-SNAPSHOT + 7.5.1-SNAPSHOT ../../pom.xml From fb93c3d601272a146904e438c11af93f32e70f1e Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Thu, 19 Sep 2024 13:59:58 -0400 Subject: [PATCH 4/4] Expose hapi-fhir-storage-cr config to downstream modules for testing (#6272) * Ensure IRepositoryFactory returns a Repository, and not a HapiFhirRepository. * Rename test so that it will run from Maven and the pipeline since it didn't before. Fix small bug that made the test error out. * Move TestCrConfig and TestCrR4Config to main source folder. Extract TestHapiFhirCrPartitionConfig as separate test config to be used only in the test source folder. Add Maven compile dependency to hapi-fhir-jpaserver-base in order to ensure that moved Config classes will compile. * Add possible code change to RequestDetailsClone to clone partition info. * Introduce separate factory interface for Repository to preserve backward compatibility. * Remove IRepositoryFactoryForInterface. * Spotless * Add javadoc. * Get rid of TODO. * Restore RepositoryConfig to master. * Move test config to different packages. * Leverage use of new RepositoryFactoryForRepositoryInterface for CrR4Config and RepositoryFactoryForRepositoryInterface. * Ensure CrR4Config and RepositoryConfig make use of new RepositoryFactoryForRepositoryInterface. * Add copyright header * Add @FunctionalInterface to factory. --- hapi-fhir-storage-cr/pom.xml | 14 ++++++++ .../fhir/cr/common/IRepositoryFactory.java | 2 ++ ...positoryFactoryForRepositoryInterface.java | 31 +++++++++++++++++ .../uhn/fhir/cr/config/RepositoryConfig.java | 8 +++++ .../ca/uhn/fhir/cr/config/r4/CrR4Config.java | 4 ++- .../cr/config/test}/TestCqlProperties.java | 25 ++++++++++++-- .../fhir/cr/config/test}/TestCrConfig.java | 34 ++++++++++++++----- .../cr/config/test}/r4/TestCrR4Config.java | 28 +++++++++++++-- .../cr/TestHapiFhirCrPartitionConfig.java | 10 ++++++ .../uhn/fhir/cr/dstu3/TestCrDstu3Config.java | 6 ++-- .../ca/uhn/fhir/cr/r4/BaseCrR4TestServer.java | 3 ++ 11 files changed, 149 insertions(+), 16 deletions(-) create mode 100644 hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/RepositoryFactoryForRepositoryInterface.java rename hapi-fhir-storage-cr/src/{test/java/ca/uhn/fhir/cr => main/java/ca/uhn/fhir/cr/config/test}/TestCqlProperties.java (92%) rename hapi-fhir-storage-cr/src/{test/java/ca/uhn/fhir/cr => main/java/ca/uhn/fhir/cr/config/test}/TestCrConfig.java (89%) rename hapi-fhir-storage-cr/src/{test/java/ca/uhn/fhir/cr => main/java/ca/uhn/fhir/cr/config/test}/r4/TestCrR4Config.java (88%) create mode 100644 hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestHapiFhirCrPartitionConfig.java diff --git a/hapi-fhir-storage-cr/pom.xml b/hapi-fhir-storage-cr/pom.xml index 8d77500f0de..775a22c5e41 100644 --- a/hapi-fhir-storage-cr/pom.xml +++ b/hapi-fhir-storage-cr/pom.xml @@ -145,6 +145,20 @@ jakarta.xml.bind-api + + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + ${project.version} + + + + org.glassfish + jakarta.json + + + + org.testcontainers diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/IRepositoryFactory.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/IRepositoryFactory.java index 24963a9cc85..82094e62a6c 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/IRepositoryFactory.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/IRepositoryFactory.java @@ -21,8 +21,10 @@ package ca.uhn.fhir.cr.common; import ca.uhn.fhir.cr.repo.HapiFhirRepository; import ca.uhn.fhir.rest.api.server.RequestDetails; +import com.google.common.annotations.Beta; @FunctionalInterface +@Beta public interface IRepositoryFactory { HapiFhirRepository create(RequestDetails theRequestDetails); } diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/RepositoryFactoryForRepositoryInterface.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/RepositoryFactoryForRepositoryInterface.java new file mode 100644 index 00000000000..a01f5736000 --- /dev/null +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/RepositoryFactoryForRepositoryInterface.java @@ -0,0 +1,31 @@ +/*- + * #%L + * HAPI FHIR - Clinical Reasoning + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.cr.common; + +import ca.uhn.fhir.rest.api.server.RequestDetails; +import org.opencds.cqf.fhir.api.Repository; + +/** + * Factory interface to return a {@link Repository} from a {@link RequestDetails} + */ +@FunctionalInterface +public interface RepositoryFactoryForRepositoryInterface { + Repository create(RequestDetails theRequestDetails); +} diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/RepositoryConfig.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/RepositoryConfig.java index fb40025f58a..93d4c0f58ce 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/RepositoryConfig.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/RepositoryConfig.java @@ -20,6 +20,7 @@ package ca.uhn.fhir.cr.config; import ca.uhn.fhir.cr.common.IRepositoryFactory; +import ca.uhn.fhir.cr.common.RepositoryFactoryForRepositoryInterface; import ca.uhn.fhir.cr.repo.HapiFhirRepository; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.rest.server.RestfulServer; @@ -28,8 +29,15 @@ import org.springframework.context.annotation.Configuration; @Configuration public class RepositoryConfig { + @Bean IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) { return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer); } + + @Bean + RepositoryFactoryForRepositoryInterface repositoryFactoryForInterface( + DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) { + return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer); + } } diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java index 19466eba19b..3cdc398e0c0 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java @@ -22,6 +22,7 @@ package ca.uhn.fhir.cr.config.r4; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.cr.common.IRepositoryFactory; +import ca.uhn.fhir.cr.common.RepositoryFactoryForRepositoryInterface; import ca.uhn.fhir.cr.config.ProviderLoader; import ca.uhn.fhir.cr.config.ProviderSelector; import ca.uhn.fhir.cr.config.RepositoryConfig; @@ -66,7 +67,8 @@ public class CrR4Config { @Bean IMeasureServiceFactory r4MeasureServiceFactory( - IRepositoryFactory theRepositoryFactory, MeasureEvaluationOptions theEvaluationOptions) { + RepositoryFactoryForRepositoryInterface theRepositoryFactory, + MeasureEvaluationOptions theEvaluationOptions) { return rd -> new R4MeasureService(theRepositoryFactory.create(rd), theEvaluationOptions); } diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCqlProperties.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCqlProperties.java similarity index 92% rename from hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCqlProperties.java rename to hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCqlProperties.java index b9c5c081728..1be7c4f3505 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCqlProperties.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCqlProperties.java @@ -1,4 +1,23 @@ -package ca.uhn.fhir.cr; +/*- + * #%L + * HAPI FHIR - Clinical Reasoning + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.cr.config.test; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; @@ -7,7 +26,9 @@ import org.cqframework.cql.cql2elm.LibraryBuilder; import org.opencds.cqf.fhir.cql.CqlEngineOptions; import org.opencds.cqf.fhir.cql.CqlOptions; - +/** + * Common CQL properties shared with downstream modules. + */ public class TestCqlProperties { //cql settings diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCrConfig.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCrConfig.java similarity index 89% rename from hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCrConfig.java rename to hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCrConfig.java index 4f42ae49d52..9a9f43a902f 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestCrConfig.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/TestCrConfig.java @@ -1,4 +1,23 @@ -package ca.uhn.fhir.cr; +/*- + * #%L + * HAPI FHIR - Clinical Reasoning + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.cr.config.test; import ca.uhn.fhir.batch2.jobs.reindex.ReindexProvider; import ca.uhn.fhir.context.FhirContext; @@ -47,6 +66,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +/** + * Common hapi-fhir clinical reasoning config shared with downstream modules. + */ @Configuration @Import({SubscriptionSubmitterConfig.class, SubscriptionChannelConfig.class}) public class TestCrConfig { @@ -77,7 +99,9 @@ public class TestCrConfig { } @Bean public TestCqlProperties testCqlProperties(){ - return new TestCqlProperties();} + return new TestCqlProperties(); + } + @Bean public JpaStorageSettings storageSettings() { JpaStorageSettings storageSettings = new JpaStorageSettings(); @@ -87,12 +111,6 @@ public class TestCrConfig { storageSettings.setResourceClientIdStrategy(JpaStorageSettings.ClientIdStrategyEnum.ANY); return storageSettings; } - - @Bean - public PartitionHelper partitionHelper() { - return new PartitionHelper(); - } - @Bean public ModelManager modelManager(Map theGlobalModelCache) { return new ModelManager(theGlobalModelCache); diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/TestCrR4Config.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/r4/TestCrR4Config.java similarity index 88% rename from hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/TestCrR4Config.java rename to hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/r4/TestCrR4Config.java index e80eab49bc4..9e5b4c50466 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/TestCrR4Config.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/test/r4/TestCrR4Config.java @@ -1,9 +1,28 @@ -package ca.uhn.fhir.cr.r4; +/*- + * #%L + * HAPI FHIR - Clinical Reasoning + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.cr.config.test.r4; -import ca.uhn.fhir.cr.TestCqlProperties; -import ca.uhn.fhir.cr.TestCrConfig; import ca.uhn.fhir.cr.common.CqlThreadFactory; import ca.uhn.fhir.cr.config.r4.CrR4Config; +import ca.uhn.fhir.cr.config.test.TestCqlProperties; +import ca.uhn.fhir.cr.config.test.TestCrConfig; import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.cql2elm.model.Model; @@ -30,6 +49,9 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +/** + * Common hapi-fhir clinical reasoning config specifically for R4 shared with downstream modules. + */ @Configuration @Import({TestCrConfig.class, CrR4Config.class}) public class TestCrR4Config { diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestHapiFhirCrPartitionConfig.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestHapiFhirCrPartitionConfig.java new file mode 100644 index 00000000000..6b95b55deed --- /dev/null +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/TestHapiFhirCrPartitionConfig.java @@ -0,0 +1,10 @@ +package ca.uhn.fhir.cr; + +import org.springframework.context.annotation.Bean; + +public class TestHapiFhirCrPartitionConfig { + @Bean + public PartitionHelper partitionHelper() { + return new PartitionHelper(); + } +} diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/dstu3/TestCrDstu3Config.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/dstu3/TestCrDstu3Config.java index 39fc0b34651..a79d4968627 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/dstu3/TestCrDstu3Config.java +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/dstu3/TestCrDstu3Config.java @@ -1,8 +1,9 @@ package ca.uhn.fhir.cr.dstu3; -import ca.uhn.fhir.cr.TestCqlProperties; -import ca.uhn.fhir.cr.TestCrConfig; +import ca.uhn.fhir.cr.TestHapiFhirCrPartitionConfig; +import ca.uhn.fhir.cr.config.test.TestCqlProperties; import ca.uhn.fhir.cr.config.dstu3.CrDstu3Config; +import ca.uhn.fhir.cr.config.test.TestCrConfig; import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.cql2elm.model.Model; @@ -26,6 +27,7 @@ import java.util.Set; @Configuration @Import({ + TestHapiFhirCrPartitionConfig.class, TestCrConfig.class, CrDstu3Config.class }) diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/BaseCrR4TestServer.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/BaseCrR4TestServer.java index 686681d6352..49e31bad8c6 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/BaseCrR4TestServer.java +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/BaseCrR4TestServer.java @@ -2,10 +2,12 @@ package ca.uhn.fhir.cr.r4; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.cr.IResourceLoader; +import ca.uhn.fhir.cr.TestHapiFhirCrPartitionConfig; import ca.uhn.fhir.cr.config.r4.ApplyOperationConfig; import ca.uhn.fhir.cr.config.r4.ExtractOperationConfig; import ca.uhn.fhir.cr.config.r4.PackageOperationConfig; import ca.uhn.fhir.cr.config.r4.PopulateOperationConfig; +import ca.uhn.fhir.cr.config.test.r4.TestCrR4Config; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; @@ -38,6 +40,7 @@ import java.util.concurrent.TimeUnit; @ContextConfiguration(classes = { + TestHapiFhirCrPartitionConfig.class, TestCrR4Config.class, ApplyOperationConfig.class, ExtractOperationConfig.class,