From 7d4b36a5828ea6045eb8918587536eacc2feb7a8 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 10 Feb 2024 20:35:30 +1100 Subject: [PATCH] fix bug copying constraints into Bundle.entry.resource profiles --- .../fhir/r5/conformance/profile/ProfilePathProcessor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java index 245d74bd8..b1beffb67 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java @@ -16,6 +16,7 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent import org.hl7.fhir.r5.model.ElementDefinition.SlicingRules; import org.hl7.fhir.r5.model.OperationOutcome.IssueType; import org.hl7.fhir.r5.model.StructureDefinition; +import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.utilities.Utilities; @@ -621,7 +622,12 @@ public class ProfilePathProcessor { if (firstTypeStructureDefinition.getSnapshot().getElement().isEmpty()) { throw new FHIRException(profileUtilities.getContext().formatMessage(I18nConstants.SNAPSHOT_IS_EMPTY, firstTypeStructureDefinition.getVersionedUrl(), "Source for first element")); } else { - src = firstTypeStructureDefinition.getSnapshot().getElement().get(0); + src = firstTypeStructureDefinition.getSnapshot().getElement().get(0).copy(); + if (!src.getPath().contains(".") && firstTypeStructureDefinition.getKind() == StructureDefinitionKind.RESOURCE) { + // we can't migrate the constraints in this case, because the sense of %resource changes when the root resource + // is treated as an element. The validator will enforce the constraint + src.getConstraint().clear(); // + } } } template = src.copy().setPath(currentBase.getPath());