fix bug copying constraints into Bundle.entry.resource profiles

This commit is contained in:
Grahame Grieve 2024-02-10 20:35:30 +11:00
parent 3a1946e37d
commit 7d4b36a582
1 changed files with 7 additions and 1 deletions

View File

@ -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());