2 // Copyright (C) 2010-2017 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/options.inc.php");
13 $typeid = formData('typeid', 'R') +
0;
14 $parent = formData('parent', 'R') +
0;
18 function QuotedOrNull($fld)
20 $fld = formDataCore($fld, true);
28 function invalue($name)
30 $fld = formData($name, "P", true);
34 function rbinput($name, $value, $desc, $colname)
37 $ret = "<input type='radio' name='$name' value='$value'";
38 if ($row[$colname] == $value) {
46 function rbvalue($rbname)
48 $tmp = $_POST[$rbname];
56 function cbvalue($cbname)
58 return empty($_POST[$cbname]) ?
0 : 1;
61 function recursiveDelete($typeid)
63 $res = sqlStatement("SELECT procedure_type_id FROM " .
64 "procedure_type WHERE parent = '$typeid'");
65 while ($row = sqlFetchArray($res)) {
66 recursiveDelete($row['procedure_type_id']);
69 sqlStatement("DELETE FROM procedure_type WHERE " .
70 "procedure_type_id = '$typeid'");
76 <script type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
77 <title
><?php
echo $typeid ?
xlt('Edit') : xlt('Add New'); ?
> <?php
echo xlt('Order/Result Type'); ?
></title
>
78 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
81 td
{ font
-size
:10pt
; }
89 font
-family
:sans
-serif
;
99 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
100 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
101 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
103 <script language
="JavaScript">
105 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
107 // The name of the form field for find-code popup results.
110 // This is for callback by the find-code popup.
111 // Appends to or erases the current list of related codes.
112 function set_related(codetype
, code
, selector
, codedesc
) {
113 var f
= document
.forms
[0];
114 var s
= f
[rcvarname
].value
;
116 if (s
.length
> 0) s +
= ';';
117 s +
= codetype +
':' + code
;
121 f
[rcvarname
].value
= s
;
124 // This is for callback by the find-code popup.
125 // Returns the array of currently selected codes with each element in codetype:code format.
126 function get_related() {
127 return document
.forms
[0][rcvarname
].value
.split(';');
130 // This is for callback by the find-code popup.
131 // Deletes the specified codetype:code from the currently selected list.
132 function del_related(s
) {
133 my_del_related(s
, document
.forms
[0][rcvarname
], false);
136 // This invokes the find-code popup.
137 function sel_related(varname
) {
138 if (typeof varname
== 'undefined') varname
= 'form_related_code';
140 dlgopen('../patient_file/encounter/find_code_dynamic.php', '_blank', 900, 600);
143 // Show or hide sections depending on procedure type.
144 function proc_type_changed() {
145 var f
= document
.forms
[0];
146 var pt
= f
.form_procedure_type
;
147 var ix
= pt
.selectedIndex
;
149 var ptval
= pt
.options
[ix
].value
;
150 var ptpfx
= ptval
.substring(0, 3);
151 $
('.ordonly').hide();
152 $
('.resonly').hide();
153 if (ptpfx
== 'ord') $
('.ordonly').show();
154 if (ptpfx
== 'res'|| ptpfx
== 'rec') $
('.resonly').show();
157 $
(document
).ready(function() {
165 <body
class="body_top">
167 // If we are saving, then save and close the window.
169 if ($_POST['form_save']) {
171 "name = " . invalue('form_name') . ", " .
172 "lab_id = " . invalue('form_lab_id') . ", " .
173 "procedure_code = " . invalue('form_procedure_code') . ", " .
174 "procedure_type = " . invalue('form_procedure_type') . ", " .
175 "body_site = " . invalue('form_body_site') . ", " .
176 "specimen = " . invalue('form_specimen') . ", " .
177 "route_admin = " . invalue('form_route_admin') . ", " .
178 "laterality = " . invalue('form_laterality') . ", " .
179 "description = " . invalue('form_description') . ", " .
180 "units = " . invalue('form_units') . ", " .
181 "`range` = " . invalue('form_range') . ", " .
182 "standard_code = " . invalue('form_standard_code') . ", " .
183 "related_code = " . invalue('form_related_code') . ", " .
184 "seq = " . invalue('form_seq');
187 sqlStatement("UPDATE procedure_type SET $sets WHERE procedure_type_id = '$typeid'");
188 // Get parent ID so we can refresh the tree view.
189 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
190 "procedure_type_id = '$typeid'");
191 $parent = $row['parent'];
193 $newid = sqlInsert("INSERT INTO procedure_type SET parent = '$parent', $sets");
194 // $newid is not really used in this script
196 } else if ($_POST['form_delete']) {
198 // Get parent ID so we can refresh the tree view after deleting.
199 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
200 "procedure_type_id = '$typeid'");
201 $parent = $row['parent'];
202 recursiveDelete($typeid);
206 if ($_POST['form_save'] ||
$_POST['form_delete']) {
207 // Find out if this parent still has any children.
208 $trow = sqlQuery("SELECT procedure_type_id FROM procedure_type WHERE parent = '$parent' LIMIT 1");
209 // Close this window and redisplay the updated list.
210 echo "<script language='JavaScript'>\n";
212 echo " alert('$info_msg');\n";
215 echo " window.close();\n";
216 echo " if (opener.refreshFamily) opener.refreshFamily($parent,'true');\n";
217 echo "</script></body></html>\n";
222 $row = sqlQuery("SELECT * FROM procedure_type WHERE procedure_type_id = '$typeid'");
225 <form method
='post' name
='theform'
226 action
='types_edit.php?typeid=<?php echo $typeid ?>&parent=<?php echo $parent ?>'>
227 <!-- no
restoreSession() on submit because session data are not relevant
-->
231 <table border
='0' width
='100%'>
234 <td width
='1%' nowrap
><b
><?php
echo xlt('Procedure Type'); ?
>:</b
></td
>
237 echo generate_select_list(
238 'form_procedure_type',
240 $row['procedure_type'],
241 xl('The type of this entity'),
244 'proc_type_changed()'
251 <td nowrap
><b
><?php
echo xlt('Name'); ?
>:</b
></td
>
253 <input type
='text' size
='40' name
='form_name' maxlength
='63'
254 value
='<?php echo htmlspecialchars($row['name
'], ENT_QUOTES); ?>'
255 title
='<?php echo xlt('Your name
for this category
, procedure
or result
'); ?>'
256 style
='width:100%' class='inputtext' />
261 <td nowrap
><b
><?php
echo xlt('Description'); ?
>:</b
></td
>
263 <input type
='text' size
='40' name
='form_description' maxlength
='255'
264 value
='<?php echo htmlspecialchars($row['description
'], ENT_QUOTES); ?>'
265 title
='<?php echo xlt('Description of this procedure
or result code
'); ?>'
266 style
='width:100%' class='inputtext' />
271 <td nowrap
><b
><?php
echo xlt('Sequence'); ?
>:</b
></td
>
273 <input type
='text' size
='4' name
='form_seq' maxlength
='11'
274 value
='<?php echo $row['seq
'] + 0; ?>'
275 title
='<?php echo xla('Relative ordering of this entity
'); ?>'
281 <td width
='1%' nowrap
><b
><?php
echo xlt('Order From'); ?
>:</b
></td
>
283 <select name
='form_lab_id' title
='<?php echo xla('The entity performing this procedure
'); ?>'>
285 $ppres = sqlStatement("SELECT ppid, name FROM procedure_providers " .
286 "ORDER BY name, ppid");
287 while ($pprow = sqlFetchArray($ppres)) {
288 echo "<option value='" . attr($pprow['ppid']) . "'";
289 if ($pprow['ppid'] == $row['lab_id']) {
293 echo ">" . text($pprow['name']) . "</option>";
300 <tr
class='ordonly resonly'>
301 <td nowrap
><b
><?php
echo xlt('Identifying Code'); ?
>:</b
></td
>
303 <input type
='text' size
='40' name
='form_procedure_code' maxlength
='31'
304 value
='<?php echo htmlspecialchars($row['procedure_code
'], ENT_QUOTES); ?>'
305 title
='<?php echo xla('The vendor
-specific code identifying this procedure
or result
'); ?>'
306 style
='width:100%' class='inputtext' />
311 <td nowrap
><b
><?php
echo xlt('Standard Code'); ?
>:</b
></td
>
314 <input type
='text' size
='50' name
='form_standard_code'
315 value
='<?php echo $row['standard_code
'] ?>' onclick
='sel_related("form_standard_code")'
316 title
='<?php echo xla('Click to select an industry
-standard code
for this procedure
'); ?>'
317 style
='width:100%' readonly
/>
319 <input type
='text' size
='50' name
='form_standard_code'
320 value
='<?php echo attr($row['standard_code
']); ?>'
321 title
='<?php echo xla('Enter the LOINC code
for this procedure
'); ?>'
322 style
='width:100%' />
327 <td width
='1%' nowrap
><b
><?php
echo xlt('Body Site'); ?
>:</b
></td
>
330 generate_form_field(array('data_type' => 1, 'field_id' => 'body_site',
331 'list_id' => 'proc_body_site',
332 'description' => xl('Body site, if applicable')), $row['body_site']);
338 <td width
='1%' nowrap
><b
><?php
echo xlt('Specimen Type'); ?
>:</b
></td
>
342 array('data_type' => 1, 'field_id' => 'specimen',
343 'list_id' => 'proc_specimen',
344 'description' => xl('Specimen Type')),
352 <td width
='1%' nowrap
><b
><?php
echo xlt('Administer Via'); ?
>:</b
></td
>
356 array('data_type' => 1, 'field_id' => 'route_admin',
357 'list_id' => 'proc_route',
358 'description' => xl('Route of administration, if applicable')),
366 <td width
='1%' nowrap
><b
><?php
echo xlt('Laterality'); ?
>:</b
></td
>
370 array('data_type' => 1, 'field_id' => 'laterality',
371 'list_id' => 'proc_lat',
372 'description' => xl('Laterality of this procedure, if applicable')),
380 <td width
='1%' nowrap
><b
><?php
echo xlt('Default Units'); ?
>:</b
></td
>
384 array('data_type' => 1, 'field_id' => 'units',
385 'list_id' => 'proc_unit',
386 'description' => xl('Optional default units for manual entry of results')),
394 <td nowrap
><b
><?php
echo xlt('Default Range'); ?
>:</b
></td
>
396 <input type
='text' size
='40' name
='form_range' maxlength
='255'
397 value
='<?php echo htmlspecialchars($row['range
'], ENT_QUOTES); ?>'
398 title
='<?php echo xla('Optional
default range
for manual entry of results
'); ?>'
399 style
='width:100%' class='inputtext' />
404 <td nowrap
><b
><?php
echo xlt('Followup Services'); ?
>:</b
></td
>
406 <input type
='text' size
='50' name
='form_related_code'
407 value
='<?php echo $row['related_code
'] ?>' onclick
='sel_related("form_related_code")'
408 title
='<?php echo xla('Click to select services to perform
if this result is abnormal
'); ?>'
409 style
='width:100%' readonly
/>
417 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
419 <?php
if ($typeid) { ?
>
421 <input type
='submit' name
='form_delete' value
='<?php echo xla('Delete
'); ?>' style
='color:red' />
425 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />