edihistory -- revisions and cleanup of 277 claim status functions
[openemr.git] / Documentation / OpenEMR_Backend_Spec.txt
blob805b483ed9f6d74c23a43fb45632f6f2b958b4c3
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)
18 authCheckSession()
19 returns boolean for whether current cookie checks out
21 authCloseSession()
22 returns nothing, runs a session_destroy
24 authLoginScreen()
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
32 delUser(id)
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
46 addGroup(groupname)
47 add a new group name to the system
48 returns the ID of the group
50 delGroup(groupname)
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.
56 sqlConnect()
57 returns a database handle, connected to localhost, user openemr, db openemr
59 sqlStatement(statement)
60 returns the query result resource.
62 sqlClose()
63 returns whatever mysql_close returns.
65 sqlInsert(statement)
66 returns the last inserted id after running your insert.
68 sqlFetchArray(mysql query result resource)
69 returns the current mysql_fetch_array result.
71 sqlQuery(statement)
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
89 disappearList (id)
90 returns true
92 reappearList (id)
93 returns true
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.
128 disappearPnote (id)
129 returns true
131 reappearPnote (id)
132 returns true
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.
146 disappearOnote (id)
147 returns true
149 reappearOnote (id)
150 returns true
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 -----
202 DEPRECATED
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
206 DEPRECATED
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
210 DEPRECATED
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
215                         $fname,
216                         $lname,
217                         $mname,
218                         $sex,
219                         $DOB,
220                         $street,
221                         $postal_code,
222                         $city,
223                         $state,
224                         $country_code,
225                         $ss,
226                         $occupation,
227                         $phone_home,
228                         $phone_biz,
229                         $phone_contact,
230                         $contact_relationship,
231                         $pid w/ default "MAX(pid)+1"
232                 )
233 returns generated pid, new or old.
235 function newEmployerData(       $pid,
236                                 $name, //all default "" unless specified
237                                 $street,
238                                 $postal_code,
239                                 $city,
240                                 $state,
241                                 $country
242                         )
243 returns generated id
245 function newInsuranceData(      $pid,
246                                 $type, //all default "" unless specified
247                                 $provider,
248                                 $policy_number,
249                                 $group_number,
250                                 $subscriber,
251                                 $subscriber_relationship,
252                                 $subscriber_ss,
253                                 $subscriber_DOB,
254                                 $subscriber_street,
255                                 $subscriber_postal_code,
256                                 $subscriber_city,
257                                 $subscriber_state,
258                                 $subscriber_country,
259                                 $subscriber_employer,
260                                 $subscriber_employer_street,
261                                 $subscriber_employer_postal_code,
262                                 $subscriber_employer_state,
263                                 $subscriber_employer_country,
264                                 $copay
265                         )
266 returns generated id
268 function newHistoryData(        $pid,
269                                 $coffee, //all default "" unless specified
270                                 $tobacco,
271                                 $alchohol,
272                                 $sleep_patterns,
273                                 $exercise_patterns,
274                                 $seatbelt_use,
275                                 $counseling,
276                                 $hazardous_activities,
277                                 $last_breast_exam,
278                                 $last_mammogram,
279                                 $last_gynocological_exam,
280                                 $last_rectal_exam,
281                                 $last_prostate_exam,
282                                 $last_phyiscal_exam,
283                                 $last_sigmoidoscopy_colonoscopy,
284                                 $history_mother,
285                                 $history_father,
286                                 $history_siblings,
287                                 $history_offspring,
288                                 $history_spouse,
289                                 $relatives_cancer,
290                                 $relatives_tuberculosis,
291                                 $relatives_diabetes,
292                                 $relatives_high_blood_pressite,
293                                 $relatives_heart_problems,
294                                 $relatives_stroke,
295                                 $relatives_epilepsy,
296                                 $relatives_mental_illness,
297                                 $relatives_suicide,
298                                 $cataract_surgery,
299                                 $tonsillectomy,
300                                 $appendectomy,
301                                 $cholecystestomy,
302                                 $heart_surgery,
303                                 $hysterectomy,
304                                 $hernia_repair,
305                                 $hip_replacement
306                                 )
307 returns id generated
309 updatePatientData(pid, array of new datas:
310         $passed['colname'] = "value string"
311 returns id generated
313 updateInsuranceData(pid, array of new datas:
314         $passed['colname'] = "value string"
315 returns id generated
317 updateEmployerData(pid, array of new datas:
318         $passed['colname'] = "value string"
319 returns id generated
320         
321 updateHistoryData(pid, array of new datas:
322         $passed['colname'] = "value string"
323 returns id generated
324         
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 -----
365 function setpid(pid)
366 set the global pid session variable