FHIR Chat · How to embed javascript logic in Questionnaire? · implementers

Stream: implementers

Topic: How to embed javascript logic in Questionnaire?


view this post on Zulip Maria Hu (Sep 02 2021 at 23:34):

When mapping an eForm template + logic , which element(s) can we map the embedded javascript logic from the form to the Questionnaire? Please advise, thanks.

view this post on Zulip Lloyd McKenzie (Sep 03 2021 at 01:00):

I guess you could use a custom extension, but we'll never define a standard extension to allow embedding Javascript in a Questionnaire because it would be a security risk. Best practice is to map your logic to standard extensions such as those defined in the Structured Data Capture IG

view this post on Zulip Brian Postlethwaite (Sep 03 2021 at 06:23):

There are many capabilities in the SDC spec that reduce the need for doing javascript code, as that would then be dependent on how it is rendered also.
If the area is validation, refer to the constraint expression, if the area is enabling/disabling, check the enableWhen property(s) and the enableWhenExpression - these are the areas that will cover lots of the baseline functionality that you might want scripting for, and these use the fhirpath expression language. (and are also applicable for non web based interfaces too)

view this post on Zulip Maria Hu (Sep 03 2021 at 16:41):

Brian Postlethwaite said:

There are many capabilities in the SDC spec that reduce the need for doing javascript code, as that would then be dependent on how it is rendered also.
If the area is validation, refer to the constraint expression, if the area is enabling/disabling, check the enableWhen property(s) and the enableWhenExpression - these are the areas that will cover lots of the baseline functionality that you might want scripting for, and these use the fhirpath expression language. (and are also applicable for non web based interfaces too)

thanks Brian !

view this post on Zulip Maria Hu (Sep 03 2021 at 16:42):

Lloyd McKenzie said:

I guess you could use a custom extension, but we'll never define a standard extension to allow embedding Javascript in a Questionnaire because it would be a security risk. Best practice is to map your logic to standard extensions such as those defined in the Structured Data Capture IG

Thanks Lloyd, will take a look.


Last updated: Apr 12 2022 at 19:14 UTC