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

Is algorithm for datemath on year and month correct?

    XMLWordPrintableJSON

Details

    • Icon: Change Request Change Request
    • Resolution: Persuasive with Modification
    • Icon: Medium Medium
    • Clinical Quality Language (FHIR)
    • 1.5
    • Clinical Decision Support
    • Authors Guide
    • 5.4.4. Date and Time Arithmetic
    • Hide

      It is the case that the normative-track content of the specification has always specified "last day of the month" behavior, in the Language Semantics chapter definitions for durations:

      http://build.fhir.org/ig/HL7/cql/05-languagesemantics.html#datetime-arithmetic-1

      However, it is also the case that some of the informative examples listed in the Appendix H describe "first day of the next month" behavior:

      http://build.fhir.org/ig/HL7/cql/15-h-timeintervalcalculations.html#definition

      http://build.fhir.org/ig/HL7/cql/15-h-timeintervalcalculations.html#definition-1

      We should correct the examples in Appendix H and ensure they are part of the CQL Test Suite

      Show
      It is the case that the normative-track content of the specification has always specified "last day of the month" behavior, in the Language Semantics chapter definitions for durations: http://build.fhir.org/ig/HL7/cql/05-languagesemantics.html#datetime-arithmetic-1 However, it is also the case that some of the informative examples listed in the Appendix H describe "first day of the next month" behavior: http://build.fhir.org/ig/HL7/cql/15-h-timeintervalcalculations.html#definition http://build.fhir.org/ig/HL7/cql/15-h-timeintervalcalculations.html#definition-1 We should correct the examples in Appendix H and ensure they are part of the CQL Test Suite
    • Chris Moesel/Jen Seeman: 17-0-5
    • Correction
    • Non-substantive

    Description

      The spec states the following in regard to year arithmetic:

      If the month and day of the date or time value is not a valid date in the resulting year, the last day of the calendar month is used.

      It says a similar thing for month arithmetic.

      This goes against every implementation I've ever seen.  Usually, something like "2020-02-29 + 1 year" results in the first day of the next month (e.g., "2021-03-01").  Similarly, "2019-01-29 + 1 month" would usually result in "2019-03-01".  For example, I did this in Node.js (javascript) replicator:

      > var Feb29 = new Date(2020, 1, 29) // NOTE: 0-based month index
      undefined
      > Feb29
      2020-02-29T05:00:00.000Z
      > Feb29.setFullYear(2021)
      1614574800000
      > Feb29
      2021-03-01T05:00:00.000Z

       

      Is the approach described in the CQL spec really what ISO8601 says to do?

      Attachments

        Activity

          People

            bryn.rhodes Bryn Rhodes
            cmoesel Chris Moesel
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: