2 // Copyright (C) 2010-2012 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");
12 require_once("$srcdir/formdata.inc.php");
14 $typeid = formData('typeid', 'R') +
0;
15 $parent = formData('parent', 'R') +
0;
19 function QuotedOrNull($fld) {
20 $fld = formDataCore($fld,true);
21 if ($fld) return "'$fld'";
25 function invalue($name) {
26 $fld = formData($name,"P",true);
30 function rbinput($name, $value, $desc, $colname) {
32 $ret = "<input type='radio' name='$name' value='$value'";
33 if ($row[$colname] == $value) $ret .= " checked";
38 function rbvalue($rbname) {
39 $tmp = $_POST[$rbname];
40 if (! $tmp) $tmp = '0';
44 function cbvalue($cbname) {
45 return empty($_POST[$cbname]) ?
0 : 1;
48 function recursiveDelete($typeid) {
49 $res = sqlStatement("SELECT procedure_type_id FROM " .
50 "procedure_type WHERE parent = '$typeid'");
51 while ($row = sqlFetchArray($res)) {
52 recursiveDelete($row['procedure_type_id']);
54 sqlStatement("DELETE FROM procedure_type WHERE " .
55 "procedure_type_id = '$typeid'");
61 <title
><?php
echo $typeid ?
xlt('Edit') : xlt('Add New'); ?
> <?php
echo xlt('Order/Result Type'); ?
></title
>
62 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
65 td
{ font
-size
:10pt
; }
73 font
-family
:sans
-serif
;
83 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
84 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
85 <script type
="text/javascript" src
="../../library/js/jquery-1.2.2.min.js"></script
>
87 <script language
="JavaScript">
89 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
91 // The name of the form field for find-code popup results.
94 // This is for callback by the find-code popup.
95 // Appends to or erases the current list of related codes.
96 function set_related(codetype
, code
, selector
, codedesc
) {
97 var f
= document
.forms
[0];
98 var s
= f
[rcvarname
].value
;
100 if (s
.length
> 0) s +
= ';';
101 s +
= codetype +
':' + code
;
105 f
[rcvarname
].value
= s
;
108 // This invokes the find-code popup.
109 function sel_related(varname
) {
110 if (typeof varname
== 'undefined') varname
= 'form_related_code';
112 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 500, 400);
115 // Show or hide sections depending on procedure type.
116 function proc_type_changed() {
117 var f
= document
.forms
[0];
118 var pt
= f
.form_procedure_type
;
119 var ix
= pt
.selectedIndex
;
121 var ptval
= pt
.options
[ix
].value
;
122 var ptpfx
= ptval
.substring(0, 3);
123 $
('.ordonly').hide();
124 $
('.resonly').hide();
125 if (ptpfx
== 'ord') $
('.ordonly').show();
126 if (ptpfx
== 'res'|| ptpfx
== 'rec') $
('.resonly').show();
129 $
(document
).ready(function() {
137 <body
class="body_top">
139 // If we are saving, then save and close the window.
141 if ($_POST['form_save']) {
144 "name = " . invalue('form_name') . ", " .
145 "lab_id = " . invalue('form_lab_id') . ", " .
146 "procedure_code = " . invalue('form_procedure_code') . ", " .
147 "procedure_type = " . invalue('form_procedure_type') . ", " .
148 "body_site = " . invalue('form_body_site') . ", " .
149 "specimen = " . invalue('form_specimen') . ", " .
150 "route_admin = " . invalue('form_route_admin') . ", " .
151 "laterality = " . invalue('form_laterality') . ", " .
152 "description = " . invalue('form_description') . ", " .
153 "units = " . invalue('form_units') . ", " .
154 "`range` = " . invalue('form_range') . ", " .
155 "standard_code = " . invalue('form_standard_code') . ", " .
156 "related_code = " . invalue('form_related_code') . ", " .
157 "seq = " . invalue('form_seq');
160 sqlStatement("UPDATE procedure_type SET $sets WHERE procedure_type_id = '$typeid'");
161 // Get parent ID so we can refresh the tree view.
162 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
163 "procedure_type_id = '$typeid'");
164 $parent = $row['parent'];
166 $newid = sqlInsert("INSERT INTO procedure_type SET parent = '$parent', $sets");
167 // $newid is not really used in this script
171 else if ($_POST['form_delete']) {
174 // Get parent ID so we can refresh the tree view after deleting.
175 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
176 "procedure_type_id = '$typeid'");
177 $parent = $row['parent'];
178 recursiveDelete($typeid);
183 if ($_POST['form_save'] ||
$_POST['form_delete']) {
184 // Find out if this parent still has any children.
185 $trow = sqlQuery("SELECT procedure_type_id FROM procedure_type WHERE parent = '$parent' LIMIT 1");
186 $haskids = empty($trow['procedure_type_id']) ?
'false' : 'true';
187 // Close this window and redisplay the updated list.
188 echo "<script language='JavaScript'>\n";
189 if ($info_msg) echo " alert('$info_msg');\n";
190 echo " window.close();\n";
191 echo " if (opener.refreshFamily) opener.refreshFamily($parent,$haskids);\n";
192 echo "</script></body></html>\n";
197 $row = sqlQuery("SELECT * FROM procedure_type WHERE procedure_type_id = '$typeid'");
200 <form method
='post' name
='theform'
201 action
='types_edit.php?typeid=<?php echo $typeid ?>&parent=<?php echo $parent ?>'>
202 <!-- no
restoreSession() on submit because session data are not relevant
-->
206 <table border
='0' width
='100%'>
209 <td width
='1%' nowrap
><b
><?php
echo xlt('Procedure Type'); ?
>:</b
></td
>
212 echo generate_select_list('form_procedure_type', 'proc_type', $row['procedure_type'],
213 xl('The type of this entity'), ' ', '', 'proc_type_changed()');
219 <td nowrap
><b
><?php
echo xlt('Name'); ?
>:</b
></td
>
221 <input type
='text' size
='40' name
='form_name' maxlength
='63'
222 value
='<?php echo htmlspecialchars($row['name
'], ENT_QUOTES); ?>'
223 title
='<?php echo xlt('Your name
for this category
, procedure
or result
'); ?>'
224 style
='width:100%' class='inputtext' />
229 <td nowrap
><b
><?php
echo xlt('Description'); ?
>:</b
></td
>
231 <input type
='text' size
='40' name
='form_description' maxlength
='255'
232 value
='<?php echo htmlspecialchars($row['description
'], ENT_QUOTES); ?>'
233 title
='<?php echo xlt('Description of this procedure
or result code
'); ?>'
234 style
='width:100%' class='inputtext' />
239 <td nowrap
><b
><?php
echo xlt('Sequence'); ?
>:</b
></td
>
241 <input type
='text' size
='4' name
='form_seq' maxlength
='11'
242 value
='<?php echo $row['seq
'] + 0; ?>'
243 title
='<?php echo xla('Relative ordering of this entity
'); ?>'
249 <td width
='1%' nowrap
><b
><?php
echo xlt('Order From'); ?
>:</b
></td
>
251 <select name
='form_lab_id' title
='<?php echo xla('The entity performing this procedure
'); ?>'>
253 $ppres = sqlStatement("SELECT ppid, name FROM procedure_providers " .
254 "ORDER BY name, ppid");
255 while ($pprow = sqlFetchArray($ppres)) {
256 echo "<option value='" . attr($pprow['ppid']) . "'";
257 if ($pprow['ppid'] == $row['lab_id']) echo " selected";
258 echo ">" . text($pprow['name']) . "</option>";
265 <tr
class='ordonly resonly'>
266 <td nowrap
><b
><?php
echo xlt('Identifying Code'); ?
>:</b
></td
>
268 <input type
='text' size
='40' name
='form_procedure_code' maxlength
='31'
269 value
='<?php echo htmlspecialchars($row['procedure_code
'], ENT_QUOTES); ?>'
270 title
='<?php echo xla('The vendor
-specific code identifying this procedure
or result
'); ?>'
271 style
='width:100%' class='inputtext' />
276 <td nowrap
><b
><?php
echo xlt('Standard Code'); ?
>:</b
></td
>
278 <input type
='text' size
='50' name
='form_standard_code'
279 value
='<?php echo $row['standard_code
'] ?>' onclick
='sel_related("form_standard_code")'
280 title
='<?php echo xla('Click to select an industry
-standard code
for this procedure
'); ?>'
281 style
='width:100%' readonly
/>
286 <td width
='1%' nowrap
><b
><?php
echo xlt('Body Site'); ?
>:</b
></td
>
289 generate_form_field(array('data_type' => 1, 'field_id' => 'body_site',
290 'list_id' => 'proc_body_site',
291 'description' => xl('Body site, if applicable')), $row['body_site']);
297 <td width
='1%' nowrap
><b
><?php
echo xlt('Specimen Type'); ?
>:</b
></td
>
300 generate_form_field(array('data_type' => 1, 'field_id' => 'specimen',
301 'list_id' => 'proc_specimen',
302 'description' => xl('Specimen Type')),
309 <td width
='1%' nowrap
><b
><?php
echo xlt('Administer Via'); ?
>:</b
></td
>
312 generate_form_field(array('data_type' => 1, 'field_id' => 'route_admin',
313 'list_id' => 'proc_route',
314 'description' => xl('Route of administration, if applicable')),
315 $row['route_admin']);
321 <td width
='1%' nowrap
><b
><?php
echo xlt('Laterality'); ?
>:</b
></td
>
324 generate_form_field(array('data_type' => 1, 'field_id' => 'laterality',
325 'list_id' => 'proc_lat',
326 'description' => xl('Laterality of this procedure, if applicable')),
333 <td width
='1%' nowrap
><b
><?php
echo xlt('Default Units'); ?
>:</b
></td
>
336 generate_form_field(array('data_type' => 1, 'field_id' => 'units',
337 'list_id' => 'proc_unit',
338 'description' => xl('Optional default units for manual entry of results')),
345 <td nowrap
><b
><?php
echo xlt('Default Range'); ?
>:</b
></td
>
347 <input type
='text' size
='40' name
='form_range' maxlength
='255'
348 value
='<?php echo htmlspecialchars($row['range
'], ENT_QUOTES); ?>'
349 title
='<?php echo xla('Optional
default range
for manual entry of results
'); ?>'
350 style
='width:100%' class='inputtext' />
355 <td nowrap
><b
><?php
echo xlt('Followup Services'); ?
>:</b
></td
>
357 <input type
='text' size
='50' name
='form_related_code'
358 value
='<?php echo $row['related_code
'] ?>' onclick
='sel_related("form_related_code")'
359 title
='<?php echo xla('Click to select services to perform
if this result is abnormal
'); ?>'
360 style
='width:100%' readonly
/>
368 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
370 <?php
if ($typeid) { ?
>
372 <input type
='submit' name
='form_delete' value
='<?php echo xla('Delete
'); ?>' style
='color:red' />
376 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />