Expand my Community achievements bar.

SOLVED

Javascript array help needed to generate narrative from checkboxes

Avatar

Level 2

For context...  the user will indicate symptoms in cardiovascular section, selecting "deny all", if none of the symptoms apply.  The narrative sub-form needs to processes diagnosis sub-form and generate text that explains the symptoms in a narrative form.  For example, if the user selects "deny all" in the cardiovascular section, the Cardiovascular System Review field would have:  "The patient denies:  High Blood Pressure, Low Blood Pressure.  The logic associated with the narrative needs to account for "deny all" and all the variations of selections.

I have what I think is a pretty good start on the logic, but would like some help with the following:

1) loading selected fields into the cv_1s array

2) loading fields not selected into the cv_0s array

3) generating the narrative

See "phr.narrative.cv_nar::calculate - (JavaScript, client)" for the coding I've done thus far.  Feel free to comment on any efficiency opportunities you see.  I have a SAS programming background, but I'm new to Javascript.  Thanks...

Rob

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Rob,

One approach would be to give your checkboxes the same name so they can then be referenced as a group and use the caption as the source of your text, so you shouldn't have to duplicate the text and will make it easier to add more later.

Attached is a sample doing that.

Hope it helps.

Bruce

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi Rob,

One approach would be to give your checkboxes the same name so they can then be referenced as a group and use the caption as the source of your text, so you shouldn't have to duplicate the text and will make it easier to add more later.

Attached is a sample doing that.

Hope it helps.

Bruce