Difference between revisions of "The Forms API"
(missing pipe symbol.) |
|||
(61 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=== The Files That Make Up Your Form === | === The Files That Make Up Your Form === | ||
Forms written to use the | |||
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: | |||
{| class="wikitable" border="1" cellpadding="1" | {| class="wikitable" border="1" cellpadding="1" | ||
|- | |- | ||
Line 13: | Line 17: | ||
| view.php | | view.php | ||
| Draw a form with data in it, allowing users to edit. | | Draw a form with data in it, allowing users to edit. | ||
| selecting a form in an encounter, show.php | | selecting a form in an encounter, (optionally) show.php | ||
|- | |- | ||
| report.php | | report.php | ||
Line 21: | Line 25: | ||
| table.sql | | table.sql | ||
| Perform all of the SQL setup of the form (table creation, list insertion, etc) | | 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: | Forms written to use the encounters form API MAY provide the following files: | ||
Line 30: | Line 37: | ||
! Function | ! Function | ||
! Called by | ! 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.php | ||
| Save the | | Save the submitted form data to the database. | ||
| new.php and view.php | | new.php and view.php | ||
|- | |- | ||
Line 40: | Line 51: | ||
|- | |- | ||
| show.php | | show.php | ||
| Show a | | Show a the most recent (and optionally signed) form of this type(if applicable). | ||
| left_nav.php | | left_nav.php(with modifications) | ||
|} | |} | ||
=== | === PHP Files to Include === | ||
==== Core APIs ==== | |||
For information about including the core APIs and using their functionality, please see [[The OpenEMR API]]. | |||
===== 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. | |||
=== | ===== library/api.inc ===== | ||
This is the file defining the OpenEMR core APIs, including access controls, and the third party forms API. | |||
====== Form Functions ====== | |||
=== Functions | |||
{| class="wikitable" border="1" cellpadding="1" | {| class="wikitable" border="1" cellpadding="1" | ||
|- | |- | ||
! Function | ! Function | ||
! | ! Use | ||
! Returns | ! Returns | ||
|- | |- | ||
| formFetch | | formFetch | ||
| retrieve encounter based form contents from the sql engine | | retrieve encounter based form contents from the sql engine | ||
| results of mysql_fetch_array | | results of mysql_fetch_array | ||
|- | |- | ||
| formSubmit | | formSubmit | ||
| save encounter based form contents to the sql engine | | save encounter based form contents to the sql engine | ||
|- | |- | ||
| 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 ==== | |||
This file contains functions for rendering form objects. | |||
===== Functions ===== | |||
* generate_form_field() | |||
==== library/forms.inc ==== | |||
forms.inc contains the 'addForm' function, for linking a form into an encounter. | |||
=== Files commonly referenced in HTML output === | === Files commonly referenced in HTML output === | ||
Line 210: | Line 144: | ||
|- | |- | ||
| formFooter | | formFooter | ||
| | |||
| display a form footer | | display a form footer | ||
|} | |} | ||
[[Category:Developer Guide]][[Category:Forms]] | |||
Latest revision as of 09:25, 8 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
Core APIs
For information about including the core APIs and using their functionality, please see The OpenEMR API.
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.
library/api.inc
This is the file defining the OpenEMR core APIs, including access controls, and the third party forms API.
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.php
This file contains functions for rendering form objects.
Functions
- generate_form_field()
library/forms.inc
forms.inc contains the 'addForm' function, for linking a form into an encounter.
Files commonly referenced in HTML output
Referenced | Used For |
---|---|
library/dialog.js | |
library/js/jquery.js | jquery |
library/textformat.js | |
$css_header | the css theme of the site |
../../forms/$form_folder/style.css | the css theme of this form |
library/dynarch_calendar.css | the css theme of calendar objects |
library/dynarch_calendar.js | calendar base code |
library/dynarch_calendar_en.js | english calendar code |
library/dynarch_calendar_setup.js |
Depreciated:
Function | From | Reason | Returns |
---|---|---|---|
formHeader | display a header for the form. | ||
html_header_show | library/translation.inc.php | NO-OP; depreciated | |
formFooter | display a form footer |