diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java index 7c2f818da..21061bb0c 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java @@ -480,6 +480,7 @@ public class VersionUtilities { res.add("ResearchDefinition"); res.add("ResearchElementDefinition"); res.add("SearchParameter"); + res.add("SpecimenDefinition"); res.add("StructureDefinition"); res.add("StructureMap"); res.add("SubscriptionTopic"); @@ -489,11 +490,12 @@ public class VersionUtilities { } if (isR5Ver(version) || "current".equals(version)) { - + res.add("ActorDefinition"); res.add("ActivityDefinition"); res.add("CapabilityStatement"); res.add("ChargeItemDefinition"); res.add("Citation"); + res.add("ClinicalUseDefinition"); res.add("CodeSystem"); res.add("CompartmentDefinition"); res.add("ConceptMap"); @@ -509,12 +511,16 @@ public class VersionUtilities { res.add("Measure"); res.add("MessageDefinition"); res.add("NamingSystem"); + res.add("ObservationDefinition"); res.add("OperationDefinition"); res.add("PlanDefinition"); res.add("Questionnaire"); + res.add("Requirements"); res.add("SearchParameter"); + res.add("SpecimenDefinition"); res.add("StructureDefinition"); res.add("StructureMap"); + res.add("SubscriptionTopic"); res.add("TerminologyCapabilities"); res.add("TestScript"); res.add("ValueSet"); diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index aa4153be1..aa9878fd1 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -30,9 +30,9 @@ Bundle_Document_Date_Missing = A document must have a date (Bundle.timestamp) Bundle_Document_Date_Missing_html = [(type = ''document'') implies (meta.lastUpdated.hasValue())] CapabalityStatement_CS_SP_WrongType = Type mismatch - SearchParameter ''{0}'' type is {1}, but type here is {2} CodeSystem_CS_VS_IncludeDetails = CodeSystem {0} has an ''all system'' value set of {1}, but the include has extra details -CodeSystem_CS_VS_Invalid = CodeSystem {0} has an ''all system'' value set of {1}, but doesn''t have a single include +CodeSystem_CS_VS_Invalid = CodeSystem {0} has an ''all system'' value set of {1}, but the value set doesn''t have a single include CODESYSTEM_CS_VS_EXP_MISMATCH = CodeSystem {0} has an ''all system'' value set of {1}, but it is an expansion with the wrong number of concepts (found {2}, expected {3}) -CodeSystem_CS_VS_WrongSystem = CodeSystem {0} has an ''all system'' value set of {1}, but doesn''t have a matching system ({2}) +CodeSystem_CS_VS_WrongSystem = CodeSystem {0} has an ''all system'' value set of {1}, but the value set doesn''t have a matching system ({2}) Extension_EXTP_Context_Wrong = The extension {0} is not allowed to be used at this point (allowed = {1}; this element is {2}) Extension_EXTM_Context_Wrong = The modifier extension {0} is not allowed to be used at this point (allowed = {1}; this element is {2}) Extension_EXT_Count_Mismatch = Extensions count mismatch: expected {0} but found {1} diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index be782a5de..9dc1fd211 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -2028,10 +2028,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (!ok) { if (definition.hasUserData(XVerExtensionManager.XVER_EXT_MARKER)) { warning(errors, NO_RULE_DATE, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, - modifier ? I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG_XVER : I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG_XVER, extUrl, contexts.toString(), plist.toString()); + modifier ? I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG_XVER : I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG_XVER, extUrl, contexts.toString(), plist.toString()); } else { rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, - modifier ? I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG : I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG, extUrl, contexts.toString(), plist.toString()); + modifier ? I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG : I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG, extUrl, contexts.toString(), plist.toString()); } return false; } else { @@ -4038,7 +4038,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rr.setFocus(res.getMatch()); rr.setExternal(false); rr.setStack(nstack.push(res.getMatch(), res.getIndex(), res.getMatch().getProperty().getDefinition(), res.getMatch().getProperty().getDefinition())); - rr.getStack().qualifyPath(".ofType("+nstack.getElement().fhirType()+")"); + rr.getStack().pathComment(nstack.getElement().fhirType()+"/"+stack.getElement().getIdBase()); return rr; } } @@ -4057,7 +4057,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rr.setFocus(e); rr.setExternal(false); rr.setStack(stack.push(e, -1, e.getProperty().getDefinition(), e.getProperty().getDefinition())); - rr.getStack().qualifyPath(".ofType("+e.fhirType()+")"); + rr.getStack().pathComment(e.fhirType()+"/"+e.getIdBase()); return rr; } e = e.getParentForValidator(); @@ -4089,7 +4089,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rr.setStack(stack.push(res.getEntry(), res.getIndex(), res.getEntry().getProperty().getDefinition(), res.getEntry().getProperty().getDefinition()).push(res.getMatch(), -1, res.getMatch().getProperty().getDefinition(), res.getMatch().getProperty().getDefinition())); - rr.getStack().qualifyPath(".ofType("+rr.getResource().fhirType()+")"); + rr.getStack().pathComment(rr.getResource().fhirType()+"/"+rr.getResource().getIdBase()); return rr; } } @@ -4101,7 +4101,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rr.setFocus(tgt.getElement()); rr.setExternal(false); rr.setStack(tgt); - rr.getStack().qualifyPath(".ofType("+tgt.getElement().fhirType()+")"); + rr.getStack().pathComment(tgt.getElement().fhirType()+"/"+tgt.getElement().getIdBase()); return rr; } } @@ -4123,7 +4123,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rr.setStack(new NodeStack(context, null, rootResource, validationLanguage).push(res.getEntry(), res.getIndex(), res.getEntry().getProperty().getDefinition(), res.getEntry().getProperty().getDefinition()).push(res.getMatch(), -1, res.getMatch().getProperty().getDefinition(), res.getMatch().getProperty().getDefinition())); - rr.getStack().qualifyPath(".ofType("+rr.getResource().fhirType()+")"); + rr.getStack().pathComment(rr.getResource().fhirType()+"/"+rr.getResource().getIdBase()); return rr; } } @@ -5121,7 +5121,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } } - stack.qualifyPath(".ofType("+resourceName+")"); + stack.pathComment(resourceName+"/"+element.getIdBase()); if (typeForResource == null) { ok = rule(errors, NO_RULE_DATE, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), 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 fcdd464dc..ef89b484f 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 @@ -154,6 +154,10 @@ public class StructureDefinitionValidator extends BaseValidator { List types = element.getChildrenByName("type"); Set typeCodes = new HashSet<>(); Set characteristics = new HashSet<>(); + if (!path.contains(".")) { + typeCodes.add(path); // root is type + addCharacteristics(characteristics, path); + } for (Element type : types) { if (hasMustSupportExtension(type)) { @@ -373,7 +377,7 @@ public class StructureDefinitionValidator extends BaseValidator { return tc; } StructureDefinition sd = context.fetchTypeDefinition(tc); - if (sd != null) { + while (sd != null) { if (sd.hasExtension(ToolingExtensions.EXT_BINDING_STYLE)) { return tc; } @@ -382,6 +386,10 @@ public class StructureDefinitionValidator extends BaseValidator { return tc; } } + if (Utilities.existsInList(sd.getType(), "string", "uri", "CodeableConcept", "Quantity", "CodeableReference")) { + return tc; + } + sd = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition()); } } return null; @@ -561,7 +569,7 @@ public class StructureDefinitionValidator extends BaseValidator { } else if (!VersionUtilities.isR5Ver(context.getVersion())) { ok = rule(errors, NO_RULE_DATE, IssueType.EXCEPTION, stack.getLiteralPath(), VersionUtilities.getCanonicalResourceNames(context.getVersion()).contains(t.getType()) || "Resource".equals(t.getType()), I18nConstants.SD_ED_TYPE_PROFILE_WRONG_TARGET, p, t, code, path, "Canonical Resource") && ok; } else { - ok = rule(errors, NO_RULE_DATE, IssueType.EXCEPTION, stack.getLiteralPath(), "CanonicalResource".equals(t.getType()) || VersionUtilities.getCanonicalResourceNames(context.getVersion()).contains(t.getType()), I18nConstants.SD_ED_TYPE_PROFILE_WRONG_TARGET, p, t, code, path, "Canonical Resource") && ok; + ok = rule(errors, NO_RULE_DATE, IssueType.EXCEPTION, stack.getLiteralPath(), Utilities.existsInList(t.getType(), "Resource", "CanonicalResource") || VersionUtilities.getCanonicalResourceNames(context.getVersion()).contains(t.getType()), I18nConstants.SD_ED_TYPE_PROFILE_WRONG_TARGET, p, t, code, path, "Canonical Resource") && ok; } } } else { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/NodeStack.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/NodeStack.java index 21348ee50..ec31324b3 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/NodeStack.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/NodeStack.java @@ -177,8 +177,8 @@ public class NodeStack { return parent; } - public void qualifyPath(String qualifier) { - literalPath = literalPath + qualifier; + public void pathComment(String comment) { + literalPath = literalPath + "/*"+comment+"*/"; } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java index f148b959c..fc727dede 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java @@ -469,6 +469,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe if (fails.size() > 0) { logOutput(""); logOutput("========================================================"); + logOutput("Test: "+name); logOutput(""); for (String s : fails) { logOutput(s); diff --git a/pom.xml b/pom.xml index 65762189b..20f798d51 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 6.2.1 - 1.2.11 + 1.2.12-SNAPSHOT 5.7.1 1.8.2 3.0.0-M5