示例#1
0
/**
 * Function to send reminders.
 *
 * Function that sends reminders and returns an array with a specific data structure.
 * <pre>The data structure of the return array includes the following elements
 *   'total_pre_unsent_reminders'  - Number of reminders before processing.
 *   'total_post_unsent_reminders' - Number of reminders after processing.
 *   'number_success_emails'       - Number of successfully sent email reminders.
 *   'number_failed_emails'        - Number of failed sent email reminders.
 *   'number_success_calls'        - Number of successfully call reminders.
 *   'number_failed_calls'         - Number of failed call reminders.
 * </pre>
 *
 * @return array                 see above for data structure of returned array
 */
function send_reminders()
{
    $logging = array();
    // Collect active reminders that have not yet been sent.
    $active_unsent_reminders = fetch_reminders('', 'unsent');
    $logging['total_pre_unsent_reminders'] = count($active_unsent_reminders);
    // Send the unsent reminders
    $logging['number_success_emails'] = 0;
    $logging['number_failed_emails'] = 0;
    $logging['number_success_calls'] = 0;
    $logging['number_failed_calls'] = 0;
    foreach ($active_unsent_reminders as $reminder) {
        // Collect patient information that reminder is going to.
        $sql = "SELECT `fname`, `lname`, `email`, `phone_home`, `hipaa_voice`, `hipaa_allowemail` from `patient_data` where `pid`=?";
        $result = sqlQueryCdrEngine($sql, array($reminder['pid']));
        $patientfname = $result['fname'];
        $patientlname = $result['lname'];
        $patientemail = $result['email'];
        $patientphone = $result['phone_home'];
        $hipaa_voice = $result['hipaa_voice'];
        $hipaa_allowemail = $result['hipaa_allowemail'];
        // Email to patient if Allow Email and set reminder sent flag.
        if ($hipaa_allowemail == "YES") {
            $mail = new MyMailer();
            $sender_name = $GLOBALS['patient_reminder_sender_name'];
            $email_address = $GLOBALS['patient_reminder_sender_email'];
            $mail->FromName = $sender_name;
            // required
            $mail->Sender = $email_address;
            // required
            $mail->From = $email_address;
            // required
            $mail->AddAddress($patientemail, $patientfname . ", " . $patientlname);
            // required
            $mail->AddReplyTo($email_address, $sender_name);
            // required
            $category_title = generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $reminder['category']);
            $item_title = generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $reminder['item']);
            $mail->Body = "Dear " . $patientfname . ", This is a message from your clinic to remind you of your " . $category_title . ": " . $item_title;
            $mail->Subject = "Clinic Reminder";
            if ($mail->Send()) {
                // deal with and keep track of this successful email
                sqlStatementCdrEngine("UPDATE `patient_reminders` SET `email_status`='1', `date_sent`=NOW() WHERE id=?", array($reminder['id']));
                $logging['number_success_emails']++;
            } else {
                // deal with and keep track of this unsuccesful email
                $logging['number_failed_emails']++;
            }
        }
        // Call to patient if Allow Voice Message and set reminder sent flag.
        if ($hipaa_voice == "YES") {
            /******************************************************************************
            *     // Maviq does not work, is not currently supported, and seems to break on windows servers, so this
            *     //  feature has been commented out for now.
            *     // Automated VOIP service provided by Maviq. Please visit http://signup.maviq.com for more information.
            *      $siteId = $GLOBALS['phone_gateway_username'];
            *      $token = $GLOBALS['phone_gateway_password'];
            *      $endpoint = $GLOBALS['phone_gateway_url'];
            *      $client = new MaviqClient($siteId, $token, $endpoint);
            *      //Set up params.
            *      $data = array(
            *        "firstName" => $patientfname,
            *        "lastName" => $patientlname,
            *        "phone" => $patientphone,
            *        //"apptDate" => "$scheduled_date[1]/$scheduled_date[2]/$scheduled_date[0]",
            *        "timeRange" => "10-18",
            *        "type" => "reminder",
            *        "timeZone" => date('P'),
            *        "greeting" => str_replace("[[sender]]", $sender_name, str_replace("[[patient_name]]", $patientfname, $myrow['reminder_content']))
            *      );
            *
            *      // Make the call.
            *      $response = $client->sendRequest("appointment", "POST", $data);
            *
            *      if ($response->IsError) {
            *        // deal with and keep track of this unsuccessful call
            *        $logging['number_failed_calls']++;
            *      }
            *      else {
            *        // deal with and keep track of this succesful call
            *        sqlStatementCdrEngine("UPDATE `patient_reminders` SET `voice_status`='1', `date_sent`=NOW() WHERE id=?", array($reminder['id']) );
            *        $logging['number_success_calls']++;
            *      }
            *******************************************************************************/
        }
    }
    // For logging purposes only:
    //  Collect active reminders that have not yet been sent.
    $logging['total_post_unsent_reminders'] = count(fetch_reminders('', 'unsent'));
    return $logging;
}
示例#2
0
/**
 *  This function delivers a document to the intended recipient.
 *  Will need to test for Hylafax.  
 *  Will need code for Direct messaging.
 *  Will need expansion to other methods of delivery.
 *  Works for email-to-fax.
 *  	To be HIPPA compliant fax address must be behind secure firewall with this server.
 *		Some suggest the fax server to fax machine portion of efaxing is not HIPPA compliant, no matter how it is done.
 *		Thus faxing is not HIPPA compliant, and if that affects you, don't deliver this way.
 */
function deliver_document($task)
{
    //use PHPMAILER
    $query = "SELECT * FROM users WHERE id=?";
    $to_data = sqlQuery($query, array($task['TO_ID']));
    $from_data = sqlQuery($query, array($task['FROM_ID']));
    $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1";
    $facility_data = sqlQuery($sql);
    $query = "SELECT * FROM patient_data where pid=?";
    $patientData = sqlQuery($query, array($task['PATIENT_ID']));
    $from_fax = preg_replace("/[^0-9]/", "", $facility_data['fax']);
    $from_name = $from_data['fname'] . " " . $from_data['lname'];
    $from_fac = $from_facility['name'];
    $to_fax = preg_replace("/[^0-9]/", "", $to_data['fax']);
    $to_name = $to_data['fname'] . " " . $to_data['lname'];
    $pt_name = $patientData['fname'] . ' ' . $patientData['lname'];
    $encounter = $task['ENC_ID'];
    $mail = new MyMailer();
    $to_email = $to_fax . "@" . $GLOBALS['hylafax_server'];
    $email_sender = $GLOBALS['patient_reminder_sender_email'];
    //consider using admin email = Notification Email Address
    //this must be a fax server approved From: address
    $file_to_attach = preg_replace('/^file:\\/\\//', "", $task['DOC_url']);
    $file_name = preg_replace('/^.*\\//', "", $task['DOC_url']);
    $cover_page = "We are processing this file: " . $filepath . '/' . $filename;
    $mail->AddReplyTo($email_sender, $from_name);
    $mail->SetFrom($email_sender, $from_name);
    $mail->AddAddress($to_email);
    //, $to_name);
    $mail->Subject = $from_fax;
    $mail->MsgHTML("<html><HEAD> <TITLE>Fax Central openEMR</TITLE> <BASE HREF='http://www.oculoplasticsllc.com'> </HEAD><body><div class='wrapper'>" . $cover_page . "</div></body></html>");
    $mail->IsHTML(true);
    $mail->AltBody = $cover_page;
    $mail->AddAttachment($file_to_attach, $file_name);
    if ($mail->Send()) {
        return true;
    } else {
        $email_status = $mail->ErrorInfo;
        error_log("EMAIL ERROR: " . $email_status, 0);
        return false;
    }
}
示例#3
0
 function document_send($email, $body, $attfile, $pname)
 {
     if (empty($email)) {
         $this->assign("process_result", "Email could not be sent, the address supplied: '{$email}' was empty or invalid.");
         return;
     }
     $desc = "Please check the attached patient document.\n Content:" . attr($body);
     $mail = new MyMailer();
     $from_name = $GLOBALS["practice_return_email_path"];
     $from = $GLOBALS["practice_return_email_path"];
     $mail->AddReplyTo($from, $from_name);
     $mail->SetFrom($from, $from);
     $to = $email;
     $to_name = $email;
     $mail->AddAddress($to, $to_name);
     $subject = "Patient documents";
     $mail->Subject = $subject;
     $mail->Body = $desc;
     $mail->AddAttachment($attfile);
     if ($mail->Send()) {
         $retstatus = "email_sent";
     } else {
         $email_status = $mail->ErrorInfo;
         //echo "EMAIL ERROR: ".$email_status;
         $retstatus = "email_fail";
     }
 }
示例#4
0
function emailLogin($patient_id, $message)
{
    $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($patient_id));
    if ($patientData['hipaa_allowemail'] != "YES" || empty($patientData['email']) || empty($GLOBALS['patient_reminder_sender_email'])) {
        return false;
    }
    if (!validEmail($patientData['email'])) {
        return false;
    }
    if (!validEmail($GLOBALS['patient_reminder_sender_email'])) {
        return false;
    }
    $mail = new MyMailer();
    $pt_name = $patientData['fname'] . ' ' . $patientData['lname'];
    $pt_email = $patientData['email'];
    $email_subject = xl('Access Your Patient Portal');
    $email_sender = $GLOBALS['patient_reminder_sender_email'];
    $mail->AddReplyTo($email_sender, $email_sender);
    $mail->SetFrom($email_sender, $email_sender);
    $mail->AddAddress($pt_email, $pt_name);
    $mail->Subject = $email_subject;
    $mail->MsgHTML("<html><body><div class='wrapper'>" . $message . "</div></body></html>");
    $mail->IsHTML(true);
    $mail->AltBody = $message;
    if ($mail->Send()) {
        return true;
    } else {
        $email_status = $mail->ErrorInfo;
        error_log("EMAIL ERROR: " . $email_status, 0);
        return false;
    }
}