Repository: FHIR/sushi
Pull request #423 (2020-05-12 18:10:44)

Rules can be set on children of choice elements
Completes task [CIMPL-363](https://standardhealthrecord.atlassian.net/browse/CIMPL-363)

Every type available on a given choice element will have some common ancestor, so any elements of that ancestor should be allowed in the path for a rule. Therefore, when a choice element is encountered on a rule path, allow it to be unfolded to gain access to any elements that are guaranteed to exist.

All types share `Element` as an ancestor, but it's possible that a more specific type is a common ancestor of all the choices. This can give access to additional paths.

mint-thompson: The tests are working on my machine, but they're not working here, so I will investigate why.

Patch:
diff --git a/src/fhirtypes/ElementDefinition.ts b/src/fhirtypes/ElementDefinition.ts
index bdab058..f674d2f 100644
--- a/src/fhirtypes/ElementDefinition.ts
+++ b/src/fhirtypes/ElementDefinition.ts
@@ -1,4 +1,4 @@
-import { isEmpty, isEqual, isMatch, cloneDeep, upperFirst } from 'lodash';
+import { isEmpty, isEqual, isMatch, cloneDeep, upperFirst, intersectionWith } from 'lodash';
 import sax = require('sax');
 import { minify } from 'html-minifier';
 import { isUri } from 'valid-url';
@@ -1614,6 +1614,44 @@ export class ElementDefinition {
     return [];
   }
 
+  /**
+   * Unfolds a choice element's typed choices. The elements added to this element's
+   * structure definition are those that are on the common ancestor of the available types.
+   * All types have a common ancestor of Element, so if all else fails, Element's
+   * elements are used.
+   *
+   * @param {Fishable} fisher - A fishable implementation for finding definitions and metadata
+   */
+  unfoldChoiceElementTypes(fisher: Fishable): ElementDefinition[] {
+    const allTypes: string[] = [];
+    this.type.forEach(t => {
+      if (t.profile?.length) {
+        allTypes.push(...t.profile);
+      } else {
+        allTypes.push(t.code);
+      }
+    });
+    const allTypeAncestry = allTypes.map(t => this.getTypeLineage(t, fisher).map(l => l.url));
+    const sharedAncestry = intersectionWith(...allTypeAncestry);
+    if (sharedAncestry.length > 0) {
+      const commonAncestor = StructureDefinition.fromJSON(fisher.fishForFHIR(sharedAncestry[0]));
+      const newElements = commonAncestor.elements.slice(1).map(e => {
+        const eClone = e.clone();
+        eClone.id = eClone.id.replace(commonAncestor.type, `${this.id}`);
+        eClone.structDef = this.structDef;
+        // Capture the original so that diffs only show what changed *after* unfolding
+        eClone.captureOriginal();
+        return eClone;
+      });
+      this.structDef.addElements(newElements);
+      return newElements;
+    } else {
+      // this should not be reachable if the rest of the software is working correctly
+      logger.error(`Could not unfold choice element ${this.id}: choices have no common ancestor.`);
+    }
+    return [];
+  }
+
   /**
    * Sets up slicings on an element by adding or modifying the element's `slicing`.  If a matching slicing discriminator
    * already exists, it will be used
diff --git a/src/fhirtypes/StructureDefinition.ts b/src/fhirtypes/StructureDefinition.ts
index 2b4f84c..df39e97 100644
--- a/src/fhirtypes/StructureDefinition.ts
+++ b/src/fhirtypes/StructureDefinition.ts
@@ -214,6 +214,9 @@ export class StructureDefinition {
         if (unfoldedElements.length > 0) {
           // Only get the children that match our path
           newMatchingElements = unfoldedElements.filter(e => e.path.startsWith(fhirPathString));
+        } else if (matchingElements[0].id.endsWith('[x]')) {
+          unfoldedElements = matchingElements[0].unfoldChoiceElementTypes(fisher);
+          newMatchingElements = unfoldedElements.filter(e => e.path.startsWith(fhirPathString));
         }
       }
 


Test patch:
diff --git a/test/export/StructureDefinitionExporter.test.ts b/test/export/StructureDefinitionExporter.test.ts
index 19979aa..a2e63c3 100644
--- a/test/export/StructureDefinitionExporter.test.ts
+++ b/test/export/StructureDefinitionExporter.test.ts
@@ -408,6 +408,20 @@ describe('StructureDefinitionExporter', () => {
     expect(loggerSpy.getLastMessage()).toMatch(/File: Foo\.fsh.*Line: 3 - 4\D*/s);
   });
 
+  it('should emit an error and continue when the path for the child of a choice element is not found', () => {
+    const profile = new Profile('Foo');
+    const rule = new FixedValueRule('value[x].comparator')
+      .withFile('Foo.fsh')
+      .withLocation([4, 7, 4, 22]);
+    rule.fixedValue = new FshCode('>=');
+    profile.rules.push(rule);
+    exporter.exportStructDef(profile);
+    const structDef = pkg.profiles[0];
+    expect(structDef).toBeDefined();
+    expect(structDef.type).toBe('Resource');
+    expect(loggerSpy.getLastMessage('error')).toMatch(/File: Foo\.fsh.*Line: 4\D*/s);
+  });
+
   // Card Rule
   it('should apply a correct card rule', () => {
     const profile = new Profile('Foo');
@@ -1464,6 +1478,79 @@ describe('StructureDefinitionExporter', () => {
     ]);
   });
 
+  it('should apply a fixedValueRule on the child of a choice element with constrained choices that share a type', () => {
+    // Quantity is the first ancestor of Duration and Age
+
+    // * value[x] only Duration or Age
+    // * value[x].comparator = #>=
+
+    const profile = new Profile('QuantifiedObservation');
+    profile.parent = 'Observation';
+
+    const onlyRule = new OnlyRule('value[x]');
+    onlyRule.types = [{ type: 'Duration' }, { type: 'Age' }];
+    profile.rules.push(onlyRule);
+
+    const fixedValueRule = new FixedValueRule('value[x].comparator');
+    fixedValueRule.fixedValue = new FshCode('>=');
+    profile.rules.push(fixedValueRule);
+
+    exporter.exportStructDef(profile);
+    const sd = pkg.profiles[0];
+    const fixedElement = sd.findElement('Observation.value[x].comparator');
+    expect(fixedElement.patternCode).toBe('>=');
+  });
+
+  it('should apply a fixedValueRule on the child of a choice element with constrained choices that share a profile', () => {
+    // Profile: CustomizedTiming
+    // Parent: Timing
+    // * extension contains customField 0..1
+    const customizedTiming = new Profile('CustomizedTiming');
+    customizedTiming.parent = 'Timing';
+    const containsRule = new ContainsRule('extension');
+    containsRule.items = [{ name: 'customField' }];
+    const cardRule = new CardRule('extension[customField]');
+    cardRule.min = 0;
+    cardRule.max = '1';
+    customizedTiming.rules.push(containsRule, cardRule);
+    doc.profiles.set(customizedTiming.name, customizedTiming);
+
+    // Profile: VerifiedTiming
+    // Parent: CustomizedTiming
+    const verifiedTiming = new Profile('VerifiedTiming');
+    verifiedTiming.parent = customizedTiming.name;
+    doc.profiles.set(verifiedTiming.name, verifiedTiming);
+
+    // Profile: ConsensusTiming
+    // Parent: CustomizedTiming
+    const consensusTiming = new Profile('ConsensusTiming');
+    consensusTiming.parent = customizedTiming.name;
+    doc.profiles.set(consensusTiming.name, consensusTiming);
+
+    // Profile: SpecialTimingObservation
+    // Parent: Observation
+    // * effective[x] only VerifiedTiming or ConsensusTiming
+    // * effective[x].extension[customField].id = my-special-id
+    const specialTimingObservation = new Profile('SpecialTimingObservation');
+    specialTimingObservation.parent = 'Observation';
+    const onlyRule = new OnlyRule('effective[x]');
+    onlyRule.types = [{ type: 'VerifiedTiming' }, { type: 'ConsensusTiming' }];
+    const fixedValueRule = new FixedValueRule('effective[x].extension[customField].id');
+    fixedValueRule.fixedValue = 'my-special-id';
+    specialTimingObservation.rules.push(onlyRule, fixedValueRule);
+    doc.profiles.set(specialTimingObservation.name, specialTimingObservation);
+
+    exporter.exportStructDef(specialTimingObservation);
+    const specialTimingObservationSd = pkg.profiles.find(
+      resource => resource.id === 'SpecialTimingObservation'
+    );
+    expect(specialTimingObservationSd).toBeDefined();
+    const fixedId = specialTimingObservationSd.findElement(
+      'Observation.effective[x].extension:customField.id'
+    );
+    expect(fixedId.patternString).toBe('my-special-id');
+  });
+
   it('should not apply an incorrect FixedValueRule', () => {
     const profile = new Profile('Foo');
     profile.parent = 'Observation';
@@ -1734,6 +1821,34 @@ describe('StructureDefinitionExporter', () => {
     expect(fooSlice).toBeDefined();
   });
 
+  it('should apply a containsRule on the child of a choice element with a common ancestor of Element', () => {
+    // Element contains extension and id
+    // * value[x].extension contains my-inline-extension 0..1
+
+    const profile = new Profile('Foo');
+    profile.parent = 'Observation';
+
+    const containsRule = new ContainsRule('value[x].extension');
+    containsRule.items = [{ name: 'my-inline-extension' }];
+    profile.rules.push(containsRule);
+
+    exporter.exportStructDef(profile);
+    const sd = pkg.profiles[0];
+    const extension = sd.elements.find(e => e.id === 'Observation.value[x].extension');
+    const extensionSlice = sd.elements.find(
+      e => e.id === 'Observation.value[x].extension:my-inline-extension'
+    );
+    const extensionSliceUrl = sd.elements.find(
+      e => e.id === 'Observation.value[x].extension:my-inline-extension.url'
+    );
+
+    expect(extension.slicing).toBeDefined();
+    expect(extension.slicing.discriminator.length).toBe(1);
+    expect(extension.slicing.discriminator[0]).toEqual({ type: 'value', path: 'url' });
+    expect(extensionSlice).toBeDefined();
+    expect(extensionSliceUrl).toBeDefined();
+    expect(extensionSliceUrl.fixedUri).toBe('my-inline-extension');
+  });
   it('should report an error and not add the slice when a ContainsRule tries to add a slice that already exists', () => {
     // Profile: DoubleSlice
     // Parent: resprate
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-Age.json b/test/testhelpers/testdefs/package/StructureDefinition-Age.json
new file mode 100644
index 0000000..7bde896
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-Age.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"Age","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"url":"http://hl7.org/fhir/StructureDefinition/Age","version":"4.0.1","name":"Age","status":"draft","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for Age Type: A duration of time during which an organism (or a process) has existed.","fhirVersion":"4.0.1","mapping":[{"identity":"rim","uri":"http://hl7.org/v3","name":"RIM Mapping"},{"identity":"v2","uri":"http://hl7.org/v2","name":"HL7 v2 Mapping"}],"kind":"complex-type","abstract":false,"type":"Age","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Quantity","derivation":"specialization","snapshot":{"element":[{"id":"Age","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"path":"Age","short":"A duration of time during which an organism (or a process) has existed","definition":"A duration of time during which an organism (or a process) has existed.","comment":"The context of use may frequently define what kind of quantity this is and therefore what kind of units can be used. The context of use may also restrict the values for the comparator.","min":0,"max":"*","base":{"path":"Age","min":0,"max":"*"},"constraint":[{"key":"age-1","severity":"error","human":"There SHALL be a code if there is a value and it SHALL be an expression of time.  If system is present, it SHALL be UCUM.  If value is present, it SHALL be positive.","expression":"(code.exists() or value.empty()) and (system.empty() or system = %ucum) and (value.empty() or value.hasValue().not() or value > 0)","xpath":"(f:code or not(f:value)) and (not(exists(f:system)) or f:system/@value='http://unitsofmeasure.org') and (not(f:value/@value) or f:value/@value >=0)"},{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"qty-3","severity":"error","human":"If a code for the unit is present, the system SHALL also be present","expression":"code.empty() or system.exists()","xpath":"not(exists(f:code)) or exists(f:system)","source":"http://hl7.org/fhir/StructureDefinition/Quantity"}],"isModifier":false,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet","valueCanonical":"http://hl7.org/fhir/ValueSet/all-time-units"},{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"AgeUnits"}],"strength":"extensible","description":"Appropriate units for Age.","valueSet":"http://hl7.org/fhir/ValueSet/age-units"},"mapping":[{"identity":"v2","map":"SN (see also Range) or CQ"},{"identity":"rim","map":"PQ, IVL<PQ>, MO, CO, depending on the values"},{"identity":"rim","map":"PQ"}]},{"id":"Age.id","path":"Age.id","representation":["xmlAttr"],"short":"Unique id for inter-element referencing","definition":"Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Age.extension","path":"Age.extension","slicing":{"discriminator":[{"type":"value","path":"url"}],"description":"Extensions are always sliced by (at least) url","rules":"open"},"short":"Additional content defined by implementations","definition":"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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Age.value","path":"Age.value","short":"Numerical value (with implicit precision)","definition":"The value of the measured amount. The value includes an implicit precision in the presentation of the value.","comment":"The implicit precision in the value should always be honored. Monetary values have their own rules for handling precision (refer to standard accounting text books).","requirements":"Precision is handled implicitly in almost all cases of measurement.","min":0,"max":"1","base":{"path":"Quantity.value","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"SN.2  / CQ - N/A"},{"identity":"rim","map":"PQ.value, CO.value, MO.value, IVL.high or IVL.low depending on the value"}]},{"id":"Age.comparator","path":"Age.comparator","short":"< | <= | >= | > - how to understand the value","definition":"How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value.","requirements":"Need a framework for handling measures where the value is <5ug/L or >400mg/L due to the limitations of measuring methodology.","min":0,"max":"1","base":{"path":"Quantity.comparator","min":0,"max":"1"},"type":[{"code":"code"}],"meaningWhenMissing":"If there is no comparator, then there is no modification of the value","constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":true,"isModifierReason":"This is labeled as \"Is Modifier\" because the comparator modifies the interpretation of the value significantly. If there is no comparator, then there is no modification of the value","isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"QuantityComparator"}],"strength":"required","description":"How the Quantity should be understood and represented.","valueSet":"http://hl7.org/fhir/ValueSet/quantity-comparator|4.0.1"},"mapping":[{"identity":"v2","map":"SN.1  / CQ.1"},{"identity":"rim","map":"IVL properties"}]},{"id":"Age.unit","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable","valueBoolean":true}],"path":"Age.unit","short":"Unit representation","definition":"A human-readable form of the unit.","requirements":"There are many representations for units of measure and in many contexts, particular representations are fixed and required. I.e. mcg for micrograms.","min":0,"max":"1","base":{"path":"Quantity.unit","min":0,"max":"1"},"type":[{"code":"string"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"PQ.unit"}]},{"id":"Age.system","path":"Age.system","short":"System that defines coded unit form","definition":"The identification of the system that provides the coded form of the unit.","requirements":"Need to know the system that defines the coded form of the unit.","min":0,"max":"1","base":{"path":"Quantity.system","min":0,"max":"1"},"type":[{"code":"uri"}],"condition":["qty-3"],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"CO.codeSystem, PQ.translation.codeSystem"}]},{"id":"Age.code","path":"Age.code","short":"Coded form of the unit","definition":"A computer processable form of the unit in some unit representation system.","comment":"The preferred system is UCUM, but SNOMED CT can also be used (for customary units) or ISO 4217 for currency.  The context of use may additionally require a code from a particular system.","requirements":"Need a computable form of the unit that is fixed across all forms. UCUM provides this for quantities, but SNOMED CT provides many units of interest.","min":0,"max":"1","base":{"path":"Quantity.code","min":0,"max":"1"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"PQ.code, MO.currency, PQ.translation.code"}]}]},"differential":{"element":[{"id":"Age","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"path":"Age","short":"A duration of time during which an organism (or a process) has existed","definition":"A duration of time during which an organism (or a process) has existed.","min":0,"max":"*","constraint":[{"key":"age-1","severity":"error","human":"There SHALL be a code if there is a value and it SHALL be an expression of time.  If system is present, it SHALL be UCUM.  If value is present, it SHALL be positive.","expression":"(code.exists() or value.empty()) and (system.empty() or system = %ucum) and (value.empty() or value.hasValue().not() or value > 0)","xpath":"(f:code or not(f:value)) and (not(exists(f:system)) or f:system/@value='http://unitsofmeasure.org') and (not(f:value/@value) or f:value/@value >=0)"}],"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet","valueCanonical":"http://hl7.org/fhir/ValueSet/all-time-units"},{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"AgeUnits"}],"strength":"extensible","description":"Appropriate units for Age.","valueSet":"http://hl7.org/fhir/ValueSet/age-units"},"mapping":[{"identity":"rim","map":"PQ"}]}]}}
\ No newline at end of file
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-Duration.json b/test/testhelpers/testdefs/package/StructureDefinition-Duration.json
new file mode 100644
index 0000000..2e0a180
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-Duration.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"Duration","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"url":"http://hl7.org/fhir/StructureDefinition/Duration","version":"4.0.1","name":"Duration","status":"active","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for Duration Type: A length of time.","fhirVersion":"4.0.1","mapping":[{"identity":"rim","uri":"http://hl7.org/v3","name":"RIM Mapping"},{"identity":"v2","uri":"http://hl7.org/v2","name":"HL7 v2 Mapping"}],"kind":"complex-type","abstract":false,"type":"Duration","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Quantity","derivation":"specialization","snapshot":{"element":[{"id":"Duration","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"path":"Duration","short":"A length of time","definition":"A length of time.","comment":"The context of use may frequently define what kind of quantity this is and therefore what kind of units can be used. The context of use may also restrict the values for the comparator.","min":0,"max":"*","base":{"path":"Duration","min":0,"max":"*"},"constraint":[{"key":"drt-1","severity":"error","human":"There SHALL be a code if there is a value and it SHALL be an expression of time.  If system is present, it SHALL be UCUM.","expression":"code.exists() implies ((system = %ucum) and value.exists())","xpath":"(f:code or not(f:value)) and (not(exists(f:system)) or f:system/@value='http://unitsofmeasure.org')"},{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"qty-3","severity":"error","human":"If a code for the unit is present, the system SHALL also be present","expression":"code.empty() or system.exists()","xpath":"not(exists(f:code)) or exists(f:system)","source":"http://hl7.org/fhir/StructureDefinition/Quantity"}],"isModifier":false,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet","valueCanonical":"http://hl7.org/fhir/ValueSet/all-time-units"},{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"DurationUnits"}],"strength":"extensible","description":"Appropriate units for Duration.","valueSet":"http://hl7.org/fhir/ValueSet/duration-units"},"mapping":[{"identity":"v2","map":"SN (see also Range) or CQ"},{"identity":"rim","map":"PQ, IVL<PQ>, MO, CO, depending on the values"},{"identity":"rim","map":"PQ, IVL<PQ> depending on the values"}]},{"id":"Duration.id","path":"Duration.id","representation":["xmlAttr"],"short":"Unique id for inter-element referencing","definition":"Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Duration.extension","path":"Duration.extension","slicing":{"discriminator":[{"type":"value","path":"url"}],"description":"Extensions are always sliced by (at least) url","rules":"open"},"short":"Additional content defined by implementations","definition":"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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Duration.value","path":"Duration.value","short":"Numerical value (with implicit precision)","definition":"The value of the measured amount. The value includes an implicit precision in the presentation of the value.","comment":"The implicit precision in the value should always be honored. Monetary values have their own rules for handling precision (refer to standard accounting text books).","requirements":"Precision is handled implicitly in almost all cases of measurement.","min":0,"max":"1","base":{"path":"Quantity.value","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"SN.2  / CQ - N/A"},{"identity":"rim","map":"PQ.value, CO.value, MO.value, IVL.high or IVL.low depending on the value"}]},{"id":"Duration.comparator","path":"Duration.comparator","short":"< | <= | >= | > - how to understand the value","definition":"How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value.","requirements":"Need a framework for handling measures where the value is <5ug/L or >400mg/L due to the limitations of measuring methodology.","min":0,"max":"1","base":{"path":"Quantity.comparator","min":0,"max":"1"},"type":[{"code":"code"}],"meaningWhenMissing":"If there is no comparator, then there is no modification of the value","constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":true,"isModifierReason":"This is labeled as \"Is Modifier\" because the comparator modifies the interpretation of the value significantly. If there is no comparator, then there is no modification of the value","isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"QuantityComparator"}],"strength":"required","description":"How the Quantity should be understood and represented.","valueSet":"http://hl7.org/fhir/ValueSet/quantity-comparator|4.0.1"},"mapping":[{"identity":"v2","map":"SN.1  / CQ.1"},{"identity":"rim","map":"IVL properties"}]},{"id":"Duration.unit","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable","valueBoolean":true}],"path":"Duration.unit","short":"Unit representation","definition":"A human-readable form of the unit.","requirements":"There are many representations for units of measure and in many contexts, particular representations are fixed and required. I.e. mcg for micrograms.","min":0,"max":"1","base":{"path":"Quantity.unit","min":0,"max":"1"},"type":[{"code":"string"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"PQ.unit"}]},{"id":"Duration.system","path":"Duration.system","short":"System that defines coded unit form","definition":"The identification of the system that provides the coded form of the unit.","requirements":"Need to know the system that defines the coded form of the unit.","min":0,"max":"1","base":{"path":"Quantity.system","min":0,"max":"1"},"type":[{"code":"uri"}],"condition":["qty-3"],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"CO.codeSystem, PQ.translation.codeSystem"}]},{"id":"Duration.code","path":"Duration.code","short":"Coded form of the unit","definition":"A computer processable form of the unit in some unit representation system.","comment":"The preferred system is UCUM, but SNOMED CT can also be used (for customary units) or ISO 4217 for currency.  The context of use may additionally require a code from a particular system.","requirements":"Need a computable form of the unit that is fixed across all forms. UCUM provides this for quantities, but SNOMED CT provides many units of interest.","min":0,"max":"1","base":{"path":"Quantity.code","min":0,"max":"1"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"v2","map":"(see OBX.6 etc.) / CQ.2"},{"identity":"rim","map":"PQ.code, MO.currency, PQ.translation.code"}]}]},"differential":{"element":[{"id":"Duration","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"path":"Duration","short":"A length of time","definition":"A length of time.","min":0,"max":"*","constraint":[{"key":"drt-1","severity":"error","human":"There SHALL be a code if there is a value and it SHALL be an expression of time.  If system is present, it SHALL be UCUM.","expression":"code.exists() implies ((system = %ucum) and value.exists())","xpath":"(f:code or not(f:value)) and (not(exists(f:system)) or f:system/@value='http://unitsofmeasure.org')"}],"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet","valueCanonical":"http://hl7.org/fhir/ValueSet/all-time-units"},{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"DurationUnits"}],"strength":"extensible","description":"Appropriate units for Duration.","valueSet":"http://hl7.org/fhir/ValueSet/duration-units"},"mapping":[{"identity":"rim","map":"PQ, IVL<PQ> depending on the values"}]}]}}
\ No newline at end of file
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-SampledData.json b/test/testhelpers/testdefs/package/StructureDefinition-SampledData.json
new file mode 100644
index 0000000..f08aa42
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-SampledData.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"SampledData","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"url":"http://hl7.org/fhir/StructureDefinition/SampledData","version":"4.0.1","name":"SampledData","status":"draft","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for SampledData Type: A series of measurements taken by a device, with upper and lower limits. There may be more than one dimension in the data.","purpose":"There is a need for a concise way to handle the data produced by devices that sample a physical state at a high frequency.","fhirVersion":"4.0.1","mapping":[{"identity":"v2","uri":"http://hl7.org/v2","name":"HL7 v2 Mapping"},{"identity":"rim","uri":"http://hl7.org/v3","name":"RIM Mapping"}],"kind":"complex-type","abstract":false,"type":"SampledData","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Element","derivation":"specialization","snapshot":{"element":[{"id":"SampledData","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"path":"SampledData","short":"A series of measurements taken by a device","definition":"A series of measurements taken by a device, with upper and lower limits. There may be more than one dimension in the data.","comment":"The data is not interpretable without at least origin, period, and dimensions, but these are optional to allow a separation between the template of measurement and the actual measurement, such as between DeviceCapabilities and DeviceLog.  When providing a summary view (for example with Observation.value[x]) SampledData should be represented with a brief display text such as \"Sampled Data\".","min":0,"max":"*","base":{"path":"SampledData","min":0,"max":"*"},"condition":["ele-1"],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"mapping":[{"identity":"rim","map":"n/a"},{"identity":"v2","map":"N/A (but see section 7.14 in v2.7)"},{"identity":"rim","map":"SLIST + GLIST"}]},{"id":"SampledData.id","path":"SampledData.id","representation":["xmlAttr"],"short":"Unique id for inter-element referencing","definition":"Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"SampledData.extension","path":"SampledData.extension","slicing":{"discriminator":[{"type":"value","path":"url"}],"description":"Extensions are always sliced by (at least) url","rules":"open"},"short":"Additional content defined by implementations","definition":"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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"SampledData.origin","path":"SampledData.origin","short":"Zero value and units","definition":"The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.","min":1,"max":"1","base":{"path":"SampledData.origin","min":1,"max":"1"},"type":[{"code":"Quantity","profile":["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"SLIST.origin"}]},{"id":"SampledData.period","path":"SampledData.period","short":"Number of milliseconds between samples","definition":"The length of time between sampling times, measured in milliseconds.","comment":"This is usually a whole number.","min":1,"max":"1","base":{"path":"SampledData.period","min":1,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"GLIST.increment"}]},{"id":"SampledData.factor","path":"SampledData.factor","short":"Multiply data by this before adding to origin","definition":"A correction factor that is applied to the sampled data points before they are added to the origin.","min":0,"max":"1","base":{"path":"SampledData.factor","min":0,"max":"1"},"type":[{"code":"decimal"}],"meaningWhenMissing":"If no factor is assigned, the data is not adjusted before adding to the origin","constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"SLIST.factor"}]},{"id":"SampledData.lowerLimit","path":"SampledData.lowerLimit","short":"Lower limit of detection","definition":"The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit).","min":0,"max":"1","base":{"path":"SampledData.lowerLimit","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (use SLIST.digits.nullFlavor)"}]},{"id":"SampledData.upperLimit","path":"SampledData.upperLimit","short":"Upper limit of detection","definition":"The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit).","min":0,"max":"1","base":{"path":"SampledData.upperLimit","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (use SLIST.digits.nullFlavor)"}]},{"id":"SampledData.dimensions","path":"SampledData.dimensions","short":"Number of sample points at each time point","definition":"The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once.","comment":"If there is more than one dimension, the code for the type of data will define the meaning of the dimensions (typically ECG data).","min":1,"max":"1","base":{"path":"SampledData.dimensions","min":1,"max":"1"},"type":[{"code":"positiveInt"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (fixed to 1)"}]},{"id":"SampledData.data","path":"SampledData.data","short":"Decimal values with spaces, or \"E\" | \"U\" | \"L\"","definition":"A series of data points which are decimal values separated by a single space (character u20). The special values \"E\" (error), \"L\" (below detection limit) and \"U\" (above detection limit) can also be used in place of a decimal value.","comment":"Data may be missing if it is omitted for summarization purposes. In general, data is required for any actual use of a SampledData.","min":0,"max":"1","base":{"path":"SampledData.data","min":0,"max":"1"},"type":[{"code":"string"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"SLIST.digits"}]}]},"differential":{"element":[{"id":"SampledData","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"trial-use"}],"path":"SampledData","short":"A series of measurements taken by a device","definition":"A series of measurements taken by a device, with upper and lower limits. There may be more than one dimension in the data.","comment":"The data is not interpretable without at least origin, period, and dimensions, but these are optional to allow a separation between the template of measurement and the actual measurement, such as between DeviceCapabilities and DeviceLog.  When providing a summary view (for example with Observation.value[x]) SampledData should be represented with a brief display text such as \"Sampled Data\".","min":0,"max":"*","mapping":[{"identity":"v2","map":"N/A (but see section 7.14 in v2.7)"},{"identity":"rim","map":"SLIST + GLIST"}]},{"id":"SampledData.origin","path":"SampledData.origin","short":"Zero value and units","definition":"The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.","min":1,"max":"1","type":[{"code":"Quantity","profile":["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}],"isSummary":true,"mapping":[{"identity":"rim","map":"SLIST.origin"}]},{"id":"SampledData.period","path":"SampledData.period","short":"Number of milliseconds between samples","definition":"The length of time between sampling times, measured in milliseconds.","comment":"This is usually a whole number.","min":1,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"GLIST.increment"}]},{"id":"SampledData.factor","path":"SampledData.factor","short":"Multiply data by this before adding to origin","definition":"A correction factor that is applied to the sampled data points before they are added to the origin.","min":0,"max":"1","type":[{"code":"decimal"}],"meaningWhenMissing":"If no factor is assigned, the data is not adjusted before adding to the origin","isSummary":true,"mapping":[{"identity":"rim","map":"SLIST.factor"}]},{"id":"SampledData.lowerLimit","path":"SampledData.lowerLimit","short":"Lower limit of detection","definition":"The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit).","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (use SLIST.digits.nullFlavor)"}]},{"id":"SampledData.upperLimit","path":"SampledData.upperLimit","short":"Upper limit of detection","definition":"The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit).","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (use SLIST.digits.nullFlavor)"}]},{"id":"SampledData.dimensions","path":"SampledData.dimensions","short":"Number of sample points at each time point","definition":"The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once.","comment":"If there is more than one dimension, the code for the type of data will define the meaning of the dimensions (typically ECG data).","min":1,"max":"1","type":[{"code":"positiveInt"}],"isSummary":true,"mapping":[{"identity":"rim","map":"N/A (fixed to 1)"}]},{"id":"SampledData.data","path":"SampledData.data","short":"Decimal values with spaces, or \"E\" | \"U\" | \"L\"","definition":"A series of data points which are decimal values separated by a single space (character u20). The special values \"E\" (error), \"L\" (below detection limit) and \"U\" (above detection limit) can also be used in place of a decimal value.","comment":"Data may be missing if it is omitted for summarization purposes. In general, data is required for any actual use of a SampledData.","min":0,"max":"1","type":[{"code":"string"}],"mapping":[{"identity":"rim","map":"SLIST.digits"}]}]}}
\ No newline at end of file
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-Timing.json b/test/testhelpers/testdefs/package/StructureDefinition-Timing.json
new file mode 100644
index 0000000..8c78363
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-Timing.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"Timing","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"url":"http://hl7.org/fhir/StructureDefinition/Timing","version":"4.0.1","name":"Timing","status":"active","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for Timing Type: Specifies an event that may occur multiple times. Timing schedules are used to record when things are planned, expected or requested to occur. The most common usage is in dosage instructions for medications. They are also used when planning care of various kinds, and may be used for reporting the schedule to which past regular activities were carried out.","purpose":"Need to able to track proposed timing schedules. There are several different ways to do this: one or more specified times, a simple rules like three times a day, or  before/after meals.","fhirVersion":"4.0.1","mapping":[{"identity":"v2","uri":"http://hl7.org/v2","name":"HL7 v2 Mapping"},{"identity":"rim","uri":"http://hl7.org/v3","name":"RIM Mapping"}],"kind":"complex-type","abstract":false,"type":"Timing","baseDefinition":"http://hl7.org/fhir/StructureDefinition/BackboneElement","derivation":"specialization","snapshot":{"element":[{"id":"Timing","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"path":"Timing","short":"A timing schedule that specifies an event that may occur multiple times","definition":"Specifies an event that may occur multiple times. Timing schedules are used to record when things are planned, expected or requested to occur. The most common usage is in dosage instructions for medications. They are also used when planning care of various kinds, and may be used for reporting the schedule to which past regular activities were carried out.","comment":"Describes the occurrence of an event that may occur multiple times. Timing schedules are used for specifying when events are expected or requested to occur, and may also be used to represent the summary of a past or ongoing event.  For simplicity, the definitions of Timing components are expressed as 'future' events, but such components can also be used to describe historic or ongoing events.\n\nA Timing schedule can be a list of events and/or criteria for when the event happens, which can be expressed in a structured form and/or as a code. When both event and a repeating specification are provided, the list of events should be understood as an interpretation of the information in the repeat structure.","min":0,"max":"*","base":{"path":"Timing","min":0,"max":"*"},"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"mapping":[{"identity":"rim","map":"n/a"},{"identity":"v2","map":"N/A"},{"identity":"rim","map":"QSET<TS> (GTS)"}]},{"id":"Timing.id","path":"Timing.id","representation":["xmlAttr"],"short":"Unique id for inter-element referencing","definition":"Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.extension","path":"Timing.extension","slicing":{"discriminator":[{"type":"value","path":"url"}],"description":"Extensions are always sliced by (at least) url","rules":"open"},"short":"Additional content defined by implementations","definition":"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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.modifierExtension","path":"Timing.modifierExtension","short":"Extensions that cannot be ignored even if unrecognized","definition":"May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. 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. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).","comment":"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.","requirements":"Modifier extensions allow for extensions that *cannot* be safely ignored to be clearly distinguished from the vast majority of extensions which can be safely ignored.  This promotes interoperability by eliminating the need for implementers to prohibit the presence of extensions. For further information, see the [definition of modifier extensions](extensibility.html#modifierExtension).","alias":["extensions","user content","modifiers"],"min":0,"max":"*","base":{"path":"BackboneElement.modifierExtension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":true,"isModifierReason":"Modifier extensions are expected to modify the meaning or interpretation of the element that contains them","isSummary":true,"mapping":[{"identity":"rim","map":"N/A"}]},{"id":"Timing.event","path":"Timing.event","short":"When the event occurs","definition":"Identifies specific times when the event occurs.","requirements":"In a Medication Administration Record, for instance, you need to take a general specification, and turn it into a precise specification.","min":0,"max":"*","base":{"path":"Timing.event","min":0,"max":"*"},"type":[{"code":"dateTime"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"QLIST<TS>"}]},{"id":"Timing.repeat","path":"Timing.repeat","short":"When the event is to occur","definition":"A set of rules that describe when the event is scheduled.","requirements":"Many timing schedules are determined by regular repetitions.","min":0,"max":"1","base":{"path":"Timing.repeat","min":0,"max":"1"},"type":[{"code":"Element"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"tim-1","severity":"error","human":"if there's a duration, there needs to be duration units","expression":"duration.empty() or durationUnit.exists()","xpath":"not(exists(f:duration)) or exists(f:durationUnit)"},{"key":"tim-2","severity":"error","human":"if there's a period, there needs to be period units","expression":"period.empty() or periodUnit.exists()","xpath":"not(exists(f:period)) or exists(f:periodUnit)"},{"key":"tim-4","severity":"error","human":"duration SHALL be a non-negative value","expression":"duration.exists() implies duration >= 0","xpath":"f:duration/@value >= 0 or not(f:duration/@value)"},{"key":"tim-5","severity":"error","human":"period SHALL be a non-negative value","expression":"period.exists() implies period >= 0","xpath":"f:period/@value >= 0 or not(f:period/@value)"},{"key":"tim-6","severity":"error","human":"If there's a periodMax, there must be a period","expression":"periodMax.empty() or period.exists()","xpath":"not(exists(f:periodMax)) or exists(f:period)"},{"key":"tim-7","severity":"error","human":"If there's a durationMax, there must be a duration","expression":"durationMax.empty() or duration.exists()","xpath":"not(exists(f:durationMax)) or exists(f:duration)"},{"key":"tim-8","severity":"error","human":"If there's a countMax, there must be a count","expression":"countMax.empty() or count.exists()","xpath":"not(exists(f:countMax)) or exists(f:count)"},{"key":"tim-9","severity":"error","human":"If there's an offset, there must be a when (and not C, CM, CD, CV)","expression":"offset.empty() or (when.exists() and ((when in ('C' | 'CM' | 'CD' | 'CV')).not()))","xpath":"not(exists(f:offset)) or exists(f:when)"},{"key":"tim-10","severity":"error","human":"If there's a timeOfDay, there cannot be a when, or vice versa","expression":"timeOfDay.empty() or when.empty()","xpath":"not(exists(f:timeOfDay)) or not(exists(f:when))"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"Implies PIVL or EIVL"}]},{"id":"Timing.repeat.id","path":"Timing.repeat.id","representation":["xmlAttr"],"short":"Unique id for inter-element referencing","definition":"Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.extension","path":"Timing.repeat.extension","slicing":{"discriminator":[{"type":"value","path":"url"}],"description":"Extensions are always sliced by (at least) url","rules":"open"},"short":"Additional content defined by implementations","definition":"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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.bounds[x]","path":"Timing.repeat.bounds[x]","short":"Length/Range of lengths, or (Start and/or end) limits","definition":"Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.","min":0,"max":"1","base":{"path":"Timing.repeat.bounds[x]","min":0,"max":"1"},"type":[{"code":"Duration"},{"code":"Range"},{"code":"Period"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"IVL(TS) used in a QSI"}]},{"id":"Timing.repeat.count","path":"Timing.repeat.count","short":"Number of times to repeat","definition":"A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.","comment":"If you have both bounds and count, then this should be understood as within the bounds period, until count times happens.","requirements":"Repetitions may be limited by end time or total occurrences.","min":0,"max":"1","base":{"path":"Timing.repeat.count","min":0,"max":"1"},"type":[{"code":"positiveInt"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.count"}]},{"id":"Timing.repeat.countMax","path":"Timing.repeat.countMax","short":"Maximum number of times to repeat","definition":"If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.","min":0,"max":"1","base":{"path":"Timing.repeat.countMax","min":0,"max":"1"},"type":[{"code":"positiveInt"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.count"}]},{"id":"Timing.repeat.duration","path":"Timing.repeat.duration","short":"How long when it happens","definition":"How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.","comment":"For some events the duration is part of the definition of the event (e.g. IV infusions, where the duration is implicit in the specified quantity and rate). For others, it's part of the timing specification (e.g. exercise).","requirements":"Some activities are not instantaneous and need to be maintained for a period of time.","min":0,"max":"1","base":{"path":"Timing.repeat.duration","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.durationMax","path":"Timing.repeat.durationMax","short":"How long when it happens (Max)","definition":"If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.","comment":"For some events the duration is part of the definition of the event (e.g. IV infusions, where the duration is implicit in the specified quantity and rate). For others, it's part of the timing specification (e.g. exercise).","requirements":"Some activities are not instantaneous and need to be maintained for a period of time.","min":0,"max":"1","base":{"path":"Timing.repeat.durationMax","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.durationUnit","path":"Timing.repeat.durationUnit","short":"s | min | h | d | wk | mo | a - unit of time (UCUM)","definition":"The units of time for the duration, in UCUM units.","min":0,"max":"1","base":{"path":"Timing.repeat.durationUnit","min":0,"max":"1"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"UnitsOfTime"}],"strength":"required","description":"A unit of time (units from UCUM).","valueSet":"http://hl7.org/fhir/ValueSet/units-of-time|4.0.1"},"mapping":[{"identity":"rim","map":"PIVL.phase.unit"}]},{"id":"Timing.repeat.frequency","path":"Timing.repeat.frequency","short":"Event occurs frequency times per period","definition":"The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.","min":0,"max":"1","base":{"path":"Timing.repeat.frequency","min":0,"max":"1"},"type":[{"code":"positiveInt"}],"meaningWhenMissing":"If no frequency is stated, the assumption is that the event occurs once per period, but systems SHOULD always be specific about this","constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.frequencyMax","path":"Timing.repeat.frequencyMax","short":"Event occurs up to frequencyMax times per period","definition":"If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.","min":0,"max":"1","base":{"path":"Timing.repeat.frequencyMax","min":0,"max":"1"},"type":[{"code":"positiveInt"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.period","path":"Timing.repeat.period","short":"Event occurs frequency times per period","definition":"Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.","min":0,"max":"1","base":{"path":"Timing.repeat.period","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.periodMax","path":"Timing.repeat.periodMax","short":"Upper limit of period (3-4 hours)","definition":"If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days.","min":0,"max":"1","base":{"path":"Timing.repeat.periodMax","min":0,"max":"1"},"type":[{"code":"decimal"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.periodUnit","path":"Timing.repeat.periodUnit","short":"s | min | h | d | wk | mo | a - unit of time (UCUM)","definition":"The units of time for the period in UCUM units.","min":0,"max":"1","base":{"path":"Timing.repeat.periodUnit","min":0,"max":"1"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"UnitsOfTime"}],"strength":"required","description":"A unit of time (units from UCUM).","valueSet":"http://hl7.org/fhir/ValueSet/units-of-time|4.0.1"},"mapping":[{"identity":"rim","map":"PIVL.phase.unit"}]},{"id":"Timing.repeat.dayOfWeek","path":"Timing.repeat.dayOfWeek","short":"mon | tue | wed | thu | fri | sat | sun","definition":"If one or more days of week is provided, then the action happens only on the specified day(s).","comment":"If no days are specified, the action is assumed to happen every day as otherwise specified. The elements frequency and period cannot be used as well as dayOfWeek.","min":0,"max":"*","base":{"path":"Timing.repeat.dayOfWeek","min":0,"max":"*"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"DayOfWeek"}],"strength":"required","valueSet":"http://hl7.org/fhir/ValueSet/days-of-week|4.0.1"},"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.timeOfDay","path":"Timing.repeat.timeOfDay","short":"Time of day for action","definition":"Specified time of day for action to take place.","comment":"When time of day is specified, it is inferred that the action happens every day (as filtered by dayofWeek) on the specified times. The elements when, frequency and period cannot be used as well as timeOfDay.","min":0,"max":"*","base":{"path":"Timing.repeat.timeOfDay","min":0,"max":"*"},"type":[{"code":"time"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.when","path":"Timing.repeat.when","short":"Code for time period of occurrence","definition":"An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.","comment":"When more than one event is listed, the event is tied to the union of the specified events.","requirements":"Timings are frequently determined by occurrences such as waking, eating and sleep.","min":0,"max":"*","base":{"path":"Timing.repeat.when","min":0,"max":"*"},"type":[{"code":"code"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"EventTiming"}],"strength":"required","description":"Real world event relating to the schedule.","valueSet":"http://hl7.org/fhir/ValueSet/event-timing|4.0.1"},"mapping":[{"identity":"rim","map":"EIVL.event"}]},{"id":"Timing.repeat.offset","path":"Timing.repeat.offset","short":"Minutes from event (before or after)","definition":"The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.","min":0,"max":"1","base":{"path":"Timing.repeat.offset","min":0,"max":"1"},"type":[{"code":"unsignedInt"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"mapping":[{"identity":"rim","map":"EIVL.offset"}]},{"id":"Timing.code","path":"Timing.code","short":"BID | TID | QID | AM | PM | QD | QOD | +","definition":"A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).","comment":"BID etc. are defined as 'at institutionally specified times'. For example, an institution may choose that BID is \"always at 7am and 6pm\".  If it is inappropriate for this choice to be made, the code BID should not be used. Instead, a distinct organization-specific code should be used in place of the HL7-defined BID code and/or a structured representation should be used (in this case, specifying the two event times).","min":0,"max":"1","base":{"path":"Timing.code","min":0,"max":"1"},"type":[{"code":"CodeableConcept"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"TimingAbbreviation"}],"strength":"preferred","description":"Code for a known / defined timing pattern.","valueSet":"http://hl7.org/fhir/ValueSet/timing-abbreviation"},"mapping":[{"identity":"rim","map":"QSC.code"}]}]},"differential":{"element":[{"id":"Timing","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"path":"Timing","short":"A timing schedule that specifies an event that may occur multiple times","definition":"Specifies an event that may occur multiple times. Timing schedules are used to record when things are planned, expected or requested to occur. The most common usage is in dosage instructions for medications. They are also used when planning care of various kinds, and may be used for reporting the schedule to which past regular activities were carried out.","comment":"Describes the occurrence of an event that may occur multiple times. Timing schedules are used for specifying when events are expected or requested to occur, and may also be used to represent the summary of a past or ongoing event.  For simplicity, the definitions of Timing components are expressed as 'future' events, but such components can also be used to describe historic or ongoing events.\n\nA Timing schedule can be a list of events and/or criteria for when the event happens, which can be expressed in a structured form and/or as a code. When both event and a repeating specification are provided, the list of events should be understood as an interpretation of the information in the repeat structure.","min":0,"max":"*","mapping":[{"identity":"v2","map":"N/A"},{"identity":"rim","map":"QSET<TS> (GTS)"}]},{"id":"Timing.event","path":"Timing.event","short":"When the event occurs","definition":"Identifies specific times when the event occurs.","requirements":"In a Medication Administration Record, for instance, you need to take a general specification, and turn it into a precise specification.","min":0,"max":"*","type":[{"code":"dateTime"}],"isSummary":true,"mapping":[{"identity":"rim","map":"QLIST<TS>"}]},{"id":"Timing.repeat","path":"Timing.repeat","short":"When the event is to occur","definition":"A set of rules that describe when the event is scheduled.","requirements":"Many timing schedules are determined by regular repetitions.","min":0,"max":"1","type":[{"code":"Element"}],"constraint":[{"key":"tim-9","severity":"error","human":"If there's an offset, there must be a when (and not C, CM, CD, CV)","expression":"offset.empty() or (when.exists() and ((when in ('C' | 'CM' | 'CD' | 'CV')).not()))","xpath":"not(exists(f:offset)) or exists(f:when)"},{"key":"tim-5","severity":"error","human":"period SHALL be a non-negative value","expression":"period.exists() implies period >= 0","xpath":"f:period/@value >= 0 or not(f:period/@value)"},{"key":"tim-6","severity":"error","human":"If there's a periodMax, there must be a period","expression":"periodMax.empty() or period.exists()","xpath":"not(exists(f:periodMax)) or exists(f:period)"},{"key":"tim-7","severity":"error","human":"If there's a durationMax, there must be a duration","expression":"durationMax.empty() or duration.exists()","xpath":"not(exists(f:durationMax)) or exists(f:duration)"},{"key":"tim-8","severity":"error","human":"If there's a countMax, there must be a count","expression":"countMax.empty() or count.exists()","xpath":"not(exists(f:countMax)) or exists(f:count)"},{"key":"tim-1","severity":"error","human":"if there's a duration, there needs to be duration units","expression":"duration.empty() or durationUnit.exists()","xpath":"not(exists(f:duration)) or exists(f:durationUnit)"},{"key":"tim-10","severity":"error","human":"If there's a timeOfDay, there cannot be a when, or vice versa","expression":"timeOfDay.empty() or when.empty()","xpath":"not(exists(f:timeOfDay)) or not(exists(f:when))"},{"key":"tim-2","severity":"error","human":"if there's a period, there needs to be period units","expression":"period.empty() or periodUnit.exists()","xpath":"not(exists(f:period)) or exists(f:periodUnit)"},{"key":"tim-4","severity":"error","human":"duration SHALL be a non-negative value","expression":"duration.exists() implies duration >= 0","xpath":"f:duration/@value >= 0 or not(f:duration/@value)"}],"isSummary":true,"mapping":[{"identity":"rim","map":"Implies PIVL or EIVL"}]},{"id":"Timing.repeat.bounds[x]","path":"Timing.repeat.bounds[x]","short":"Length/Range of lengths, or (Start and/or end) limits","definition":"Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.","min":0,"max":"1","type":[{"code":"Duration"},{"code":"Range"},{"code":"Period"}],"isSummary":true,"mapping":[{"identity":"rim","map":"IVL(TS) used in a QSI"}]},{"id":"Timing.repeat.count","path":"Timing.repeat.count","short":"Number of times to repeat","definition":"A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.","comment":"If you have both bounds and count, then this should be understood as within the bounds period, until count times happens.","requirements":"Repetitions may be limited by end time or total occurrences.","min":0,"max":"1","type":[{"code":"positiveInt"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.count"}]},{"id":"Timing.repeat.countMax","path":"Timing.repeat.countMax","short":"Maximum number of times to repeat","definition":"If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.","min":0,"max":"1","type":[{"code":"positiveInt"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.count"}]},{"id":"Timing.repeat.duration","path":"Timing.repeat.duration","short":"How long when it happens","definition":"How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.","comment":"For some events the duration is part of the definition of the event (e.g. IV infusions, where the duration is implicit in the specified quantity and rate). For others, it's part of the timing specification (e.g. exercise).","requirements":"Some activities are not instantaneous and need to be maintained for a period of time.","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.durationMax","path":"Timing.repeat.durationMax","short":"How long when it happens (Max)","definition":"If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.","comment":"For some events the duration is part of the definition of the event (e.g. IV infusions, where the duration is implicit in the specified quantity and rate). For others, it's part of the timing specification (e.g. exercise).","requirements":"Some activities are not instantaneous and need to be maintained for a period of time.","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.durationUnit","path":"Timing.repeat.durationUnit","short":"s | min | h | d | wk | mo | a - unit of time (UCUM)","definition":"The units of time for the duration, in UCUM units.","min":0,"max":"1","type":[{"code":"code"}],"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"UnitsOfTime"}],"strength":"required","description":"A unit of time (units from UCUM).","valueSet":"http://hl7.org/fhir/ValueSet/units-of-time|4.0.1"},"mapping":[{"identity":"rim","map":"PIVL.phase.unit"}]},{"id":"Timing.repeat.frequency","path":"Timing.repeat.frequency","short":"Event occurs frequency times per period","definition":"The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.","min":0,"max":"1","type":[{"code":"positiveInt"}],"meaningWhenMissing":"If no frequency is stated, the assumption is that the event occurs once per period, but systems SHOULD always be specific about this","isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.frequencyMax","path":"Timing.repeat.frequencyMax","short":"Event occurs up to frequencyMax times per period","definition":"If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.","min":0,"max":"1","type":[{"code":"positiveInt"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.period","path":"Timing.repeat.period","short":"Event occurs frequency times per period","definition":"Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.periodMax","path":"Timing.repeat.periodMax","short":"Upper limit of period (3-4 hours)","definition":"If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days.","min":0,"max":"1","type":[{"code":"decimal"}],"isSummary":true,"mapping":[{"identity":"rim","map":"PIVL.phase"}]},{"id":"Timing.repeat.periodUnit","path":"Timing.repeat.periodUnit","short":"s | min | h | d | wk | mo | a - unit of time (UCUM)","definition":"The units of time for the period in UCUM units.","min":0,"max":"1","type":[{"code":"code"}],"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"UnitsOfTime"}],"strength":"required","description":"A unit of time (units from UCUM).","valueSet":"http://hl7.org/fhir/ValueSet/units-of-time|4.0.1"},"mapping":[{"identity":"rim","map":"PIVL.phase.unit"}]},{"id":"Timing.repeat.dayOfWeek","path":"Timing.repeat.dayOfWeek","short":"mon | tue | wed | thu | fri | sat | sun","definition":"If one or more days of week is provided, then the action happens only on the specified day(s).","comment":"If no days are specified, the action is assumed to happen every day as otherwise specified. The elements frequency and period cannot be used as well as dayOfWeek.","min":0,"max":"*","type":[{"code":"code"}],"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"DayOfWeek"}],"strength":"required","valueSet":"http://hl7.org/fhir/ValueSet/days-of-week|4.0.1"},"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.timeOfDay","path":"Timing.repeat.timeOfDay","short":"Time of day for action","definition":"Specified time of day for action to take place.","comment":"When time of day is specified, it is inferred that the action happens every day (as filtered by dayofWeek) on the specified times. The elements when, frequency and period cannot be used as well as timeOfDay.","min":0,"max":"*","type":[{"code":"time"}],"isSummary":true,"mapping":[{"identity":"rim","map":"n/a"}]},{"id":"Timing.repeat.when","path":"Timing.repeat.when","short":"Code for time period of occurrence","definition":"An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.","comment":"When more than one event is listed, the event is tied to the union of the specified events.","requirements":"Timings are frequently determined by occurrences such as waking, eating and sleep.","min":0,"max":"*","type":[{"code":"code"}],"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"EventTiming"}],"strength":"required","description":"Real world event relating to the schedule.","valueSet":"http://hl7.org/fhir/ValueSet/event-timing|4.0.1"},"mapping":[{"identity":"rim","map":"EIVL.event"}]},{"id":"Timing.repeat.offset","path":"Timing.repeat.offset","short":"Minutes from event (before or after)","definition":"The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.","min":0,"max":"1","type":[{"code":"unsignedInt"}],"isSummary":true,"mapping":[{"identity":"rim","map":"EIVL.offset"}]},{"id":"Timing.code","path":"Timing.code","short":"BID | TID | QID | AM | PM | QD | QOD | +","definition":"A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).","comment":"BID etc. are defined as 'at institutionally specified times'. For example, an institution may choose that BID is \"always at 7am and 6pm\".  If it is inappropriate for this choice to be made, the code BID should not be used. Instead, a distinct organization-specific code should be used in place of the HL7-defined BID code and/or a structured representation should be used (in this case, specifying the two event times).","min":0,"max":"1","type":[{"code":"CodeableConcept"}],"isSummary":true,"binding":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName","valueString":"TimingAbbreviation"}],"strength":"preferred","description":"Code for a known / defined timing pattern.","valueSet":"http://hl7.org/fhir/ValueSet/timing-abbreviation"},"mapping":[{"identity":"rim","map":"QSC.code"}]}]}}
\ No newline at end of file
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-dateTime.json b/test/testhelpers/testdefs/package/StructureDefinition-dateTime.json
new file mode 100644
index 0000000..c992ddc
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-dateTime.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"dateTime","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"url":"http://hl7.org/fhir/StructureDefinition/dateTime","version":"4.0.1","name":"dateTime","status":"active","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for dateTime Type: A date, date-time or partial date (e.g. just year or year + month).  If hours and minutes are specified, a time zone SHALL be populated. The format is a union of the schema types gYear, gYearMonth, date and dateTime. Seconds must be provided due to schema type constraints but may be zero-filled and may be ignored.                 Dates SHALL be valid dates.","fhirVersion":"4.0.1","kind":"primitive-type","abstract":false,"type":"dateTime","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Element","derivation":"specialization","snapshot":{"element":[{"id":"dateTime","path":"dateTime","short":"Primitive Type dateTime","definition":"A date, date-time or partial date (e.g. just year or year + month).  If hours and minutes are specified, a time zone SHALL be populated. The format is a union of the schema types gYear, gYearMonth, date and dateTime. Seconds must be provided due to schema type constraints but may be zero-filled and may be ignored.                 Dates SHALL be valid dates.","min":0,"max":"*","base":{"path":"dateTime","min":0,"max":"*"},"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":false},{"id":"dateTime.id","path":"dateTime.id","representation":["xmlAttr"],"short":"xml:id (or equivalent in JSON)","definition":"unique id for the element within a resource (for internal references)","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false},{"id":"dateTime.extension","path":"dateTime.extension","short":"Additional content defined by implementations","definition":"May be used to represent additional information that is not part of the basic definition of the resource. 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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), 'value')])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false},{"id":"dateTime.value","path":"dateTime.value","representation":["xmlAttr"],"short":"Primitive value for dateTime","definition":"The actual value","min":0,"max":"1","base":{"path":"dateTime.value","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"dateTime"},{"url":"http://hl7.org/fhir/StructureDefinition/regex","valueString":"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"}],"code":"http://hl7.org/fhirpath/System.DateTime"}],"isModifier":false,"isSummary":false}]},"differential":{"element":[{"id":"dateTime","path":"dateTime","short":"Primitive Type dateTime","definition":"A date, date-time or partial date (e.g. just year or year + month).  If hours and minutes are specified, a time zone SHALL be populated. The format is a union of the schema types gYear, gYearMonth, date and dateTime. Seconds must be provided due to schema type constraints but may be zero-filled and may be ignored.                 Dates SHALL be valid dates.","min":0,"max":"*"},{"id":"dateTime.value","path":"dateTime.value","representation":["xmlAttr"],"short":"Primitive value for dateTime","definition":"Primitive value for dateTime","min":0,"max":"1","type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"dateTime"},{"url":"http://hl7.org/fhir/StructureDefinition/regex","valueString":"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"}],"code":"http://hl7.org/fhirpath/System.DateTime"}]}]}}
\ No newline at end of file
diff --git a/test/testhelpers/testdefs/package/StructureDefinition-time.json b/test/testhelpers/testdefs/package/StructureDefinition-time.json
new file mode 100644
index 0000000..8fabae7
--- /dev/null
+++ b/test/testhelpers/testdefs/package/StructureDefinition-time.json
@@ -0,0 +1,1 @@
+{"resourceType":"StructureDefinition","id":"time","meta":{"lastUpdated":"2019-11-01T09:29:23.356+11:00"},"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status","valueCode":"normative"},{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version","valueCode":"4.0.0"}],"url":"http://hl7.org/fhir/StructureDefinition/time","version":"4.0.1","name":"time","status":"active","date":"2019-11-01T09:29:23+11:00","publisher":"HL7 FHIR Standard","contact":[{"telecom":[{"system":"url","value":"http://hl7.org/fhir"}]}],"description":"Base StructureDefinition for time Type: A time during the day, with no date specified","fhirVersion":"4.0.1","kind":"primitive-type","abstract":false,"type":"time","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Element","derivation":"specialization","snapshot":{"element":[{"id":"time","path":"time","short":"Primitive Type time","definition":"A time during the day, with no date specified","min":0,"max":"*","base":{"path":"time","min":0,"max":"*"},"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"}],"isModifier":false,"isSummary":false},{"id":"time.id","path":"time.id","representation":["xmlAttr"],"short":"xml:id (or equivalent in JSON)","definition":"unique id for the element within a resource (for internal references)","min":0,"max":"1","base":{"path":"Element.id","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"string"}],"code":"http://hl7.org/fhirpath/System.String"}],"isModifier":false,"isSummary":false},{"id":"time.extension","path":"time.extension","short":"Additional content defined by implementations","definition":"May be used to represent additional information that is not part of the basic definition of the resource. 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":"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":["extensions","user content"],"min":0,"max":"*","base":{"path":"Element.extension","min":0,"max":"*"},"type":[{"code":"Extension"}],"constraint":[{"key":"ele-1","severity":"error","human":"All FHIR elements must have a @value or children","expression":"hasValue() or (children().count() > id.count())","xpath":"@value|f:*|h:div","source":"http://hl7.org/fhir/StructureDefinition/Element"},{"key":"ext-1","severity":"error","human":"Must have either extensions or value[x], not both","expression":"extension.exists() != value.exists()","xpath":"exists(f:extension)!=exists(f:*[starts-with(local-name(.), 'value')])","source":"http://hl7.org/fhir/StructureDefinition/Extension"}],"isModifier":false,"isSummary":false},{"id":"time.value","path":"time.value","representation":["xmlAttr"],"short":"Primitive value for time","definition":"The actual value","min":0,"max":"1","base":{"path":"time.value","min":0,"max":"1"},"type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"time"},{"url":"http://hl7.org/fhir/StructureDefinition/regex","valueString":"([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?"}],"code":"http://hl7.org/fhirpath/System.Time"}],"isModifier":false,"isSummary":false}]},"differential":{"element":[{"id":"time","path":"time","short":"Primitive Type time","definition":"A time during the day, with no date specified","min":0,"max":"*"},{"id":"time.value","path":"time.value","representation":["xmlAttr"],"short":"Primitive value for time","definition":"Primitive value for time","min":0,"max":"1","type":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type","valueUrl":"time"},{"url":"http://hl7.org/fhir/StructureDefinition/regex","valueString":"([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?"}],"code":"http://hl7.org/fhirpath/System.Time"}]}]}}
\ No newline at end of file