Cleaned up the logout script
[openemr.git] / library / freeb / BillingService.class.php
blob096046c58e58243a14115c231178b9daa048f2ad
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class BillingService Extends DataObjectBase {
7 function BillingService() {
8 $this->_addFunc("name", array( "name" => "FreeB.FBBillingService.Name",
9 "sig" => array(XMLRPCSTRING,XMLRPCINT),
10 "doc" => ""));
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBBillingService.StreetAddress",
12 "sig" => array(XMLRPCSTRING,XMLRPCINT),
13 "doc" => ""));
14 $this->_addFunc("city", array( "name" => "FreeB.FBBillingService.City",
15 "sig" => array(XMLRPCSTRING,XMLRPCINT),
16 "doc" => ""));
17 $this->_addFunc("state", array( "name" => "FreeB.FBBillingService.State",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBBillingService.Zipcode",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBBillingService.PhoneCountry",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBBillingService.PhoneExtension",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBBillingService.PhoneArea",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBBillingService.PhoneNumber",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("etin", array( "name" => "FreeB.FBBillingService.ETIN",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("tin", array( "name" => "FreeB.FBBillingService.TIN",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
44 function name($m) {
46 $err="";
48 $obj= $m->getparam(0);
49 $key = $obj->getval();
51 $sql = "SELECT * FROM facility where billing_location = '1'";
52 //echo $sql;
53 $db = $GLOBALS['adodb']['db'];
54 $results = $db->Execute($sql);
56 if (!$results) {
57 $err = $db->ErrorMsg();
59 else {
60 if (!$results->EOF) {
61 $retval = $results->fields['name'];
65 // if we generated an error, create an error return response
66 if ($err) {
67 return $this->_handleError($err);
69 else {
70 // otherwise, we create the right response
71 // with the state name
72 return new xmlrpcresp(new xmlrpcval($retval));
76 function streetaddress($m) {
78 $err="";
80 $obj= $m->getparam(0);
81 $key = $obj->getval();
83 $sql = "SELECT * FROM facility where billing_location = '1'";
84 //echo $sql;
85 $db = $GLOBALS['adodb']['db'];
86 $results = $db->Execute($sql);
88 if (!$results) {
89 $err = $db->ErrorMsg();
91 else {
92 if (!$results->EOF) {
93 $retval = $results->fields['street'];
97 // if we generated an error, create an error return response
98 if ($err) {
99 return $this->_handleError($err);
101 else {
102 // otherwise, we create the right response
103 // with the state name
104 return new xmlrpcresp(new xmlrpcval($retval));
109 function city($m) {
111 $err="";
114 $obj= $m->getparam(0);
115 $key = $obj->getval();
117 $sql = "SELECT * FROM facility where billing_location = '1'";
118 //echo $sql;
119 $db = $GLOBALS['adodb']['db'];
120 $results = $db->Execute($sql);
122 if (!$results) {
123 $err = $db->ErrorMsg();
125 else {
126 if (!$results->EOF) {
127 $retval = $results->fields['city'];
131 // if we generated an error, create an error return response
132 if ($err) {
133 return $this->_handleError($err);
135 else {
136 // otherwise, we create the right response
137 // with the state name
138 return new xmlrpcresp(new xmlrpcval($retval));
142 function state($m) {
144 $err="";
147 $obj= $m->getparam(0);
148 $key = $obj->getval();
150 $sql = "SELECT * FROM facility where billing_location = '1'";
151 //echo $sql;
152 $db = $GLOBALS['adodb']['db'];
153 $results = $db->Execute($sql);
155 if (!$results) {
156 $err = $db->ErrorMsg();
158 else {
159 if (!$results->EOF) {
160 $retval = $results->fields['state'];
164 // if we generated an error, create an error return response
165 if ($err) {
166 return $this->_handleError($err);
168 else {
169 // otherwise, we create the right response
170 // with the state name
171 return new xmlrpcresp(new xmlrpcval($retval));
175 function zipcode($m) {
177 $err="";
179 $obj= $m->getparam(0);
180 $key = $obj->getval();
182 $sql = "SELECT * FROM facility where billing_location = '1'";
183 //echo $sql;
184 $db = $GLOBALS['adodb']['db'];
185 $results = $db->Execute($sql);
187 if (!$results) {
188 $err = $db->ErrorMsg();
190 else {
191 if (!$results->EOF) {
192 $retval = $results->fields['postal_code'];
196 // if we generated an error, create an error return response
197 if ($err) {
198 return $this->_handleError($err);
200 else {
201 // otherwise, we create the right response
202 // with the state name
203 return new xmlrpcresp(new xmlrpcval($retval));
207 function phonecountry($m) {
209 $err="";
211 //unimplemented by OpenEMR
212 $pkey = "1";
214 // if we generated an error, create an error return response
215 if ($err) {
216 return $this->_handleError($err);
218 else {
219 // otherwise, we create the right response
220 // with the state name
221 return new xmlrpcresp(new xmlrpcval($pkey));
225 function phoneextension($m) {
227 $err="";
229 //unimplemented by OpenEMR
230 $pkey = "";
232 // if we generated an error, create an error return response
233 if ($err) {
234 return $this->_handleError($err);
236 else {
237 // otherwise, we create the right response
238 // with the state name
239 return new xmlrpcresp(new xmlrpcval($pkey));
243 function phonearea($m) {
245 $err="";
247 $sql = "SELECT * FROM facility where billing_location = '1'";
248 //echo $sql;
249 $db = $GLOBALS['adodb']['db'];
250 $results = $db->Execute($sql);
252 if (!$results) {
253 $err = $db->ErrorMsg();
255 else {
256 if (!$results->EOF) {
257 $retval = $results->fields['phone'];
261 $phone_parts = array();
262 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
263 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
264 $retval = $phone_parts[1];
266 // if we generated an error, create an error return response
267 if ($err) {
268 return $this->_handleError($err);
270 else {
271 // otherwise, we create the right response
272 // with the state name
273 return new xmlrpcresp(new xmlrpcval($retval));
277 function phonenumber($m) {
279 $err="";
281 $obj= $m->getparam(0);
282 $key = $obj->getval();
284 $sql = "SELECT * FROM facility where billing_location = '1'";
285 //echo $sql;
286 $db = $GLOBALS['adodb']['db'];
287 $results = $db->Execute($sql);
289 if (!$results) {
290 $err = $db->ErrorMsg();
292 else {
293 if (!$results->EOF) {
294 $retval = $results->fields['phone'];
298 $phone_parts = array();
299 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
300 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
301 $retval = $phone_parts[2] . "-" . $phone_parts[3];
303 // if we generated an error, create an error return response
304 if ($err) {
305 return $this->_handleError($err);
307 else {
308 // otherwise, we create the right response
309 // with the state name
310 return new xmlrpcresp(new xmlrpcval($retval));
314 function etin($m) {
316 $err="";
318 $obj= $m->getparam(0);
319 $key = $obj->getval();
321 $sql = "SELECT * FROM facility where billing_location = 1";
322 //echo $sql;
323 $db = $GLOBALS['adodb']['db'];
324 $results = $db->Execute($sql);
326 $vals = array();
327 if (!$results) {
328 $err = $db->ErrorMsg();
330 else {
331 if (!$results->EOF) {
332 $retval = $results->fields['federal_ein'];
337 // if we generated an error, create an error return response
338 if ($err) {
339 return $this->_handleError($err);
341 else {
342 // otherwise, we create the right response
343 // with the state name
344 return new xmlrpcresp(new xmlrpcval($retval));
348 function tin($m) {
350 $err="";
352 $obj= $m->getparam(0);
353 $key = $obj->getval();
355 $sql = "SELECT * FROM facility where billing_location = 1";
356 //echo $sql;
357 $db = $GLOBALS['adodb']['db'];
358 $results = $db->Execute($sql);
360 $vals = array();
361 if (!$results) {
362 $err = $db->ErrorMsg();
364 else {
365 if (!$results->EOF) {
366 $retval = $results->fields['federal_ein'];
371 // if we generated an error, create an error return response
372 if ($err) {
373 return $this->_handleError($err);
375 else {
376 // otherwise, we create the right response
377 // with the state name
378 return new xmlrpcresp(new xmlrpcval($retval));
384 //'FreeB.FBBillingService.Name' => \&FreeB_FBBillingService_Name,
385 //'FreeB.FBBillingService.StreetAddress' => \&FreeB_FBBillingService_StreetAddress,
386 //'FreeB.FBBillingService.City' => \&FreeB_FBBillingService_City,
387 //'FreeB.FBBillingService.State' => \&FreeB_FBBillingService_State,
388 //'FreeB.FBBillingService.Zipcode' => \&FreeB_FBBillingService_Zipcode,
389 //'FreeB.FBBillingService.PhoneCountry' => \&FreeB_FBBillingService_PhoneCountry,
390 //'FreeB.FBBillingService.PhoneExtension' => \&FreeB_FBBillingService_PhoneExtension,
391 //'FreeB.FBBillingService.PhoneArea' => \&FreeB_FBBillingService_PhoneArea,
392 //'FreeB.FBBillingService.PhoneNumber' => \&FreeB_FBBillingService_PhoneNumber,
393 //'FreeB.FBBillingService.ETIN' => \&FreeB_FBBillingService_ETIN,
394 //'FreeB.FBBillingService.TIN' => \&FreeB_FBBillingService_TIN,