Closed GitHubUNCStudent closed 5 years ago
I saved your form definition data as a JSON file and uploaded it to our demo system (https://lhcforms.nlm.nih.gov/). The form is rendered correctly and the captured data also appears to be correct. One of the ways to get user data out of the widget is to call LForms.Util.getFormData(). Could you show me what was involved when you clicked the "Submit" button in your application?
Hi Ye,
What I am doing is:
Within the Javascript of my shortqstn.html page,
A. Posting the form data via:
Diane,
The LHC-Forms widget does not support POSTing data directly to back-end server. You need to get the data out of the widget using JavaScript code (by calling LForms.Util.getFormData, for example). The resulting data is a JSON object, which can be processed before and/or after you send it to the back-end. See details here: http://lhncbc.github.io/lforms/.
I cannot see the shortqstn. It returns an error message: "Method Not Allowed". I guess it is only allowed within your dev environment.
You can get FHIR QuestionnaireResponse from the LHC-Forms widget, by call LForms.Util.getFormFHIRData. Currently we partially support DSTU 3 and R4 and SDC Questionnaire. Again, you need JavaScript code to retrieve the data from the widget, and process it whatever you want. The HTML version of your form does not matter here if you want to use LHC-Forms. A JSON file with the form definition data you posted should just work with the LHC-Forms widget.
Hope it helps.
Ye
Is this (below in large font in green color) where I would place the LForms.Util.getFormFHIRData method? Thanks for the explanation that direct POST to the backend is not supported.
Diane Rodden MSIS candidate 2019 School of Information and Library Science University of North Carolina at Chapel Hill mail to: rodden@live.unc.eduhttp://mail%20to:%20rodden@live.unc.edu
From: Ye Wang notifications@github.com Sent: Monday, July 29, 2019 1:54 PM To: lhncbc/lforms lforms@noreply.github.com Cc: Rodden, Diane Judith rodden@live.unc.edu; Author author@noreply.github.com Subject: Re: [lhncbc/lforms] dataTypes CNE and CWE not transmitting user answers (#13)
Diane,
The LHC-Forms widget does not support POSTing data directly to back-end server. You need to get the data out of the widget using JavaScript code (by calling LForms.Util.getFormData, for example). The resulting data is a JSON object, which can be processed before and/or after you send it to the back-end. See details here: http://lhncbc.github.io/lforms/.
I cannot see the shortqstn. It returns an error message: "Method Not Allowed". I guess it is only allowed within your dev environment.
You can get FHIR QuestionnaireResponse from the LHC-Forms widget, by call LForms.Util.getFormFHIRData. Currently we partially support DSTU 3 and R4 and SDC Questionnaire. Again, you need JavaScript code to retrieve the data from the widget, and process it whatever you want. The HTML version of your form does not matter here if you want to use LHC-Forms. A JSON file with the form definition data you posted should just work with the LHC-Forms widget.
Hope it helps.
Ye
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/lhncbc/lforms/issues/13?email_source=notifications&email_token=AMWYACFHHJLKA2WYSUSHPGTQB4VEVA5CNFSM4IHPUHPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BQAHI#issuecomment-516096029, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMWYACC5Y4V4PVJEEFXPBDDQB4VEVANCNFSM4IHPUHPA.
You could change your submit button to type="button" and add an onclick="..." attribute. The "..." would be the call to get the FHIR data, and then code to send it back to your server (probably with an AJAX call). Getting the FHIR data would look like "var qr = LForms.Util.getFormFHIRData('QuestionnaireResponse', 'R4')' after which variable "qr" will have the FHIR QuestionnaireResponse structure. (I am assuming you wanted the output in FHIR.) As Ye mentioned, getFormFHIRData is documented at http://lhncbc.github.io/lforms/#retrieving-fhir-data. To convert that to a JSON string, you might use "var qrJSON = JSON.stringify(qr, null, 2)". Do you know how to send qrJSON back to your server via AJAX? You could alternatively stuff it into a field value and post.
I worked on this last night and all today, but it is not working.
I have attached my html with the Javascript. Right now, I am just trying to get the data from the form into the variable qr without POSTING it anywhere. I have changed the button as suggested by you to what is shown below in large green font.
I am supposed to be demonstrating the LHC-Forms solution to executive leadership in my organization on Thursday, so I am in a panic.
My Firefox console is showing these 2 error messages. Why am I getting the error LForms is not defined?:
ReferenceError: qr is not defined
Diane Rodden MSIS candidate 2019 School of Information and Library Science University of North Carolina at Chapel Hill mail to: rodden@live.unc.eduhttp://mail%20to:%20rodden@live.unc.edu
From: plynchnlm notifications@github.com Sent: Monday, July 29, 2019 6:08 PM To: lhncbc/lforms lforms@noreply.github.com Cc: Rodden, Diane Judith rodden@live.unc.edu; Author author@noreply.github.com Subject: Re: [lhncbc/lforms] dataTypes CNE and CWE not transmitting user answers (#13)
You could change your submit button to type="button" and add an onclick="..." attribute. The "..." would be the call to get the FHIR data, and then code to send it back to your server (probably with an AJAX call). Getting the FHIR data would look like "var qr = LForms.Util.getFormFHIRData('QuestionnaireResponse', 'R4')' after which variable "qr" will have the FHIR QuestionnaireResponse structure. (I am assuming you wanted the output in FHIR.) As Ye mentioned, getFormFHIRData is documented at http://lhncbc.github.io/lforms/#retrieving-fhir-data. To convert that to a JSON string, you might use "var qrJSON = JSON.stringify(qr, null, 2)". Do you know how to send qrJSON back to your server via AJAX? You could alternatively stuff it into a field value and post.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/lhncbc/lforms/issues/13?email_source=notifications&email_token=AMWYACBGIY2AI4B7CTIYMTLQB5S55A5CNFSM4IHPUHPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3CEZ3Q#issuecomment-516181230, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMWYACHL6YQEKXSIYDTPZI3QB5S55ANCNFSM4IHPUHPA.
<!DOCTYPE html>
|
|
|
Study Submission Form Demo
The script “lformsFHIR.min.js” depends on the script “lforms.min.js”, so you should reverse the order of those tags. That is likely the cause of “LForms not deined”.
Also, in your "onclick" handler, "var qr" establishes a local variable, so later when you are trying to log it, the variable is not accessible. You could put it on the window varaible in onclick (window.qr = ... instead of var qr = ...).
I can see there is a need for a small example of using the FHIR part to get people started. We do have an app at https://lhncbc.github.io/lforms-fhir-app/, which is open-source (https://github.com/lhncbc/lforms-fhir-app) but that is probably not simple enough to be a good example.
I created a small example here https://jsfiddle.net/lforms/8f754jhy/15/ which should hopefully get you unstuck.
Note that in that example the form is in FHIR Questionnaire format (which is one of the output formats the form builder generates for you), so there is an extra call to convert from Questionnaire to the LHC-Forms format.
Updated example (with some options to turn off the top-level questions and controls): https://jsfiddle.net/lforms/8f754jhy/21/
Thank you for getting me unstuck. Your examples were very valuable. I greatly appreciate your help.
The LHC-Forms documentation has great demos for creating and adding the forms to a web page, so I had no problems with that portion of my project.
But there was no documentation on how to go about retrieving the user answers using LForms.Util.getFormFHIRData(resourceType, fhirVersion, formDataSource, options).
Your example of how to include LForms.Util.getFormFHIRData in one's html page was extremely useful and would be a great addition to the LHC-Form demos.
Diane Rodden MSIS candidate 2019 School of Information and Library Science University of North Carolina at Chapel Hill mail to: rodden@live.unc.eduhttp://mail%20to:%20rodden@live.unc.edu
From: plynchnlm notifications@github.com Sent: Tuesday, July 30, 2019 5:50 PM To: lhncbc/lforms lforms@noreply.github.com Cc: Rodden, Diane Judith rodden@live.unc.edu; Author author@noreply.github.com Subject: Re: [lhncbc/lforms] dataTypes CNE and CWE not transmitting user answers (#13)
Updated example (with some options to turn off the top-level questions and controls): https://jsfiddle.net/lforms/8f754jhy/21/
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/lhncbc/lforms/issues/13?email_source=notifications&email_token=AMWYACH5SMDDV4RBXO7RLS3QCCZSXA5CNFSM4IHPUHPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3FNM6Q#issuecomment-516609658, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMWYACH362LLR74ZSDAT2OLQCCZSXANCNFSM4IHPUHPA.
I am glad it helped, and I am planning to add that as one of the demos soon.
The documentation for getFormFHIRData is here: http://lhncbc.github.io/lforms/#retrieving-fhir-data But maybe something wasn't clear? Or maybe it just needed an example.
Hi, When I change the version of LForms script like this,
It's return a error message is Uncaught TypeError: $(...).tooltip is not a function. Why ?
That seems to be a new, unrelated problem. Please open a new issue, and I will reply there. I am closing this one, as I added the demo requested by GitHubUNCStudent.
When I use LHC Forms, the dataTypes CNE and CWE are displaying correctly, but when the user selects choices, none of them are being transmitted in the JSON. The user's answers for other dataTypes are correctly being transmitted.
An example is my form at http://fhirsirbtesting.pythonanywhere.com/processshortqstn
For example, if I populate the form with Study Type = B. Behavioral
and click on the Submit button, the JSON transmitted is:
{ "Hazards_64": "", "Locations_113": "", "Multi-site_75": "Yes", "PI Name": "Test PI", "Study Type_43": "B. Behavioral" }
Below is my form definition: