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

Issues with %resource.answers().value.ordinal().sum()

    XMLWordPrintableJSON

Details

    • Icon: Change Request Change Request
    • Resolution: Persuasive with Modification
    • Icon: Medium Medium
    • Structured Data Capture (SDC) (FHIR)
    • current
    • FHIR Infrastructure
    • Using Expressions
    • Hide
      1. Remove the 'answers()' function - we don't think it's useful given its limitations.  If you already have to filter, may as well just do things the old fashioned way.  Will update the examples accordingly.
      2. Can ignore this as we're yanking answers()
      3. Will rename the function 'ordinal()' to 'weight()'
      4. / 5. Need to make clear that answerExpression can't ever return 'code' - has to return Coding. 
      5. InitialExpression and CalculatedExpression can return either Coding or code.  If it returns 'code', then the process is to check the allowed answer values (via answerOption, answerValueSet or answerExpression) and look for a matching code.  If there's one match, that's the Coding.  If there are multiple matches, that's an error.  If there are no matches and it's a 'closed' choice, that's an error.  If there are no matches and it's an open choice, the string value for the code is sent as a string value.

      Will add an implementer note on ordinal saying:

      There are two common approaches to implement the weight() function:

      1. Ensure that the 'ordinal'(weight?) extension is present on each answer, even if it isn't in the source data for the loaded QuestionnaireResponse.
      2. Leverage the %qitem variable to return access the associated Questionnaire item, from which the answerOptions/answerValueSet/answerExpression can be found and the answer can be looked up and the weight extension value retrieved.
      Show
      Remove the 'answers()' function - we don't think it's useful given its limitations.  If you already have to filter, may as well just do things the old fashioned way.  Will update the examples accordingly. Can ignore this as we're yanking answers() Will rename the function 'ordinal()' to 'weight()' / 5. Need to make clear that answerExpression can't ever return 'code' - has to return Coding.  InitialExpression and CalculatedExpression can return either Coding or code.  If it returns 'code', then the process is to check the allowed answer values (via answerOption, answerValueSet or answerExpression) and look for a matching code.  If there's one match, that's the Coding.  If there are multiple matches, that's an error.  If there are no matches and it's a 'closed' choice, that's an error.  If there are no matches and it's an open choice, the string value for the code is sent as a string value. Will add an implementer note on ordinal saying: There are two common approaches to implement the weight() function: Ensure that the 'ordinal'(weight?) extension is present on each answer, even if it isn't in the source data for the loaded QuestionnaireResponse. Leverage the %qitem variable to return access the associated Questionnaire item, from which the answerOptions/answerValueSet/answerExpression can be found and the answer can be looked up and the weight extension value retrieved.
    • Brian Postlethwaite/Paul Lynch: 3-0-0
    • Correction
    • Non-compatible

    Description

      See https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/.25resource.2Eanswers.28.29.2Evalue.2Eordinal.28.29.2Esum.28.29, which might have updates.

      The SDC PHQ-9 example includes the FHIRPath %resource.answers().value.ordinal().sum() as a calculated expression to compute the sum of the scores. There are a number of issues here that need some correction or clarification.

      1) %resource.answers() will return all of the answers for the questionnaire, including the answer that contains the calculated expression. What happens when that total value along with the others is passed to ordinal()? (Note: Lloyd's suggestion is to exclude it, with something like %resource.repeat(item).where(linkId != 'totalScore').answers() – though then I think answers() is equivalent to answer.value, and so it is not really worth having.

      2) The page defining answers() says, "The function is equivalent to descendants().where($this is QuestionnaireResponse.item.answer.value)". That expression does not make sense to me. The "is" operator is suppose to take a type specifier (e.g., "$this is Patient").

      3) The ordinal() function refers to the ordinalValue extension, which two years ago (FHIR-24672) was voted to be renamed to "itemWeight". I am not sure why that issue has sat for two years, if that is really going to happen, perhaps we should go ahead and rename the "ordinal" function now?

      4) The input to ordinal is a bunch of values, presumably Codings, but as noted above might include a total value. When looking for the ordinalValue extensions for this codings, how does the ordinal() implementation know which items the Codings came from? I suppose an implementation might keep internally track of where those Codings came from, but what if someone writes, ("1234-5").combine("23456-7").ordinal() (or otherwise constructs some codes/Codings as input without a Questionnaire item source)?

      5) Related to (4), the documentation for ordinal() is unclear on several points. It seems to have the notion that there is a particular element or item in view. There is %context, but that is the item on which the expression sits, which could very well be a sibling of the items with the scores (as in the PHQ-9).

      Attachments

        Activity

          People

            Unassigned Unassigned
            plynch Paul Lynch
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: