<?php

$ruid = $_GET['ruid'];
$date = $_GET['date'];
$patid = $_GET['patid'];
$studyUID = $_GET['studyUID'];
$patage = $_GET['patage'];
$patsex = $_GET['patsex'];
$name = $_GET['name'];
$mod = $_GET['mod'];

?>
<!doctype html public "-//w3c//dtd html 3.2//ja">
<html>
<head>
<title>report for:<?php echo $patid ?><?php echo $name ?><?php echo $patage ?><?php echo $patsex ?>date:<?php echo $date ?>mod:<?php echo $mod ?></title>
<meta http-equiv=content-type content="text/html; charset=x-euc-jp">

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin


function print_out() {
    self.print();
}


//END -->
</script>

<STYLE>
BR.page { page-break-after: always }
.main_font {font-family :  serif; font-size : 12pt ;}
.strong_font {font-family : sans-serif;}
</STYLE>




</head>
<body BACKGROUND="./img/yellow.jpg">


<?php

//  onLoad="print_out()"


//
//	2002.1.1
//	DICOM to WWW Gateway :PHP script
//	Made by Norya Yokohama % Medical Division @ WERC
//  2004.9.19
//  added by tadashi tsuchimoto @ MITT belong to yokohamazyuku
//  show report (modified with facilitylevel)
//


  include "init.inc";
  include "param_setting.ini";
  include "sql_generator.ini";
  include "file_mod.inc";
  $include_path=".";
  require("$include_path/dbconnect.ini");


//DB query

$db_handle = db_contact_start($db_type,$target_host,$target_db);




  
  print("<center><font size=6><B>　　Imageing diagnosis Report</B></font></center>");
  print("<div align=right><font=3>&nbsp detail report</font></div>");
  



  $sql = "select 
  reportlevel.report AS report ,
  reportlevel.summary AS summary ,
  reportlevel.drname AS drname ,
  reportlevel.clinicalinfo as clinicalinfo,
  reportlevel.imagediag as imagediag,
  reportlevel.tequnitian as tequnitian,
  reportlevel.orderdr as orderdr,
  reportlevel.dept as dept,
  reportlevel.diagtime as diagtime,
  reportlevel.print as print,
  reportlevel.comment as comment,
  reportlevel.patparentrep as patparentrep,
  reportlevel.bookmark as bookmark,
  reportlevel.refimage2 as refimage2,
  reportlevel.refimage3 as refimage3,
  reportlevel.refimage4 as refimage4,
  reportlevel.refimage5 as refimage5,
  reportlevel.refimage6 as refimage6,
  reportlevel.refimage7 as refimage7,
  reportlevel.refimage8 as refimage8,
  reportlevel.refimage9 as refimage9,
  reportlevel.refimage10 as refimage10,
  reportlevel.refimage as refimage,
  reportlevel.ward as ward 
   from reportlevel
  where reportlevel.ruid ='$ruid'";

  $rtn_select = $db_handle->prepare($sql);
  $rtn_select->execute();
  
  
  $row_count = $rtn_select->rowCount();


  if ($row_count>=1){
	while ($rtn_select_row = $rtn_select->fetch(PDO::FETCH_ASSOC)) {
	
    $report = $rtn_select_row['report'] ;
    $summary = $rtn_select_row['summary'] ;
    $drname = $rtn_select_row['drname'] ;
    $clinicalinfo = $rtn_select_row['clinicalinfo'] ;
    $imagediag = $rtn_select_row['imagediag'] ;
    $tequnitian = $rtn_select_row['tequnitian'] ;
    $dept = $rtn_select_row['dept'] ;
    $orderdr = $rtn_select_row['orderdr'] ;
    $diagtime = $rtn_select_row['diagtime'] ;
    $print = $rtn_select_row['print'] ;
    $comment = $rtn_select_row['comment'] ;
    $refimage = $rtn_select_row['refimage'] ;
    $refimage2 = $rtn_select_row['refimage2'] ;
    $refimage3 = $rtn_select_row['refimage3'] ;
    $refimage4 = $rtn_select_row['refimage4'] ;
    $refimage5 = $rtn_select_row['refimage5'] ;
    $refimage6 = $rtn_select_row['refimage6'] ;
	$analysis6 = $rtn_select_row['refimage7'] ;
	$analysis7 = $rtn_select_row['refimage8'] ;
	$analysis8 = $rtn_select_row['refimage9'] ;
	$analysis9 = $rtn_select_row['refimage10'] ;
	$analysis10 = $rtn_select_row['refimage3'] ;
    $patparentrep = $rtn_select_row['patparentrep'] ;
    $bookmark = $rtn_select_row['bookmark'] ;
    $ward = $rtn_select_row['ward'] ;
	
	}

  }else{
  print("no report registered");


  }



@$report = str_replace("\’", "'", $report);
@$summary = str_replace("\’", "'", $summary);
@$clinicalinfo = str_replace("\’", "'", $clinicalinfo);
@$imagediag = str_replace("\’", "'", $imagediag);


    $time = getdate();
	$aYear=$time['year'];
	$aMonth=$time['mon'];
	$aDay=$time['mday'];
	$printtime = ( $aYear ."/".  $aMonth ."/".  $aDay  );






  $fdate=formatDate($date);


if(!$orderdr){
	$orderdr = "&nbsp";
	}

if(!$comment){
	$comment = "&nbsp";
	}



if(!$drname){
	$drname = "&nbsp";
	}




print("<hr size=1 color=black>");

  print("<table border=0>");
  print("<TR><TD width=70 class=\"main_font_em\">patient ID</TD>
  <TD width=150 align=left class=\"main_font\">$patid</TD>
  <TD width=150 class=\"main_font_em\">modarity</TD>
  <TD width=200 align=left class=\"main_font\">$mod</TD>
  <TD width=50 align=right class=\"main_font\">$ward</TD></TR>");
  print("<TR><TD width=70 class=\"main_font_em\">NAME</TD>
  <TD width=150 align=left class=\"main_font\">$name</TD>
  <TD width=150 class=\"main_font_em\">order Dr</TD>
  <TD width=250 align=left colspan=2 class=\"main_font\">$orderdr</TD>
  </TR>");
  print("<TR><TD width=70 class=\"main_font_em\">age</TD>
  <TD width=150 align=left class=\"main_font\">$patage</TD>
  <TD width=150 class=\"main_font_em\">Dept Radiology</TD>
  <TD width=250 align=left colspan=2 class=\"main_font\">&nbsp</TD></TR>");
  print("<TR><TD width=70 class=\"main_font_em\">sex</TD>
  <TD width=150 align=left class=\"main_font\">$patsex</TD>
  <TD width=150 class=\"main_font_em\">comment</TD>
  <TD width=250 align=left colspan=2 class=\"main_font\"> address,Phone number  </TD></TR>");
  print("<TR><TD width=70 class=\"main_font_em\">study date</TD>
  <TD width=150 align=left class=\"main_font\"> $date  </TD>
  <TD width=150 class=\"main_font\">&nbsp</TD>
  <TD width=250 align=left colspan=2 class=\"main_font\"> order comment </TD></TR>");
  print("</table>");

print("<hr size=1 color=black>");

//print("<br>$patparentrep<br>");


print("<table><tr><td class=\"strong_font\"><b><clinical information></b></td></tr></table>");



$clinicalinfo = nl2br($clinicalinfo);
print("<TABLE Border=0 Bordercolor=\"#000000\" Bgcolor=\"#f8f8ff\" WIDTH=\"650\" height=\"50\">");
print("<tr><td valign=top class=\"main_font\">");

print("$clinicalinfo");

print("</tr></td>");
print("</table>");



  print("<table><tr><td class=\"strong_font\"><b><findings></b>&nbsp &nbsp &nbsp &nbsp prev study $summary</td></tr></table>");

$report = nl2br($report);


print("<TABLE Border=0 Bordercolor=\"#000000\" Bgcolor=\"#f8f8ff\" WIDTH=\"650\" height=\"250\">");
print("<tr><td valign=top class=\"main_font\">");

print("$report");


print("</tr></td>");
print("</table>");



print("<table><tr><td class=\"strong_font\"><b>＜Impression＞</b></td></tr></table>");

$imagediag = nl2br($imagediag);

print("<TABLE Border=0 Bordercolor=\"#000000\" Bgcolor=\"#f8f8ff\" WIDTH=\"650\" height=\"50\">");
print("<tr><td valign=top class=\"main_font\">");

print("$imagediag");

print("</tr></td>");
print("</table>");




print("</form>");



if ($refimage){




if($refimage4){
print("<br>refer another page");
print("<BR><BR><BR><BR><BR><BR><BR>");
print("<BR><BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime </div>");

print("<BR CLASS=page>");

  print("<table border=0>");
  print("<TR><TD width=70 class=\"main_font\">patient ID</TD>
  <TD width=160 align=left class=\"main_font\">$patid</TD>
  <TD width=70 class=\"main_font\">date</TD>
  <TD width=270 align=left class=\"main_font\">$fdate</TD>
  <TD width=50 align=right class=\"main_font\">$ward</TD></TR>");
  print("<TR><TD width=70 class=\"main_font\">patient name</TD>
  <TD width=160 align=left class=\"main_font\">&nbsp</TD>
  <TD width=70 class=\"main_font\">order dr</TD>
  <TD width=320 align=left colspan=2 class=\"main_font\">$orderdr</TD>
  </TR>");
  print("<TR><TD width=70 class=\"main_font\">NAME</TD>
  <TD width=160 align=left class=\"main_font\">$name_sm</TD>
  <TD width=70 class=\"main_font\">comment</TD>
  <TD width=320 align=left colspan=2 class=\"main_font\">$comment</TD></TR>");
  print("<TR><TD width=70 class=\"main_font\">age</TD>
  <TD width=160 align=left class=\"main_font\">$patage_mod</TD>
  <TD width=70 class=\"main_font\">&nbsp</TD>
  <TD width=320 align=left colspan=2 class=\"main_font\">&nbsp</TD></TR>");
  print("<TR><TD width=70 class=\"main_font\">sex</TD>
  <TD width=160 align=left class=\"main_font\">$patsex</TD>
  <TD width=70 class=\"main_font\">modarity</TD>
  <TD width=320 align=left colspan=2 class=\"main_font\"> $report_mod  </TD></TR>");
  print("</table>");
}



if($refimage){
print("Refer images");
print("<br>");
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage\" Width=210 Height=210>");

if(!$refimage2){
print("<BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");

}

}

if($refimage2){
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage2\" Width=210 Height=210>");

if(!$refimage3){
print("<BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");

}

}

if($refimage3){

print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage3\" Width=210 Height=210>");

if(!$refimage4){
print("<BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");

}

}



if($refimage4){
print("<br>");
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage4\" Width=210 Height=210>");

	if(!$refimage5){
print("<BR><BR><BR><BR><BR><BR><BR><BR><BR>");
print("<BR><BR><BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");

	}

}




if($refimage5){
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage5\" Width=210 Height=210>");

print("<BR><BR><BR><BR><BR><BR><BR><BR><BR>");
print("<BR><BR><BR>");
print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");

}


}
if (!$refimage){

print("<BR><BR><BR><BR>");

print("<div align=right>reading Dr: $drname &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  reported date:$diagtime</div>");


}



print("<hr size=1 color=black>");
print("<center><b>RSNA<font=2> </font></b>　TEL 000-1111-1111</center>");




?>



</body>
</html>
