From 527b2cb35b15bf23285f655615469ea8a707e871 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 27 Sep 2023 05:51:46 +1000 Subject: [PATCH] Fix issue validating CDA FHIR Path constraints --- .../src/main/resources/Messages.properties | 2 +- .../instance/type/StructureDefinitionValidator.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 016b03c75..92a8440e3 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -267,7 +267,7 @@ XHTML_XHTML_Image_Reference_Illegal = Invalid Image Reference in the XHTML (''{0 XHTML_XHTML_NS_InValid = Wrong namespace on the XHTML (''{0}'', should be ''{1}'') XHTML_XHTML_Name_Invalid = Wrong name on the XHTML (''{0}'') - must start with div _DT_Fixed_Wrong = Value is ''{0}'' but must be ''{1}'' -All_observations_should_have_an_effectiveDateTime_or_an_effectivePeriodR4 = Best Practice Recommendation: In general, all observations should have an effective[x] ({0}) +All_observations_should_have_an_effectiveDateTime_or_an_effectivePeriod = Best Practice Recommendation: In general, all observations should have an effective[x] ({0}) All_observations_should_have_a_performer = Best Practice Recommendation: In general, all observations should have a performer All_observations_should_have_a_subject = Best Practice Recommendation: In general, all observations should have a subject Unable_to_resolve_slice_matching__no_fixed_value_or_required_value_set = Unable to resolve slice matching - no fixed value or required value set diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java index e47b294e9..18defe561 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java @@ -604,7 +604,14 @@ public class StructureDefinitionValidator extends BaseValidator { private List getTypesForElement(List elements, Element element, String profileType) { List types = new ArrayList<>(); if (element.hasChild("path") && !element.getNamedChildValue("path").contains(".")) { - types.add(element.getNamedChildValue("path")); + String t = element.getNamedChildValue("path"); + if (profileType.equals(t)) { + types.add(profileType); + } else if (profileType.endsWith("/"+t)) { + types.add(profileType); + } else { + throw new Error("Error: this should not happen: '"+t+"' vs '"+profileType+"'?"); + } } else { for (Element tr : element.getChildrenByName("type")) { String t = tr.getNamedChildValue("code");