LHNCBC / lforms-fhir-app

A SMART on FHIR app that uses lforms widget to handle Questionnaire and QuestionnaireResponse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom valueset+codesystem not recognised?

vadi2 opened this issue · comments

I've got a question with a #choice answer that's tied to a SNOMED codes+a few custom ones that weren't available in SNOMED. I pointed the app to my personal fhir server where I host the codesystem, valueset, and the questionnaire that uses it and while the questionnaire is rendered fine, the list of choices for the question is not - and there's this stacktrace:

TypeError: e[u] is undefined
    prefetchList https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    initialize https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    n https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    link https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $digest https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    showSavedQuestionnaire https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
39c705a4.vendor.js:1:386539
    t https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    get https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $digest https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    showSavedQuestionnaire https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1

Is this a known issue / anything I can work around?

Resources in question -
Archive.zip

Our current test Questionnaire for answerValueSet, https://github.com/lhncbc/lforms/blob/master/test/data/R4/fhir-context-q.json, labels each case with an itemControl extension to mark it either as a drop-down list (i.e., a short list that can be fully expanded) or an autocomplete list (which shows a list of matches as the user types). It is possible that we are not supporting the case where you don't include either itemControl value. Could you try adding one of those values for itemControl and see if that fixes things? The other possible problem is that the ValueSet expansion is erroring out or not returning anything. Check the network tab and see if you see an "expand" URL and whether you get something back. It should be doing an expansion for any items marked with itemControl "drop-down", and for items of type "autocomplete" it will wait until the user types in the field.

Could you try adding one of those values for itemControl and see if that fixes things?

I dropped it in like this:

   {
      "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"
          }
        }
      ],
      "linkId": "ComorbiditiesSACQ",
      "type": "choice",
      "text": "Have you been told by a doctor that you have any of the following?",
      "answerValueSet": "https://connect.ichom.org/fhir/ValueSet/SACQ-patient-comorbidity-history",
      "required": true,
      "repeats": true
    },

But it didn't seem to help:

Screenshot 2021-12-07 at 1 55 19 PM

The other possible problem is that the ValueSet expansion is erroring out or not returning anything.

That looks all good:

Screenshot 2021-12-07 at 1 57 16 PM

Although I notice the stacktrace is different:

TypeError: e[u] is undefined
    prefetchList https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    initialize https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    n https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    link https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $digest https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    showSavedQuestionnaire https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    promise callback*g.showSavedQuestionnaire/< https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    i https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    completeTask https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    i https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    setTimeout handler*yn/u.defer https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    e https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    showSavedQuestionnaire https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    fn https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js line 1 > Function:4
    t https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $eval https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    compile https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    dispatch https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    handle https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    add https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    Te https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    each https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    each https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    Te https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    on https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    compile https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    Re https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    le https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    V https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    R https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    K https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    Z https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    e https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    d https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    compile https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    watchCollection https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $digest https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    <anonymous> https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    $broadcast https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    getAllQ https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    promise callback*u.getAllQ https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    confirmAndCloseDialog https://lhcforms.nlm.nih.gov/lforms-fhir-app/9a407f5d.app.js:1
    fn https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js line 1 > Function:4
    t https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $eval https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    $apply https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    compile https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
    dispatch https://lhcforms.nlm.nih.gov/lforms-fhir-app/39c705a4.vendor.js:1
39c705a4.vendor.js:1:386539

Any ideas we could try?

Could you try replacing the answerValueSet with "http://terminology.hl7.org/ValueSet/v3-MessageWaitingPriority" ? That is the corresponding example that is working in the questionnaire above. I wonder if there is something about your ValueSet that LForms is having issues with. I can see from your screenshot that it is getting the expansion back; I don't know what the problem could be.

That valueset works beautifully - here's is a screen recording where I try both (a bit lengthy).

As soon as I switch it back to mine, the showSavedQuestionnaire appears when rendering the questionnaire.

Here are the two valueset expansions, would you know what is the app looking for in particular?

comorbidity-history-expansion.txt

messagewaitingpriority-expansion.txt

I suspect the problem is that some of the codes in the comorbidity expansion are missing a "display" property.

That was it!

You'd be surprised at the amount of servers I had to go through - the intersection of those that return 'display' on $expand, support $expand by a url, and support Questionnaires is surprisingly low (yours does support it - I just missed it due to operator error).

Should I put in an issue to keep track that the optional display is required? I agree it's important for the human, but some codes are self-explanatory like in my code system, so showing something would be better than misrendering the questionnaire.

Certainly the current behavior of throwing an obscure exception without explanation is not helpful. At the very least, an error message (even to the console) would have made the problem understandable. I think it is odd that $expand would not return 'display', but it sounds that is a common problem, and in cases where the code is meaningful, perhaps it would be useful to go ahead and display it. I suppose if a Questionnaire author was wondering why non-meaningful codes were showing up rather than display strings, it would not take long to see that the problem was that the display strings were not there. The easy solution would be for us to copy the code into the missing display, but that would affect the Coding in the QuestionnaireResponse, so probably we have to make more extensive modifications to leave the Codings alone but show either the 'display' or the 'code'. I am going to create an internal tracker item, and refer to this issue. If you would like to open a separate issue here for that request so you can be notified when that is in place, feel free. It might be some months though, as we have a backlog of needed things.

If you do file an issue, the repository to file it on would be https://github.com/lhncbc/lforms, the widget which this app uses.

I agree with the solution, thanks for considering it!