more organization of autoloaded files (#424)
[openemr.git] / interface / patient_file / encounter / search_code.php
blob62efe95f1557f252c73e1059df9abb3f13499b22
1 <?php
3 ////////////////////////////////////////////////////////////////////////////////
4 // THIS MODULE REPLACES cptcm_codes.php, hcpcs_codes.php AND icd9cm_codes.php.
5 ////////////////////////////////////////////////////////////////////////////////
7 include_once("../../globals.php");
8 include_once("../../../custom/code_types.inc.php");
10 //the maximum number of records to pull out with the search:
11 $M = 30;
13 //the number of records to display before starting a second column:
14 $N = 15;
16 $code_type = $_GET['type'];
19 <html>
20 <head>
21 <?php html_header_show();?>
22 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
24 <!-- add jQuery support -->
25 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
27 </head>
28 <body class="body_bottom">
29 <div id="patient_search_code">
31 <table border=0 cellspacing=0 cellpadding=0 height=100%>
32 <tr>
34 <td valign=top>
36 <form name="search_form" id="search_form" method="post" action="search_code.php?type=<?php echo $code_type ?>">
37 <input type="hidden" name="mode" value="search">
39 <span class="title"><?php echo $code_type ?> <?php xl('Codes','e'); ?></span><br>
41 <input type="textbox" id="text" name="text" size=15>
43 <input type='submit' id="submitbtn" name="submitbtn" value='<?php xl('Search','e'); ?>'>
44 <div id="searchspinner" style="display: inline; visibility:hidden;"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div>
46 </form>
48 <?php
49 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] == "") {
50 echo "<div id='resultsummary' style='background-color:lightgreen;'>";
51 echo "Enter search criteria above</div>";
54 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] != "") {
55 // $sql = "SELECT * FROM codes WHERE (code_text LIKE '%" . $_POST["text"] .
56 // "%' OR code LIKE '%" . $_POST["text"] . "%') AND code_type = '" .
57 // $code_types[$code_type]['id'] . "' ORDER BY code LIMIT " . ($M + 1);
59 // The above is obsolete now, fees come from the prices table:
60 $sql = "SELECT codes.*, prices.pr_price FROM codes " .
61 "LEFT OUTER JOIN patient_data ON patient_data.pid = '$pid' " .
62 "LEFT OUTER JOIN prices ON prices.pr_id = codes.id AND " .
63 "prices.pr_selector = '' AND " .
64 "prices.pr_level = patient_data.pricelevel " .
65 "WHERE (code_text LIKE '%" . $_POST["text"] . "%' OR " .
66 "code LIKE '%" . $_POST["text"] . "%') AND " .
67 "code_type = '" . $code_types[$code_type]['id'] . "' " .
68 "ORDER BY code ".
69 " LIMIT " . ($M + 1).
70 "";
72 if ($res = sqlStatement($sql) ) {
73 for($iter=0; $row=sqlFetchArray($res); $iter++)
75 $result[$iter] = $row;
77 echo "<div id='resultsummary' style='background-color:lightgreen;'>";
78 if (count($result) > $M) {
79 echo "Showing the first ".$M." results";
81 else if (count($result) == 0) {
82 echo "No results found";
84 else {
85 echo "Showing all ".count($result)." results";
87 echo "</div>";
89 <div id="results">
90 <table><tr class='text'><td valign='top'>
91 <?php
92 $count = 0;
93 $total = 0;
95 if ($result) {
96 foreach ($result as $iter) {
97 if ($count == $N) {
98 echo "</td><td valign='top'>\n";
99 $count = 0;
102 echo "<div class='oneresult' style='padding: 3px 0px 3px 0px;'>";
103 echo "<a target='".xl('Diagnosis')."' href='diagnosis.php?mode=add" .
104 "&type=" . urlencode($code_type) .
105 "&code=" . urlencode($iter{"code"}) .
106 "&modifier=" . urlencode($iter{"modifier"}) .
107 "&units=" . urlencode($iter{"units"}) .
108 // "&fee=" . urlencode($iter{"fee"}) .
109 "&fee=" . urlencode($iter['pr_price']) .
110 "&text=" . urlencode($iter{"code_text"}) .
111 "' onclick='top.restoreSession()'>";
112 echo ucwords("<b>" . strtoupper($iter{"code"}) . "&nbsp;" . $iter['modifier'] .
113 "</b>" . " " . strtolower($iter{"code_text"}));
114 echo "</a><br>\n";
115 echo "</div>";
117 $count++;
118 $total++;
120 if ($total == $M) {
121 echo "</span><span class=alert>".xl('Some codes were not displayed.')."</span>\n";
122 break;
127 </td></tr></table>
128 </div>
129 <?php
134 </td>
135 </tr>
136 </table>
138 </div> <!-- end large outer patient_search_code DIV -->
139 </body>
141 <script language="javascript">
143 // jQuery stuff to make the page a little easier to use
145 $(document).ready(function(){
146 $("#text").focus();
147 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
148 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
149 //$(".oneresult").click(function() { SelectPatient(this); });
150 $("#search_form").submit(function() { SubmitForm(this); });
153 // show the 'searching...' status and submit the form
154 var SubmitForm = function(eObj) {
155 $("#submitbtn").attr("disabled", "true");
156 $("#submitbtn").css("disabled", "true");
157 $("#searchspinner").css("visibility", "visible");
158 return top.restoreSession();
161 </script>
163 </html>