2 [-*****************************************************************************-]
3 [-* Copyright (C)
2005-
2006 Rod Roark
<rod@sunsetsystems.com
> and others *-]
5 [-* LICENSE: This program is free software; you can redistribute it and/or *-]
6 [-* modify it under the terms of the GNU General Public License *-]
7 [-* as published by the Free Software Foundation; either version
3 *-]
8 [-* of the License, or (at your option) any later version. *-]
9 [-* This program is distributed in the hope that it will be useful, *-]
10 [-* but WITHOUT ANY WARRANTY; without even the implied warranty of *-]
11 [-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *-]
12 [-* GNU General Public License for more details. *-]
13 [-* You should have received a copy of the GNU General Public License *-]
14 [-* along with this program. If not, *-]
15 [-* see
<http://opensource.org/licenses/gpl-license.php
>;. *-]
16 [-*****************************************************************************-]
17 [-* @package OpenEMR *-]
18 [-* @author Rod Roark
<rod@sunsetsystems.com
> *-]
19 [-* @author Roberto Vasquez
<robertogagliotta@gmail.com
> *-]
20 [-* @link http://www.open-emr.org *-]
22 [-*****************************************************************************-]
23 [-config_load
file=
"default.conf"-]
24 [-*Load the Language Definitions*-]
25 [-config_load
file=
"lang.$USER_LANG"-]
26 [-include
file=
"$TPL_NAME/views/header.html"-]
27 [-* we want to include out stylesheet for this view*-]
28 [-fetch
file=
"$TPL_STYLE_PATH/day.css" assign=
"css"-]
36 font-family: Arial, Helvetica, sans-serif;
40 background-color:#ddffdd;
45 background-color:#ffbbbb;
50 background-color:#ffffff;
54 background-color:#ffbbbb;
63 border-bottom-width:
0px;
68 border-bottom-width:
0px;
72 div.tiny { width:
1px; height:
1px; font-size:
1px; }
75 <style type=
"text/css">@import url
(../../../library/dynarch_calendar.css);</style>
76 <script type=
"text/javascript" src=
"../../../library/dialog.js?v=[-php-] echo $v_js_includes; [-/php-]"></script>
77 <script type=
"text/javascript" src=
"../../../library/textformat.js"></script>
78 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar.js"></script>
79 [-php-] include_once(
"{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); [-/php-]
80 <script type=
"text/javascript" src=
"../../../library/dynarch_calendar_setup.js"></script>
82 <script language='JavaScript'
>
84 var mypcc
= '[-php-] echo $GLOBALS['phone_country_code
'] [-/php-]';
86 // This is called from the event editor popup.
87 function refreshme() {
89 document
.forms
[0].submit();
92 function newEvt(startampm
, starttimeh
, starttimem
, eventdate
, providerid
, catid
) {
93 dlgopen('add_edit_event.php?startampm=' + startampm
+
94 '&starttimeh=' + starttimeh
+ '&starttimem=' + starttimem
+
95 '&date=' + eventdate
+ '&userid=' + providerid
+ '&catid=' + catid
,
99 function oldEvt(eventdate
, eventid
) {
100 dlgopen('add_edit_event.php?date='+eventdate
+'&eid=' + eventid
, '_blank', 775, 500);
103 function goPid(pid
) {
104 top
.restoreSession();
106 echo
" top.RTop.location = '../../patient_file/summary/demographics.php' " .
107 "+ '?set_pid=' + pid;\n";
111 function GoToToday(theForm
){
112 var todays_date
= new Date();
113 var theMonth
= todays_date
.getMonth() + 1;
114 theMonth
= theMonth
< 10 ? "0" + theMonth
: theMonth
;
115 theForm
.jumpdate
.value
= todays_date
.getFullYear() + "-" + theMonth
+ "-" + todays_date
.getDate();
116 top
.restoreSession();
122 <!-- Required for the popup date selectors -->
123 <div id=
"overDiv" style=
"position:absolute; visibility:hidden; z-index:1000;"></div>
127 // A_CATEGORY is an ordered array of associative-array categories.
128 // Keys of interest are: id, name, color, desc, event_duration.
130 // echo
"<!-- A_CATEGORY = "; print_r($this-
>_tpl_vars['A_CATEGORY']); echo
" -->\n"; // debugging
131 // echo
"<!-- A_EVENTS = "; print_r($this-
>_tpl_vars['A_EVENTS']); echo
" -->\n"; // debugging
133 $A_CATEGORY =& $this-
>_tpl_vars['A_CATEGORY'];
135 // [-if $PRINT_VIEW !=
1-]
136 // [-*Main Navigation*-]
137 // [-include
file=
"$TPL_NAME/views/global/navigation.html"-]
140 $A_EVENTS =& $this-
>_tpl_vars['A_EVENTS'];
141 // $S_EVENTS =& $this-
>_tpl_vars['S_EVENTS']; // Deleted by Rod
142 $providers =& $this-
>_tpl_vars['providers'];
143 $times =& $this-
>_tpl_vars['times'];
144 $interval = $this-
>_tpl_vars['interval'];
145 $viewtype = $this-
>_tpl_vars['VIEW_TYPE'];
146 $PREV_WEEK_URL = $this-
>_tpl_vars['PREV_WEEK_URL'];
147 $NEXT_WEEK_URL = $this-
>_tpl_vars['NEXT_WEEK_URL'];
148 $PREV_DAY_URL = $this-
>_tpl_vars['PREV_DAY_URL'];
149 $NEXT_DAY_URL = $this-
>_tpl_vars['NEXT_DAY_URL'];
151 $Date = postcalendar_getDate();
152 if (!isset($y)) $y = substr($Date,
0,
4);
153 if (!isset($m)) $m = substr($Date,
4,
2);
154 if (!isset($d)) $d = substr($Date,
6,
2);
156 // echo
"<!-- There are " . count($A_EVENTS) .
" A_EVENTS days -->\n";
158 $MULTIDAY = count($A_EVENTS)
> 1;
160 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
161 if (count($facilities) ==
1 || !$_SESSION['pc_facility']) {
162 $_SESSION['pc_facility'] = $facilities[
0]['id'];
164 if ( $_SESSION['pc_facility'] ) {
165 $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']);
167 $provinfo = getProviderInfo();
169 // echo
"<form name='theform' action='index.php?module=PostCalendar&func=view" .
170 echo
"<form id='theform' name='theform' action='index.php?module=PostCalendar&func=view" .
171 "&tplview=default&pc_category=&pc_topic=' " .
172 "method='post' onsubmit='return top.restoreSession()'>\n";
174 echo
"<table border='0' cellpadding='0' cellspacing='0' width='99%'>\n";
175 echo
" <tr><td colspan='3' height='5'></td></tr>\n";
178 // Build the scrolling selection list of providers.
179 echo
" <td rowspan='2' align='left' valign='top' width='33%' nowrap>\n";
180 echo
" <select multiple size='3' name='pc_username[]'>\n";
181 echo
" <option value='__PC_ALL__'>" .xl (
"All Users").
"</option>\n";
182 foreach ($provinfo as $doc) {
183 $username = $doc['username'];
184 echo
" <option value='$username'";
185 foreach ($providers as $provider)
186 if ($provider['username'] == $username) echo
" selected";
187 echo
">" . $doc['fname'] .
" " . $doc['lname'] .
"</option>\n";
191 /*********************************************************************
192 // ==============================
193 // FACILITY FILTERING (lemonsoftware)
194 $facilities = getFacilities();
195 echo
" <select name='pc_facility'>\n";
196 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
197 echo
" <option value='0' $selected>" .xl('All Facilities').
"</option>\n";
198 foreach ($facilities as $fa) {
199 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
200 echo
" <option value='" .$fa['id'].
"' $selected>" .$fa['name'].
"</option>\n";
203 *********************************************************************/
204 // ==============================
205 // FACILITY FILTERING (lemonsoftware)
206 if ($_SESSION['authorizeduser'] ==
1) {
207 $facilities = getFacilities();
209 $facilities = getUserFacilities($_SESSION['authId']); // from users_facility
210 if (count($facilities) ==
1)
211 $_SESSION['pc_facility'] = ($facilities[
0]['id']);
213 if (count($facilities)
> 1) {
214 echo
" <select name='pc_facility' id='pc_facility' onChange='document.getElementById(\"theform\
").submit();'>\n";
215 if ( !$_SESSION['pc_facility'] ) $selected =
"selected='selected'";
216 if ( !$GLOBALS['restrict_user_facility']) echo
" <option value='0' $selected>" . xl('All Facilities') .
"</option>\n";
217 foreach ($facilities as $fa) {
218 $selected = ( $_SESSION['pc_facility'] == $fa['id']) ?
"selected='selected'" :
"" ;
219 echo
" <option value='" . $fa['id'] .
"' $selected>" . $fa['name'] .
"</option>\n";
223 /********************************************************************/
226 // ==============================
230 // Build the date and view type selectors and the Go button and the Today button.
231 echo
" <td align='center' valign='top' width='34%' nowrap>\n";
233 echo
" <input type='text' size='10' name='jumpdate' id='jumpdate'\n" .
234 " value='$y-$m-$d' title='yyyy-mm-dd date to go to'\n" .
235 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
236 " <img src='../../pic/show_calendar.gif' id='img_jumpdate' align='absbottom'\n" .
237 " width='24' height='22' border='0' alt='[?]' style='cursor:pointer'\n" .
238 " title='" .xl (
"Click here to choose a date").
"'>\n";
240 echo
" <select name='viewtype'>\n";
241 foreach ( array ('day' =
> xl(
"Day View"), 'week' =
> xl(
"Week View"), 'month' =
> xl(
"Month View"), 'year' =
> xl(
"Year View"))
243 echo
" <option value='$key'";
244 if ($key == $viewtype) echo
" selected";
245 echo
">$value</option>\n";
248 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Go").
"' />\n";
249 echo
" <input type='submit' name='bnsubmit' value='" .xl (
"Today").
"' onClick='GoToToday(theform);' />\n";
252 // Show the Add and Search buttons.
253 echo
" <td align='right' valign='top' width='33%' nowrap>\n";
254 echo
" <input type='button' value='" .xl (
"Add").
"' onclick='newEvt(1, 9, 00, $Date, 0, 0)' />\n";
255 echo
" <input type='button' value='" . xl (
"Search") .
256 "' onclick='top.restoreSession();location=\"index.php?module=PostCalendar&func=search\
"' />\n";
260 // Show the date/range and its previous- and next-day/week selectors.
262 echo
" <td align='center' width='34%' nowrap>\n";
263 $atmp = array_keys($A_EVENTS);
266 echo
"<a href='" . attr($PREV_WEEK_URL) .
"' onclick='top.restoreSession()'><<</a> \n";
267 echo dateformat(strtotime($atmp[
0]));
269 echo dateformat(strtotime($atmp[count($atmp)-
1]));
270 echo
" <a href='" . attr($NEXT_WEEK_URL) .
"' onclick='top.restoreSession()'>>></a>\n";
272 echo
"<a href='" . attr($PREV_DAY_URL) .
"' onclick='top.restoreSession()'><<</a> \n";
273 echo dateformat(strtotime($atmp[
0]), true);
274 echo
" <a href='" . attr($NEXT_DAY_URL) .
"' onclick='top.restoreSession()'>>></a>\n";
277 echo
" <td align='right' width='33%' nowrap>\n";
288 <script language='JavaScript'
>
289 Calendar
.setup({inputField
:"jumpdate", ifFormat
:"%Y-%m-%d", button
:"img_jumpdate"});
292 [-assign
var=
"dayname" value=$DATE|date_format:
"%w"-]
293 [-assign
var=
"day" value=$DATE|date_format:
"%d"|string_format:
"%1d"-]
294 [-assign
var=
"month" value=$DATE|date_format:
"%m"|string_format:
"%1d"-]
295 [-assign
var=
"year" value=$DATE|date_format:
"%Y"|string_format:
"%4d"-]
297 [-pc_sort_events
var=
"S_EVENTS" sort=
"time" order=
"asc" value=$A_EVENTS-]
301 echo
"<table width='100%' border='1' cellpadding='1' cellspacing='0' >\n";
302 $tdstylearr = array('bordyy', 'bordny', 'bordyn', 'bordnn');
305 foreach ($A_EVENTS as $date =
> $events) {
306 $need_headers = true;
307 $eventdate = substr($date,
0,
4) . substr($date,
5,
2) . substr($date,
8,
2);
309 // If multiple days then show a date header for each.
312 echo
" <td colspan='" . (count($providers) *
2) .
"' align='center'>" .
313 dateformat(strtotime($date), true) .
"</td>";
317 $arr_events = $A_EVENTS[$date];
318 list($slotkey, $slotevent) = each($arr_events);
320 // This is an array of provider status information for this day,
321 // used to properly assign table cell attributes.
325 $lastslotindex = count($times) -
1;
327 // For each time slot...
328 foreach ($times as $slottime) {
329 $startampm = ($slottime['mer']) ==
"pm" ?
2 :
1;
330 $starttimeh = $slottime['hour'];
331 $starttimem = $slottime['minute'];
332 $slotendmins = $starttimeh *
60 + $starttimem + $interval;
334 // Repeat doc names at
1PM. This is a kludge; omit it for released code.
335 // if ($starttimeh ==
13 && $starttimem ==
0) $need_headers = true;
337 // Get all events for all providers just for this time slot now, because we
338 // can pick up where we left off and because we don't want to re-scan all
339 // events for the day for each table cell.
342 for (; isset($slotkey); list($slotkey, $slotevent) = each($arr_events)) {
343 $starth = substr($slotevent['startTime'],
0,
2);
344 $startm = substr($slotevent['startTime'],
3,
2);
346 if (($starth *
60 + $startm)
>= $slotendmins) break;
348 $arr_slot[$slotkey] = $slotevent;
350 $catid = $slotevent['catid'];
351 $providerid = $slotevent['aid'];
352 $durminutes = ceil($slotevent['duration'] /
60);
353 $durslots = ceil($durminutes / $interval);
355 // While we're here, collect information for cell cosmetics.
356 if ($catid ==
2) { // in office
357 $provstat[$providerid]['in'] = true;
359 // Save preferred category info for this IN event.
360 $provstat[$providerid]['in_cat'] = -
1;
361 $provstat[$providerid]['in_slot0'] = $slotindex;
362 $provstat[$providerid]['in_slots'] =
1;
363 if ($slotevent['prefcatid']) {
364 foreach ($A_CATEGORY as $catkey =
> $catval) {
365 if ($catval['id'] == $slotevent['prefcatid']) {
366 $provstat[$providerid]['in_cat'] = $catkey;
367 $provstat[$providerid]['in_slots'] =
368 ceil(ceil($catval['event_duration'] /
60) / $interval);
373 if ($provstat[$providerid]['in_cat'] <
0) {
374 echo
"<!-- Unmatched prefcatid = " . $slotevent['prefcatid'] .
" -->\n"; // debugging
379 else if ($catid ==
3) { // out of office
380 $provstat[$providerid]['in'] = false;
382 else if ($catid ==
4 || $catid ==
8 || $catid ==
11) { // unavailable types
383 // unavailable slots are marked 'res' for appropriate coloring.
384 $endindex = $slotindex + $durslots;
385 for ($i = $slotindex; $i < $endindex; ++$i) {
386 $provstat[$providerid][$i]['res'] = true;
389 // If duration
> slot size then mark slots for border control. A slot
390 // marked 'ext' is not to have a border between itself and the slot below.
392 $endindex = $slotindex + $durslots -
1;
393 for ($i = $slotindex; $i < $endindex; ++$i) {
394 $provstat[$providerid][$i]['ext'] = true;
398 // Finished getting event information for this time slot.
400 // Write a header row with the provider names if appropriate.
402 $need_headers = false;
404 foreach ($providers as $provider) {
405 echo
" <td colspan='2' align='center'>";
406 echo $provider['fname'][
0] .
" " . $provider['lname'];
414 // We are now ready to write the table row for the current time slot.
415 // This loops once for each provider to be displayed.
417 foreach ($providers as $provider) {
418 $providerid = $provider['id'];
420 // Mark this as a no-bottom-border slot if the preferred category
421 // duration extends beyond it.
423 // echo
"<!-- slotindex=$slotindex in=" . $provstat[$providerid]['in'] .
424 //
" in_cat=" . $provstat[$providerid]['in_cat'] .
425 //
" in_slot0=" . $provstat[$providerid]['in_slot0'] .
426 //
" in_slots=" . $provstat[$providerid]['in_slots'] .
" -->\n"; // debugging
428 if ($provstat[$providerid]['in']) {
429 if (($slotindex +
1 - $provstat[$providerid]['in_slot0']) % $provstat[$providerid]['in_slots'])
430 $provstat[$providerid][$slotindex]['ext'] = true;
433 $content =
""; // this will be the event cell content
436 if ($provstat[$providerid][$slotindex]['res'] || ! $provstat[$providerid]['in']) {
440 // Remove top and/or bottom table cell borders using CSS when events span
441 // time slots or when the practitioner is not in-office. Using
"rowspan"
442 // would be a difficult and inferior solution to this problem.
446 if ($slotindex < $lastslotindex &&
447 ($provstat[$providerid][$slotindex]['ext'] || !$provstat[$providerid]['in'])) {
448 $tdstyleix +=
1; // no bottom
450 if ($slotindex
> 0 && ($provstat[$providerid][$slotindex-
1]['ext'] ||
451 !($provstat[$providerid]['in'] || $provstat[$providerid]['wasin']))) {
452 $tdstyleix +=
2; // no top
455 $tdstyle = ' ' . $tdstylearr[$tdstyleix];
457 $disptimeh = ($starttimeh
> 12) ? ($starttimeh -
12) : $starttimeh;
460 if ($provstat[$providerid]['in_cat']
>=
0) {
461 $category =& $A_CATEGORY[$provstat[$providerid]['in_cat']];
462 if ($category['id']) $in_cat_id = $category['id'];
465 // If a slot omits the top border, then we omit the TOD cell's top border
466 // and skip writing its time-of-day text. This way we can get some rows
467 // with no content at all, which should produce a more compact and readable
470 echo
" <td class='t$clsuffix$tdstyle'";
471 if ($slotindex ==
0) echo
" width='1%'";
474 echo
"<a href='javascript:newEvt($startampm,$starttimeh,$starttimem,$eventdate,$providerid,$in_cat_id)'>";
475 echo
"$disptimeh:$starttimem</a>";
477 echo
"<div class=tiny></div>"; //
1x1 px content so the browser does not suppress borders
481 echo
" <td class='e$clsuffix$tdstyle'";
482 if ($clsuffix ==
"acell" && $in_cat_id) {
483 echo
" style='background-color:" . $category['color'] .
"'";
484 echo
" title='" . $category['name'] .
"'";
488 // Scan all events for this time slot and generate the associated HTML for
489 // this doc. JavaScript is used in hrefs to reduce the volume of output.
492 while (list($eventkey, $event) = each($arr_slot)) {
493 if ($event['aid'] != $providerid) continue;
494 if ($content) $content .=
" ";
495 $starth = substr($event['startTime'],
0,
2);
496 $startm = substr($event['startTime'],
3,
2);
497 $eventid = $event['eid'];
498 $patientid = $event['pid'];
499 $commapos = strpos($event['patient_name'],
",");
500 $lname = substr($event['patient_name'],
0, $commapos);
501 $fname = substr($event['patient_name'], $commapos +
2);
502 $patient_dob = $event['patient_dob'];
503 $patient_age = $event['patient_age'];
504 $title = xl('Age') .
" $patient_age ($patient_dob)";
505 $catid = $event['catid'];
506 $comment = addslashes($event['hometext']);
507 $catname = $event['catname'];
508 if ($comment && $GLOBALS['calendar_appt_style'] <
4)
509 $title .=
" " . $comment;
510 if ($catid ==
2 || $catid ==
3 || $catid ==
4 || $catid ==
8 || $catid ==
11) {
511 if ($catid ==
2) $catname = xl('IN');
512 else if ($catid ==
3) $catname = xl('OUT');
513 else if ($catid ==
4) $catname = xl('VACATION');
514 else if ($catid ==
8) $catname = xl('LUNCH');
515 else if ($catid ==
11) $catname = xl('RESERVED');
516 // Omit lunch, vacation, etc. if the doc is not in-office.
517 if ($provstat[$providerid]['in'] || $catid <
4) {
518 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)'>";
519 $content .= $catname;
520 if ($comment) $content .=
" - $comment";
524 else if ($patientid) { // some sort of patient appointment
525 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname'>";
526 // $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) .
"</a>";
527 $content .= $starth . ':' . $startm . '
' . htmlspecialchars($event['apptstatus']) .
" </a>";
528 $content .=
"<a href='javascript:goPid($patientid)' title='$title'>";
529 if ($catid ==
1) $content .=
"<strike>";
530 $content .= htmlspecialchars($lname);
531 if ($GLOBALS['calendar_appt_style'] !=
1) {
532 $content .=
"," . htmlspecialchars($fname);
533 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
534 $content .=
"(" . $event['title'];
535 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
536 $content .=
": <font color='green'>" . htmlspecialchars(trim($event['hometext'])) .
"</font>";
540 if ($catid ==
1) $content .=
"</strike>";
543 else { // some other non-patient event
544 $content .=
"<a href='javascript:oldEvt($eventdate,$eventid)' title='$catname' " .
545 "style='background-color:" . $event['catcolor'] .
"'>";
546 $content .= $starth . ':' . $startm . '
' . htmlspecialchars($event['apptstatus']) .
" ";
547 if ($GLOBALS['calendar_appt_style'] !=
1) {
548 if ($event['title'] && $GLOBALS['calendar_appt_style']
>=
3) {
549 $content .= $event['title'];
550 if ($event['hometext'] && $GLOBALS['calendar_appt_style']
>=
4)
551 $content .=
": " . htmlspecialchars(trim($event['hometext']));
558 if (! $content) $content =
"<div class=tiny></div>"; // so the browser does not suppress borders
559 echo $content .
"</td>\n";
561 // Keep track of whether the doc was in during the previous time slot.
562 $provstat[$providerid]['wasin'] = $provstat[$providerid]['in'];
575 // [-include
file=
"$TPL_NAME/views/global/footer.html"-]
576 // [-include
file=
"$TPL_NAME/views/footer.html"-]