gad-7 form (#4266)
[openemr.git] / interface / forms / gad7 / view.php
blobfb2693b9d444113f7079dfe6c94a1d8218488bfa
1 <?php
3 /**
4 * gad-7 form using form api view.php
5 * open a previously completed GAD-7 form for further editing
7 * @package OpenEMR
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 */
21 <html><head>
22 <head>
23 <title><?php echo text($string_form_title); ?> </title>
24 <?php Header::setupHeader(); ?>
25 </head>
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"]); ?>
29 <script>
30 // get scores from previous saving of the form
31 var gad7_score = 0;
32 </script>
33 <SCRIPT
34 src="<?php echo $rootdir;?>/forms/gad7/gad7_javasrc.js">
35 </script>
37 <SCRIPT>
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); ?> );
62 if (conf) {
63 window.location.href="<?php echo $GLOBALS['form_exit_url']; ?>";
65 return ( conf );
67 </script>
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()); ?>" />
71 <br></br>
72 <span ><font size=4><?php echo text($str_form_name); ?></font></span>
73 <br></br>
74 <input type="Submit" value="<?php echo xla('Save Form'); ?>" style="color: #483D8B" >
75 &nbsp &nbsp
76 <input type="button" value="<?php echo attr($str_nosave_exit);?>" onclick="top.restoreSession();return( nosave_exit());" style="color: #483D8B">
77 <br>
78 <span class="text"><h2><?php echo xlt('How often have you been bothered by the following over the past 2 weeks?'); ?></h2></span>
79 <table>
80 <tr>
81 <td>
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>
88 </select>
89 <script>
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
93 gad7_score += i;
94 all_scores[0] = i;
95 </script>
96 <br>
97 </br>
98 </tr>
99 </table>
100 <table>
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>
107 </select>
108 <script>
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;
112 gad7_score += i;
113 all_scores[1] = i;
114 </script>
115 <br></br>
116 </tr>
117 </table>
118 <table>
119 <tr>
120 <td>
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>
127 </select>
128 <script>
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;
132 gad7_score += i;
133 all_scores[2] = i;
134 </script>
135 <br></br>
136 </tr>
137 </table>
138 <table>
139 <tr><td>
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>
146 </select>
147 <script>
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;
151 gad7_score += i;
152 all_scores[3] = i;
153 </script>
154 <br></br>
155 </tr>
156 </table>
157 <table>
158 <tr><td>
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>
165 </select>
166 <script>
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;
170 gad7_score += i;
171 all_scores[4] = i;
172 </script>
173 <br></br>
174 </tr>
175 </table>
176 <table>
177 <tr><td>
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>
184 </select>
185 <script>
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;
189 gad7_score += i;
190 all_scores[5] = i;
191 </script>
192 <br></br>
193 </tr>
194 </table>
195 <table>
196 <tr><td>
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>
203 </select>
204 <script>
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;
208 gad7_score += i;
209 all_scores[6] = i;
210 </script>
211 <br></br>
212 </tr>
213 </table>
215 <!-- where the final question (8) will go if the score > 0 -->
216 </table>
217 <table frame = above>
218 <tr><td>
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>
222 <br>
223 </table>
224 <table frame=hsides>
225 <tr><td>
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" -->
229 <br></br>
230 </tr>
231 </table>
232 <SCRIPT>
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
237 </script>
238 <br>
239 <input type="Submit" value="<?php echo xla('Save Form'); ?>" style="color: #483D8B" >
240 &nbsp &nbsp
241 <input type="button" value="<?php echo attr($str_nosave_exit);?>" onclick="top.restoreSession();return( nosave_exit());" style="color: #483D8B">
242 <br><br><br>
243 </form>
245 <?php
246 formFooter();