<?php
ini_set("display_errors","1");
ini_set("display_startup_errors","1");
header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");
set_magic_quotes_runtime(0);
include("include/dbcommon.php");
include("include/Nursing_Handover_variables.php");
if(!@$_SESSION["UserID"])
{
$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
header("Location: login.php?message=expired");
return;
}
if(!CheckSecurity(@$_SESSION["OwnerID"],"Export"))
{
echo "<p>"."You don't have permissions to access this table"."<a href=\"login.php\">"."Back to login page"."</a></p>";
return;
}
include('libs/Smarty.class.php');
$smarty = new Smarty();
$conn=db_connect();
$strSQL=$_SESSION[$strTableName."_sql"];
LogInfo($strSQL);
// Pagination:
$numrows=GetRowCount($strSQL);
$mypage=(integer)$_SESSION[$strTableName."_pagenumber"];
if(!$mypage)
$mypage=1;
// page size
$PageSize=(integer)$_SESSION[$strTableName."_pagesize"];
if(!$PageSize)
$PageSize=$gPageSize;
$recno=1;
if($numrows)
{
$maxRecords = $numrows;
$maxpages=ceil($maxRecords/$PageSize);
if($mypage > $maxpages)
$mypage = $maxpages;
if($mypage<1)
$mypage=1;
$maxrecs=$PageSize;
$strSQL.=" limit ".(($mypage-1)*$PageSize).",".$PageSize;
}
$rs=db_query($strSQL,$conn);
// hide colunm headers if needed
$recordsonpage=$numrows-($mypage-1)*$PageSize;
if($recordsonpage>$PageSize)
$recordsonpage=$PageSize;
if($recordsonpage>=1)
$smarty->assign("column1show",true);
else
$smarty->assign("column1show",false);
// fill $rowinfo array
$rowinfo = array();
$data=db_fetch_array($rs);
while($data && $recno<=$PageSize)
{
$row=array();
for($col=1;$data && $recno<=$PageSize && $col<=1;$col++)
{
$recno++;
$keylink="";
$keylink.="&key1=".htmlspecialchars(urlencode($data["Primary"]));
// Ward -
$value="";
if(strlen($data["Ward"]))
{
$strdata = make_db_value("Ward",$data["Ward"]);
$LookupSQL="SELECT ";
$LookupSQL.="`Ward`";
$LookupSQL.=" FROM `ward list` WHERE `Ward` = " . $strdata;
LogInfo($LookupSQL);
$rsLookup = db_query($LookupSQL,$conn);
if($lookuprow=db_fetch_numarray($rsLookup))
$value=ProcessLargeText($lookuprow[0],"","",MODE_PRINT);
else
$value=ProcessLargeText(GetData($data,"Ward", ""),"field=Ward".$keylink,MODE_PRINT);
}
else
$value="";
$row[$col."Ward_value"]=$value;
// Bed -
$value="";
$value = ProcessLargeText(GetData($data,"Bed", ""),"field=Bed".$keylink,MODE_PRINT);
$row[$col."Bed_value"]=$value;
// Patient Name -
$value="";
$value = ProcessLargeText(GetData($data,"Patient Name", ""),"field=Patient+Name".$keylink,MODE_PRINT);
$row[$col."Patient_Name_value"]=$value;
// Date of Birth - Short Date
$value="";
$value = ProcessLargeText(GetData($data,"Date of Birth", "Short Date"),"field=Date+of+Birth".$keylink,MODE_PRINT);
$row[$col."Date_of_Birth_value"]=$value;
// Unit Number -
$value="";
$value = ProcessLargeText(GetData($data,"Unit Number", ""),"field=Unit+Number".$keylink,MODE_PRINT);
$row[$col."Unit_Number_value"]=$value;
// Sex -
$value="";
$value = ProcessLargeText(GetData($data,"Sex", ""),"field=Sex".$keylink,MODE_PRINT);
$row[$col."Sex_value"]=$value;
// Consultant -
$value="";
if(strlen($data["Consultant"]))
{
$strdata = make_db_value("Consultant",$data["Consultant"]);
$LookupSQL="SELECT ";
$LookupSQL.="`Consultant`";
$LookupSQL.=" FROM `consultants` WHERE `Consultant` = " . $strdata;
LogInfo($LookupSQL);
$rsLookup = db_query($LookupSQL,$conn);
if($lookuprow=db_fetch_numarray($rsLookup))
$value=ProcessLargeText($lookuprow[0],"","",MODE_PRINT);
else
$value=ProcessLargeText(GetData($data,"Consultant", ""),"field=Consultant".$keylink,MODE_PRINT);
}
else
$value="";
$row[$col."Consultant_value"]=$value;
// Code -
$value="";
$value = ProcessLargeText(GetData($data,"Code", ""),"field=Code".$keylink,MODE_PRINT);
$row[$col."Code_value"]=$value;
// Diagnosis -
$value="";
$value = ProcessLargeText(GetData($data,"Diagnosis", ""),"field=Diagnosis".$keylink,MODE_PRINT);
$row[$col."Diagnosis_value"]=$value;
// Allergies -
$value="";
$value = ProcessLargeText(GetData($data,"Allergies", ""),"field=Allergies".$keylink,MODE_PRINT);
$row[$col."Allergies_value"]=$value;
// Nurses -
$value="";
$value = ProcessLargeText(GetData($data,"Nurses", ""),"field=Nurses".$keylink,MODE_PRINT);
$row[$col."Nurses_value"]=$value;
// Social Services -
$value="";
$value = ProcessLargeText(GetData($data,"Social Services", ""),"field=Social+Services".$keylink,MODE_PRINT);
$row[$col."Social_Services_value"]=$value;
// Team -
$value="";
$value = ProcessLargeText(GetData($data,"Team", ""),"field=Team".$keylink,MODE_PRINT);
$row[$col."Team_value"]=$value;
// Notes -
$value="";
$value = ProcessLargeText(GetData($data,"Notes", ""),"field=Notes".$keylink,MODE_PRINT);
$row[$col."Notes_value"]=$value;
$row[$col."show"]=true;
$data=db_fetch_array($rs);
}
$rowinfo[]=$row;
}
$smarty->assign("rowinfo",$rowinfo);
$strSQL=$_SESSION[$strTableName."_sql"];
$smarty->display("Nursing_Handover_print.htm");