VT Red Flags Report
From PikaDocs
Some notes on an attempt to write a red flags report. This might be a little too far out there or a bad idea...
| Table of contents |
Put Red Flags into a function
Edit modules/case_screen.php so that all your red flag code is part of one big function, beginning with this:
function red_flags($case_row) {
and ending with this:
return $warnings; } // end of new function red_flags // main code for case_screen.php $warnings = red_flags($case_row);
The red flags will continue to function exactly the same on the case screen
Add new field to cases table
ALTER TABLE `cases` ADD `has_flags` tinyint( 4 ) default NULL
Edit ops/update_case.php
Around line 13 or so find this:
require_once('pikaCase.php');
And add this after it:
// adding requirement for pikaMisc - Andrew Cameron 2006/5/2
require_once('pikaMisc.php');
Around line 25 find this:
// The user is saving the case record. $case_data->setValues(pl_clean_form_input($_POST));
Add this after it:
// Andrew Cameron 2006/5/2 - experimenting with red flag report stuff
// this function lifted from case.php because we call modules/case_screen.php later and that file needs this function
// TODO - deprecate this when the case_screen module is revamped for PHP 5.
function pl_warning($str)
{
return pikaMisc::htmlRedFlag($str);
}
// below code is modified only slightly from case.php
$case_row = $case_data->getValues();
if (is_numeric($case_data->client_id))
{
require_once('pikaContact.php');
$primary_client = new pikaContact($case_data->client_id);
$case_row = array_merge($case_row, $primary_client->getValues());
}
$dirty_case_row = $case_row;
$case_row = pl_clean_html_array($case_row);
$case_row['birth_date'] = pl_date_unmogrify($case_row['birth_date']);
$case_row['open_date'] = pl_date_unmogrify($case_row['open_date']);
$case_row['close_date'] = pl_date_unmogrify($case_row['close_date']);
// include the red flags file now - make sure you have modified it to put all the code in a function
include_once('modules/case_screen.php');
// set the has_flags variable based on whether there were warnings
if (strlen($warnings)>1)
$flagarray['has_flags']=1;
else
$flagarray['has_flags']=0;
// save the has_flags variable back to the case using setValues function
$case_data->setValues($flagarray);
The rest of the file continues with:
$case_data->__destruct();
and everything else stays the same.
Notes
The idea here is to get the completed data coming into update_case.php, prep it by unmogrifying dates and getting client info, pass it to the new red_flags function in case_screen.php, determine whether red_flags were set on the case, and then update the has_flags variable accordingly. Now you can write a report to look for cases like this:
SELECT * FROM `cases` WHERE `has_flags` = 1;
I did some rudimentary speed testing. I enabled's Pika benchmarking feature. Before these changes I found that the Conflict, Eligibility, Case Info and Document tabs generally took between 0.10 and 0.15 seconds server time. After these changes the range seemed to fall between 0.10 and 0.17. Possibly a slight increase on the maximum time? But on the whole I would say the times are quite similar before and after the changes.
- original entry by Andrew Cameron
Legal Services Lawline of Vermont (http://www.lawlinevt.org/) and Vermont Legal Aid (http://www.vtlegalaid.org/)
- small code update, AC 2006/6/27 using strlen to check $warnings instead of if($warnings) in update_case.php
