Highway to PSR2
[openemr.git] / myportal / soap_service / portal_connectivity.php
blobccd95ed377291f89776f3093f1676cef959df529
1 <?php
2 /**
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>;.
18 * @package OpenEMR
19 * @author Eldho Chacko <eldho@zhservices.com>
20 * @author Vinish K <vinish@zhservices.com>
21 * @link http://www.open-emr.org
24 function portal_connection()
26 global $credentials;
27 $password = $GLOBALS['portal_offsite_password'];
28 $randkey = '';
29 $timminus = date("Y-m-d H:m", (strtotime(date("Y-m-d H:m"))-7200)).":00";
30 sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<=?)", array($timminus));
31 sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<=?", array($timminus));
32 do {
33 $randkey = substr(md5(rand().rand()), 0, 8);
34 $res = sqlStatement("SELECT * FROM audit_details WHERE field_value = ?", array($randkey));
35 $cnt = sqlNumRows($res);
36 } while ($cnt>0);
37 $password = sha1($password.gmdate("Y-m-d H").$randkey);
38 $grpID = sqlInsert("INSERT INTO audit_master SET type=5");
39 sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?", array($randkey,$grpID));
40 $credentials = array($GLOBALS['portal_offsite_username'],$password,$randkey);
41 //CALLING WEBSERVICE ON THE PATIENT-PORTAL
42 $client = new SoapClient(null, array(
43 'location' => $GLOBALS['portal_offsite_address_patient_link']."/webservice/webserver.php",
44 'uri' => "urn://portal/req"
45 ));
46 return $client;