The new changes helps serve two important aspects
[openemr.git] / myportal / soap_service / server_oemruser.php
blob1992f43d5dc422bfebfe18a82c8f9a944c8a369e
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 //
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Jacob T Paul <jacob@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 //SANITIZE ALL ESCAPES
29 $sanitize_all_escapes=true;
32 //STOP FAKE REGISTER GLOBALS
33 $fake_register_globals=false;
36 class OEMRUser{
38 //this will return the query string along with the parameter array, according to the case case.
39 //actual execution is done in the select_query function in Server_side
41 private function getPid($id){
42 $row = sqlQuery("SELECT pid FROM audit_master WHERE id=? AND approval_status=1",array($id));
43 return $row['pid'];
46 public function query_formation($data){
47 global $pid;
48 switch($data[0]){
49 case 'U1':
50 $query="select * from audit_master where approval_status='1' and (type='1' or type='2' or type='3') ";
51 return array($query);
52 break;
54 case 'U2':
55 $query=" select * from audit_master where approval_status='1' and (type='1' or type='2' or type='3') order by id limit ?,1";
56 return array($query,array($data[1][0]-1));
57 break;
59 case 'U3':
60 $pid = $this->getPid($data[1]);
61 $query="SELECT * FROM documents_legal_master AS dlm " .
62 "LEFT OUTER JOIN documents_legal_detail as dld ON dlm_document_id=dld_master_docid WHERE " .
63 " dlm_subcategory not in (SELECT dlc_id FROM `documents_legal_categories` where dlc_category_name='Layout Signed'".
64 " and dlc_category_type=2) and dlm_effective_date <= now() AND dlm_effective_date<>'0000-00-00 00:00:00' " .
65 "AND dld_id IS NOT NULL AND dld_pid=? and dld_signed='0' " .
66 "ORDER BY dlm_effective_date DESC";
67 return array($query,array($pid));
68 break;
70 // Entries pending for approval for Existing Patient and New Patient.
71 case 'U4':
72 $pid = $this->getPid($data[1]);
73 $query= "select * from audit_master where pid=? and approval_status='1' and (type='1' or type='2')";
74 return array($query,array($pid));
75 break;
77 // Entries pending for approval for documents only (no demo change).
78 case 'U5':
79 $pid = $this->getPid($data[1]);
80 $query = " select * from audit_master where pid=? and approval_status='1' and type='3' ";
81 return array($query,array($pid));
82 break;
84 case 'P1':
85 $query= "select MAX(pid)+1 AS pid from patient_data ";
87 return array($query);
88 break;
90 //for building patient Demo
91 case 'P2':
92 $query="select * from layout_options " .
93 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
94 "ORDER BY group_name, seq";
95 return array($query);
96 break;
98 //for building patient Demo Date of Birth
99 case 'P3':
100 $pid = $this->getPid($data[1]);
101 $query="select *, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD from patient_data where pid=? order by date DESC limit 0,1 ";
102 return array($query,array($pid));
103 break;
105 //for building patient Demo Employer Data
106 case 'P4':
107 $pid = $this->getPid($data[1]);
108 $query="select * from employer_data where pid=? order by date DESC limit 0,1 ";
109 return array($query,array($pid));
110 break;
112 //for building patient Demo Insurance company details for Patient
113 case 'P5':
114 $data[1][0] = $this->getPid($data[1][0]);
115 $query=" select insd.*, ic.name as provider_name from insurance_data as insd " .
116 "left join insurance_companies as ic on ic.id = insd.provider " .
117 "where pid = ? and type =? order by date DESC limit 1 ";
118 return array($query,$data[1]);
119 break;
121 // Entries pending for approval demo and documents.
122 case 'P6':
123 $pid = $this->getPid($data[1]);
124 $query=" select * from audit_master as am,audit_details as ad WHERE am.id=ad.audit_master_id and am.pid=? and am.approval_status='1'
125 and (am.type='1' or am.type='2' or am.type='3') order by ad.id";
126 return array($query,array($pid));
127 break;
128 // Demo building from layout options.
130 case 'P7':
131 $query=" select * from layout_options WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
132 " ORDER BY group_name, seq";
133 return array($query);
134 break;
136 //Global specific application for building demo.
137 case 'P8':
138 $query="select * from globals where gl_name ='specific_application' ";
139 return array($query);
140 break;
142 //Global omit employers for building demo.
143 case 'P9':
144 $query=" select * from globals where gl_name ='omit_employers' ";
145 return array($query);
146 break;
148 case 'B13':
149 //patient appointment
150 $query="select * from facility where service_location != 0 order by name";
151 return array($query);
152 break;
154 case 'E1':
155 //list of approvals
156 $query="select *,audit_master.id as audit_master_id from audit_master,patient_data where audit_master.pid=patient_data.pid and
157 audit_master.approval_status='1' order by audit_master.id";
158 return array($query);
159 break;
161 case 'E2':
162 //list of approvals
163 $query="select * from facility";
164 return array($query);
165 break;
167 case 'E3':
168 //list of approvals
169 $query="select id,fname,lname,mname from users where authorized=1";
170 return array($query);
171 break;
173 case 'E4':
174 //list of approvals
175 $query="select * from audit_master,patient_data,audit_details where audit_master.pid=patient_data.pid and
176 audit_master.approval_status='1' and audit_master.type = 10 and audit_master_id=audit_master.id order by audit_master.id";
177 return array($query);
178 break;
180 case 'E5':
181 //list of approvals
182 $query="select * from audit_master where audit_master.id=?";
183 $row = sqlQuery($query,$data[1]);
184 return array("SELECT * FROM documents_legal_detail join documents_legal_master on dld_master_docid=dlm_document_id WHERE dld_pid=? and dld_signed='0'
185 and dlm_document_id=dld_master_docid and dlm_subcategory not in (SELECT dlc_id FROM `documents_legal_categories`
186 where dlc_category_name='Layout Signed' and dlc_category_type=2)",array($row['pid']));
187 break;
189 case 'F4':
190 //signing
191 $query="select * from documents_legal_categories where dlc_category_name=? and dlc_category_type=2";
192 return array($query,$data[1]);
193 break;
195 case 'F5':
196 //signing
197 $query="select * from documents_legal_master LEFT OUTER JOIN documents_legal_categories ON dlm_category=dlc_id WHERE
198 dlm_subcategory <> ? and dlm_filename<>'' and dlm_upload_type = 0";
199 return array($query,$data[1]);
200 break;
202 case 'F8':
203 //signing
204 $pid = $this->getPid($data[1]);
205 $query="select * from audit_master where pid=? and approval_status='1' and (type='1' or type='2' or type='3')";
206 return array($query,array($pid));
207 break;
209 case 'F12':
210 //Selection from master document for showing to patient
211 $query="select * from documents_legal_master WHERE dlm_document_name=?";
212 return array($query,$data[1]);
213 break;
215 case 'payment_settings_all':
216 $query = "SELECT service_name,login_id,transaction_key,md5 FROM payment_gateway_details";
217 return array($query);
218 break;
220 case 'payment_gateways_list':
221 $query = "SELECT option_id, title FROM list_options WHERE list_id = 'payment_gateways' ORDER BY seq";
222 return array($query);
223 break;
225 case 'F13':
226 $query = "SELECT pid ,fname,lname,mname,DOB FROM patient_data
227 where fname like ? or lname like ? or mname like ? or
228 CONCAT(lname,' ',fname,' ',mname) like ? or pid like ? ORDER BY lname";
229 return array($query,array($data[1]."%",$data[1]."%",$data[1]."%",$data[1]."%",$data[1]."%"));