<?php
header("Content-type: application/xml");
?>
<?xml version="1.0"?>
<patients>
<?php
include("inc/settings.php");
include("inc/functions.php");
@$pId = $_GET["pId"];
@$pFName = $_GET["pFName"];
@$pSName = $_GET["pSName"];
@$sDate = $_GET["sDate"];
@$eDate = $_GET["eDate"];
@$cr = $_GET["cr"];
@$ct = $_GET["ct"];
@$mg = $_GET["mg"];
@$mr = $_GET["mr"];
@$nm = $_GET["nm"];
@$us = $_GET["us"];
$sql = "SELECT dicompatients.*, dicomstudies.* FROM dicompatients, dicomstudies WHERE dicomstudies.patientId = dicompatients.patientId ";
if($pId != "" or $pId != null)
{
$sql = $sql . " AND dicompatients.patientId LIKE '%$pId%'";
}
if($pFName != "" OR $pFName != null)
{
$sql = $sql . " AND dicompatients.patientNam LIKE '%$pFName%'";
}
if($pSName != "" OR $pSName != null)
{
$sql = $sql . " AND dicompatients.patientNam LIKE '%$pSName%'";
}
if(($sDate != "" or $sDate != null) AND ($eDate != "" or $eDate != null))
{
$sql = $sql . " AND dicomstudies.StudyDate >= $sDate AND dicomstudies.StudyDate <= $eDate";
}
if($cr != "" OR $cr != null)
{
$sql = $sql . " AND StudyModal LIKE '%CR%'";
}
if($ct != "" OR $ct != null)
{
$sql = $sql . " AND StudyModal LIKE '%CT%'";
}
if($mg != "" OR $mg != null)
{
$sql = $sql . " AND StudyModal LIKE '%MG%'";
}
if($mr != "" OR $mr != null)
{
$sql = $sql . " AND StudyModal LIKE '%MR%'";
}
if($nm != "" OR $nm != null)
{
$sql = $sql . " AND StudyModal LIKE '%NM%'";
}
if($us != "" OR $us != null)
{
$sql = $sql . " AND StudyModal LIKE '%US%'";
}
//echo $sql;
@mysql_connect($dbhost,$dbuser,$dbpass) or die("ERROR--CAN'T CONNECT TO SERVER");
@mysql_select_db($dbname) or die("ERROR--CAN'T CONNECT TO DB");
$res = mysql_query($sql) or die("Error: " . mysql_error());
$num = mysql_num_rows($res);
for($i=0;$i<$num;$i++)
{
$pid = mysql_result($res,$i,"PatientID");
$pname = mysql_result($res,$i,"PatientNam");
$pdob = convertDateFromDB(mysql_result($res,$i,"PatientBir"));
$sdate = convertDateFromDB(mysql_result($res,$i,"StudyDate"));
$sinst = mysql_result($res,$i,"StudyInsta");
$names = formatName($pname);
$sdesc = mysql_result($res,$i,"StudyDescr");
$sex = mysql_result($res,$i,"PatientSex");
switch($sex)
{
case 'M' : $sexIcon = "ico/male.png"; $sex = "Male"; break;
case 'F' : $sexIcon = "ico/female.png"; $sex = "Female"; break;
default : $sexIcon = "ico/unknown.png"; $sex = "Unknown"; break;
}
?>
<patient>
<StudyDate><?php echo $sdate; ?></StudyDate>
<PatientId><?php echo $pid; ?></PatientId>
<PFName><?php echo $names["fname"]; ?></PFName>
<PSName><?php echo $names["sname"]; ?></PSName>
<PatientNam><?php echo $pname; ?></PatientNam>
<PatientBir><?php echo $pdob; ?></PatientBir>
<StudyInsta><?php echo $sinst; ?></StudyInsta>
<StudyDesc><?php echo $sdesc; ?></StudyDesc>
<PatientSexIcon><?php echo $sexIcon; ?></PatientSexIcon>
<PatientSex><?php echo $sex; ?></PatientSex>
</patient>
<?php
}
?>
</patients>