remove legacy includes dir
[openemr.git] / library / freeb / Provider.class.php
blob5c1318211c2338c49557649e3d85b8f23b077a69
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Provider Extends DataObjectBase {
7 function Provider() {
8 $this->_addFunc("socialsecuritynumber", array( "name" => "FreeB.FBProvider.SocialSecurityNumber",
9 "sig" => array(XMLRPCSTRING,XMLRPCINT),
10 "doc" => ""));
11 $this->_addFunc("tin", array( "name" => "FreeB.FBProvider.TIN",
12 "sig" => array(XMLRPCSTRING,XMLRPCINT),
13 "doc" => ""));
14 $this->_addFunc("ipn", array( "name" => "FreeB.FBProvider.IPN",
15 "sig" => array(XMLRPCSTRING,XMLRPCINT),
16 "doc" => ""));
17 $this->_addFunc("npi", array( "name" => "FreeB.FBProvider.NPI",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("firstname", array( "name" => "FreeB.FBProvider.FirstName",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("middlename", array( "name" => "FreeB.FBProvider.MiddleName",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("lastname", array( "name" => "FreeB.FBProvider.LastName",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBProvider.StreetAddress",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("city", array( "name" => "FreeB.FBProvider.City",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("state", array( "name" => "FreeB.FBProvider.State",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("zipcode", array( "name" => "FreeB.FBProvider.Zipcode",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
41 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBProvider.PhoneCountry",
42 "sig" => array(XMLRPCSTRING,XMLRPCINT),
43 "doc" => ""));
44 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBProvider.PhoneExtension",
45 "sig" => array(XMLRPCSTRING,XMLRPCINT),
46 "doc" => ""));
47 $this->_addFunc("phonearea", array( "name" => "FreeB.FBProvider.PhoneArea",
48 "sig" => array(XMLRPCSTRING,XMLRPCINT),
49 "doc" => ""));
50 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBProvider.PhoneNumber",
51 "sig" => array(XMLRPCSTRING,XMLRPCINT),
52 "doc" => ""));
56 function socialsecuritynumber($m) {
57 // since this function is useless I will get the NPI number using this
58 $err="";
60 $obj= $m->getparam(0);
61 $key = $obj->getval();
63 $sql = "SELECT * FROM users where id = '" . $key . "'";
64 //echo $sql;
65 $db = $GLOBALS['adodb']['db'];
66 $results = $db->Execute($sql);
68 if (!$results) {
69 $err = $db->ErrorMsg();
71 else {
72 if (!$results->EOF) {
73 $retval = $results->fields['npi'];
77 // if we generated an error, create an error return response
78 if ($err) {
79 return $this->_handleError($err);
81 else {
82 // otherwise, we create the right response
83 // with the state name
84 return new xmlrpcresp(new xmlrpcval($retval,"string"));
88 function tin($m) {
90 $err="";
92 $obj= $m->getparam(0);
93 $key = $obj->getval();
95 $sql = "SELECT * FROM users where id = '" . $key . "'";
96 //echo $sql;
97 $db = $GLOBALS['adodb']['db'];
98 $results = $db->Execute($sql);
100 if (!$results) {
101 $err = $db->ErrorMsg();
103 else {
104 if (!$results->EOF) {
105 $retval = $results->fields['federaltaxid'];
110 // if we generated an error, create an error return response
111 if ($err) {
112 return $this->_handleError($err);
114 else {
115 // otherwise, we create the right response
116 // with the state name
117 return new xmlrpcresp(new xmlrpcval($retval,"string"));
121 function ipn($m) {
123 $err="";
125 $obj= $m->getparam(0);
126 $key = $obj->getval();
128 $sql = "SELECT * FROM users where id = '" . $key . "'";
129 //echo $sql;
130 $db = $GLOBALS['adodb']['db'];
131 $results = $db->Execute($sql);
133 if (!$results) {
134 $err = $db->ErrorMsg();
136 else {
137 if (!$results->EOF) {
138 $retval = $results->fields['upin'];
143 // if we generated an error, create an error return response
144 if ($err) {
145 return $this->_handleError($err);
147 else {
148 // otherwise, we create the right response
149 // with the state name
150 return new xmlrpcresp(new xmlrpcval($retval,"string"));
154 function npi($m) {
156 $err="";
158 $obj= $m->getparam(0);
159 $key = $obj->getval();
161 $sql = "SELECT * FROM users where id = '" . $key . "'";
162 //echo $sql;
163 $db = $GLOBALS['adodb']['db'];
164 $results = $db->Execute($sql);
166 if (!$results) {
167 $err = $db->ErrorMsg();
169 else {
170 if (!$results->EOF) {
171 $retval = $results->fields['npi'];
176 // if we generated an error, create an error return response
177 if ($err) {
178 return $this->_handleError($err);
180 else {
181 // otherwise, we create the right response
182 // with the state name
183 return new xmlrpcresp(new xmlrpcval($retval,"string"));
188 function firstname($m) {
190 $err="";
192 $obj= $m->getparam(0);
193 $key = $obj->getval();
195 $sql = "SELECT * FROM users where id = '" . $key . "'";
196 //echo $sql;
197 $db = $GLOBALS['adodb']['db'];
198 $results = $db->Execute($sql);
200 if (!$results) {
201 $err = $db->ErrorMsg();
203 else {
204 if (!$results->EOF) {
205 $retval = $results->fields['fname'];
210 // if we generated an error, create an error return response
211 if ($err) {
212 return $this->_handleError($err);
214 else {
215 // otherwise, we create the right response
216 // with the state name
217 return new xmlrpcresp(new xmlrpcval($retval,"string"));
221 function middlename($m) {
223 $err="";
225 $obj= $m->getparam(0);
226 $key = $obj->getval();
228 $sql = "SELECT * FROM users where id = '" . $key . "'";
229 //echo $sql;
230 $db = $GLOBALS['adodb']['db'];
231 $results = $db->Execute($sql);
233 if (!$results) {
234 $err = $db->ErrorMsg();
236 else {
237 if (!$results->EOF) {
238 $retval = $results->fields['federaltaxid'];
243 // if we generated an error, create an error return response
244 if ($err) {
245 return $this->_handleError($err);
247 else {
248 // otherwise, we create the right response
249 // with the state name
250 return new xmlrpcresp(new xmlrpcval($pkey));
254 function lastname($m) {
256 $err="";
258 $obj= $m->getparam(0);
259 $key = $obj->getval();
261 $sql = "SELECT * FROM users where id = '" . $key . "'";
262 //echo $sql;
263 $db = $GLOBALS['adodb']['db'];
264 $results = $db->Execute($sql);
266 if (!$results) {
267 $err = $db->ErrorMsg();
269 else {
270 if (!$results->EOF) {
271 $retval = $results->fields['lname'];
276 // if we generated an error, create an error return response
277 if ($err) {
278 return $this->_handleError($err);
280 else {
281 // otherwise, we create the right response
282 // with the state name
283 return new xmlrpcresp(new xmlrpcval($retval,"string"));
287 function streetaddress($m) {
289 $err="";
291 $obj= $m->getparam(0);
292 $key = $obj->getval();
294 $sql = "SELECT * FROM users where id = '" . $key . "'";
295 //echo $sql;
296 $db = $GLOBALS['adodb']['db'];
297 $results = $db->Execute($sql);
299 if (!$results) {
300 $err = $db->ErrorMsg();
302 else {
303 if (!$results->EOF) {
304 $retval = $results->fields['facility'];
308 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
309 //echo $sql;
310 $db = $GLOBALS['adodb']['db'];
311 $results = $db->Execute($sql);
313 if (!$results) {
314 $err = $db->ErrorMsg();
316 else {
317 if (!$results->EOF) {
318 $retval = $results->fields['street'];
323 // if we generated an error, create an error return response
324 if ($err) {
325 return $this->_handleError($err);
327 else {
328 // otherwise, we create the right response
329 // with the state name
330 return new xmlrpcresp(new xmlrpcval($retval,"string"));
335 function city($m) {
337 $err="";
339 $obj= $m->getparam(0);
340 $key = $obj->getval();
342 $sql = "SELECT * FROM users where id = '" . $key . "'";
343 //echo $sql;
344 $db = $GLOBALS['adodb']['db'];
345 $results = $db->Execute($sql);
347 if (!$results) {
348 $err = $db->ErrorMsg();
350 else {
351 if (!$results->EOF) {
352 $retval = $results->fields['facility'];
356 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
357 //echo $sql;
358 $db = $GLOBALS['adodb']['db'];
359 $results = $db->Execute($sql);
361 if (!$results) {
362 $err = $db->ErrorMsg();
364 else {
365 if (!$results->EOF) {
366 $retval = $results->fields['city'];
370 // if we generated an error, create an error return response
371 if ($err) {
372 return $this->_handleError($err);
374 else {
375 // otherwise, we create the right response
376 // with the state name
377 return new xmlrpcresp(new xmlrpcval($pkey));
381 function state($m) {
383 $err="";
385 $obj= $m->getparam(0);
386 $key = $obj->getval();
388 $sql = "SELECT * FROM users where id = '" . $key . "'";
389 //echo $sql;
390 $db = $GLOBALS['adodb']['db'];
391 $results = $db->Execute($sql);
393 if (!$results) {
394 $err = $db->ErrorMsg();
396 else {
397 if (!$results->EOF) {
398 $retval = $results->fields['facility'];
402 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
403 //echo $sql;
404 $db = $GLOBALS['adodb']['db'];
405 $results = $db->Execute($sql);
407 if (!$results) {
408 $err = $db->ErrorMsg();
410 else {
411 if (!$results->EOF) {
412 $retval = $results->fields['state'];
416 // if we generated an error, create an error return response
417 if ($err) {
418 return $this->_handleError($err);
420 else {
421 // otherwise, we create the right response
422 // with the state name
423 return new xmlrpcresp(new xmlrpcval($retval,"string"));
427 function zipcode($m) {
429 $err="";
431 $obj= $m->getparam(0);
432 $key = $obj->getval();
434 $sql = "SELECT * FROM users where id = '" . $key . "'";
435 //echo $sql;
436 $db = $GLOBALS['adodb']['db'];
437 $results = $db->Execute($sql);
439 if (!$results) {
440 $err = $db->ErrorMsg();
442 else {
443 if (!$results->EOF) {
444 $retval = $results->fields['facility'];
448 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
449 //echo $sql;
450 $db = $GLOBALS['adodb']['db'];
451 $results = $db->Execute($sql);
453 if (!$results) {
454 $err = $db->ErrorMsg();
456 else {
457 if (!$results->EOF) {
458 $retval = $results->fields['postal_code'];
462 // if we generated an error, create an error return response
463 if ($err) {
464 return $this->_handleError($err);
466 else {
467 // otherwise, we create the right response
468 // with the state name
469 return new xmlrpcresp(new xmlrpcval($retval,"string"));
472 function phonecountry($m) {
474 $err="";
476 $pkey = "1";
478 // if we generated an error, create an error return response
479 if ($err) {
480 return $this->_handleError($err);
482 else {
483 // otherwise, we create the right response
484 // with the state name
485 return new xmlrpcresp(new xmlrpcval($pkey));
489 function phoneextension($m) {
491 $err="";
493 //unimplmented by OpenEMR
494 $pkey = "";
496 // if we generated an error, create an error return response
497 if ($err) {
498 return $this->_handleError($err);
500 else {
501 // otherwise, we create the right response
502 // with the state name
503 return new xmlrpcresp(new xmlrpcval($pkey));
507 function phonearea($m) {
509 $err="";
511 $obj= $m->getparam(0);
512 $key = $obj->getval();
514 $sql = "SELECT * FROM users where id = '" . $key . "'";
515 //echo $sql;
516 $db = $GLOBALS['adodb']['db'];
517 $results = $db->Execute($sql);
519 if (!$results) {
520 $err = $db->ErrorMsg();
522 else {
523 if (!$results->EOF) {
524 $retval = $results->fields['facility'];
528 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
529 //echo $sql;
530 $db = $GLOBALS['adodb']['db'];
531 $results = $db->Execute($sql);
533 if (!$results) {
534 $err = $db->ErrorMsg();
536 else {
537 if (!$results->EOF) {
538 $retval = $results->fields['phone'];
542 $phone_parts = array();
543 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
544 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
545 $retval = $phone_parts[1];
547 // if we generated an error, create an error return response
548 if ($err) {
549 return $this->_handleError($err);
551 else {
552 // otherwise, we create the right response
553 // with the state name
554 return new xmlrpcresp(new xmlrpcval($retval,"string"));
558 function phonenumber($m) {
560 $err="";
562 $obj= $m->getparam(0);
563 $key = $obj->getval();
565 $sql = "SELECT * FROM users where id = '" . $key . "'";
566 //echo $sql;
567 $db = $GLOBALS['adodb']['db'];
568 $results = $db->Execute($sql);
570 if (!$results) {
571 $err = $db->ErrorMsg();
573 else {
574 if (!$results->EOF) {
575 $retval = $results->fields['facility'];
579 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
580 //echo $sql;
581 $db = $GLOBALS['adodb']['db'];
582 $results = $db->Execute($sql);
584 if (!$results) {
585 $err = $db->ErrorMsg();
587 else {
588 if (!$results->EOF) {
589 $retval = $results->fields['phone'];
593 $phone_parts = array();
594 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
595 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
596 $retval = $phone_parts[2] . "-" . $phone_parts[3] ;
598 // if we generated an error, create an error return response
599 if ($err) {
600 return $this->_handleError($err);
602 else {
603 // otherwise, we create the right response
604 // with the state name
605 return new xmlrpcresp(new xmlrpcval($retval,"string"));
613 //'FreeB.FBProvider.SocialSecurityNumber' => \&FreeB_FBProvider_SocialSecurityNumber,
614 //'FreeB.FBProvider.TIN' => \&FreeB_FBProvider_TIN,
615 //'FreeB.FBProvider.IPN' => \&FreeB_FBProvider_IPN,
616 //'FreeB.FBProvider.NPI' => \&FreeB_FBProvider_NPI,
617 //'FreeB.FBProvider.FirstName' => \&FreeB_FBProvider_FirstName,
618 //'FreeB.FBProvider.MiddleName' => \&FreeB_FBProvider_MiddleName,
619 //'FreeB.FBProvider.LastName' => \&FreeB_FBProvider_LastName,
620 //'FreeB.FBProvider.StreetAddress' => \&FreeB_FBProvider_StreetAddress,
621 //'FreeB.FBProvider.City' => \&FreeB_FBProvider_City,
622 //'FreeB.FBProvider.State' => \&FreeB_FBProvider_State,
623 //'FreeB.FBProvider.Zipcode' => \&FreeB_FBProvider_Zipcode,
624 //'FreeB.FBProvider.PhoneCountry' => \&FreeB_FBProvider_PhoneCountry,
625 //'FreeB.FBProvider.PhoneExtension' => \&FreeB_FBProvider_PhoneExtension,
626 //'FreeB.FBProvider.PhoneNumber' => \&FreeB_FBProvider_PhoneNumber,
627 //'FreeB.FBProvider.PhoneArea' => \&FreeB_FBProvider_PhoneArea,