allow a non-doc to authorize stuff if see_auth = all
[openemr.git] / library / freeb / Facility.class.php
blobad2807a39623bc29e8a898ccc39f9fcc4a0bdd64
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Facility Extends DataObjectBase {
7 function Facility() {
8 $this->_addFunc("name", array( "name" => "FreeB.FBFacility.Name",
9 "sig" => array(XMLRPCSTRING,XMLRPCINT),
10 "doc" => ""));
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBFacility.StreetAddress",
12 "sig" => array(XMLRPCSTRING,XMLRPCINT),
13 "doc" => ""));
14 $this->_addFunc("city", array( "name" => "FreeB.FBFacility.City",
15 "sig" => array(XMLRPCSTRING,XMLRPCINT),
16 "doc" => ""));
17 $this->_addFunc("state", array( "name" => "FreeB.FBFacility.State",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBFacility.Zipcode",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBFacility.PhoneCountry",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBFacility.PhoneExtension",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBFacility.PhoneArea",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBFacility.PhoneNumber",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("x12code", array( "name" => "FreeB.FBFacility.X12Code",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("hcfacode", array( "name" => "FreeB.FBFacility.HCFACode",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
41 $this->_addFunc("cliacode", array( "name" => "FreeB.FBFacility.CLIACode",
42 "sig" => array(XMLRPCSTRING,XMLRPCINT),
43 "doc" => ""));
47 function name($m) {
49 $err="";
51 $retval = "";
52 $obj= $m->getparam(0);
53 $key = $obj->getval();
55 $sql = "SELECT * FROM facility where id = '" . $key ."'";
56 //echo $sql;
57 $db = $GLOBALS['adodb']['db'];
58 $results = $db->Execute($sql);
60 if (!$results) {
61 $err = $db->ErrorMsg();
63 else {
64 if (!$results->EOF) {
65 $retval = $results->fields['name'];
69 // if we generated an error, create an error return response
70 if ($err) {
71 return $this->_handleError($err);
73 else {
74 // otherwise, we create the right response
75 // with the state name
76 return new xmlrpcresp(new xmlrpcval($retval,"string"));
80 function streetaddress($m) {
82 $err="";
84 $retval = "";
85 $obj= $m->getparam(0);
86 $key = $obj->getval();
88 $sql = "SELECT * FROM facility where id = '" . $key ."'";
89 //echo $sql;
90 $db = $GLOBALS['adodb']['db'];
91 $results = $db->Execute($sql);
93 if (!$results) {
94 $err = $db->ErrorMsg();
96 else {
97 if (!$results->EOF) {
98 $retval = $results->fields['street'];
102 // if we generated an error, create an error return response
103 if ($err) {
104 return $this->_handleError($err);
106 else {
107 // otherwise, we create the right response
108 // with the state name
109 return new xmlrpcresp(new xmlrpcval($retval,"string"));
114 function city($m) {
116 $err="";
118 $retval = "";
119 $obj= $m->getparam(0);
120 $key = $obj->getval();
122 $sql = "SELECT * FROM facility where id = '" . $key ."'";
123 //echo $sql;
124 $db = $GLOBALS['adodb']['db'];
125 $results = $db->Execute($sql);
127 if (!$results) {
128 $err = $db->ErrorMsg();
130 else {
131 if (!$results->EOF) {
132 $retval = $results->fields['city'];
136 // if we generated an error, create an error return response
137 if ($err) {
138 return $this->_handleError($err);
140 else {
141 // otherwise, we create the right response
142 // with the state name
143 return new xmlrpcresp(new xmlrpcval($retval,"string"));
146 function state($m) {
148 $err="";
150 $retval = "";
151 $obj= $m->getparam(0);
152 $key = $obj->getval();
154 $sql = "SELECT * FROM facility where id = '" . $key ."'";
155 //echo $sql;
156 $db = $GLOBALS['adodb']['db'];
157 $results = $db->Execute($sql);
159 if (!$results) {
160 $err = $db->ErrorMsg();
162 else {
163 if (!$results->EOF) {
164 $retval = $results->fields['state'];
168 // if we generated an error, create an error return response
169 if ($err) {
170 return $this->_handleError($err);
172 else {
173 // otherwise, we create the right response
174 // with the state name
175 return new xmlrpcresp(new xmlrpcval($retval,"string"));
178 function zipcode($m) {
180 $err="";
182 $retval = "";
183 $obj= $m->getparam(0);
184 $key = $obj->getval();
186 $sql = "SELECT * FROM facility where id = '" . $key ."'";
187 //echo $sql;
188 $db = $GLOBALS['adodb']['db'];
189 $results = $db->Execute($sql);
191 if (!$results) {
192 $err = $db->ErrorMsg();
194 else {
195 if (!$results->EOF) {
196 $retval = $results->fields['postal_code'];
200 // if we generated an error, create an error return response
201 if ($err) {
202 return $this->_handleError($err);
204 else {
205 // otherwise, we create the right response
206 // with the state name
207 return new xmlrpcresp(new xmlrpcval($retval,"string"));
210 function phonecountry($m) {
212 $err="";
214 //OpenEMR only supports a sinlge coutry code for phones
215 $pkey = "1";
217 // if we generated an error, create an error return response
218 if ($err) {
219 return $this->_handleError($err);
221 else {
222 // otherwise, we create the right response
223 // with the state name
224 return new xmlrpcresp(new xmlrpcval($pkey));
228 function phoneextension($m) {
230 $err="";
232 //unimplemented by OpenEMR
233 $pkey = "";
235 // if we generated an error, create an error return response
236 if ($err) {
237 return $this->_handleError($err);
239 else {
240 // otherwise, we create the right response
241 // with the state name
242 return new xmlrpcresp(new xmlrpcval($pkey));
246 function phonearea($m) {
248 $err="";
250 $retval = "";
251 $obj= $m->getparam(0);
252 $key = $obj->getval();
254 $sql = "SELECT * FROM facility where id = '" . $key ."'";
255 //echo $sql;
256 $db = $GLOBALS['adodb']['db'];
257 $results = $db->Execute($sql);
259 if (!$results) {
260 $err = $db->ErrorMsg();
262 else {
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
274 if ($err) {
275 return $this->_handleError($err);
277 else {
278 // otherwise, we create the right response
279 // with the state name
280 return new xmlrpcresp(new xmlrpcval($retval,"string"));
284 function phonenumber($m) {
286 $err="";
288 $retval = "";
289 $obj= $m->getparam(0);
290 $key = $obj->getval();
292 $sql = "SELECT * FROM facility where id = '" . $key ."'";
293 //echo $sql;
294 $db = $GLOBALS['adodb']['db'];
295 $results = $db->Execute($sql);
297 if (!$results) {
298 $err = $db->ErrorMsg();
300 else {
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
312 if ($err) {
313 return $this->_handleError($err);
315 else {
316 // otherwise, we create the right response
317 // with the state name
318 return new xmlrpcresp(new xmlrpcval($pkey));
322 function x12code($m) {
324 $err="";
326 $retval = "";
327 $obj= $m->getparam(0);
328 $key = $obj->getval();
330 $sql = "SELECT * FROM facility where id = '" . $key ."'";
331 //echo $sql;
332 $db = $GLOBALS['adodb']['db'];
333 $results = $db->Execute($sql);
335 if (!$results) {
336 $err = $db->ErrorMsg();
338 else {
339 if (!$results->EOF) {
340 $retval = $results->fields['pos_code'];
344 // if we generated an error, create an error return response
345 if ($err) {
346 return $this->_handleError($err);
348 else {
349 // otherwise, we create the right response
350 // with the state name
351 return new xmlrpcresp(new xmlrpcval($retval));
355 function hcfacode($m) {
357 $err="";
359 $retval = "";
360 $obj= $m->getparam(0);
361 $key = $obj->getval();
363 $sql = "SELECT * FROM facility where id = '" . $key ."'";
364 //echo $sql;
365 $db = $GLOBALS['adodb']['db'];
366 $results = $db->Execute($sql);
368 if (!$results) {
369 $err = $db->ErrorMsg();
371 else {
372 if (!$results->EOF) {
373 $retval = $results->fields['pos_code'];
377 // if we generated an error, create an error return response
378 if ($err) {
379 return $this->_handleError($err);
381 else {
382 // otherwise, we create the right response
383 // with the state name
384 return new xmlrpcresp(new xmlrpcval($retval,"i4"));
388 function cliacode($m) {
390 $err="";
392 $retval = "";
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);
400 if (!$results) {
401 $err = $db->ErrorMsg();
403 else {
404 if (!$results->EOF) {
405 $retval = $results->fields['domain_identifier'];
409 // if we generated an error, create an error return response
410 if ($err) {
411 return $this->_handleError($err);
413 else {
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,