fixed bug in setting pid
[openemr.git] / library / freeb / BillingService.class.php
blob0a8bbf059cfbec840909b61b710af514c630a296
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class BillingService Extends DataObjectBase {
7 function BillingService() {
8 $this->_addFunc("name", array( "name" => "FreeB.FBBillingService.Name",
9 "sig" => array(XMLRPCSTRING,XMLRPCINT),
10 "doc" => ""));
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBBillingService.StreetAddress",
12 "sig" => array(XMLRPCSTRING,XMLRPCINT),
13 "doc" => ""));
14 $this->_addFunc("city", array( "name" => "FreeB.FBBillingService.City",
15 "sig" => array(XMLRPCSTRING,XMLRPCINT),
16 "doc" => ""));
17 $this->_addFunc("state", array( "name" => "FreeB.FBBillingService.State",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBBillingService.Zipcode",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBBillingService.PhoneCountry",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBBillingService.PhoneExtension",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBBillingService.PhoneArea",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBBillingService.PhoneNumber",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("etin", array( "name" => "FreeB.FBBillingService.ETIN",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("tin", array( "name" => "FreeB.FBBillingService.TIN",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
44 function name($m) {
46 $err="";
48 $obj= $m->getparam(0);
49 $key = $obj->getval();
51 $sql = "SELECT * FROM facility where billing_location = '1'";
52 //echo $sql;
53 $db = $GLOBALS['adodb']['db'];
54 $results = $db->Execute($sql);
56 if (!$results) {
57 $err = $db->ErrorMsg();
59 else {
60 if (!$results->EOF) {
61 $retval = $results->fields['name'];
65 // if we generated an error, create an error return response
66 if ($err) {
67 return $this->_handleError($err);
69 else {
70 // otherwise, we create the right response
71 // with the state name
72 return new xmlrpcresp(new xmlrpcval($retval));
76 function streetaddress($m) {
78 $err="";
80 $obj= $m->getparam(0);
81 $key = $obj->getval();
83 $sql = "SELECT * FROM facility where billing_location = '1'";
84 //echo $sql;
85 $db = $GLOBALS['adodb']['db'];
86 $results = $db->Execute($sql);
88 if (!$results) {
89 $err = $db->ErrorMsg();
91 else {
92 if (!$results->EOF) {
93 $retval = $results->fields['street'];
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));
109 function city($m) {
111 $err="";
114 $obj= $m->getparam(0);
115 $key = $obj->getval();
117 $sql = "SELECT * FROM facility where billing_location = '1'";
118 //echo $sql;
119 $db = $GLOBALS['adodb']['db'];
120 $results = $db->Execute($sql);
122 if (!$results) {
123 $err = $db->ErrorMsg();
125 else {
126 if (!$results->EOF) {
127 $retval = $results->fields['city'];
131 // if we generated an error, create an error return response
132 if ($err) {
133 return $this->_handleError($err);
135 else {
136 // otherwise, we create the right response
137 // with the state name
138 return new xmlrpcresp(new xmlrpcval($retval));
142 function state($m) {
144 $err="";
147 $obj= $m->getparam(0);
148 $key = $obj->getval();
150 $sql = "SELECT * FROM facility where billing_location = '1'";
151 //echo $sql;
152 $db = $GLOBALS['adodb']['db'];
153 $results = $db->Execute($sql);
155 if (!$results) {
156 $err = $db->ErrorMsg();
158 else {
159 if (!$results->EOF) {
160 $retval = $results->fields['state'];
164 // if we generated an error, create an error return response
165 if ($err) {
166 return $this->_handleError($err);
168 else {
169 // otherwise, we create the right response
170 // with the state name
171 return new xmlrpcresp(new xmlrpcval($retval));
175 function zipcode($m) {
177 $err="";
179 $obj= $m->getparam(0);
180 $key = $obj->getval();
182 $sql = "SELECT * FROM facility where billing_location = '1'";
183 //echo $sql;
184 $db = $GLOBALS['adodb']['db'];
185 $results = $db->Execute($sql);
187 if (!$results) {
188 $err = $db->ErrorMsg();
190 else {
191 if (!$results->EOF) {
192 $retval = $results->fields['postal_code'];
196 // if we generated an error, create an error return response
197 if ($err) {
198 return $this->_handleError($err);
200 else {
201 // otherwise, we create the right response
202 // with the state name
203 return new xmlrpcresp(new xmlrpcval($retval));
207 function phonecountry($m) {
209 $err="";
211 //unimplemented by OpenEMR
212 $pkey = "1";
214 // if we generated an error, create an error return response
215 if ($err) {
216 return $this->_handleError($err);
218 else {
219 // otherwise, we create the right response
220 // with the state name
221 return new xmlrpcresp(new xmlrpcval($pkey));
225 function phoneextension($m) {
227 $err="";
229 //unimplemented by OpenEMR
230 $pkey = "";
232 // if we generated an error, create an error return response
233 if ($err) {
234 return $this->_handleError($err);
236 else {
237 // otherwise, we create the right response
238 // with the state name
239 return new xmlrpcresp(new xmlrpcval($pkey));
243 function phonearea($m) {
245 $err="";
247 $sql = "SELECT * FROM facility where billing_location = '1'";
248 //echo $sql;
249 $db = $GLOBALS['adodb']['db'];
250 $results = $db->Execute($sql);
252 if (!$results) {
253 $err = $db->ErrorMsg();
255 else {
256 if (!$results->EOF) {
257 $retval = $results->fields['phone'];
261 $phone_parts = array();
262 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
263 $retval = $phone_parts[1];
265 // if we generated an error, create an error return response
266 if ($err) {
267 return $this->_handleError($err);
269 else {
270 // otherwise, we create the right response
271 // with the state name
272 return new xmlrpcresp(new xmlrpcval($retval));
276 function phonenumber($m) {
278 $err="";
280 $obj= $m->getparam(0);
281 $key = $obj->getval();
283 $sql = "SELECT * FROM facility where billing_location = '1'";
284 //echo $sql;
285 $db = $GLOBALS['adodb']['db'];
286 $results = $db->Execute($sql);
288 if (!$results) {
289 $err = $db->ErrorMsg();
291 else {
292 if (!$results->EOF) {
293 $retval = $results->fields['phone'];
297 $phone_parts = array();
298 preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
299 $retval = $phone_parts[2] . "-" . $phone_parts[3];
301 // if we generated an error, create an error return response
302 if ($err) {
303 return $this->_handleError($err);
305 else {
306 // otherwise, we create the right response
307 // with the state name
308 return new xmlrpcresp(new xmlrpcval($retval));
312 function etin($m) {
314 $err="";
316 $obj= $m->getparam(0);
317 $key = $obj->getval();
319 $sql = "SELECT * FROM facility where billing_location = 1";
320 //echo $sql;
321 $db = $GLOBALS['adodb']['db'];
322 $results = $db->Execute($sql);
324 $vals = array();
325 if (!$results) {
326 $err = $db->ErrorMsg();
328 else {
329 if (!$results->EOF) {
330 $retval = $results->fields['federal_ein'];
335 // if we generated an error, create an error return response
336 if ($err) {
337 return $this->_handleError($err);
339 else {
340 // otherwise, we create the right response
341 // with the state name
342 return new xmlrpcresp(new xmlrpcval($retval));
346 function tin($m) {
348 $err="";
350 $obj= $m->getparam(0);
351 $key = $obj->getval();
353 $sql = "SELECT * FROM facility where billing_location = 1";
354 //echo $sql;
355 $db = $GLOBALS['adodb']['db'];
356 $results = $db->Execute($sql);
358 $vals = array();
359 if (!$results) {
360 $err = $db->ErrorMsg();
362 else {
363 if (!$results->EOF) {
364 $retval = $results->fields['federal_ein'];
369 // if we generated an error, create an error return response
370 if ($err) {
371 return $this->_handleError($err);
373 else {
374 // otherwise, we create the right response
375 // with the state name
376 return new xmlrpcresp(new xmlrpcval($retval));
382 //'FreeB.FBBillingService.Name' => \&FreeB_FBBillingService_Name,
383 //'FreeB.FBBillingService.StreetAddress' => \&FreeB_FBBillingService_StreetAddress,
384 //'FreeB.FBBillingService.City' => \&FreeB_FBBillingService_City,
385 //'FreeB.FBBillingService.State' => \&FreeB_FBBillingService_State,
386 //'FreeB.FBBillingService.Zipcode' => \&FreeB_FBBillingService_Zipcode,
387 //'FreeB.FBBillingService.PhoneCountry' => \&FreeB_FBBillingService_PhoneCountry,
388 //'FreeB.FBBillingService.PhoneExtension' => \&FreeB_FBBillingService_PhoneExtension,
389 //'FreeB.FBBillingService.PhoneArea' => \&FreeB_FBBillingService_PhoneArea,
390 //'FreeB.FBBillingService.PhoneNumber' => \&FreeB_FBBillingService_PhoneNumber,
391 //'FreeB.FBBillingService.ETIN' => \&FreeB_FBBillingService_ETIN,
392 //'FreeB.FBBillingService.TIN' => \&FreeB_FBBillingService_TIN,