Пример #1
0
 public function insert_authorizenet_details($var)
 {
     global $pid;
     $data_credentials = $var[0];
     if (UserService::valid($data_credentials)) {
         $authorizenetid = $var['authorizenetid'];
         $query = "UPDATE patient_access_offsite SET authorize_net_id = ? WHERE pid = ?";
         sqlInsert($query, array($authorizenetid, $pid));
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }
Пример #2
0
 public function insert_audit_master($var)
 {
     global $pid;
     $data_credentials = $var[0];
     if (UserService::valid($data_credentials)) {
         $approval_status = $var['approval_status'];
         $type = $var['type'];
         $ip_address = $var['ip_address'];
         $master_query = "INSERT INTO audit_master SET\n\t\t       pid = ?,\n\t\t       approval_status = ?,\n\t\t       ip_address = ?,\n\t\t       type =?";
         $audit_master_id = sqlInsert($master_query, array($pid, $approval_status, $ip_address, $type));
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }
Пример #3
0
 public function updateStatus($data)
 {
     if (UserService::valid($data[0]) == 'existingpatient') {
         require_once "../../library/pnotes.inc";
         foreach ($data[1] as $id) {
             updatePnoteMessageStatus($id, $data[2]);
         }
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }
Пример #4
0
 function transmitCCD($data = array())
 {
     $ccd = $data['ccd'];
     $recipient = $data['recipient'];
     $requested_by = $data['requested_by'];
     $xml_type = $data['xml_type'];
     if (UserService::valid($data[0]) == 'existingpatient') {
         try {
             $_SESSION['authProvider'] = 1;
             global $pid;
             //get patient name in Last_First format (used for CCDA filename) and
             //First Last for the message text.
             $patientData = getPatientPID(array("pid" => $pid));
             if (empty($patientData[0]['lname'])) {
                 $att_filename = "";
                 $patientName2 = "";
             } else {
                 //spaces are the argument delimiter for the phiMail API calls and must be removed
                 $extension = $xml_type == 'CCDA' ? 'xml' : strtolower($xml_type);
                 $att_filename = " " . str_replace(" ", "_", $xml_type . "_" . $patientData[0]['lname'] . "_" . $patientData[0]['fname']) . "." . $extension;
                 $patientName2 = $patientData[0]['fname'] . " " . $patientData[0]['lname'];
             }
             $config_err = xl("Direct messaging is currently unavailable.") . " EC:";
             if ($GLOBALS['phimail_enable'] == false) {
                 return "{$config_err} 1";
             }
             $fp = phimail_connect($err);
             if ($fp === false) {
                 return "{$config_err} {$err}";
             }
             $phimail_username = $GLOBALS['phimail_username'];
             $phimail_password = $GLOBALS['phimail_password'];
             $ret = phimail_write_expect_OK($fp, "AUTH {$phimail_username} {$phimail_password}\n");
             if ($ret !== TRUE) {
                 return "{$config_err} 4";
             }
             $ret = phimail_write_expect_OK($fp, "TO {$recipient}\n");
             if ($ret !== TRUE) {
                 return xl("Delivery is not allowed to the specified Direct Address.");
             }
             $ret = fgets($fp, 1024);
             //ignore extra server data
             if ($requested_by == "patient") {
                 $text_out = xl("Delivery of the attached clinical document was requested by the patient") . ($patientName2 == "" ? "." : ", " . $patientName2 . ".");
             } else {
                 $text_out = xl("A clinical document is attached") . ($patientName2 == "" ? "." : " " . xl("for patient") . " " . $patientName2 . ".");
             }
             $text_len = strlen($text_out);
             phimail_write($fp, "TEXT {$text_len}\n");
             $ret = @fgets($fp, 256);
             if ($ret != "BEGIN\n") {
                 phimail_close($fp);
                 return "{$config_err} 5";
             }
             $ret = phimail_write_expect_OK($fp, $text_out);
             if ($ret !== TRUE) {
                 return "{$config_err} 6";
             }
             if (in_array($xml_type, array('CCR', 'CCDA', 'CDA'))) {
                 $ccd = simplexml_load_string($ccd);
                 $ccd_out = $ccd->saveXml();
                 $ccd_len = strlen($ccd_out);
                 phimail_write($fp, "ADD " . ($xml_type == "CCR" ? $xml_type . ' ' : "CDA ") . $ccd_len . $att_filename . "\n");
                 //phimail_write($fp,"ADD " . (isset($xml_type) ? $xml_type . ' ' : "CDA ") . $ccd_len . $att_filename . "\n");
             } else {
                 if (strtolower($xml_type) == 'html' || strtolower($xml_type) == 'pdf') {
                     $ccd_out = base64_decode($ccd);
                     $message_length = strlen($ccd_out);
                     $add_type = strtolower($xml_type) == 'html' ? 'TEXT' : 'RAW';
                     phimail_write($fp, "ADD " . $add_type . " " . $message_length . "" . $att_filename . "\n");
                 }
             }
             $ret = fgets($fp, 256);
             if ($ret != "BEGIN\n") {
                 phimail_close($fp);
                 return "{$config_err} 7";
             }
             $ret = phimail_write_expect_OK($fp, $ccd_out);
             if ($ret !== TRUE) {
                 return "{$config_err} 8";
             }
             phimail_write($fp, "SEND\n");
             $ret = fgets($fp, 256);
             phimail_close($fp);
             if ($requested_by == "patient") {
                 $reqBy = "portal-user";
                 $sql = "SELECT id FROM users WHERE username='******'";
                 if (($r = sqlStatement($sql)) === FALSE || ($u = sqlFetchArray($r)) === FALSE) {
                     $reqID = 1;
                     //default if we don't have a service user
                 } else {
                     $reqID = $u['id'];
                 }
             } else {
                 $reqBy = $_SESSION['authUser'];
                 $reqID = $_SESSION['authUserID'];
             }
             if (substr($ret, 5) == "ERROR") {
                 //log the failure
                 newEvent("transmit-ccd", $reqBy, $_SESSION['authProvider'], 0, $ret, $pid);
                 return xl("The message could not be sent at this time.");
             }
             /**
              * If we get here, the message was successfully sent and the return
              * value $ret is of the form "QUEUED recipient message-id" which
              * is suitable for logging. 
              */
             $msg_id = explode(" ", trim($ret), 4);
             if ($msg_id[0] != "QUEUED" || !isset($msg_id[2])) {
                 //unexpected response
                 $ret = "UNEXPECTED RESPONSE: " . $ret;
                 newEvent("transmit-ccd", $reqBy, $_SESSION['authProvider'], 0, $ret, $pid);
                 return xl("There was a problem sending the message.");
             }
             newEvent("transmit-" . $xml_type, $reqBy, $_SESSION['authProvider'], 1, $ret, $pid);
             $adodb = $GLOBALS['adodb']['db'];
             //            $sql="INSERT INTO direct_message_log (msg_type,msg_id,sender,recipient,status,status_ts,patient_id,user_id) " .
             //             "VALUES ('S', ?, ?, ?, 'S', NOW(), ?, ?)";
             //            $res=@sqlStatement($sql,array($msg_id[2],$phimail_username,$recipient,$pid,$reqID));
             return "SUCCESS";
         } catch (Exception $e) {
             return 'Error: ' . $e->getMessage();
         }
     }
 }
Пример #5
0
 public function insert_dld($data)
 {
     global $pid;
     if (UserService::valid($data[0]) == 'existingpatient' || UserService::valid($data[0]) == 'newpatient') {
         sqlInsert("INSERT INTO documents_legal_detail (dld_pid,dld_signed,dld_filepath,dld_master_docid,dld_filename,dld_encounter,dld_file_for_pdf_generation) " . " VALUES (?,?,?,?,?,?,?)", array($pid, $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]));
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }
Пример #6
0
 public function print_ccr_report($data)
 {
     if (UserService::valid($data[0]) == 'existingpatient') {
         $ccraction = $data[1];
         $raw = $data[2];
         require_once "../../ccr/createCCR.php";
         ob_start();
         createCCR($ccraction, $raw);
         $html = ob_get_clean();
         if ($ccraction == 'viewccd') {
             $html = preg_replace('/<!DOCTYPE html PUBLIC "-\\/\\/W3C\\/\\/DTD HTML 4.01\\/\\/EN" "http:\\/\\/www.w3.org\\/TR\\/html4\\/strict.dtd">/', '', $html);
             $pos1 = strpos($html, 'body {');
             $pos2 = strpos($html, '.h1center');
             $tes = substr("{$html}", $pos1, $pos2 - $pos1);
             $html = str_replace($tes, '', $html);
             $html = str_replace('h3>', 'h2>', $html);
             $html = base64_encode($html);
         } else {
             $pos1 = strpos($html, '*{');
             $pos2 = strpos($html, 'h1');
             $tes = substr("{$html}", $pos1, $pos2 - $pos1);
             $html = str_replace($tes, '', $html);
         }
         return $html;
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }