FHIR QA driven changes

This commit is contained in:
Grahame Grieve 2023-02-12 17:53:41 +11:00
parent bd424e7b60
commit 3a427385c5
6 changed files with 30 additions and 15 deletions

View File

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

View File

@ -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}

View File

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

View File

@ -154,6 +154,10 @@ public class StructureDefinitionValidator extends BaseValidator {
List<Element> types = element.getChildrenByName("type");
Set<String> typeCodes = new HashSet<>();
Set<String> 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 {

View File

@ -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+"*/";
}

View File

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