more logical tests (test derivation by constraint)

This commit is contained in:
Grahame Grieve 2019-10-18 22:26:29 +11:00
parent ffded29218
commit a74bbc2fb4
7 changed files with 261 additions and 17 deletions

2
.gitignore vendored
View File

@ -298,3 +298,5 @@ local.properties
/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml
/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml
/org.hl7.fhir.r5/src/test/resources/snapshot-generation/t29b-input.xml
/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical1-actual.xml
/org.hl7.fhir.r5/src/test/resources/snapshot-generation/logical2-actual.xml

View File

@ -452,7 +452,8 @@ public class SnapShotGenerationTests {
pu.setIds(test.included, false);
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, test.included.getBaseDefinition());
pu.generateSnapshot(base, test.included, test.included.getUrl(), "http://test.org/profile", test.included.getName());
TestingUtilities.context().cacheResource(test.included);
if (!TestingUtilities.context().hasResource(StructureDefinition.class, test.included.getUrl()))
TestingUtilities.context().cacheResource(test.included);
}
StructureDefinition base = getSD(test.getSource().getBaseDefinition());
if (!base.getUrl().equals(test.getSource().getBaseDefinition()))

View File

@ -136,17 +136,10 @@
<max value="1"/>
</base>
<type>
<code>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type">
<valueString value="string"/>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type">
<valueUrl value="string"/>
</extension>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type">
<valueString value="xsd:string"/>
</extension>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type">
<valueString value="xsd:string"/>
</extension>
</code>
<code value="http://hl7.org/fhirpath/System.String"/>
</type>
<isModifier value="false"/>
<isSummary value="false"/>
@ -180,6 +173,22 @@
<type>
<code value="Extension"/>
</type>
<constraint>
<key value="ele-1"/>
<severity value="error"/>
<human value="All FHIR elements must have a @value or children"/>
<expression value="hasValue() or (children().count() &gt; id.count())"/>
<xpath value="@value|f:*|h:div"/>
<source value="Element"/>
</constraint>
<constraint>
<key value="ext-1"/>
<severity value="error"/>
<human value="Must have either extensions or value[x], not both"/>
<expression value="extension.exists() != value.exists()"/>
<xpath value="exists(f:extension)!=exists(f:*[starts-with(local-name(.), &quot;value&quot;)])"/>
<source value="Extension"/>
</constraint>
<isModifier value="false"/>
<isSummary value="false"/>
<mapping>

View File

@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="ANY"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>Defines the basic properties of every data value. This is an abstract type, meaning that no value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type.</p>
</div>
</text>
<extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace">
<valueUri value="urn:hl7-org:v3"/>
</extension>

View File

@ -0,0 +1,212 @@
<?xml version="1.0" encoding="UTF-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="ANY2"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<table border="0" cellpadding="0" cellspacing="0" style="border: 0px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;">
<tr style="border: 1px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;">
<th style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<a href="nullformats.html#table" title="The logical name of the element">Name</a>
</th>
<th style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<a href="nullformats.html#table" title="Information about the use of the element">Flags</a>
</th>
<th style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<a href="nullformats.html#table" title="Minimum and Maximum # of times the the element can appear in the instance">Card.</a>
</th>
<th style="width: 100px" class="hierarchy">
<a href="nullformats.html#table" title="Reference to the type of the element">Type</a>
</th>
<th style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<a href="nullformats.html#table" title="Additional information about the element">Description &amp; Constraints</a>
<span style="float: right">
<a href="nullformats.html#table" title="Legend for this format">
<img src="nullhelp16.png" alt="doco" style="background-color: inherit"/>
</a>
</span>
</th>
</tr>
<tr style="border: 0px #F0F0F0 solid; padding:0px; vertical-align: top; background-color: white;">
<td style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px; white-space: nowrap; background-image: url(tbl_bck0.png)" class="hierarchy">
<img src="tbl_spacer.png" alt="." style="background-color: inherit" class="hierarchy"/>
<img src="icon_element.gif" alt="." style="background-color: white; background-color: inherit" title="Element" class="hierarchy"/>
<span title="null">nullFlavor</span>
<a name="ANY.nullFlavor"> </a>
</td>
<td style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy"/>
<td style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<span style="opacity: 0.4">0</span>
<span style="opacity: 0.5">..</span>
<span style="opacity: 0.4">1</span>
</td>
<td style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<a style="opacity: 0.4" href="nulldatatypes.html#code">code</a>
</td>
<td style="vertical-align: top; text-align : left; background-color: white; border: 0px #F0F0F0 solid; padding:0px 4px 0px 4px" class="hierarchy">
<span style="font-weight:bold">Fixed Value: </span>
<span style="color: darkgreen">UNK</span>
</td>
</tr>
<tr>
<td colspan="5" class="hierarchy">
<br/>
<a href="nullformats.html#table" title="Legend for this format">
<img src="nullhelp16.png" alt="doco" style="background-color: inherit"/> Documentation for this format
</a>
</td>
</tr>
</table>
</div>
</text>
<extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace">
<valueUri value="urn:hl7-org:v3"/>
</extension>
<url value="http://hl7.org/fhir/cda/StructureDefinition/ANY2"/>
<name value="ANY2"/>
<title value="ANY2 - constraint on ANY to test out making constraints in specializations"/>
<status value="active"/>
<experimental value="false"/>
<publisher value="HL7"/>
<description value="test constraints in specializations"/>
<mapping>
<identity value="rim"/>
<uri value="http://hl7.org/v3"/>
<name value="RIM Mapping"/>
</mapping>
<kind value="logical"/>
<abstract value="true"/>
<type value="ANY"/>
<baseDefinition value="http://hl7.org/fhir/cda/StructureDefinition/ANY"/>
<derivation value="specialization"/>
<snapshot>
<element id="ANY">
<path value="ANY"/>
<short value="Base for all elements"/>
<definition value="Defines the basic properties of every data value. This is an abstract type, meaning that no value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type."/>
<min value="1"/>
<max value="*"/>
<base>
<path value="Element"/>
<min value="0"/>
<max value="*"/>
</base>
<condition value="ele-1"/>
<constraint>
<key value="ele-1"/>
<severity value="error"/>
<human value="All FHIR elements must have a @value or children"/>
<expression value="hasValue() or (children().count() &gt; id.count())"/>
<xpath value="@value|f:*|h:div"/>
<source value="ANY"/>
</constraint>
<isModifier value="false"/>
<mapping>
<identity value="rim"/>
<map value="n/a"/>
</mapping>
</element>
<element id="ANY.id">
<path value="ANY.id"/>
<representation value="xmlAttr"/>
<short value="Unique id for inter-element referencing"/>
<definition value="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces."/>
<min value="0"/>
<max value="1"/>
<base>
<path value="Element.id"/>
<min value="0"/>
<max value="1"/>
</base>
<type>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type">
<valueUrl value="string"/>
</extension>
<code value="http://hl7.org/fhirpath/System.String"/>
</type>
<isModifier value="false"/>
<isSummary value="false"/>
<mapping>
<identity value="rim"/>
<map value="n/a"/>
</mapping>
</element>
<element id="ANY.extension">
<path value="ANY.extension"/>
<slicing>
<discriminator>
<type value="value"/>
<path value="url"/>
</discriminator>
<description value="Extensions are always sliced by (at least) url"/>
<rules value="open"/>
</slicing>
<short value="Additional content defined by implementations"/>
<definition value="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension."/>
<comment value="There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions. The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone."/>
<alias value="extensions"/>
<alias value="user content"/>
<min value="0"/>
<max value="*"/>
<base>
<path value="Element.extension"/>
<min value="0"/>
<max value="*"/>
</base>
<type>
<code value="Extension"/>
</type>
<constraint>
<key value="ele-1"/>
<severity value="error"/>
<human value="All FHIR elements must have a @value or children"/>
<expression value="hasValue() or (children().count() &gt; id.count())"/>
<xpath value="@value|f:*|h:div"/>
<source value="Element"/>
</constraint>
<constraint>
<key value="ext-1"/>
<severity value="error"/>
<human value="Must have either extensions or value[x], not both"/>
<expression value="extension.exists() != value.exists()"/>
<xpath value="exists(f:extension)!=exists(f:*[starts-with(local-name(.), &quot;value&quot;)])"/>
<source value="Extension"/>
</constraint>
<isModifier value="false"/>
<isSummary value="false"/>
<mapping>
<identity value="rim"/>
<map value="n/a"/>
</mapping>
</element>
<element id="ANY.nullFlavor">
<path value="ANY.nullFlavor"/>
<representation value="xmlAttr"/>
<label value="Exceptional Value Detail"/>
<definition value="If a value is an exceptional value (NULL-value), this specifies in what way and why proper information is missing."/>
<min value="0"/>
<max value="1"/>
<base>
<path value="ANY.nullFlavor"/>
<min value="0"/>
<max value="1"/>
</base>
<type>
<code value="code"/>
</type>
<fixedCode value="UNK"/>
<binding>
<strength value="required"/>
<valueSet value="http://terminology.hl7.org/ValueSet/v3-NullFlavor"/>
</binding>
</element>
</snapshot>
<differential>
<element id="ANY.nullFlavor">
<path value="ANY.nullFlavor"/>
<fixedCode value="UNK"/>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="ANY2"/>
<extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace">
<valueUri value="urn:hl7-org:v3"/>
</extension>
<url value="http://hl7.org/fhir/cda/StructureDefinition/ANY2"/>
<name value="ANY2"/>
<title value="ANY2 - constraint on ANY to test out making constraints in specializations"/>
<status value="active"/>
<experimental value="false"/>
<publisher value="HL7"/>
<description value="test constraints in specializations"/>
<kind value="logical"/>
<abstract value="true"/>
<type value="ANY"/>
<baseDefinition value="http://hl7.org/fhir/cda/StructureDefinition/ANY"/>
<derivation value="specialization"/>
<differential>
<element id="ANY.nullFlavor">
<path value="ANY.nullFlavor"/>
<fixedCode value="UNK"/>
</element>
</differential>
</StructureDefinition>

View File

@ -231,4 +231,5 @@
<test gen="true" id="au3"/>
<test gen="true" id="dv1"/>
<test gen="true" id="logical1"/>
<test gen="true" id="logical2" register="logical1-expected"/>
</snapshot-generation-tests>