<?php

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


?>

<!doctype html public "-//w3c//dtd html 3.2//ja">
<html>
<head>
<title>show order</title>
<meta http-equiv=content-type content="image/jpeg; charset=x-euc-jp">

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

?>
//END -->
</script>


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


<?php

//
//	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
//  order related source
//


  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);


  $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");
  exit;


  }





print("<p>");

if($refimage){
	if($refimage2){
		if($refimage3){
			if($refimage4){
				if($refimage5){
					$ref_num = 6;
					      }
					$ref_num = 5;
				      }	
				$ref_num = 4;
				}
			$ref_num = 3;
			}
		$ref_num = 2;
	      }

if(!@$ref_num){
  $ref_num = 1;
}



if($refimage6){
print("<img src=\"show_orderimage.php?ruid=$ruid&date=$date&patid=$patid&name=$name&studyUID=$studyUID&refimage=$refimage6\" Width=930 Height=1500>");
}





?>


</body>
</html>
