Core APIThis is the main FreeMED API, which contains the bulk of FreeMED’s commonly used functions. The rest of the functions are located in classes which are called dynamically using CreateObject(). It is located in lib/API.php. Summary | This is the main FreeMED API, which contains the bulk of FreeMED’s commonly used functions. | | | | Query ACL for a particular resource. | | Check ACLs, optionally with patient access. | | Checks to see if the current user has access to the specified facility. | | Checks to see whether the current user has access to the specified patient. | | Retrieves a configuration value from FreeMED’s centralized configuration database table. | | Check configuration value against user database then system configuration database. | | Master function to run authentication routines for the current used. | | Determine dates between two YYYY-MM-DD dates. | | Creates a drug selection widget. | | Get a database table record by its “id” field. | | Return a single field from a particular database table from its “id” field. | | Set breakpoint for handlers for a certain function | | Creates an SQL “WHERE” clause based on search information provided by <freemed::display_itemlist>, as used by most of FreeMED’s modules. | | Resolves a stored document’s full path based on the qualifiers presented. | | Set key binding for a particular key or set of keys. | | Determines whether a module is installed in the system, and optionally whether it is above a certain minimum versioning number. | | Check to see if module is allowable via ACLs | | Gets a cached module value (such as “MODULE_NAME”, etc) from the module cache. | | Gets cached metainformation for the specified module in the module cache. | | Provides global access to a PHP.module_list object with cached module information. | | Returns the list of modules associated with a certain handler. | | Lookup the module name as needed by FreeMED’s module calls, but by the class name of the module. | | Registers module or newer version of module in FreeMED’s global module registry. | | Get list of tables for modules. | | Get table name from module name. | | Get the current version number of a particular module in FreeMED from the module database table. | | Create a multiple-choice widget | | Create a “patient box” with quick access to various patient functions. | | Create a patient selection widget | | Create XHTML widget to represent printer selection | | Dumps the output of an SQL query to a multidimentional hashed array. | | Perform internationalization (i18n) on an HTML_QuickForm PEAR object. | | Create HL7 v2.3.1 compliant race widget (table 0005) | | Creates a rich text editing widget (HTML) | | Remove potentially hazardous characters from filenames | | Convert an SQL timestamp (such as MySQL timestamps) into a nice-looking date string. | | Stores posted file in scanned document image store. | | Determines whether the current browser supports DjVu. | | Resolve file to existing either in default template or current template. | | Determine if a particular user flag is set for the current user. | | Determine if the current user has the ability to “override” the locking of a record. | | Get log object with caching. | | Displays phone number in system format. | | Create alternating texts. | | Creates the ADD/RETURN TO MENU bar present in most FreeMED modules. | | Creates a paginated list display based on formatting data for a particular result set. | | Creates an XHTML facility selection widget. | | Create an XHTML selection box | | Export FreeMED database table to a file | | Import an SQL table into FreeMED | | Get next valid SQL format date (YYYY-MM-DD) | | Get previous date in SQL format (YYYY-MM-DD) | | Assemble seperate date fields into single SQL format date hash | | Creates XHTML-compliant date selection widget | | Create a nicely formatted date display | | Convert array to XHTML input type=HIDDEN tags | | Create an XHTML compliant number selection widget | | Display the current template | | Push page onto global history stack. | | Pop off page from global history stack. | | Push patient onto global history stack. | | Get global history list for patients | | Get global history list for pages | | Contruct a help link from the specified page and section | | Check current basic authentication against users in the database. |
freemed:: aclQuery ACL for a particular resource. Parameters$category | Which category of ARO is being queried. Examples would be things like ‘admin’, ‘bill’, ‘schedule’, et cetera. | $permission | Resource being queried. This would be things like ‘add’, ‘modify’, ‘view’, ‘delete’, et cetera. | $axo_group | (optional) AXO group to be searched on. Note that valid groups are things like ‘patient’. | $axo_item | (optional) AXO item. This would be the patient ID key for a patient, or something else for another AXO group. |
ReturnsBoolean, depending on whether the resource is allowed or denied.
freemed:: acl_patientCheck ACLs, optionally with patient access. Note that this function behaves exactly like freemed::acl if the acl_patient configuration value is disabled. Parameters$category | Which category of ARO is being queried. Examples would be things like ‘admin’, ‘bill’, ‘schedule’, et cetera. | $permission | Resource being queried. This would be things like ‘add’, ‘modify’, ‘view’, ‘delete’, et cetera. | $pid | Patient id number (record id) for patient being checked. |
ReturnsBoolean, whether access is granted. See Alsofreemed::acl
freemed:: check_access_for_facilityChecks to see if the current user has access to the specified facility. Parameters$facility_number | the database id of the facility in question |
Returns$access | boolean value, whether access is granted |
See Alsofreemed::check_access_for_patient
freemed:: check_access_for_patientChecks to see whether the current user has access to the specified patient. Parameters$patient_number | The database identifier for the patient | $user (optional) | The database identifier for the current user. (This should be used when dealing with XML-RPC or another protocol which does not use cookie-based authentication. |
Returns$access | boolean, whether access is granted |
See Alsofreemed::check_access_for_facility
freemed:: config_valueRetrieves a configuration value from FreeMED’s centralized configuration database table. Parameters$key | The name of the configuration value desired. |
Returns$value | The value of the configuration key, or NULL if the key is not found. |
freemed:: config_user_valueCheck configuration value against user database then system configuration database. Parameters$key | The name of the configuration value desired. |
Returns$value | The value of the configuration key, or NULL if the key is not found. |
See Alsofreemed::config_value
freemed:: connectMaster function to run authentication routines for the current used. This method should be called at the beginning of every standalone FreeMED script when dealing with standard session based authentication.
freemed:: dates_betweenDetermine dates between two YYYY-MM-DD dates. Parameters$start | Starting date in YYYY-MM-DD | $end | Ending date in YYYY-MM-DD |
ReturnsArray of dates in YYYY-MM-DD
freemed:: drug_widgetCreates a drug selection widget. Parameters$varname | Name of the variable which should contain the drug name. | $formname (optional) | Name of the form that contains this widget. Defaults to “myform”. | $submitname (optional) | Name of the variable that is used to pass data between the child window and the parent window. Defaults to “submit_action”. |
Returns$widget | XHTML compliant widget code |
freemed:: get_link_recGet a database table record by its “id” field. Parameters$id | Value of the id field requested. | $table | Name of the FreeMED database table. |
Returns$rec | Associative array / hash containing key and value pairs, where the key is the name of the database table field, and its associated value is the value found in the database. | $force_no_cache | (optional) Boolean, allows defeating of automatic caching, which will distrupt sequential operations. Defaults to false. |
See Alsofreemed::get_link_field
freemed:: get_link_fieldReturn a single field from a particular database table from its “id” field. Parameters$id | Value of the id field requested. | $table | Name of the FreeMED database table. | $field | Name of the field in the database table. |
Returns$val | Scalar value of the database table field. |
See Alsofreemed::get_link_rec
freemed:: handler_breakpointSet breakpoint for handlers for a certain function Parameters$name | Name of handler (example: MainMenuNotify) | $params | Array of parameters to be passed to the associated handlers. None are passed by default. |
freemed:: itemlist_conditionsCreates an SQL “WHERE” clause based on search information provided by <freemed::display_itemlist>, as used by most of FreeMED’s modules. Parameters$where (optional) | Boolean value, whether a “WHERE” should be prepended to the returned query. Defaults to true. |
Returns$clause | SQL query “WHERE” clause |
freemed:: image_filenameResolves a stored document’s full path based on the qualifiers presented. Parameters$patient | Patient identifier | $record | Record identifier of the “images” table | $type | File type (usually “djvu”) | $img_store (optional) | Boolean, whether or not the relative pathname will be prepended (usually “img/store/”). |
ReturnsThe relative path and file name of the image.
freemed:: key_bindingSet key binding for a particular key or set of keys. Parameters$binding | Associative array of key code => binding. |
freemed:: module_checkDetermines whether a module is installed in the system, and optionally whether it is above a certain minimum versioning number. Parameters$module | Name of the module | $minimum_version (optional) | The minimum allowable version of the specified module. If this is not specified, any version will return true. |
Returns$installed | Boolean, whether the module is installed |
freemed:: module_check_aclCheck to see if module is allowable via ACLs Parameters$module | Module class name | $permission | Permission type (view, add, mod, et cetera) |
ReturnsBoolean value, true or false
freemed:: module_get_valueGets a cached module value (such as “MODULE_NAME”, etc) from the module cache. Parameters$module | Name of the module | $key | Variable name in question |
Returns$val | Value of the variable name in question |
See Alsofreemed::module_get_meta
freemed:: module_get_metaGets cached metainformation for the specified module in the module cache. Acts as a wrapper for freemed::module_get_value. Parameters$module | Name of the module | $key | Hash index of the metainformation in question |
Returns$val | Value of the metainformation in question |
See Alsofreemed::module_get_value
freemed:: module_cacheProvides global access to a PHP.module_list object with cached module information. Returns$cache | An object (PHP.module_list) containing the cached module information. |
freemed:: module_handlerReturns the list of modules associated with a certain handler. Parameters$handler | Scalar name of the handler. This is case sensitive. |
Returns$modules | Array of modules which are associated with the specified handler. These all will be in lowercase, so remember to use strtolower(). |
freemed:: module_lookupLookup the module name as needed by FreeMED’s module calls, but by the class name of the module. Parameters$class | Class name of the module |
Returns$module | MODULE_NAME of the specified module. |
freemed:: module_registerRegisters module or newer version of module in FreeMED’s global module registry. Parameters$module | Name of module (must be resolved using freemed::module_lookup, or by using MODULE_NAME). | $version | Version of module to register. |
freemed:: module_tablesGet list of tables for modules. Returnsi18n’d associative array
freemed:: module_to_tableGet table name from module name. Parameters$module | Module name (class name) |
ReturnsSQL table name
freemed:: module_versionGet the current version number of a particular module in FreeMED from the module database table. Parameters$module | Name of module (must be resolved using freemed::module_lookup, or by using MODULE_NAME). |
freemed:: multiple_choiceCreate a multiple-choice widget Parameters$sql_query $display_field | Hash of the field display format, with ‘##’ surrounding the members of the table. (For example: ‘##phylname##, ##phyfname##’ from a query on the physician table would print their last name and first name separated by a comma.) | $select_name | Name of the variable that the widget is specifying. | $blob_data | The actual compressed data string which contains the array of values. |
$display_all (optional) ReturnsXHTML-compliant multiple choice widget code.
freemed:: patient_boxCreate a “patient box” with quick access to various patient functions. Parameters$patient_object | An object of type ‘FreeMED.Patient’ which encapsulates the selected patient’s data. |
ReturnsXHTML compliant patient box widget code.
freemed:: patient_widgetCreate a patient selection widget Parameters$varname | The name of the variable that this widget contains data for. | $formname (optional) | Name of the form that this widget is contained in. Defaults to “myform”. | $submitname (optional) | The name of the submit button which is passed to the child window that is created. Defaults to “submit_action”. | $autosubmit | (optional) Whether or not to submit on click. Boolean, defaults to false. |
ReturnsXHTML compliant patient selection widget code.
freemed:: printers_widgetCreate XHTML widget to represent printer selection Parameters$varname | Name of the variable which will hold the data returned by this widget |
ReturnsXHTML compliant widget code
freemed:: query_to_arrayDumps the output of an SQL query to a multidimentional hashed array. Parameters$query | Text SQL query | $single_dimension | (optional) Reduce to single array, using k and v table columns as key and value. Defaults to true. |
ReturnsMultidimentional hashed array.
freemed:: quickform_i18nPerform internationalization (i18n) on an HTML_QuickForm PEAR object. Parameters
freemed:: race_widgetCreate HL7 v2.3.1 compliant race widget (table 0005) Parameters$varname | Name of the variable which contains this data. |
Returns$widget | XHTML compliant race widget code. |
freemed:: rich_text_areaCreates a rich text editing widget (HTML) Parameters$varname | Name of variable to store the data in | $rows | (optional) Vertical size of text area. Defaults to 10 lines. | $cols | (optional) Horizontal size of text area. Defaults to 60 characters. | $force_js | (optional) Force Javascript to be displayed every time. Defaults to false. |
ReturnsXHTML-compliant rich text area widget
freemed:: secure_filenameRemove potentially hazardous characters from filenames Parameters$original | Original filename |
Returns$sanitized | Sanitized filename |
freemed:: sql2dateConvert an SQL timestamp (such as MySQL timestamps) into a nice-looking date string. Parameters$date | SQL timestamp string |
ReturnsFormatted date/time string
freemed:: store_imageStores posted file in scanned document image store. Parameters$patient_id | Patient identifier from the patient table. Do not pass a patient object. | $varname | The variable name describing the file that was posted using the HTTP POST method. | $type | (optional) This is either ‘identification’ in the case of an identifying photograph, or the record number of this document in the scanned documents table | $encoding | (optional) Type of DjVu encoding. Currently ‘cjb2’ and ‘c44’ encodings are supported. |
ReturnsName of file if successful.
freemed:: support_djvuDetermines whether the current browser supports DjVu. Parameters$browser | PHP.browser_detect object. |
ReturnsBoolean, whether DjVu is supported or not.
freemed:: template_fileResolve file to existing either in default template or current template. Parameters$file | Filename, relative to the template structure (login_form.php would resolve to lib/template/*/login_form.php) |
ReturnsFully qualified template path (lib/template/*/*)
freemed:: user_flagDetermine if a particular user flag is set for the current user. Parameters$flag | The flag in question. This should be something like USER_ADMIN, USER_DELETE, etc. |
ReturnsTrue if the flag is set for the current user.
freemed:: lock_overrideDetermine if the current user has the ability to “override” the locking of a record. ReturnsBoolean value, whether or not the user has override permissions.
freemed:: log_objectGet log object with caching. ReturnsFreeMED.Log object
freemed:: phone_displayDisplays phone number in system format. ParametersReturnsFormatted phone number for display
freemed_alternatefunction freemed_alternate ( | $_elements | ) |
|
Create alternating texts. Used mostly for alternating row displays, either as CLASS tags or as BGCOLOR tags. Parameters$elements | Array of elements which are to be alternated between. Defaults to array (‘cell’, ‘cell_alt’). |
ReturnsThe next element in the circular loop of the presented array.
freemed_display_actionbarfunction freemed_display_actionbar ( | $this_page_name | = | "", | | $__ref | = | "" | ) |
|
Creates the ADD/RETURN TO MENU bar present in most FreeMED modules. Parameters$page_name | (optional) Name of the current page. | $ref | (optional) Name of the referring page. If this is not explicitly set, the global variable ‘_ref’ acts as the default value. |
ReturnsXHTML compliant actionbar widget.
freemed_display_itemlistfunction freemed_display_itemlist ( | $result, | | | | $page_link, | | | | $control_list, | | | | $blank_list, | | | | $xref_list | = | "", | | $cur_page_var | = | "this_page", | | $index_field | = | "", | | $flags | = | -1 | ) |
|
Creates a paginated list display based on formatting data for a particular result set. This should be used in conjunction with freemed::itemlist_conditions to produce a proper SQL query. Parameters$result | SQL query passed to the display. | $page_link | Current page name. | $control_list | List of column names and database table column names, as an associative array. (Example: array ( __(“Date”) => ‘procdt’, __(“Procedure Code”) => ‘proccpt’ ) ) | $blank_list | Array of values for the columns describing what a blank entry should be displayed as. | $xref_list | (optional) Associative array describing cross table references. For example, if your column ‘proccpt’ described a CPT code, you could use ‘cpt’ => ‘cptcode’ to describe the table name (‘cpt’) and the column to be displayed name (‘cptcode’), which would be determined by the value of the corresponding column in $control_list. | $cur_page_var | (optional) Pagination tracking variable. The default is ‘this_page’. | $index_field | (optional) Currently this is unused, and should be passed as ‘’ or NULL. | $flags | (optional) Bitfield of operators, such as ITEMLIST_MOD | ITEMLIST_DEL. |
ReturnsXHTML compliant item listing with search widgets.
freemed_display_facilitiesfunction freemed_display_facilities ( | $param | = | "", | | $default_load | = | false, | | $intext | = | "", | | $by_array | = | "" | ) |
|
Creates an XHTML facility selection widget. Parameters$varname | Name of the global variable containing the data for this widget. | $default_load | (optional) Depreciated. | $internal_external | (optional) Exclusively internal or external facilities. If this is passed at all, “0” selects internal facilities and “1” selects external facilities. | $by_array | (optional) Array of facility id numbers to limit the selection to. |
ReturnsXHTML compliant facility selection widget.
freemed_display_selectboxfunction freemed_display_selectbox ( | $result, | | | | $format, | | | | $param | = | "", | | $size | = | "" | ) |
|
Create an XHTML selection box Parameters$result | SQL query result | $format | Format hash for the display box (result field names surrounded by ‘##’s) | $varname | Name of the variable to store the selected data in. | $size | (optional) Size of the box. Defaults to default size. |
ReturnsXHTML compliant selection widget.
freemed_export_stock_datafunction freemed_export_stock_data ( | $table_name, | | | | $file_name | = | "" | ) |
|
Export FreeMED database table to a file Parameters$table_name | Name of the SQL table to export |
freemed_import_stock_datafunction freemed_import_stock_data ( | $table_name | ) |
|
Import an SQL table into FreeMED Parameters$table_name | Name of the SQL table to import |
freemed_get_date_nextfunction freemed_get_date_next ( | $cur_dt | ) |
|
Get next valid SQL format date (YYYY-MM-DD) ParametersReturnsNext date.
freemed_get_date_prevfunction freemed_get_date_prev ( | $cur_dt | ) |
|
Get previous date in SQL format (YYYY-MM-DD) ParametersReturnsPrevious date.
fm_date_assemblefunction fm_date_assemble ( | $datevarname | = | "", | | $array_index | = | -1 | ) |
|
Assemble seperate date fields into single SQL format date hash Parameters$varname | Name of the date variable | $array_index | (optional) Array index of $varname that should contain the result data. |
ReturnsSQL formated date string.
fm_date_entryfunction fm_date_entry ( | $datevarname | = | "", | | $pre_epoch | = | false, | | $arrayvalue | = | -1 | ) |
|
Creates XHTML-compliant date selection widget Parameters$varname | Variable name to contain the result data. | $pre_epoch | (optional) Whether the date selection widget should contain years more than 20 in the past. Defaults to false. | $array_index | (optional) Array index for varname to determine which element of the array is being used. Defaults to no array index. |
ReturnsXHTML-compliant date selection widget.
fm_date_printfunction fm_date_print ( | $actualdate, | | | | $show_text_days | = | false | ) |
|
Create a nicely formatted date display Parameters$date | SQL formated date | $show_text_days | (optional) Whether or not to show the day names as text names. Defaults to false. |
ReturnsFormatted date display.
fm_htmlize_arrayfunction fm_htmlize_array ( | $variable_name, | | $cur_array | ) |
|
Convert array to XHTML input type=HIDDEN tags Parameters$varname | Variable name to put the data in | $cur_array | Actual data to be stored |
ReturnsXHTML input type=HIDDEN tags
fm_number_selectfunction fm_number_select ( | $varname, | | | | $min | = | 0, | | $max | = | 10, | | $step | = | 1, | | $addz | = | false, | | $submit_on_blur | = | false | ) |
|
Create an XHTML compliant number selection widget Parameters$varname | Name of the variable to store this data in | $min | (optional) Minimum value. Defaults to 0. | $max | (optional) Maximum value. Defaults to 10. | $step | (optional) Incrementing value. Defaults to 1. | $add_zero | (optional) Prepend zeros to values under 10. Defaults to false. | $submit_on_blur | (optional) Submit the form when focus on the widget is lost. Defaults to false. |
ReturnsXHTML-compliant number selection widget
template_displayfunction template_display ( | $terminate_on_execute | = | true | ) |
|
Display the current template Parameters$terminate | (optional) End script execution on termination of function. Defaults to true. |
page_pushPush page onto global history stack.
page_popPop off page from global history stack.
patient_pushfunction patient_push ( | $patient | ) |
|
Push patient onto global history stack.
patient_history_listfunction patient_history_list () |
Get global history list for patients ReturnsArray of patients in global history list.
page_history_listfunction page_history_list () |
Get global history list for pages ReturnsArray of pages in global history list.
help_urlfunction help_url ( | $page | = | "", | | $section | = | "" | ) |
|
Contruct a help link from the specified page and section Parameters$page | (optional) Name of the page that this relates to. | $section | (optional) Subsection of the page. |
ReturnsFully formed URL to the specified help page.
check_basic_authenticationfunction check_basic_authentication () |
Check current basic authentication against users in the database. This function is broken until phpwebtools is upgraded to support MD5-based basic authentication verification. ReturnsBoolean value, whether user is properly authenticated.
|