3 * Offsite Portal connection function library.
5 * Copyright (C) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author Eldho Chacko <eldho@zhservices.com>
20 * @author Vinish K <vinish@zhservices.com>
21 * @link http://www.open-emr.org
24 //SANITIZE ALL ESCAPES
25 $sanitize_all_escapes=true;
28 //STOP FAKE REGISTER GLOBALS
29 $fake_register_globals=false;
31 function portal_connection(){
33 $password = $GLOBALS['portal_offsite_password'];
35 $timminus = date("Y-m-d H:m",(strtotime(date("Y-m-d H:m"))-7200)).":00";
36 sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<=?)",array($timminus));
37 sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<=?",array($timminus));
39 $randkey = substr(md5(rand().rand()), 0, 8);
40 $res = sqlStatement("SELECT * FROM audit_details WHERE field_value = ?",array($randkey));
41 $cnt = sqlNumRows($res);
44 $password = sha1($password.gmdate("Y-m-d H").$randkey);
45 $grpID = sqlInsert("INSERT INTO audit_master SET type=5");
46 sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?",array($randkey,$grpID));
47 $credentials = array($GLOBALS['portal_offsite_username'],$password,$randkey);
48 //CALLING WEBSERVICE ON THE PATIENT-PORTAL
49 $client = new SoapClient(null, array(
50 'location' => $GLOBALS['portal_offsite_address_patient_link']."/webservice/webserver.php",
51 'uri' => "urn://portal/req"