The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / patient_file / encounter / search_code.php
blob2e4a1ac8c95703bd050b553cbafe06f9f800b630
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");
9 include_once("$srcdir/sql.inc");
11 //the maximum number of records to pull out with the search:
12 $M = 30;
14 //the number of records to display before starting a second column:
15 $N = 15;
17 $code_type = $_GET['type'];
20 <html>
21 <head>
22 <?php html_header_show();?>
23 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
25 <!-- add jQuery support -->
26 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script>
28 </head>
29 <body class="body_bottom">
30 <div id="patient_search_code">
32 <table border=0 cellspacing=0 cellpadding=0 height=100%>
33 <tr>
35 <td valign=top>
37 <form name="search_form" id="search_form" method="post" action="search_code.php?type=<?php echo $code_type ?>">
38 <input type="hidden" name="mode" value="search">
40 <span class="title"><?php echo $code_type ?> <?php xl('Codes','e'); ?></span><br>
42 <input type="textbox" id="text" name="text" size=15>
44 <input type='submit' id="submitbtn" name="submitbtn" value='<?php xl('Search','e'); ?>'>
45 <div id="searchspinner" style="display: inline; visibility:hidden;"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div>
47 </form>
49 <?php
50 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] == "") {
51 echo "<div id='resultsummary' style='background-color:lightgreen;'>";
52 echo "Enter search criteria above</div>";
55 if (isset($_POST["mode"]) && $_POST["mode"] == "search" && $_POST["text"] != "") {
56 // $sql = "SELECT * FROM codes WHERE (code_text LIKE '%" . $_POST["text"] .
57 // "%' OR code LIKE '%" . $_POST["text"] . "%') AND code_type = '" .
58 // $code_types[$code_type]['id'] . "' ORDER BY code LIMIT " . ($M + 1);
60 // The above is obsolete now, fees come from the prices table:
61 $sql = "SELECT codes.*, prices.pr_price FROM codes " .
62 "LEFT OUTER JOIN patient_data ON patient_data.pid = '$pid' " .
63 "LEFT OUTER JOIN prices ON prices.pr_id = codes.id AND " .
64 "prices.pr_selector = '' AND " .
65 "prices.pr_level = patient_data.pricelevel " .
66 "WHERE (code_text LIKE '%" . $_POST["text"] . "%' OR " .
67 "code LIKE '%" . $_POST["text"] . "%') AND " .
68 "code_type = '" . $code_types[$code_type]['id'] . "' " .
69 "ORDER BY code ".
70 " LIMIT " . ($M + 1).
71 "";
73 if ($res = sqlStatement($sql) ) {
74 for($iter=0; $row=sqlFetchArray($res); $iter++)
76 $result[$iter] = $row;
78 echo "<div id='resultsummary' style='background-color:lightgreen;'>";
79 if (count($result) > $M) {
80 echo "Showing the first ".$M." results";
82 else if (count($result) == 0) {
83 echo "No results found";
85 else {
86 echo "Showing all ".count($result)." results";
88 echo "</div>";
90 <div id="results">
91 <table><tr class='text'><td valign='top'>
92 <?php
93 $count = 0;
94 $total = 0;
96 if ($result) {
97 foreach ($result as $iter) {
98 if ($count == $N) {
99 echo "</td><td valign='top'>\n";
100 $count = 0;
103 echo "<div class='oneresult' style='padding: 3px 0px 3px 0px;'>";
104 echo "<a target='".xl('Diagnosis')."' href='diagnosis.php?mode=add" .
105 "&type=" . urlencode($code_type) .
106 "&code=" . urlencode($iter{"code"}) .
107 "&modifier=" . urlencode($iter{"modifier"}) .
108 "&units=" . urlencode($iter{"units"}) .
109 // "&fee=" . urlencode($iter{"fee"}) .
110 "&fee=" . urlencode($iter['pr_price']) .
111 "&text=" . urlencode($iter{"code_text"}) .
112 "' onclick='top.restoreSession()'>";
113 echo ucwords("<b>" . strtoupper($iter{"code"}) . "&nbsp;" . $iter['modifier'] .
114 "</b>" . " " . strtolower($iter{"code_text"}));
115 echo "</a><br>\n";
116 echo "</div>";
118 $count++;
119 $total++;
121 if ($total == $M) {
122 echo "</span><span class=alert>".xl('Some codes were not displayed.')."</span>\n";
123 break;
128 </td></tr></table>
129 </div>
130 <?php
135 </td>
136 </tr>
137 </table>
139 </div> <!-- end large outer patient_search_code DIV -->
140 </body>
142 <script language="javascript">
144 // jQuery stuff to make the page a little easier to use
146 $(document).ready(function(){
147 $("#text").focus();
148 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
149 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
150 //$(".oneresult").click(function() { SelectPatient(this); });
151 $("#search_form").submit(function() { SubmitForm(this); });
154 // show the 'searching...' status and submit the form
155 var SubmitForm = function(eObj) {
156 $("#submitbtn").attr("disabled", "true");
157 $("#submitbtn").css("disabled", "true");
158 $("#searchspinner").css("visibility", "visible");
159 return top.restoreSession();
162 </script>
164 </html>