1 ********** internal backend functions **********
3 ----- library/auth.inc ------
5 NOTICE: Please note that this Backend Spec is a development document, and was used during the developmental stages of OpenEMR. It was last updated for OpenEMR version 1.3, and therefore does not completely detail all of the newer library functions.
7 --------------------------------------------------------
9 we will ALWAYS look for $_GET['auth'], if it is login we will do so, if it is logout we will do so. all our post vars must be set to have a chance getting in. auth.inc should ALWAYS BE CALLED ABSOLUTELY FIRST.
11 authNewSession(username, md5sum of password, provider)
12 returns boolean, is pass checks out or not. if true, also sets:
13 $_SESSION['authUser'] = current username logged in
14 $_SESSION['authPass'] = md5sum of logged in users password
15 $_SESSION['authProvider'] = the current provider
16 $_SESSION['authId'] = user Id number (record id)
19 returns boolean for whether current cookie checks out
22 returns nothing, runs a session_destroy
25 returns nothing. includes js file, then login.inc, and die()
27 addUser(username, password, info, authorized w/ default yes)
28 adds a user to the system with the given credentials
29 returns the unique ID of the user with the given information
30 password is an MD5 hash
33 deletes the user with the given ID from the system
35 changePassword(id, password)
36 changes the password of the user with the given id to password
37 password is an MD5 hash
39 getUserList(cols w/default *, limit w/default all, start w/default 0)
40 returns a nested array of the user information specified in cols
42 getProviderList(cols w/default *, limit w/ default all, start w/ default
44 return a nested array of cols from the groups table
47 add a new group name to the system
48 returns the ID of the group
51 deletes the group from the system
53 ----- library/sql.inc - Matthew Beale, Ted Dziuba -----
54 we will ALWAYS create a connection to sql, and set $GLOBALS['dbh'] to our database connection.
57 returns a database handle, connected to localhost, user openemr, db openemr
59 sqlStatement(statement)
60 returns the query result resource.
63 returns whatever mysql_close returns.
66 returns the last inserted id after running your insert.
68 sqlFetchArray(mysql query result resource)
69 returns the current mysql_fetch_array result.
72 returns the first result from the database.
75 ********** public backend functions **********
77 ----- library/lists.inc - Matthew Beale -----
78 used for accessing openemr.lists in the db, we require_once('sql.inc')
80 getListById(id, columns - default all)
81 returns the first record returned, the most recent (although there _should_ only be one.
83 getListByType(patient id, type, wanted columns w/ deafult all, active - default 'all', limit default "all", offset default "0")
84 returns a multi-dimensional array or record lines returned.
86 addList(patient id, entry type, title, comments, activity state w/ default active)
87 returns the id generated by the insert
95 ----- library/transactions.inc - Matt Koch, Matthew Beale ------
96 used for accessing openemr.transactions in the db, we require_once('sql.inc')
98 getTransById(id, columns - default all)
99 returns the first record returned, the most recent (although there _should_ only be one.
101 getTransByPid(patient id, columns w/ default all)
102 returns a multi-dimensional array or record lines returned.
104 newTransaction(patient id, body text, title, authorized w/ default "0")
105 returns id of inserted record
107 authorizeTransaction(id, authorized w/ default '1')
108 returns useless data. if you want it to return something let us know.
110 ----- library/pnotes.inc - Matt Koch, Matthew Beale -----
111 used for accessing openemr.pnotes in the db, we require_once('sql.inc')
113 getByPnoteId(id, columns - default all)
114 returns the first record returned, the most recent (although there _should_ only be one.
116 getPnotesByDate(date, activity w/ default "1", columns w/ default "*", patient id - default "%", limit w/ default "all", start w/ default 0)
117 returns a multi-dimensional array or record lines returned.
119 getPnotesByPid(patient id, activity w/ default "1", columns w/ default all, limit - 10, start - 0)
120 returns a multi-dimensional array or record lines returned.
122 addPnote(patient id, body text, authorized w/ default "0", activity w/ default "1")
123 returns the id of the insert.
125 authorizePnote(id, authorize w/ default "1")
126 returns useless data. if you want it to return something let us know.
134 ----- library/onotes.inc - Ted Dziuba, Matthew Beale -----
135 used for accessing openemr.onotes, we require('sql.inc')
137 getOnoteById(id, cols wanted w/default all)
138 returns the first record returned, the most recent
140 getOnoteByDate(date, activity w/ default "1" (can take 0, 1, or all), cols wanted w/default all,limit - "all", offset w/ default "0")
141 returns a multi-dimensional array or record of lines returned
143 addOnote(body text, $activity w/ default "1")
144 returns the id you just generated, dont you feel lucky.
152 ----- library/forms.inc - Ted Dziuba, Matthew Koch -----
154 getFormById(id, cols - "*")
155 returns form with specified id
157 getFormsByPID (pid, columns w/ default all)
158 returns form with specified PID
160 getFormByEncounter(pid, encounter, columns w/ default "form_id, form_name")
161 return forms matching encounter in multi-dimensional array
163 addForm(encounter, form_name, form_id, formdir, pid, authorized w/ default "0")
164 adds form with specified values, returns id
166 authorizeForm(id, authorize w/ default "1")
167 returns useless data. if you want it to return something let us know.
169 function getEncounters($pid)
170 returns array of all encounters filed under a given pid, in order by date descending
172 ----- library/billing.inc - Matthew Beale, Ted Dziuba -----
174 getBillingById(id, cols w/ default all)
175 returns billing record from id
177 getBillingByPid(pid, columns w/ default all)
178 returns billing record from pid
180 getBillingByEncounter(pid,encounter id, columns w/ defaults "code_type, code, code_text")
181 return billings matching encounter in multi-dimensional array
183 addBilling(encounter, code_type, code, $code_text, pid, authorized w/ default "0")
184 adds billing entry with values, returns id
186 authorizeBilling(id, authorize w/ default "1")
187 returns useless data. if you want it to return something let us know
189 function deleteBilling($id)
190 makes a billing entry not active - misnomer - does not actually delete it, but makes it invisible to interface
191 ----- library/log.inc - Matthew Beale, Ted Dziuba -----
193 newEvent(event(login||logout||backup||view), user, groupname, comment w/ default "")
194 return id generated in insert
196 getEventByDate($date, $cols w/ default all)
197 returns nested array of results
200 ----- library/patient.inc - Matthew Beale, Ted Dziuba -----
203 getPatientById(id, cols w/default *, type w/ default "primary") << "table_name_col_name, table2_name_col2_name"
204 return array of patient information in cols of the patient with pid id
207 getPatientByLname(lname, cols w/default *, type w/ default "primary") << as above
208 return array of patient information in cols of the patient with lname
211 getPatients(cols w/default "patient_data_name, patient_data_fname, patient_data_lname")
212 returns nested array of said values.
214 newPatientData( $title, //all default "" unless specified
230 $contact_relationship,
231 $pid w/ default "MAX(pid)+1"
233 returns generated pid, new or old.
235 function newEmployerData( $pid,
236 $name, //all default "" unless specified
245 function newInsuranceData( $pid,
246 $type, //all default "" unless specified
251 $subscriber_relationship,
255 $subscriber_postal_code,
259 $subscriber_employer,
260 $subscriber_employer_street,
261 $subscriber_employer_postal_code,
262 $subscriber_employer_state,
263 $subscriber_employer_country,
268 function newHistoryData( $pid,
269 $coffee, //all default "" unless specified
276 $hazardous_activities,
279 $last_gynocological_exam,
283 $last_sigmoidoscopy_colonoscopy,
290 $relatives_tuberculosis,
292 $relatives_high_blood_pressite,
293 $relatives_heart_problems,
296 $relatives_mental_illness,
309 updatePatientData(pid, array of new datas:
310 $passed['colname'] = "value string"
313 updateInsuranceData(pid, array of new datas:
314 $passed['colname'] = "value string"
317 updateEmployerData(pid, array of new datas:
318 $passed['colname'] = "value string"
321 updateHistoryData(pid, array of new datas:
322 $passed['colname'] = "value string"
325 getPatientData(pid, cols w/ default *)
326 returns array of cols specified by given with pid id
328 getHistoryData(pid, cols w/ default *)
329 returns array of cols specified by given with pid id
331 getInsuranceData(pid, type w/ default primary, cols w/ default *)
332 return array of cols specified by given from patient with pid id and type primary or secondary
334 getEmployerData(pid, cols w/ default *)
335 return array of cols specified by given of patient with pid id
337 getPatientLnames(lname, cols w/default = "pid, lname, fname, mname, id", orderby w/ default "lname ASC", limit w/ default "all", start w/ default "0")
338 return array of cols specified by given of patients with last name lname
340 getPatientIds(cols w/ default "pid, id, lname, fname, mname", orderby w/ default "id ASC", limit w/ default "all", start w/ default "0")
341 returns array of cols specified by cols of all unique pids
343 ----- library/report.inc - Matthew Beale -----
345 getPatientReport(pid)
346 returns nested array of column name containing 'content' at time of change and 'date'
348 getEmployeeReport(pid)
349 returns nested array of column name containing 'content' at time of change and 'date'
351 getHistoryReport(pid)
352 returns nested array of column name containing 'content' at time of change and 'date
354 getInsuranceReport(pid, type)
355 returns nested array of column name containing 'content' at time of change and 'date
358 ----- library/encounter.inc - Matthew Stack -----
360 function setencounter(encounter)
361 set the global encounter session variable - if encounter is "", then it creates an entry in the forms table to represent a blank encounter
363 ----- library/pid.inc - Matthew Stack -----
366 set the global pid session variable