<?php

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

?>
<!doctype html public "-//w3c//dtd html 3.2//ja">
<html>
<head>
<title>update report</title>
<meta http-equiv=content-type content="text/html;">

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



//END -->
</script>

<script language="javascript1.2" src="tree.js"></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
//  update report
//


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

//patient query

  print("<table>");
  print("<TR><TH>patient ID:</TH><tH ALIGN=RIGHT bgcolor=\"#ccffff\">$patid</TH><TH>sex:</TH><tH ALIGN=RIGHT bgcolor=\"#ccffff\">$patsex</TH></TR>");
  print("<TR><TH>aptient name:</TH><tH ALIGN=LEFT bgcolor=\"#ccd555\">$name</TH><TH>age:</TH><tH ALIGN=RIGHT bgcolor=\"#ccffff\">$patage</TH></TR>");
  @$fdate=formatDate($date);
  print("<TR><TH>study date:</TH><tH ALIGN=LEFT bgcolor=\"#cccfff\">$date</TH>");

  print("</table>");



  $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("new report insert");
  $sql_insert = "insert into reportlevel (ruid) values ('$ruid')";
  $rtn_insert = $db_handle->prepare($sql_insert);
  $rtn_insert->execute();


  }




if(@$orderdr){
print("now order Dr <b>$orderdr</b> <br>");
}



?>

<b>regist Irradiation Report</b><br>
<table>


<tr>
<td>


<?php
//print("$study_report");

print("<font color=red>");

if($study_report == "report_on"){
print("<b>now mode :read needed </b>");
}
elseif($study_report == "no_report"){
print("<b>now mode :no need </b>");
}
elseif($study_report == "done"){
print("<b>now mode :already done </b>");
}
elseif($study_report == "transient"){
print("<b>now mode :transient </b>");
}
elseif($study_report == "transfer"){
print("<b>now mode :support</b>");
}else{
print("<b>now mode :reserved </b>");
}

print("</font>");



?>

<FORM ENCTYPE="multipart/form-data" ACTION="referimage_do6.php" METHOD=POST >
<b>file reading</b><br>
<?php

print("$study_report ");

if($study_report == "" or $study_report == "null" ){
print("<input type=\"radio\" name=\"report_on\" value=\"\" checked>not registered");
}
else{
print("<input type=\"radio\" name=\"report_on\" value=\"\">not registered");
}

if($study_report == "report_on" or fnmatch("*divide*",$study_report)){
print("<input type=\"radio\" name=\"report_on\" value=\"report_on\" checked>report need");
}
else{
print("<input type=\"radio\" name=\"report_on\" value=\"report_on\">report need");
}

if($study_report == "out"){
print("<input type=\"radio\" name=\"report_on\" value=\"out\" checked>report need(special)");
}
else{
print("<input type=\"radio\" name=\"report_on\" value=\"out\">report need(special)");
}

if($study_report == "no_report"){
print("<input type=\"radio\" name=\"report_on\" value=\"no_report\" checked>no need");
}
else{
print("<input type=\"radio\" name=\"report_on\" value=\"no_report\">no need");
}



print("<br>");




?>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10000000">



<INPUT NAME="userfile" TYPE="file">
<input type=hidden name=ruid value="<? echo $ruid; ?>">
<input type=hidden name=studyUID value="<? echo $studyUID; ?>">
<INPUT TYPE="submit" VALUE="update Irradiation Report">
</FORM>

</td>
</tr>

<tr>
<td align=right>


<FORM action="referimage_del6.php" METHOD=POST>
<input type=hidden name=ruid value="<? echo $ruid; ?>">
<INPUT TYPE="submit" VALUE="delete Irradiation Report">
</FORM>


</td>
</tr>

</tr>

</table>

<b>regist film reading</b><br>
<table>


<tr>
<td>






</td>

</tr>

</table>


<?
print("<b>now Irradiation Report</b><br>");

if($refimage6){
print("we have<br>");
print("<img src=\"show_refimage.php?date=$date&patid=$patid&name=$name&ruid=$ruid&studyUID=$studyUID&refimage=$refimage6\" Width=500 Height=700>");
}


?>





</body>
</html>
