LHNCBC / lforms

See the project website at http://lhncbc.github.io/lforms/, or view the demo website at https://lhcforms.nlm.nih.gov/lhcforms.
Other
107 stars 56 forks source link

Unable to map FHIR enableWhen operator: undefined #27

Closed yunwwang closed 4 years ago

yunwwang commented 4 years ago

I got this error when import a FHIR R4 Questionnaire resource with enableWhen element. Does LHC widget support Questionnaire.item.enableWhen?

plynchnlm commented 4 years ago

Yes, although we just fixed a problem with enableWhen in 20.2.1. What version of LForms are you using? Can you attach a sample Questionnaire that demonstrates the problem?

yunwwang commented 4 years ago

I used the one demo app at https://lhcforms.nlm.nih.gov/lhcforms Here is the questionnaire: { "resourceType": "Questionnaire", "id": "urn:hl7:davinci:crd:home-oxygen-questionnaire_2-r4", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/cqif-questionnaire", "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-questionnaire-r4" ] }, "title": "Home Oxygen Therapy", "status": "draft", "subjectType": [ "Patient" ], "date": "2019-12-06", "publisher": "Da Vinci DTR", "extension": [{ "url": "http://hl7.org/fhir/StructureDefinition/cqif-library", "valueReference": { "reference": "urn:hl7:davinci:crd:library-oxygen-therapy-prepopulate-r4" } }, { "url": "http://hl7.org/fhir/StructureDefinition/cqif-library", "valueReference": { "reference": "urn:hl7:davinci:crd:library-basic-patient-info-prepopulate-r4" } }, { "url": "http://hl7.org/fhir/StructureDefinition/cqif-library", "valueReference": { "reference": "urn:hl7:davinci:crd:library-basic-practitioner-info-prepopulate-r4" } } ], "contained": [{ "resourceType": "ValueSet", "id": "gender", "name": "Gender", "status": "draft", "description": "Gender", "compose": { "include": [{ "concept": [{ "code": "male", "display": "Male" }, { "code": "female", "display": "Female" }, { "code": "other", "display": "Other" } ] }] } }], "item": [{ "linkId": "1", "text": "Patient Information", "type": "group", "item": [{ "linkId": "1.1", "text": "Last Name but Different This Time", "type": "string", "required": true }, { "linkId": "1.2", "text": "First Name", "type": "string", "required": true }, { "linkId": "1.3", "text": "Middle Initial", "type": "string", "required": true }, { "linkId": "1.4", "text": "Date Of Birth", "type": "date", "required": true }, { "linkId": "1.5", "text": "Gender", "type": "choice", "required": true, "options": { "reference": "#gender" } }, { "linkId": "1.6", "text": "Medicare ID", "type": "string", "required": true } ] }, { "linkId": "2", "text": "Provider who is performing face-to-face evaluation", "type": "group", "item": [{ "linkId": "2.1", "text": "Last Name", "type": "string", "required": true }, { "linkId": "2.2", "text": "First Name", "type": "string", "required": true }, { "linkId": "2.3", "text": "Middle Initial", "type": "string", "required": true }, { "linkId": "2.4", "text": "NPI", "type": "string", "required": true }, { "linkId": "2.5", "text": "Date of Face-To-Face Evaluation", "type": "date", "required": true } ] }, { "linkId": "3", "text": "Coverage Requirements", "type": "group", "item": [{ "linkId": "3.1", "text": "Relevant Patient Diagnoses (conditions that might be expected to improve with oxygen therapy)", "type": "open-choice", "required": true, "repeats": true, "option": [{ "valueCoding": { "code": "COPD" } }, { "valueCoding": { "code": "Bronchiectasis" } }, { "valueCoding": { "code": "Hypoxemia" } }, { "valueCoding": { "code": "Diffuse interstitial lung disease" } }, { "valueCoding": { "code": "Cystic fibrosis" } }, { "valueCoding": { "code": "Pulmonary neoplasm" } }, { "valueCoding": { "code": "Erythrocytosis" } }, { "valueCoding": { "code": "Pulmonary hypertension" } }, { "valueCoding": { "code": "Recurring CHF d/t Cor Pulmonale" } } ] }, { "linkId": "3.2", "text": "Arterial oxygen saturation (Patient on room air while at rest and awake when tested)", "type": "quantity", "required": false }, { "linkId": "3.3", "text": "Arterial Partial Pressure of Oxygen (PO2) (Patient on room air while at rest and awake when tested)", "type": "quantity", "required": false }, { "linkId": "3.4", "text": "Arterial oxygen saturation (Patient tested during exercise)", "type": "quantity", "required": false }, { "linkId": "3.5", "text": "Arterial Partial Pressure of Oxygen (PO2) (Patient tested during exercise)", "type": "quantity", "required": false }, { "linkId": "3.6", "text": "Is there a documented improvement of hypoxemia during exercise with oxygen?", "type": "boolean", "required": false }, { "linkId": "3.7", "text": "Is the patient mobile within the home? ", "type": "boolean", "required": false, "enableWhen": [ { "question": "5.1b", "answerBoolean": true } ] }, { "linkId": "3.8", "text": "Does the patient have dependent edema due to congestive heart failure?", "type": "boolean", "required": false, "enableWhen": [ { "question": "3.2", "answerQuantity": { "value": 89, "unit": "%" } } ] } ] }, { "linkId": "4", "text": "Prescribed Use", "type": "group", "item": [{ "linkId": "4.1", "text": "Start date", "type": "date", "required": true }, { "linkId": "4.2", "text": "Length of need: (months) (99 = lifetime)", "type": "integer", "required": false }, { "linkId": "4.4", "text": "Peak Flow Rate", "type": "group", "item": [{ "linkId": "4.4.1", "text": "LPM", "type": "integer", "required": true }, { "linkId": "4.4.2", "text": "oxygen %", "type": "integer", "required": true } ] }, { "linkId": "4.4b", "text": "Since > 4 LPM prescribed, enter arterial oxygen saturation or PO2 while patient was on 4 LPM in stable state.", "type": "quantity", "required": true, "enableWhen": [ { "operator": ">", "question": "4.4.1", "answerInteger": 4 } ] }, { "linkId": "4.5", "text": "Average Flow Rate", "type": "group", "item": [{ "linkId": "4.5.1", "text": "LPM", "type": "integer", "required": true }, { "linkId": "4.5.2", "text": "oxygen %", "type": "integer", "required": true } ] }, { "linkId": "4.6", "text": "Frequency of use (choose all that apply)", "type": "open-choice", "required": true, "repeats": true, "option": [{ "valueCoding": { "code": "At rest and awake" } }, { "valueCoding": { "code": "During exertion" } }, { "valueCoding": { "code": "During sleep" } } ] } ] }, { "linkId": "5", "text": "Oxygen Supply Order Details", "type": "group", "item": [{ "linkId": "5.1", "text": "Current Order Description", "type": "string", "readOnly": true }, { "linkId": "5.1b", "text": "Current Order Is For A Portable Device", "type": "boolean", "readOnly": true }, { "linkId": "5.2", "text": "Type", "type": "choice", "required": true, "option": [{ "valueCoding": { "code": "Liquid" } }, { "valueCoding": { "code": "Compressed Gas" } }, { "valueCoding": { "code": "Concentrator" } } ] }, { "linkId": "5.3", "text": "Means of oxygen delivery and accessories", "type": "open-choice", "required": true, "repeats": true, "option": [{ "valueCoding": { "code": "Nasal cannula" } }, { "valueCoding": { "code": "Non-rebreather" } }, { "valueCoding": { "code": "Ventilator" } }, { "valueCoding": { "code": "Mask" } }, { "valueCoding": { "code": "PAP bleed in" } }, { "valueCoding": { "code": "Oxygen conserving device" } }, { "valueCoding": { "code": "High flow oxygen therapy" } } ] }, { "linkId": "5.4", "text": "Type of order", "type": "choice", "required": true, "option": [{ "valueCoding": { "code": "Initial or original order for certification" } }, { "valueCoding": { "code": "Change in status" } }, { "valueCoding": { "code": "Revision or change in equipment" } }, { "valueCoding": { "code": "Replacement" } } ] }, { "linkId": "5.5", "text": "Reason for Change in Status", "type": "open-choice", "required": true, "enableWhen": [ { "question": "5.4", "answerCoding": { "code": "Change in status" } } ], "option": [{ "valueCoding": { "code": "Patient relocated" } }, { "valueCoding": { "code": "Different supplier" } } ] } ] } ] }

plynchnlm commented 4 years ago

It looks to me like the problem is that your enableWhen's are missing the operator field, which per the R4 spec, is required.

Also, if you fix that, then presently you would run into a bug in lforms which we have fixed but the fix is not yet in that demo system (which was updated around 2/26). The fix is present in our SDC app, at https://lhcforms.nlm.nih.gov/sdc, so I recommend you test your form there. The "upload" button at that app does not save the form to the FHIR server; it doesn't get saved unless you use the "save" menu. If you do save the form, please note that we reset that FHIR server weekly.

We are also at this moment fixing a bug with enableWhen.answerCoding, but I don't think that will affect your form since you have not specified a "system".

yunwwang commented 4 years ago

I created a new sample Questionnaire and tried to upload to https://lhncbc.github.io/lforms-fhir-app/. I noticed that it only works when the target item is dat the same group. For example, this works { "resourceType": "Questionnaire", "id": "2", "title": "Enable When Test", "status": "draft", "subjectType": [ "Patient" ], "date": "2019-12-06", "item": [ { "linkId": "1", "text": "First Item", "type": "group", "item": [ { "linkId": "1.1.1", "text": "checkbox 1", "type": "boolean" }, { "linkId": "1.2", "text": "Should enable when 1.1.1 is true", "type": "string", "enableWhen": [ { "question": "1.1.1", "operator": "=", "answerBoolean": true } ] } ] } ] } but this does NOT (error: TypeError: Cannot read property '_skipLogicTargets' of null) { "resourceType": "Questionnaire", "id": "2", "title": "Enable When Test", "status": "draft", "subjectType": [ "Patient" ], "date": "2019-12-06", "item": [ { "linkId": "1", "text": "First Item", "type": "group", "item": [ { "linkId": "1.1", "text": "Checkbox Group", "type": "group", "item": [ { "linkId": "1.1.1", "text": "checkbox 1", "type": "boolean" }, { "linkId": "1.1.2", "text": "checkbox 2", "type": "boolean" } ] }, { "linkId": "1.2", "text": "Should enable when 1.1.1 is true", "type": "string", "enableWhen": [ { "question": "1.1.1", "operator": "=", "answerBoolean": true } ] } ] } ] }

plynchnlm commented 4 years ago

In our implementation, the "question" linkID can be in the same group, one of the answer groups, or the immediate children of one of the ancestors. (In other words, siblings of ancestors, but not children of siblings of ancestors.) I think this was done to optimize the search and to avoid problems with repeating groups. Does that limitation cause a problem for what you need to do?

yunwwang commented 4 years ago

I have maybe one or two falling in that category. I will see if I can re group them.