FreeMED. MaintenanceModule

Database table maintenance module superclass.  This is descended from BaseModule.

Summary
Database table maintenance module superclass.
Defines the ORDER BY clause for built-in functions.
List of form variables which need to be used in the add or modify forms.
Turns of ACL checking for ‘support’ modules.
Defines the name of the SQL table used and/or defined by this module.
Specifies the format of the widget method.
Specifies the format of the XML-RPC structures returned by the FreeMED.DynamicModule.picklist method.
Specifies the field names which are allowed to have distinct value queries against them.
Should be overridden by any module which needs different access checks.
Basic superclass addition routine.
Wrapper for _add.
Basic superclass deletion routine.
Wrapper for _del.
Basic superclass modification routine.
Wrapper for _mod.
Superclass stub for basic add/modify form capabilities.
Returns an array of form elements to be passed to <html_form::form_table> which are to be used in an add or modify form.
Generic picklist for XML-RPC.
Provide a list of distinct values for a particular field.
Get single support data field.
Convert id to text, based on $this->widget_hash
Generic widget code to allow a picklist-based widget for simple modules.
Internal method called by the module superclass, which executes initial table creation from create_table and initial data import from freemed_import_stock_data.
Creates the initial table definition required by this module to function properly.

Variables

$this->order_field

Defines the ORDER BY clause for built-in functions.  This should be present in all child modules.  It is set to ‘id’ by default, which is horrible behavior, and should be overridden in all child classes.

$this->form_vars

List of form variables which need to be used in the add or modify forms.

Example

$this->form_vars = array ( ‘ptfname’, ‘ptlname’ );

See Also

form

$this->defeat_acl

Turns of ACL checking for ‘support’ modules.  This is useful for modules that are used with their own internal access controls.  Defaults to false.

Example

$this->defeat_acl = true;

$this->table_name

Defines the name of the SQL table used and/or defined by this module.  Must be defined for the module to function properly if a table definition is used.

Example

$this->table_name = ‘facility’;

$this->widget_hash

Specifies the format of the widget method.  This is formatted by having SQL field names surrounded by ‘##’s.

Example

$this->widget_hash = ‘##phylname##, ##phyfname##’;

$this->rpc_field_map

Specifies the format of the XML-RPC structures returned by the FreeMED.DynamicModule.picklist method.  These are passed as key => value, where key is the target name of the structure item and value is the name of the SQL field.  “id” is passed as “id” by default.  If this array is not defined, FreeMED.DynamicModule.picklist will fail for the target module.

Example

$this->rpc_field_map = array ( ‘last_name’ => ‘ptlname’ );

$this->distinct_fields

Specifies the field names which are allowed to have distinct value queries against them.

Example

$this->distinct_fields = array ( “assignedto” );

Functions

acl_access

function acl_access ($type)

Should be overridden by any module which needs different access checks.

_add

function _add ($_param =  NULL)

Basic superclass addition routine.

Parameters

$_param(optional) Associative array of values.  If specified, _add will run quiet.  The associative array is in the format of sql_name => sql_value.

Returns

Nothing if there are no parameters.  If $_param is specified, _add will return the id number if successful or false if unsuccessful.

See Also

add

add

function add ()

Wrapper for _add.  This exists so that FreeMED modules can override the basic add functionality while still having access to the low-level functionality.

See Also

_add

_del

function _del ($_id =  -1)

Basic superclass deletion routine.

Parameters

$_param(optional) Id number for the record to be deleted.

Returns

Nothing if there are no parameters.  If $_param is specified, _del will return boolean true or false depending on whether it is successful.

See Also

del

del

function del ()

Wrapper for _del.  This exists so that FreeMED modules can override the basic del while still having access to the low-level functionality.

See Also

_del

_mod

function _mod ($_param =  NULL)

Basic superclass modification routine.

Parameters

$_param(optional) Associative array of values.  If specified, _mod will run quiet.  The associative array is in the format of sql_name => sql_value.

Returns

Nothing if there are no parameters.  If $_param is specified, _mod will return boolean true or false depending on whether it is successful.

See Also

mod

mod

function mod()

Wrapper for _mod.  This exists so that FreeMED modules can override the basic mod while still having access to the low-level functionality.

See Also

_mod

form

function form ()

Superclass stub for basic add/modify form capabilities.  Performs no useful task, and should be overridden with the methods producing an addition/modification form.

generate_form

function generate_form ( )

Returns an array of form elements to be passed to <html_form::form_table> which are to be used in an add or modify form.  This should be overridden, and has no use if form is overridden.

picklist

function picklist ($criteria =  NULL)

Generic picklist for XML-RPC.

Parameters

$criteria(optional) Hash of criteria fields to narrow the search

Returns

Array of hashes

distinct

function distinct ($field)

Provide a list of distinct values for a particular field.

Parameters

$fieldName of field to provide distinct values for.

Returns

Array of distinct values, or false if the field name is invalid.

get_field

function get_field ($id,
$field)

Get single support data field.

Parameters

$idRecord id
$fieldField name

Returns

Textual version of field

to_text

function to_text ($id,  
$field = 'id')

Convert id to text, based on $this->widget_hash

Parameters

$idRecord id
$field(optional) Defaults to id for the identifying field.

Returns

Textual version of record

widget

function widget ($varname,  
$conditions =  false,
$field =  'id',
$options =  NULL)

Generic widget code to allow a picklist-based widget for simple modules.  Should be overridden for more complex tasks.

This function uses $this->widget_hash, which contains field names surrounded by ‘##’s.

Parameters

$varnameName of the variable that the widget’s data is passed in.
$conditions(optional) Additional clauses for SQL WHERE. defaults to none.
$field(optional) Field to return as value.  Defaults to id.
$options(optional) Options to pass to html_form::select_widget
  • multiple - Pass a size value for this to be a multiple selection widget

Returns

XHTML-compliant picklist widget.

_setup

function _setup ()

Internal method called by the module superclass, which executes initial table creation from create_table and initial data import from freemed_import_stock_data.

create_table

function create_table ()

Creates the initial table definition required by this module to function properly.  Relies on the table_definition class variable, and will not execute if it is not present.

Returns

Boolean, false if failed.

function widget ($varname,  
$conditions =  false,
$field =  'id',
$options =  NULL)
Generic widget code to allow a picklist-based widget for simple modules.
function acl_access ($type)
Should be overridden by any module which needs different access checks.
function _add ($_param =  NULL)
Basic superclass addition routine.
function add ()
Wrapper for _add.
function _del ($_id =  -1)
Basic superclass deletion routine.
function del ()
Wrapper for _del.
function _mod ($_param =  NULL)
Basic superclass modification routine.
function mod()
Wrapper for _mod.
function form ()
Superclass stub for basic add/modify form capabilities.
function generate_form ( )
Returns an array of form elements to be passed to html_form::form_table which are to be used in an add or modify form.
function picklist ($criteria =  NULL)
Generic picklist for XML-RPC.
function distinct ($field)
Provide a list of distinct values for a particular field.
function get_field ($id,
$field)
Get single support data field.
function to_text ($id,  
$field = 'id')
Convert id to text, based on $this->widget_hash
Specifies the format of the widget method.
function _setup ()
Internal method called by the module superclass, which executes initial table creation from create_table and initial data import from freemed_import_stock_data.
function create_table ()
Creates the initial table definition required by this module to function properly.
function freemed_import_stock_data ($table_name)
Import an SQL table into FreeMED
Basic FreeMED module class.