public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to run reports.');
     }
     $this->reportName = $context->get('reportName');
     PHPWS_Core::initModClass('hms', 'Report.php');
     $report = ReportManager::getReportInstance($this->reportName);
     /** TODO
              $view = $report->getSetupView();
     
              if(is_null($view)){
     
              }else{
     
              }
              $context->setContent($view->show());
              */
     $report->schedule();
 }
Exemplo n.º 2
0
/**
 * Process clinic rules.
 *
 * Test the clinic rules of entire clinic and create a report or patient reminders (can also test
 * on one patient or patients of one provider). The structure of the returned results is dependent on the
 * $organize_mode and $mode parameters.
 * <pre>The results are dependent on the $organize_mode parameter settings
 *   'default' organize_mode:
 *     Returns a two-dimensional array of results organized by rules (dependent on the following $mode settings):
 *       'reminders-due' mode - returns an array of reminders (action array elements plus a 'pid' and 'due_status')
 *       'reminders-all' mode - returns an array of reminders (action array elements plus a 'pid' and 'due_status')
 *       'report' mode        - returns an array of rows for the Clinical Quality Measures (CQM) report
 *   'plans' organize_mode:
 *     Returns similar to default, but organizes by the active plans
 * </pre>
 *
 * @param  integer      $provider      id of a selected provider. If blank, then will test entire clinic. If 'collate_outer' or 'collate_inner', then will test each provider in entire clinic; outer will nest plans  inside collated providers, while inner will nest the providers inside the plans (note inner and outer are only different if organize_mode is set to plans).
 * @param  string       $type          rule filter (active_alert,passive_alert,cqm,amc,patient_reminder). If blank then will test all rules. 
 * @param  string/array $dateTarget    target date (format Y-m-d H:i:s). If blank then will test with current date as target. If an array, then is holding two dates ('dateBegin' and 'dateTarget').
 * @param  string       $mode          choose either 'report' or 'reminders-all' or 'reminders-due' (required)
 * @param  integer      $patient_id    pid of patient. If blank then will check all patients.
 * @param  string       $plan          test for specific plan only
 * @param  string       $organize_mode Way to organize the results (default, plans). See above for organization structure of the results.
 * @param  array        $options       can hold various option (for now, used to hold the manual number of labs for the AMC report)
 * @param  string       $pat_prov_rel  How to choose patients that are related to a chosen provider. 'primary' selects patients that the provider is set as primary provider. 'encounter' selectes patients that the provider has seen. This parameter is only applicable if the $provider parameter is set to a provider or collation setting.
 * @param  integer      $start         applicable patient to start at (when batching process)
 * @param  integer      $batchSize     number of patients to batch (when batching process)
 * @return array                       See above for organization structure of the results.
 */
function test_rules_clinic($provider = '', $type = '', $dateTarget = '', $mode = '', $patient_id = '', $plan = '', $organize_mode = 'default', $options = array(), $pat_prov_rel = 'primary', $start = NULL, $batchSize = NULL)
{
    // If dateTarget is an array, then organize them.
    if (is_array($dateTarget)) {
        $dateArray = $dateTarget;
        $dateTarget = $dateTarget['dateTarget'];
    }
    // Set date to current if not set
    $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s');
    // Prepare the results array
    $results = array();
    // If set the $provider to collate_outer (or collate_inner without plans organize mode),
    // then run through this function recursively and return results.
    if ($provider == "collate_outer" || $provider == "collate_inner" && $organize_mode != 'plans') {
        // First, collect an array of all providers
        $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
        $ures = sqlStatementCdrEngine($query);
        // Second, run through each provider recursively
        while ($urow = sqlFetchArray($ures)) {
            $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan, $organize_mode, $options, $pat_prov_rel, $start, $batchSize);
            if (!empty($newResults)) {
                $provider_item['is_provider'] = TRUE;
                $provider_item['prov_lname'] = $urow['lname'];
                $provider_item['prov_fname'] = $urow['fname'];
                $provider_item['npi'] = $urow['npi'];
                $provider_item['federaltaxid'] = $urow['federaltaxid'];
                array_push($results, $provider_item);
                $results = array_merge($results, $newResults);
            }
        }
        // done, so now can return results
        return $results;
    }
    // If set organize-mode to plans, then collects active plans and run through this
    // function recursively and return results.
    if ($organize_mode == "plans") {
        // First, collect active plans
        $plans_resolve = resolve_plans_sql($plan, $patient_id);
        // Second, run through function recursively
        foreach ($plans_resolve as $plan_item) {
            //  (if collate_inner, then nest a collation of providers within each plan)
            if ($provider == "collate_inner") {
                // First, collect an array of all providers
                $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
                $ures = sqlStatementCdrEngine($query);
                // Second, run through each provider recursively
                $provider_results = array();
                while ($urow = sqlFetchArray($ures)) {
                    $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan_item['id'], 'default', $options, $pat_prov_rel, $start, $batchSize);
                    if (!empty($newResults)) {
                        $provider_item['is_provider'] = TRUE;
                        $provider_item['prov_lname'] = $urow['lname'];
                        $provider_item['prov_fname'] = $urow['fname'];
                        $provider_item['npi'] = $urow['npi'];
                        $provider_item['federaltaxid'] = $urow['federaltaxid'];
                        array_push($provider_results, $provider_item);
                        $provider_results = array_merge($provider_results, $newResults);
                    }
                }
                if (!empty($provider_results)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $provider_results);
                }
            } else {
                // (not collate_inner, so do not nest providers within each plan)
                $newResults = test_rules_clinic($provider, $type, $dateTarget, $mode, $patient_id, $plan_item['id'], 'default', $options, $pat_prov_rel, $start, $batchSize);
                if (!empty($newResults)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $newResults);
                }
            }
        }
        // done, so now can return results
        return $results;
    }
    // Collect applicable patient pids
    $patientData = array();
    $patientData = buildPatientArray($patient_id, $provider, $pat_prov_rel, $start, $batchSize);
    // Go through each patient(s)
    //
    //  If in report mode, then tabulate for each rule:
    //    Total Patients
    //    Patients that pass the filter
    //    Patients that pass the target
    //  If in reminders mode, then create reminders for each rule:
    //    Reminder that action is due soon
    //    Reminder that action is due
    //    Reminder that action is post-due
    //Collect applicable rules
    // Note that due to a limitation in the this function, the patient_id is explicitly
    //  for grouping items when not being done in real-time or for official reporting.
    //  So for cases such as patient reminders on a clinic scale, the calling function
    //  will actually need rather than pass in a explicit patient_id for each patient in
    //  a separate call to this function.
    if ($mode != "report") {
        // Use per patient custom rules (if exist)
        // Note as discussed above, this only works for single patient instances.
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    } else {
        // $mode = "report"
        // Only use default rules (do not use patient custom rules)
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    }
    foreach ($rules as $rowRule) {
        // If using cqm or amc type, then use the hard-coded rules set.
        // Note these rules are only used in report mode.
        if ($rowRule['cqm_flag'] || $rowRule['amc_flag']) {
            require_once dirname(__FILE__) . "/classes/rulesets/ReportManager.php";
            $manager = new ReportManager();
            if ($rowRule['amc_flag']) {
                // Send array of dates ('dateBegin' and 'dateTarget')
                $tempResults = $manager->runReport($rowRule, $patientData, $dateArray, $options);
            } else {
                // Send target date
                $tempResults = $manager->runReport($rowRule, $patientData, $dateTarget);
            }
            if (!empty($tempResults)) {
                foreach ($tempResults as $tempResult) {
                    array_push($results, $tempResult);
                }
            }
            // Go on to the next rule
            continue;
        }
        // If in reminder mode then need to collect the measurement dates
        //  from rule_reminder table
        $target_dates = array();
        if ($mode != "report") {
            // Calculate the dates to check for
            if ($type == "patient_reminder") {
                $reminder_interval_type = "patient_reminder";
            } else {
                // $type == "passive_alert" or $type == "active_alert"
                $reminder_interval_type = "clinical_reminder";
            }
            $target_dates = calculate_reminder_dates($rowRule['id'], $dateTarget, $reminder_interval_type);
        } else {
            // $mode == "report"
            // Only use the target date in the report
            $target_dates[0] = $dateTarget;
        }
        //Reset the counters
        $total_patients = 0;
        $pass_filter = 0;
        $exclude_filter = 0;
        $pass_target = 0;
        // Find the number of target groups
        $targetGroups = returnTargetGroups($rowRule['id']);
        if (count($targetGroups) == 1 || $mode == "report") {
            //skip this section if not report and more than one target group
            foreach ($patientData as $rowPatient) {
                // Count the total patients
                $total_patients++;
                $dateCounter = 1;
                // for reminder mode to keep track of which date checking
                foreach ($target_dates as $dateFocus) {
                    //Skip if date is set to SKIP
                    if ($dateFocus == "SKIP") {
                        $dateCounter++;
                        continue;
                    }
                    //Set date counter and reminder token (applicable for reminders only)
                    if ($dateCounter == 1) {
                        $reminder_due = "soon_due";
                    } else {
                        if ($dateCounter == 2) {
                            $reminder_due = "due";
                        } else {
                            // $dateCounter == 3
                            $reminder_due = "past_due";
                        }
                    }
                    // First, deal with deceased patients
                    //  (for now will simply not pass the filter, but can add a database item
                    //   if ever want to create rules for dead people)
                    // Could also place this function at the total_patients level if wanted.
                    //  (But then would lose the option of making rules for dead people)
                    // Note using the dateTarget rather than dateFocus
                    if (is_patient_deceased($rowPatient['pid'], $dateTarget)) {
                        continue;
                    }
                    // Check if pass filter
                    $passFilter = test_filter($rowPatient['pid'], $rowRule['id'], $dateFocus);
                    if ($passFilter === "EXCLUDED") {
                        // increment EXCLUDED and pass_filter counters
                        //  and set as FALSE for reminder functionality.
                        $pass_filter++;
                        $exclude_filter++;
                        $passFilter = FALSE;
                    }
                    if ($passFilter) {
                        // increment pass filter counter
                        $pass_filter++;
                    } else {
                        $dateCounter++;
                        continue;
                    }
                    // Check if pass target
                    $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], '', $dateFocus);
                    if ($passTarget) {
                        // increment pass target counter
                        $pass_target++;
                        // send to reminder results
                        if ($mode == "reminders-all") {
                            // place the completed actions into the reminder return array
                            $actionArray = resolve_action_sql($rowRule['id'], '1');
                            foreach ($actionArray as $action) {
                                $action_plus = $action;
                                $action_plus['due_status'] = "not_due";
                                $action_plus['pid'] = $rowPatient['pid'];
                                $results = reminder_results_integrate($results, $action_plus);
                            }
                        }
                        break;
                    } else {
                        // send to reminder results
                        if ($mode != "report") {
                            // place the uncompleted actions into the reminder return array
                            $actionArray = resolve_action_sql($rowRule['id'], '1');
                            foreach ($actionArray as $action) {
                                $action_plus = $action;
                                $action_plus['due_status'] = $reminder_due;
                                $action_plus['pid'] = $rowPatient['pid'];
                                $results = reminder_results_integrate($results, $action_plus);
                            }
                        }
                    }
                    $dateCounter++;
                }
            }
        }
        // Calculate and save the data for the rule
        $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
        if ($mode == "report") {
            $newRow = array('is_main' => TRUE, 'total_patients' => $total_patients, 'excluded' => $exclude_filter, 'pass_filter' => $pass_filter, 'pass_target' => $pass_target, 'percentage' => $percentage);
            $newRow = array_merge($newRow, $rowRule);
            array_push($results, $newRow);
        }
        // Now run through the target groups if more than one
        if (count($targetGroups) > 1) {
            foreach ($targetGroups as $i) {
                //Reset the target counter
                $pass_target = 0;
                foreach ($patientData as $rowPatient) {
                    $dateCounter = 1;
                    // for reminder mode to keep track of which date checking
                    foreach ($target_dates as $dateFocus) {
                        //Skip if date is set to SKIP
                        if ($dateFocus == "SKIP") {
                            $dateCounter++;
                            continue;
                        }
                        //Set date counter and reminder token (applicable for reminders only)
                        if ($dateCounter == 1) {
                            $reminder_due = "soon_due";
                        } else {
                            if ($dateCounter == 2) {
                                $reminder_due = "due";
                            } else {
                                // $dateCounter == 3
                                $reminder_due = "past_due";
                            }
                        }
                        // First, deal with deceased patients
                        //  (for now will simply not pass the filter, but can add a database item
                        //   if ever want to create rules for dead people)
                        // Could also place this function at the total_patients level if wanted.
                        //  (But then would lose the option of making rules for dead people)
                        // Note using the dateTarget rather than dateFocus
                        if (is_patient_deceased($rowPatient['pid'], $dateTarget)) {
                            continue;
                        }
                        // Check if pass filter
                        $passFilter = test_filter($rowPatient['pid'], $rowRule['id'], $dateFocus);
                        if ($passFilter === "EXCLUDED") {
                            $passFilter = FALSE;
                        }
                        if (!$passFilter) {
                            // increment pass filter counter
                            $dateCounter++;
                            continue;
                        }
                        //Check if pass target
                        $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], $i, $dateFocus);
                        if ($passTarget) {
                            // increment pass target counter
                            $pass_target++;
                            // send to reminder results
                            if ($mode == "reminders-all") {
                                // place the completed actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], $i);
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = "not_due";
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                            break;
                        } else {
                            // send to reminder results
                            if ($mode != "report") {
                                // place the actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], $i);
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = $reminder_due;
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                        }
                        $dateCounter++;
                    }
                }
                // Calculate and save the data for the rule
                $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
                // Collect action for title (just use the first one, if more than one)
                $actionArray = resolve_action_sql($rowRule['id'], $i);
                $action = $actionArray[0];
                if ($mode == "report") {
                    $newRow = array('is_sub' => TRUE, 'action_category' => $action['category'], 'action_item' => $action['item'], 'total_patients' => '', 'excluded' => '', 'pass_filter' => '', 'pass_target' => $pass_target, 'percentage' => $percentage);
                    array_push($results, $newRow);
                }
            }
        }
    }
    // Return the data
    return $results;
}
Exemplo n.º 3
0
            //print_r($bw_list);
            $replacement = $bw_handler->getReplacementList();
            //print_r($replacement);
            $filtered_report_reason = preg_replace($bw_list, $replacement, $report_reason);
            //echo "new report filtered report: ".$filtered_report_reason;
            //Add a new record to report table
            $new_report = new Report();
            $new_report->setReason($filtered_report_reason);
            $new_report->setEntityForReport($entity_for_report);
            $new_report->setEntityId($entity_id);
            $new_report->setReportedBy($reported_by);
            $reportManager = new ReportManager();
            $new_report_id = $reportManager->addReport($new_report);
            if ($new_report_id > 0) {
                echo "Adding a new comment succeeded.";
                //send a notification to admin
                $rm = new ReportManager();
                $new_report = $rm->getReportById($new_report_id);
                $result = $rm->sendNoteToAdmin($new_report);
                echo $result;
            } else {
                echo "Adding a new comment failed.";
            }
        } else {
            echo "Posting all valid report fields is failed.";
        }
    } else {
        echo "Posting a report is failed.";
    }
}
//end if ($user_logged_in)
Exemplo n.º 4
0
<?php

include_once '../../php-jru.php';
$reportManager = new ReportManager();
$result = $reportManager->RunToBuffer('productos', PJRU_PDF);
header('Content-type: application/pdf');
print $result;
Exemplo n.º 5
0
<?php

/*se incluse las librerias*/
include_once '../../php-jru.php';
/*lista de formatos y su respectivo mime type*/
$formatos = array(PJRU_PDF => array('Documento Portable (PDF)', 'application/pdf'), PJRU_EXCEL => array('Exel', 'application/vnd.ms-excel'), PJRU_OPEN_DOCUMENT => array('OpenOffice', 'application/vnd.oasis.opendocument.text'), PJRU_RICH_TEXT => array('Documento de Texto de Microsoft (RTF)', 'application/rtf'));
/*se genera el report si se indica el formato*/
if (isset($_REQUEST['formato'])) {
    $reportManager = new ReportManager();
    $result = $reportManager->RunToFile('productos', $_REQUEST['formato']);
    //echo $formatos[$_REQUEST['formato']][1];
    header('Content-type: ' . $formatos[$_REQUEST['formato']][1]);
    //                readfile($result);
    print $result;
    die(0);
} else {
    ?>

<div style="margin-left: auto; margin-right: auto; width: 450px;  margin-top: 100px">

<h2>Generación de reportes con PHP-JRU </h2>
Para mayor información visite:
<br/> 
<a href="http://robertbruno.wordpress.com">robertbruno.wordpress.com</a>

<br/><br/>

Indique el formato del reporte que desea ejecutar

<br/>
Exemplo n.º 6
0
 /**
  * Removes all traces of a tutor from the database/system
  * Use with caution!
  *
  * @param int $ID The ID of the tutor to destroy
  */
 function destroyTutor($ID)
 {
     if ($this->userExists($ID)) {
         $db = $this->getDB();
         $queryTutor = "DELETE FROM " . self::TABLE_TUTOR . " WHERE userID = " . $ID;
         $queryUser = "******" . self::TABLE_USER . " WHERE userID = " . $ID;
         $db->query($queryTutor);
         $db->query($queryUser);
         $timesheetManager = new TimesheetManager();
         $timesheetManager->removeTimesheets($ID);
         $reportManager = new ReportManager();
         $reportManager->removeReports($ID);
         $scheduleManager = self::$scheduleManager;
         $scheduleManager->removeSchedule($ID);
     }
 }
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" id="searchButton" value="Search">
                <input type="button" id="resetButton" value="Reset">
            </td>
            
        </tr>
    </table>
</form>


<?php 
$reportManager = new ReportManager();
$reportListBackwards = $reportManager->getAll();
if (is_null($reportListBackwards)) {
    echo "There are currently no reports to display!";
} else {
    $reportList = array_reverse($reportListBackwards);
    echo '<table id="viewTutoringReportTable">';
    echo '<tr>';
    echo '<th class="tableHeader" id="dateHeader">Date</th>';
    echo '<th class="tableHeader" id="tutorHeader">Tutor</th>';
    echo '<th class="tableHeader" id="studentHeader">Student</th>';
    echo '<th class="tableHeader" id="reportHeader">Submitted Report</th>';
    echo '</tr>';
    foreach ($reportList as $report) {
        $time = strtotime($report->getDate());
        $date = date("m/d/Y", $time);
<?php

require_once __DIR__ . '/../admin/checkLogin.php';
require_once __DIR__ . '/../oop/TutoringReport.php';
require_once __DIR__ . '/../oop/manager/ReportManager.php';
$studentName = $_POST['name'];
$reportText = $_POST['report'];
error_log($studentName . $reportText);
$report = new TutoringReport($USER, $studentName, $reportText);
$reportManager = new ReportManager();
$reportManager->save($report);
echo 'success';
Exemplo n.º 9
0
<?php

include_once '../../php-jru.php';
$reportManager = new ReportManager();
$result = $reportManager->RunToBuffer('municipios', PJRU_PDF);
header('Content-type: application/pdf');
print $result;