4 * gad-7 form using form api view.php
5 * open a previously completed GAD-7 form for further editing
8 * @link http://www.open-emr.org
9 * @author Ruth Moulton <moulton ruth@muswell.me.uk>
10 * @copyright Copyright (c) 2021 ruth moulton <ruth@muswell.me.uk>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("gad7.inc.php"); // common strings, require_once(globals.php), other includes etc
17 use OpenEMR\Common\Csrf\CsrfUtils
; // security module
18 use OpenEMR\Core\Header
;
19 use Mpdf\Mpdf
; /* used to generate a pdf of the form */
23 <title
><?php
echo text($string_form_title); ?
> </title
>
24 <?php Header
::setupHeader(); ?
>
26 <body
class="body_top">
27 <?php
// read in the values from the filled in form held in db
28 $obj = formFetch("form_gad7", $_GET["id"]); ?
>
30 // get scores from previous saving of the form
34 src
="<?php echo $rootdir;?>/forms/gad7/gad7_javasrc.js">
38 // stuff that uses embedded php must go here, not in the include javascript file - it must be executed on server side before page is sent to client. included javascript is only executed on the client
40 function create_q8(question
, menue
){
41 // create the question - the second part is italicised
42 var text
= document
.createTextNode(jsAttr(<?php
echo js_escape($str_q8); ?
>));
43 question
.appendChild(text
);
44 var new_line
= document
.createElement("br"); // second part is in italics
45 var ital
= document
.createElement("i"); // second part is in italics
46 var question_2
= document
.createTextNode(jsAttr(<?php
echo js_escape($str_q8_2); ?
>));
47 ital
.appendChild(question_2
) ;
48 question
.name
= "eighth";
49 question
.appendChild(new_line
);
50 question
.appendChild(ital
);
52 // populate the the menue
53 menue
.options
[0] = new Option ( <?php
echo js_escape($str_not); ?
>, "0");
54 menue
.options
[1] = new Option ( <?php
echo js_escape($str_somewhat); ?
>, "1");
55 menue
.options
[2] = new Option ( <?php
echo js_escape($str_very); ?
>, "2");
56 menue
.options
[3] = new Option ( <?php
echo js_escape($str_extremely);?
>, "3");
57 menue
.options
[4] = new Option ( <?php
echo js_escape($str_default); ?
>, "undef");
59 // check user really wants to exit without saving new answers
60 function nosave_exit() {
61 var conf
= confirm ( <?php
echo js_escape($str_nosave_confirm); ?
> );
63 window
.location
.href
="<?php echo $GLOBALS['form_exit_url']; ?>";
69 <form method
=post action
="<?php echo $rootdir;?>/forms/gad7/save.php?mode=update&id=<?php echo attr_url($_GET["id
"]); ?>" name
="my_form" >
70 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
72 <span
><font size
=4><?php
echo text($str_form_name); ?
></font
></span
>
74 <input type
="Submit" value
="<?php echo xla('Save Form'); ?>" style
="color: #483D8B" >
76 <input type
="button" value
="<?php echo attr($str_nosave_exit);?>" onclick
="top.restoreSession();return( nosave_exit());" style
="color: #483D8B">
78 <span
class="text"><h2
><?php
echo xlt('How often have you been bothered by the following over the past 2 weeks?'); ?
></h2
></span
>
82 <span
class="text"><?php
echo xlt('Feeling nervous, anxious, or on edge'); ?
></span
>
83 <select name
="nervous_score" onchange
="update_score(0, my_form.nervous_score.value);">
84 <option value
="0"><?php
echo text($str_not); ?
></option
>
85 <option value
="1"><?php
echo text($str_several); ?
></option
>
86 <option value
="2"><?php
echo text($str_more); ?
></option
>
87 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
90 // set the default to the previous value - so it is displayed in the menue box
91 document
.my_form
.nervous_score
.options
[<?php
echo text($obj['nervous_score']); ?
>].defaultSelected
=true;
92 var i
= <?php
echo text($obj['nervous_score']); ?
> ; //the value from last time
101 <span
class="text" ><?php
echo xlt('Not being able to stop or control worrying'); ?
></span
>
102 <select name
="control_worry_score" onchange
="update_score(1, my_form.control_worry_score.value);" >
103 <option value
="0"><?php
echo text($str_not); ?
></option
>
104 <option value
="1"><?php
echo text($str_several); ?
></option
>
105 <option value
="2"><?php
echo text($str_more); ?
></option
>
106 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
109 // set the default to the previous value - so it is displayed in the menue box
110 var i
= <?php
echo text($obj['control_worry_score']); ?
>; //the value from last time
111 document
.my_form
.control_worry_score
.options
[i
].defaultSelected
=true;
121 <span
class="text" ><?php
echo xlt('Worrying too much about different things'); ?
></span
>
122 <select name
="worry_score" onchange
="update_score(2, my_form.worry_score.value);" >
123 <option value
="0"><?php
echo text($str_not); ?
></option
>
124 <option value
="1"><?php
echo text($str_several); ?
></option
>
125 <option value
="2"><?php
echo text($str_more); ?
></option
>
126 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
129 // set the previous value to the default - so it is displayed in the menue box
130 var i
= <?php
echo text($obj['worry_score']); ?
> ; //the value from last time
131 document
.my_form
.worry_score
.options
[i
].defaultSelected
=true;
140 <span
class="text" ><?php
echo xlt('Trouble relaxing'); ?
></span
>
141 <select name
="relax_score" onchange
="update_score(3, my_form.relax_score.value);">
142 <option value
="0"><?php
echo text($str_not); ?
></option
>
143 <option value
="1"><?php
echo text($str_several); ?
></option
>
144 <option value
="2"><?php
echo text($str_more); ?
></option
>
145 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
148 // set the previous value to the default - so it is displayed in the menue box
149 var i
= <?php
echo text($obj['relax_score']); ?
> ; //the value from last time
150 document
.my_form
.relax_score
.options
[i
].defaultSelected
=true;
159 <span
class="text" ><?php
echo xlt("Being so restless that it's hard to sit still"); ?
></span
>
160 <select name
="restless_score" onchange
="update_score(4, my_form.restless_score.value);">
161 <option value
="0"><?php
echo text($str_not); ?
></option
>
162 <option value
="1"><?php
echo text($str_several); ?
></option
>
163 <option value
="2"><?php
echo text($str_more); ?
></option
>
164 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
167 // set the previous value to the default - so it is displayed in the menue box
168 var i
= <?php
echo text($obj['restless_score']); ?
> ; //the value from last time
169 document
.my_form
.restless_score
.options
[i
].defaultSelected
=true;
178 <span
class="text" ><?php
echo xlt('Becoming easily annoyed or irritable'); ?
></span
>
179 <select name
="irritable_score" onchange
="update_score(5, my_form.irritable_score.value);">
180 <option value
="0"><?php
echo text($str_not); ?
></option
>
181 <option value
="1"><?php
echo text($str_several); ?
></option
>
182 <option value
="2"><?php
echo text($str_more); ?
></option
>
183 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
186 // set the previous value to the default - so it is displayed in the menue box
187 var i
= <?php
echo text($obj['irritable_score']); ?
> ; //the value from last time
188 document
.my_form
.irritable_score
.options
[i
].defaultSelected
=true;
197 <span
class="text" ><?php
echo xlt('Feeling afraid as if something awful might happen'); ?
></span
>
198 <select name
="fear_score" onchange
="update_score(6, my_form.fear_score.value);">
199 <option value
="0"><?php
echo text($str_not); ?
></option
>
200 <option value
="1"><?php
echo text($str_several); ?
></option
>
201 <option value
="2"><?php
echo text($str_more); ?
></option
>
202 <option value
="3"><?php
echo text($str_nearly); ?
></option
>
205 // set the previous value to the default - so it is displayed in the menue box
206 var i
= <?php
echo text($obj['fear_score']);?
> ; //the value from last time
207 document
.my_form
.fear_score
.options
[i
].defaultSelected
=true;
215 <!-- where the
final question (8) will go
if the score
> 0 -->
217 <table frame
= above
>
219 <!-- optional
- only asked
if score so far
>0 and not included in
final score
-->
220 <!-- where the
final question will go
if the score
> 0 -->
221 <span id
="q8_place"></span
>
226 <span id
="show_gad7_score"><b
><?php
echo xlt("Total GAD-7 score"); ?
>:</b
> </td
>
227 <!-- use this to save the individual scores in the database
-->
228 <!-- input type
="hidden" name
="scores_array" -->
233 // only display the final question if the score is > 0
234 // pass the function the answer previously entered onto the form
235 manage_question_8 ("<?php echo text($obj["difficulty
"]); ?>"); //do we need q8
236 update_score ("undef",gad7_score
); //display total from last time
239 <input type
="Submit" value
="<?php echo xla('Save Form'); ?>" style
="color: #483D8B" >
241 <input type
="button" value
="<?php echo attr($str_nosave_exit);?>" onclick
="top.restoreSession();return( nosave_exit());" style
="color: #483D8B">