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
),
76 function firstname($m) {
81 $obj= $m->getparam(0);
82 $key = $obj->getval();
84 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
86 $db = $GLOBALS['adodb']['db'];
87 $results = $db->Execute($sql);
90 $err = $db->ErrorMsg();
94 $retval = $results->fields
['subscriber_fname'];
98 // if we generated an error, create an error return response
100 return $this->_handleError($err);
103 // otherwise, we create the right response
104 // with the state name
105 return new xmlrpcresp(new xmlrpcval($retval,"string"));
109 function middlename($m) {
114 $obj= $m->getparam(0);
115 $key = $obj->getval();
117 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
119 $db = $GLOBALS['adodb']['db'];
120 $results = $db->Execute($sql);
123 $err = $db->ErrorMsg();
126 if (!$results->EOF
) {
127 $retval = $results->fields
['subscriber_mname'];
131 // if we generated an error, create an error return response
133 return $this->_handleError($err);
136 // otherwise, we create the right response
137 // with the state name
138 return new xmlrpcresp(new xmlrpcval($retval,"string"));
142 function lastname($m) {
147 $obj= $m->getparam(0);
148 $key = $obj->getval();
150 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
152 $db = $GLOBALS['adodb']['db'];
153 $results = $db->Execute($sql);
156 $err = $db->ErrorMsg();
159 if (!$results->EOF
) {
160 $retval = $results->fields
['subscriber_lname'];
164 // if we generated an error, create an error return response
166 return $this->_handleError($err);
169 // otherwise, we create the right response
170 // with the state name
171 return new xmlrpcresp(new xmlrpcval($retval,"string"));
180 $obj= $m->getparam(0);
181 $key = $obj->getval();
183 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
185 $db = $GLOBALS['adodb']['db'];
186 $results = $db->Execute($sql);
189 $err = $db->ErrorMsg();
192 if (!$results->EOF
) {
193 $retval = $results->fields
['policy_number'];
196 // if we generated an error, create an error return response
198 return $this->_handleError($err);
201 // otherwise, we create the right response
202 // with the state name
203 return new xmlrpcresp(new xmlrpcval($retval));
207 function dateofbirth($m) {
212 $obj= $m->getparam(0);
213 $key = $obj->getval();
215 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
217 $db = $GLOBALS['adodb']['db'];
218 $results = $db->Execute($sql);
221 $err = $db->ErrorMsg();
224 if (!$results->EOF
) {
225 $retval = $results->fields
['subscriber_DOB'];
228 if (!empty($retval)) {
229 $retval = $this->_isodate($retval);
235 // if we generated an error, create an error return response
237 return $this->_handleError($err);
240 // otherwise, we create the right response
241 // with the state name
242 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
251 $obj= $m->getparam(0);
252 $key = $obj->getval();
254 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
256 $db = $GLOBALS['adodb']['db'];
257 $results = $db->Execute($sql);
260 $err = $db->ErrorMsg();
263 if (!$results->EOF
) {
264 $retval = $results->fields
['subscriber_sex'];
267 if (strtolower($retval) == "male") {
270 elseif (strtolower($retval) == "female") {
274 // if we generated an error, create an error return response
276 return $this->_handleError($err);
279 // otherwise, we create the right response
280 // with the state name
281 return new xmlrpcresp(new xmlrpcval($retval,"string"));
287 function groupname($m) {
292 $obj= $m->getparam(0);
293 $key = $obj->getval();
295 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
297 $db = $GLOBALS['adodb']['db'];
298 $results = $db->Execute($sql);
301 $err = $db->ErrorMsg();
304 if (!$results->EOF
) {
305 $retval = $results->fields
['subscriber_employer'];
309 // if we generated an error, create an error return response
311 return $this->_handleError($err);
314 // otherwise, we create the right response
315 // with the state name
316 return new xmlrpcresp(new xmlrpcval($retval,"string"));
320 function groupnumber($m) {
325 $obj= $m->getparam(0);
326 $key = $obj->getval();
328 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
330 $db = $GLOBALS['adodb']['db'];
331 $results = $db->Execute($sql);
334 $err = $db->ErrorMsg();
337 if (!$results->EOF
) {
338 $retval = $results->fields
['group_number'];
342 // if we generated an error, create an error return response
344 return $this->_handleError($err);
347 // otherwise, we create the right response
348 // with the state name
349 return new xmlrpcresp(new xmlrpcval($retval,"string"));
352 function isemployed($m) {
357 $obj= $m->getparam(0);
358 $key = $obj->getval();
363 // if we generated an error, create an error return response
365 return $this->_handleError($err);
368 // otherwise, we create the right response
369 // with the state name
370 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
374 function employername($m) {
379 $obj= $m->getparam(0);
380 $key = $obj->getval();
382 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
384 $db = $GLOBALS['adodb']['db'];
385 $results = $db->Execute($sql);
388 $err = $db->ErrorMsg();
391 if (!$results->EOF
) {
392 $retval = $results->fields
['subscriber_employer'];
397 // if we generated an error, create an error return response
399 return $this->_handleError($err);
402 // otherwise, we create the right response
403 // with the state name
404 return new xmlrpcresp(new xmlrpcval($retval,"string"));
408 function isstudent($m) {
411 //unimplemented by OpenEMR
414 // if we generated an error, create an error return response
416 return $this->_handleError($err);
419 // otherwise, we create the right response
420 // with the state name
421 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
425 function schoolname($m) {
429 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
431 $db = $GLOBALS['adodb']['db'];
432 $results = $db->Execute($sql);
435 $err = $db->ErrorMsg();
438 if (!$results->EOF
) {
439 $retval = $results->fields
['subscriber_employer'];
443 // if we generated an error, create an error return response
445 return $this->_handleError($err);
448 // otherwise, we create the right response
449 // with the state name
450 return new xmlrpcresp(new xmlrpcval($retval,"string"));
454 function isassigning($m) {
461 // if we generated an error, create an error return response
463 return $this->_handleError($err);
466 // otherwise, we create the right response
467 // with the state name
468 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
472 function planname($m) {
477 $obj= $m->getparam(0);
478 $key = $obj->getval();
480 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
482 $db = $GLOBALS['adodb']['db'];
483 $results = $db->Execute($sql);
486 $err = $db->ErrorMsg();
489 if (!$results->EOF
) {
490 $retval = $results->fields
['plan_name'];
494 // if we generated an error, create an error return response
496 return $this->_handleError($err);
499 // otherwise, we create the right response
500 // with the state name
501 return new xmlrpcresp(new xmlrpcval($retval,"string"));
505 function streetaddress($m) {
510 $obj= $m->getparam(0);
511 $key = $obj->getval();
513 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
515 $db = $GLOBALS['adodb']['db'];
516 $results = $db->Execute($sql);
519 $err = $db->ErrorMsg();
522 if (!$results->EOF
) {
523 $retval = $results->fields
['subscriber_street'];
527 // if we generated an error, create an error return response
529 return $this->_handleError($err);
532 // otherwise, we create the right response
533 // with the state name
534 return new xmlrpcresp(new xmlrpcval($retval,"string"));
544 $obj= $m->getparam(0);
545 $key = $obj->getval();
547 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
549 $db = $GLOBALS['adodb']['db'];
550 $results = $db->Execute($sql);
553 $err = $db->ErrorMsg();
556 if (!$results->EOF
) {
557 $retval = $results->fields
['subscriber_city'];
561 // if we generated an error, create an error return response
563 return $this->_handleError($err);
566 // otherwise, we create the right response
567 // with the state name
568 return new xmlrpcresp(new xmlrpcval($retval,"string"));
576 $obj= $m->getparam(0);
577 $key = $obj->getval();
579 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
581 $db = $GLOBALS['adodb']['db'];
582 $results = $db->Execute($sql);
585 $err = $db->ErrorMsg();
588 if (!$results->EOF
) {
589 $retval = $results->fields
['subscriber_state'];
593 // if we generated an error, create an error return response
595 return $this->_handleError($err);
598 // otherwise, we create the right response
599 // with the state name
600 return new xmlrpcresp(new xmlrpcval($retval,"string"));
603 function zipcode($m) {
608 $obj= $m->getparam(0);
609 $key = $obj->getval();
611 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
613 $db = $GLOBALS['adodb']['db'];
614 $results = $db->Execute($sql);
617 $err = $db->ErrorMsg();
620 if (!$results->EOF
) {
621 $retval = $results->fields
['subscriber_postal_code'];
624 // if we generated an error, create an error return response
626 return $this->_handleError($err);
629 // otherwise, we create the right response
630 // with the state name
631 return new xmlrpcresp(new xmlrpcval($retval,"string"));
634 function phonecountry($m) {
637 //Unimplemented by OpenEMR
639 // if we generated an error, create an error return response
641 return $this->_handleError($err);
644 // otherwise, we create the right response
645 // with the state name
646 return new xmlrpcresp(new xmlrpcval($retval,"string"));
650 function phoneextension($m) {
653 //unimplemented by OpenEMR
656 // if we generated an error, create an error return response
658 return $this->_handleError($err);
661 // otherwise, we create the right response
662 // with the state name
663 return new xmlrpcresp(new xmlrpcval($pkey));
667 function phonearea($m) {
672 $obj= $m->getparam(0);
673 $key = $obj->getval();
675 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
677 $db = $GLOBALS['adodb']['db'];
678 $results = $db->Execute($sql);
681 $err = $db->ErrorMsg();
684 if (!$results->EOF
) {
685 $retval = $results->fields
['subscriber_phone'];
688 $phone_parts = array();
689 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
690 $retval = $phone_parts[1];
692 // if we generated an error, create an error return response
694 return $this->_handleError($err);
697 // otherwise, we create the right response
698 // with the state name
699 return new xmlrpcresp(new xmlrpcval($retval,"string"));
702 function phonenumber($m) {
707 $obj= $m->getparam(0);
708 $key = $obj->getval();
710 $sql = "SELECT * FROM insurance_data where id = '" . $key . "'";
712 $db = $GLOBALS['adodb']['db'];
713 $results = $db->Execute($sql);
716 $err = $db->ErrorMsg();
719 if (!$results->EOF
) {
720 $retval = $results->fields
['subscriber_phone'];
723 $phone_parts = array();
724 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
725 $retval = $phone_parts[2] . "-" . $phone_parts[3];
727 // if we generated an error, create an error return response
729 return $this->_handleError($err);
732 // otherwise, we create the right response
733 // with the state name
734 return new xmlrpcresp(new xmlrpcval($retval,"string"));
740 //'FreeB.FBInsured.FirstName' => \&FreeB_FBInsured_FirstName,
741 //'FreeB.FBInsured.LastName' => \&FreeB_FBInsured_LastName,
742 //'FreeB.FBInsured.MiddleName' => \&FreeB_FBInsured_MiddleName,
743 //'FreeB.FBInsured.ID' => \&FreeB_FBInsured_ID,
745 //'FreeB.FBInsured.DateOfBirth' => \&FreeB_FBInsured_DateOfBirth,
746 //'FreeB.FBInsured.Sex' => \&FreeB_FBInsured_Sex,
747 //'FreeB.FBInsured.GroupName' => \&FreeB_FBInsured_GroupName,
748 //'FreeB.FBInsured.GroupNumber' => \&FreeB_FBInsured_GroupNumber,
749 //'FreeB.FBInsured.isEmployed' => \&FreeB_FBInsured_isEmployed,
750 //'FreeB.FBInsured.EmployerName' => \&FreeB_FBInsured_EmployerName,
751 //'FreeB.FBInsured.isStudent' => \&FreeB_FBInsured_isStudent,
752 //'FreeB.FBInsured.SchoolName' => \&FreeB_FBInsured_SchoolName,
753 //'FreeB.FBInsured.isAssigning' => \&FreeB_FBInsured_isAssigning,
754 //'FreeB.FBInsured.PlanName' => \&FreeB_FBInsured_PlanName,
756 //'FreeB.FBInsured.StreetAddress' => \&FreeB_FBInsured_StreetAddress,
757 //'FreeB.FBInsured.City' => \&FreeB_FBInsured_City,
758 //'FreeB.FBInsured.State' => \&FreeB_FBInsured_State,
759 //'FreeB.FBInsured.Zipcode' => \&FreeB_FBInsured_Zipcode,
760 //'FreeB.FBInsured.PhoneCountry' => \&FreeB_FBInsured_PhoneCountry,
761 //'FreeB.FBInsured.PhoneExtension' => \&FreeB_FBInsured_PhoneExtension,
762 //'FreeB.FBInsured.PhoneArea' => \&FreeB_FBInsured_PhoneArea,
763 //'FreeB.FBInsured.PhoneNumber' => \&FreeB_FBInsured_PhoneNumber,