Update Procedures Functionality (#1775)
[openemr.git] / interface / orders / types.php
blob190d2b5cc1bcf808d83a354aaea241cb0bf69572
1 <?php
2 /**
3 * types.php
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Jerry Padgett <sjpadgett@gmail.com>
10 * @copyright Copyright (c) 2010-2012 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/acl.inc");
17 use OpenEMR\Core\Header;
19 // This script can be run either inside the OpenEMR frameset for order catalog
20 // maintenance, or as a popup window for selecting an item to order. In the
21 // popup case the GET variables 'popup' (a boolean) and 'order' (an optional
22 // item ID to select) will be provided, and maintenance may also be permitted.
24 $popup = empty($_GET['popup']) ? 0 : 1;
25 $order = isset($_GET['order']) ? $_GET['order'] + 0 : 0;
26 $labid = isset($_GET['labid']) ? $_GET['labid'] + 0 : 0;
28 // If Save was clicked, set the result, close the window and exit.
30 if ($popup && $_POST['form_save']) {
31 $form_order = isset($_GET['form_order']) ? $_GET['form_order'] + 0 : 0;
32 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " . "procedure_type_id = '$form_order'");
33 $name = addslashes($ptrow['name']);
35 <script type="text/javascript"
36 src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js">
37 </script>
38 <script language="JavaScript">
39 if (opener.closed || ! opener.set_proc_type) {
40 alert('<?php echo xlt('The destination form was closed; I cannot act on your selection.'); ?>');
41 } else {
42 opener.set_proc_type(<?php echo "$form_order, '$name'" ?>);
43 <?php
44 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
45 // GET parms needed for this are: formid, formseq.
46 if (isset($_GET['formid'])) {
47 require_once("qoe.inc.php");
48 $qoe_init_javascript = '';
49 echo ' opener.set_proc_html("';
50 echo generate_qoe_html($form_order, intval($_GET['formid']), 0, intval($_GET['formseq']));
51 echo '", "' . $qoe_init_javascript . '");' . "\n";
55 window.close(); // comment out for debugging
56 </script>
57 <?php
58 exit();
60 // end Save logic
63 <!DOCTYPE html>
64 <html>
66 <head>
67 <?php Header::setupHeader(['opener', 'datetime-picker', 'jquery-ui', 'jquery-ui-base']);?>
69 <title><?php echo xlt('Configure Orders and Results'); ?></title>
71 <style type="text/css">
72 #con0 table {
73 margin: 0;
74 padding: 0;
75 width: 100%;
77 #con0 td {
78 /*padding: 0;*/
79 font-family: sans-serif;
80 font-size: 11px;
81 line-height: 25px;
83 .plusminus {
84 font-family: monospace;
85 /*font-size: 11px;*/
87 .haskids {
88 color: #0000dd;
89 cursor: pointer;
90 cursor: hand;
92 tr.head {
93 font-size: 14px;
94 background-color: #cccccc;
95 font-weight: bold;
97 tr.evenrow {
98 background-color: #ddddff;
100 tr.oddrow {
101 background-color: #ffffff;
103 tr.outertr {
104 padding: 0px 0px 0px 10px;
106 td {
107 line-height: 25px;
109 .col1 {
110 width: 33%
112 .col2 {
113 width: 12%
115 .col3 {
116 width: 8%
118 .col4 {
119 width: 28%
121 .col5 {
122 width: 10%
124 .col6 {
125 width: 8%
127 .oe-bold {
128 font-weight: 700;
130 .oe-grp {
131 font-size: 16px !important;
132 font-weight: 900;
133 /*padding-left:0;*/
135 .oe-ord {
136 font-weight: 800;
138 .oe-pl0 {
139 padding-left: 0 !important;
141 .oe-pl10 {
142 padding-left: 10px;
144 .oe-pl20 {
145 padding-left: 20px;
147 .oe-pl30 {
148 padding-left: 30px;
150 .oe-pl40 {
151 padding-left: 40px;
153 .oe-pl50 {
154 padding-left: 50px;
156 .oe-pl60 {
157 padding-left: 60px;
159 .oe-pl-final {
160 padding-left: 70px;
162 </style>
165 <?php
166 if ($popup) { ?>
167 <script type="text/javascript" src="../../library/topdialog.js"></script>
168 <?php } ?>
171 <script language="JavaScript">
173 <?php
174 if ($popup) {
175 require($GLOBALS['srcdir'] . "/restoreSession.php");
179 <?php
180 // Create array of IDs to pre-select, leaf to top.
181 echo "preopen = [";
182 echo $order > 0 ? $order : 0;
183 for ($parentid = $order; $parentid > 0;) {
184 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
185 $parentid = $row['parent'] + 0;
186 echo ", $parentid";
189 echo "];\n";
193 // initiate by loading the top-level nodes
194 $(document).ready(function(){
195 nextOpen();
198 // This is called repeatedly at initialization until all desired nodes
199 // have been opened.
200 function nextOpen() {
201 if (preopen.length) {
202 var thisid = preopen.pop();
204 if (thisid == 0 || preopen.length > 0) {
205 if (thisid > 0)
206 toggle(thisid);
207 else
208 $.getScript('types_ajax.php?id=' + thisid + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
210 else {
211 recolor();
214 else {
215 recolor();
219 // toggle expansion indicator from + to - or vice versa
220 function swapsign(td1, from, to) {
221 var s = td1.html();
222 var i = s.indexOf('>' + from + ' <');
223 if (i >= 0) td1.html(s.substring(0,i+1) + to + s.substring(i+2));
226 // onclick handler to expand or collapse a node
227 function toggle(id) {
228 var td1 = $('#td' + id);
229 if (!td1.hasClass('haskids')) return;
230 if (td1.hasClass('isExpanded')) {
231 $('#con' + id).remove();
232 td1.removeClass('isExpanded');
233 swapsign(td1, '-', '+');
234 recolor();
236 else {
237 td1.parent().after('<tr class="outertr"><td colspan="6" id="con' + id + '" style="padding:0">Loading...</td></tr>');
238 td1.addClass('isExpanded');
239 swapsign(td1, '+', '-');
240 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
244 // Called by the edit window to refresh a given node's children
245 function refreshFamily(id, haskids) {
246 if (id) { // id == 0 means top level
247 var td1 = $('#td' + id);
248 if (td1.hasClass('isExpanded')) {
249 $('#con' + id).remove();
250 td1.removeClass('isExpanded');
251 swapsign(td1, '-', '+');
253 if (td1.hasClass('haskids') && !haskids) {
254 td1.removeClass('haskids');
255 // swapsign(td1, '+', '.');
256 swapsign(td1, '+', '|');
257 return;
259 if (!td1.hasClass('haskids') && haskids) {
260 td1.addClass('haskids');
261 // swapsign(td1, '.', '+');
262 swapsign(td1, '|', '+');
264 if (haskids) {
265 td1.parent().after('<tr class="outertr"><td colspan="6" id="con' + id + '" style="padding:0">Loading...</td></tr>');
266 td1.addClass('isExpanded');
267 swapsign(td1, '+', '-');
270 if (haskids)
271 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
272 else
273 recolor();
276 // edit/add a node
277 function handleNode(id, type, add, lab) {
278 if (type > 0) {
279 type = (type === 1 && !add) ? 'fgp' : 'for';
281 let url = 'types_edit.php?addfav=' + type + '&labid=' + lab + '&parent=0&typeid=' + id;
282 if (add) {
283 url = 'types_edit.php?addfav=' + type + '&labid=' + lab + '&typeid=0&parent=' + id;
286 dlgopen(url, '_blank', 800, 850);
289 // call this to alternate row colors when anything changes the number of rows
290 function recolor() {
291 var i = 0;
292 $('#con0 tr').each(function(index) {
293 // skip any row that contains other rows
294 if ($(this).hasClass('outertr')) return;
295 this.className = (i++ & 1) ? "evenrow" : "oddrow";
299 // Callback from popups to refresh this display.
300 function refreshme() {
301 // location.reload();
302 document.forms[0].submit();
304 </script>
306 </head>
308 <body class="body_nav">
309 <?php
310 if ($GLOBALS['enable_help'] == 1) {
311 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="' . xla("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
312 } elseif ($GLOBALS['enable_help'] == 2) {
313 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#DCD6D0 !Important" title="' . xla("To enable help - Go to Administration > Globals > Features > Enable Help Modal") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
314 } elseif ($GLOBALS['enable_help'] == 0) {
315 $help_icon = '';
318 <div class="container">
319 <div class="row">
320 <div class="col-xs-12">
321 <div class="page-header clearfix">
322 <h2 id="header_title" class="clearfix"><span id='header_text'><?php echo xlt('Configure Orders and Results');?></span><?php echo $help_icon; ?></h2>
323 </div>
324 </div>
325 </div>
326 <div class="row">
327 <div class="col-xs-12">
328 <form method='post' name='theform'
329 action='types.php?popup=<?php echo $popup ?>&order=<?php
330 echo $order;
331 if (isset($_GET['formid'])) {
332 echo '&formid=' . $_GET['formid'];
335 if (isset($_GET['formseq'])) {
336 echo '&formseq=' . $_GET['formseq'];
338 ?>'>
339 <div class="btn-group">
340 <button type="button" name="form_search" class="btn btn-default btn-refresh" onclick="refreshme()"><?php echo xlt('Refresh');?></button>
341 <button type="button" class="btn btn-default btn-add" name='add_node_btn' id='add_node_button' onclick='handleNode(0,"","")'><?php echo xlt('Add Top Level');?></button>
342 </div>
343 <br>
344 <br>
345 <div class = "table-responsive">
346 <table class="table" style="margin-bottom:0">
347 <thead>
348 <tr class='head'>
349 <td class='col1' align='left'>&nbsp;&nbsp;<?php echo xlt('Name') ?> <i id="name-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
350 <td class='col2 oe-pl0' align='left'><?php echo xlt('Category') ?> <i id="order-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
351 <td class='col3 oe-pl0' align='left'><?php echo xlt('Code') ?> <i id="code-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
352 <td class='col6 oe-pl0' align='left'><?php echo xlt('Tier') ?> <i id="tier-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
353 <td class='col4 oe-pl0' align='left'><?php echo xlt('Description') ?></td>
354 <td class='col5 oe-pl0' align='left' style='padding-left:0px'><?php echo xlt('Edit/Add') ?></td>
355 </tr>
356 </thead>
357 </table>
358 </div>
359 <div id="con0"></div>
360 <?php //can change position of buttons by creating a class 'position-override' and adding rule text-align:center or right as the case may be in individual stylesheets ?>
361 <div class="form-group clearfix">
362 <div class="col-sm-12 text-left position-override">
363 <div class="btn-group btn-group-pinch" role="group">
364 <?php if ($popup) { ?>
365 <button type="submit" class="btn btn-default btn-save" name='form_save' value='<?php echo xla('Save'); ?>'><?php echo xlt('Save');?></button>
366 <button class="btn btn-link btn-cancel btn-separate-left" onclick="CancelDistribute()"><?php echo xlt('Cancel');?></button>
367 <?php } ?>
368 </div>
369 </div>
370 </div>
371 </form>
372 </div>
373 </div>
374 </div><!--End of Container div-->
375 <br>
376 <?php
377 //home of the help modal ;)
378 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
379 if ($GLOBALS['enable_help'] == 1) {
380 echo "<script>var helpFile = 'configure_orders_help.php'</script>";
381 //help_modal.php lives in interface, set path accordingly
382 require "../help_modal.php";
385 <script>
386 //jqury-ui tooltip
387 $(document).ready(function(){
388 //for jquery tooltip to function if jquery 1.12.1.js is called via jquery-ui in the Header::setupHeader
389 // the relevant css file needs to be called i.e. jquery-ui-darkness - to get a black tooltip
390 $('#name-tooltip').attr( "title", "<?php echo xla('The actual tests or procedures that can be searched for and ordered are highlighted in yellow'); ?>" + ". " + "<?php echo xla('Click on the blue plus sign under Name to reveal test names'); ?>").tooltip();
391 $('#order-tooltip').attr( "title", "<?php echo xla('The entries marked yes can be ordered as a test or procedure'); ?>" + ". " + "<?php echo xla('Click on the blue plus sign under Name to reveal test names'); ?>" ).tooltip();
392 $('#code-tooltip').attr( "title", "<?php echo xla('Category - Order, Result and Recommendation need an identifying code');?>" + ". " + "<?php echo xla('Red Triangle indicates a required code that is missing')?>.").
393 tooltip();
394 $('#tier-tooltip').attr( "title", "<?php echo xla('Shows the hierarchal level of this line');?>" + ". " + "<?php echo xla('Tier 1 entries should be of Category Top Group')?>.").
395 tooltip();
396 $('table td .required-tooltip').attr( "title", "<?php echo xla('For proper tabulated display of tests and results an identifying code is required'); ?>").tooltip();
397 $("table td .required-tooltip").fadeIn(500);
398 $("table td .required-tooltip3").fadeOut(1000);
399 $("table td .required-tooltip").fadeIn(500);
400 $(".plusminus").click(function(){
401 $(".required-tooltip").effect("pulsate", {times:1}, 4000);
404 </script>
406 </body>
407 </html>