From f85012c26337b423da08efc414abea69671c61da Mon Sep 17 00:00:00 2001 From: Lee Surprenant Date: Thu, 27 Jan 2022 14:03:07 -0500 Subject: [PATCH] issue #3192 - omit breaking types from 4.0.1 CapabilityStatement In the current draft of FHIR R4B, the following resource types have backwards-incompatible changes: * DeviceDefinition * Evidence * EvidenceVariable Now these resource types will be omitted from the FHIR 4.0.1 version of our CapabilityStatement (similar to the types that are newly added in R4B). Based on https://chat.fhir.org/#narrow/stream/179166-implementers/topic/R4B.20compatibilty/near/269414612, I left a TODO in the code about whether to remove ActivityDefinition and PlanDefinition from the 4.0.1 flavor of the CapabilityStatement as well. At least for now, they are still advertised and should work for R4 clients just fine (so long as there's no R4B instances that use the new subjectCanonical choice type). Signed-off-by: Lee Surprenant --- .../ibm/fhir/server/resources/Capabilities.java | 16 ++++++++++++---- .../ibm/fhir/server/test/CapabilitiesTest.java | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fhir-server/src/main/java/com/ibm/fhir/server/resources/Capabilities.java b/fhir-server/src/main/java/com/ibm/fhir/server/resources/Capabilities.java index 8e0478d5c22..9cff50b6c57 100644 --- a/fhir-server/src/main/java/com/ibm/fhir/server/resources/Capabilities.java +++ b/fhir-server/src/main/java/com/ibm/fhir/server/resources/Capabilities.java @@ -139,6 +139,14 @@ public class Capabilities extends FHIRResource { R4B_ONLY_RESOURCES.add(ResourceType.Value.SUBSCRIPTION_STATUS); R4B_ONLY_RESOURCES.add(ResourceType.Value.SUBSCRIPTION_TOPIC); R4B_ONLY_RESOURCES.add(ResourceType.Value.SUBSTANCE_DEFINITION); + // The following resource types existed in R4, but have breaking changes in R4B. + // Because we only support the R4B version, we don't want to advertise these in our 4.0.1 statement. + R4B_ONLY_RESOURCES.add(ResourceType.Value.DEVICE_DEFINITION); + R4B_ONLY_RESOURCES.add(ResourceType.Value.EVIDENCE); + R4B_ONLY_RESOURCES.add(ResourceType.Value.EVIDENCE_VARIABLE); + // TODO: make final decision on whether to lump these in with the breaking resources + // R4B_ONLY_RESOURCES.add(ResourceType.Value.PLAN_DEFINITION); + // R4B_ONLY_RESOURCES.add(ResourceType.Value.ACTIVITY_DEFINITION); } // Error Messages @@ -149,7 +157,7 @@ public class Capabilities extends FHIRResource { @Context protected HttpServletRequest httpServletRequest; - + // Constructor public Capabilities() throws Exception { super(); @@ -205,7 +213,7 @@ public Response capabilities(@QueryParam("mode") @DefaultValue("full") String mo /** * Which FHIRVersion to use for the generated CapabilityStatement - * + * * @param acceptHeaderValue * @return 4.3.0 if the client is asking for it, otherwise 4.0.1 */ @@ -386,7 +394,7 @@ private CapabilityStatement buildCapabilityStatement(FHIRVersion fhirVersion) th } com.ibm.fhir.model.type.Boolean isUpdateCreate = com.ibm.fhir.model.type.Boolean.of(isUpdateCreateEnabled()); - + // Build the list of supported resources. List resources = new ArrayList<>(); @@ -676,7 +684,7 @@ private List convertStringList(List stri */ private List getSupportedResourceTypes(PropertyGroup rsrcsGroup, FHIRVersion fhirVersion) throws Exception { final List resourceTypes = new ArrayList<>(); - + if (rsrcsGroup == null) { resourceTypes.addAll(ALL_RESOURCE_TYPES); } else { diff --git a/fhir-server/src/test/java/com/ibm/fhir/server/test/CapabilitiesTest.java b/fhir-server/src/test/java/com/ibm/fhir/server/test/CapabilitiesTest.java index 8a811b9a250..6f6cd7474bb 100644 --- a/fhir-server/src/test/java/com/ibm/fhir/server/test/CapabilitiesTest.java +++ b/fhir-server/src/test/java/com/ibm/fhir/server/test/CapabilitiesTest.java @@ -50,7 +50,7 @@ void testBuildCapabilityStatement_resources_omitted() throws Exception { assertEquals(capabilityStatement.getRest().size(), 1, "Number of REST Elements"); CapabilityStatement.Rest restDefinition = capabilityStatement.getRest().get(0); - assertRestDefinition(restDefinition, 4, 128, 9, 0, 0, 9, 0, 0); + assertRestDefinition(restDefinition, 4, 125, 9, 0, 0, 9, 0, 0); } @Test @@ -65,7 +65,7 @@ void testBuildCapabilityStatement_resources_empty_r4() throws Exception { assertEquals(capabilityStatement.getRest().size(), 1, "Number of REST Elements"); CapabilityStatement.Rest restDefinition = capabilityStatement.getRest().get(0); - assertRestDefinition(restDefinition, 0, 128, 0, 0, 0, 0, 0, 0); + assertRestDefinition(restDefinition, 0, 125, 0, 0, 0, 0, 0, 0); } @Test