Uploaded image for project: 'FHIR Specification Feedback'
  1. FHIR Specification Feedback
  2. FHIR-42738

"Datetime must be at least to day" regex rejects valid dateTimes with the required precision

    XMLWordPrintableJSON

Details

    • Icon: Technical Correction Technical Correction
    • Resolution: Persuasive
    • Icon: Medium Medium
    • US Core (FHIR)
    • 6.1.0
    • Cross-Group Projects
    • US Core Laboratory Result Observation Profile
      US Core Observation Clinical Result Profile
      US Core Observation Screening Assessment Profile
    • Hide

      updated us-core-1 xpath to:

       

      \d{4}\d{2}\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|[-+]\d{2}:\d{2})?)?$

       

      tested and matches

       

      1905-08-23
      2015-02-07T13:28:17-05:00
      2017-01-01T00:00:00.000Z
      2015-02-07T13:28:00-05:00
      2017-01-01T00:00:00Z

       

      does not match 

      1905
      1905-08

      Show
      updated us-core-1 xpath to:   \d{4} \d{2} \d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z| [-+] \d{2}:\d{2})?)?$   tested and matches   1905-08-23 2015-02-07T13:28:17-05:00 2017-01-01T00:00:00.000Z 2015-02-07T13:28:00-05:00 2017-01-01T00:00:00Z   does not match  1905 1905-08
    • Correction

    Description

      The regex used to validate that Observation.effectiveDateTime satisfies constraint us-core-1 ("Datetime must be at least to day.") rejects many values that are valid FHIR dateTimes precise to the day or better.

      Relevant excerpt from StructureDefinition-us-core-observation-clinical-result.json:

      // ...
      "constraint": [
          // ...
          {
              "key": "us-core-1",
              "severity": "error",
              "human": "Datetime must be at least to day.",
              "expression": "$this is DateTime implies $this.toString().length() >= 10",
              "xpath": "f:matches(effectiveDateTime,/\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)/)"
          }
      ],
      // ...

      The regex ...

      \d\{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)
      

      ... doesn't match any of the examples of valid dateTimes from the core FHIR spec for dateTime that are precise to at least a day:

      1905-08-23
      2015-02-07T13:28:17-05:00
      2017-01-01T00:00:00.000Z

      Attachments

        Activity

          People

            Unassigned Unassigned
            nzkeith-elation Keith Smith
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: