Valid special cases on contained resources and Bundle entries

This commit is contained in:
Grahame Grieve 2023-09-25 13:50:02 +10:00
parent ac7a7c5a83
commit 194e2113ce
2 changed files with 11 additions and 5 deletions

View File

@ -5608,6 +5608,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
break;
}
}
checkSpecials(hostContext, errors, element, stack, ok, pct, mode);
if (typeForResource.getProfile().size() == 1) {
long t = System.nanoTime();
@ -6665,8 +6667,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
List<Element> performers = new ArrayList<>();
element.getNamedChildren("performer", performers);
ok = bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), performers.size() > 0, I18nConstants.ALL_OBSERVATIONS_SHOULD_HAVE_A_PERFORMER) && ok;
ok = bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null, I18nConstants.ALL_OBSERVATIONS_SHOULD_HAVE_AN_EFFECTIVEDATETIME_OR_AN_EFFECTIVEPERIOD) && ok;
ok = bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(),
element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null ||
element.getNamedChild("effectiveTiming") != null || element.getNamedChild("effectiveInstant") != null,
I18nConstants.ALL_OBSERVATIONS_SHOULD_HAVE_AN_EFFECTIVEDATETIME_OR_AN_EFFECTIVEPERIOD, element.getProperty().typeSummary()) && ok;
return ok;
}

View File

@ -115,14 +115,14 @@ public class BundleValidator extends BaseValidator {
String rtype = entry.getNamedChild(RESOURCE).fhirType();
int rcount = counter.containsKey(rtype) ? counter.get(rtype)+1 : 0;
counter.put(rtype, rcount);
Element res = entry.getNamedChild(RESOURCE);
NodeStack rstack = estack.push(res, -1, null, null);
for (BundleValidationRule bvr : validator().getBundleValidationRules()) {
if (meetsRule(bvr, rtype, rcount, count)) {
StructureDefinition defn = context.fetchResource(StructureDefinition.class, bvr.getProfile());
if (defn == null) {
throw new Error(context.formatMessage(I18nConstants.BUNDLE_RULE_PROFILE_UNKNOWN, bvr.getRule(), bvr.getProfile()));
} else {
Element res = entry.getNamedChild(RESOURCE);
NodeStack rstack = estack.push(res, -1, null, null);
if (validator().isCrumbTrails()) {
res.addMessage(signpost(errors, NO_RULE_DATE, IssueType.INFORMATIONAL, res.line(), res.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM, defn.getUrl()));
}
@ -130,7 +130,9 @@ public class BundleValidator extends BaseValidator {
ok = validator().startInner(hostContext, errors, res, res, defn, rstack, false, pct, mode) && ok;
}
}
}
}
// also, while we're here, check the specials, since this doesn't happen anywhere else
((InstanceValidator) parent).checkSpecials(hostContext, errors, res, rstack, true, pct, mode);
}
// todo: check specials