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
),
52 $obj= $m->getparam(0);
53 $key = $obj->getval();
55 $sql = "SELECT * FROM facility where id = '" . $key ."'";
57 $db = $GLOBALS['adodb']['db'];
58 $results = $db->Execute($sql);
61 $err = $db->ErrorMsg();
65 $retval = $results->fields
['name'];
69 // if we generated an error, create an error return response
71 return $this->_handleError($err);
74 // otherwise, we create the right response
75 // with the state name
76 return new xmlrpcresp(new xmlrpcval($retval,"string"));
80 function streetaddress($m) {
85 $obj= $m->getparam(0);
86 $key = $obj->getval();
88 $sql = "SELECT * FROM facility where id = '" . $key ."'";
90 $db = $GLOBALS['adodb']['db'];
91 $results = $db->Execute($sql);
94 $err = $db->ErrorMsg();
98 $retval = $results->fields
['street'];
102 // if we generated an error, create an error return response
104 return $this->_handleError($err);
107 // otherwise, we create the right response
108 // with the state name
109 return new xmlrpcresp(new xmlrpcval($retval,"string"));
119 $obj= $m->getparam(0);
120 $key = $obj->getval();
122 $sql = "SELECT * FROM facility where id = '" . $key ."'";
124 $db = $GLOBALS['adodb']['db'];
125 $results = $db->Execute($sql);
128 $err = $db->ErrorMsg();
131 if (!$results->EOF
) {
132 $retval = $results->fields
['city'];
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"));
151 $obj= $m->getparam(0);
152 $key = $obj->getval();
154 $sql = "SELECT * FROM facility where id = '" . $key ."'";
156 $db = $GLOBALS['adodb']['db'];
157 $results = $db->Execute($sql);
160 $err = $db->ErrorMsg();
163 if (!$results->EOF
) {
164 $retval = $results->fields
['state'];
168 // if we generated an error, create an error return response
170 return $this->_handleError($err);
173 // otherwise, we create the right response
174 // with the state name
175 return new xmlrpcresp(new xmlrpcval($retval,"string"));
178 function zipcode($m) {
183 $obj= $m->getparam(0);
184 $key = $obj->getval();
186 $sql = "SELECT * FROM facility where id = '" . $key ."'";
188 $db = $GLOBALS['adodb']['db'];
189 $results = $db->Execute($sql);
192 $err = $db->ErrorMsg();
195 if (!$results->EOF
) {
196 $retval = $results->fields
['postal_code'];
200 // if we generated an error, create an error return response
202 return $this->_handleError($err);
205 // otherwise, we create the right response
206 // with the state name
207 return new xmlrpcresp(new xmlrpcval($retval,"string"));
210 function phonecountry($m) {
214 //OpenEMR only supports a sinlge coutry code for phones
217 // if we generated an error, create an error return response
219 return $this->_handleError($err);
222 // otherwise, we create the right response
223 // with the state name
224 return new xmlrpcresp(new xmlrpcval($pkey));
228 function phoneextension($m) {
232 //unimplemented by OpenEMR
235 // if we generated an error, create an error return response
237 return $this->_handleError($err);
240 // otherwise, we create the right response
241 // with the state name
242 return new xmlrpcresp(new xmlrpcval($pkey));
246 function phonearea($m) {
251 $obj= $m->getparam(0);
252 $key = $obj->getval();
254 $sql = "SELECT * FROM facility where id = '" . $key ."'";
256 $db = $GLOBALS['adodb']['db'];
257 $results = $db->Execute($sql);
260 $err = $db->ErrorMsg();
263 if (!$results->EOF
) {
264 $retval = $results->fields
['phone'];
268 $phone_parts = array();
269 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
270 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
271 $retval = $phone_parts[1];
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"));
284 function phonenumber($m) {
289 $obj= $m->getparam(0);
290 $key = $obj->getval();
292 $sql = "SELECT * FROM facility where id = '" . $key ."'";
294 $db = $GLOBALS['adodb']['db'];
295 $results = $db->Execute($sql);
298 $err = $db->ErrorMsg();
301 if (!$results->EOF
) {
302 $retval = $results->fields
['phone'];
306 $phone_parts = array();
307 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
308 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
309 $retval = $phone_parts[2] . "-" . $phone_parts[3];
311 // if we generated an error, create an error return response
313 return $this->_handleError($err);
316 // otherwise, we create the right response
317 // with the state name
318 return new xmlrpcresp(new xmlrpcval($pkey));
322 function x12code($m) {
327 $obj= $m->getparam(0);
328 $key = $obj->getval();
330 $sql = "SELECT * FROM facility where id = '" . $key ."'";
332 $db = $GLOBALS['adodb']['db'];
333 $results = $db->Execute($sql);
336 $err = $db->ErrorMsg();
339 if (!$results->EOF
) {
340 $retval = $results->fields
['pos_code'];
344 // if we generated an error, create an error return response
346 return $this->_handleError($err);
349 // otherwise, we create the right response
350 // with the state name
351 return new xmlrpcresp(new xmlrpcval($retval));
355 function hcfacode($m) {
360 $obj= $m->getparam(0);
361 $key = $obj->getval();
363 $sql = "SELECT * FROM facility where id = '" . $key ."'";
365 $db = $GLOBALS['adodb']['db'];
366 $results = $db->Execute($sql);
369 $err = $db->ErrorMsg();
372 if (!$results->EOF
) {
373 $retval = $results->fields
['pos_code'];
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($retval,"i4"));
388 function cliacode($m) {
393 $obj= $m->getparam(0);
394 $key = $obj->getval();
396 $sql = "SELECT domain_identifier FROM facility where id = '" . $key ."'";
397 $db = $GLOBALS['adodb']['db'];
398 $results = $db->Execute($sql);
401 $err = $db->ErrorMsg();
404 if (!$results->EOF
) {
405 $retval = $results->fields
['domain_identifier'];
409 // if we generated an error, create an error return response
411 return $this->_handleError($err);
414 return new xmlrpcresp(new xmlrpcval($retval,"string"));
420 //'FreeB.FBFacility.Name' => \&FreeB_FBFacility_Name,
421 //'FreeB.FBFacility.StreetAddress' => \&FreeB_FBFacility_StreetAddress,
422 //'FreeB.FBFacility.City' => \&FreeB_FBFacility_City,
423 //'FreeB.FBFacility.State' => \&FreeB_FBFacility_State,
424 //'FreeB.FBFacility.Zipcode' => \&FreeB_FBFacility_Zipcode,
425 //'FreeB.FBFacility.PhoneNumber' => \&FreeB_FBFacility_PhoneNumber,
426 //'FreeB.FBFacility.PhoneCountry' => \&FreeB_FBFacility_PhoneCountry,
427 //'FreeB.FBFacility.PhoneExtension' => \&FreeB_FBFacility_PhoneExtension,
428 //'FreeB.FBFacility.PhoneArea' => \&FreeB_FBFacility_PhoneArea,
429 //'FreeB.FBFacility.X12Code' => \&FreeB_FBFacility_X12Code,
430 //'FreeB.FBFacility.HCFACode' => \&FreeB_FBFacility_HCFACode,