PHP7 Project. Commit 20. Fixes in calendar module.
[openemr.git] / interface / main / calendar / find_patient_popup.php
blob31fb9345e32ffafc317b63a1ab47942cf32b2461
1 <?php
2 /* Copyright (C) 2005-2007 Rod Roark <rod@sunsetsystems.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 */
12 * This popup is called when adding/editing a calendar event
16 //SANITIZE ALL ESCAPES
17 $sanitize_all_escapes=true;
20 //STOP FAKE REGISTER GLOBALS
21 $fake_register_globals=false;
24 include_once('../../globals.php');
25 include_once("$srcdir/patient.inc");
26 include_once("$srcdir/formdata.inc.php");
28 $info_msg = "";
30 // If we are searching, search.
32 if ($_REQUEST['searchby'] && $_REQUEST['searchparm']) {
33 $searchby = $_REQUEST['searchby'];
34 $searchparm = trim($_REQUEST['searchparm']);
36 if ($searchby == "Last") {
37 $result = getPatientLnames("$searchparm","*");
38 } elseif ($searchby == "Phone") { //(CHEMED) Search by phone number
39 $result = getPatientPhone("$searchparm","*");
40 } elseif ($searchby == "ID") {
41 $result = getPatientId("$searchparm","*");
42 } elseif ($searchby == "DOB") {
43 $result = getPatientDOB("$searchparm","*");
44 } elseif ($searchby == "SSN") {
45 $result = getPatientSSN("$searchparm","*");
50 <html>
51 <head>
52 <?php html_header_show();?>
53 <title><?php echo htmlspecialchars( xl('Patient Finder'), ENT_NOQUOTES); ?></title>
54 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
56 <style>
57 form {
58 padding: 0px;
59 margin: 0px;
61 #searchCriteria {
62 text-align: center;
63 width: 100%;
64 font-size: 0.8em;
65 background-color: #ddddff;
66 font-weight: bold;
67 padding: 3px;
69 #searchResultsHeader {
70 width: 100%;
71 background-color: lightgrey;
73 #searchResultsHeader table {
74 width: 96%; /* not 100% because the 'searchResults' table has a scrollbar */
75 border-collapse: collapse;
77 #searchResultsHeader th {
78 font-size: 0.7em;
80 #searchResults {
81 width: 100%;
82 height: 80%;
83 overflow: auto;
86 /* search results column widths */
87 .srName { width: 30%; }
88 .srPhone { width: 21%; }
89 .srSS { width: 17%; }
90 .srDOB { width: 17%; }
91 .srID { width: 15%; }
93 #searchResults table {
94 width: 100%;
95 border-collapse: collapse;
96 background-color: white;
98 #searchResults tr {
99 cursor: hand;
100 cursor: pointer;
102 #searchResults td {
103 font-size: 0.7em;
104 border-bottom: 1px solid #eee;
106 .oneResult { }
107 .billing { color: red; font-weight: bold; }
109 /* for search results or 'searching' notification */
110 #searchstatus {
111 font-size: 0.8em;
112 font-weight: bold;
113 padding: 1px 1px 10px 1px;
114 font-style: italic;
115 color: black;
116 text-align: center;
118 .noResults { background-color: #ccc; }
119 .tooManyResults { background-color: #fc0; }
120 .howManyResults { background-color: #9f6; }
121 #searchspinner {
122 display: inline;
123 visibility: hidden;
126 /* highlight for the mouse-over */
127 .highlight {
128 background-color: #336699;
129 color: white;
131 </style>
133 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script>
134 <!-- ViSolve: Verify the noresult parameter -->
135 <?php
136 if(isset($_GET["res"])){
137 echo '
138 <script language="Javascript">
139 // Pass the variable to parent hidden type and submit
140 opener.document.theform.resname.value = "noresult";
141 opener.document.theform.submit();
142 // Close the window
143 window.self.close();
144 </script>';
147 <!-- ViSolve: Verify the noresult parameter -->
149 <script language="JavaScript">
151 function selpid(pid, lname, fname, dob) {
152 if (opener.closed || ! opener.setpatient)
153 alert("<?php echo htmlspecialchars( xl('The destination form was closed; I cannot act on your selection.'), ENT_QUOTES); ?>");
154 else
155 opener.setpatient(pid, lname, fname, dob);
156 window.close();
157 return false;
160 </script>
162 </head>
164 <body class="body_top">
166 <div id="searchCriteria">
167 <form method='post' name='theform' id="theform" action='find_patient_popup.php?<?php if(isset($_GET['pflag'])) echo "pflag=0"; ?>'>
168 <?php echo htmlspecialchars( xl('Search by:'), ENT_NOQUOTES); ?>
169 <select name='searchby'>
170 <option value="Last"><?php echo htmlspecialchars( xl('Name'), ENT_NOQUOTES); ?></option>
171 <!-- (CHEMED) Search by phone number -->
172 <option value="Phone"<?php if ($searchby == 'Phone') echo ' selected' ?>><?php echo htmlspecialchars( xl('Phone'), ENT_NOQUOTES); ?></option>
173 <option value="ID"<?php if ($searchby == 'ID') echo ' selected' ?>><?php echo htmlspecialchars( xl('ID'), ENT_NOQUOTES); ?></option>
174 <option value="SSN"<?php if ($searchby == 'SSN') echo ' selected' ?>><?php echo htmlspecialchars( xl('SSN'), ENT_NOQUOTES); ?></option>
175 <option value="DOB"<?php if ($searchby == 'DOB') echo ' selected' ?>><?php echo htmlspecialchars( xl('DOB'), ENT_NOQUOTES); ?></option>
176 </select>
177 <?php echo htmlspecialchars( xl('for:'), ENT_NOQUOTES); ?>
178 <input type='text' id='searchparm' name='searchparm' size='12' value='<?php echo htmlspecialchars( $_REQUEST['searchparm'], ENT_QUOTES); ?>'
179 title='<?php echo htmlspecialchars( xl('If name, any part of lastname or lastname,firstname'), ENT_QUOTES); ?>'>
180 &nbsp;
181 <input type='submit' id="submitbtn" value='<?php echo htmlspecialchars( xl('Search'), ENT_QUOTES); ?>'>
182 <!-- &nbsp; <input type='button' value='<?php echo htmlspecialchars( xl('Close'), ENT_QUOTES); ?>' onclick='window.close()' /> -->
183 <div id="searchspinner"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div>
184 </form>
185 </div>
188 <?php if (! isset($_REQUEST['searchparm'])): ?>
189 <div id="searchstatus"><?php echo htmlspecialchars( xl('Enter your search criteria above'), ENT_NOQUOTES); ?></div>
190 <?php elseif (count($result) == 0): ?>
191 <div id="searchstatus" class="noResults"><?php echo htmlspecialchars( xl('No records found. Please expand your search criteria.'), ENT_NOQUOTES); ?>
192 <br>
193 <!--VicarePlus :: If pflag is set the new patient create link will not be displayed --!>
194 <a class="noresult" href='find_patient_popup.php?res=noresult' <?php if(isset($_GET['pflag'])) { ?> style="display:none;" <?php } ?> ><?php echo htmlspecialchars( xl('Click Here to add a new patient.'), ENT_NOQUOTES); ?></a>
195 </div>
196 <?php elseif (count($result)>=100): ?>
197 <div id="searchstatus" class="tooManyResults"><?php echo htmlspecialchars( xl('More than 100 records found. Please narrow your search criteria.'), ENT_NOQUOTES); ?></div>
198 <?php elseif (count($result)<100): ?>
199 <div id="searchstatus" class="howManyResults"><?php echo htmlspecialchars( count($result), ENT_NOQUOTES); ?> <?php echo htmlspecialchars( xl('records found.'), ENT_NOQUOTES); ?></div>
200 <?php endif; ?>
202 <?php if (isset($result)): ?>
204 <div id="searchResultsHeader">
205 <table>
206 <tr>
207 <th class="srName"><?php echo htmlspecialchars( xl('Name'), ENT_NOQUOTES); ?></th>
208 <th class="srPhone"><?php echo htmlspecialchars( xl('Phone'), ENT_NOQUOTES); ?></th> <!-- (CHEMED) Search by phone number -->
209 <th class="srSS"><?php echo htmlspecialchars( xl('SS'), ENT_NOQUOTES); ?></th>
210 <th class="srDOB"><?php echo htmlspecialchars( xl('DOB'), ENT_NOQUOTES); ?></th>
211 <th class="srID"><?php echo htmlspecialchars( xl('ID'), ENT_NOQUOTES); ?></th>
212 </tr>
213 </table>
214 </div>
216 <div id="searchResults">
217 <table>
218 <?php
219 foreach ($result as $iter) {
220 $iterpid = $iter['pid'];
221 $iterlname = $iter['lname'];
222 $iterfname = $iter['fname'];
223 $itermname = $iter['mname'];
224 $iterdob = $iter['DOB'];
226 // If billing note exists, then it gets special coloring and an extra line of output
227 // in the 'name' column.
228 $trClass = "oneresult";
229 if (!empty($iter['billing_note'])) { $trClass .= " billing"; }
231 echo " <tr class='".$trClass."' id='" .
232 htmlspecialchars( $iterpid."~".$iterlname."~".$iterfname."~".$iterdob, ENT_QUOTES) . "'>";
233 echo " <td class='srName'>" . htmlspecialchars( $iterlname.", ".$iterfname." ".$itermname, ENT_NOQUOTES);
234 if (!empty($iter['billing_note'])) { echo "<br>" . htmlspecialchars( $iter['billing_note'], ENT_NOQUOTES); }
235 echo "</td>\n";
236 echo " <td class='srPhone'>" . htmlspecialchars( $iter['phone_home'], ENT_NOQUOTES) . "</td>\n"; //(CHEMED) Search by phone number
237 echo " <td class='srSS'>" . htmlspecialchars( $iter['ss'], ENT_NOQUOTES) . "</td>\n";
238 echo " <td class='srDOB'>" . htmlspecialchars( $iter['DOB'], ENT_NOQUOTES) . "</td>\n";
239 echo " <td class='srID'>" . htmlspecialchars( $iter['pubpid'], ENT_NOQUOTES) . "</td>\n";
240 echo " </tr>";
243 </table>
244 </div>
245 <?php endif; ?>
247 <script language="javascript">
249 // jQuery stuff to make the page a little easier to use
251 $(document).ready(function(){
252 $("#searchparm").focus();
253 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
254 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
255 $(".oneresult").click(function() { SelectPatient(this); });
256 //ViSolve
257 $(".noresult").click(function () { SubmitForm(this);});
259 //$(".event").dblclick(function() { EditEvent(this); });
260 $("#theform").submit(function() { SubmitForm(this); });
264 // show the 'searching...' status and submit the form
265 var SubmitForm = function(eObj) {
266 $("#submitbtn").css("disabled", "true");
267 $("#searchspinner").css("visibility", "visible");
268 return true;
272 // another way to select a patient from the list of results
273 // parts[] ==> 0=PID, 1=LName, 2=FName, 3=DOB
274 var SelectPatient = function (eObj) {
275 objID = eObj.id;
276 var parts = objID.split("~");
277 return selpid(parts[0], parts[1], parts[2], parts[3]);
280 </script>
282 </center>
283 </body>
284 </html>