Location: PHPKode > projects > Clinical Handover Database > output/include/Current_Patients_masterlist.php
<?php

function DisplayMasterTableInfo($detailtable, $keys)
{
	global $conn,$strTableName,$smarty;
	
	$oldTableName=$strTableName;
	$strTableName="Current Patients";

$strSQL = "select `Primary`, 
`Patient Name`, 
`Date of Birth`, 
`Unit Number`, 
`Sex`, 
`Ward`, 
`Bed`, 
`Consultant`, 
`Code`, 
`Category`, 
`Admission Date`, 
`Diagnosis`, 
`Allergies`, 
`Notes`, 
`Nurses`, 
`Social Services`, 
`Team`, 
`Ward Round Notes` 
From `patients`
WHERE `Category` = \"Inpatient\"";
$where="";

if($detailtable=="Current Jobs")
{
		$where.= GetFullFieldName("Patient Name")."=".make_db_value("Patient Name",$keys[1-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}

	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	$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]);
				else
					$value=ProcessLargeText(GetData($data,"Ward", ""),"field=Ward".$keylink);
			}
			$smarty->assign("showmaster_Ward",$value);

//	Bed - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Bed", ""),"field=Bed".$keylink);
			$smarty->assign("showmaster_Bed",$value);

//	Patient Name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Patient Name", ""),"field=Patient+Name".$keylink);
			$smarty->assign("showmaster_Patient_Name",$value);

//	Date of Birth - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"Date of Birth", "Short Date"),"field=Date+of+Birth".$keylink);
			$smarty->assign("showmaster_Date_of_Birth",$value);

//	Unit Number - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Unit Number", ""),"field=Unit+Number".$keylink);
			$smarty->assign("showmaster_Unit_Number",$value);

//	Sex - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Sex", ""),"field=Sex".$keylink);
			$smarty->assign("showmaster_Sex",$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]);
				else
					$value=ProcessLargeText(GetData($data,"Consultant", ""),"field=Consultant".$keylink);
			}
			$smarty->assign("showmaster_Consultant",$value);

//	Diagnosis - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Diagnosis", ""),"field=Diagnosis".$keylink);
			$smarty->assign("showmaster_Diagnosis",$value);

//	Allergies - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Allergies", ""),"field=Allergies".$keylink);
			$smarty->assign("showmaster_Allergies",$value);

//	Code - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Code", ""),"field=Code".$keylink);
			$smarty->assign("showmaster_Code",$value);

//	Notes - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Notes", ""),"field=Notes".$keylink);
			$smarty->assign("showmaster_Notes",$value);
	$strTableName=$oldTableName;
}
?>
Return current item: Clinical Handover Database