2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Insured
Extends DataObjectBase
{
8 $this->_addFunc("firstname", array( "name" => "FreeB.FBInsured.FirstName",
9 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
11 $this->_addFunc("middlename", array( "name" => "FreeB.FBInsured.MiddleName",
12 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
14 $this->_addFunc("lastname", array( "name" => "FreeB.FBInsured.LastName",
15 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
17 $this->_addFunc("id", array( "name" => "FreeB.FBInsured.ID",
18 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
20 $this->_addFunc("dateofbirth", array( "name" => "FreeB.FBInsured.DateOfBirth",
21 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
23 $this->_addFunc("sex", array( "name" => "FreeB.FBInsured.Sex",
24 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
26 $this->_addFunc("groupname", array( "name" => "FreeB.FBInsured.GroupName",
27 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
29 $this->_addFunc("groupnumber", array( "name" => "FreeB.FBInsured.GroupNumber",
30 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
32 $this->_addFunc("isemployed", array( "name" => "FreeB.FBInsured.isEmployed",
33 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
35 $this->_addFunc("employername", array( "name" => "FreeB.FBInsured.EmployerName",
36 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
38 $this->_addFunc("isstudent", array( "name" => "FreeB.FBInsured.isStudent",
39 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
41 $this->_addFunc("schoolname", array( "name" => "FreeB.FBInsured.SchoolName",
42 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
44 $this->_addFunc("isassigning", array( "name" => "FreeB.FBInsured.isAssigning",
45 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
47 $this->_addFunc("planname", array( "name" => "FreeB.FBInsured.PlanName",
48 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
50 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBInsured.StreetAddress",
51 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
53 $this->_addFunc("city", array( "name" => "FreeB.FBInsured.City",
54 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
56 $this->_addFunc("state", array( "name" => "FreeB.FBInsured.State",
57 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
59 $this->_addFunc("zipcode", array( "name" => "FreeB.FBInsured.Zipcode",
60 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
62 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBInsured.PhoneCountry",
63 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
65 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBInsured.PhoneExtension",
66 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
68 $this->_addFunc("phonearea", array( "name" => "FreeB.FBInsured.PhoneArea",
69 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
71 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBInsured.PhoneNumber",
72 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
74 $this->_addFunc("payerkey", array("name" => "FreeB.FBInsured.PayerKey",
75 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
79 function firstname($m) {
84 $obj= $m->getparam(0);
85 $key = $obj->getval();
87 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
89 $db = $GLOBALS['adodb']['db'];
90 $results = $db->Execute($sql);
93 $err = $db->ErrorMsg();
97 $retval = $results->fields
['subscriber_fname'];
101 // if we generated an error, create an error return response
103 return $this->_handleError($err);
106 // otherwise, we create the right response
107 // with the state name
108 return new xmlrpcresp(new xmlrpcval($retval,"string"));
112 function middlename($m) {
117 $obj= $m->getparam(0);
118 $key = $obj->getval();
120 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
122 $db = $GLOBALS['adodb']['db'];
123 $results = $db->Execute($sql);
126 $err = $db->ErrorMsg();
129 if (!$results->EOF
) {
130 $retval = $results->fields
['subscriber_mname'];
134 // if we generated an error, create an error return response
136 return $this->_handleError($err);
139 // otherwise, we create the right response
140 // with the state name
141 return new xmlrpcresp(new xmlrpcval($retval,"string"));
145 function lastname($m) {
150 $obj= $m->getparam(0);
151 $key = $obj->getval();
153 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
155 $db = $GLOBALS['adodb']['db'];
156 $results = $db->Execute($sql);
159 $err = $db->ErrorMsg();
162 if (!$results->EOF
) {
163 $retval = $results->fields
['subscriber_lname'];
167 // if we generated an error, create an error return response
169 return $this->_handleError($err);
172 // otherwise, we create the right response
173 // with the state name
174 return new xmlrpcresp(new xmlrpcval($retval,"string"));
183 $obj= $m->getparam(0);
184 $key = $obj->getval();
186 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
188 $db = $GLOBALS['adodb']['db'];
189 $results = $db->Execute($sql);
192 $err = $db->ErrorMsg();
195 if (!$results->EOF
) {
196 $retval = $results->fields
['policy_number'];
199 // if we generated an error, create an error return response
201 return $this->_handleError($err);
204 // otherwise, we create the right response
205 // with the state name
206 return new xmlrpcresp(new xmlrpcval($retval));
210 function dateofbirth($m) {
215 $obj= $m->getparam(0);
216 $key = $obj->getval();
218 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
220 $db = $GLOBALS['adodb']['db'];
221 $results = $db->Execute($sql);
224 $err = $db->ErrorMsg();
227 if (!$results->EOF
) {
228 $retval = $results->fields
['subscriber_DOB'];
231 if (!empty($retval)) {
232 $retval = $this->_isodate($retval);
238 // if we generated an error, create an error return response
240 return $this->_handleError($err);
243 // otherwise, we create the right response
244 // with the state name
245 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
254 $obj= $m->getparam(0);
255 $key = $obj->getval();
257 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
259 $db = $GLOBALS['adodb']['db'];
260 $results = $db->Execute($sql);
263 $err = $db->ErrorMsg();
266 if (!$results->EOF
) {
267 $retval = $results->fields
['subscriber_sex'];
270 if (strtolower($retval) == "male") {
273 elseif (strtolower($retval) == "female") {
277 // if we generated an error, create an error return response
279 return $this->_handleError($err);
282 // otherwise, we create the right response
283 // with the state name
284 return new xmlrpcresp(new xmlrpcval($retval,"string"));
290 function groupname($m) {
295 $obj= $m->getparam(0);
296 $key = $obj->getval();
298 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
300 $db = $GLOBALS['adodb']['db'];
301 $results = $db->Execute($sql);
304 $err = $db->ErrorMsg();
307 if (!$results->EOF
) {
308 $retval = $results->fields
['subscriber_employer'];
312 // if we generated an error, create an error return response
314 return $this->_handleError($err);
317 // otherwise, we create the right response
318 // with the state name
319 return new xmlrpcresp(new xmlrpcval($retval,"string"));
323 function groupnumber($m) {
328 $obj= $m->getparam(0);
329 $key = $obj->getval();
331 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
333 $db = $GLOBALS['adodb']['db'];
334 $results = $db->Execute($sql);
337 $err = $db->ErrorMsg();
340 if (!$results->EOF
) {
341 $retval = $results->fields
['group_number'];
345 // if we generated an error, create an error return response
347 return $this->_handleError($err);
350 // otherwise, we create the right response
351 // with the state name
352 return new xmlrpcresp(new xmlrpcval($retval,"string"));
355 function isemployed($m) {
360 $obj= $m->getparam(0);
361 $key = $obj->getval();
366 // if we generated an error, create an error return response
368 return $this->_handleError($err);
371 // otherwise, we create the right response
372 // with the state name
373 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
377 function employername($m) {
382 $obj= $m->getparam(0);
383 $key = $obj->getval();
385 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
387 $db = $GLOBALS['adodb']['db'];
388 $results = $db->Execute($sql);
391 $err = $db->ErrorMsg();
394 if (!$results->EOF
) {
395 $retval = $results->fields
['subscriber_employer'];
400 // if we generated an error, create an error return response
402 return $this->_handleError($err);
405 // otherwise, we create the right response
406 // with the state name
407 return new xmlrpcresp(new xmlrpcval($retval,"string"));
411 function isstudent($m) {
414 //unimplemented by OpenEMR
417 // if we generated an error, create an error return response
419 return $this->_handleError($err);
422 // otherwise, we create the right response
423 // with the state name
424 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
428 function schoolname($m) {
432 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
434 $db = $GLOBALS['adodb']['db'];
435 $results = $db->Execute($sql);
438 $err = $db->ErrorMsg();
441 if (!$results->EOF
) {
442 $retval = $results->fields
['subscriber_employer'];
446 // if we generated an error, create an error return response
448 return $this->_handleError($err);
451 // otherwise, we create the right response
452 // with the state name
453 return new xmlrpcresp(new xmlrpcval($retval,"string"));
457 function isassigning($m) {
464 // if we generated an error, create an error return response
466 return $this->_handleError($err);
469 // otherwise, we create the right response
470 // with the state name
471 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
475 function planname($m) {
480 $obj= $m->getparam(0);
481 $key = $obj->getval();
483 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
485 $db = $GLOBALS['adodb']['db'];
486 $results = $db->Execute($sql);
489 $err = $db->ErrorMsg();
492 if (!$results->EOF
) {
493 $retval = $results->fields
['plan_name'];
497 // if we generated an error, create an error return response
499 return $this->_handleError($err);
502 // otherwise, we create the right response
503 // with the state name
504 return new xmlrpcresp(new xmlrpcval($retval,"string"));
508 function streetaddress($m) {
513 $obj= $m->getparam(0);
514 $key = $obj->getval();
516 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
518 $db = $GLOBALS['adodb']['db'];
519 $results = $db->Execute($sql);
522 $err = $db->ErrorMsg();
525 if (!$results->EOF
) {
526 $retval = $results->fields
['subscriber_street'];
530 // if we generated an error, create an error return response
532 return $this->_handleError($err);
535 // otherwise, we create the right response
536 // with the state name
537 return new xmlrpcresp(new xmlrpcval($retval,"string"));
547 $obj= $m->getparam(0);
548 $key = $obj->getval();
550 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
552 $db = $GLOBALS['adodb']['db'];
553 $results = $db->Execute($sql);
556 $err = $db->ErrorMsg();
559 if (!$results->EOF
) {
560 $retval = $results->fields
['subscriber_city'];
564 // if we generated an error, create an error return response
566 return $this->_handleError($err);
569 // otherwise, we create the right response
570 // with the state name
571 return new xmlrpcresp(new xmlrpcval($retval,"string"));
579 $obj= $m->getparam(0);
580 $key = $obj->getval();
582 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
584 $db = $GLOBALS['adodb']['db'];
585 $results = $db->Execute($sql);
588 $err = $db->ErrorMsg();
591 if (!$results->EOF
) {
592 $retval = $results->fields
['subscriber_state'];
596 // if we generated an error, create an error return response
598 return $this->_handleError($err);
601 // otherwise, we create the right response
602 // with the state name
603 return new xmlrpcresp(new xmlrpcval($retval,"string"));
606 function zipcode($m) {
611 $obj= $m->getparam(0);
612 $key = $obj->getval();
614 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
616 $db = $GLOBALS['adodb']['db'];
617 $results = $db->Execute($sql);
620 $err = $db->ErrorMsg();
623 if (!$results->EOF
) {
624 $retval = $results->fields
['subscriber_postal_code'];
627 // if we generated an error, create an error return response
629 return $this->_handleError($err);
632 // otherwise, we create the right response
633 // with the state name
634 return new xmlrpcresp(new xmlrpcval($retval,"string"));
637 function phonecountry($m) {
640 //Unimplemented by OpenEMR
642 // if we generated an error, create an error return response
644 return $this->_handleError($err);
647 // otherwise, we create the right response
648 // with the state name
649 return new xmlrpcresp(new xmlrpcval($retval,"string"));
653 function phoneextension($m) {
656 //unimplemented by OpenEMR
659 // if we generated an error, create an error return response
661 return $this->_handleError($err);
664 // otherwise, we create the right response
665 // with the state name
666 return new xmlrpcresp(new xmlrpcval($pkey));
670 function phonearea($m) {
675 $obj= $m->getparam(0);
676 $key = $obj->getval();
678 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
680 $db = $GLOBALS['adodb']['db'];
681 $results = $db->Execute($sql);
684 $err = $db->ErrorMsg();
687 if (!$results->EOF
) {
688 $retval = $results->fields
['subscriber_phone'];
692 $phone_parts = array();
693 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
694 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
695 $retval = $phone_parts[1];
697 // if we generated an error, create an error return response
699 return $this->_handleError($err);
702 // otherwise, we create the right response
703 // with the state name
704 return new xmlrpcresp(new xmlrpcval($retval,"string"));
707 function phonenumber($m) {
712 $obj= $m->getparam(0);
713 $key = $obj->getval();
715 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
717 $db = $GLOBALS['adodb']['db'];
718 $results = $db->Execute($sql);
721 $err = $db->ErrorMsg();
724 if (!$results->EOF
) {
725 $retval = $results->fields
['subscriber_phone'];
729 $phone_parts = array();
730 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
731 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
732 $retval = $phone_parts[2] . "-" . $phone_parts[3];
734 // if we generated an error, create an error return response
736 return $this->_handleError($err);
739 // otherwise, we create the right response
740 // with the state name
741 return new xmlrpcresp(new xmlrpcval($retval,"string"));
745 function payerkey($m) {
749 $obj= $m->getparam(0);
750 $key = $obj->getval();
752 $sql = "SELECT provider FROM insurance_data where id = '$key'";
753 $db = $GLOBALS['adodb']['db'];
754 $results = $db->Execute($sql);
757 $err = $db->ErrorMsg() . " $sql";
760 if (!$results->EOF
) {
761 $pkey = $results->fields
['provider'];
766 return $this->_handleError($err);
769 return new xmlrpcresp(new xmlrpcval($pkey, "i4"));
775 //'FreeB.FBInsured.FirstName' => \&FreeB_FBInsured_FirstName,
776 //'FreeB.FBInsured.LastName' => \&FreeB_FBInsured_LastName,
777 //'FreeB.FBInsured.MiddleName' => \&FreeB_FBInsured_MiddleName,
778 //'FreeB.FBInsured.ID' => \&FreeB_FBInsured_ID,
780 //'FreeB.FBInsured.DateOfBirth' => \&FreeB_FBInsured_DateOfBirth,
781 //'FreeB.FBInsured.Sex' => \&FreeB_FBInsured_Sex,
782 //'FreeB.FBInsured.GroupName' => \&FreeB_FBInsured_GroupName,
783 //'FreeB.FBInsured.GroupNumber' => \&FreeB_FBInsured_GroupNumber,
784 //'FreeB.FBInsured.isEmployed' => \&FreeB_FBInsured_isEmployed,
785 //'FreeB.FBInsured.EmployerName' => \&FreeB_FBInsured_EmployerName,
786 //'FreeB.FBInsured.isStudent' => \&FreeB_FBInsured_isStudent,
787 //'FreeB.FBInsured.SchoolName' => \&FreeB_FBInsured_SchoolName,
788 //'FreeB.FBInsured.isAssigning' => \&FreeB_FBInsured_isAssigning,
789 //'FreeB.FBInsured.PlanName' => \&FreeB_FBInsured_PlanName,
791 //'FreeB.FBInsured.StreetAddress' => \&FreeB_FBInsured_StreetAddress,
792 //'FreeB.FBInsured.City' => \&FreeB_FBInsured_City,
793 //'FreeB.FBInsured.State' => \&FreeB_FBInsured_State,
794 //'FreeB.FBInsured.Zipcode' => \&FreeB_FBInsured_Zipcode,
795 //'FreeB.FBInsured.PhoneCountry' => \&FreeB_FBInsured_PhoneCountry,
796 //'FreeB.FBInsured.PhoneExtension' => \&FreeB_FBInsured_PhoneExtension,
797 //'FreeB.FBInsured.PhoneArea' => \&FreeB_FBInsured_PhoneArea,
798 //'FreeB.FBInsured.PhoneNumber' => \&FreeB_FBInsured_PhoneNumber,