4 * Script to pick a procedure order type from the compendium.
7 * @link https://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Jerry Padgett <sjpadgett@gmail.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2013 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 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\Core\Header
;
20 $order = (int) ($_GET['order'] ??
null);
21 $labid = (int) ($_GET['labid'] ??
null);
23 //////////////////////////////////////////////////////////////////////
24 // The form was submitted with the selected code type.
25 if (isset($_GET['typeid'])) {
27 $typeid = (int) $_GET['typeid'];
30 $ptrow = sqlQuery("SELECT * FROM procedure_type WHERE procedure_type_id = ?", array($typeid));
31 $name = $ptrow['name'];
32 $proctype = trim($ptrow['procedure_type']);
33 $codes = ($proctype === 'pro') ?
'' : $ptrow['related_code'];
34 $transport = trim($ptrow['transport']);
35 $testid = trim($ptrow['procedure_code']);
36 $proctype_name = trim($ptrow['procedure_type_name']);
38 if ($ptrow['procedure_type'] == 'fgp') {
39 $res = sqlStatement("SELECT * FROM procedure_type WHERE parent = ? && procedure_type = 'for' ORDER BY seq, name, procedure_type_id", array($typeid));
40 while ($row = sqlFetchArray($res)) {
46 <script src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
49 alert(<?php
echo xlj('The destination form was closed; I cannot act on your selection.'); ?
>);
53 if (isset($_GET['addfav'])) {
54 $order = json_encode($ptrow);
55 echo "opener.set_new_fav($order);\nwindow.close();";
60 if (!isset($grporders[$i]['procedure_type_id'])) {
61 echo "opener.set_proc_type(" . js_escape($typeid) . ", " . js_escape($name) . ", " . js_escape($codes) . ", " . js_escape($transport) . ", " . js_escape($proctype_name) . ", " . js_escape($testid) . ", '0');\n";
63 $t = count($grporders) - $i;
64 $typeid = $grporders[$i]['procedure_type_id'] +
0;
65 $name = ($grporders[$i]['name']);
66 $codes = ($grporders[$i]['related_code']);
67 $transport = trim($ptrow['transport']);
68 $testid = trim($ptrow['procedure_code']);
69 $proctype_name = trim($ptrow['procedure_type_name']);
70 echo "opener.set_proc_type(" . js_escape($typeid) . ", " . js_escape($name) . ", " . js_escape($codes) . ", " . js_escape($transport) . ", " . js_escape($proctype_name) . ", " . js_escape($testid) . ", " . js_escape($t) . ");\n";
72 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
73 // GET parms needed for this are: formid, formseq.
74 if (isset($_GET['formid'])) {
76 require_once("qoe.inc.php");
77 $qoe_init_javascript = '';
78 echo ' opener.set_proc_html("';
79 echo generate_qoe_html($typeid, (int)$_GET['formid'], 0, (int)$_GET['formseq']);
80 echo '", "' . $qoe_init_javascript . '");' . "\n";
82 echo ' opener.set_proc_html("", "");' . "\n";
86 } while ($grporders[$i]['procedure_type_id']);
96 //////////////////////////////////////////////////////////////////////
102 <?php Header
::setupHeader(['opener']); ?
>
103 <title
><?php
echo xlt('Procedure Picker'); ?
></title
>
106 // Reload the script with the select procedure type ID.
107 function selcode(typeid
) {
108 location
.href
= 'find_order_popup.php?order=' +
<?php
echo js_url($order); ?
> +
'&labid=' +
<?php
echo js_url($labid);
109 if (isset($_GET['addfav'])) {
110 echo " + '&addfav=' + " . js_url($_GET['addfav']);
112 if (isset($_GET['formid'])) {
113 echo " + '&formid=' + " . js_url($_GET['formid']);
115 if (isset($_GET['formseq'])) {
116 echo " + '&formseq=' + " . js_url($_GET['formseq']);
118 ?
> +
'&typeid=' +
encodeURIComponent(typeid
);
124 <div
class="container">
126 <form
class="form-inline" method
='post' name
='theform' action
='find_order_popup.php<?php echo "?order=" . attr_url($order) . "&labid=" . attr_url($labid);
127 if (isset($_GET['formid
'])) {
128 echo '&formid
=' . attr_url($_GET['formid
']);
131 if (isset($_GET['formseq
'])) {
132 echo '&formseq
=' . attr_url($_GET['formseq
']);
134 if (isset($_GET['addfav
'])) {
135 echo '&addfav
=' . attr_url($_GET['addfav
']);
138 <div
class="col-sm-12">
139 <div
class="input-group">
140 <input type
="hidden" name
='isfav' value
='<?php echo attr($_REQUEST['ordLookup
'] ?? ''); ?>' />
141 <input
class="form-control" id
='search_term' name
='search_term' value
='<?php echo attr($_REQUEST['search_term
'] ?? ''); ?>' title
='<?php echo xla('Any part of the desired code
or its description
'); ?>' placeholder
="<?php echo xla('Search for') ?>…"/>
142 <span
class="input-group-append">
143 <button type
="submit" class="btn btn-primary btn-search" name
='bn_search' value
="true"><?php
echo xlt('Search'); ?
></button
>
144 <?php
if (!isset($_REQUEST['addfav'])) { ?
>
145 <button type
="submit" class="btn btn-primary btn-search" name
='bn_grpsearch' value
="true"><?php
echo xlt('Favorites'); ?
></button
>
147 <button type
="button" class="btn btn-danger btn-delete" onclick
="selcode(0)"><?php
echo xlt('Erase'); ?
></button
>
151 <?php
if (!empty($_REQUEST['bn_search']) ||
!empty($_REQUEST['bn_grpsearch'])) { ?
>
152 <div
class="table-responsive mt-3">
153 <table
class="table table-striped table-sm">
155 <th
><?php
echo xlt('Type'); ?
></th
>
156 <th
><?php
echo xlt('Code'); ?
></th
>
157 <th
><?php
echo xlt('Description'); ?
></th
>
160 $ord = isset($_REQUEST['bn_search']) ?
'ord' : 'fgp';
161 if ($ord === 'ord') {
162 $sub = "OR procedure_type LIKE 'pro'";
164 $search_term = '%' . $_REQUEST['search_term'] . '%';
165 $query = "SELECT procedure_type_id, procedure_code, procedure_type, name " .
166 "FROM procedure_type WHERE " .
168 "(procedure_type LIKE ? $sub) AND " .
169 "activity = 1 AND " .
170 "(procedure_code LIKE ? OR name LIKE ?) " .
171 "ORDER BY seq, procedure_code";
172 $res = sqlStatement($query, array($labid, $ord, $search_term, $search_term));
174 while ($row = sqlFetchArray($res)) {
175 $itertypeid = $row['procedure_type_id'];
176 $itertype = strtoupper($row['procedure_type']);
177 $itercode = $row['procedure_code'];
178 $itertext = trim($row['name']);
179 $anchor = "<a href='' onclick='return selcode(" . attr_js($itertypeid) . ")'>";
181 echo " <td>$anchor" . text($itertype) . "</a></td>\n";
182 echo " <td>$anchor" . text($itercode) . "</a></td>\n";
183 echo " <td>$anchor" . text($itertext) . "</a></td>\n";