minor cosmetic change
[openemr.git] / interface / main / finder / patient_select.php
blobe6ee76904ce312ac03de90ba9ae2f3d49b67e811
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/patient.inc");
5 $patient = $_REQUEST['patient'];
6 $findBy = $_REQUEST['findBy'];
7 $MAXSHOW = 500; // maximum number of results to display at once
9 // this is a quick fix so it doesn't go to thousands records.
10 // the searching functions on patient.inc need improvement.
11 if ($patient=='') $patient=xl('Please enter some information','e');
14 <html>
15 <head>
16 <?php html_header_show();?>
18 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
19 <style>
20 form {
21 padding: 0px;
22 margin: 0px;
24 #searchCriteria {
25 text-align: center;
26 width: 100%;
27 font-size: 0.8em;
28 background-color: #ddddff;
29 font-weight: bold;
30 padding: 3px;
32 #searchResultsHeader {
33 width: 100%;
34 background-color: lightgrey;
36 #searchResultsHeader table {
37 width: 96%; /* not 100% because the 'searchResults' table has a scrollbar */
38 border-collapse: collapse;
40 #searchResultsHeader th {
41 font-size: 0.7em;
43 #searchResults {
44 width: 100%;
45 height: 80%;
46 overflow: auto;
49 .srName { width: 12%; }
50 .srPhone { width: 11%; }
51 .srSS { width: 11%; }
52 .srDOB { width: 8%; }
53 .srID { width: 7%; }
54 .srPID { width: 7%; }
55 .srNumEnc { width: 11%; }
56 .srNumDays { width: 11%; }
57 .srDateLast { width: 11%; }
58 .srDateNext { width: 11%; }
60 #searchResults table {
61 width: 100%;
62 border-collapse: collapse;
63 background-color: white;
65 #searchResults tr {
66 cursor: hand;
67 cursor: pointer;
69 #searchResults td {
70 font-size: 0.7em;
71 border-bottom: 1px solid #eee;
73 .oneResult { }
74 .billing { color: red; font-weight: bold; }
75 #tooManyResults {
76 font-size: 0.8em;
77 font-weight: bold;
78 padding: 1px 1px 10px 1px;
79 font-style: italic;
80 color: black;
81 background-color: #fc0;
83 #howManyResults {
84 font-size: 0.8em;
85 font-weight: bold;
86 padding: 1px 1px 10px 1px;
87 font-style: italic;
88 color: black;
89 background-color: #9f6;
91 .highlight {
92 background-color: #336699;
93 color: white;
95 </style>
97 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script>
99 </head>
100 <body class="body_top">
101 <a href="./patient_select_help.php" target=_new>[Help]&nbsp</a>
103 <?php
104 //the maximum number of patient records to display:
105 $sqllimit = $MAXSHOW;
107 if ($findBy == "Last")
108 $result = getPatientLnames("$patient","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", "lname ASC, fname ASC", $sqllimit);
109 else if ($findBy == "ID")
110 $result = getPatientId("$patient","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", "lname ASC, fname ASC", $sqllimit);
111 else if ($findBy == "DOB")
112 $result = getPatientDOB("$patient","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", "lname ASC, fname ASC", $sqllimit);
113 else if ($findBy == "SSN")
114 $result = getPatientSSN("$patient","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", "lname ASC, fname ASC", $sqllimit);
115 elseif ($findBy == "Phone") //(CHEMED) Search by phone number
116 $result = getPatientPhone("$patient","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", "lname ASC, fname ASC", $sqllimit);
119 <?php if ($GLOBALS['PATIENT_INC_COUNT'] > $MAXSHOW): ?>
120 <span id="tooManyResults">
121 <?php else: ?>
122 <span id="howManyResults">
123 <?php endif; ?>
124 <?php echo "Showing " . count($result) . " of " . $GLOBALS['PATIENT_INC_COUNT'] . " records found."; ?></span>
126 <br>
128 <div id="searchResultsHeader">
129 <table>
130 <tr>
131 <th class="srName"><?php xl('Name','e');?></th>
132 <th class="srPhone"><?php xl('Phone','e');?></th>
133 <th class="srSS"><?php xl('SS','e');?></th>
134 <th class="srDOB"><?php xl('DOB','e');?></th>
135 <th class="srID"><?php xl('ID','e');?></th>
136 <th class="srPID"><?php xl('PID','e');?></th>
137 <th class="srNumEnc"><?php xl('[Number Of Encounters]','e');?></th>
138 <th class="srNumDays"><?php xl('[Days Since Last Encounter]','e');?></th>
139 <th class="srDateLast"><?php xl('[Date of Last Encounter]','e');?></th>
140 <th class="srDateNext">
141 <?php
142 $add_days = 90;
143 if (preg_match('/^(\d+)\s*(.*)/',$patient,$matches) > 0) {
144 $add_days = $matches[1];
145 $patient = $matches[2];
148 [<?php echo $add_days?> Days From Last Encounter]
149 </th>
150 </tr>
151 </table>
152 </div>
154 <div id="searchResults">
156 <table>
157 <tr>
158 <?php
159 if ($result) {
160 foreach ($result as $iter) {
161 echo "<tr class='oneresult' id='".$iter['pid']."'>";
162 echo "<td class='srName'>" . $iter['lname'] . ", " . $iter['fname'] . "</td>\n";
163 //other phone number display setup for tooltip
164 $phone_biz = '';
165 if ($iter{"phone_biz"} != "") {
166 $phone_biz = " [business phone ".$iter{"phone_biz"}."] ";
168 $phone_contact = '';
169 if ($iter{"phone_contact"} != "") {
170 $phone_contact = " [contact phone ".$iter{"phone_contact"}."] ";
172 $phone_cell = '';
173 if ($iter{"phone_cell"} != "") {
174 $phone_cell = " [cell phone ".$iter{"phone_cell"}."] ";
176 $all_other_phones = $phone_biz.$phone_contact.$phone_cell;
177 if ($all_other_phones == '') {$all_other_phones = 'No other phone numbers listed';}
178 //end of phone number display setup, now display the phone number(s)
179 echo "<td class='srPhone' title='$all_other_phones'>" . $iter['phone_home']. "</td>\n";
180 echo "<td class='srSS'>" . $iter['ss'] . "</td>";
181 if ($iter{"DOB"} != "0000-00-00 00:00:00") {
182 echo "<td class='srDOB'>" . $iter['DOB_TS'] . "</td>";
183 } else {
184 echo "<td class='srDOB'>&nbsp;</td>";
186 echo "<td class='srID'>" . $iter['pubpid'] . "</td>";
187 echo "<td class='srPID'>" . $iter['pid'] . "</td>";
188 //setup for display of encounter date info
189 $encounter_count = 0;
190 $day_diff = '';
191 $last_date_seen = '';
192 $next_appt_date= '';
193 $pid = '';
195 // calculate date differences based on date of last encounter with billing entries
196 $query = "select DATE_FORMAT(max(form_encounter.date),'%m/%d/%y') as mydate," .
197 " (to_days(current_date())-to_days(max(form_encounter.date))) as day_diff," .
198 " DATE_FORMAT(max(form_encounter.date) + interval " . $add_days .
199 " day,'%m/%d/%y') as next_appt, dayname(max(form_encounter.date) + interval " .
200 $add_days." day) as next_appt_day from form_encounter " .
201 "join billing on billing.encounter = form_encounter.encounter and " .
202 "billing.pid = form_encounter.pid and billing.activity = 1 and " .
203 "billing.code_type not like 'COPAY' where ".
204 "form_encounter.pid = " . $iter{"pid"};
205 $statement= sqlStatement($query);
206 if ($results = mysql_fetch_array($statement, MYSQL_ASSOC)) {
207 $last_date_seen = $results['mydate'];
208 $day_diff = $results['day_diff'];
209 $next_appt_date= $results['next_appt_day'].', '.$results['next_appt'];
212 //calculate count of encounters by distinct billing dates with cpt4
213 //entries
214 $query = "select count(distinct date) as encounter_count " .
215 "from billing where code_type not like 'COPAY' and activity = 1 " .
216 "and pid = ".$iter{"pid"};
217 $statement= sqlStatement($query);
218 if ($results = mysql_fetch_array($statement, MYSQL_ASSOC)) {
219 $encounter_count = $results['encounter_count'];
221 echo "<td class='srNumEnc'>".$encounter_count."</td>";
222 echo "<td class='srNumDay'>".$day_diff."</td>";
223 echo "<td class='srDateLast'>".$last_date_seen."</td>";
224 echo "<td class='srDateNext'>".$next_appt_date."</td>";
225 echo "\n";
229 </table>
230 </div> <!-- end searchResults DIV -->
232 <script language="javascript">
234 // jQuery stuff to make the page a little easier to use
236 $(document).ready(function(){
237 $("#searchparm").focus();
238 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
239 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
240 $(".oneresult").click(function() { SelectPatient(this); });
241 //$(".event").dblclick(function() { EditEvent(this); });
244 var SelectPatient = function (eObj) {
245 <?php
246 // For the old layout we load a frameset that also sets up the new pid.
247 // The new layout loads just the demographics frame here, which in turn
248 // will set the pid and load all the other frames.
249 if ($GLOBALS['concurrent_layout'])
252 // larry :: dbc insert
253 if( $GLOBALS['dutchpc'] )
254 $newPage = "../../patient_file/summary/demographics_dutch.php?set_pid=";
255 else
256 $newPage = "../../patient_file/summary/demographics.php?set_pid=";
257 // larry :: end of dbc insert
259 $target = "document";
260 } else {
261 $newPage = "../../patient_file/patient_file.php?set_pid=";
262 $target = "top";
265 objID = eObj.id;
266 var parts = objID.split("~");
267 <?php echo $target; ?>.location.href = '<?php echo $newPage; ?>' + parts[0];
268 return true;
271 </script>
273 </body>
274 </html>