google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
465 stars 246 forks source link

Initiate new screener encounter #625

Closed fredhersch closed 2 years ago

fredhersch commented 2 years ago

User story As a HCW I can select to initiate a new sceener for a patient generating a new encounter and relevant observations

Steps:

Alt path:

Additional information

santosh-pingle commented 2 years ago

700 crash while saving extracted resources on ResourcesIndexer.

santosh-pingle commented 2 years ago

Just for reference, @jingtang10 asked to try below approach to check whether ui alignment issues get fixed.

to continue with the definition based extraction discussion, why can't we have hidden question groups and each has enable when expression that evaluates to true if a certain answer is given. This way we still keep a single question for the multiple choices. and the groups will be enabled respectively if certain options are ticked in that single question. and if a group is enabled (albeit hidden) we will extract a separate observation.

santosh-pingle commented 2 years ago

I will start working on above changes.

santosh-pingle commented 2 years ago

@jingtang10 I am trying out above suggested approach on symptom question item to just check whether its possible or not. Though, I do have couple of doubts here to implement it, but considering to form questionnaire json first with those modifications, so that it will help me to ask those questions better way.

santosh-pingle commented 2 years ago

@jingtang10

Tried out 2nd approach as mentioned above on symptoms questionnaire item to align ui.

{
  "title": "Screener",
  "status": "active",
  "version": "0.0.1",
  "publisher": "Fred Hersch (fredhersch@google.com)",
  "resourceType": "Questionnaire",
  "subjectType": [
    "Encounter"
  ],
  "extension": [
    {
      "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext",
      "valueExpression": {
        "language": "application/x-fhir-query",
        "expression": "Encounter",
        "name": "encounter"
      }
    }
  ],
  "item": [
    {
      "text": "Symptoms",
      "linkId": "1.0.0",
      "type": "group",
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/questionnaire-item-control",
                "code": "page",
                "display": "Page"
              }
            ],
            "text": "Page"
          }
        }
      ],
      "item": [
        {
          "text": "In the past two weeks have you experienced ANY of these symptoms?",
          "type": "choice",
          "linkId": "1.1.0",
          "required": true,
          "repeats": true,
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
              "valueCodeableConcept": {
                "coding": [
                  {
                    "system": "http://hl7.org/fhir/questionnaire-item-control",
                    "code": "drop-down",
                    "display": "Drop down"
                  }
                ],
                "text": "Drop down"
              }
            }
          ],
          "answerOption": [
            {
              "valueCoding": {
                "code": "386661006",
                "display": "Fever",
                "system": "http://snomed.info/sct"
              }
            },
            {
              "valueCoding": {
                "code": "13645005",
                "display": "Shortness of breath",
                "system": "http://snomed.info/sct"
              }
            },
            {
              "valueCoding": {
                "code": "49727002",
                "display": "Cough",
                "system": "http://snomed.info/sct"
              }
            },
            {
              "valueCoding": {
                "code": "44169009",
                "display": "Loss of smell",
                "system": "http://snomed.info/sct"
              }
            }
          ]
        },
        {
          "linkId": "1.2.0",
          "type": "group",
          "definition": "http://hl7.org/fhir/StructureDefinition/Observation",
          "extension": [
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext",
              "valueExpression": {
                "language": "application/x-fhir-query",
                "expression": "Observation",
                "name": "fever"
              }
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden",
              "valueBoolean": true
            }
          ],
          "enableWhen": [
            {
              "question": "1.1.0",
              "operator": "=",
              "answerCoding": {
                "code": "386661006",
                "display": "Fever",
                "system": "http://snomed.info/sct"
              }
            }
          ],
          "item": [
            {
              "type": "choice",
              "linkId": "1.2.1",
              "required": true,
              "repeats": true,
              "definition": "http://hl7.org/fhir/StructureDefinition/Observation#Observation.code",
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "drop-down",
                        "display": "Drop down"
                      }
                    ],
                    "text": "Drop down"
                  }
                }
              ],
              "answerOption": [
                {
                  "valueCoding": {
                    "code": "386661006",
                    "display": "Fever",
                    "system": "http://snomed.info/sct"
                  },
                  "initialSelected": true
                }
              ]
            }
          ]
        },
        {
          "linkId": "1.3.0",
          "type": "group",
          "definition": "http://hl7.org/fhir/StructureDefinition/Observation",
          "extension": [
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext",
              "valueExpression": {
                "language": "application/x-fhir-query",
                "expression": "Observation",
                "name": "breathShortness"
              }
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden",
              "valueBoolean": true
            }
          ],
          "enableWhen": [
            {
              "question": "1.1.0",
              "operator": "=",
              "answerCoding": {
                "code": "13645005",
                "display": "Shortness of breath",
                "system": "http://snomed.info/sct"
              }
            }
          ],
          "item": [
            {
              "type": "choice",
              "linkId": "1.3.1",
              "required": true,
              "repeats": true,
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "drop-down",
                        "display": "Drop down"
                      }
                    ],
                    "text": "Drop down"
                  }
                }
              ],
              "definition": "http://hl7.org/fhir/StructureDefinition/Observation#Observation.code",
              "answerOption": [
                {
                  "valueCoding": {
                    "code": "13645005",
                    "display": "Shortness of breath",
                    "system": "http://snomed.info/sct"
                  },
                  "initialSelected": true
                }
              ]
            }
          ]
        },
        {
          "linkId": "1.4.0",
          "type": "group",
          "definition": "http://hl7.org/fhir/StructureDefinition/Observation",
          "extension": [
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext",
              "valueExpression": {
                "language": "application/x-fhir-query",
                "expression": "Observation",
                "name": "cough"
              }
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden",
              "valueBoolean": true
            }
          ],
          "enableWhen": [
            {
              "question": "1.1.0",
              "operator": "=",
              "answerCoding": {
                "code": "49727002",
                "display": "Cough",
                "system": "http://snomed.info/sct"
              }
            }
          ],
          "item": [
            {
              "type": "choice",
              "linkId": "1.4.1",
              "required": true,
              "repeats": true,
              "definition": "http://hl7.org/fhir/StructureDefinition/Observation#Observation.code",
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "drop-down",
                        "display": "Drop down"
                      }
                    ],
                    "text": "Drop down"
                  }
                }
              ],
              "answerOption": [
                {
                  "valueCoding": {
                    "code": "49727002",
                    "display": "Cough",
                    "system": "http://snomed.info/sct"
                  },
                  "initialSelected": true
                }
              ]
            }
          ]
        },
        {
          "linkId": "1.5.0",
          "type": "group",
          "definition": "http://hl7.org/fhir/StructureDefinition/Observation",
          "extension": [
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext",
              "valueExpression": {
                "language": "application/x-fhir-query",
                "expression": "Observation",
                "name": "lossOfSmell"
              }
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden",
              "valueBoolean": true
            }
          ],
          "enableWhen": [
            {
              "question": "1.1.0",
              "operator": "=",
              "answerCoding": {
                "code": "44169009",
                "display": "Loss of smell",
                "system": "http://snomed.info/sct"
              }
            }
          ],
          "item": [
            {
              "type": "choice",
              "linkId": "1.5.1",
              "required": true,
              "repeats": true,
              "definition": "http://hl7.org/fhir/StructureDefinition/Observation#Observation.code",
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "drop-down",
                        "display": "Drop down"
                      }
                    ],
                    "text": "Drop down"
                  }
                }
              ],
              "answerOption": [
                {
                  "valueCoding": {
                    "code": "44169009",
                    "display": "Loss of smell",
                    "system": "http://snomed.info/sct"
                  },
                  "initialSelected": true
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
{
  "resourceType": "QuestionnaireResponse",
  "item": [
    {
      "linkId": "1.0.0",
      "item": [
        {
          "linkId": "1.1.0",
          "answer": [
            {
              "valueCoding": {
                "system": "http://snomed.info/sct",
                "code": "44169009",
                "display": "Loss of smell"
              }
            }
          ]
        },
        {
          "linkId": "1.2.0",
          "item": [
            {
              "linkId": "1.2.1"
            }
          ]
        },
        {
          "linkId": "1.3.0",
          "item": [
            {
              "linkId": "1.3.1"
            }
          ]
        },
        {
          "linkId": "1.4.0",
          "item": [
            {
              "linkId": "1.4.1"
            }
          ]
        },
        {
          "linkId": "1.5.0",
          "item": [
            {
              "linkId": "1.5.1"
            }
          ]
        }
      ]
    }
  ]
}

It looks like below edge cases are not supported in sdc library when ui get generated and answers get captured from question

santosh-pingle commented 2 years ago

Just for reference, @jingtang10 asked to try below approach to check whether ui alignment issues get fixed.

to continue with the definition based extraction discussion, why can't we have hidden question groups and each has enable when expression that evaluates to true if a certain answer is given. This way we still keep a single question for the multiple choices. and the groups will be enabled respectively if certain options are ticked in that single question. and if a group is enabled (albeit hidden) we will extract a separate observation.

@jingtang10 @fredhersch @aditya-07

I had tried this approach. Provided feedback, you can refer https://github.com/google/android-fhir/issues/625#issuecomment-900363679 for more information. To proceed further, it is required to implement/debug missing edge cases which are not implemented yet. https://github.com/google/android-fhir/issues/625#issuecomment-900363679. Please let me know your input on it. Thanks!

santosh-pingle commented 2 years ago

In parallel, I will start working on Start documentation for the for issue #625 #724

jingtang10 commented 2 years ago

thanks @santosh-pingle for sharing the questionnaire - it looks right to me.

santosh-pingle commented 2 years ago

As mentioned in https://github.com/google/android-fhir/issues/625#issuecomment-900363679

I will create separate issue for it, just for reference. Found root cause(callback issue), will create PR for this issue.

santosh-pingle commented 2 years ago

736 On checkbox selection, enablewhen does not enable question item though question match answer option in it.

santosh-pingle commented 2 years ago

InitialSelected: true, does not select the checkbox answer option. -> Alternative way is to provide initial value coding.

santosh-pingle commented 2 years ago

739 On checkbox selection, enablewhen does not enable question item though question match answer option in it.

santosh-pingle commented 2 years ago

@jingtang10 Working on Question item was not hidden after adding hidden extension in item in questionnaire. #683 Will try to push PR in second half of today.

As mentioned in #625 (comment), it is one of the edge case which needs fix to hide the question item.

santosh-pingle commented 2 years ago

PR #742 (hidden extension to hide question item.)

santosh-pingle commented 2 years ago

@jingtang10 @fredhersch @aditya-07

Found a new edge case which is not supported yet by sdk. If the question item has enablewhen clause, and it also has initial coding value, in that case question item with initial coding value gets added to the questionnaire response though enablewhen clause is false.

Just consider the symptoms question as an example. Symptoms main question has 4 answer options as checkboxes. None of the answer options are selected initially. There are hidden question items with initial coding value and enablewhen clause. (enable clause is false) Bug = > all hidden question answer options with initial coding value are added to question response.

jingtang10 commented 2 years ago

@santosh-pingle can you send a fix in the view model?

santosh-pingle commented 2 years ago

I am working on it. Thanks!

santosh-pingle commented 2 years ago

PR #755 and PR #742 are merged. Now, this issue is unblocked. I will continue 2nd approach to fix ui alignment issue as mentioned in https://github.com/google/android-fhir/issues/625#issuecomment-899469983.

santosh-pingle commented 2 years ago

@santosh-pingle let's leave this for now. Want to get the observations for risk factors, symptoms and vital signs working first.

@fredhersch Currently, we are modifying questionnaire json for symptoms, medical history, temperature, pulse oximetry, and heart rate as per PR #755 and PR #742 to fix ui alignment issue. We can refer https://github.com/google/android-fhir/issues/625#issuecomment-899469983 for more information.

But we have not started risk factors and immunization yet, are they still in scope? (are we going to work on it once above ui alignment issues get fixed?)

santosh-pingle commented 2 years ago

@jingtang10 @fredhersch @Tarun-Bhardwaj @aditya-07

By end of PR #785 ui alignment issues and resource extraction of Symptoms, Risk Factors, Medical History, Temperature, Pulse Oximetry, and Heart rate will be fixed.

Pending action item : https://github.com/google/android-fhir/issues/625#issuecomment-890770164 Immunization questionnaire is still pending, could you please confirm whether it's still in scope?

fredhersch commented 2 years ago

Thanks @santosh-pingle, let's close the issue for now. We can add Immunizations later