2 // ------------------------------------------------------------------------ //
3 // Garden State Health Systems //
4 // Copyright (c) 2010 gshsys.com //
5 // <http://www.gshsys.com/> //
6 // ------------------------------------------------------------------------ //
7 // This program is free software; you can redistribute it and/or modify //
8 // it under the terms of the GNU General Public License as published by //
9 // the Free Software Foundation; either version 2 of the License, or //
10 // (at your option) any later version. //
12 // You may not change or alter any portion of this comment or credits //
13 // of supporting developers from this source code or any supporting //
14 // source code which is considered copyrighted (c) material of the //
15 // original comment or credit authors. //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details. //
22 // You should have received a copy of the GNU General Public License //
23 // along with this program; if not, write to the Free Software //
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
25 // ------------------------------------------------------------------------ //
27 function getHeaderData() {
29 // Reserved for future use
33 function getMedicationData() {
37 SELECT prescriptions.date_added ,
38 prescriptions.patient_id,
39 prescriptions.start_date,
40 prescriptions.quantity,
41 prescriptions.interval,
44 prescriptions.medication,
46 prescriptions.provider_id,
50 LEFT JOIN list_options AS lo
51 ON lo.list_id = 'drug_units' AND prescriptions.unit = lo.option_id
52 WHERE prescriptions.patient_id = ?";
54 $result = sqlStatement($sql, array($pid) );
58 function getImmunizationData() {
61 $sql = " SELECT immunizations.administered_date,
62 immunizations.patient_id,
63 immunizations.vis_date,
65 immunizations.immunization_id,
66 immunizations.manufacturer,
68 FROM immunizations , list_options
69 WHERE immunizations.immunization_id = list_options.option_id and immunizations.patient_id = ? and list_id = 'immunizations' " ;
71 $result = sqlStatement($sql, array($pid) );
76 function getProcedureData() {
82 lists.title as proc_title,
84 list_options.title as outcome,
88 lists.diagnosis as `code`,
89 IF(SUBSTRING(lists.diagnosis,1,LOCATE(':',lists.diagnosis)-1) = 'ICD9','ICD9-CM',SUBSTRING(lists.diagnosis,1,LOCATE(':',lists.diagnosis)-1)) AS coding
92 LEFT JOIN issue_encounter
93 ON issue_encounter.list_id = lists.id
94 LEFT JOIN form_encounter
95 ON form_encounter.encounter = issue_encounter.encounter
97 ON form_encounter.facility_id = facility.id
99 ON form_encounter.provider_id = users.id
100 LEFT JOIN list_options
101 ON lists.outcome = list_options.option_id
102 AND list_options.list_id = 'outcome'
103 WHERE lists.type = 'surgery'
107 pt.name as proc_title,
110 ptt.laterality as laterality,
111 ptt.body_site as body_site,
112 'Lab Order' as `type`,
113 ptt.standard_code as `code`,
114 IF(SUBSTRING(ptt.standard_code,1,LOCATE(':',ptt.standard_code)-1) = 'ICD9','ICD9-CM',SUBSTRING(ptt.standard_code,1,LOCATE(':',ptt.standard_code)-1)) AS coding
116 procedure_result AS prs
117 LEFT JOIN procedure_report AS prp
118 ON prs.procedure_report_id = prp.procedure_report_id
119 LEFT JOIN procedure_order AS po
120 ON prp.procedure_order_id = po.procedure_order_id
121 LEFT JOIN procedure_type AS pt
122 ON prs.procedure_type_id = pt.procedure_type_id
123 LEFT JOIN procedure_type AS ptt
124 ON pt.parent = ptt.procedure_type_id
125 AND ptt.procedure_type = 'ord'
126 LEFT JOIN list_options AS lo
127 ON lo.list_id = 'proc_unit'
128 AND pt.units = lo.option_id
129 WHERE po.patient_id = ? ";
131 $result = sqlStatement($sql, array($pid,$pid) );
136 function getProblemData() {
141 select fe.encounter, fe.reason, fe.provider_id, u.title, u.fname, u.lname,
142 fe.facility_id, f.street, f.city, f.state, ie.list_id, l.pid, l.title as prob_title, l.diagnosis,
143 l.outcome, l.groupname, l.begdate, l.enddate, l.type, l.comments , l.date, cd.code_text
145 left join issue_encounter as ie
147 left join form_encounter as fe
148 on fe.encounter = ie.encounter
149 left join facility as f
150 on fe.facility_id = f.id
152 on fe.provider_id = u.id
153 left join codes as cd
154 on cd.code = SUBSTRING(l.diagnosis, LOCATE(':',l.diagnosis)+1)
155 where l.type = 'medical_problem' and l.pid=?";
157 $result = sqlStatement($sql, array($pid) );
162 function getAlertData() {
167 select fe.reason, fe.provider_id, fe.facility_id, fe.encounter,
168 ie.list_id, l.pid, l.title as alert_title, l.outcome,
169 l.groupname, l.begdate, l.enddate, l.type, l.diagnosis, l.date ,
170 l.reaction , l.comments ,
171 f.street, f.city, f.state, u.title, u.fname, u.lname, cd.code_text
173 left join issue_encounter as ie
175 left join form_encounter as fe
176 on fe.encounter = ie.encounter
177 left join facility as f
178 on fe.facility_id = f.id
180 on fe.provider_id = u.id
181 left join codes as cd
182 on cd.code = SUBSTRING(l.diagnosis, LOCATE(':',l.diagnosis)+1)
183 where l.type = 'allergy' and l.pid=?";
185 $result = sqlStatement($sql, array($pid) );
190 function getResultData() {
196 prs.procedure_result_id as `pid`,
198 pt.procedure_type_id as `type`,
200 concat_ws(' ',prs.result,lo.title) as `result`,
201 prs.range as `range`,
202 prs.abnormal as `abnormal`,
203 prs.comments as `comments`,
206 procedure_result AS prs
207 LEFT JOIN procedure_report AS prp
208 ON prs.procedure_report_id = prp.procedure_report_id
209 LEFT JOIN procedure_order AS po
210 ON prp.procedure_order_id = po.procedure_order_id
211 LEFT JOIN procedure_type AS pt
212 ON prs.procedure_type_id = pt.procedure_type_id
213 LEFT JOIN procedure_type AS ptt
214 ON pt.parent = ptt.procedure_type_id
215 AND ptt.procedure_type = 'ord'
216 LEFT JOIN list_options AS lo
217 ON lo.list_id = 'proc_unit' AND pt.units = lo.option_id
218 WHERE po.patient_id=?";
220 $result = sqlStatement($sql, array($pid) );
225 function getActorData() {
229 select fname, lname, DOB, sex, pid, street, city, state, postal_code, phone_contact
233 $result[0] = sqlStatement($sql, array($pid) );
236 SELECT * FROM users AS u LEFT JOIN facility AS f ON u.facility_id = f.id WHERE u.id=?";
238 $result[1] = sqlStatement($sql2, array($_SESSION['authUserID']) );
245 LEFT JOIN procedure_order AS po
246 ON po.procedure_type_id = pt.procedure_type_id
248 ON f.form_id = po.procedure_order_id
249 LEFT JOIN list_options AS lo
250 ON lo.title = f.form_name
254 AND lo.list_id = 'proc_type'
255 AND lo.option_id = 'ord'
258 $result[2] = sqlStatement($sql3, array($pid) );
264 function getReportFilename() {
268 select fname, lname, pid
272 $result = sqlQuery($sql, array($pid) );
273 $result_filename = $result['lname']."-".$result['fname']."-".$result['pid']."-".date("mdY",time());
275 return $result_filename;