Ejemplo n.º 1
0
function patient_reminder_widget($patient_id, $dateTarget = '')
{
    // Set date to current if not set
    $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s');
    // Update reminders for patient
    update_reminders($dateTarget, $patient_id);
    // Fetch the active reminders
    $listReminders = fetch_reminders($patient_id);
    if (empty($listReminders)) {
        // No reminders to show.
        echo htmlspecialchars(xl('No active patient reminders.'), ENT_NOQUOTES);
        return;
    }
    echo "<table cellpadding='0' cellspacing='0'>";
    foreach ($listReminders as $reminder) {
        echo "<tr><td style='padding:0 1em 0 1em;'><span class='small'>";
        // show reminder label
        echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $reminder['category']) . ": " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $reminder['item']);
        echo "</span></td><td style='padding:0 1em 0 1em;'><span class='small'>";
        // show reminder due status
        echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_reminder_due_opt'), $reminder['due_status']);
        echo "</span></td><td style='padding:0 1em 0 1em;'><span class='small'>";
        // show reminder sent date
        if (empty($reminder['date_sent'])) {
            echo htmlspecialchars(xl('Reminder Not Sent Yet'), ENT_NOQUOTES);
        } else {
            echo htmlspecialchars(xl('Reminder Sent On') . ": " . $reminder['date_sent'], ENT_NOQUOTES);
        }
        echo "</span></td></tr>";
    }
    echo "</table>";
}
Ejemplo n.º 2
0
/**
 * Function to update reminders via a batching method to improve performance and decrease memory overhead.
 *
 * Function that updates reminders and returns an array with a specific data structure.
 * <pre>The data structure of the return array includes the following elements
 *  'total_active_actions'         - Number of active actions.
 *  'total_pre_active_reminders'   - Number of active reminders before processing.
 *  'total_pre_unsent_reminders'   - Number of unsent reminders before processing.
 *  'total_post_active_reminders'  - Number of active reminders after processing.
 *  'total_post_unsent_reminders'  - Number of unsent reminders after processing.
 *  'number_new_reminders'         - Number of new reminders
 *  'number_updated_reminders'     - Number of updated reminders (due_status change)
 *  'number_inactivated_reminders' - Number of inactivated reminders.
 *  'number_unchanged_reminders'   - Number of unchanged reminders.
 * </pre>
 *
 * @param  string   $dateTarget  target date (format Y-m-d H:i:s). If blank then will test with current date as target.
 * @param  integer  $batchSize   number of patients to batch (default is 25; plan to optimize this default setting in the future)
 * @param  integer  $report_id   id of report in database (if already bookmarked)
 * @param  boolean  $also_send   if TRUE, then will also call send_reminder when done
 * @return array                 see above for data structure of returned array
 */
function update_reminders_batch_method($dateTarget = '', $batchSize = 25, $report_id = NULL, $also_send = FALSE)
{
    // Default to a batchsize, if empty
    if (empty($batchSize)) {
        $batchSize = 25;
    }
    // Collect total number of pertinent patients (to calculate batching parameters)
    $totalNumPatients = buildPatientArray('', '', '', NULL, NULL, TRUE);
    // Cycle through the batches and collect/combine results
    if ($totalNumPatients % $batchSize > 0) {
        $totalNumberBatches = floor($totalNumPatients / $batchSize) + 1;
    } else {
        $totalNumberBatches = floor($totalNumPatients / $batchSize);
    }
    // Prepare the database to track/store results
    if ($also_send) {
        $report_id = beginReportDatabase("process_send_reminders", '', $report_id);
    } else {
        $report_id = beginReportDatabase("process_reminders", '', $report_id);
    }
    setTotalItemsReportDatabase($report_id, $totalNumPatients);
    $patient_counter = 0;
    for ($i = 0; $i < $totalNumberBatches; $i++) {
        $patient_counter = $batchSize * ($i + 1);
        if ($patient_counter > $totalNumPatients) {
            $patient_counter = $totalNumPatients;
        }
        $update_rem_log_batch = update_reminders($dateTarget, '', $batchSize * $i + 1, $batchSize);
        if ($i == 0) {
            // For first cycle, simply copy it to update_rem_log
            $update_rem_log = $update_rem_log_batch;
        } else {
            // Debug statements
            //error_log("CDR: ".print_r($update_rem_log,TRUE),0);
            //error_log("CDR: ".($batchSize*$i). " records",0);
            // Integrate batch results into main update_rem_log
            $update_rem_log['total_active_actions'] = $update_rem_log['total_active_actions'] + $update_rem_log_batch['total_active_actions'];
            $update_rem_log['total_pre_active_reminders'] = $update_rem_log['total_pre_active_reminders'] + $update_rem_log_batch['total_pre_active_reminders'];
            $update_rem_log['total_pre_unsent_reminders'] = $update_rem_log['total_pre_unsent_reminders'] + $update_rem_log_batch['total_pre_unsent_reminders'];
            $update_rem_log['number_new_reminders'] = $update_rem_log['number_new_reminders'] + $update_rem_log_batch['number_new_reminders'];
            $update_rem_log['number_updated_reminders'] = $update_rem_log['number_updated_reminders'] + $update_rem_log_batch['number_updated_reminders'];
            $update_rem_log['number_unchanged_reminders'] = $update_rem_log['number_unchanged_reminders'] + $update_rem_log_batch['number_unchanged_reminders'];
            $update_rem_log['number_inactivated_reminders'] = $update_rem_log['number_inactivated_reminders'] + $update_rem_log_batch['number_inactivated_reminders'];
            $update_rem_log['total_post_active_reminders'] = $update_rem_log['total_post_active_reminders'] + $update_rem_log_batch['total_post_active_reminders'];
            $update_rem_log['total_post_unsent_reminders'] = $update_rem_log['total_post_unsent_reminders'] + $update_rem_log_batch['total_post_unsent_reminders'];
        }
        //Update database to track results
        updateReportDatabase($report_id, $patient_counter);
    }
    // Create an array for saving to database (allows combining with the send log)
    $save_log = array();
    $save_log[] = $update_rem_log;
    // Send reminders, if this was selected
    if ($also_send) {
        $log_send = send_reminders();
        $save_log[] = $log_send;
    }
    // Record combo results in database
    finishReportDatabase($report_id, json_encode($save_log));
    // Just return the process reminders array
    return $update_rem_log;
}
Ejemplo n.º 3
0
</span>

<?php 
// Collect the sender information
// TODO
// $sender_name
// $email_address
//
?>

<table>
 <tr>
  <td class='text' align='left' colspan="3"><br>
  
    <?php 
$update_rem_log = update_reminders();
?>

    <span class="text"><?php 
echo htmlspecialchars(xl('The patient reminders have been updated'), ENT_NOQUOTES) . ":";
?>
</span><br>
      <span class="text"><?php 
echo htmlspecialchars(xl('Total active actions'), ENT_NOQUOTES) . ": " . $update_rem_log['total_active_actions'];
?>
</span><br>
      <span class="text"><?php 
echo htmlspecialchars(xl('Total active reminders before update'), ENT_NOQUOTES) . ": " . $update_rem_log['total_pre_active_reminders'];
?>
</span><br>
      <span class="text"><?php 
Ejemplo n.º 4
0
echo $GLOBALS['phone_country_code'];
?>
';
</script>

</head>

<?php 
$patient_id = $_GET['patient_id'] ? $_GET['patient_id'] : "";
$mode = $_GET['mode'] ? $_GET['mode'] : "simple";
$sortby = $_GET['sortby'];
$sortorder = $_GET['sortorder'];
$begin = $_GET['begin'];
if (!empty($patient_id)) {
    //Only update one patient
    $update_rem_log = update_reminders('', $patient_id);
}
if ($mode == "simple") {
    // Collect the rules for the per patient rules selection tab
    $rules_default = resolve_rules_sql('', '0', TRUE);
}
?>

<script language="javascript">
  // This is for callback by the find-patient popup.
  function setpatient(pid, lname, fname, dob) {
    var f = document.forms[0];
    f.form_patient.value = lname + ', ' + fname;
    f.patient_id.value = pid;
  }