2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Patient
Extends DataObjectBase
{
9 $this->_addFunc("firstname", array( "name" => "FreeB.FBPatient.FirstName",
10 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
12 $this->_addFunc("middlename", array( "name" => "FreeB.FBPatient.MiddleName",
13 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
15 $this->_addFunc("lastname", array( "name" => "FreeB.FBPatient.LastName",
16 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
18 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBPatient.StreetAddress",
19 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
21 $this->_addFunc("city", array( "name" => "FreeB.FBPatient.City",
22 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
24 $this->_addFunc("state", array( "name" => "FreeB.FBPatient.State",
25 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
27 $this->_addFunc("zipcode", array( "name" => "FreeB.FBPatient.Zipcode",
28 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
30 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBPatient.PhoneCountry",
31 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
33 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBPatient.PhoneExtension",
34 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
36 $this->_addFunc("phonearea", array( "name" => "FreeB.FBPatient.PhoneArea",
37 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
39 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBPatient.PhoneNumber",
40 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
42 $this->_addFunc("title", array( "name" => "FreeB.FBPatient.Title",
43 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
45 $this->_addFunc("account", array( "name" => "FreeB.FBPatient.Account",
46 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
48 $this->_addFunc("isdead", array( "name" => "FreeB.FBPatient.isDead",
49 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
51 $this->_addFunc("dateofbirth", array( "name" => "FreeB.FBPatient.DateOfBirth",
52 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
54 $this->_addFunc("dateofdeath", array( "name" => "FreeB.FBPatient.DateOfDeath",
55 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
57 $this->_addFunc("sex", array( "name" => "FreeB.FBPatient.Sex",
58 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
60 $this->_addFunc("issingle", array( "name" => "FreeB.FBPatient.isSingle",
61 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
63 $this->_addFunc("ismarried", array( "name" => "FreeB.FBPatient.isMarried",
64 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
66 $this->_addFunc("ismaritalotherhcfa", array( "name" => "FreeB.FBPatient.isMaritalOtherHCFA",
67 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
69 $this->_addFunc("isemployed", array( "name" => "FreeB.FBPatient.isEmployed",
70 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
72 $this->_addFunc("isfulltimestudent", array( "name" => "FreeB.FBPatient.isFullTimeStudent",
73 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
75 $this->_addFunc("isparttimestudent", array( "name" => "FreeB.FBPatient.isPartTimeStudent",
76 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
78 $this->_addFunc("ischildofinsured", array( "name" => "FreeB.FBPatient.isChildOfInsured",
79 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
81 $this->_addFunc("ishusbandofinsured", array( "name" => "FreeB.FBPatient.isHusbandOfInsured",
82 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
84 $this->_addFunc("iswifeofinsured", array( "name" => "FreeB.FBPatient.isWifeOfInsured",
85 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
87 $this->_addFunc("isdivorceeofinsured", array( "name" => "FreeB.FBPatient.isDivorceeOfInsured",
88 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
90 $this->_addFunc("isselfofinsured", array( "name" => "FreeB.FBPatient.isSelfOfInsured",
91 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
93 $this->_addFunc("isotherofinsured", array( "name" => "FreeB.FBPatient.isOtherOfInsured",
94 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
96 $this->_addFunc("socialsecuritynumber", array( "name" => "FreeB.FBPatient.SocialSecurityNumber",
97 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
99 $this->_addFunc("coveragecount", array( "name" => "FreeB.FBPatient.CoverageCount",
100 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
102 $this->_addFunc("x12insuredrelationship", array( "name" => "FreeB.FBPatient.X12InsuredRelationship",
103 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
105 $this->_addFunc("ispregnant", array( "name" => "FreeB.FBPatient.isPregnant",
106 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
108 $this->_addFunc("insuredkey", array("name" => "FreeB.FBPatient.InsuredKey",
109 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCSTRING
),
114 function firstname($m) {
119 $obj= $m->getparam(0);
120 $key = $obj->getval();
122 $sql = "SELECT * FROM patient_data where pid = '" . $key . "'";
124 $db = $GLOBALS['adodb']['db'];
125 $results = $db->Execute($sql);
128 $err = $db->ErrorMsg();
131 if (!$results->EOF
) {
132 $retval = $results->fields
['fname'];
136 // if we generated an error, create an error return response
138 return $this->_handleError($err);
141 // otherwise, we create the right response
142 // with the state name
143 return new xmlrpcresp(new xmlrpcval($retval,"string"));
147 function middlename($m) {
152 $obj= $m->getparam(0);
153 $key = $obj->getval();
155 $sql = "SELECT * FROM patient_data where pid = '" . $key . "'";
157 $db = $GLOBALS['adodb']['db'];
158 $results = $db->Execute($sql);
161 $err = $db->ErrorMsg();
164 if (!$results->EOF
) {
165 $retval = $results->fields
['mname'];
170 // if we generated an error, create an error return response
172 return $this->_handleError($err);
175 // otherwise, we create the right response
176 // with the state name
177 return new xmlrpcresp(new xmlrpcval($retval,"string"));
181 function lastname($m) {
186 $obj= $m->getparam(0);
187 $key = $obj->getval();
189 $sql = "SELECT * FROM patient_data where pid = '" . $key . "'";
191 $db = $GLOBALS['adodb']['db'];
192 $results = $db->Execute($sql);
195 $err = $db->ErrorMsg();
198 if (!$results->EOF
) {
199 $retval = $results->fields
['lname'];
204 // if we generated an error, create an error return response
206 return $this->_handleError($err);
209 // otherwise, we create the right response
210 // with the state name
211 return new xmlrpcresp(new xmlrpcval($retval,"string"));
215 function streetaddress($m) {
220 $obj= $m->getparam(0);
221 $key = $obj->getval();
223 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
225 $db = $GLOBALS['adodb']['db'];
226 $results = $db->Execute($sql);
229 $err = $db->ErrorMsg();
232 if (!$results->EOF
) {
233 $retval = $results->fields
['street'];
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,"string"));
255 $obj= $m->getparam(0);
256 $key = $obj->getval();
258 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
260 $db = $GLOBALS['adodb']['db'];
261 $results = $db->Execute($sql);
264 $err = $db->ErrorMsg();
267 if (!$results->EOF
) {
268 $retval = $results->fields
['city'];
273 // if we generated an error, create an error return response
275 return $this->_handleError($err);
278 // otherwise, we create the right response
279 // with the state name
280 return new xmlrpcresp(new xmlrpcval($retval,"string"));
289 $obj= $m->getparam(0);
290 $key = $obj->getval();
292 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
294 $db = $GLOBALS['adodb']['db'];
295 $results = $db->Execute($sql);
298 $err = $db->ErrorMsg();
301 if (!$results->EOF
) {
302 $retval = $results->fields
['state'];
307 // if we generated an error, create an error return response
309 return $this->_handleError($err);
312 // otherwise, we create the right response
313 // with the state name
314 return new xmlrpcresp(new xmlrpcval($retval,"string"));
318 function zipcode($m) {
323 $obj= $m->getparam(0);
324 $key = $obj->getval();
326 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
328 $db = $GLOBALS['adodb']['db'];
329 $results = $db->Execute($sql);
332 $err = $db->ErrorMsg();
335 if (!$results->EOF
) {
336 $retval = $results->fields
['postal_code'];
341 // if we generated an error, create an error return response
343 return $this->_handleError($err);
346 // otherwise, we create the right response
347 // with the state name
348 return new xmlrpcresp(new xmlrpcval($retval,"string"));
352 function phonecountry($m) {
356 //OpenEMR only supports US country code
359 // if we generated an error, create an error return response
361 return $this->_handleError($err);
364 // otherwise, we create the right response
365 // with the state name
366 return new xmlrpcresp(new xmlrpcval($pkey));
370 function phoneextension($m) {
374 //unimplemented by openemr
377 // if we generated an error, create an error return response
379 return $this->_handleError($err);
382 // otherwise, we create the right response
383 // with the state name
384 return new xmlrpcresp(new xmlrpcval($pkey));
388 function phonearea($m) {
393 $obj= $m->getparam(0);
394 $key = $obj->getval();
396 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
398 $db = $GLOBALS['adodb']['db'];
399 $results = $db->Execute($sql);
402 $err = $db->ErrorMsg();
405 if (!$results->EOF
) {
406 $retval = $results->fields
['phone_home'];
410 $phone_parts = array();
411 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
412 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
413 $retval = $phone_parts[1];
415 // if we generated an error, create an error return response
417 return $this->_handleError($err);
420 // otherwise, we create the right response
421 // with the state name
422 return new xmlrpcresp(new xmlrpcval($retval,"string"));
426 function phonenumber($m) {
431 $obj= $m->getparam(0);
432 $key = $obj->getval();
434 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
436 $db = $GLOBALS['adodb']['db'];
437 $results = $db->Execute($sql);
440 $err = $db->ErrorMsg();
443 if (!$results->EOF
) {
444 $retval = $results->fields
['phone_home'];
448 $phone_parts = array();
449 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
450 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
451 $retval = $phone_parts[2] . "-" . $phone_parts[3];
453 // if we generated an error, create an error return response
455 return $this->_handleError($err);
458 // otherwise, we create the right response
459 // with the state name
460 return new xmlrpcresp(new xmlrpcval($retval,"string"));
470 $obj= $m->getparam(0);
471 $key = $obj->getval();
473 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
475 $db = $GLOBALS['adodb']['db'];
476 $results = $db->Execute($sql);
479 $err = $db->ErrorMsg();
482 if (!$results->EOF
) {
483 $retval = $results->fields
['title'];
488 // if we generated an error, create an error return response
490 return $this->_handleError($err);
493 // otherwise, we create the right response
494 // with the state name
495 return new xmlrpcresp(new xmlrpcval($retval,"string"));
499 function account($m) {
504 $retval = $_SESSION['patient_id'] . "-" . $_SESSION['billkey'];
506 // if we generated an error, create an error return response
508 return $this->_handleError($err);
511 // otherwise, we create the right response
512 // with the state name
513 return new xmlrpcresp(new xmlrpcval($retval));
517 function isdead($m) {
521 //unimplemented by OpenEMR
524 // if we generated an error, create an error return response
526 return $this->_handleError($err);
529 // otherwise, we create the right response
530 // with the state name
531 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
535 function dateofbirth($m) {
540 $obj= $m->getparam(0);
541 $key = $obj->getval();
543 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
545 $db = $GLOBALS['adodb']['db'];
546 $results = $db->Execute($sql);
549 $err = $db->ErrorMsg();
552 if (!$results->EOF
) {
553 $retval = $results->fields
['DOB'];
558 $retval = $this->_isodate($retval);
560 // if we generated an error, create an error return response
562 return $this->_handleError($err);
565 // otherwise, we create the right response
566 // with the state name
567 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
571 function dateofdeath($m) {
575 //Unimplimented by OpenEMR
578 // if we generated an error, create an error return response
580 return $this->_handleError($err);
583 // otherwise, we create the right response
584 // with the state name
585 return new xmlrpcresp(new xmlrpcval($pkey,XMLRPCDATETIME
));
594 $obj= $m->getparam(0);
595 $key = $obj->getval();
597 $sql = "SELECT * FROM patient_data where pid = '" . $key . "'";
599 $db = $GLOBALS['adodb']['db'];
600 $results = $db->Execute($sql);
603 $err = $db->ErrorMsg();
606 if (!$results->EOF
) {
607 $retval = $results->fields
['sex'];
610 if (strtolower($retval) == "male") {
613 elseif (strtolower($retval) == "female") {
617 // if we generated an error, create an error return response
619 return $this->_handleError($err);
622 // otherwise, we create the right response
623 // with the state name
624 return new xmlrpcresp(new xmlrpcval($retval,"string"));
630 function issingle($m) {
635 $obj= $m->getparam(0);
636 $key = $obj->getval();
638 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
640 $db = $GLOBALS['adodb']['db'];
641 $results = $db->Execute($sql);
644 $err = $db->ErrorMsg();
647 if (!$results->EOF
) {
648 $retval = $results->fields
['status'];
652 if ($retval == "single") {
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($retval,"i4"));
670 function ismarried($m) {
675 $obj= $m->getparam(0);
676 $key = $obj->getval();
678 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
680 $db = $GLOBALS['adodb']['db'];
681 $results = $db->Execute($sql);
684 $err = $db->ErrorMsg();
687 if (!$results->EOF
) {
688 $retval = $results->fields
['status'];
692 if ($retval == "married") {
700 // if we generated an error, create an error return response
702 return $this->_handleError($err);
705 // otherwise, we create the right response
706 // with the state name
707 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
711 function ismaritalotherhcfa($m) {
716 $obj= $m->getparam(0);
717 $key = $obj->getval();
719 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
721 $db = $GLOBALS['adodb']['db'];
722 $results = $db->Execute($sql);
725 $err = $db->ErrorMsg();
728 if (!$results->EOF
) {
729 $retval = $results->fields
['status'];
733 if ($retval == "domestic partner") {
741 // if we generated an error, create an error return response
743 return $this->_handleError($err);
746 // otherwise, we create the right response
747 // with the state name
748 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
752 function isemployed($m) {
757 $obj= $m->getparam(0);
758 $key = $obj->getval();
760 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
762 $db = $GLOBALS['adodb']['db'];
763 $results = $db->Execute($sql);
766 $err = $db->ErrorMsg();
769 if (!$results->EOF
) {
770 $retval = $results->fields
['occupation'];
774 if ($retval == "Unemployed" ||
empty($retval)) {
782 // if we generated an error, create an error return response
784 return $this->_handleError($err);
787 // otherwise, we create the right response
788 // with the state name
789 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
793 function isfulltimestudent($m) {
798 $obj= $m->getparam(0);
799 $key = $obj->getval();
801 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
803 $db = $GLOBALS['adodb']['db'];
804 $results = $db->Execute($sql);
807 $err = $db->ErrorMsg();
810 if (!$results->EOF
) {
811 $retval = $results->fields
['occupation'];
815 if (strtolower($retval) == "student") {
822 // if we generated an error, create an error return response
824 return $this->_handleError($err);
827 // otherwise, we create the right response
828 // with the state name
829 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
833 function isparttimestudent($m) {
838 $obj= $m->getparam(0);
839 $key = $obj->getval();
841 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
843 $db = $GLOBALS['adodb']['db'];
844 $results = $db->Execute($sql);
847 $err = $db->ErrorMsg();
850 if (!$results->EOF
) {
851 $retval = $results->fields
['occupation'];
855 if (strtolower($retval) == "pt student") {
863 // if we generated an error, create an error return response
865 return $this->_handleError($err);
868 // otherwise, we create the right response
869 // with the state name
870 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
874 function ischildofinsured($m) {
879 $obj= $m->getparam(0);
880 $key = $obj->getval();
881 $obj= $m->getparam(1);
882 $key2 = $obj->getval();
883 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
885 $db = $GLOBALS['adodb']['db'];
886 $results = $db->Execute($sql);
889 $err = $db->ErrorMsg();
892 if (!$results->EOF
) {
893 $retval = $results->fields
['subscriber_relationship'];
897 if (strtolower($retval) == "child") {
904 // if we generated an error, create an error return response
906 return $this->_handleError($err);
909 // otherwise, we create the right response
910 // with the state name
911 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
915 function ishusbandofinsured($m) {
920 $obj= $m->getparam(0);
921 $key = $obj->getval();
922 $obj= $m->getparam(1);
923 $key2 = $obj->getval();
924 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
926 $db = $GLOBALS['adodb']['db'];
927 $results = $db->Execute($sql);
930 $err = $db->ErrorMsg();
933 if (!$results->EOF
) {
934 $retval = $results->fields
['subscriber_relationship'];
938 if (strtolower($retval) == "spouse") {
946 // if we generated an error, create an error return response
948 return $this->_handleError($err);
951 // otherwise, we create the right response
952 // with the state name
953 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
957 function iswifeofinsured($m) {
962 $obj= $m->getparam(0);
963 $key = $obj->getval();
964 $obj= $m->getparam(1);
965 $key2 = $obj->getval();
966 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
968 $db = $GLOBALS['adodb']['db'];
969 $results = $db->Execute($sql);
972 $err = $db->ErrorMsg();
975 if (!$results->EOF
) {
976 $retval = $results->fields
['subscriber_relationship'];
980 if (strtolower($retval) == "spouse" && $results->fields
['sex'] == "male") {
988 // if we generated an error, create an error return response
990 return $this->_handleError($err);
993 // otherwise, we create the right response
994 // with the state name
995 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
999 function isdivorceeofinsured($m) {
1004 $obj= $m->getparam(0);
1005 $key = $obj->getval();
1006 $obj= $m->getparam(1);
1007 $key2 = $obj->getval();
1008 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
1010 $db = $GLOBALS['adodb']['db'];
1011 $results = $db->Execute($sql);
1014 $err = $db->ErrorMsg();
1017 if (!$results->EOF
) {
1018 $retval = $results->fields
['subscriber_relationship'];
1022 if (strtolower($retval) == "divorcee") {
1030 // if we generated an error, create an error return response
1032 return $this->_handleError($err);
1035 // otherwise, we create the right response
1036 // with the state name
1037 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
1041 function isselfofinsured($m) {
1046 $obj= $m->getparam(0);
1047 $key = $obj->getval();
1048 $obj= $m->getparam(1);
1049 $key2 = $obj->getval();
1050 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
1052 $db = $GLOBALS['adodb']['db'];
1053 $results = $db->Execute($sql);
1056 $err = $db->ErrorMsg();
1059 if (!$results->EOF
) {
1060 $retval = $results->fields
['subscriber_relationship'];
1064 if (strtolower($retval) == "self") {
1072 // if we generated an error, create an error return response
1074 return $this->_handleError($err);
1077 // otherwise, we create the right response
1078 // with the state name
1079 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
1083 function isotherofinsured($m) {
1088 $obj= $m->getparam(0);
1089 $key = $obj->getval();
1090 $obj= $m->getparam(1);
1091 $key2 = $obj->getval();
1092 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
1094 $db = $GLOBALS['adodb']['db'];
1095 $results = $db->Execute($sql);
1098 $err = $db->ErrorMsg();
1101 if (!$results->EOF
) {
1102 $retval = $results->fields
['subscriber_relationship'];
1106 if (strtolower($retval) == "other") {
1114 // if we generated an error, create an error return response
1116 return $this->_handleError($err);
1119 // otherwise, we create the right response
1120 // with the state name
1121 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
1125 function socialsecuritynumber($m) {
1130 $obj= $m->getparam(0);
1131 $key = $obj->getval();
1133 $sql = "SELECT * FROM patient_data where pid = '" . $_SESSION['patient_id'] . "'";
1135 $db = $GLOBALS['adodb']['db'];
1136 $results = $db->Execute($sql);
1139 $err = $db->ErrorMsg();
1142 if (!$results->EOF
) {
1143 $retval = $results->fields
['ss'];
1147 // if we generated an error, create an error return response
1149 return $this->_handleError($err);
1152 // otherwise, we create the right response
1153 // with the state name
1154 return new xmlrpcresp(new xmlrpcval($pkey));
1159 function coveragecount($m) {
1163 //unimplemented in OpenEMR
1166 // if we generated an error, create an error return response
1168 return $this->_handleError($err);
1171 // otherwise, we create the right response
1172 // with the state name
1173 return new xmlrpcresp(new xmlrpcval($pkey));
1177 function x12insuredrelationship($m) {
1180 $obj= $m->getparam(0);
1181 $patientkey = $obj->getval();
1183 $obj= $m->getparam(1);
1184 $insuredkey = $obj->getval();
1187 $obj= $m->getparam(0);
1188 $key = $obj->getval();
1189 $obj= $m->getparam(1);
1190 $key2 = $obj->getval();
1191 $sql = "SELECT * FROM insurance_data where pid = '" . $key . "' AND id = '" . $key2 . "'";
1193 $db = $GLOBALS['adodb']['db'];
1194 $results = $db->Execute($sql);
1197 $err = $db->ErrorMsg();
1200 if (!$results->EOF
) {
1201 $retval = $results->fields
['subscriber_relationship'];
1205 if (strtolower($retval) == "self") {
1208 elseif (strtolower($retval) == "spouse") {
1211 elseif (strtolower($retval) == "child") {
1214 elseif (strtolower($retval) == "other") {
1219 * For Reference these values are currently in use, we only support a subset
1221 * 04 Grandfather or Grandmother
1222 * 05 Grandson or Granddaughter
1223 * 07 Nephew or Niece
1227 * 17 Stepson or Stepdaughter
1231 * 22 Handicapped Dependent
1232 * 23 Sponsored Dependent
1233 * 24 Dependent of a Minor Dependent
1234 * 29 Significant Other
1238 * 36 Emancipated Minor
1241 * 41 Injured Plaintiff
1242 * 43 Child Where Insured Has No Financial Responsibility
1244 * G8 Other Relationship
1248 // if we generated an error, create an error return response
1250 return $this->_handleError($err);
1253 // otherwise, we create the right response
1254 // with the state name
1255 return new xmlrpcresp(new xmlrpcval($retval,"string"));
1259 function x12secondarymedicarecode($m) {
1263 //unimplemented in OpenEMR
1267 * For future reference values can be:
1268 *12 Medicare Secondary Working Aged Beneficiary or Spouse with Employer Group Health Plan
1269 *13 Medicare Secondary End-Stage Renal Disease Beneficiary in the 12 month coordination period with an employer's group health plan
1270 *14 Medicare Secondary, No-fault Insurance including Auto is Primary
1271 *15 Medicare Secondary Worker's Compensation
1272 *16 Medicare Secondary Public Health Service (PHS)or Other Federal Agency
1273 *41 Medicare Secondary Black Lung
1274 *42 Medicare Secondary Veteran's Administration
1275 *43 Medicare Secondary Disabled Beneficiary Under Age 65 with Large Group Health Plan (LGHP)
1276 *47 Medicare Secondary, Other Liability Insurance is Primary
1279 // if we generated an error, create an error return response
1281 return $this->_handleError($err);
1284 // otherwise, we create the right response
1285 // with the state name
1286 return new xmlrpcresp(new xmlrpcval($pkey));
1290 function ispregnant($m) {
1294 //unimplemented in OpenEMR
1297 // if we generated an error, create an error return response
1299 return $this->_handleError($err);
1302 // otherwise, we create the right response
1303 // with the state name
1304 return new xmlrpcresp(new xmlrpcval($pkey));
1308 function insuredkey($m) {
1311 $obj= $m->getparam(0);
1312 $patientkey = $obj->getval();
1314 $obj= $m->getparam(1);
1315 $instype = $obj->getval();
1319 // TBD: This needs to compensate for the encounter date which is not given
1320 // to us, but we are getting rid of freeb anyway. Also I'm not sure this
1321 // function is even used; Procedure::InsuredKey seems to be used instead.
1322 $sql = "SELECT id FROM insurance_data WHERE pid = '$patientkey' AND " .
1323 "type = '$instype' ORDER BY date DESC LIMIT 1";
1325 $db = $GLOBALS['adodb']['db'];
1326 $results = $db->Execute($sql);
1329 $err = $db->ErrorMsg();
1332 if (!$results->EOF
) {
1333 $retval = $results->fields
['id'];
1338 return $this->_handleError($err);
1341 return new xmlrpcresp(new xmlrpcval($retval, "i4"));
1347 //'FreeB.FBPatient.FirstName' => \&FreeB_FBPatient_FirstName,
1348 //'FreeB.FBPatient.MiddleName' => \&FreeB_FBPatient_MiddleName,
1349 //'FreeB.FBPatient.LastName' => \&FreeB_FBPatient_LastName,
1350 //'FreeB.FBPatient.StreetAddress' => \&FreeB_FBPatient_StreetAddres,
1351 //'FreeB.FBPatient.City' => \&FreeB_FBPatient_City,
1352 //'FreeB.FBPatient.Zipcode' => \&FreeB_FBPatient_Zipcode,
1353 //'FreeB.FBPatient.State' => \&FreeB_FBPatient_State,
1354 //'FreeB.FBPatient.PhoneCountry' => \&FreeB_FBPatient_PhoneCountry,
1355 //'FreeB.FBPatient.PhoneExtension' => \&FreeB_FBPatient_PhoneExtension,
1356 //'FreeB.FBPatient.PhoneArea' => \&FreeB_FBPatient_PhoneArea,
1357 //'FreeB.FBPatient.PhoneNumber' => \&FreeB_FBPatient_PhoneNumber,
1358 //'FreeB.FBPatient.Title' => \&FreeB_FBPatient_Title,
1359 //'FreeB.FBPatient.Account' => \&FreeB_FBPatient_Account,
1360 //'FreeB.FBPatient.isDead' => \&FreeB_FBPatient_isDead,
1361 //'FreeB.FBPatient.DateOfBirth' => \&FreeB_FBPatient_DateOfBirth,
1362 //'FreeB.FBPatient.DateOfDeath' => \&FreeB_FBPatient_DateOfDeath,
1363 //'FreeB.FBPatient.Sex' => \&FreeB_FBPatient_Sex,
1364 //'FreeB.FBPatient.isSingle' => \&FreeB_FBPatient_isSingle,
1365 //'FreeB.FBPatient.isMarried' => \&FreeB_FBPatient_isMarried,
1366 //'FreeB.FBPatient.isMaritalOtherHCFA' => \&FreeB_FBPatient_isMaritalOtherHCFA,
1367 //'FreeB.FBPatient.isEmployed' => \&FreeB_FBPatient_isEmployed,
1368 //'FreeB.FBPatient.isFullTimeStudent' => \&FreeB_FBPatient_isFullTimeStudent,
1369 //'FreeB.FBPatient.isPartTimeStudent' => \&FreeB_FBPatient_isPartTimeStudent,
1370 //'FreeB.FBPatient.isChildOfInsured' => \&FreeB_FBPatient_isChildOfInsured,
1371 //'FreeB.FBPatient.isHusbandOfInsured' => \&FreeB_FBPatient_isHusbandOfInsured,
1372 //'FreeB.FBPatient.isWifeOfInsured' => \&FreeB_FBPatient_isWifeOfInsured,
1373 //'FreeB.FBPatient.isDivorceeOfInsured' => \&FreeB_FBPatient_isDivorceeOfInsured,
1374 //'FreeB.FBPatient.isSelfOfInsured' => \&FreeB_FBPatient_isSelfOfInsured,
1375 //'FreeB.FBPatient.isOtherOfInsured' => \&FreeB_FBPatient_isOtherOfInsured,
1376 //'FreeB.FBPatient.ReferringProviderKey' => \&FreeB_FBPatient_ReferringProviderKey,
1377 //'FreeB.FBPatient.SocialSecurityNumber' => \&FreeB_FBPatient_SocialSecurityNumber,
1378 //'FreeB.FBPatient.CoverageCount' => \&FreeB_FBPatient_CoverageCount,
1379 //'FreeB.FBPatient.X12InsuredRelationship' => \&FreeB_FBPatient_X12InsuredRelationship,
1380 //'FreeB.FBPatient.isPregnant' => \&FreeB_FBPatient_isPregnant,