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")]);
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")]);
40 // If Save was clicked, set the result, close the window and exit.
42 if ($popup && $_POST['form_save']) {
43 $form_order = isset($_GET['form_order']) ?
$_GET['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
>
49 if (opener
.closed ||
! opener
.set_proc_type
) {
50 alert(<?php
echo xlj('The destination form was closed; I cannot act on your selection.'); ?
>);
52 opener
.set_proc_type(<?php
echo js_escape($form_order) . ", " . js_escape($name); ?
>);
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
77 <?php Header
::setupHeader(['opener', 'datetime-picker']);?
>
79 <title
><?php
echo xlt('Configure Orders and Results'); ?
></title
>
88 font
-family
: sans
-serif
;
93 font
-family
: monospace
;
102 background
-color
: var(--light
);
106 background
-color
: var(--light
);
109 background
-color
: var(--white
);
112 padding
: 0px
0px
0px
10px
;
136 pointer
-events
: none
;
143 <?php Header
::setupAssets('topdialog'); ?
>
151 require($GLOBALS['srcdir'] . "/restoreSession.php");
156 // Create array of IDs to pre-select, leaf to top.
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'];
169 // initiate by loading the top-level nodes
174 // This is called repeatedly at initialization until all desired nodes
176 function nextOpen() {
177 if (preopen
.length
) {
178 var thisid
= preopen
.pop();
180 if (thisid
== 0 || preopen
.length
> 0) {
184 $
.getScript('types_ajax.php?id=' +
encodeURIComponent(thisid
) +
'&order=' +
<?php
echo js_url($order); ?
> +
'&labid=' +
<?php
echo js_url($labid); ?
>);
194 // toggle expansion indicator from + to - or vice versa
195 function swapsign(td1
, from
, to
) {
197 var i
= s
.indexOf('>' + from +
' <');
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')) {
209 if (td1
.hasClass('isExpanded')) {
210 $
('#con' + id
).remove();
211 td1
.removeClass('isExpanded');
212 swapsign(td1
, '-', '+');
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
, '+', '|');
236 if (!td1
.hasClass('haskids') && haskids
) {
237 td1
.addClass('haskids');
238 swapsign(td1
, '|', '+');
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
, '+', '-');
247 $
.getScript('types_ajax.php?id=' +
encodeURIComponent(id
) +
'&order=' +
<?php
echo js_url($order); ?
> +
'&labid=' +
<?php
echo js_url($labid); ?
>);
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"); ?
>;
258 type
= (type
=== 1 && !add
) ?
'fgp' : 'for';
260 let url
= 'types_edit.php?addfav=' +
encodeURIComponent(type
) +
'&labid=' +
encodeURIComponent(lab
) +
'&parent=0&typeid=' +
encodeURIComponent(id
);
263 url
= 'types_edit.php?addfav=' +
encodeURIComponent(type
) +
'&labid=' +
encodeURIComponent(lab
) +
'&typeid=0&parent=' +
encodeURIComponent(id
);
264 dlgopen(url
, '_blank', 800, 750, false, addTitle
);
266 dlgopen(url
, '_blank', 800, 750, false, editTitle
);
270 // call this to alternate row colors when anything changes the number of rows
273 $
('#con0 tr').each(function(index
) {
274 // skip any row that contains other rows
275 if ($
(this
).hasClass('outertr')) {
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();
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) {
301 <div
class="container mt-3">
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
>
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
']);
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');?
>
324 <button type
="button" name
="form_search" class="btn btn-primary btn-refresh" onclick
="refreshme()">
325 <?php
echo xlt('Refresh');?
>
330 <div
class="table-responsive">
331 <table
class="table mb-0">
334 <td
class='col1 text-left'> 
; 
;<?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
>
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');?
>
354 <button
class="btn btn-secondary btn-cancel" onclick
="CancelDistribute()">
355 <?php
echo xlt('Cancel');?
>
364 </div
><!--End of Container div
-->
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";
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'); ?
>,
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'); ?
>,
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')?
> +
".",
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')?
> +
".",
392 $
('table td .required-tooltip').tooltip({
393 title
: <?php
echo xlj('For proper tabulated display of tests and results an identifying code is required'); ?
>,
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);