2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Facility
Extends DataObjectBase
{
8 $this->_addFunc("name", array( "name" => "FreeB.FBFacility.Name",
9 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBFacility.StreetAddress",
12 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
14 $this->_addFunc("city", array( "name" => "FreeB.FBFacility.City",
15 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
17 $this->_addFunc("state", array( "name" => "FreeB.FBFacility.State",
18 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBFacility.Zipcode",
21 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBFacility.PhoneCountry",
24 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBFacility.PhoneExtension",
27 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBFacility.PhoneArea",
30 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBFacility.PhoneNumber",
33 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
35 $this->_addFunc("x12code", array( "name" => "FreeB.FBFacility.X12Code",
36 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCINT
),
38 $this->_addFunc("hcfacode", array( "name" => "FreeB.FBFacility.HCFACode",
39 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
41 $this->_addFunc("cliacode", array( "name" => "FreeB.FBFacility.CLIACode",
42 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
44 $this->_addFunc("npi", array( "name" => "FreeB.FBFacility.NPI",
45 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
55 $obj= $m->getparam(0);
56 $key = $obj->getval();
58 $sql = "SELECT * FROM facility where id = '" . $key ."'";
60 $db = $GLOBALS['adodb']['db'];
61 $results = $db->Execute($sql);
64 $err = $db->ErrorMsg();
68 $retval = $results->fields
['name'];
72 // if we generated an error, create an error return response
74 return $this->_handleError($err);
77 // otherwise, we create the right response
78 // with the state name
79 return new xmlrpcresp(new xmlrpcval($retval,"string"));
83 function streetaddress($m) {
88 $obj= $m->getparam(0);
89 $key = $obj->getval();
91 $sql = "SELECT * FROM facility where id = '" . $key ."'";
93 $db = $GLOBALS['adodb']['db'];
94 $results = $db->Execute($sql);
97 $err = $db->ErrorMsg();
100 if (!$results->EOF
) {
101 $retval = $results->fields
['street'];
105 // if we generated an error, create an error return response
107 return $this->_handleError($err);
110 // otherwise, we create the right response
111 // with the state name
112 return new xmlrpcresp(new xmlrpcval($retval,"string"));
122 $obj= $m->getparam(0);
123 $key = $obj->getval();
125 $sql = "SELECT * FROM facility where id = '" . $key ."'";
127 $db = $GLOBALS['adodb']['db'];
128 $results = $db->Execute($sql);
131 $err = $db->ErrorMsg();
134 if (!$results->EOF
) {
135 $retval = $results->fields
['city'];
139 // if we generated an error, create an error return response
141 return $this->_handleError($err);
144 // otherwise, we create the right response
145 // with the state name
146 return new xmlrpcresp(new xmlrpcval($retval,"string"));
154 $obj= $m->getparam(0);
155 $key = $obj->getval();
157 $sql = "SELECT * FROM facility where id = '" . $key ."'";
159 $db = $GLOBALS['adodb']['db'];
160 $results = $db->Execute($sql);
163 $err = $db->ErrorMsg();
166 if (!$results->EOF
) {
167 $retval = $results->fields
['state'];
171 // if we generated an error, create an error return response
173 return $this->_handleError($err);
176 // otherwise, we create the right response
177 // with the state name
178 return new xmlrpcresp(new xmlrpcval($retval,"string"));
181 function zipcode($m) {
186 $obj= $m->getparam(0);
187 $key = $obj->getval();
189 $sql = "SELECT * FROM facility where id = '" . $key ."'";
191 $db = $GLOBALS['adodb']['db'];
192 $results = $db->Execute($sql);
195 $err = $db->ErrorMsg();
198 if (!$results->EOF
) {
199 $retval = $results->fields
['postal_code'];
203 // if we generated an error, create an error return response
205 return $this->_handleError($err);
208 // otherwise, we create the right response
209 // with the state name
210 return new xmlrpcresp(new xmlrpcval($retval,"string"));
213 function phonecountry($m) {
217 //OpenEMR only supports a sinlge coutry code for phones
220 // if we generated an error, create an error return response
222 return $this->_handleError($err);
225 // otherwise, we create the right response
226 // with the state name
227 return new xmlrpcresp(new xmlrpcval($pkey));
231 function phoneextension($m) {
235 //unimplemented by OpenEMR
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($pkey));
249 function phonearea($m) {
254 $obj= $m->getparam(0);
255 $key = $obj->getval();
257 $sql = "SELECT * FROM facility where id = '" . $key ."'";
259 $db = $GLOBALS['adodb']['db'];
260 $results = $db->Execute($sql);
263 $err = $db->ErrorMsg();
266 if (!$results->EOF
) {
267 $retval = $results->fields
['phone'];
271 $phone_parts = array();
272 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
273 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
274 $retval = $phone_parts[1];
276 // if we generated an error, create an error return response
278 return $this->_handleError($err);
281 // otherwise, we create the right response
282 // with the state name
283 return new xmlrpcresp(new xmlrpcval($retval,"string"));
287 function phonenumber($m) {
292 $obj= $m->getparam(0);
293 $key = $obj->getval();
295 $sql = "SELECT * FROM facility 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
['phone'];
309 $phone_parts = array();
310 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
311 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
312 $retval = $phone_parts[2] . "-" . $phone_parts[3];
314 // if we generated an error, create an error return response
316 return $this->_handleError($err);
319 // otherwise, we create the right response
320 // with the state name
321 return new xmlrpcresp(new xmlrpcval($pkey));
325 function x12code($m) {
330 $obj= $m->getparam(0);
331 $key = $obj->getval();
333 $sql = "SELECT * FROM facility where id = '" . $key ."'";
335 $db = $GLOBALS['adodb']['db'];
336 $results = $db->Execute($sql);
339 $err = $db->ErrorMsg();
342 if (!$results->EOF
) {
343 $retval = $results->fields
['pos_code'];
347 // if we generated an error, create an error return response
349 return $this->_handleError($err);
352 // otherwise, we create the right response
353 // with the state name
354 return new xmlrpcresp(new xmlrpcval($retval));
358 function hcfacode($m) {
363 $obj= $m->getparam(0);
364 $key = $obj->getval();
366 $sql = "SELECT * FROM facility where id = '" . $key ."'";
368 $db = $GLOBALS['adodb']['db'];
369 $results = $db->Execute($sql);
372 $err = $db->ErrorMsg();
375 if (!$results->EOF
) {
376 $retval = $results->fields
['pos_code'];
380 // if we generated an error, create an error return response
382 return $this->_handleError($err);
385 // otherwise, we create the right response
386 // with the state name
387 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
391 function cliacode($m) {
396 $obj= $m->getparam(0);
397 $key = $obj->getval();
399 $sql = "SELECT domain_identifier FROM facility where id = '" . $key ."'";
400 $db = $GLOBALS['adodb']['db'];
401 $results = $db->Execute($sql);
404 $err = $db->ErrorMsg();
407 if (!$results->EOF
) {
408 $retval = $results->fields
['domain_identifier'];
412 // if we generated an error, create an error return response
414 return $this->_handleError($err);
417 return new xmlrpcresp(new xmlrpcval($retval,"string"));
425 $obj= $m->getparam(0);
426 $key = $obj->getval();
428 $sql = "SELECT * FROM facility where id = '" . $key ."'";
430 $db = $GLOBALS['adodb']['db'];
431 $results = $db->Execute($sql);
434 $err = $db->ErrorMsg();
437 if (!$results->EOF
) {
438 $retval = $results->fields
['facility_npi'];
442 // if we generated an error, create an error return response
444 return $this->_handleError($err);
447 // otherwise, we create the right response
448 // with the state name
449 return new xmlrpcresp(new xmlrpcval($retval,"string"));
456 //'FreeB.FBFacility.Name' => \&FreeB_FBFacility_Name,
457 //'FreeB.FBFacility.StreetAddress' => \&FreeB_FBFacility_StreetAddress,
458 //'FreeB.FBFacility.City' => \&FreeB_FBFacility_City,
459 //'FreeB.FBFacility.State' => \&FreeB_FBFacility_State,
460 //'FreeB.FBFacility.Zipcode' => \&FreeB_FBFacility_Zipcode,
461 //'FreeB.FBFacility.PhoneNumber' => \&FreeB_FBFacility_PhoneNumber,
462 //'FreeB.FBFacility.PhoneCountry' => \&FreeB_FBFacility_PhoneCountry,
463 //'FreeB.FBFacility.PhoneExtension' => \&FreeB_FBFacility_PhoneExtension,
464 //'FreeB.FBFacility.PhoneArea' => \&FreeB_FBFacility_PhoneArea,
465 //'FreeB.FBFacility.X12Code' => \&FreeB_FBFacility_X12Code,
466 //'FreeB.FBFacility.HCFACode' => \&FreeB_FBFacility_HCFACode,
467 //'FreeB.FBFacility.NPI => \&FreeB_FBFacility_NPI