Merge pull request #271 from hapifhir/fix-bundle-rendering

Fix bundle rendering
This commit is contained in:
Grahame Grieve 2020-07-14 08:01:05 +10:00 committed by GitHub
commit a493b8bb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -185,7 +185,7 @@ public class BundleRenderer extends ResourceRenderer {
} }
private void renderResponse(XhtmlNode root, BundleEntryResponseComponent response) { private void renderResponse(XhtmlNode root, BundleEntryResponseComponent response) {
root.para().addText("Request:"); root.para().addText("Response:");
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(response.getStatus()+"\r\n"); b.append(response.getStatus()+"\r\n");
if (response.hasLocation()) if (response.hasLocation())
@ -198,7 +198,7 @@ public class BundleRenderer extends ResourceRenderer {
} }
private void renderRequest(XhtmlNode root, BundleEntryRequestComponent request) { private void renderRequest(XhtmlNode root, BundleEntryRequestComponent request) {
root.para().addText("Response:"); root.para().addText("Request:");
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(request.getMethod()+" "+request.getUrl()+"\r\n"); b.append(request.getMethod()+" "+request.getUrl()+"\r\n");
if (request.hasIfNoneMatch()) if (request.hasIfNoneMatch())

View File

@ -1723,9 +1723,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
checkRatio(errors, path, focus, (Ratio) fixed, fixedSource, pattern); checkRatio(errors, path, focus, (Ratio) fixed, fixedSource, pattern);
else if (fixed instanceof SampledData) else if (fixed instanceof SampledData)
checkSampledData(errors, path, focus, (SampledData) fixed, fixedSource, pattern); checkSampledData(errors, path, focus, (SampledData) fixed, fixedSource, pattern);
else if (fixed instanceof Reference)
checkReference(errors, path, focus, (Reference) fixed, fixedSource, pattern);
else 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<Element> extensions = new ArrayList<Element>(); List<Element> extensions = new ArrayList<Element>();
focus.getNamedChildren("extension", extensions); focus.getNamedChildren("extension", extensions);
if (fixed.getExtension().size() == 0) { 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 // if we == null, we inferred ft from the reference. if we are told to treat this as gospel
TypeRefComponent type = getReferenceTypeRef(container.getType()); TypeRefComponent type = getReferenceTypeRef(container.getType());
Set<String> types = new HashSet<>(); Set<String> types = new HashSet<>();
StructureDefinition sdFT = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+ft);
boolean ok = false;
for (CanonicalType tp : type.getTargetProfile()) { for (CanonicalType tp : type.getTargetProfile()) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, tp.getValue()); StructureDefinition sd = context.fetchResource(StructureDefinition.class, tp.getValue());
if (sd != null) { if (sd != null) {
types.add(sd.getType()); 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) { 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); checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), fixedSource, "data", focus, pattern);
} }
private void checkReference(List<ValidationMessage> 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<ValidationMessage> errors, String path, Element focus, Timing fixed, String fixedSource, boolean pattern) { private void checkTiming(List<ValidationMessage> errors, String path, Element focus, Timing fixed, String fixedSource, boolean pattern) {
checkFixedValue(errors, path + ".repeat", focus.getNamedChild("repeat"), fixed.getRepeat(), fixedSource, "value", focus, pattern); checkFixedValue(errors, path + ".repeat", focus.getNamedChild("repeat"), fixed.getRepeat(), fixedSource, "value", focus, pattern);