2 // Copyright (C) 2010-2014 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 invokes the find-code popup.
125 function sel_related(varname
) {
126 if (typeof varname
== 'undefined') varname
= 'form_related_code';
128 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 500, 400);
131 // Show or hide sections depending on procedure type.
132 function proc_type_changed() {
133 var f
= document
.forms
[0];
134 var pt
= f
.form_procedure_type
;
135 var ix
= pt
.selectedIndex
;
137 var ptval
= pt
.options
[ix
].value
;
138 var ptpfx
= ptval
.substring(0, 3);
139 $
('.ordonly').hide();
140 $
('.resonly').hide();
141 if (ptpfx
== 'ord') $
('.ordonly').show();
142 if (ptpfx
== 'res'|| ptpfx
== 'rec') $
('.resonly').show();
145 $
(document
).ready(function() {
153 <body
class="body_top">
155 // If we are saving, then save and close the window.
157 if ($_POST['form_save']) {
159 "name = " . invalue('form_name') . ", " .
160 "lab_id = " . invalue('form_lab_id') . ", " .
161 "procedure_code = " . invalue('form_procedure_code') . ", " .
162 "procedure_type = " . invalue('form_procedure_type') . ", " .
163 "body_site = " . invalue('form_body_site') . ", " .
164 "specimen = " . invalue('form_specimen') . ", " .
165 "route_admin = " . invalue('form_route_admin') . ", " .
166 "laterality = " . invalue('form_laterality') . ", " .
167 "description = " . invalue('form_description') . ", " .
168 "units = " . invalue('form_units') . ", " .
169 "`range` = " . invalue('form_range') . ", " .
170 "standard_code = " . invalue('form_standard_code') . ", " .
171 "related_code = " . invalue('form_related_code') . ", " .
172 "seq = " . invalue('form_seq');
175 sqlStatement("UPDATE procedure_type SET $sets WHERE procedure_type_id = '$typeid'");
176 // Get parent ID so we can refresh the tree view.
177 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
178 "procedure_type_id = '$typeid'");
179 $parent = $row['parent'];
181 $newid = sqlInsert("INSERT INTO procedure_type SET parent = '$parent', $sets");
182 // $newid is not really used in this script
184 } else if ($_POST['form_delete']) {
186 // Get parent ID so we can refresh the tree view after deleting.
187 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
188 "procedure_type_id = '$typeid'");
189 $parent = $row['parent'];
190 recursiveDelete($typeid);
194 if ($_POST['form_save'] ||
$_POST['form_delete']) {
195 // Find out if this parent still has any children.
196 $trow = sqlQuery("SELECT procedure_type_id FROM procedure_type WHERE parent = '$parent' LIMIT 1");
197 $haskids = empty($trow['procedure_type_id']) ?
'false' : 'true';
198 // Close this window and redisplay the updated list.
199 echo "<script language='JavaScript'>\n";
201 echo " alert('$info_msg');\n";
204 echo " window.close();\n";
205 echo " if (opener.refreshFamily) opener.refreshFamily($parent,$haskids);\n";
206 echo "</script></body></html>\n";
211 $row = sqlQuery("SELECT * FROM procedure_type WHERE procedure_type_id = '$typeid'");
214 <form method
='post' name
='theform'
215 action
='types_edit.php?typeid=<?php echo $typeid ?>&parent=<?php echo $parent ?>'>
216 <!-- no
restoreSession() on submit because session data are not relevant
-->
220 <table border
='0' width
='100%'>
223 <td width
='1%' nowrap
><b
><?php
echo xlt('Procedure Type'); ?
>:</b
></td
>
226 echo generate_select_list(
227 'form_procedure_type',
229 $row['procedure_type'],
230 xl('The type of this entity'),
233 'proc_type_changed()'
240 <td nowrap
><b
><?php
echo xlt('Name'); ?
>:</b
></td
>
242 <input type
='text' size
='40' name
='form_name' maxlength
='63'
243 value
='<?php echo htmlspecialchars($row['name
'], ENT_QUOTES); ?>'
244 title
='<?php echo xlt('Your name
for this category
, procedure
or result
'); ?>'
245 style
='width:100%' class='inputtext' />
250 <td nowrap
><b
><?php
echo xlt('Description'); ?
>:</b
></td
>
252 <input type
='text' size
='40' name
='form_description' maxlength
='255'
253 value
='<?php echo htmlspecialchars($row['description
'], ENT_QUOTES); ?>'
254 title
='<?php echo xlt('Description of this procedure
or result code
'); ?>'
255 style
='width:100%' class='inputtext' />
260 <td nowrap
><b
><?php
echo xlt('Sequence'); ?
>:</b
></td
>
262 <input type
='text' size
='4' name
='form_seq' maxlength
='11'
263 value
='<?php echo $row['seq
'] + 0; ?>'
264 title
='<?php echo xla('Relative ordering of this entity
'); ?>'
270 <td width
='1%' nowrap
><b
><?php
echo xlt('Order From'); ?
>:</b
></td
>
272 <select name
='form_lab_id' title
='<?php echo xla('The entity performing this procedure
'); ?>'>
274 $ppres = sqlStatement("SELECT ppid, name FROM procedure_providers " .
275 "ORDER BY name, ppid");
276 while ($pprow = sqlFetchArray($ppres)) {
277 echo "<option value='" . attr($pprow['ppid']) . "'";
278 if ($pprow['ppid'] == $row['lab_id']) {
282 echo ">" . text($pprow['name']) . "</option>";
289 <tr
class='ordonly resonly'>
290 <td nowrap
><b
><?php
echo xlt('Identifying Code'); ?
>:</b
></td
>
292 <input type
='text' size
='40' name
='form_procedure_code' maxlength
='31'
293 value
='<?php echo htmlspecialchars($row['procedure_code
'], ENT_QUOTES); ?>'
294 title
='<?php echo xla('The vendor
-specific code identifying this procedure
or result
'); ?>'
295 style
='width:100%' class='inputtext' />
300 <td nowrap
><b
><?php
echo xlt('Standard Code'); ?
>:</b
></td
>
303 <input type
='text' size
='50' name
='form_standard_code'
304 value
='<?php echo $row['standard_code
'] ?>' onclick
='sel_related("form_standard_code")'
305 title
='<?php echo xla('Click to select an industry
-standard code
for this procedure
'); ?>'
306 style
='width:100%' readonly
/>
308 <input type
='text' size
='50' name
='form_standard_code'
309 value
='<?php echo attr($row['standard_code
']); ?>'
310 title
='<?php echo xla('Enter the LOINC code
for this procedure
'); ?>'
311 style
='width:100%' />
316 <td width
='1%' nowrap
><b
><?php
echo xlt('Body Site'); ?
>:</b
></td
>
319 generate_form_field(array('data_type' => 1, 'field_id' => 'body_site',
320 'list_id' => 'proc_body_site',
321 'description' => xl('Body site, if applicable')), $row['body_site']);
327 <td width
='1%' nowrap
><b
><?php
echo xlt('Specimen Type'); ?
>:</b
></td
>
331 array('data_type' => 1, 'field_id' => 'specimen',
332 'list_id' => 'proc_specimen',
333 'description' => xl('Specimen Type')),
341 <td width
='1%' nowrap
><b
><?php
echo xlt('Administer Via'); ?
>:</b
></td
>
345 array('data_type' => 1, 'field_id' => 'route_admin',
346 'list_id' => 'proc_route',
347 'description' => xl('Route of administration, if applicable')),
355 <td width
='1%' nowrap
><b
><?php
echo xlt('Laterality'); ?
>:</b
></td
>
359 array('data_type' => 1, 'field_id' => 'laterality',
360 'list_id' => 'proc_lat',
361 'description' => xl('Laterality of this procedure, if applicable')),
369 <td width
='1%' nowrap
><b
><?php
echo xlt('Default Units'); ?
>:</b
></td
>
373 array('data_type' => 1, 'field_id' => 'units',
374 'list_id' => 'proc_unit',
375 'description' => xl('Optional default units for manual entry of results')),
383 <td nowrap
><b
><?php
echo xlt('Default Range'); ?
>:</b
></td
>
385 <input type
='text' size
='40' name
='form_range' maxlength
='255'
386 value
='<?php echo htmlspecialchars($row['range
'], ENT_QUOTES); ?>'
387 title
='<?php echo xla('Optional
default range
for manual entry of results
'); ?>'
388 style
='width:100%' class='inputtext' />
393 <td nowrap
><b
><?php
echo xlt('Followup Services'); ?
>:</b
></td
>
395 <input type
='text' size
='50' name
='form_related_code'
396 value
='<?php echo $row['related_code
'] ?>' onclick
='sel_related("form_related_code")'
397 title
='<?php echo xla('Click to select services to perform
if this result is abnormal
'); ?>'
398 style
='width:100%' readonly
/>
406 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
408 <?php
if ($typeid) { ?
>
410 <input type
='submit' name
='form_delete' value
='<?php echo xla('Delete
'); ?>' style
='color:red' />
414 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />