Difference between revisions of "The Forms API"
Bradymiller (talk | contribs) |
(seperate forms API from core APIs.) |
||
Line 129: | Line 129: | ||
==== library/api.inc ==== | ==== library/api.inc ==== | ||
This is the file defining the | This is the file defining the OpenEMR core APIs, including the third party forms API. | ||
for information about the core APIs, please see [[The OpenEMR API]]. | |||
The preferred method of including api.inc from your form is to use require_once. for instance: '''require_once($GLOBALS['srcdir'].'/api.inc');'''. | The preferred method of including api.inc from your form is to use require_once. for instance: '''require_once($GLOBALS['srcdir'].'/api.inc');'''. | ||
===== Functions ===== | |||
===== Form Functions ===== | |||
{| class="wikitable" border="1" cellpadding="1" | {| class="wikitable" border="1" cellpadding="1" | ||
|- | |- | ||
Line 148: | Line 151: | ||
| formJump | | formJump | ||
| redirect the browser to either the top of the current encounter, or an optional URL. | | redirect the browser to either the top of the current encounter, or an optional URL. | ||
} | |||
==== library/options.inc.php ==== | ==== library/options.inc.php ==== |
Revision as of 05:15, 6 December 2012
The Files That Make Up Your Form
In order to implement a form, you provide a series of files. These files are placed into a subdirectory of the interface/forms/ directory of your OpenEMR install.
Required Files
Forms written to use the Forms API MUST provide the following files:
Name | Function | Called by |
---|---|---|
new.php | Draw a form for users to input data into. | dropdown box on right hand of encounters page |
view.php | Draw a form with data in it, allowing users to edit. | selecting a form in an encounter, (optionally) show.php |
report.php | Draw part of a form displaying a simple 'report' of the form data. | encounters.php and the medical records report function |
table.sql | Perform all of the SQL setup of the form (table creation, list insertion, etc) | Executed by library/registry.inc's installSQL function, called when you hit the 'register' link for a form on the 'forms admin' page. |
Optional Files
Other files can exist in your form's directory to provide additional funcionality, EG, a printing function, or a non-encounter form, or just to contain common code used by multiple files in your forms. the following is a list of common file names, and their functions (by convention).
Forms written to use the encounters form API MAY provide the following files:
Name | Function | Called by |
---|---|---|
info.txt | A more user friendly name for your form. if present, displayed in forms admin page, and used as the name when referring to the form. | library/registry.inc and interface/forms_admin/forms_admin.php |
save.php | Save the submitted form data to the database. | new.php and view.php |
print.php | Print the current form, with the contents pulled from the database. | view.php |
show.php | Show a the most recent (and optionally signed) form of this type(if applicable). | left_nav.php(with modifications) |
PHP Files to Include
interface/globals.php
Including globals.php (which is required) brings in many variables which are useful for finding components of openemr, or for inheriting the look and feel of other openemr code.
The preferred method of including globals.php from your form is to use require_once to include, and dirname() to find the current location. For instance: require_once(dirname(__FILE__) . '/../../globals.php');.
Variables
Forms written to use the encounters form API MAY use the following variables after they have included global.php:
Variable | Used For | common value(s) or equivalance. |
---|---|---|
$GLOBALS['athletic_team'] | not false if we need to check squads. part of 'sports team' functionality. | True or False |
$GLOBALS['concurrent_layout'] | decide on target of back action in a form. | True or False |
$GLOBALS['encounter'] | the ID of the current encounter, or empty for none. | is_numeric() or "" |
$GLOBALS['fileroot'] | the path to the top of openemr in the filesystem. | /var/www/openemr/ |
$GLOBALS['phone_country_code'] | calendar code. | |
$GLOBALS['pid'] | The unique identifier of the current patient. | is_numeric(), or empty. |
$GLOBALS['srcdir'] | find files for inclusion. | /var/www/openemr/library/ |
$GLOBALS['style'] | ||
$GLOBALS['webroot'] | the path of the top of openemr, when generating URIs. | /openemr/ |
$css_header | include the global css stylesheet. | |
$tmore | the text string that should be the label next to the page name, on a show form page. |
The following variables are old, and depreciated.
Variable | Use | Reason for Depreciation |
---|---|---|
$top_bg_line | colour selection. | the same function can be accomplished by editing the global openemr CSS stylesheet. |
$srcdir | find includes. | replaced by $GLOBALS['srcdir'] |
library/api.inc
This is the file defining the OpenEMR core APIs, including the third party forms API.
for information about the core APIs, please see The OpenEMR API.
The preferred method of including api.inc from your form is to use require_once. for instance: require_once($GLOBALS['srcdir'].'/api.inc');.
Form Functions
Function | Use | Returns | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
formFetch | retrieve encounter based form contents from the sql engine | results of mysql_fetch_array | |||||||||||||||||||||||||||||||||||||||||
formSubmit | save encounter based form contents to the sql engine | ||||||||||||||||||||||||||||||||||||||||||
formJump | redirect the browser to either the top of the current encounter, or an optional URL.
} library/options.inc.phpThis file contains functions for rendering form objects. Functions
library/patient.inclibrary/forms.incforms.inc contains the 'addForm' function, for linking a form into an encounter. library/sql.inc
Files commonly referenced in HTML output
|