Stream: questionnaire
Topic: Questionnaire prepopulation/populate
Corey Wen (Jun 01 2021 at 14:42):
Are there any examples on questionnaire population?
I've looked into using the prepopulate parameter for "http://lhncbc.github.io/lforms/" and read through "http://hl7.org/fhir/uv/sdc/2019May/populate.html" about Observation-based, FHIRPath-based, and StructureMap-based population but have not managed to get anything working.
Examples of any working questionnaire population would be appreciated.
Paul Lynch (Jun 01 2021 at 14:56):
There are a few examples of Observations-based and FHIRPath-based prepopulation in the "Featured Questionnaire" list in the app at https://lhcforms.nlm.nih.gov/sdc.
Corey Wen (Jun 01 2021 at 16:41):
I tried following the example by copying the "US Surgeon General family health portrait" questionnaire json, then using LHC-forms to render it after setting the FHIR context and prepoulate parameter for LHC-forms to true but the questionnaire did not get populated with the patient's first name and birthdate.
What could be the cause of this?
LForms.Util.setFHIRContext(client)
LForms.Util.addFormToPage(questionnaire, 'questionslhc', { prepopulate: true })
Paul Lynch (Jun 01 2021 at 16:58):
That looks correct.
1) What version of LHC-Forms are you using?
2) Are you sure the launchContext extension is in the questionnaire object? There is more than one version of the "US Surgeon General Family Health Portrait", and not all have it.
3) Is there any error or stack trace reported in the console?
Corey Wen (Jun 01 2021 at 17:35):
1) The version is 28.1.3
2) I used the questionnaire object by going to the "Show As" dropdown -> "FHIR Questionnaire (SDC)" which gave me the FHIR SDC Questionnaire Resource in json format. The json has an extension + url field which looks like the following
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext",
3) There is no error or stack trace reported in the console.
Paul Lynch (Jun 01 2021 at 17:57):
Did you include the FHIR support file for R4? (http://lhncbc.github.io/lforms/#fhirScripts). If so, could you create a jsfiddle that shows the problem?
Corey Wen (Jun 01 2021 at 18:38):
The FHIR support file for R4 is included. I tried to set up a jsfiddle but am not sure how to get it working so that it includes the EHR launch so that you can select a patient.
Paul Lynch (Jun 01 2021 at 18:47):
LForms.Util.setFHIRContext(FHIR.client({serverUrl: serverUrl, tokenResponse: { patient: patientId }}));
Paul Lynch (Jun 01 2021 at 18:49):
(so, you don't need the SMART launch.)
Corey Wen (Jun 01 2021 at 20:28):
Here is the jsfiddle, I would appreciate it if you could read through the comments. https://jsfiddle.net/dL2jokpv/1/
I managed to get the population to work but I don't quite understand why it works in this manner.
Initially I was using the questionnaire resource that I copy pasted from "https://lhcforms.nlm.nih.gov/sdc", from the "Show As" dropdown -> "FHIR Questionnaire from Server" or "FHIR Questionnaire (SDC)"
image.png
Neither of these resources when used as a json resource were prepopulated in the original application.
Then, I set up the jsfiddle and found out the questionnaire was successfully populated using the "fhirQuestionnaireSDC" but not the "fhirQuestionnaireFromServer".
After, I tried fetching the questionnaire resource from the URL"https://lforms-fhir.nlm.nih.gov/baseR4/Questionnaire/54127-6-x" and this was also able to populate in the jsfiddle. Then I tested fetching from that URL to use in the original application and it was able to populate.
I'm unsure as to why the two resources (fetching from URL/"fhirQuestionnaireSDC") work in the jsfiddle but only fetching from the URL works in the original application for populating.
Additionally, the resulting resource fetched from the URL "https://lforms-fhir.nlm.nih.gov/baseR4/Questionnaire/54127-6-x" is very similar to the "fhirQuestionnaireFromServer" resource with only a few differences on certain lines, so I'm unsure as to why one works and the other does not.
The only differences were version and the left (fhirQuestionnaireFromServer) had extensions for observationExtract, while the right (fetched from URL) did not. Everything else seemed to be the same.
image.png
image.png
Paul Lynch (Jun 01 2021 at 21:14):
When you choose the "FHIR Questionnaire (SDC)" option you are getting a new export to Questionnaire of what was imported into LHC-Forms, so there could be differences, but both should work the same. I will take a look.
Paul Lynch (Jun 01 2021 at 22:54):
I see the problem. The reason we tag LHC-Forms' output with "lformsVersion" is because occasionally there is a breaking change in the output. The Questionnaire at https://lforms-fhir.nlm.nih.gov/baseR4/Questionnaire/54127-6-x was generated by LHC-Forms 25.0.0. In version 29.0.0, the URI for the launchContext extension was updated to match what is currently at build.fhir.org. So, the original problem you were having was that you were using the 29.0.0 URI with a 28.1.3 LHC-Forms. The SDC Questionnaire App at https://lhcforms.nlm.nih.gov/sdc handles these problems by using our lforms-updater package, which relies on the version number in the tag to know what updates to apply to match the application's version.
Paul Lynch (Jun 01 2021 at 23:02):
So, two options:
1) If you want your Questionnaire definition to be up-to-date with the SDC IG at build.fhir.org (well, more up to date), update your lforms package to 29+, and use the current launchContext URI.
2) If you don't care about being up to date or the small bug fixes in 29.0.3, stay at 28.1.3, and use the older launchContext URI (which you see in https://lforms-fhir.nlm.nih.gov/baseR4/Questionnaire/54127-6-x)
Note: I am currently working on updating the initialExpression URI, which somehow was missed when updating the launchContext URI. So, there will be another breaking change for that one, and another release of lforms-updater. (BTW, in case you are wondering, that package only works to upgrade, and won't downgrade to earlier versions.)
Last updated: Apr 12 2022 at 19:14 UTC