2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Practice
Extends DataObjectBase
{
8 $this->_addFunc("name", array( "name" => "FreeB.FBPractice.Name",
9 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBPractice.StreetAddress",
12 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
14 $this->_addFunc("city", array( "name" => "FreeB.FBPractice.City",
15 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
17 $this->_addFunc("state", array( "name" => "FreeB.FBPractice.State",
18 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBPractice.Zipcode",
21 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBPractice.PhoneCountry",
24 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBPractice.PhoneExtension",
27 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBPractice.PhoneArea",
30 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBPractice.PhoneNumber",
33 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
35 $this->_addFunc("isacceptsassignment", array( "name" => "FreeB.FBPractice.isAcceptsAssignment",
36 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
38 $this->_addFunc("tin", array( "name" => "FreeB.FBPractice.TIN",
39 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
41 $this->_addFunc("npi", array( "name" => "FreeB.FBPractice.NPI",
42 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
44 $this->_addFunc("practiceid", array( "name" => "FreeB.FBPractice.PracticeID",
45 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
47 $this->_addFunc("renderingpracticeid", array( "name" => "FreeB.FBPractice.RenderingPracticeID",
48 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
50 $this->_addFunc("groupid", array( "name" => "FreeB.FBPractice.GroupID",
51 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
53 $this->_addFunc("providernumx12type", array( "name" => "FreeB.FBPractice.ProviderNumX12Type",
54 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
56 $this->_addFunc("renderingnumx12type", array( "name" => "FreeB.FBPractice.RenderingNumX12Type",
57 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
,XMLRPCINT
),
59 $this->_addFunc("x12id", array( "name" => "FreeB.FBPractice.X12Id",
60 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
70 $obj= $m->getparam(0);
71 $key = $obj->getval();
73 $sql = "SELECT * FROM facility where billing_location = '1'";
75 $db = $GLOBALS['adodb']['db'];
76 $results = $db->Execute($sql);
79 $err = $db->ErrorMsg();
83 $retval = $results->fields
['name'];
87 // if we generated an error, create an error return response
89 return $this->_handleError($err);
92 // otherwise, we create the right response
93 // with the state name
94 return new xmlrpcresp(new xmlrpcval($retval,""));
98 function streetaddress($m) {
102 $obj= $m->getparam(0);
103 $key = $obj->getval();
105 $sql = "SELECT * FROM facility where billing_location = '1'";
107 $db = $GLOBALS['adodb']['db'];
108 $results = $db->Execute($sql);
111 $err = $db->ErrorMsg();
114 if (!$results->EOF
) {
115 $retval = $results->fields
['street'];
119 // if we generated an error, create an error return response
121 return $this->_handleError($err);
124 // otherwise, we create the right response
125 // with the state name
126 return new xmlrpcresp(new xmlrpcval($retval,"string"));
135 $obj= $m->getparam(0);
136 $key = $obj->getval();
138 $sql = "SELECT * FROM facility where billing_location = '1'";
140 $db = $GLOBALS['adodb']['db'];
141 $results = $db->Execute($sql);
144 $err = $db->ErrorMsg();
147 if (!$results->EOF
) {
148 $retval = $results->fields
['city'];
152 // if we generated an error, create an error return response
154 return $this->_handleError($err);
157 // otherwise, we create the right response
158 // with the state name
159 return new xmlrpcresp(new xmlrpcval($retval,"string"));
167 $obj= $m->getparam(0);
168 $key = $obj->getval();
170 $sql = "SELECT * FROM facility where billing_location = '1'";
172 $db = $GLOBALS['adodb']['db'];
173 $results = $db->Execute($sql);
176 $err = $db->ErrorMsg();
179 if (!$results->EOF
) {
180 $retval = $results->fields
['state'];
184 // if we generated an error, create an error return response
186 return $this->_handleError($err);
189 // otherwise, we create the right response
190 // with the state name
191 return new xmlrpcresp(new xmlrpcval($retval,"string"));
195 function zipcode($m) {
199 $obj= $m->getparam(0);
200 $key = $obj->getval();
202 $sql = "SELECT * FROM facility where billing_location = '1'";
204 $db = $GLOBALS['adodb']['db'];
205 $results = $db->Execute($sql);
208 $err = $db->ErrorMsg();
211 if (!$results->EOF
) {
212 $retval = $results->fields
['postal_code'];
216 // if we generated an error, create an error return response
218 return $this->_handleError($err);
221 // otherwise, we create the right response
222 // with the state name
223 return new xmlrpcresp(new xmlrpcval($retval,"string"));
226 function phonecountry($m) {
232 // if we generated an error, create an error return response
234 return $this->_handleError($err);
237 // otherwise, we create the right response
238 // with the state name
239 return new xmlrpcresp(new xmlrpcval($pkey));
243 function phoneextension($m) {
247 //unimplemented by OpenEMR
250 // if we generated an error, create an error return response
252 return $this->_handleError($err);
255 // otherwise, we create the right response
256 // with the state name
257 return new xmlrpcresp(new xmlrpcval($pkey));
261 function phonearea($m) {
265 $obj= $m->getparam(0);
266 $key = $obj->getval();
268 $sql = "SELECT * FROM facility where billing_location = '1'";
270 $db = $GLOBALS['adodb']['db'];
271 $results = $db->Execute($sql);
274 $err = $db->ErrorMsg();
277 if (!$results->EOF
) {
278 $retval = $results->fields
['phone'];
282 $phone_parts = array();
283 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
284 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
285 $retval = $phone_parts[1];
287 // if we generated an error, create an error return response
289 return $this->_handleError($err);
292 // otherwise, we create the right response
293 // with the state name
294 return new xmlrpcresp(new xmlrpcval($retval,"string"));
298 function phonenumber($m) {
302 $obj= $m->getparam(0);
303 $key = $obj->getval();
305 $sql = "SELECT * FROM facility where billing_location = '1'";
307 $db = $GLOBALS['adodb']['db'];
308 $results = $db->Execute($sql);
311 $err = $db->ErrorMsg();
314 if (!$results->EOF
) {
315 $retval = $results->fields
['phone'];
319 $phone_parts = array();
320 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
321 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
322 $retval = $phone_parts[2] . "-" . $phone_parts[3];
324 // if we generated an error, create an error return response
326 return $this->_handleError($err);
329 // otherwise, we create the right response
330 // with the state name
331 return new xmlrpcresp(new xmlrpcval($retval,"string"));
335 function isacceptsassignment($m) {
339 $obj= $m->getparam(0);
340 $key = $obj->getval();
342 $sql = "SELECT * FROM facility where billing_location = '1'";
344 $db = $GLOBALS['adodb']['db'];
345 $results = $db->Execute($sql);
348 $err = $db->ErrorMsg();
351 if (!$results->EOF
) {
352 $retval = $results->fields
['accepts_assignment'];
356 // if we generated an error, create an error return response
358 return $this->_handleError($err);
361 // otherwise, we create the right response
362 // with the state name
363 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
368 * Returns a federal ein based on practice, payer, provider
369 * @key int practice identifier used in database, in OpenEMR practices are facilities
370 * @payerkey int database id of the insurance company
371 * @providekey int database id of the provider
378 $obj= $m->getparam(0);
379 $key = $obj->getval();
381 $obj= $m->getparam(1);
382 $payerkey = $obj->getval();
384 $obj= $m->getparam(2);
385 $providerkey = $obj->getval();
387 $sql = "SELECT * FROM facility where billing_location = 1";
389 $db = $GLOBALS['adodb']['db'];
390 $results = $db->Execute($sql);
394 $err = $db->ErrorMsg();
397 if (!$results->EOF
) {
398 $retval = $results->fields
['federal_ein'];
403 // if we generated an error, create an error return response
405 return $this->_handleError($err);
408 // otherwise, we create the right response
409 // with the state name
410 return new xmlrpcresp(new xmlrpcval($retval,"string"));
415 function practiceid($m) {
419 $obj= $m->getparam(0);
420 $key = $obj->getval();
422 $obj= $m->getparam(1);
423 $payerkey = $obj->getval();
425 $obj= $m->getparam(2);
426 $providerkey = $obj->getval();
428 //this query gets the exact match or resorts to the default when no exact is found (default has a NULL value for insurance_company_id)
429 $sql = "SELECT * FROM insurance_numbers where (insurance_company_id = '$payerkey' OR insurance_company_id is NULL) AND provider_id = '$providerkey' order by insurance_company_id DESC";
431 $db = $GLOBALS['adodb']['db'];
432 $results = $db->Execute($sql);
436 $err = $db->ErrorMsg();
439 while (!$results->EOF
) {
440 $vals[] = $results->fields
['provider_number'];
441 $results->MoveNext();
445 //if there is an exact match or not match and only the default then set it here
446 if (!empty($vals[0])) {
450 //if the exact match was empty for a provider number reference the default which is 1 because the nifty query and sorting above
454 // if we generated an error, create an error return response
456 return $this->_handleError($err);
459 // otherwise, we create the right response
460 // with the state name
461 return new xmlrpcresp(new xmlrpcval($retval,"string"));
465 function renderingpracticeid($m) {
469 $obj= $m->getparam(0);
470 $key = $obj->getval();
472 $obj= $m->getparam(1);
473 $payerkey = $obj->getval();
475 $obj= $m->getparam(2);
476 $providerkey = $obj->getval();
478 //this query gets the exact match or resorts to the default when no exact is found (default has a NULL value for insurance_company_id)
479 $sql = "SELECT * FROM insurance_numbers where (insurance_company_id = '$payerkey' OR insurance_company_id is NULL) AND provider_id = '$providerkey' order by insurance_company_id DESC";
481 $db = $GLOBALS['adodb']['db'];
482 $results = $db->Execute($sql);
486 $err = $db->ErrorMsg();
489 while (!$results->EOF
) {
490 $vals[] = $results->fields
['rendering_provider_number'];
491 $results->MoveNext();
495 //if there is an exact match or not match and only the default then set it here
496 if (!empty($vals[0])) {
500 //if the exact match was empty for a provider number reference the default which is 1 because the nifty query and sorting above
504 // if we generated an error, create an error return response
506 return $this->_handleError($err);
509 // otherwise, we create the right response
510 // with the state name
511 return new xmlrpcresp(new xmlrpcval($retval,"string"));
515 function groupid($m) {
519 $obj= $m->getparam(0);
520 $key = $obj->getval();
522 $obj= $m->getparam(1);
523 $payerkey = $obj->getval();
525 $obj= $m->getparam(2);
526 $providerkey = $obj->getval();
528 //this query gets the exact match or resorts to the default when no exact is found (default has a NULL value for insurance_company_id)
529 $sql = "SELECT * FROM insurance_numbers where (insurance_company_id = '$payerkey' OR insurance_company_id is NULL) AND provider_id = '$providerkey' order by insurance_company_id DESC";
531 $db = $GLOBALS['adodb']['db'];
532 $results = $db->Execute($sql);
536 $err = $db->ErrorMsg();
539 while (!$results->EOF
) {
540 $vals[] = $results->fields
['group_number'];
541 $results->MoveNext();
545 if (!empty($vals[0])) {
549 //if the exact match was empty for a group number reference the default which is 1 because the nifty query and sorting above
554 // if we generated an error, create an error return response
556 return $this->_handleError($err);
559 // otherwise, we create the right response
560 // with the state name
561 return new xmlrpcresp(new xmlrpcval($retval,"string"));
565 function providernumx12type($m) {
569 $obj= $m->getparam(0);
570 $key = $obj->getval();
572 $obj= $m->getparam(1);
573 $payerkey = $obj->getval();
575 $obj= $m->getparam(2);
576 $providerkey = $obj->getval();
578 //this query gets the exact match or resorts to the default when no exact is found (default has a NULL value for insurance_company_id)
579 $sql = "SELECT * FROM insurance_numbers where (insurance_company_id = '$payerkey' OR insurance_company_id is NULL) AND provider_id = '$providerkey' order by insurance_company_id DESC";
581 $db = $GLOBALS['adodb']['db'];
582 $results = $db->Execute($sql);
586 $err = $db->ErrorMsg();
589 while (!$results->EOF
) {
590 $vals[] = $results->fields
['provider_number_type'];
591 $results->MoveNext();
595 //if there is an exact match or not match and only the default then set it here
596 if (!empty($vals[0])) {
600 //if the exact match was empty for a provider number reference the default which is 1 because the nifty query and sorting above
604 // if we generated an error, create an error return response
606 return $this->_handleError($err);
609 // otherwise, we create the right response
610 // with the state name
611 return new xmlrpcresp(new xmlrpcval($retval));
615 function renderingnumx12type($m) {
619 $obj= $m->getparam(0);
620 $key = $obj->getval();
622 $obj= $m->getparam(1);
623 $payerkey = $obj->getval();
625 $obj= $m->getparam(2);
626 $providerkey = $obj->getval();
628 //this query gets the exact match or resorts to the default when no exact is found (default has a NULL value for insurance_company_id)
629 $sql = "SELECT * FROM insurance_numbers where (insurance_company_id = '$payerkey' OR insurance_company_id is NULL) AND provider_id = '$providerkey' order by insurance_company_id DESC";
631 $db = $GLOBALS['adodb']['db'];
632 $results = $db->Execute($sql);
636 $err = $db->ErrorMsg();
639 while (!$results->EOF
) {
640 $vals[] = $results->fields
['rendering_provider_number_type'];
641 $results->MoveNext();
645 //if there is an exact match or not match and only the default then set it here
646 if (!empty($vals[0])) {
650 //if the exact match was empty for a provider number reference the default which is 1 because the nifty query and sorting above
654 // if we generated an error, create an error return response
656 return $this->_handleError($err);
659 // otherwise, we create the right response
660 // with the state name
661 return new xmlrpcresp(new xmlrpcval($retval));
670 $obj= $m->getparam(0);
671 $key = $obj->getval();
673 $sql = "SELECT * FROM facility where billing_location = 1";
675 $db = $GLOBALS['adodb']['db'];
676 $results = $db->Execute($sql);
680 $err = $db->ErrorMsg();
683 if (!$results->EOF
) {
684 $retval = $results->fields
['federal_ein'];
689 // if we generated an error, create an error return response
691 return $this->_handleError($err);
694 // otherwise, we create the right response
695 // with the state name
696 return new xmlrpcresp(new xmlrpcval($retval));
704 $obj= $m->getparam(0);
705 $key = $obj->getval();
707 $obj= $m->getparam(1);
708 $payerkey = $obj->getval();
710 $obj= $m->getparam(2);
711 $providerkey = $obj->getval();
713 $sql = "SELECT * FROM facility where billing_location = 1";
715 $db = $GLOBALS['adodb']['db'];
716 $results = $db->Execute($sql);
720 $err = $db->ErrorMsg();
723 if (!$results->EOF
) {
724 $retval = $results->fields
['facility_npi'];
729 // if we generated an error, create an error return response
731 return $this->_handleError($err);
734 // otherwise, we create the right response
735 // with the state name
736 return new xmlrpcresp(new xmlrpcval($retval,"string"));
744 //'FreeB.FBPractice.Name' => \&FreeB_FBPractice_Name,
745 //'FreeB.FBPractice.StreetAddress' => \&FreeB_FBPractice_StreetAddress,
746 //'FreeB.FBPractice.City' => \&FreeB_FBPractice_City,
747 //'FreeB.FBPractice.State' => \&FreeB_FBPractice_State,
748 //'FreeB.FBPractice.Zipcode' => \&FreeB_FBPractice_Zipcode,
749 //'FreeB.FBPractice.PhoneCountry' => \&FreeB_FBPractice_PhoneCountry,
750 //'FreeB.FBPractice.PhoneExtension' => \&FreeB_FBPractice_PhoneExtension,
751 //'FreeB.FBPractice.PhoneNumber' => \&FreeB_FBPractice_PhoneNumber,
752 //'FreeB.FBPractice.PhoneArea' => \&FreeB_FBPractice_PhoneArea,
753 //'FreeB.FBPractice.isAcceptsAssignment' => \&FreeB_FBPractice_isAcceptsAssignment,
754 //'FreeB.FBPractice.PracticeID' => \&FreeB_FBPractice_PracticeID,
755 //'FreeB.FBPractice.RenderingPracticeID' => \&FreeB_FBPractice_RenderingPracticeID,
756 //'FreeB.FBPractice.GroupID' => \&FreeB_FBPractice_GroupID,
757 //'FreeB.FBPractice.TIN' => \&FreeB_FBPractice_TIN,
758 //'FreeB.FBPractice.NPI' => \&FreeB_FBPractice_NPI,
759 //'FreeB.FBPractice.ProviderNumX12Type' => \&FreeB_FBPractice_ProviderNumX12Type,
760 //'FreeB.FBPractice.RenderingNumX12Type' => \&FreeB_FBPractice_RenderingNumX12Type,
761 //'FreeB.FBPractice.X12Id' => \&FreeB_FBPractice_X12Id,