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

Incorrect results from "CumulativeDuration" function in the documentation

    XMLWordPrintableJSON

Details

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Medium Medium

    Description

      The "CumulativeDuration" function provided in the documentation does not work correctly and returns an unexpected result [object Object]0. The function is defined as follows:

      /*
      @author: Ludwig van Beethoven
      @description: Determines the cumulative duration of a list of intervals
      @comment: This function collapses the input intervals prior to determining the cumulative duration
      to ensure overlapping intervals do not contribute multiple times to the result
       */
      define function "CumulativeDuration"(Intervals List<Interval<DateTime>>):
        Sum((collapse Intervals) X return all duration in days of X)

      However, the following alternative function definition produces the correct result:

      define function "CumulativeDuration"(Intervals List<Interval<DateTime>>):
        Sum((collapse Intervals) I return (difference in days between start of I and end of I) + 1) 

      Please investigate and update the documentation to provide the correct "CumulativeDuration" function definition to prevent future confusion and ensure accurate results for users.
       
      For example:

      {Interval[@2022-03-23T00:00:00.0, @2022-04-01T00:00:00.0), Interval[@2022-04-23T00:00:00.0, @2022-04-25T00:00:00.0)}

      Test Results:

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            grytcyna Grytcyna Oleg
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: