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");
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 <script type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
62 <title
><?php
echo $typeid ?
xlt('Edit') : xlt('Add New'); ?
> <?php
echo xlt('Order/Result Type'); ?
></title
>
63 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
66 td
{ font
-size
:10pt
; }
74 font
-family
:sans
-serif
;
84 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
85 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
86 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
88 <script language
="JavaScript">
90 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
92 // The name of the form field for find-code popup results.
95 // This is for callback by the find-code popup.
96 // Appends to or erases the current list of related codes.
97 function set_related(codetype
, code
, selector
, codedesc
) {
98 var f
= document
.forms
[0];
99 var s
= f
[rcvarname
].value
;
101 if (s
.length
> 0) s +
= ';';
102 s +
= codetype +
':' + code
;
106 f
[rcvarname
].value
= s
;
109 // This invokes the find-code popup.
110 function sel_related(varname
) {
111 if (typeof varname
== 'undefined') varname
= 'form_related_code';
113 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 500, 400);
116 // Show or hide sections depending on procedure type.
117 function proc_type_changed() {
118 var f
= document
.forms
[0];
119 var pt
= f
.form_procedure_type
;
120 var ix
= pt
.selectedIndex
;
122 var ptval
= pt
.options
[ix
].value
;
123 var ptpfx
= ptval
.substring(0, 3);
124 $
('.ordonly').hide();
125 $
('.resonly').hide();
126 if (ptpfx
== 'ord') $
('.ordonly').show();
127 if (ptpfx
== 'res'|| ptpfx
== 'rec') $
('.resonly').show();
130 $
(document
).ready(function() {
138 <body
class="body_top">
140 // If we are saving, then save and close the window.
142 if ($_POST['form_save']) {
145 "name = " . invalue('form_name') . ", " .
146 "lab_id = " . invalue('form_lab_id') . ", " .
147 "procedure_code = " . invalue('form_procedure_code') . ", " .
148 "procedure_type = " . invalue('form_procedure_type') . ", " .
149 "body_site = " . invalue('form_body_site') . ", " .
150 "specimen = " . invalue('form_specimen') . ", " .
151 "route_admin = " . invalue('form_route_admin') . ", " .
152 "laterality = " . invalue('form_laterality') . ", " .
153 "description = " . invalue('form_description') . ", " .
154 "units = " . invalue('form_units') . ", " .
155 "`range` = " . invalue('form_range') . ", " .
156 "standard_code = " . invalue('form_standard_code') . ", " .
157 "related_code = " . invalue('form_related_code') . ", " .
158 "seq = " . invalue('form_seq');
161 sqlStatement("UPDATE procedure_type SET $sets WHERE procedure_type_id = '$typeid'");
162 // Get parent ID so we can refresh the tree view.
163 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
164 "procedure_type_id = '$typeid'");
165 $parent = $row['parent'];
167 $newid = sqlInsert("INSERT INTO procedure_type SET parent = '$parent', $sets");
168 // $newid is not really used in this script
172 else if ($_POST['form_delete']) {
175 // Get parent ID so we can refresh the tree view after deleting.
176 $row = sqlQuery("SELECT parent FROM procedure_type WHERE " .
177 "procedure_type_id = '$typeid'");
178 $parent = $row['parent'];
179 recursiveDelete($typeid);
184 if ($_POST['form_save'] ||
$_POST['form_delete']) {
185 // Find out if this parent still has any children.
186 $trow = sqlQuery("SELECT procedure_type_id FROM procedure_type WHERE parent = '$parent' LIMIT 1");
187 $haskids = empty($trow['procedure_type_id']) ?
'false' : 'true';
188 // Close this window and redisplay the updated list.
189 echo "<script language='JavaScript'>\n";
190 if ($info_msg) echo " alert('$info_msg');\n";
191 echo " window.close();\n";
192 echo " if (opener.refreshFamily) opener.refreshFamily($parent,$haskids);\n";
193 echo "</script></body></html>\n";
198 $row = sqlQuery("SELECT * FROM procedure_type WHERE procedure_type_id = '$typeid'");
201 <form method
='post' name
='theform'
202 action
='types_edit.php?typeid=<?php echo $typeid ?>&parent=<?php echo $parent ?>'>
203 <!-- no
restoreSession() on submit because session data are not relevant
-->
207 <table border
='0' width
='100%'>
210 <td width
='1%' nowrap
><b
><?php
echo xlt('Procedure Type'); ?
>:</b
></td
>
213 echo generate_select_list('form_procedure_type', 'proc_type', $row['procedure_type'],
214 xl('The type of this entity'), ' ', '', 'proc_type_changed()');
220 <td nowrap
><b
><?php
echo xlt('Name'); ?
>:</b
></td
>
222 <input type
='text' size
='40' name
='form_name' maxlength
='63'
223 value
='<?php echo htmlspecialchars($row['name
'], ENT_QUOTES); ?>'
224 title
='<?php echo xlt('Your name
for this category
, procedure
or result
'); ?>'
225 style
='width:100%' class='inputtext' />
230 <td nowrap
><b
><?php
echo xlt('Description'); ?
>:</b
></td
>
232 <input type
='text' size
='40' name
='form_description' maxlength
='255'
233 value
='<?php echo htmlspecialchars($row['description
'], ENT_QUOTES); ?>'
234 title
='<?php echo xlt('Description of this procedure
or result code
'); ?>'
235 style
='width:100%' class='inputtext' />
240 <td nowrap
><b
><?php
echo xlt('Sequence'); ?
>:</b
></td
>
242 <input type
='text' size
='4' name
='form_seq' maxlength
='11'
243 value
='<?php echo $row['seq
'] + 0; ?>'
244 title
='<?php echo xla('Relative ordering of this entity
'); ?>'
250 <td width
='1%' nowrap
><b
><?php
echo xlt('Order From'); ?
>:</b
></td
>
252 <select name
='form_lab_id' title
='<?php echo xla('The entity performing this procedure
'); ?>'>
254 $ppres = sqlStatement("SELECT ppid, name FROM procedure_providers " .
255 "ORDER BY name, ppid");
256 while ($pprow = sqlFetchArray($ppres)) {
257 echo "<option value='" . attr($pprow['ppid']) . "'";
258 if ($pprow['ppid'] == $row['lab_id']) echo " selected";
259 echo ">" . text($pprow['name']) . "</option>";
266 <tr
class='ordonly resonly'>
267 <td nowrap
><b
><?php
echo xlt('Identifying Code'); ?
>:</b
></td
>
269 <input type
='text' size
='40' name
='form_procedure_code' maxlength
='31'
270 value
='<?php echo htmlspecialchars($row['procedure_code
'], ENT_QUOTES); ?>'
271 title
='<?php echo xla('The vendor
-specific code identifying this procedure
or result
'); ?>'
272 style
='width:100%' class='inputtext' />
277 <td nowrap
><b
><?php
echo xlt('Standard Code'); ?
>:</b
></td
>
280 <input type
='text' size
='50' name
='form_standard_code'
281 value
='<?php echo $row['standard_code
'] ?>' onclick
='sel_related("form_standard_code")'
282 title
='<?php echo xla('Click to select an industry
-standard code
for this procedure
'); ?>'
283 style
='width:100%' readonly
/>
285 <input type
='text' size
='50' name
='form_standard_code'
286 value
='<?php echo attr($row['standard_code
']); ?>'
287 title
='<?php echo xla('Enter the LOINC code
for this procedure
'); ?>'
288 style
='width:100%' />
293 <td width
='1%' nowrap
><b
><?php
echo xlt('Body Site'); ?
>:</b
></td
>
296 generate_form_field(array('data_type' => 1, 'field_id' => 'body_site',
297 'list_id' => 'proc_body_site',
298 'description' => xl('Body site, if applicable')), $row['body_site']);
304 <td width
='1%' nowrap
><b
><?php
echo xlt('Specimen Type'); ?
>:</b
></td
>
307 generate_form_field(array('data_type' => 1, 'field_id' => 'specimen',
308 'list_id' => 'proc_specimen',
309 'description' => xl('Specimen Type')),
316 <td width
='1%' nowrap
><b
><?php
echo xlt('Administer Via'); ?
>:</b
></td
>
319 generate_form_field(array('data_type' => 1, 'field_id' => 'route_admin',
320 'list_id' => 'proc_route',
321 'description' => xl('Route of administration, if applicable')),
322 $row['route_admin']);
328 <td width
='1%' nowrap
><b
><?php
echo xlt('Laterality'); ?
>:</b
></td
>
331 generate_form_field(array('data_type' => 1, 'field_id' => 'laterality',
332 'list_id' => 'proc_lat',
333 'description' => xl('Laterality of this procedure, if applicable')),
340 <td width
='1%' nowrap
><b
><?php
echo xlt('Default Units'); ?
>:</b
></td
>
343 generate_form_field(array('data_type' => 1, 'field_id' => 'units',
344 'list_id' => 'proc_unit',
345 'description' => xl('Optional default units for manual entry of results')),
352 <td nowrap
><b
><?php
echo xlt('Default Range'); ?
>:</b
></td
>
354 <input type
='text' size
='40' name
='form_range' maxlength
='255'
355 value
='<?php echo htmlspecialchars($row['range
'], ENT_QUOTES); ?>'
356 title
='<?php echo xla('Optional
default range
for manual entry of results
'); ?>'
357 style
='width:100%' class='inputtext' />
362 <td nowrap
><b
><?php
echo xlt('Followup Services'); ?
>:</b
></td
>
364 <input type
='text' size
='50' name
='form_related_code'
365 value
='<?php echo $row['related_code
'] ?>' onclick
='sel_related("form_related_code")'
366 title
='<?php echo xla('Click to select services to perform
if this result is abnormal
'); ?>'
367 style
='width:100%' readonly
/>
375 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
377 <?php
if ($typeid) { ?
>
379 <input type
='submit' name
='form_delete' value
='<?php echo xla('Delete
'); ?>' style
='color:red' />
383 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />