Bug fix for provider Insurance Numbers
[openemr.git] / library / classes / WSProvider.class.php
blobce67210afc5bfada7151fa37f040e501a8af8090
1 <?php
2 require_once(dirname(__FILE__) . "/../patient.inc");
3 include_once (dirname(__FILE__) . "/../sqlconf.php");
4 include_once (dirname(__FILE__) . "/../../includes/config.php");
6 class WSProvider extends WSWrapper{
8 var $user_id;
9 var $info;
10 var $_db;
12 function WSProvider($user_id) {
13 if (!is_numeric($user_id))
14 return;
16 parent::WSWrapper(null,false);
18 $this->user_id = $user_id;
19 $this->_db = $GLOBALS['adodb']['db'];
21 if (!$this->_config['enabled']) return;
22 if ($this->_config['enabled'] === 2) return;
24 if ($this->load_info()) {
25 $function['ezybiz.add_salesman'] = array(new xmlrpcval($this->data,"struct"));
26 $this->send($function);
28 // if the remote user was added make an entry in the local mapping table to that updates can be made correctly
29 if (is_numeric($this->value)) {
30 $sql = "REPLACE INTO integration_mapping set id = '" . $this->_db->GenID("sequences") . "', foreign_id ='" . $this->value . "', foreign_table ='salesman', local_id = '" . $this->user_id . "', local_table = 'users' ";
31 $this->_db->Execute($sql) or die ("error: " . $this->_db->ErrorMsg());
36 function load_info() {
37 $user_info = getProviderInfo($this->user_id);
39 if (count($user_info)) {
40 //returns array of arrays with 1 array
41 $user_info = $user_info[0];
43 $sql = "SELECT foreign_id,foreign_table FROM integration_mapping where local_table = 'users' and local_id = '" . $this->user_id . "'";
44 $result = $this->_db->Execute($sql);
45 if ($result && !$result->EOF) {
46 $user_info['foreign_update'] = true;
47 $user_info['foreign_id'] = $result->fields['foreign_id'];
48 $user_info['foreign_table'] = $result->fields['foreign_table'];
50 } else {
51 $this->data = array();
52 return false;
55 $this->data = $user_info;
56 return true;