bug fix: configurable prescription logo
[openemr.git] / library / freeb / Provider.class.php
blob80a3dd3bfbf398b1062768a7b3472b6c9bcf5f36
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("firstname", array( "name" => "FreeB.FBProvider.FirstName",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("middlename", array( "name" => "FreeB.FBProvider.MiddleName",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("lastname", array( "name" => "FreeB.FBProvider.LastName",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBProvider.StreetAddress",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("city", array( "name" => "FreeB.FBProvider.City",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("state", array( "name" => "FreeB.FBProvider.State",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("zipcode", array( "name" => "FreeB.FBProvider.Zipcode",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBProvider.PhoneCountry",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
41 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBProvider.PhoneExtension",
42 "sig" => array(XMLRPCSTRING,XMLRPCINT),
43 "doc" => ""));
44 $this->_addFunc("phonearea", array( "name" => "FreeB.FBProvider.PhoneArea",
45 "sig" => array(XMLRPCSTRING,XMLRPCINT),
46 "doc" => ""));
47 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBProvider.PhoneNumber",
48 "sig" => array(XMLRPCSTRING,XMLRPCINT),
49 "doc" => ""));
52 function socialsecuritynumber($m) {
54 $err="";
56 $obj= $m->getparam(0);
57 $key = $obj->getval();
59 $sql = "SELECT * FROM users where id = '" . $key . "'";
60 //echo $sql;
61 $db = $GLOBALS['adodb']['db'];
62 $results = $db->Execute($sql);
64 if (!$results) {
65 $err = $db->ErrorMsg();
67 else {
68 if (!$results->EOF) {
69 $retval = $results->fields['federaltaxid'];
73 // if we generated an error, create an error return response
74 if ($err) {
75 return $this->_handleError($err);
77 else {
78 // otherwise, we create the right response
79 // with the state name
80 return new xmlrpcresp(new xmlrpcval($retval,"string"));
84 function tin($m) {
86 $err="";
88 $obj= $m->getparam(0);
89 $key = $obj->getval();
91 $sql = "SELECT * FROM users where id = '" . $key . "'";
92 //echo $sql;
93 $db = $GLOBALS['adodb']['db'];
94 $results = $db->Execute($sql);
96 if (!$results) {
97 $err = $db->ErrorMsg();
99 else {
100 if (!$results->EOF) {
101 $retval = $results->fields['federaltaxid'];
106 // if we generated an error, create an error return response
107 if ($err) {
108 return $this->_handleError($err);
110 else {
111 // otherwise, we create the right response
112 // with the state name
113 return new xmlrpcresp(new xmlrpcval($retval,"string"));
117 function ipn($m) {
119 $err="";
121 $obj= $m->getparam(0);
122 $key = $obj->getval();
124 $sql = "SELECT * FROM users where id = '" . $key . "'";
125 //echo $sql;
126 $db = $GLOBALS['adodb']['db'];
127 $results = $db->Execute($sql);
129 if (!$results) {
130 $err = $db->ErrorMsg();
132 else {
133 if (!$results->EOF) {
134 $retval = $results->fields['upin'];
139 // if we generated an error, create an error return response
140 if ($err) {
141 return $this->_handleError($err);
143 else {
144 // otherwise, we create the right response
145 // with the state name
146 return new xmlrpcresp(new xmlrpcval($retval,"string"));
150 function firstname($m) {
152 $err="";
154 $obj= $m->getparam(0);
155 $key = $obj->getval();
157 $sql = "SELECT * FROM users where id = '" . $key . "'";
158 //echo $sql;
159 $db = $GLOBALS['adodb']['db'];
160 $results = $db->Execute($sql);
162 if (!$results) {
163 $err = $db->ErrorMsg();
165 else {
166 if (!$results->EOF) {
167 $retval = $results->fields['fname'];
172 // if we generated an error, create an error return response
173 if ($err) {
174 return $this->_handleError($err);
176 else {
177 // otherwise, we create the right response
178 // with the state name
179 return new xmlrpcresp(new xmlrpcval($retval,"string"));
183 function middlename($m) {
185 $err="";
187 $obj= $m->getparam(0);
188 $key = $obj->getval();
190 $sql = "SELECT * FROM users where id = '" . $key . "'";
191 //echo $sql;
192 $db = $GLOBALS['adodb']['db'];
193 $results = $db->Execute($sql);
195 if (!$results) {
196 $err = $db->ErrorMsg();
198 else {
199 if (!$results->EOF) {
200 $retval = $results->fields['federaltaxid'];
205 // if we generated an error, create an error return response
206 if ($err) {
207 return $this->_handleError($err);
209 else {
210 // otherwise, we create the right response
211 // with the state name
212 return new xmlrpcresp(new xmlrpcval($pkey));
216 function lastname($m) {
218 $err="";
220 $obj= $m->getparam(0);
221 $key = $obj->getval();
223 $sql = "SELECT * FROM users where id = '" . $key . "'";
224 //echo $sql;
225 $db = $GLOBALS['adodb']['db'];
226 $results = $db->Execute($sql);
228 if (!$results) {
229 $err = $db->ErrorMsg();
231 else {
232 if (!$results->EOF) {
233 $retval = $results->fields['lname'];
238 // if we generated an error, create an error return response
239 if ($err) {
240 return $this->_handleError($err);
242 else {
243 // otherwise, we create the right response
244 // with the state name
245 return new xmlrpcresp(new xmlrpcval($retval,"string"));
249 function streetaddress($m) {
251 $err="";
253 $obj= $m->getparam(0);
254 $key = $obj->getval();
256 $sql = "SELECT * FROM users where id = '" . $key . "'";
257 //echo $sql;
258 $db = $GLOBALS['adodb']['db'];
259 $results = $db->Execute($sql);
261 if (!$results) {
262 $err = $db->ErrorMsg();
264 else {
265 if (!$results->EOF) {
266 $retval = $results->fields['facility'];
270 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
271 //echo $sql;
272 $db = $GLOBALS['adodb']['db'];
273 $results = $db->Execute($sql);
275 if (!$results) {
276 $err = $db->ErrorMsg();
278 else {
279 if (!$results->EOF) {
280 $retval = $results->fields['street'];
285 // if we generated an error, create an error return response
286 if ($err) {
287 return $this->_handleError($err);
289 else {
290 // otherwise, we create the right response
291 // with the state name
292 return new xmlrpcresp(new xmlrpcval($retval,"string"));
297 function city($m) {
299 $err="";
301 $obj= $m->getparam(0);
302 $key = $obj->getval();
304 $sql = "SELECT * FROM users where id = '" . $key . "'";
305 //echo $sql;
306 $db = $GLOBALS['adodb']['db'];
307 $results = $db->Execute($sql);
309 if (!$results) {
310 $err = $db->ErrorMsg();
312 else {
313 if (!$results->EOF) {
314 $retval = $results->fields['facility'];
318 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
319 //echo $sql;
320 $db = $GLOBALS['adodb']['db'];
321 $results = $db->Execute($sql);
323 if (!$results) {
324 $err = $db->ErrorMsg();
326 else {
327 if (!$results->EOF) {
328 $retval = $results->fields['city'];
332 // if we generated an error, create an error return response
333 if ($err) {
334 return $this->_handleError($err);
336 else {
337 // otherwise, we create the right response
338 // with the state name
339 return new xmlrpcresp(new xmlrpcval($pkey));
343 function state($m) {
345 $err="";
347 $obj= $m->getparam(0);
348 $key = $obj->getval();
350 $sql = "SELECT * FROM users where id = '" . $key . "'";
351 //echo $sql;
352 $db = $GLOBALS['adodb']['db'];
353 $results = $db->Execute($sql);
355 if (!$results) {
356 $err = $db->ErrorMsg();
358 else {
359 if (!$results->EOF) {
360 $retval = $results->fields['facility'];
364 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
365 //echo $sql;
366 $db = $GLOBALS['adodb']['db'];
367 $results = $db->Execute($sql);
369 if (!$results) {
370 $err = $db->ErrorMsg();
372 else {
373 if (!$results->EOF) {
374 $retval = $results->fields['state'];
378 // if we generated an error, create an error return response
379 if ($err) {
380 return $this->_handleError($err);
382 else {
383 // otherwise, we create the right response
384 // with the state name
385 return new xmlrpcresp(new xmlrpcval($retval,"string"));
389 function zipcode($m) {
391 $err="";
393 $obj= $m->getparam(0);
394 $key = $obj->getval();
396 $sql = "SELECT * FROM users where id = '" . $key . "'";
397 //echo $sql;
398 $db = $GLOBALS['adodb']['db'];
399 $results = $db->Execute($sql);
401 if (!$results) {
402 $err = $db->ErrorMsg();
404 else {
405 if (!$results->EOF) {
406 $retval = $results->fields['facility'];
410 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
411 //echo $sql;
412 $db = $GLOBALS['adodb']['db'];
413 $results = $db->Execute($sql);
415 if (!$results) {
416 $err = $db->ErrorMsg();
418 else {
419 if (!$results->EOF) {
420 $retval = $results->fields['postal_code'];
424 // if we generated an error, create an error return response
425 if ($err) {
426 return $this->_handleError($err);
428 else {
429 // otherwise, we create the right response
430 // with the state name
431 return new xmlrpcresp(new xmlrpcval($retval,"string"));
434 function phonecountry($m) {
436 $err="";
438 $pkey = "1";
440 // if we generated an error, create an error return response
441 if ($err) {
442 return $this->_handleError($err);
444 else {
445 // otherwise, we create the right response
446 // with the state name
447 return new xmlrpcresp(new xmlrpcval($pkey));
451 function phoneextension($m) {
453 $err="";
455 //unimplmented by OpenEMR
456 $pkey = "";
458 // if we generated an error, create an error return response
459 if ($err) {
460 return $this->_handleError($err);
462 else {
463 // otherwise, we create the right response
464 // with the state name
465 return new xmlrpcresp(new xmlrpcval($pkey));
469 function phonearea($m) {
471 $err="";
473 $obj= $m->getparam(0);
474 $key = $obj->getval();
476 $sql = "SELECT * FROM users where id = '" . $key . "'";
477 //echo $sql;
478 $db = $GLOBALS['adodb']['db'];
479 $results = $db->Execute($sql);
481 if (!$results) {
482 $err = $db->ErrorMsg();
484 else {
485 if (!$results->EOF) {
486 $retval = $results->fields['facility'];
490 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
491 //echo $sql;
492 $db = $GLOBALS['adodb']['db'];
493 $results = $db->Execute($sql);
495 if (!$results) {
496 $err = $db->ErrorMsg();
498 else {
499 if (!$results->EOF) {
500 $retval = $results->fields['phone'];
504 $phone_parts = array();
505 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
506 $retval = $phone_parts[1];
508 // if we generated an error, create an error return response
509 if ($err) {
510 return $this->_handleError($err);
512 else {
513 // otherwise, we create the right response
514 // with the state name
515 return new xmlrpcresp(new xmlrpcval($retval,"string"));
519 function phonenumber($m) {
521 $err="";
523 $obj= $m->getparam(0);
524 $key = $obj->getval();
526 $sql = "SELECT * FROM users where id = '" . $key . "'";
527 //echo $sql;
528 $db = $GLOBALS['adodb']['db'];
529 $results = $db->Execute($sql);
531 if (!$results) {
532 $err = $db->ErrorMsg();
534 else {
535 if (!$results->EOF) {
536 $retval = $results->fields['facility'];
540 $sql = "SELECT * FROM facility where name = '" . $retval ."'";
541 //echo $sql;
542 $db = $GLOBALS['adodb']['db'];
543 $results = $db->Execute($sql);
545 if (!$results) {
546 $err = $db->ErrorMsg();
548 else {
549 if (!$results->EOF) {
550 $retval = $results->fields['phone'];
554 $phone_parts = array();
555 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
556 $retval = $phone_parts[2] . "-" . $phone_parts[3] ;
558 // if we generated an error, create an error return response
559 if ($err) {
560 return $this->_handleError($err);
562 else {
563 // otherwise, we create the right response
564 // with the state name
565 return new xmlrpcresp(new xmlrpcval($retval,"string"));
571 //'FreeB.FBProvider.SocialSecurityNumber' => \&FreeB_FBProvider_SocialSecurityNumber,
572 //'FreeB.FBProvider.TIN' => \&FreeB_FBProvider_TIN,
573 //'FreeB.FBProvider.IPN' => \&FreeB_FBProvider_IPN,
574 //'FreeB.FBProvider.FirstName' => \&FreeB_FBProvider_FirstName,
575 //'FreeB.FBProvider.MiddleName' => \&FreeB_FBProvider_MiddleName,
576 //'FreeB.FBProvider.LastName' => \&FreeB_FBProvider_LastName,
577 //'FreeB.FBProvider.StreetAddress' => \&FreeB_FBProvider_StreetAddress,
578 //'FreeB.FBProvider.City' => \&FreeB_FBProvider_City,
579 //'FreeB.FBProvider.State' => \&FreeB_FBProvider_State,
580 //'FreeB.FBProvider.Zipcode' => \&FreeB_FBProvider_Zipcode,
581 //'FreeB.FBProvider.PhoneCountry' => \&FreeB_FBProvider_PhoneCountry,
582 //'FreeB.FBProvider.PhoneExtension' => \&FreeB_FBProvider_PhoneExtension,
583 //'FreeB.FBProvider.PhoneNumber' => \&FreeB_FBProvider_PhoneNumber,
584 //'FreeB.FBProvider.PhoneArea' => \&FreeB_FBProvider_PhoneArea,