Remove concurrent_layout and clarify layout and themes selections (#272)
[openemr.git] / interface / forms / observation / new.php
blob5673b6a8dff50e74ad809558e8f9b98306ed4439
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2015 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 //
23 // Author: Jacob T Paul <jacob@zhservices.com>
24 // Vinish K <vinish@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 //SANITIZE ALL ESCAPES
29 $sanitize_all_escapes = true;
31 //STOP FAKE REGISTER GLOBALS
32 $fake_register_globals = false;
34 include_once("../../globals.php");
35 include_once("$srcdir/api.inc");
36 require_once("$srcdir/patient.inc");
37 require_once("$srcdir/options.inc.php");
38 require_once($GLOBALS['srcdir'] . '/csv_like_join.php');
39 require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
41 formHeader("Form:Observation Form");
42 $returnurl = 'encounter_top.php';
43 $formid = 0 + (isset($_GET['id']) ? $_GET['id'] : '');
45 if ($formid) {
46 $sql = "SELECT * FROM `form_observation` WHERE id=? AND pid = ? AND encounter = ?";
47 $res = sqlStatement($sql, array($formid,$_SESSION["pid"], $_SESSION["encounter"]));
49 for ($iter = 0; $row = sqlFetchArray($res); $iter++)
50 $all[$iter] = $row;
51 $check_res = $all;
54 $check_res = $formid ? $check_res : array();
57 <html>
58 <head>
59 <?php html_header_show(); ?>
60 <!-- pop up calendar -->
61 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
62 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
63 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
64 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
65 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
66 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
67 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
68 </head>
70 <body class="body_top">
71 <script type="text/javascript">
73 function duplicateRow(e) {
74 var newRow = e.cloneNode(true);
75 e.parentNode.insertBefore(newRow, e.nextSibling);
76 changeIds('tb_row');
77 changeIds('comments');
78 changeIds('code');
79 changeIds('description');
80 changeIds('img_code_date');
81 changeIds('code_date');
82 changeIds('displaytext');
83 changeIds('code_type');
84 changeIds('table_code');
85 changeIds('ob_value');
86 changeIds('ob_unit');
87 changeIds('ob_value_phin');
88 changeIds('ob_value_head');
89 changeIds('ob_unit_head');
90 removeVal(newRow.id);
93 function removeVal(rowid)
95 rowid1 = rowid.split('tb_row_');
96 document.getElementById("comments" + rowid1[1]).value = '';
97 document.getElementById("code_" + rowid1[1]).value = '';
98 document.getElementById("description_" + rowid1[1]).value = '';
99 document.getElementById("img_code_date_" + rowid1[1]).value = '';
100 document.getElementById("code_date_" + rowid1[1]).value = '';
101 document.getElementById("displaytext_" + rowid1[1]).innerHTML = '';
102 document.getElementById("code_type_" + rowid1[1]).value = '';
103 document.getElementById("table_code_" + rowid1[1]).value = '';
104 document.getElementById("ob_value_" + rowid1[1]).value = '';
105 document.getElementById("ob_unit_" + rowid1[1]).value = '';
106 document.getElementById("ob_value_phin_" + rowid1[1]).value = '';
107 document.getElementById("ob_value_head" + rowid1[1]).innerHTML = '';
108 document.getElementById("ob_unit_head" + rowid1[1]).innerHTML = '';
111 function changeIds(class_val) {
112 var elem = document.getElementsByClassName(class_val);
113 for (var i = 0; i < elem.length; i++) {
114 if (elem[i].id) {
115 index = i + 1;
116 elem[i].id = class_val + "_" + index;
118 if (class_val == 'code_date')
120 Calendar.setup({inputField: class_val + "_" + index, ifFormat: "%Y-%m-%d", button: "img_code_date_" + index});
125 function deleteRow(rowId)
127 if (rowId != 'tb_row_1') {
128 var table = document.getElementById("table_observation");
129 var rowIndex = document.getElementById(rowId).rowIndex;
130 table.deleteRow(rowIndex);
134 function sel_code(id)
136 id = id.split('tb_row_');
137 var checkId = '_' + id[1];
138 document.getElementById('clickId').value = checkId;
139 dlgopen('<?php echo $GLOBALS['webroot'] . "/interface/patient_file/encounter/" ?>find_code_popup.php?codetype=LOINC,PHIN Questions', '_blank', 700, 400);
142 function set_related(codetype, code, selector, codedesc) {
143 var checkId = document.getElementById('clickId').value;
144 document.getElementById("code" + checkId).value = code;
145 document.getElementById("description" + checkId).value = codedesc;
146 document.getElementById("displaytext" + checkId).innerHTML = codedesc;
147 document.getElementById("code_type" + checkId).value = codetype;
148 if(codetype == 'LOINC') {
149 document.getElementById("table_code" + checkId).value = 'LN';
150 if(code == '21612-7') {
151 document.getElementById('ob_value_head' + checkId).style.display = '';
152 document.getElementById('ob_unit_head' + checkId).style.display = '';
153 document.getElementById('ob_value' + checkId).style.display = '';
154 var sel_unit_age = document.getElementById('ob_unit' + checkId);
155 if(document.getElementById('ob_unit' + checkId).value == '') {
156 var opt = document.createElement("option");
157 opt.value='d';
158 opt.text='Day';
159 sel_unit_age.appendChild(opt);
160 var opt1 = document.createElement("option");
161 opt1.value='mo';
162 opt1.text='Month';
163 sel_unit_age.appendChild(opt1);
164 var opt2 = document.createElement("option");
165 opt2.value='UNK';
166 opt2.text='Unknown';
167 sel_unit_age.appendChild(opt2);
168 var opt3 = document.createElement("option");
169 opt3.value='wk';
170 opt3.text='Week';
171 sel_unit_age.appendChild(opt3);
172 var opt4 = document.createElement("option");
173 opt4.value='a';
174 opt4.text='Year';
175 sel_unit_age.appendChild(opt4);
177 document.getElementById('ob_unit' + checkId).style.display = 'block';
178 document.getElementById('ob_value_phin' + checkId).style.display = 'none';
180 else if (code == '8661-1'){
181 document.getElementById('ob_unit_head' + checkId).style.display = 'none';
182 var select = document.getElementById('ob_unit' + checkId);
183 select.innerHTML= "";
184 document.getElementById('ob_unit' + checkId).style.display = 'none';
185 document.getElementById('ob_value_phin' + checkId).style.display = 'none';
186 document.getElementById('ob_value_head' + checkId).style.display = '';
187 document.getElementById('ob_value' + checkId).style.display = '';
190 else {
191 document.getElementById("table_code" + checkId).value = 'PHINQUESTION';
192 document.getElementById('ob_value_head' + checkId).style.display = '';
193 document.getElementById('ob_unit_head' + checkId).style.display = 'none';
194 var select_unit = document.getElementById('ob_unit' + checkId);
195 select_unit.innerHTML= "";
196 document.getElementById('ob_value' + checkId).value = '';
197 document.getElementById('ob_value' + checkId).style.display = 'none';
198 document.getElementById('ob_unit' + checkId).style.display = 'none';
199 document.getElementById('ob_value_phin' + checkId).style.display = '';
203 </script>
204 <p><span class="forms-title"><?php echo xlt('Observation Form'); ?></span></p>
205 </br>
206 <?php echo "<form method='post' name='my_form' " . "action='$rootdir/forms/observation/save.php?id=" . attr($formid) . "'>\n"; ?>
207 <table id="table_observation" border="0" >
209 <?php
210 if (!empty($check_res)) {
211 foreach ($check_res as $key => $obj) {
212 $style= '';
214 <tr class="tb_row" id="tb_row_<?php echo $key + 1; ?>">
215 <td align="left" class="forms"><?php echo xlt('Code'); ?>:</td>
216 <td class="forms">
217 <input type="text" id="code_<?php echo $key + 1; ?>" style="width:50%;" name="code[]" class="code" value="<?php echo text($obj{"code"}); ?>" onclick='sel_code(this.parentElement.parentElement.id);'><br>
218 <span id="displaytext_<?php echo $key + 1; ?>" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"><?php echo text($obj{"description"}); ?></span>
219 <input type="hidden" id="description_<?php echo $key + 1; ?>" name="description[]" class="description" value="<?php echo text($obj{"description"}); ?>">
220 <input type="hidden" id="code_type_<?php echo $key + 1; ?>" name="code_type[]" class="code_type" value="<?php echo text($obj{"code_type"}); ?>">
221 <input type="hidden" id="table_code_<?php echo $key + 1; ?>" name="table_code[]" class="table_code" value="<?php echo text($obj{"table_code"}); ?>">
222 </td>
223 <td id="ob_value_head_<?php echo $key + 1; ?>" class="forms ob_value_head" align="left" <?php if( !$obj{"ob_value"}) {?>style="display: none;" <?php }?>><?php echo xlt('Value'); ?>:</td>
224 <td class="forms">
225 <?php
226 if((text($obj{"code"}) == '21612-7' || text($obj{"code"}) == '8661-1')) {
227 $style = 'display: block;';
229 elseif(text($obj{"code"}) == 'SS003' || !$obj{"ob_value"}) {
230 $style = 'display: none;';
233 <input type="text" name="ob_value[]" id="ob_value_<?php echo $key + 1; ?>" style="width: 60%; <?php echo $style;?>" class="ob_value" value="<?php if((text($obj{"code"}) == '21612-7' || text($obj{"code"}) == '8661-1') && text($obj{"code"}) != 'SS003') echo text($obj{"ob_value"}); ?>">
234 <select name="ob_value_phin[]" id="ob_value_phin_<?php echo $key + 1; ?>" class="ob_value_phin" <?php if(text($obj{"code"}) != 'SS003') { ?> style="display: none;" <?php }?>>
235 <option value="261QE0002X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QE0002X') echo 'selected = "selected"' ;?>><?php echo xlt('Emergency Care'); ?></option>
236 <option value="261QM2500X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QM2500X') echo 'selected = "selected"' ;?>><?php echo xlt('Medical Specialty'); ?></option>
237 <option value="261QP2300X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QP2300X') echo 'selected = "selected"' ;?>><?php echo xlt('Primary Care'); ?></option>
238 <option value="261QU0200X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QU0200X') echo 'selected = "selected"' ;?>><?php echo xlt('Urgent Care'); ?></option>
239 </select>
240 </td>
241 <?php
242 if(!$obj{"ob_unit"} || (text($obj{"code"}) == 'SS003')|| text($obj{"code"}) == '8661-1') {
243 $style = 'display: none;' ;
245 elseif(text($obj{"code"}) == '21612-7') {
246 $style = 'display: block';
249 <td id="ob_unit_head_<?php echo $key + 1; ?>" class="forms ob_unit_head" align="left" style="<?php echo $style;?>"><?php echo xlt('Units'); ?>:</td>
250 <td class="forms">
251 <select <?php if(text($obj{"code"}) != '21612-7') { ?> style="display: none;" <?php }?> name="ob_unit[]" id="ob_unit_<?php echo $key + 1; ?>" class="ob_unit">
252 <option value="d" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'd') echo 'selected = "selected"' ;?>><?php echo xlt('Day'); ?></option>
253 <option value="mo" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'mo') echo 'selected = "selected"' ;?>><?php echo xlt('Month'); ?></option>
254 <option value="UNK" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'UNK') echo 'selected = "selected"' ;?>><?php echo xlt('Unknown'); ?></option>
255 <option value="wk" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'wk') echo 'selected = "selected"' ;?>><?php echo xlt('Week'); ?></option>
256 <option value="a" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'a') echo 'selected = "selected"' ;?>><?php echo xlt('Year'); ?></option>
257 </select>
258 </td>
259 <td align="left" class="forms"><?php echo xlt('Comments'); ?>:</td>
260 <td class="forms">
261 <textarea rows="4" id="comments_<?php echo $key + 1; ?>" cols="20" name="comments[]" class="comments"><?php echo text($obj{"observation"}); ?></textarea>
262 </td>
263 <td align="left" class="forms"><?php echo xlt('Date'); ?>:</td>
264 <td class="forms">
265 <input type='text' id="code_date_<?php echo $key + 1; ?>" size='10' name='code_date[]' class="code_date" <?php echo attr($disabled) ?> value='<?php echo attr($obj{"date"}); ?>' title='<?php echo xla('yyyy-mm-dd Date of service'); ?>' onkeyup='datekeyup(this, mypcc)' onblur='dateblur(this, mypcc)' />
266 <img src='../../pic/show_calendar.gif' align='absbottom' id="img_code_date_<?php echo $key + 1; ?>" width='24' height='22' class="img_code_date" border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to choose a date'); ?>'>
267 </td>
268 <td>
269 <img src='../../pic/add.png' onclick="duplicateRow(this.parentElement.parentElement);" align='absbottom' width='27' height='24' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to duplicate the row'); ?>'>
270 <img src='../../pic/remove.png' onclick="deleteRow(this.parentElement.parentElement.id);" align='absbottom' width='24' height='22' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to delete the row'); ?>'>
271 </td>
272 <script language="javascript">
273 /* required for popup calendar */
274 Calendar.setup({inputField: "code_date_<?php echo $key + 1; ?>", ifFormat: "%Y-%m-%d", button: "img_code_date_<?php echo $key + 1; ?>"});
275 </script>
276 </tr>
277 <?php
279 } else {
281 <tr class="tb_row" id="tb_row_1">
282 <td align="left" class="forms"><?php echo xlt('Code'); ?>:</td>
283 <td class="forms">
284 <input type="text" id="code_1" name="code[]" style="width:50%;" class="code" value="<?php echo text($obj{"code"}); ?>" onclick='sel_code(this.parentElement.parentElement.id);'><br>
285 <span id="displaytext_1" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"><?php echo text($obj{"description"}); ?></span>
286 <input type="hidden" id="description_1" name="description[]" class="description" value="<?php echo text($obj{"description"}); ?>">
287 <input type="hidden" id="code_type_1" name="code_type[]" class="code_type" value="<?php echo text($obj{"code_type"}); ?>">
288 <input type="hidden" id="table_code_1" name="table_code[]" class="table_code" value="<?php echo text($obj{"table_code"}); ?>">
289 </td>
290 <td id="ob_value_head_1" class="forms ob_value_head" align="left" <?php if( !$obj{"ob_value"}) {?>style="display: none;" <?php }?>><?php echo xlt('Value'); ?>:</td>
291 <td class="forms">
292 <?php
293 if((text($obj{"code"}) == '21612-7' || text($obj{"code"}) == '8661-1')) {
294 $style = 'display: block;';
296 elseif(text($obj{"code"}) == 'SS003' || !$obj{"ob_value"}) {
297 $style = 'display: none;';
300 <input type="text" name="ob_value[]" id="ob_value_1" style="width: 60%;<?php echo $style;?>" class="ob_value" value="<?php if((text($obj{"code"}) == '21612-7' || text($obj{"code"}) == '8661-1') && text($obj{"code"}) != 'SS003') echo text($obj{"ob_value"}); ?>">
301 <select name="ob_value_phin[]" id="ob_value_phin_1" class="ob_value_phin" <?php if(text($obj{"code"}) != 'SS003') { ?> style="display: none;" <?php }?>>
302 <option value="261QE0002X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QE0002X') echo 'selected = "selected"' ;?>><?php echo xlt('Emergency Care'); ?></option>
303 <option value="261QM2500X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QM2500X') echo 'selected = "selected"' ;?>><?php echo xlt('Medical Specialty'); ?></option>
304 <option value="261QP2300X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QP2300X') echo 'selected = "selected"' ;?>><?php echo xlt('Primary Care'); ?></option>
305 <option value="261QU0200X" <?php if(text($obj{"code"}) == 'SS003' && text($obj{"ob_value"}) == '261QU0200X') echo 'selected = "selected"' ;?>><?php echo xlt('Urgent Care'); ?></option>
306 </select>
307 </td>
308 <?php
309 if(!$obj{"ob_unit"} || (text($obj{"code"}) == 'SS003')|| text($obj{"code"}) == '8661-1') {
310 $style = 'display: none;' ;
312 elseif(text($obj{"code"}) == '21612-7') {
313 $style = 'display: block';
316 <td id="ob_unit_head_1" class="forms ob_unit_head" align="left" style="<?php echo $style;?>"><?php echo xlt('Units'); ?>:</td>
317 <td class="forms">
318 <select <?php if(text($obj{"code"}) != '21612-7') { ?> style="display: none;" <?php }?> name="ob_unit[]" id="ob_unit_1" class="ob_unit">
319 <option value="d" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'd') echo 'selected = "selected"' ;?>><?php echo xlt('Day'); ?></option>
320 <option value="mo" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'mo') echo 'selected = "selected"' ;?>><?php echo xlt('Month'); ?></option>
321 <option value="UNK" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'UNK') echo 'selected = "selected"' ;?>><?php echo xlt('Unknown'); ?></option>
322 <option value="wk" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'wk') echo 'selected = "selected"' ;?>><?php echo xlt('Week'); ?></option>
323 <option value="a" <?php if(text($obj{"code"}) == '21612-7' && text($obj{"ob_unit"}) == 'a') echo 'selected = "selected"' ;?>><?php echo xlt('Year'); ?></option>
324 </select>
325 </td>
326 <td align="left" class="forms"><?php echo xlt('Comments'); ?>:</td>
327 <td class="forms">
328 <textarea rows="4" id="comments_1" cols="20" name="comments[]" class="comments"><?php echo text($obj{"observation"}); ?></textarea>
329 </td>
330 <td align="left" class="forms"><?php echo xlt('Date'); ?>:</td>
331 <td class="forms">
332 <input type='text' id="code_date_1" size='10' name='code_date[]' class="code_date" <?php echo attr($disabled) ?> value='<?php echo attr($obj{"date"}); ?>' title='<?php echo xla('yyyy-mm-dd Date of service'); ?>' onkeyup='datekeyup(this, mypcc)' onblur='dateblur(this, mypcc)' />
333 <img src='../../pic/show_calendar.gif' align='absbottom' id="img_code_date_<?php echo $key + 1; ?>" width='24' height='22' class="img_code_date" border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to choose a date'); ?>'>
334 </td>
335 <td>
336 <img src='../../pic/add.png' onclick="duplicateRow(this.parentElement.parentElement);" align='absbottom' width='27' height='24' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to duplicate the row'); ?>'>
337 <img src='../../pic/remove.png' onclick="deleteRow(this.parentElement.parentElement.id);" align='absbottom' width='24' height='22' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to delete the row'); ?>'>
338 </td>
339 <script language="javascript">
340 /* required for popup calendar */
341 Calendar.setup({inputField: "code_date_1", ifFormat: "%Y-%m-%d", button: "img_code_date_1"});
342 </script>
343 </tr>
344 <?php }
347 <tr>
348 <td align="left" colspan="5" style="padding-bottom:7px;"></td>
349 </tr>
350 <tr>
351 <td colspan="5"></td>
352 <td colspan="4">
353 <input type="hidden" id="clickId" value="">
354 <input type='submit' value='<?php echo xla('Save'); ?>' class="button-css">&nbsp;
355 </td>
356 </tr>
357 </table>
358 </form>
359 <?php
360 formFooter();