Feature to add drug-drug interaction checking for the
[openemr.git] / interface / orders / types.php
blob322067a85080ea027e263ae8bfef0808765b874a
1 <?php
2 /**
3 * Copyright (C) 2010-2012 Rod Roark <rod@sunsetsystems.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 */
11 require_once("../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/formdata.inc.php");
15 // This script can be run either inside the OpenEMR frameset for order catalog
16 // maintenance, or as a popup window for selecting an item to order. In the
17 // popup case the GET variables 'popup' (a boolean) and 'order' (an optional
18 // item ID to select) will be provided, and maintenance may also be permitted.
20 $popup = empty($_GET['popup']) ? 0 : 1;
21 $order = formData('order', 'G') + 0;
22 $labid = formData('labid', 'G') + 0;
24 // If Save was clicked, set the result, close the window and exit.
26 if ($popup && $_POST['form_save']) {
27 $form_order = formData('form_order') + 0;
28 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
29 "procedure_type_id = '$form_order'");
30 $name = addslashes($ptrow['name']);
32 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
33 <script language="JavaScript">
34 if (opener.closed || ! opener.set_proc_type) {
35 alert('<?php xl('The destination form was closed; I cannot act on your selection.','e'); ?>');
37 else {
38 opener.set_proc_type(<?php echo "$form_order, '$name'" ?>);
39 <?php
40 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
41 // GET parms needed for this are: formid, formseq.
42 if (isset($_GET['formid'])) {
43 require_once("qoe.inc.php");
44 $qoe_init_javascript = '';
45 echo ' opener.set_proc_html("';
46 echo generate_qoe_html($form_order, intval($_GET['formid']), 0, intval($_GET['formseq']));
47 echo '", "' . $qoe_init_javascript . '");' . "\n";
51 window.close(); // comment out for debugging
52 </script>
53 <?php
54 exit();
56 // end Save logic
59 <html>
61 <head>
63 <title><?php xl('Order and Result Types','e'); ?></title>
65 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
67 <style type="text/css">
68 body {
69 font-family:sans-serif;
70 font-size:9pt;
71 font-weight:normal;
72 padding: 5px 3px 5px 3px;
74 #con0 table {
75 margin:0;
76 padding:0;
77 width:100%;
79 #con0 td {
80 padding:0pt;
81 font-family:sans-serif;
82 font-size:9pt;
84 .plusminus {
85 font-family:monospace;
86 font-size:10pt;
88 .haskids {
89 color:#0000dd;
90 cursor:pointer;
91 cursor:hand;
93 tr.head {
94 font-size:10pt;
95 background-color:#cccccc;
96 font-weight:bold;
98 tr.evenrow {
99 background-color:#ddddff;
101 tr.oddrow {
102 background-color:#ffffff;
105 .col1 {width:35%}
106 .col2 {width:8%}
107 .col3 {width:12%}
108 .col4 {width:35%}
109 .col5 {width:10%}
110 </style>
112 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js" type="text/javascript"></script>
113 <?php if ($popup) { ?>
114 <script type="text/javascript" src="../../library/topdialog.js"></script>
115 <?php } ?>
116 <script type="text/javascript" src="../../library/dialog.js"></script>
118 <script language="JavaScript">
120 <?php if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
122 <?php
123 // Create array of IDs to pre-select, leaf to top.
124 echo "preopen = [";
125 echo $order > 0 ? $order : 0;
126 for ($parentid = $order; $parentid > 0;) {
127 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
128 $parentid = $row['parent'] + 0;
129 echo ", $parentid";
131 echo "];\n";
134 // initiate by loading the top-level nodes
135 $(document).ready(function(){
136 nextOpen();
139 // This is called repeatedly at initialization until all desired nodes
140 // have been opened.
141 function nextOpen() {
142 if (preopen.length) {
143 var thisid = preopen.pop();
144 if (thisid == 0 || preopen.length > 0) {
145 if (thisid > 0)
146 toggle(thisid);
147 else
148 $.getScript('types_ajax.php?id=' + thisid + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
150 else {
151 recolor();
154 else {
155 recolor();
159 // toggle expansion indicator from + to - or vice versa
160 function swapsign(td1, from, to) {
161 var s = td1.html();
162 var i = s.indexOf('>' + from + '<');
163 if (i >= 0) td1.html(s.substring(0,i+1) + to + s.substring(i+2));
166 // onclick handler to expand or collapse a node
167 function toggle(id) {
168 var td1 = $('#td' + id);
169 if (!td1.hasClass('haskids')) return;
170 if (td1.hasClass('isExpanded')) {
171 $('#con' + id).remove();
172 td1.removeClass('isExpanded');
173 swapsign(td1, '-', '+');
174 recolor();
176 else {
177 td1.parent().after('<tr class="outertr"><td colspan="5" id="con' + id + '" style="padding:0">Loading...</td></tr>');
178 td1.addClass('isExpanded');
179 swapsign(td1, '+', '-');
180 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
184 // Called by the edit window to refresh a given node's children
185 function refreshFamily(id, haskids) {
186 if (id) { // id == 0 means top level
187 var td1 = $('#td' + id);
188 if (td1.hasClass('isExpanded')) {
189 $('#con' + id).remove();
190 td1.removeClass('isExpanded');
191 swapsign(td1, '-', '+');
193 if (td1.hasClass('haskids') && !haskids) {
194 td1.removeClass('haskids');
195 // swapsign(td1, '+', '.');
196 swapsign(td1, '+', '|');
197 return;
199 if (!td1.hasClass('haskids') && haskids) {
200 td1.addClass('haskids');
201 // swapsign(td1, '.', '+');
202 swapsign(td1, '|', '+');
204 if (haskids) {
205 td1.parent().after('<tr class="outertr"><td colspan="5" id="con' + id + '" style="padding:0">Loading...</td></tr>');
206 td1.addClass('isExpanded');
207 swapsign(td1, '+', '-');
210 if (haskids)
211 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
212 else
213 recolor();
216 // edit a node
217 function enode(id) {
218 dlgopen('types_edit.php?parent=0&typeid=' + id, '_blank', 700, 550);
221 // add a node
222 function anode(id) {
223 dlgopen('types_edit.php?typeid=0&parent=' + id, '_blank', 700, 550);
226 // call this to alternate row colors when anything changes the number of rows
227 function recolor() {
228 var i = 0;
229 $('#con0 tr').each(function(index) {
230 // skip any row that contains other rows
231 if ($(this).hasClass('outertr')) return;
232 this.className = (i++ & 1) ? "evenrow" : "oddrow";
236 </script>
238 </head>
240 <body class="body_nav">
241 <center>
243 <h3 style='margin-top:0'><?php xl('Types of Orders and Results','e') ?></h3>
245 <form method='post' name='theform' action='types.php?popup=<?php echo $popup ?>&order=<?php
246 echo $order;
247 if (isset($_GET['formid' ])) echo '&formid=' . $_GET['formid'];
248 if (isset($_GET['formseq'])) echo '&formseq=' . $_GET['formseq'];
249 ?>'>
251 <table width='100%' cellspacing='0' cellpadding='0' border='0'>
252 <tr class='head'>
253 <th class='col1' align='left'>&nbsp;&nbsp;<?php xl('Name','e') ?></th>
254 <th class='col2' align='left'><?php xl('Order','e') ?></th>
255 <th class='col3' align='left'><?php xl('Code','e') ?></th>
256 <th class='col4' align='left'><?php xl('Description','e') ?></th>
257 <th class='col5' align='left'>&nbsp;</th>
258 </tr>
259 </table>
261 <div id="con0">
262 </div>
265 <?php if ($popup) { ?>
266 <input type='submit' name='form_save' value='<?php xl('Save','e'); ?>' />
267 &nbsp;
268 <input type='button' value=<?php xl('Cancel','e'); ?> onclick='window.close()' />
269 &nbsp;
270 <?php } ?>
271 <input type='button' value='<?php xl('Add Top Level','e'); ?>' onclick='anode(0)' />
272 </p>
274 </form>
276 </center>
278 </body>
279 </html>