Fix a nasty bug; avoid 0 value for pc_multiple field.
[openemr.git] / interface / main / calendar / find_patient.php
blobbb2fae7d2936ad33d76c08dea5d038cd0768edc7
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/calendar.inc");
4 include_once("$srcdir/patient.inc");
6 //the maximum number of patient records to display:
7 $M = 2000;
9 if (isset($_POST["mode"]) && ($_POST["mode"] == "editappt")) {
10 //echo "saved appt";
11 $body_code = ' onload="javascript:parent.Calendar.location.href=parent.Calendar.location.href;" ';
12 $year = $_POST["year"];
13 $month = $_POST["month"];
14 $day = $_POST["day"];
15 $hour = $_POST["hour"];
16 $minute = $_POST["minute"];
17 if ($_POST["ampm"] == "pm") {
18 $hour += 12;
20 $timesave = "$year-$month-$day $hour:$minute";
21 //echo $timesave;
22 $providerres = sqlQuery("select name from groups where user='".$_POST["provider"]."' limit 1");
24 saveCalendarUpdate($_POST["calid"],$_POST["pid"],$timesave,$_POST["reason"],$_POST["provider"],$providerres{"name"});
26 elseif (isset($_POST["mode"]) && ($_POST["mode"] == "deleteappt")) {
27 $body_code = ' onload="javascript:parent.Calendar.location.href=parent.Calendar.location.href;" ';
29 deleteCalendarItem($_POST["calid"],$_POST["pid"]);
31 elseif (isset($_POST["mode"]) && ($_POST["mode"] == "saveappt")) {
32 $body_code = ' onload="javascript:parent.Calendar.location.href=parent.Calendar.location.href;" ';
33 $year = $_POST["year"];
34 $month = $_POST["month"];
35 $day = $_POST["day"];
36 $hour = $_POST["hour"];
37 $minute = $_POST["minute"];
38 if ($_POST["ampm"] == "pm") {
39 $hour += 12;
41 $timesave = "$year-$month-$day $hour:$minute";
42 $providerres = sqlQuery("select name from groups where user='".$_POST["provider"]."' limit 1");
43 newCalendarItem($_POST["pid"],$timesave,$_POST["reason"],$_POST["provider"],$providerres{"name"});
44 } else {
45 $body_code = "";
46 $category = $_GET["event_category"];
47 if(empty($category))
49 $category = $_POST['category'];
53 if (isset($_GET["mode"]) && ($_GET["mode"] == "reset")) {
54 $_SESSION["lastname"] = "";
55 $_SESSION["firstname"] = "";
56 //$_SESSION["category"] = $_POST["category"];
57 $category = $_POST["category"];
60 if (isset($_POST["mode"]) && ($_POST["mode"] == "findpatient")) {
61 $_SESSION["findby"] = $_POST["findBy"];
62 $_SESSION["lastname"] = $_POST["lastname"];
63 $_SESSION["firstname"] = $_POST["firstname"];
64 $category = $_POST["category"];
67 $findby = $_SESSION["findby"];
68 $lastname = $_SESSION["lastname"];
69 $firstname = $_SESSION["firstname"];
72 <html>
73 <head>
74 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
75 <script type="text/javascript" src="../../../library/dialog.js"></script>
77 <script language='JavaScript'>
79 // This is called from the event editor popup to refresh the display.
80 function refreshme() {
81 var cf = parent.frames[0].frames[0]; // calendar frame
82 if (cf && cf.refreshme) cf.refreshme();
85 // Cloned from interface/main/calendar/.../views/day/default.html:
86 function newEvt(startampm, starttimeh, starttimem, eventdate, providerid, patientid) {
87 dlgopen('add_edit_event.php?startampm=' + startampm +
88 '&starttimeh=' + starttimeh + '&starttimem=' + starttimem +
89 '&date=' + eventdate + '&userid=' + providerid +
90 '&patientid=' + patientid,
91 '_blank', 550, 270);
94 </script>
96 </head>
97 <body <?php echo $bottom_bg_line;?> topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0 <?php echo $body_code;?>>
99 <table border=0 cellpadding=3 cellspacing=0>
100 <tr>
101 <td width='150' valign='top'>
102 <span class='bold'><?php xl('Patient Appointment','e'); ?></span>
103 <?php if ($userauthorized == 1) { ?>
104 <a class="more" style="font-size:8pt;"
105 href="../authorizations/authorizations.php"
106 name="Authorizations"><?php xl('(Notes and Authorizations)','e'); ?></a>
107 <?php } else { ?>
108 <a class="more" style="font-size:8pt;"
109 href="../authorizations/authorizations.php"
110 name="Authorizations"><?php xl('(Patient Notes)','e'); ?></a>
111 <?php } ?>
113 <form name='findpatientform' action="find_patient.php?no_nav=1" method='post'>
114 <input type='hidden' name='mode' value="findpatient">
115 <input name='lastname' size='15' value="<?php echo $_SESSION["lastname"];?>"
116 onfocus="javascript:document.findpatientform.lastname.value='';"><br>
117 <select name="findBy" size='1'>
118 <option value="ID"><?php xl ('ID','e'); ?></option>
119 <option value="Last" selected><?php xl('Name','e'); ?></option>
120 <option value="SSN"><?php xl ('SSN','e'); ?></option>
121 <option value="DOB"><?php xl ('DOB','e'); ?></option>
122 </select><br>
123 <div align='right'>
124 <a href="javascript:document.findpatientform.submit();" class='link_submit'><?php xl ('Search','e'); ?></a>
125 </div>
126 </form>
127 </td>
128 <td width='300' valign='top'>
129 <?php
130 if ($lastname != "") {
132 <span class='bold'><?php xl ('Records Found','e'); ?></span>
133 <a class='text' href="../../new/new_patient.php" target="_top"><?php xl ('(New Patient)','e'); ?></a><br>
134 <?php
135 $count = 0;
136 $total = 0;
138 if ($findby == "Last") {
139 $result = getPatientLnames("$lastname","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS");
140 } elseif ($findby == "ID") {
141 $result = getPatientId("$lastname","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS");
142 } elseif ($findby == "DOB") {
143 $result = getPatientDOB("$lastname","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS");
144 } elseif ($findby == "SSN") {
145 $result = getPatientSSN("$lastname","*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS");
148 echo "<table>\n";
149 echo "<tr><td><span class='text'><?php xl ('Name','e'); ?></span></td>" .
150 "<td><span class='text'><?php xl ('SS','e'); ?></span></td>" .
151 "<td><span class='text'><?php xl ('DOB','e'); ?></span></td>" .
152 "<td><span class='text'><?php xl ('ID','e'); ?></span></td></tr>\n";
154 //set ampm default for find patient results links event_startampm
155 $ampm = 1;
156 if (date("H") >= 12) {
157 $ampm = 2;
159 //get the categories so you can get the details of the default category
160 $dbconn = $GLOBALS['adodb']['db'];
162 $sql = "SELECT pc_catid,pc_catname,pc_catcolor,pc_catdesc, " .
163 "pc_recurrtype,pc_recurrspec,pc_recurrfreq,pc_duration, " .
164 "pc_dailylimit,pc_end_date_flag,pc_end_date_type,pc_end_date_freq, " .
165 "pc_end_all_day FROM openemr_postcalendar_categories " .
166 "WHERE pc_catid = " . $GLOBALS['default_category'];
167 $catresult = $dbconn->Execute($sql);
169 $event_dur_minutes = ($catresult->fields['pc_duration']%(60 * 60))/60;
170 $event_dur_hours = ($catresult->fields['pc_duration']/(60 * 60));
171 $event_title = $catresult->fields['pc_catname'];
173 if ($result) {
174 foreach ($result as $iter) {
175 if ($total >= $M) {
176 break;
178 echo "<tr>";
180 $tmp = "<td><a class='link' href='javascript:newEvt($ampm," . date("H") .
181 ",0," . date("Ymd") . "," . $iter["providerID"] . "," . $iter['pid'] .
182 ")'>";
184 echo $tmp . $iter['lname'] . ", " . $iter['fname'] . "</a></td>\n";
185 echo $tmp . $iter['ss'] . "</a></td>\n";
186 echo $tmp . $iter['DOB_TS'] . "</a></td>\n";
187 echo $tmp . $iter['pubpid'] . "</a></td>\n";
189 echo "</tr>";
190 $count++;
191 $total++;
195 echo "</table>\n";
198 </td>
200 </tr>
201 </table>
203 </body>
204 </html>