Restyling Procedures part 1 (#1774)
[openemr.git] / interface / orders / types.php
blobed1cdb78c01722814c86d8e227bf04390676d110
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: 18px !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 a node
277 function enode(id) {
278 dlgopen('types_edit.php?parent=0&typeid=' + id, '_blank', 800, 750);
281 // add a node
282 function anode(id) {
283 dlgopen('types_edit.php?typeid=0&parent=' + id, '_blank', 800, 750);
286 // call this to alternate row colors when anything changes the number of rows
287 function recolor() {
288 var i = 0;
289 $('#con0 tr').each(function(index) {
290 // skip any row that contains other rows
291 if ($(this).hasClass('outertr')) return;
292 this.className = (i++ & 1) ? "evenrow" : "oddrow";
296 // Callback from popups to refresh this display.
297 function refreshme() {
298 // location.reload();
299 document.forms[0].submit();
301 </script>
303 </head>
305 <body class="body_nav">
306 <?php
307 if ($GLOBALS['enable_help'] == 1) {
308 $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>';
309 } elseif ($GLOBALS['enable_help'] == 2) {
310 $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>';
311 } elseif ($GLOBALS['enable_help'] == 0) {
312 $help_icon = '';
315 <div class="container">
316 <div class="row">
317 <div class="col-xs-12">
318 <div class="page-header clearfix">
319 <h2 id="header_title" class="clearfix"><span id='header_text'><?php echo xlt('Configure Orders and Results');?></span><?php echo $help_icon; ?></h2>
320 </div>
321 </div>
322 </div>
323 <div class="row">
324 <div class="col-xs-12">
325 <form method='post' name='theform'
326 action='types.php?popup=<?php echo $popup ?>&order=<?php
327 echo $order;
328 if (isset($_GET['formid'])) {
329 echo '&formid=' . $_GET['formid'];
332 if (isset($_GET['formseq'])) {
333 echo '&formseq=' . $_GET['formseq'];
335 ?>'>
336 <div class="btn-group">
337 <button type="button" name="form_search" class="btn btn-default btn-refresh" onclick="refreshme()"><?php echo xlt('Refresh');?></button>
338 <button type="button" class="btn btn-default btn-add" name='add_node_btn' id='add_node_button' onclick='anode(0)'><?php echo xlt('Add Top Level');?></button>
339 </div>
340 <br>
341 <br>
342 <div class = "table-responsive">
343 <table class="table" style="margin-bottom:0">
344 <thead>
345 <tr class='head'>
346 <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>
347 <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>
348 <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>
349 <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>
350 <td class='col4 oe-pl0' align='left'><?php echo xlt('Description') ?></td>
351 <td class='col5 oe-pl0' align='left' style='padding-left:0px'><?php echo xlt('Edit/Add') ?></td>
352 </tr>
353 </thead>
354 </table>
355 </div>
356 <div id="con0"></div>
357 <?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 ?>
358 <div class="form-group clearfix">
359 <div class="col-sm-12 text-left position-override">
360 <div class="btn-group btn-group-pinch" role="group">
361 <?php if ($popup) { ?>
362 <button type="submit" class="btn btn-default btn-save" name='form_save' value='<?php echo xla('Save'); ?>'><?php echo xlt('Save');?></button>
363 <button class="btn btn-link btn-cancel btn-separate-left" onclick="CancelDistribute()"><?php echo xlt('Cancel');?></button>
364 <?php } ?>
365 </div>
366 </div>
367 </div>
368 </form>
369 </div>
370 </div>
371 </div><!--End of Container div-->
372 <br>
373 <?php
374 //home of the help modal ;)
375 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
376 if ($GLOBALS['enable_help'] == 1) {
377 echo "<script>var helpFile = 'configure_orders_help.php'</script>";
378 //help_modal.php lives in interface, set path accordingly
379 require "../help_modal.php";
382 <script>
383 //jqury-ui tooltip
384 $(document).ready(function(){
385 //for jquery tooltip to function if jquery 1.12.1.js is called via jquery-ui in the Header::setupHeader
386 // the relevant css file needs to be called i.e. jquery-ui-darkness - to get a black tooltip
387 $('#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();
388 $('#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();
389 $('#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')?>.").
390 tooltip();
391 $('#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')?>.").
392 tooltip();
393 $('table td .required-tooltip').attr( "title", "<?php echo xla('For proper tabulated display of tests and results an identifying code is required'); ?>").tooltip();
394 $("table td .required-tooltip").fadeIn(500);
395 $("table td .required-tooltip3").fadeOut(1000);
396 $("table td .required-tooltip").fadeIn(500);
397 $(".plusminus").click(function(){
398 $(".required-tooltip").effect("pulsate", {times:1}, 4000);
401 </script>
403 </body>
404 </html>