minor bug fix
[openemr.git] / library / freeb / Payer.class.php
blobd13905c704af638ab59b2cccb9edcb186789e880
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
4 require_once(dirname(__FILE__) . "/../classes/InsuranceCompany.class.php");
6 class Payer Extends DataObjectBase {
8 function Payer() {
9 $this->_addFunc("ismedicare", array( "name" => "FreeB.FBPayer.isMedicare",
10 "sig" => array(XMLRPCSTRING,XMLRPCINT),
11 "doc" => ""));
12 $this->_addFunc("ismedicaid", array( "name" => "FreeB.FBPayer.isMedicaid",
13 "sig" => array(XMLRPCSTRING,XMLRPCINT),
14 "doc" => ""));
15 $this->_addFunc("ischampusva", array( "name" => "FreeB.FBPayer.isChampusva",
16 "sig" => array(XMLRPCSTRING,XMLRPCINT),
17 "doc" => ""));
18 $this->_addFunc("isbcbs", array( "name" => "FreeB.FBPayer.isBcbs",
19 "sig" => array(XMLRPCSTRING,XMLRPCINT),
20 "doc" => ""));
21 $this->_addFunc("isfeca", array( "name" => "FreeB.FBPayer.isFeca",
22 "sig" => array(XMLRPCSTRING,XMLRPCINT),
23 "doc" => ""));
24 $this->_addFunc("ischampus", array( "name" => "FreeB.FBPayer.isChampus",
25 "sig" => array(XMLRPCSTRING,XMLRPCINT),
26 "doc" => ""));
27 $this->_addFunc("isotherhcfa", array( "name" => "FreeB.FBPayer.isOtherHCFA",
28 "sig" => array(XMLRPCSTRING,XMLRPCINT),
29 "doc" => ""));
30 $this->_addFunc("nationalplanid", array( "name" => "FreeB.FBPayer.NationalPlanID",
31 "sig" => array(XMLRPCSTRING,XMLRPCINT),
32 "doc" => ""));
33 $this->_addFunc("id", array( "name" => "FreeB.FBPayer.ID",
34 "sig" => array(XMLRPCSTRING,XMLRPCINT),
35 "doc" => ""));
36 $this->_addFunc("name", array( "name" => "FreeB.FBPayer.Name",
37 "sig" => array(XMLRPCSTRING,XMLRPCINT),
38 "doc" => ""));
39 $this->_addFunc("attn", array( "name" => "FreeB.FBPayer.Attn",
40 "sig" => array(XMLRPCSTRING,XMLRPCINT),
41 "doc" => ""));
42 $this->_addFunc("streetaddress",array( "name" => "FreeB.FBPayer.StreetAddress",
43 "sig" => array(XMLRPCSTRING,XMLRPCINT),
44 "doc" => ""));
45 $this->_addFunc("city", array( "name" => "FreeB.FBPayer.City",
46 "sig" => array(XMLRPCSTRING,XMLRPCINT),
47 "doc" => ""));
48 $this->_addFunc("state", array( "name" => "FreeB.FBPayer.State",
49 "sig" => array(XMLRPCSTRING,XMLRPCINT),
50 "doc" => ""));
51 $this->_addFunc("zipcode", array( "name" => "FreeB.FBPayer.Zipcode",
52 "sig" => array(XMLRPCSTRING,XMLRPCINT),
53 "doc" => ""));
54 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBPayer.PhoneCountry",
55 "sig" => array(XMLRPCSTRING,XMLRPCINT),
56 "doc" => ""));
57 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBPayer.PhoneExtension",
58 "sig" => array(XMLRPCSTRING,XMLRPCINT),
59 "doc" => ""));
60 $this->_addFunc("phonearea", array( "name" => "FreeB.FBPayer.PhoneArea",
61 "sig" => array(XMLRPCSTRING,XMLRPCINT),
62 "doc" => ""));
63 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBPayer.PhoneNumber",
64 "sig" => array(XMLRPCSTRING,XMLRPCINT),
65 "doc" => ""));
66 $this->_addFunc("procedurecodeset", array( "name" => "FreeB.FBPayer.ProcedureCodeSet",
67 "sig" => array(XMLRPCSTRING,XMLRPCINT),
68 "doc" => ""));
69 $this->_addFunc("diagnosiscodeset", array( "name" => "FreeB.FBPayer.DiagnosisCodeSet",
70 "sig" => array(XMLRPCSTRING,XMLRPCINT),
71 "doc" => ""));
72 $this->_addFunc("ishcfacondensed", array( "name" => "FreeB.FBPayer.isHCFACondensed",
73 "sig" => array(XMLRPCSTRING,XMLRPCINT),
74 "doc" => ""));
75 $this->_addFunc("x12secondarymedicarecode", array( "name" => "FreeB.FBPayer.X12SecondaryMedicareCode",
76 "sig" => array(XMLRPCSTRING,XMLRPCSTRING),
77 "doc" => ""));
78 $this->_addFunc("x12claimtype", array( "name" => "FreeB.FBPayer.X12ClaimType",
79 "sig" => array(XMLRPCSTRING,XMLRPCINT),
80 "doc" => ""));
83 function ismedicare($m) {
85 $err="";
86 $retval = false;
87 $obj= $m->getparam(0);
88 $ikey = $obj->getval();
89 $ic = new InsuranceCompany($ikey);
90 $type = $ic->get_freeb_type();
92 //constants for types are defined in class InsuranceCompanies
93 if ($type == FREEB_TYPE_MEDICARE) {
94 $retval = true;
97 // if we generated an error, create an error return response
98 if ($err) {
99 return $this->_handleError($err);
101 else {
102 // otherwise, we create the right response
103 // with the state name
104 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
108 function ismedicaid($m) {
110 $err="";
112 $retval = false;
113 $obj= $m->getparam(0);
114 $ikey = $obj->getval();
115 $ic = new InsuranceCompany($ikey);
116 $type = $ic->get_freeb_type();
118 //constants for types are defined in class InsuranceCompanies
119 if ($type == FREEB_TYPE_MEDICAID) {
120 $retval = true;
123 // if we generated an error, create an error return response
124 if ($err) {
125 return $this->_handleError($err);
127 else {
128 // otherwise, we create the right response
129 // with the state name
130 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
134 function ischampusva($m) {
136 $err="";
138 $retval = false;
139 $obj= $m->getparam(0);
140 $ikey = $obj->getval();
141 $ic = new InsuranceCompany($ikey);
142 $type = $ic->get_freeb_type();
144 //constants for types are defined in class InsuranceCompanies
145 if ($type == FREEB_TYPE_CHAMPUSVA) {
146 $retval = true;
149 // if we generated an error, create an error return response
150 if ($err) {
151 return $this->_handleError($err);
153 else {
154 // otherwise, we create the right response
155 // with the state name
156 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
160 function isbcbs($m) {
162 $err="";
164 $retval = false;
165 $obj= $m->getparam(0);
166 $ikey = $obj->getval();
167 $ic = new InsuranceCompany($ikey);
168 $type = $ic->get_freeb_type();
170 //constants for types are defined in class InsuranceCompanies
171 if ($type == FREEB_TYPE_BCBS) {
172 $retval = true;
175 // if we generated an error, create an error return response
176 if ($err) {
177 return $this->_handleError($err);
179 else {
180 // otherwise, we create the right response
181 // with the state name
182 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
186 function isfeca($m) {
188 $err="";
190 $retval = false;
191 $obj= $m->getparam(0);
192 $ikey = $obj->getval();
193 $ic = new InsuranceCompany($ikey);
194 $type = $ic->get_freeb_type();
196 //constants for types are defined in class InsuranceCompanies
197 if ($type == FREEB_TYPE_FECA) {
198 $retval = true;
201 // if we generated an error, create an error return response
202 if ($err) {
203 return $this->_handleError($err);
205 else {
206 // otherwise, we create the right response
207 // with the state name
208 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
212 function ischampus($m) {
214 $err="";
216 $retval = false;
217 $obj= $m->getparam(0);
218 $ikey = $obj->getval();
219 $ic = new InsuranceCompany($ikey);
220 $type = $ic->get_freeb_type();
222 //constants for types are defined in class InsuranceCompanies
223 if ($type == FREEB_TYPE_CHAMPUS) {
224 $retval = true;
227 // if we generated an error, create an error return response
228 if ($err) {
229 return $this->_handleError($err);
231 else {
232 // otherwise, we create the right response
233 // with the state name
234 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
238 function isotherhcfa($m) {
240 $err="";
242 $retval = false;
243 $obj= $m->getparam(0);
244 $ikey = $obj->getval();
245 $ic = new InsuranceCompany($ikey);
246 $type = $ic->get_freeb_type();
248 //constants for types are defined in class InsuranceCompanies
249 if ($type == FREEB_TYPE_OTHER_HCFA) {
250 $retval = true;
253 // if we generated an error, create an error return response
254 if ($err) {
255 return $this->_handleError($err);
257 else {
258 // otherwise, we create the right response
259 // with the state name
260 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
264 function nationalplanid($m) {
266 $err="";
268 $retval = "";
269 $obj= $m->getparam(0);
270 $ikey = $obj->getval();
271 $ic = new InsuranceCompany($ikey);
272 $retval = $ic->get_cms_id();
274 //constants for types are defined in class InsuranceCompanies
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));
287 function id($m) {
289 $err="";
291 $retval ="";
292 $obj= $m->getparam(0);
293 $key = $obj->getval();
295 $sql = "SELECT * FROM insurance_companies where id='" . $key . "'";
296 //echo $sql;
297 $db = $GLOBALS['adodb']['db'];
298 $results = $db->Execute($sql);
300 if (!$results) {
301 $err = $db->ErrorMsg();
303 else {
304 if (!$results->EOF) {
305 $retval = $results->fields['cms_id'];
309 // if we generated an error, create an error return response
310 if ($err) {
311 return $this->_handleError($err);
313 else {
314 // otherwise, we create the right response
315 // with the state name
316 return new xmlrpcresp(new xmlrpcval($retval),"string");
320 function name($m) {
323 $err="";
325 $pkey = "";
327 $obj= $m->getparam(0);
328 $ikey = $obj->getval();
329 $ic = new InsuranceCompany($ikey);
330 $pkey = $ic->get_name();
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,"string"));
343 function attn($m) {
345 $err="";
346 $obj= $m->getparam(0);
347 $ikey = $obj->getval();
348 $ic = new InsuranceCompany($ikey);
349 $pkey = $ic->get_attn();
351 // if we generated an error, create an error return response
352 if ($err) {
353 return $this->_handleError($err);
355 else {
356 // otherwise, we create the right response
357 // with the state name
358 return new xmlrpcresp(new xmlrpcval($pkey,"string"));
362 function streetaddress($m) {
364 $err="";
366 $obj= $m->getparam(0);
367 $ikey = $obj->getval();
368 $ic = new InsuranceCompany($ikey);
369 $pkey = $ic->address->get_lines_display();
372 // if we generated an error, create an error return response
373 if ($err) {
374 return $this->_handleError($err);
376 else {
377 // otherwise, we create the right response
378 // with the state name
379 return new xmlrpcresp(new xmlrpcval($pkey));
382 function city($m) {
384 $err="";
387 $obj= $m->getparam(0);
388 $ikey = $obj->getval();
389 $ic = new InsuranceCompany($ikey);
390 $pkey = $ic->address->get_city();
392 // if we generated an error, create an error return response
393 if ($err) {
394 return $this->_handleError($err);
396 else {
397 // otherwise, we create the right response
398 // with the state name
399 return new xmlrpcresp(new xmlrpcval($pkey));
402 function state($m) {
404 $err="";
407 $obj= $m->getparam(0);
408 $ikey = $obj->getval();
409 $ic = new InsuranceCompany($ikey);
410 $pkey = $ic->address->get_state();
412 // if we generated an error, create an error return response
413 if ($err) {
414 return $this->_handleError($err);
416 else {
417 // otherwise, we create the right response
418 // with the state name
419 return new xmlrpcresp(new xmlrpcval($pkey));
422 function zipcode($m) {
424 $err="";
427 $obj= $m->getparam(0);
428 $ikey = $obj->getval();
429 $ic = new InsuranceCompany($ikey);
430 $pkey = $ic->address->get_zip();
432 // if we generated an error, create an error return response
433 if ($err) {
434 return $this->_handleError($err);
436 else {
437 // otherwise, we create the right response
438 // with the state name
439 return new xmlrpcresp(new xmlrpcval($pkey));
442 function phonecountry($m) {
444 $err="";
446 $obj= $m->getparam(0);
447 $ikey = $obj->getval();
448 $ic = new InsuranceCompany($ikey);
449 $pkey = $ic->phone->get_country_code();
451 // if we generated an error, create an error return response
452 if ($err) {
453 return $this->_handleError($err);
455 else {
456 // otherwise, we create the right response
457 // with the state name
458 return new xmlrpcresp(new xmlrpcval($pkey));
461 function phoneextension($m) {
463 $err="";
464 //unimplemented by openemr
465 $pkey = "";
467 // if we generated an error, create an error return response
468 if ($err) {
469 return $this->_handleError($err);
471 else {
472 // otherwise, we create the right response
473 // with the state name
474 return new xmlrpcresp(new xmlrpcval($pkey));
477 function phonearea($m) {
479 $err="";
482 $obj= $m->getparam(0);
483 $ikey = $obj->getval();
484 $ic = new InsuranceCompany($ikey);
485 $pkey = $ic->phone->get_area_code();
487 // if we generated an error, create an error return response
488 if ($err) {
489 return $this->_handleError($err);
491 else {
492 // otherwise, we create the right response
493 // with the state name
494 return new xmlrpcresp(new xmlrpcval($pkey));
497 function phonenumber($m) {
499 $err="";
502 $obj= $m->getparam(0);
503 $ikey = $obj->getval();
504 $ic = new InsuranceCompany($ikey);
505 $pkey = $ic->phone->get_number();
507 // if we generated an error, create an error return response
508 if ($err) {
509 return $this->_handleError($err);
511 else {
512 // otherwise, we create the right response
513 // with the state name
514 return new xmlrpcresp(new xmlrpcval($pkey));
518 function procedurecodeset($m) {
520 $err="";
522 //OpenEMR only supports CPT-4 at this time
523 //HCPCS support is almost fully developed
524 $pkey = "CPT-4";
526 // if we generated an error, create an error return response
527 if ($err) {
528 return $this->_handleError($err);
530 else {
531 // otherwise, we create the right response
532 // with the state name
533 return new xmlrpcresp(new xmlrpcval($pkey));
538 function diagnosiscodeset($m) {
540 $err="";
542 //OpenEMR only supports ICD9 diagnosis codes
543 $pkey = "ICD-9";
545 // if we generated an error, create an error return response
546 if ($err) {
547 return $this->_handleError($err);
549 else {
550 // otherwise, we create the right response
551 // with the state name
552 return new xmlrpcresp(new xmlrpcval($pkey));
556 function ishcfacondensed($m) {
558 $err="";
560 //defaults to uncondensed
561 $pkey = false;
563 // if we generated an error, create an error return response
564 if ($err) {
565 return $this->_handleError($err);
567 else {
568 // otherwise, we create the right response
569 // with the state name
570 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
575 function x12secondarymedicarecode($m) {
577 $err="";
579 //unsupported by OpenEMR
580 $pkey = "";
582 // if we generated an error, create an error return response
583 if ($err) {
584 return $this->_handleError($err);
586 else {
587 // otherwise, we create the right response
588 // with the state name
589 return new xmlrpcresp(new xmlrpcval($pkey));
593 function x12claimtype($m) {
595 $err="";
597 //type of payer determined by HIPAA, supposed to be superceded by PlanID at some point, I don't think yet 06/03/2004
599 $obj= $m->getparam(0);
600 $ikey = $obj->getval();
601 $ic = new InsuranceCompany($ikey);
602 $pkey = $ic->get_freeb_claim_type();
604 // if we generated an error, create an error return response
605 if ($err) {
606 return $this->_handleError($err);
608 else {
609 // otherwise, we create the right response
610 // with the state name
611 return new xmlrpcresp(new xmlrpcval($pkey));
622 //'FreeB.FBPayer.isMedicare' => \&FreeB_FBPayer_isMedicare,
623 //'FreeB.FBPayer.isMedicaid' => \&FreeB_FBPayer_isMedicaid,
624 //'FreeB.FBPayer.isChampusva' => \&FreeB_FBPayer_isChampusva,
625 //'FreeB.FBPayer.isBcbs' => \&FreeB_FBPayer_isBcbs,
626 //'FreeB.FBPayer.isFeca' => \&FreeB_FBPayer_isFeca,
627 //'FreeB.FBPayer.isChampus' => \&FreeB_FBPayer_isChampus,
628 //'FreeB.FBPayer.isOtherHCFA' => \&FreeB_FBPayer_isOtherHCFA,
629 //'FreeB.FBPayer.NationalPlanID' => \&FreeB_FBPayer_NationalPlanID,
630 //'FreeB.FBPayer.ID' => \&FreeB_FBPayer_ID,
631 //'FreeB.FBPayer.Name' => \&FreeB_FBPayer_Name,
632 //'FreeB.FBPayer.Attn' => \&FreeB_FBPayer_Attn,
633 //'FreeB.FBPayer.StreetAddress' => \&FreeB_FBPayer_Street,
634 //'FreeB.FBPayer.City' => \&FreeB_FBPayer_City,
635 //'FreeB.FBPayer.State' => \&FreeB_FBPayer_State,
636 //'FreeB.FBPayer.Zipcode' => \&FreeB_FBPayer_Zipcode,
637 //'FreeB.FBPayer.PhoneCountry' => \&FreeB_FBPayer_PhoneCountry,
638 //'FreeB.FBPayer.PhoneExtension' => \&FreeB_FBPayer_PhoneExtension,
639 //'FreeB.FBPayer.PhoneArea' => \&FreeB_FBPayer_PhoneArea,
640 //'FreeB.FBPayer.PhoneNumber' => \&FreeB_FBPayer_PhoneNumber,
641 //'FreeB.FBPayer.ProcedureCodeSet' => \&FreeB_FBPayer_ProcedureCodeSet,
642 //'FreeB.FBPayer.DiagnosisCodeSet' => \&FreeB_FBPayer_DiagnosisCodeSet,
643 //'FreeB.FBPayer.isHCFACondensed' => \&FreeB_FBPayer_isHCFACondensed,
644 //'FreeB.FBPayer.X12SecondaryMedicareCode' => \&FreeB_FBPayer_X12SecondaryMedicareCode,
645 //'FreeB.FBPayer.X12ClaimType' => \&FreeB_FBPayer_X12ClaimType,