Skip to content

Implement answerOption initialSelected to set initial value for choice #2035

@maimoonak

Description

@maimoonak

Describe the bug
Fhir spec allows to add a boolean property 'initialSelected' to each answerOption to set that as initial when rendering questionnaire item as defined here .
Also Rule 11 specifies that "If one or more answerOption is present, initial cannot be present. Use answerOption.initialSelected instead"

Component
SDC library

To Reproduce
This questionnaire should work and allow setting initial values

{
  "resourceType": "Questionnaire",
  "item": [{
      "linkId": "2.0",
      "type": "choice",
      "text": "Initially selected multiple choice",
      "repeats": true,
      "answerOption": [{
          "valueCoding": {
            "code": "1st",
            "display": "First",
            "system": "custom"
          }
        }, {
          "valueCoding": {
            "code": "2nd",
            "display": "Second",
            "system": "custom"
          },
          "initialSelected": true
        }, {
          "valueCoding": {
            "code": "3rd",
            "display": "Third",
            "system": "custom"
          },
          "initialSelected": true
       } ]
    }, {
      "linkId": "2.0",
      "type": "string",
      "text": "Initially provided text value",
      "initial": [{
          "valueString": "Here is a sample text"
      }]
    }
]}

Expected behavior
Above questionnaire should work and select the values marked as initialSelected in answerOption.

Would you like to work on the issue?
A PR is created and this issue would be resolved by that

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Complete

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions