From 0dad5ac58e8bf255ba327fab30bbb574611a4591 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 9 Apr 2019 14:24:05 +1000 Subject: [PATCH] validation related updates for IG publication --- .../convertors/VersionConvertor_30_50.java | 46 ++++++++++++++----- .../fhir/r5/validation/InstanceValidator.java | 3 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java index ef3866270..43a94a6a3 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java @@ -2915,27 +2915,51 @@ public class VersionConvertor_30_50 { throw new FHIRException("Unknown type "+src.fhirType()); } - private static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { + private static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { copyResource(src, tgt); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) - tgt.addExtension(convertExtension(t2)); - for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) - tgt.addModifierExtension(convertExtension(t3)); + for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) { + boolean ok = true; + for (String s : extensionsToIgnore) + if (s.equals(t2.getUrl())) + ok = false; + if (ok) + tgt.addExtension(convertExtension(t2)); + } + for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) { + boolean ok = true; + for (String s : extensionsToIgnore) + if (s.equals(t3.getUrl())) + ok = false; + if (ok) + tgt.addModifierExtension(convertExtension(t3)); + } } - private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { + private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { copyResource(src, tgt); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r5.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) - tgt.addExtension(convertExtension(t2)); - for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) + for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) { + boolean ok = true; + for (String s : extensionsToIgnore) + if (s.equals(t2.getUrl())) + ok = false; + if (ok) + tgt.addExtension(convertExtension(t2)); + } + for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { + boolean ok = true; + for (String s : extensionsToIgnore) + if (s.equals(t3.getUrl())) + ok = false; + if (ok) tgt.addModifierExtension(convertExtension(t3)); + } } public static org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException { if (src == null) @@ -19794,7 +19818,7 @@ public class VersionConvertor_30_50 { if (src == null) return null; org.hl7.fhir.r5.model.ValueSet tgt = new org.hl7.fhir.r5.model.ValueSet(); - copyDomainResource(src, tgt); + copyDomainResource(src, tgt, "http://hl7.org/fhir/StructureDefinition/valueset-extensible"); if (src.hasUrl()) tgt.setUrl(src.getUrl()); for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) @@ -19840,7 +19864,7 @@ public class VersionConvertor_30_50 { if (src == null) return null; org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet(); - copyDomainResource(src, tgt); + copyDomainResource(src, tgt, "http://hl7.org/fhir/StructureDefinition/valueset-extensible"); if (src.hasUrl()) tgt.setUrl(src.getUrl()); for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index b1624d690..3836bc0ad 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -1467,7 +1467,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat // now, do we check the URI target? if (fetcher != null) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, fetcher.resolveURL(appContext, path, e.primitiveValue()), "URL value '"+e.primitiveValue()+"' does not resolve"); + boolean found = fetcher.resolveURL(appContext, path, e.primitiveValue()); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, found, "URL value '"+e.primitiveValue()+"' does not resolve"); } } if (type.equals("id")) {