Skip to content

Commit

Permalink
integrated patch 2819784 with most current cvs development tree
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed Jul 15, 2009
1 parent 2789874 commit 26eb773
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 3 deletions.
6 changes: 6 additions & 0 deletions interface/main/finder/patient_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function submitList(offset) {
else {
$patient = $_REQUEST['patient'];
$findBy = $_REQUEST['findBy'];
$searchFields = $_REQUEST['searchFields'];

echo "<input type='hidden' name='patient' value='$patient' />\n";
echo "<input type='hidden' name='findBy' value='$findBy' />\n";
Expand All @@ -147,6 +148,11 @@ function submitList(offset) {
$result = getPatientSSN("$patient", $given, $orderby, $sqllimit, $fstart);
elseif ($findBy == "Phone") //(CHEMED) Search by phone number
$result = getPatientPhone("$patient", $given, $orderby, $sqllimit, $fstart);
else if ($findBy == "Any")
$result = getByPatientDemographics("$patient", $given, $orderby, $sqllimit, $fstart);
else if ($findBy == "Filter") {
$result = getByPatientDemographicsFilter($searchFields, "$patient", $given, $orderby, $sqllimit, $fstart);
}
}
?>

Expand Down
25 changes: 25 additions & 0 deletions interface/main/left_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,19 @@ function syncRadios() {
f.popups.disabled = (active_pid == 0);
}

//
var my_window;
function initFilter() {
my_window = window.open("../../custom/search.php", "mywindow","status=1");
}

function processFilter( fieldString ) {
document.getElementById('searchFields').value=fieldString;
findPatient( "Filter" );
my_window.close();
}


// Process the click to find a patient by name, id, ssn or dob.
function findPatient(findby) {
var f = document.forms[0];
Expand Down Expand Up @@ -1018,6 +1031,17 @@ function selpopup(selobj) {
<a href="javascript:findPatient('DOB');" class="navitem"><?php xl('DOB','e'); ?></a>
</td>
</tr>

<tr>
<td class='smalltext'>&nbsp;</td>
<td class='smalltext'>
<a href="javascript:findPatient('Any');" class="navitem"><?php xl('Any', 'e'); ?></a>
</td>
<td class='smalltext' align='right'>
<a href="javascript:initFilter();" class="navitem"><?php xl('Filter', 'e'); ?></a>
</td>
</tr>

</table>

<hr />
Expand All @@ -1031,6 +1055,7 @@ function selpopup(selobj) {
<?php xl('Help','e'); ?></a>

<input type='hidden' name='findBy' value='Last' />
<input type="hidden" name="searchFields" id="searchFields"/>

</form>

Expand Down
73 changes: 70 additions & 3 deletions library/patient.inc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,13 @@ function getPatientLnames($lname = "%", $given = "pid, id, lname, fname, mname,
if ($fname{0} != strtoupper($fname{0})) {$search_for_pieces2 = '%';}

$where = "lname LIKE '" . $search_for_pieces1 . "$lname%' " .
"AND fname LIKE '" . $search_for_pieces2 . "$fname%'";
"AND fname LIKE '" . $search_for_pieces2 . "$fname%' ";
if (!empty($GLOBALS['pt_restrict_field'])) {
if ( $_SESSION{"authUser"} != 'admin' || $GLOBALS['pt_restrict_admin'] ) {
$where .= "AND ( patient_data.".$GLOBALS['pt_restrict_field']." = ( SELECT facility_id FROM users WHERE username = '".$_SESSION{"authUser"}."') OR patient_data.".$GLOBALS['pt_restrict_field']." = '' ) ";
}
}

$sql="SELECT $given FROM patient_data WHERE $where ORDER BY $orderby";
if ($limit != "all") $sql .= " LIMIT $start, $limit";

Expand All @@ -319,7 +325,60 @@ function getPatientLnames($lname = "%", $given = "pid, id, lname, fname, mname,

function getPatientId($pid = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
{
$where = "pubpid LIKE '$pid%'";

$where = "pubpid LIKE '$pid%' ";
if (!empty($GLOBALS['pt_restrict_field']) && $GLOBALS['pt_restrict_by_id'] ) {
if ( $_SESSION{"authUser"} != 'admin' || $GLOBALS['pt_restrict_admin'] ) {
$where .= "AND ( patient_data.".$GLOBALS['pt_restrict_field']." = ( SELECT facility_id FROM users WHERE username = '".$_SESSION{"authUser"}."') OR patient_data.".$GLOBALS['pt_restrict_field']." = '' ) ";
}
}

$sql = "SELECT $given FROM patient_data WHERE $where ORDER BY $orderby";
if ($limit != "all") $sql .= " limit $start, $limit";
$rez = sqlStatement($sql);
for($iter=0; $row=sqlFetchArray($rez); $iter++)
$returnval[$iter]=$row;

_set_patient_inc_count($limit, count($returnval), $where);
return $returnval;
}

function getByPatientDemographics($searchTerm = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
{
$layoutCols = sqlStatement( "SELECT field_id FROM layout_options WHERE form_id='DEM' AND group_name not like ('%Employer%' ) AND uor !=0" );

$where = "";
for($iter=0; $row=sqlFetchArray($layoutCols); $iter++) {
if ( $iter > 0 ) {
$where .= " or ";
}
$where .= " ".$row["field_id"]." like '%".$searchTerm."%' ";
}

$sql = "SELECT $given FROM patient_data WHERE $where ORDER BY $orderby";
if ($limit != "all") $sql .= " limit $start, $limit";
$rez = sqlStatement($sql);
for($iter=0; $row=sqlFetchArray($rez); $iter++)
$returnval[$iter]=$row;

_set_patient_inc_count($limit, count($returnval), $where);
return $returnval;
}

function getByPatientDemographicsFilter($searchFields, $searchTerm = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0" )
{
$layoutCols = split( '~', $searchFields );

$where = "";
$i = 0;
foreach ($layoutCols as $val ) {
if ( $i > 0 ) {
$where .= " or ";
}
$where .= " ".$val." like '%".$searchTerm."%' ";
$i++;
}

$sql = "SELECT $given FROM patient_data WHERE $where ORDER BY $orderby";
if ($limit != "all") $sql .= " limit $start, $limit";
$rez = sqlStatement($sql);
Expand All @@ -330,6 +389,7 @@ function getPatientId($pid = "%", $given = "pid, id, lname, fname, mname, provid
return $returnval;
}


// return a collection of Patient PIDs
// new arg style by JRM March 2008
// orig function getPatientPID($pid = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
Expand Down Expand Up @@ -377,8 +437,15 @@ function getPatientName($pid) {
function getPatientDOB($DOB = "%", $given = "pid, id, lname, fname, mname", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
{
$DOB = fixDate($DOB, $DOB);
$where = "DOB like '$DOB%'";
$where = "DOB like '$DOB%' ";
if (!empty($GLOBALS['pt_restrict_field'])) {
if ( $_SESSION{"authUser"} != 'admin' || $GLOBALS['pt_restrict_admin'] ) {
$where .= "AND ( patient_data.".$GLOBALS['pt_restrict_field']." = ( SELECT facility_id FROM users WHERE username = '".$_SESSION{"authUser"}."') OR patient_data.".$GLOBALS['pt_restrict_field']." = '' ) ";
}
}

$sql="SELECT $given FROM patient_data WHERE $where ORDER BY $orderby";

if ($limit != "all") $sql .= " LIMIT $start, $limit";

$rez = sqlStatement($sql);
Expand Down

0 comments on commit 26eb773

Please sign in to comment.