fhir-sdc icon indicating copy to clipboard operation
fhir-sdc copied to clipboard

initialExpression fails to prepopulate repeats choice field (inside repeats group) with values using context

Open projkov opened this issue 7 months ago • 0 comments

Resource example

extension:
  - url: >-
      http://example.com
    valueTiming:
      repeat:
        duration: 1
        dayOfWeek:
          - mon
          - tue
        timeOfDay:
          - '09:00:00'
        durationUnit: h
id: example-schedule
resourceType: Schedule

Questionnaire example

resourceType: Questionnaire
id: edit-schedule
status: active
launchContext:
  - type:
      - Schedule
    name:
      code: Schedule
    description: Schedule to edit
name: edit-schedule
title: Edit Schedule
url: edit-schedule
mapping:
  - reference: Mapping/edit-schedule-extract
item:
  - linkId: root-group
    type: group
    item:
      - linkId: time-period
        text: Time period
        type: group
        repeats: true
        itemPopulationContext:
          language: text/fhirpath
          expression: >-
            %Schedule.extension.where(url='http://example.com')
        item:
          - linkId: day-of-the-week
            text: Day of the week
            type: choice
            repeats: true
            answerOption:
              - valueCoding:
                  code: sun
                  system: http://hl7.org/fhir/ValueSet/days-of-week
                  display: Sunday
              - valueCoding:
                  code: mon
                  system: http://hl7.org/fhir/ValueSet/days-of-week
                  display: Monday
              - valueCoding:
                  code: tue
                  system: http://hl7.org/fhir/ValueSet/days-of-week
                  display: Tuesday
            initialExpression:
              language: text/fhirpath
              expression: "%Questionnaire.repeat(item).where(linkId='day-of-the-week').answerOption.valueCoding.where(code in %context.valueTiming.repeat.dayOfWeek)"
          - linkId: time-start
            text: Time start
            type: time
            initialExpression:
              language: text/fhirpath
              expression: '%context.valueTiming.repeat.timeOfDay'
meta:
  profile:
    - https://emr-core.beda.software/StructureDefinition/fhir-emr-questionnaire

Expected behaviour

Field with the linkId "day-of-the-week" should display 2 selected values: Monday and Tuesday

Current behaviour

Field with the linkId "day-of-the-week" displays 0 values

projkov avatar Jun 04 '25 11:06 projkov