* fix bug looking for contained resources inside bundles when validating resources using conformsTo()
* fix problems validating canonical reference profile types
This commit is contained in:
parent
2d2000b009
commit
8bb6ebfa31
|
@ -0,0 +1,8 @@
|
||||||
|
## Validator Changes
|
||||||
|
|
||||||
|
* fix bug looking for contained resources inside bundles when validating resources using conformsTo()
|
||||||
|
* fix problems validating canonical reference profile types
|
||||||
|
|
||||||
|
## Other code changes
|
||||||
|
|
||||||
|
n/a
|
|
@ -309,7 +309,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (e.getSpecial() == SpecialElement.CONTAINED) {
|
if (e.getSpecial() == SpecialElement.CONTAINED) {
|
||||||
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e, ctxt.getRootResource(), ctxt.getGroupingResource()), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e, ctxt.getRootResource(), ctxt.getGroupingResource()), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
||||||
} else if (e.getSpecial() != null) {
|
} else if (e.getSpecial() != null) {
|
||||||
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e, ctxt.getRootResource(), ctxt.getRootResource()), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e, e, ctxt.getRootResource()), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
||||||
} else {
|
} else {
|
||||||
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
|
||||||
}
|
}
|
||||||
|
@ -2343,17 +2343,22 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> listExpectedCanonicalTypes(ElementDefinition context) {
|
private Set<String> listExpectedCanonicalTypes(ElementDefinition context) {
|
||||||
List<String> res = new ArrayList<>();
|
Set<String> res = new HashSet<>();
|
||||||
TypeRefComponent tr = context.getType("canonical");
|
TypeRefComponent tr = context.getType("canonical");
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
for (CanonicalType p : tr.getTargetProfile()) {
|
for (CanonicalType p : tr.getTargetProfile()) {
|
||||||
String url = p.getValue();
|
String url = p.getValue();
|
||||||
|
StructureDefinition sd = this.context.fetchResource(StructureDefinition.class, url);
|
||||||
|
if (sd != null) {
|
||||||
|
res.add(sd.getType());
|
||||||
|
} else {
|
||||||
if (url != null && url.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
|
if (url != null && url.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
|
||||||
res.add(url.substring("http://hl7.org/fhir/StructureDefinition/".length()));
|
res.add(url.substring("http://hl7.org/fhir/StructureDefinition/".length()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2375,19 +2380,15 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
private boolean isCorrectCanonicalType(Resource r, CanonicalType p) {
|
private boolean isCorrectCanonicalType(Resource r, CanonicalType p) {
|
||||||
String url = p.getValue();
|
String url = p.getValue();
|
||||||
String t = null;
|
String t = null;
|
||||||
if (url.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
|
|
||||||
t = url.substring("http://hl7.org/fhir/StructureDefinition/".length());
|
|
||||||
} else {
|
|
||||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, url);
|
StructureDefinition sd = context.fetchResource(StructureDefinition.class, url);
|
||||||
if (sd != null) {
|
if (sd != null) {
|
||||||
t = sd.getType();
|
t = sd.getType();
|
||||||
}
|
} else if (url.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
|
||||||
}
|
t = url.substring("http://hl7.org/fhir/StructureDefinition/".length());
|
||||||
if (t == null ) {
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
return Utilities.existsInList(t, "Resource", "CanonicalResource") || t.equals(r.fhirType());
|
return false;
|
||||||
}
|
}
|
||||||
|
return Utilities.existsInList(t, "Resource", "CanonicalResource") || t.equals(r.fhirType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanonicalURLElement(Element e) {
|
private boolean isCanonicalURLElement(Element e) {
|
||||||
|
@ -4616,7 +4617,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
ValidatorHostContext hc = null;
|
ValidatorHostContext hc = null;
|
||||||
if (special == SpecialElement.BUNDLE_ENTRY || special == SpecialElement.BUNDLE_OUTCOME || special == SpecialElement.PARAMETER) {
|
if (special == SpecialElement.BUNDLE_ENTRY || special == SpecialElement.BUNDLE_OUTCOME || special == SpecialElement.PARAMETER) {
|
||||||
resource = element;
|
resource = element;
|
||||||
assert Utilities.existsInList(hostContext.getRootResource().fhirType(), "Bundle", "Parameters");
|
assert Utilities.existsInList(hostContext.getRootResource().fhirType(), "Bundle", "Parameters") : "Resource is "+hostContext.getRootResource().fhirType()+", expected Bundle or Parameters";
|
||||||
hc = hostContext.forEntry(element, hostContext.getRootResource()); // root becomes the grouping resource (should be either bundle or parameters)
|
hc = hostContext.forEntry(element, hostContext.getRootResource()); // root becomes the grouping resource (should be either bundle or parameters)
|
||||||
} else {
|
} else {
|
||||||
hc = hostContext.forContained(element);
|
hc = hostContext.forContained(element);
|
||||||
|
|
Loading…
Reference in New Issue