test max value set handling.

This commit is contained in:
Grahame Grieve 2019-09-02 11:27:19 +10:00
parent d63a8f7be3
commit 09b74eab50
8 changed files with 133 additions and 0 deletions

View File

@ -139,4 +139,28 @@ public class ValueSetUtilities {
return -1; 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;
}
} }

View File

@ -121,6 +121,7 @@ import org.hl7.fhir.r5.model.TypeDetails;
import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; 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.FHIRLexer.FHIRLexerException;
import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; 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); fr = context.fetchResource(ValueSet.class, reference);
} }
} }
if (fr == null)
fr = ValueSetUtilities.generateImplicitValueSet(reference);
txTime = txTime + (System.nanoTime() - t); txTime = txTime + (System.nanoTime() - t);
return fr; return fr;
} }

View File

@ -854,6 +854,34 @@
"errorCount": 1 "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" : { "bundle-local-refs.xml" : {
"errorCount": 0, "errorCount": 0,
"warningCount": 0 "warningCount": 0

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<url value="http://hl7.org/fhir/StructureDefinition/multi-profile-same-resource-profile"/>
<name value="MaxValueSetProfile"/>
<status value="draft"/>
<description value="Profile with max value Set"/>
<kind value="resource"/>
<abstract value="false"/>
<type value="Observation"/>
<baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/>
<derivation value="constraint"/>
<differential>
<element id="Observation.code">
<path value="Observation.code"/>
<min value="1"/>
<max value="1"/>
<binding>
<strength value="extensible"/>
<valueSet value="http://hl7.org/fhir/ValueSet/clinical-findings"/>
<extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet">
<valueCanonical value="http://snomed.info/sct?fhir_vs"/>
</extension>
</binding>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Observation xmlns="http://hl7.org/fhir">
<status value="final"/>
<code>
<coding>
<system value="http://snomed.info/sct"/>
<code value="109006"/>
<display value="Anxiety disorder of childhood OR adolescence"/>
</coding>
</code>
<subject>
<reference value="Patient/example"/>
</subject>
</Observation>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Observation xmlns="http://hl7.org/fhir">
<status value="final"/>
<code>
<coding>
<system value="http://snomed.info/sct"/>
<code value="106004"/>
<display value="Posterior carpal region"/>
</coding>
</code>
<subject>
<reference value="Patient/example"/>
</subject>
</Observation>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Observation xmlns="http://hl7.org/fhir">
<status value="final"/>
<code>
<text value="Anxiety disorder of childhood OR adolescence"/>
</code>
<subject>
<reference value="Patient/example"/>
</subject>
</Observation>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Observation xmlns="http://hl7.org/fhir">
<status value="final"/>
<code>
<coding>
<system value="http://loinc.org"/>
<code value="29463-7"/>
<display value="Body Weight"/>
</coding>
</code>
<subject>
<reference value="Patient/example"/>
</subject>
</Observation>