Testing IG
0.0.1 - CI Build

Testing IG, published by DBojicic. This guide is not an authorized publication; it is the continuous build for version 0.0.1 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/dbojicic/test-repo/ and changes regularly. See the Directory of published versions

MedicationRequest.authoredOn - Date or Data Absent Reason

MedicationRequest.authoredOn date or Data Absent Reason

This test series evaluates four candidate FHIRPath expressions for the AU Core MedicationRequest.authoredOn invariant au-core-medreq-01, raised in FHIR-59045.

The human readable invariant description is:

Date shall be precise to the day or, if not available, the Data Absent Reason extension shall be present

The tests evaluate whether each candidate expression:

  • requires a populated MedicationRequest.authoredOn value to be precise to at least the day
  • requires Data Absent Reason (DAR) when MedicationRequest.authoredOn has no value
  • determines how each expression behaves when a value and DAR are both present
  • allows further constraints to be applied to MedicationRequest.authoredOn in downstream profiles

This will be used to determine which expression correctly implements the human readable description without intentionally restricting downstream use and profiling choices around MedicationRequest.authoredOn and the use of DAR.

Candidate expressions

The following candidate expressions are tested:

Series code Candidate expression
ao-a ($this.hasValue() and $this.toString().length() >= 10) or ($this.hasValue().not() and extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists())
ao-b ($this.hasValue() implies $this.toString().length() >= 10) and ($this.hasValue().not() implies extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists())
ao-c ($this.hasValue() and $this.toString().length() >= 10) xor extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()
ao-d ($this.hasValue() implies ($this.toString().length() >= 10 and extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists().not())) and ($this.hasValue().not() implies extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists())

The purpose of this test series is to confirm which expression(s) correctly implement the human readable description, without unintentionally restricting downstream profiling choices around authoredOn cardinality or use of DAR. This will provide input into discussion about which of the correct expressions is preferable for AU Core.

Initial expression comparison

Note: A FHIR primitive element can contain both a primitive value and extensions. The presence of a value and DAR on MedicationRequest.authoredOn should be considered when comparing the candidate expressions and any needed specific requirements built into the invariant expression.

The following table shows the expected result for each expression based on its FHIRPath logic:

Scenario ao-a ao-b ao-c ao-d What we want
Precise value only Pass Pass Pass Pass Pass
Imprecise value only Fail Fail Fail Fail Fail
DAR only Pass Pass Pass Pass Pass
Other extension only, no DAR Fail Fail Fail Fail Fail
Precise value + DAR Pass Pass Fail Fail Fail
Imprecise value + DAR Fail Fail Pass Fail Fail

The differences from the expression logic:

  • ao-a requires either a sufficiently precise value, or no value with DAR present. When a sufficiently precise value is present, the expression passes regardless of whether DAR is also present.
  • ao-b requires a value, when present, to be sufficiently precise, and requires DAR when there is no value. No additional restriction on DAR when a value is present. Its expected results are the same as ar-or.
  • ao-c requires exactly one side of the expression to evaluate to true. It fails a precise value with DAR. But - an imprecise value makes the first condition false; when DAR is also present, the second condition is true and the overall expression passes.
  • ao-d requires a value, when present, to be sufficiently precise and DAR to be absent. When there is no value, it requires DAR to be present. It fails both a precise value with DAR and an imprecise value with DAR.

These scenarios are tested first to confirm the expected behaviour of each candidate expression. TBD - derived profiles + full test matrix.

List of baseline profiles:

Profile Expression
au-core-medicationrequest-ao-a ao-a
au-core-medicationrequest-ao-b ao-b
au-core-medicationrequest-ao-c ao-c
au-core-medicationrequest-ao-d ao-d

List of derived profiles:

  • ao-e: derives from ao-d + requires DAR to be present
  • ao-f: derives from ao-d + requires authoredOn to have a value Note: only two profiles deriving from the profile with preferred expression (ao-d) created at this stage, more to be done as needed.

List of baseline scenarios, to run against each profile:

Scenario What it does
Precise value only valid value accepted
Imprecise value only, no DAR enforced precision requriement
DAR only DAR accepted
Other extension only, no DAR DAR required when value is not present
DAR + other extension, no value DAR requirement satisfied
Precise value + DAR should have one or the other
Imprecise value + DAR this shows issue with the xor expression - don't think AU Core wants to allow this
Precise value + other extension, no DAR allowed, the invariant does not say anything about other extensions
Imprecise value + other extension, no DAR enforced precision requriement
No authoredOn element cardinality behavior

Tests

The table below lists each test profile and its additional constraint, the test scenarios, expected validation results, and corresponding example instances.

Profile Constraint Test scenario Expected result Example id
medicationrequest-ao-a ($this.hasValue() and $this.toString().length() >= 10) or ($this.hasValue().not() and extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()) authoredOn value present, full datetime Pass MedicationRequest-ao-a-01
authoredOn value present, date only (10 chars) Pass MedicationRequest-ao-a-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-a-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-a-04
authoredOn value not present, DAR used instead Pass MedicationRequest-ao-a-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-a-06
DAR + other extension, no value Pass MedicationRequest-ao-a-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-a-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-a-09
authoredOn precise value present + other extension, no DAR Pass MedicationRequest-ao-a-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-a-11
No authoredOn element Fail MedicationRequest-ao-a-12
medicationrequest-ao-b ($this.hasValue() implies $this.toString().length() >= 10) and ($this.hasValue().not() implies extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()) authoredOn value present, full datetime Pass MedicationRequest-ao-b-01
authoredOn value present, date only (10 chars) Pass MedicationRequest-ao-b-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-b-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-b-04
authoredOn value not present, DAR used instead Pass MedicationRequest-ao-b-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-b-06
DAR + other extension, no value Pass MedicationRequest-ao-b-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-b-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-b-09
authoredOn precise value present + other extension, no DAR Pass MedicationRequest-ao-b-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-b-11
No authoredOn element Fail MedicationRequest-ao-b-12
medicationrequest-ao-c ($this.hasValue() and $this.toString().length() >= 10) xor extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists() authoredOn value present, full datetime Pass MedicationRequest-ao-c-01
authoredOn value present, date only (10 chars) Pass MedicationRequest-ao-c-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-c-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-c-04
authoredOn value not present, DAR used instead Pass MedicationRequest-ao-c-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-c-06
DAR + other extension, no value Pass MedicationRequest-ao-c-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-c-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-c-09
authoredOn precise value present + other extension, no DAR Pass MedicationRequest-ao-c-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-c-11
No authoredOn element Fail MedicationRequest-ao-c-12
medicationrequest-ao-d ($this.hasValue() implies ($this.toString().length() >= 10 and extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists().not())) and ($this.hasValue().not() implies extension('http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()) authoredOn value present, full datetime Pass MedicationRequest-ao-d-01
authoredOn value present, date only (10 chars) Pass MedicationRequest-ao-d-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-d-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-d-04
authoredOn value not present, DAR used instead Pass MedicationRequest-ao-d-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-d-06
DAR + other extension, no value Pass MedicationRequest-ao-d-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-d-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-d-09
authoredOn precise value present + other extension, no DAR Pass MedicationRequest-ao-d-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-d-11
No authoredOn element Fail MedicationRequest-ao-d-12
medicationrequest-ao-e Derives from medicationrequest-ao-d and requires DAR authoredOn value present, full datetime Fail MedicationRequest-ao-e-01
authoredOn value present, date only (10 chars) Fail MedicationRequest-ao-e-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-e-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-e-04
authoredOn value not present, DAR used instead Pass MedicationRequest-ao-e-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-e-06
DAR + other extension, no value Pass MedicationRequest-ao-e-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-e-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-e-09
authoredOn precise value present + other extension, no DAR Fail MedicationRequest-ao-e-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-e-11
No authoredOn element Fail MedicationRequest-ao-e-12
medicationrequest-ao-f Derives from medicationrequest-ao-d and requires authoredOn to have a value authoredOn value present, full datetime Pass MedicationRequest-ao-f-01
authoredOn value present, date only (10 chars) Pass MedicationRequest-ao-f-02
authoredOn value present, month only (7 chars) Fail MedicationRequest-ao-f-03
authoredOn value present, year only (4 chars) Fail MedicationRequest-ao-f-04
authoredOn value not present, DAR used instead Fail MedicationRequest-ao-f-05
Other extension only, no value and no DAR Fail MedicationRequest-ao-f-06
DAR + other extension, no value Fail MedicationRequest-ao-f-07
authoredOn precise value present + DAR Fail MedicationRequest-ao-f-08
authoredOn imprecise value present + DAR Fail MedicationRequest-ao-f-09
authoredOn precise value present + other extension, no DAR Pass MedicationRequest-ao-f-10
authoredOn imprecise value present + other extension, no DAR Fail MedicationRequest-ao-f-11
No authoredOn element Fail MedicationRequest-ao-f-12