FreeMED. Scheduler

Holds methods for dealing with calendar ans scheduling appointments.  Most methods from lib/calendar-functions.php that were important should have been migrated here.

Summary
Holds methods for dealing with calendar ans scheduling appointments.
Contains the common names of calendar fields, mapped to their SQL names.
Copy the given appointment to a specified date
Addition method for date.
Determine if a date falls between a beginning and end date.
Check to see if date is in the past
Creates AM/PM user-friendly hour display.
Creates AM/PM user-friendly time display.
Display calendar event from scheduler.
Return proper names for special event mappings, as per the group calendar and Travel.
Look up list of appointments for specified day and provider.
Given a group id, return the appointments in that group
Generate a miniature calendar, linking to the given page
Retrieves an appointment record from its id
Form a human readable time string from an hour and a minute.
Creates a scheduler map.
Determine whether an appointment of the specified duration at the specified time will fit in the specified map.
Creates a blank scheduler map.
Given an appointment id and data, modify an appointment record.
Given a group id (for a group of appointments), modify a group of appointment records with the given data.
Creates 3rd generation multiple scheduling map.
Get next available slot with appropriate parameters.
Increment time slot by 5 minutes.
Create an appointment record with the specified data
Given an appointment (by its id) and a set of dates, replicate the appointment exactly on given dates.
Scroll a given date back by a month
Scroll a given date forward by a month
Internal helper function to convert SQL queries into scheduler appointment arrays (arrays of associative arrays).

Variables

calendar_field_mapping

var $calendar_field_mapping

Contains the common names of calendar fields, mapped to their SQL names.  For copying purposes, it also contains SQL names mapped to themselves.

Functions

copy_appointment

function copy_appointment ($id,
$date)

Copy the given appointment to a specified date

Parameters

$idid for the specified appointment
$dateSQL date format (YYYY-MM-DD) specifying the date to copy the appointment

Returns

Boolean, whether successful

See Also

copy_group_appointment

copy_group_appointment

function copy_group_appointment ($group_id,
$date)

Parameters

$group_idid for the group appointments
$dateTarget date

Return

Boolean, whether successful

See Also

copy_appointment

date_add

function date_add ($starting,
$interval)

Addition method for date.  Adds days to starting date.

Parameters

Returns

Date in SQL date format.

date_in_range

function date_in_range ($checkdate,
$dtbegin,
$dtend)

Determine if a date falls between a beginning and end date.

Parameters

$checkdateDate to check.  Should be in ANSI SQL date format (YYYY-MM-DD).
$dtbeginBeginning of time span to compare against.
$dtendEnding of time span to compare against.

Returns

Boolean value, whether date falls between specified dates.

date_in_the_past

function date_in_the_past ($datestamp)

Check to see if date is in the past

Parameters

$dateSQL formatted date string (YYYY-MM-DD)

Returns

Boolean, true if date is past, false if date is present or future.

display_hour

function display_hour ($hour)

Creates AM/PM user-friendly hour display.

Parameters

$hourHour in 0..24 military format.

Returns

AM/PM display of hour

display_time

function display_time ($hour,
$minute)

Creates AM/PM user-friendly time display.

Parameters

$hourHour in 0..24 military format.
$minuteMinute in 0..60 format.

Returns

User-friendly AM/PM display of time.

event_calendar_print

function event_calendar_print ($event,  
$short =  false)

Display calendar event from scheduler.

Parameters

$eventscheduler table event id number.
$short(optional) boolean, whether to shorten the view for a concise output.  Defaults to false.

Returns

XHTML formatted calendar event.

event_special

function event_special ($mapping)

Return proper names for special event mappings, as per the group calendar and Travel.

Parameters

$mappingSpecial id mapping.  This is usually a number from 0 to 8.

Returns

Text name of specified mapping.

find_date_appointments

function find_date_appointments ($date,  
$provider =  -1)

Look up list of appointments for specified day and provider.

Parameters

$dateDate in YYYY-MM-DD
$provider(optional) id for the provider in question.  If this is omitted, all providers will be queried.

Returns

Array of associative arrays containing appointment information

find_group_appointments

function find_group_appointments ($group_id)

Given a group id, return the appointments in that group

Parameters

$group_idid for the group that is being searched for

Returns

Array of associative arrays containing appointment information.

generate_calendar_mini

function generate_calendar_mini ($given_date,
$this_url)

Generate a miniature calendar, linking to the given page

Parameters

$given_dateDate to be selected
$this_urlURL to append the date to in links

Returns

HTML code for miniature calendar

get_appointment

function get_appointment ($id)

Retrieves an appointment record from its id

Parameters

$idid for the specified appointment

Returns

Associative array containing appointment information

get_time_string

function get_time_string ($hour,
$minute)

Form a human readable time string from an hour and a minute.

Parameters

$hourHour in 24 hour format (0 to 24).
$minuteMinutes (0 to 60).

Returns

Formatted time string.

map

function map ($query)

Creates a scheduler map.  This is the 2nd generation of the depreciated interference map.

Parameters

$querySQL query string.

Returns

”map” associative multi-dimentional array containing scheduling interference data.

See Also

map_fit map_init

map_fit

function map_fit ($map,  
$time,  
$duration = 5,
$id =  -1)

Determine whether an appointment of the specified duration at the specified time will fit in the specified map.

Parameters

$mapScheduler “map” as generated by map.
$timeTime string specifying the time of the appointment to check.  Should be in format HH:MM.
$duration(optional) Duration of the appointment in minutes.  This is 5 by default.
$id(optional) If this is specified it shows the pre-existing scheduler id for an appointment, so that if it is being moved, it does not conflict with itself.

Returns

Boolean, whether specified appointment fits into the specified map.

See Also

map map_init

map_init

function map_init ()

Creates a blank scheduler map.

Returns

Blank scheduler map (associative array).

See Also

map map_fit

move_appointment

function move_appointment ($original,  
$data =  NULL)

Given an appointment id and data, modify an appointment record.

Parameters

$originalOriginal appointment id
$dataAssociative array of data to be changed in the appointment record.  See calendar_field_mapping for a list of acceptable keys.

Returns

Boolean, whether successful.

move_group_appointment

function move_group_appointment ($group_id,
$data)

Given a group id (for a group of appointments), modify a group of appointment records with the given data.  This follows the same basic format as move_appointment

Parameters

$group_idid for the appointment group
$dataAssociative array of data to be changed in the appointment record.  See calendar_field_mapping for a list of acceptable keys.

Returns

Boolean, whether successful.

See Also

move_appointment

multimap

function multimap ($query,  
$selected =  -1)

Creates 3rd generation multiple scheduling map.  This is used to automatically create additional columns due to overlapping and overbooking.

Parameters

$querySQL query string describing options.
$selected(optional) Scheduler table id of selected appointment.  If this is not specified, no appointment will be selected by default.

Returns

Multimap (associative array).

See Also

map

next_available

function next_available ($_criteria)

Get next available slot with appropriate parameters.

Parameters

$_criteriaHash containing one or more of the following:
  • after - After a particular hour
  • date - Date to start the search from
  • days - Number of days to search (defaults to 4)
  • duration - In minutes (defaults to 5)
  • forceday - Force day to be day of week (1..7 ~ Mon..Sun)
  • location - Room location
  • provider - With a particular provider
  • single - Provide single answer
  • weekday - Force weekday (boolean)

Returns

array ( of array ( date, hour, minute ) ) false if nothing is open

next_time_increment

function next_time_increment ($time)

Increment time slot by 5 minutes.

Parameters

$timeTime in HH:MM format.

Returns

Next time slot in HH:MM format.

set_appointment

function set_appointment ($data =  NULL)

Create an appointment record with the specified data

Parameters

$dataAssociative array of values to be used when setting the appointment.  Uses calendar_field_mapping to determine values from keys.

Returns

id of created appointment

set_group_appointment

function set_group_appointment ($patients,
$data)

Parameters

$patientsArray of patient identifiers.  The first of this array will be the appointment used to generate the group id.
$dataAssociative array of data used to populate the appointment data.  Same syntax as set_appointment.

Returns

Group key id for new group created.

See Also

set_appointment

set_recurring_appointment

function set_recurring_appointment ($appointment,
$ts,
$desc)

Given an appointment (by its id) and a set of dates, replicate the appointment exactly on given dates.  All of the appointments can later be accessed through the use of the calrecurid field.  This allows for recurring appointments to be modified and deleted.  A natural language description of the appointment is placed in recurnote.

Parameters

$appointmentid of the appointment in question
$tsArray of timestamps containing the dates for the appointment to repeat
$descDescription of the recurrance

scroll_prev_month

function scroll_prev_month ($given_date = "")

Scroll a given date back by a month

Parameters

$given_date(optional) Date to scroll back from in SQL date format (YYYY-MM-DD).  Defaults to current date.

Returns

SQL formatted date string for a date approximately one month previous to the given date.

scroll_next_month

function scroll_next_month ($given_date = "")

Scroll a given date forward by a month

Parameters

$given_date(optional) Date to scroll forward from in SQL date format (YYYY-MM-DD).  Defaults to current date.

Returns

SQL formatted date string for a date approximately one month after the given date.

_query_to_result_array

function _query_to_result_array ($query)

Internal helper function to convert SQL queries into scheduler appointment arrays (arrays of associative arrays).

Parameters

$querySQL query text

Returns

Array of associative arrays containing appointment data.

var $calendar_field_mapping
Contains the common names of calendar fields, mapped to their SQL names.
function copy_appointment ($id,
$date)
Copy the given appointment to a specified date
function copy_group_appointment ($group_id,
$date)
function date_add ($starting,
$interval)
Addition method for date.
function date_in_range ($checkdate,
$dtbegin,
$dtend)
Determine if a date falls between a beginning and end date.
function date_in_the_past ($datestamp)
Check to see if date is in the past
function display_hour ($hour)
Creates AM/PM user-friendly hour display.
function display_time ($hour,
$minute)
Creates AM/PM user-friendly time display.
function event_calendar_print ($event,  
$short =  false)
Display calendar event from scheduler.
function event_special ($mapping)
Return proper names for special event mappings, as per the group calendar and Travel.
function find_date_appointments ($date,  
$provider =  -1)
Look up list of appointments for specified day and provider.
function find_group_appointments ($group_id)
Given a group id, return the appointments in that group
function generate_calendar_mini ($given_date,
$this_url)
Generate a miniature calendar, linking to the given page
function get_appointment ($id)
Retrieves an appointment record from its id
function get_time_string ($hour,
$minute)
Form a human readable time string from an hour and a minute.
function map ($query)
Creates a scheduler map.
function map_fit ($map,  
$time,  
$duration = 5,
$id =  -1)
Determine whether an appointment of the specified duration at the specified time will fit in the specified map.
function map_init ()
Creates a blank scheduler map.
function move_appointment ($original,  
$data =  NULL)
Given an appointment id and data, modify an appointment record.
function move_group_appointment ($group_id,
$data)
Given a group id (for a group of appointments), modify a group of appointment records with the given data.
function multimap ($query,  
$selected =  -1)
Creates 3rd generation multiple scheduling map.
function next_available ($_criteria)
Get next available slot with appropriate parameters.
function next_time_increment ($time)
Increment time slot by 5 minutes.
function set_appointment ($data =  NULL)
Create an appointment record with the specified data
function set_group_appointment ($patients,
$data)
function set_recurring_appointment ($appointment,
$ts,
$desc)
Given an appointment (by its id) and a set of dates, replicate the appointment exactly on given dates.
function scroll_prev_month ($given_date = "")
Scroll a given date back by a month
function scroll_next_month ($given_date = "")
Scroll a given date forward by a month
function _query_to_result_array ($query)
Internal helper function to convert SQL queries into scheduler appointment arrays (arrays of associative arrays).