From 09b74eab505e2917032afbb91a5e9531be17c5c1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 2 Sep 2019 11:27:19 +1000 Subject: [PATCH] test max value set handling. --- .../r5/terminologies/ValueSetUtilities.java | 24 ++++++++++++++++ .../fhir/r5/validation/InstanceValidator.java | 3 ++ .../validation-examples/manifest.json | 28 +++++++++++++++++++ .../maxvalueset-profile.xml | 26 +++++++++++++++++ .../observation-maxvs-base.xml | 14 ++++++++++ .../observation-maxvs-ex.xml | 14 ++++++++++ .../observation-maxvs-text.xml | 10 +++++++ .../observation-maxvs-wrong.xml | 14 ++++++++++ 8 files changed, 133 insertions(+) create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/maxvalueset-profile.xml create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-base.xml create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-ex.xml create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-text.xml create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-wrong.xml diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java index ac24b75f6..85d30c069 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java @@ -139,4 +139,28 @@ public class ValueSetUtilities { return -1; } + public static ValueSet generateImplicitValueSet(String uri) { + if (uri.startsWith("http://snomed.info/sct")) + return generateImplicitSnomedValueSet(uri); + return null; + } + + private static ValueSet generateImplicitSnomedValueSet(String uri) { + if ("http://snomed.info/sct?fhir_vs".equals(uri)) + return makeImplicitSnomedValueSet(uri); + return null; + } + + private static ValueSet makeImplicitSnomedValueSet(String uri) { + ValueSet vs = new ValueSet(); + vs.setUrl(uri); + vs.setName("SCTValueSet"); + vs.setTitle("SCT ValueSet"); + vs.setDescription("All SNOMED CT Concepts"); + vs.setCopyright("This value set includes content from SNOMED CT, which is copyright © 2002+ International Health Terminology Standards Development Organisation (SNOMED International), and distributed by agreement between SNOMED International and HL7. Implementer use of SNOMED CT is not covered by this agreement"); + vs.setStatus(PublicationStatus.ACTIVE); + vs.getCompose().addInclude().setSystem("http://snomed.info/sct"); + return vs; + } + } 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 30e41b786..be46593b9 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 @@ -121,6 +121,7 @@ import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.terminologies.ValueSetUtilities; import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException; import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; @@ -2554,6 +2555,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat fr = context.fetchResource(ValueSet.class, reference); } } + if (fr == null) + fr = ValueSetUtilities.generateImplicitValueSet(reference); txTime = txTime + (System.nanoTime() - t); return fr; } diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json index b4eeb21eb..6768327e0 100644 --- a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json @@ -854,6 +854,34 @@ "errorCount": 1 } }, + "observation-maxvs-base.xml": { + "errorCount": 0, + "profile": { + "source": "maxvalueset-profile.xml", + "errorCount": 0 + } + }, + "observation-maxvs-ex.xml": { + "errorCount": 0, + "profile": { + "source": "maxvalueset-profile.xml", + "errorCount": 0 + } + }, + "observation-maxvs-text.xml": { + "errorCount": 0, + "profile": { + "source": "maxvalueset-profile.xml", + "errorCount": 0 + } + }, + "observation-maxvs-wrong.xml": { + "errorCount": 0, + "profile": { + "source": "maxvalueset-profile.xml", + "errorCount": 1 + } + }, "bundle-local-refs.xml" : { "errorCount": 0, "warningCount": 0 diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/maxvalueset-profile.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/maxvalueset-profile.xml new file mode 100644 index 000000000..cdf7258f8 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/maxvalueset-profile.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-base.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-base.xml new file mode 100644 index 000000000..dce49fd79 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-base.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-ex.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-ex.xml new file mode 100644 index 000000000..2654340a5 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-ex.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-text.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-text.xml new file mode 100644 index 000000000..882a2851a --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-text.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-wrong.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-wrong.xml new file mode 100644 index 000000000..83209001a --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/observation-maxvs-wrong.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file