Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

answerOption.valueString crashes SDC library #1360

Closed
vadi2 opened this issue May 4, 2022 · 6 comments · Fixed by #1399
Closed

answerOption.valueString crashes SDC library #1360

vadi2 opened this issue May 4, 2022 · 6 comments · Fixed by #1399
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working

Comments

@vadi2
Copy link

vadi2 commented May 4, 2022

Describe the bug
Loading a questionnaire with answerOption.valueString instead of answerOption.valueCoding as the library expects causes a crash. valueStrings and other types are perfectly legitimate options per the spec, however.

Component
SDC library & reference app.

To Reproduce

  1. Add Questionnaire below to the app
  2. View Questionnaire

Additional context
Sample questionnaire:

{
  "resourceType": "Questionnaire",
  "id": "3141",
  "url": "http://example.org/fhir/Questionnaire/1",
  "title": "Questionnaire with answerOption.valueString",
  "status": "draft",
  "item": [
    {
      "linkId": "FIRSTBC",
      "type": "choice",
      "text": "Indicate if this is first breast cancer or new cancer on contralateral or ipsilateral breast:",
      "answerOption": [
        {
          "valueString": "Primary tumor"
        },
        {
          "valueString": "New ipsilateral"
        },
        {
          "valueString": "New contralateral"
        }
      ]
    }
  ]
}
@vadi2 vadi2 changed the title answerOption.valueString crashes library answerOption.valueString crashes SDC library May 4, 2022
@vadi2
Copy link
Author

vadi2 commented May 4, 2022

An example where a valueInterger would be useful. While strings are dubious, because Codings are better instead, supporting integers is quite necessary:

        {
          "linkId": "EORTC-QLQ-Q29-Q30",
          "type": "group",
          "text": "For the following questions please select the number between 1 and 7 that best applies to you, with 1 = Very poor and 7 = Excellent.",
          "item": [
            {
              "linkId": "EORTCQLQC30_Q29",
              "type": "choice",
              "text": "How would you rate your overall health during the past week?",
              "required": true,
              "answerOption": [
                {
                  "valueInteger": 1
                },
                {
                  "valueInteger": 2
                },
                {
                  "valueInteger": 3
                },
                {
                  "valueInteger": 4
                },
                {
                  "valueInteger": 5
                },
                {
                  "valueInteger": 6
                },
                {
                  "valueInteger": 7
                }
              ]
            },

@Tarun-Bhardwaj Tarun-Bhardwaj added Triage type:bug Something isn't working P1 High priority issue effort:small Small effort - 2 days and removed Triage labels May 6, 2022
@jingtang10
Copy link
Collaborator

thanks very much for raising this @vadi2 - @santosh-pingle is working on this

@jingtang10
Copy link
Collaborator

this is related (but different) to #1098. @santosh-pingle please also see the fhir chat discussion: https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/Answer.20value.20set.20and.20answers.20as.20string

@santosh-pingle
Copy link
Collaborator

santosh-pingle commented May 17, 2022

@jingtang10
Can you please confirm whether QuestionnaireResponse will always have answerOption type as Coding, if type in Questionnaire Item is choice?

e.g

{
  "resourceType": "QuestionnaireResponse",
  "item": [
    {
      "linkId": "EORTCQLQC30_Q29",
      "answer": [
        {
          "valueCoding": {
            "code": "2",
            "display": "2"
          }
        }
      ]
    }
  ]
}

@jingtang10
Copy link
Collaborator

@jingtang10 Can you please confirm whether QuestionnaireResponse will always have answerOption type as Coding, if type in Questionnaire Item is choice?

e.g

{
  "resourceType": "QuestionnaireResponse",
  "item": [
    {
      "linkId": "EORTCQLQC30_Q29",
      "answer": [
        {
          "valueCoding": {
            "code": "2",
            "display": "2"
          }
        }
      ]
    }
  ]
}

so the answer type in the questionnaire response item needs to agree with the type of the questionnaire item. that's the only requirement as far as i can see.

additionally, the type of the answer option needs to agree with the type of the questionnaire item.

@jingtang10
Copy link
Collaborator

jingtang10 commented Jun 16, 2022

I think one consequence of this issue is that if we have a string/integer/date/time/whatever questionnaire item with answer options, we should render it using a "choice" widget such as dropdown. at the moment we pick the widget using the questionnaire type (e.g. if it's a string, we have text input, if it's date, we have a date picker) but it seems we need to have some logic to override that and say if any questionnaire item has answer options, we probably should use dropdown.

@vadi2 is this what other form fillers do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working
Projects
Archived in project
4 participants