acknowledgments update
[openemr.git] / interface / orders / find_order_popup.php
blobef34212af36f576581e3b71952aae95ed17cdab8
1 <?php
2 /**
3 * Script to pick a procedure order type from the compendium.
5 * Copyright (C) 2013 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
22 $fake_register_globals = false;
23 $sanitize_all_escapes = true;
25 require_once("../globals.php");
27 $order = 0 + $_GET['order'];
28 $labid = 0 + $_GET['labid'];
30 //////////////////////////////////////////////////////////////////////
31 // The form was submitted with the selected code type.
32 if (isset($_GET['typeid'])) {
33 $typeid = $_GET['typeid'] + 0;
34 $name = '';
35 if ($typeid) {
36 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
37 "procedure_type_id = '$typeid'");
38 $name = addslashes($ptrow['name']);
41 <script language="JavaScript">
42 if (opener.closed || !opener.set_proc_type) {
43 alert('<?php xl('The destination form was closed; I cannot act on your selection.','e'); ?>');
45 else {
46 opener.set_proc_type(<?php echo "$typeid, '$name'"; ?>);
47 <?php
48 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
49 // GET parms needed for this are: formid, formseq.
50 if (isset($_GET['formid'])) {
51 if ($typeid) {
52 require_once("qoe.inc.php");
53 $qoe_init_javascript = '';
54 echo ' opener.set_proc_html("';
55 echo generate_qoe_html($typeid, intval($_GET['formid']), 0, intval($_GET['formseq']));
56 echo '", "' . $qoe_init_javascript . '");' . "\n";
58 else {
59 echo ' opener.set_proc_html("", "");' . "\n";
64 window.close();
65 </script>
66 <?php
67 exit();
69 // End Submission.
70 //////////////////////////////////////////////////////////////////////
73 <html>
74 <head>
75 <?php html_header_show(); ?>
76 <title><?php echo xlt('Procedure Picker'); ?></title>
77 <link rel="stylesheet" href='<?php echo attr($css_header) ?>' type='text/css'>
79 <style>
80 td { font-size:10pt; }
81 </style>
83 <script language="JavaScript">
85 // Reload the script with the select procedure type ID.
86 function selcode(typeid) {
87 location.href = 'find_order_popup.php<?php
88 echo "?order=$order&labid=$labid";
89 if (isset($_GET['formid' ])) echo '&formid=' . $_GET['formid'];
90 if (isset($_GET['formseq'])) echo '&formseq=' . $_GET['formseq'];
91 ?>&typeid=' + typeid;
92 return false;
95 </script>
97 </head>
99 <body class="body_top">
101 <form method='post' name='theform' action='find_order_popup.php<?php
102 echo "?order=$order&labid=$labid";
103 if (isset($_GET['formid' ])) echo '&formid=' . $_GET['formid'];
104 if (isset($_GET['formseq'])) echo '&formseq=' . $_GET['formseq'];
105 ?>'>
107 <center>
109 <table border='0' cellpadding='5' cellspacing='0'>
111 <tr>
112 <td height="1">
113 </td>
114 </tr>
116 <tr bgcolor='#ddddff'>
117 <td>
120 <?php echo xlt('Search for:'); ?>
121 <input type='text' name='search_term' size='12' value='<?php echo attr($_REQUEST['search_term']); ?>'
122 title='<?php echo xla('Any part of the desired code or its description'); ?>' />
123 &nbsp;
124 <input type='submit' name='bn_search' value='<?php echo xla('Search'); ?>' />
125 &nbsp;&nbsp;&nbsp;
126 <input type='button' value='<?php echo xla('Erase'); ?>' onclick="selcode(0)" />
127 </b>
128 </td>
129 </tr>
131 <tr>
132 <td height="1">
133 </td>
134 </tr>
136 </table>
138 <?php if ($_REQUEST['bn_search']) { ?>
140 <table border='0'>
141 <tr>
142 <td><b><?php echo xlt('Code'); ?></b></td>
143 <td><b><?php echo xlt('Description'); ?></b></td>
144 </tr>
145 <?php
146 $search_term = '%' . $_REQUEST['search_term'] . '%';
148 $query = "SELECT procedure_type_id, procedure_code, name " .
149 "FROM procedure_type WHERE " .
150 "lab_id = ? AND " .
151 "procedure_type LIKE 'ord' AND " .
152 "activity = 1 AND " .
153 "(procedure_code LIKE ? OR name LIKE ?) " .
154 "ORDER BY seq, procedure_code";
156 // echo "<!-- $query $labid $search_term -->\n"; // debugging
158 $res = sqlStatement($query, array($labid, $search_term, $search_term));
160 while ($row = sqlFetchArray($res)) {
161 $itertypeid = $row['procedure_type_id'];
162 $itercode = $row['procedure_code'];
163 $itertext = trim($row['name']);
164 $anchor = "<a href='' onclick='return selcode(" .
165 "\"" . $itertypeid . "\")'>";
166 echo " <tr>";
167 echo " <td>$anchor" . text($itercode) . "</a></td>\n";
168 echo " <td>$anchor" . text($itertext) . "</a></td>\n";
169 echo " </tr>";
172 </table>
174 <?php } ?>
176 </center>
177 </form>
178 </body>
179 </html>