Fix: Revert "Fix: OpenEMR logs sensitive information such as payment details (#7341...
[openemr.git] / interface / orders / types.php
blob4ad135f52183f999dd230fc08ea9e4b36e1c7ffa
1 <?php
3 /**
4 * types.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @author Jerry Padgett <sjpadgett@gmail.com>
11 * @copyright Copyright (c) 2010-2012 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../globals.php");
18 use OpenEMR\Common\Acl\AclMain;
19 use OpenEMR\Common\Twig\TwigContainer;
20 use OpenEMR\Core\Header;
22 // This script can be run either inside the OpenEMR frameset for order catalog
23 // maintenance, or as a popup window for selecting an item to order. In the
24 // popup case the GET variables 'popup' (a boolean) and 'order' (an optional
25 // item ID to select) will be provided, and maintenance may also be permitted.
27 $popup = empty($_GET['popup']) ? 0 : 1;
28 $order = isset($_GET['order']) ? $_GET['order'] + 0 : 0;
29 $labid = isset($_GET['labid']) ? $_GET['labid'] + 0 : 0;
31 if (!$popup && !AclMain::aclCheckCore('admin', 'super')) {
32 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Configure Orders and Results")]);
33 exit;
35 if ($popup && !AclMain::aclCheckCore('patients', 'lab') && !AclMain::aclCheckCore('admin', 'super')) {
36 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Configure Orders and Results")]);
37 exit;
40 // If Save was clicked, set the result, close the window and exit.
42 if ($popup && $_POST['form_save'] ?? '') {
43 $form_order = isset($_REQUEST['form_order']) ? $_REQUEST['form_order'] + 0 : 0;
44 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE procedure_type_id = ?", [$form_order]);
45 $name = $ptrow['name'];
47 <script src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
48 <script>
49 if (opener.closed || ! opener.set_proc_type) {
50 alert(<?php echo xlj('The destination form was closed; I cannot act on your selection.'); ?>);
51 } else {
52 opener.set_proc_type(<?php echo js_escape($form_order) . ", " . js_escape($name); ?>);
53 <?php
54 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
55 // GET parms needed for this are: formid, formseq.
56 if (isset($_GET['formid'])) {
57 require_once("qoe.inc.php");
58 $qoe_init_javascript = '';
59 echo ' opener.set_proc_html("';
60 echo generate_qoe_html($form_order, (int)$_GET['formid'], 0, (int)$_GET['formseq']);
61 echo '", "' . $qoe_init_javascript . '");' . "\n";
65 window.close(); // comment out for debugging
66 </script>
67 <?php
68 exit();
70 // end Save logic
73 <!DOCTYPE html>
74 <html>
76 <head>
77 <?php Header::setupHeader(['opener', 'datetime-picker']);?>
79 <title><?php echo xlt('Configure Orders and Results'); ?></title>
81 <style>
82 #con0 table {
83 margin: 0;
84 padding: 0;
85 width: 100%;
87 #con0 td {
88 font-family: sans-serif;
89 font-size: 11px;
90 line-height: 25px;
92 .plusminus {
93 font-family: monospace;
95 .haskids {
96 color: #0000dd;
97 cursor: pointer;
98 cursor: hand;
100 tr.head {
101 font-size: 14px;
102 background-color: var(--light);
103 font-weight: bold;
105 tr.evenrow {
106 background-color: var(--light);
108 tr.oddrow {
109 background-color: var(--white);
111 tr.outertr {
112 padding: 0px 0px 0px 10px;
114 td {
115 line-height: 25px;
117 .col1 {
118 width: 33%;
120 .col2 {
121 width: 12%;
123 .col3 {
124 width: 8%;
126 .col4 {
127 width: 28%;
129 .col5 {
130 width: 5%;
132 .col6 {
133 width: 8%;
135 .tooltip {
136 pointer-events: none;
138 </style>
141 <?php
142 if ($popup) { ?>
143 <?php Header::setupAssets('topdialog'); ?>
144 <?php } ?>
147 <script>
149 <?php
150 if ($popup) {
151 require($GLOBALS['srcdir'] . "/restoreSession.php");
155 <?php
156 // Create array of IDs to pre-select, leaf to top.
157 echo "preopen = [";
158 echo $order > 0 ? $order : 0;
159 for ($parentid = $order; $parentid > 0;) {
160 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = ?", [$parentid]);
161 $parentid = (int) $row['parent'];
162 echo ", $parentid";
165 echo "];\n";
169 // initiate by loading the top-level nodes
170 $(function () {
171 nextOpen();
174 // This is called repeatedly at initialization until all desired nodes
175 // have been opened.
176 function nextOpen() {
177 if (preopen.length) {
178 var thisid = preopen.pop();
180 if (thisid == 0 || preopen.length > 0) {
181 if (thisid > 0) {
182 toggle(thisid);
183 } else {
184 $.getScript('types_ajax.php?id=' + encodeURIComponent(thisid) + '&order=' + <?php echo js_url($order); ?> + '&labid=' + <?php echo js_url($labid); ?>);
186 } else {
187 recolor();
189 } else {
190 recolor();
194 // toggle expansion indicator from + to - or vice versa
195 function swapsign(td1, from, to) {
196 var s = td1.html();
197 var i = s.indexOf('>' + from + ' <');
198 if (i >= 0) {
199 td1.html(s.substring(0,i+1) + to + s.substring(i+2));
203 // onclick handler to expand or collapse a node
204 function toggle(id) {
205 var td1 = $('#td' + id);
206 if (!td1.hasClass('haskids')) {
207 return;
209 if (td1.hasClass('isExpanded')) {
210 $('#con' + id).remove();
211 td1.removeClass('isExpanded');
212 swapsign(td1, '-', '+');
213 recolor();
214 } else {
215 td1.parent().after('<tr class="outertr"><td colspan="7" class="p-0" id="con' + id + '">Loading...</td></tr>');
216 td1.addClass('isExpanded');
217 swapsign(td1, '+', '-');
218 $.getScript('types_ajax.php?id=' + encodeURIComponent(id) + '&order=' + <?php echo js_url($order); ?> + '&labid=' + <?php echo js_url($labid); ?>);
222 // Called by the edit window to refresh a given node's children
223 function refreshFamily(id, haskids) {
224 if (id) { // id == 0 means top level
225 var td1 = $('#td' + id);
226 if (td1.hasClass('isExpanded')) {
227 $('#con' + id).remove();
228 td1.removeClass('isExpanded');
229 swapsign(td1, '-', '+');
231 if (td1.hasClass('haskids') && !haskids) {
232 td1.removeClass('haskids');
233 swapsign(td1, '+', '|');
234 return;
236 if (!td1.hasClass('haskids') && haskids) {
237 td1.addClass('haskids');
238 swapsign(td1, '|', '+');
240 if (haskids) {
241 td1.parent().after('<tr class="outertr"><td colspan="7" class="p-0" id="con' + id + '">Loading...</td></tr>');
242 td1.addClass('isExpanded');
243 swapsign(td1, '+', '-');
246 if (haskids) {
247 $.getScript('types_ajax.php?id=' + encodeURIComponent(id) + '&order=' + <?php echo js_url($order); ?> + '&labid=' + <?php echo js_url($labid); ?>);
248 } else {
249 recolor();
253 // edit/add a node
254 function handleNode(id, type, add, lab) {
255 var editTitle = '<i class="fa fa-pencil-alt" style="width:20px;" aria-hidden="true"></i> ' + <?php echo xlj("Edit Mode"); ?> + ' ';
256 var addTitle = '<i class="fa fa-plus" style="width:20px;" aria-hidden="true"></i> ' + <?php echo xlj("Add Mode"); ?>;
257 if (type > 0) {
258 type = (type === 1 && !add) ? 'fgp' : 'for';
260 let url = 'types_edit.php?addfav=' + encodeURIComponent(type) + '&labid=' + encodeURIComponent(lab) + '&parent=0&typeid=' + encodeURIComponent(id);
262 if (add) {
263 url = 'types_edit.php?addfav=' + encodeURIComponent(type) + '&labid=' + encodeURIComponent(lab) + '&typeid=0&parent=' + encodeURIComponent(id);
264 dlgopen(url, '_blank', 800, 750, false, addTitle);
265 } else {
266 dlgopen(url, '_blank', 800, 750, false, editTitle);
270 // call this to alternate row colors when anything changes the number of rows
271 function recolor() {
272 var i = 0;
273 $('#con0 tr').each(function(index) {
274 // skip any row that contains other rows
275 if ($(this).hasClass('outertr')) {
276 return;
278 this.className = (i++ & 1) ? "evenrow" : "oddrow";
282 // Callback from popups to refresh this display.
283 function refreshme() {
284 // location.reload();
285 document.forms[0].submit();
287 </script>
289 </head>
291 <body>
292 <?php
293 if ($GLOBALS['enable_help'] == 1) {
294 $help_icon = '<a class="oe-pull-away 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>';
295 } elseif ($GLOBALS['enable_help'] == 2) {
296 $help_icon = '<a class="oe-pull-away 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>';
297 } elseif ($GLOBALS['enable_help'] == 0) {
298 $help_icon = '';
301 <div class="container mt-3">
302 <div class="row">
303 <div class="col-sm-12">
304 <h2 id="header_title"><span id='header_text'><?php echo xlt('Configure Orders and Results');?></span><?php echo $help_icon; ?></h2>
305 </div>
306 </div>
307 <div class="row">
308 <div class="col-sm-12">
309 <form method='post' name='theform'
310 action='types.php?popup=<?php echo attr_url($popup); ?>&order=<?php
311 echo attr_url($order);
312 if (isset($_GET['formid'])) {
313 echo '&formid=' . attr_url($_GET['formid']);
316 if (isset($_GET['formseq'])) {
317 echo '&formseq=' . attr_url($_GET['formseq']);
319 ?>'>
320 <div class="btn-group">
321 <button type="button" class="btn btn-primary btn-add" name='add_node_btn' id='add_node_button' onclick='handleNode(0,"",true,"")'>
322 <?php echo xlt('Add Top Level');?>
323 </button>
324 <button type="button" name="form_search" class="btn btn-primary btn-refresh" onclick="refreshme()">
325 <?php echo xlt('Refresh');?>
326 </button>
327 </div>
328 <br />
329 <br />
330 <div class="table-responsive">
331 <table class="table mb-0">
332 <thead>
333 <tr class='head'>
334 <td class='col1 text-left'>&nbsp;&nbsp;<?php echo xlt('Name') ?> <i id="name-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
335 <td class='col2 oe-pl0 text-left'><?php echo xlt('Category') ?> <i id="order-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
336 <td class='col3 oe-pl0 text-left'><?php echo xlt('Code') ?> <i id="code-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
337 <td class='col6 oe-pl0 text-left'><?php echo xlt('Tier') ?> <i id="tier-tooltip" class="fa fa-info-circle oe-text-black" aria-hidden="true"></i></td>
338 <td class='col4 oe-pl0 text-left'><?php echo xlt('Description') ?></td>
339 <td class='col5 oe-pl0 text-left'><?php echo xlt('Edit') ?></td>
340 <td class='col5 oe-pl0 text-center'><?php echo xlt('Add') ?></td>
341 </tr>
342 </thead>
343 </table>
344 </div>
345 <div id="con0"></div>
346 <?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 ?>
347 <div class="form-group">
348 <div class="col-sm-12 text-left position-override">
349 <div class="btn-group" role="group">
350 <?php if ($popup) { ?>
351 <button type="submit" class="btn btn-primary btn-save" name='form_save' value='<?php echo xla('Save'); ?>'>
352 <?php echo xlt('Save');?>
353 </button>
354 <button class="btn btn-secondary btn-cancel" onclick="CancelDistribute()">
355 <?php echo xlt('Cancel');?>
356 </button>
357 <?php } ?>
358 </div>
359 </div>
360 </div>
361 </form>
362 </div>
363 </div>
364 </div><!--End of Container div-->
365 <?php
366 //home of the help modal ;)
367 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
368 if ($GLOBALS['enable_help'] == 1) {
369 echo "<script>var helpFile = 'configure_orders_help.php'</script>";
370 //help_modal.php lives in interface, set path accordingly
371 require "../help_modal.php";
374 <script>
375 $(function () {
376 $('#name-tooltip').tooltip({
377 title: <?php echo xlj('The actual tests or procedures that can be searched for and ordered are highlighted in yellow'); ?> + ". " + <?php echo xlj('Click on the blue plus sign under Name to reveal test names'); ?>,
378 placement: 'right',
380 $('#order-tooltip').tooltip({
381 title: <?php echo xlj('The entries highlighted in yellow can be ordered as a test or procedure those highlighted in pink can be ordered as a Custom Group'); ?> + ". " + <?php echo xlj('Click on the blue plus sign under Name to reveal test names'); ?>,
382 placement: 'right',
384 $('#code-tooltip').tooltip({
385 title: <?php echo xlj('Category - Order, Result and Recommendation need an identifying code');?> + ". " + <?php echo xlj('Red Triangle indicates a required code that is missing')?> + ".",
386 placement: 'right',
388 $('#tier-tooltip').tooltip({
389 title: <?php echo xlj('Shows the hierarchal level of this line');?> + ". " + <?php echo xlj('Tier 1 entries should be of Category Top Group')?> + ".",
390 placement: 'right',
392 $('table td .required-tooltip').tooltip({
393 title: <?php echo xlj('For proper tabulated display of tests and results an identifying code is required'); ?>,
394 placement: 'right',
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>