diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/BundleRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/BundleRenderer.java index 937a9034e..48c0a8c14 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/BundleRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/BundleRenderer.java @@ -185,7 +185,7 @@ public class BundleRenderer extends ResourceRenderer { } private void renderResponse(XhtmlNode root, BundleEntryResponseComponent response) { - root.para().addText("Request:"); + root.para().addText("Response:"); StringBuilder b = new StringBuilder(); b.append(response.getStatus()+"\r\n"); if (response.hasLocation()) @@ -198,7 +198,7 @@ public class BundleRenderer extends ResourceRenderer { } private void renderRequest(XhtmlNode root, BundleEntryRequestComponent request) { - root.para().addText("Response:"); + root.para().addText("Request:"); StringBuilder b = new StringBuilder(); b.append(request.getMethod()+" "+request.getUrl()+"\r\n"); if (request.hasIfNoneMatch()) 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 ee63fb65c..d6fd47102 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 @@ -1723,9 +1723,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat checkRatio(errors, path, focus, (Ratio) fixed, fixedSource, pattern); else if (fixed instanceof SampledData) checkSampledData(errors, path, focus, (SampledData) fixed, fixedSource, pattern); + else if (fixed instanceof Reference) + checkReference(errors, path, focus, (Reference) fixed, fixedSource, pattern); else - rule(errors, IssueType.EXCEPTION, focus.line(), focus.col(), path, false, I18nConstants.INTERNAL_INT_BAD_TYPE, fixed.getClass().getName()); + rule(errors, IssueType.EXCEPTION, focus.line(), focus.col(), path, false, I18nConstants.INTERNAL_INT_BAD_TYPE, fixed.fhirType()); List extensions = new ArrayList(); focus.getNamedChildren("extension", extensions); if (fixed.getExtension().size() == 0) { @@ -2462,13 +2464,23 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat // if we == null, we inferred ft from the reference. if we are told to treat this as gospel TypeRefComponent type = getReferenceTypeRef(container.getType()); Set types = new HashSet<>(); + StructureDefinition sdFT = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+ft); + boolean ok = false; for (CanonicalType tp : type.getTargetProfile()) { StructureDefinition sd = context.fetchResource(StructureDefinition.class, tp.getValue()); if (sd != null) { types.add(sd.getType()); } + StructureDefinition sdF = sdFT; + while (sdF != null) { + if (sdF == sd) { + ok = true; + break; + } + sdF = sdF.hasBaseDefinition() ? context.fetchResource(StructureDefinition.class, sdF.getBaseDefinition()) : null; + } } - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, types.isEmpty() || types.contains(ft), I18nConstants.REFERENCE_REF_BADTARGETTYPE2, ft, ref, types); + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, types.isEmpty() || ok, I18nConstants.REFERENCE_REF_BADTARGETTYPE2, ft, ref, types); } if (pol == ReferenceValidationPolicy.CHECK_VALID) { @@ -2554,6 +2566,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), fixedSource, "data", focus, pattern); } + private void checkReference(List errors, String path, Element focus, Reference fixed, String fixedSource, boolean pattern) { + checkFixedValue(errors, path + ".reference", focus.getNamedChild("reference"), fixed.getReferenceElement_(), fixedSource, "reference", focus, pattern); + checkFixedValue(errors, path + ".type", focus.getNamedChild("type"), fixed.getTypeElement(), fixedSource, "type", focus, pattern); + checkFixedValue(errors, path + ".identifier", focus.getNamedChild("identifier"), fixed.getIdentifier(), fixedSource, "identifier", focus, pattern); + checkFixedValue(errors, path + ".display", focus.getNamedChild("display"), fixed.getDisplayElement(), fixedSource, "display", focus, pattern); + } + private void checkTiming(List errors, String path, Element focus, Timing fixed, String fixedSource, boolean pattern) { checkFixedValue(errors, path + ".repeat", focus.getNamedChild("repeat"), fixed.getRepeat(), fixedSource, "value", focus, pattern);