<?php


// parameter

$patid = $_GET['patid'];
$size = $_GET['size'];
$browser = $_GET['browser'];
$scwidth = $_GET['scwidth'];
$scheight = $_GET['scheight'];
$userid = $_GET['userid'];
$permission = $_GET['permission'];



//matching window

if($scheight == "1200"){
	$ordinary_width = "560";
	$ordinary_height = "550";
	}
if($scheight == "1050"){
	$ordinary_width = "580";
	$ordinary_height = "573";
	}
if($scheight == "1024"){
	$ordinary_width = "530";
	$ordinary_height = "520";
	}

if($scheight == "960"){
	$ordinary_width = "470";
	$ordinary_height = "450";
	}

if($scheight == "864"){
	$ordinary_width = "450";
	$ordinary_height = "432";
	}

if($scheight == "768"){
	$ordinary_width = "480";
	$ordinary_height = "460";
	}
	
if($scheight == "600"){
	$ordinary_width = "335";
	$ordinary_height = "304";
	}

if(!$scheight){
	$ordinary_width = "335";
	$ordinary_height = "304";
	}

?>


<!doctype html public "-//w3c//dtd html 3.2//ja">
<html>
<head>
<title>study list for <?php echo $patid ?></title>
<meta http-equiv=content-type content="text/html; charset=x-euc-jp">

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






function WINDOWopen(cgurl,throwed_width,throwed_height){
window.open(cgurl,'','toolbar=0,location=0,directories=0,status=0,menu=0,scrollbars=1,resizable=0,width=' + throwed_width + ',height=' + throwed_height );
}




function echo_dicom(url) {
//		window.open(dicom_path);
var dicom;
dicom=window.open("","","width=5,height=5,top=0,left=0");
dicom.focus();
dicom.document.write('<body bgcolor="#000000" onload=javascript:location.replace("' + url + '");setTimeout("window.close()","10000")>');
dicom.document.write('</body></html>');
dicom.document.close();
}




	list = new Array();

	


function alertlist(){
	var valfor;
	for(i=0;i<list.length;i++){
	valfor = eval(list[i]);
	alert(valfor) ;
	}
}


var study_series_list = new Array;


function cacth_paging(studyUID,seriesUID){

//alert("ok");

	var orig_image_num = document.getElementById(seriesUID).image_num.value ;
	var orig_position_x = document.getElementById(seriesUID).position_x.value ;
	var orig_position_y = document.getElementById(seriesUID).position_y.value ;
	var orig_position_z = document.getElementById(seriesUID).position_z.value ;
	var orig_target_orientation = document.getElementById(seriesUID).target_orientation.value ;
	var orig_patient_position = document.getElementById(seriesUID).patient_position.value ;



	for(i = 0; i < study_series_list[studyUID].length; i++){
		if(seriesUID != study_series_list[studyUID][i]){
//			alert("array ok");
			var win_tmp = study_series_list[studyUID][i];
			
				for(j = 0; j < list.length; j++){
				var element = list[j];
				if (element==undefined)
				{
					alert("no array");
					break;
				}
					if(win_tmp == element.name){
//					alert('bingo! ' + element.name);
					
					var target_patient_position = document.getElementById(element.name).patient_position.value ;
					
					if(orig_patient_position == target_patient_position){
//					alert("position same !");
					
					
					var target_image_num = document.getElementById(element.name).image_num.value ;
					var target_position_x = document.getElementById(element.name).position_x.value ;
					var target_position_y = document.getElementById(element.name).position_y.value ;
					var target_position_z = document.getElementById(element.name).position_z.value ;
					var target_orientation = document.getElementById(element.name).target_orientation.value ;
					

						if(orig_target_orientation == target_orientation){
						
						switch (target_orientation) {
						case "x":
						element.catch_scrolling(orig_image_num,target_orientation,orig_position_x,orig_position_y,orig_position_z);
						 break;
						case "y":
						element.catch_scrolling(orig_image_num,target_orientation,orig_position_x,orig_position_y,orig_position_z);
						 break;
						case "z":
						element.catch_scrolling(orig_image_num,target_orientation,orig_position_x,orig_position_y,orig_position_z);
						 break;
						 case "variable":
						element.catch_scrolling(orig_image_num,target_orientation,orig_position_x,orig_position_y,orig_position_z);
						 break;
						 
						 }
						 
						}


					}
					}
				}
		
		}
	}

}


function win_closed(winVar) {

/* 子ウインドウから親ウインドウを調べたい場合は 
win_closed(window.opener) と書いてください
Support: http://game.gr.jp/js-ml/samples/200102/openerTest.html
*/

var ua = navigator.userAgent
if( !!winVar )
        if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 )
             && ua.indexOf('Win')!=-1 ) 
             return winVar.closed
        else return typeof winVar.document  != 'object'
    else return true
}

var now_pos_x_cli = 1;
var now_pos_y_cli = 1;
var xtarget = "";
var ytarget = "";
var get_param_x;
var get_param_y;
var win_sum = parent.back.document.windata.win_colum_sum.value;
var win_size = parent.back.document.windata.win_size_trf.value;









function win_close(){
var i;
while(true)
{
	var element=(list.shift());
	if (element==undefined)
	{
		break;
	}
	element.close();
}
}

function win_close2(){
var i;
list = parent.back.document.win_ctl.win_val.value;
while(true)
{
	var element=(list.shift());
	if (element==undefined)
	{
		break;
	}
	element.close();
}
}

function initTile(){
	parent.back.document.windata.now_pos_x.value = 1;
	parent.back.document.windata.now_pos_y.value = 1;
}

var list_status = 0;
var list_cacher = 0;

function list_set(){
	if(list && (list_status > list_cacher)){
	parent.back.document.forms['yng_brother'] = list;
	list_cacher = list_status;
	}else{
//	alert("no");
	}
}

function transfer_loop(){
	while(list){
	setTimeout("list_set()",10000);
//	alert('ok')
	}
}

//END -->
</script>





<?php
//set font size

print("<style type=\"text/css\">");
print("<!--");
print("BODY, TH, TD { font-size: 10pt; }");
print("-->");
print("</style>");


?>


<script language="javascript1.2" src="tree.js"></script>

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

<SCRIPT LANGUAGE="JavaScript">
initTile();


</script>

<?php

//
//	2002.1.1
//	DICOM to WWW Gateway :PHP script
//	Made by Norya Yokohama % Medical Division @ WERC
//  Updated by tadashi tsuchimoto @ MITT belong to yokohamazyuku
//	show_study.php
//




  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

$sql = sql_generator("show_study_patient");
$rtn_patient = $db_handle->prepare($sql);
$rtn_patient->execute(array($_GET['patid']));

  while ($patient_row = $rtn_patient->fetch(PDO::FETCH_ASSOC)) {
//	print_r($patient_row);
	$patsex = trim($patient_row['patsex']) ;
	$patname = trim($patient_row['patnam']) ;
	$patbirthdate = trim($patient_row['birthdate']) ;
  }

	$patage = calc_age($patbirthdate);
	$patname = str_replace("^^^" , "", $patname);
	$patname = str_replace("^" , ",", $patname);
	$patname = trim($patname);
	$patname = str_replace(" ","",$patname);
	$patname = str_replace(",","_",$patname);


// prepare studyUID and seriesUID selection

$sql = sql_generator("show_study_studyUID");
$rtn_studyUID = $db_handle->prepare($sql);
$sql = sql_generator("show_study_seriesUID");
$rtn_seriesUID = $db_handle->prepare($sql);

// prepair for sumnail

$sql = sql_generator("show_study_sumnail");
$rtn_sumnail = $db_handle->prepare($sql);

//get study with patientID
$rtn_studyUID->execute(array($_GET['patid']));

$study_count = $rtn_studyUID->rowCount();







print("<center>");


print("<table border=3>");

//   print table 

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

  print("<table border=3>");
  print("<TR><TH>Patient ID:</TH><tH ALIGN=RIGHT bgcolor=\"#ccffff\">$patid</TH></TR>");




  print("<TR><TH>Patient Name:</TH><tH ALIGN=LEFT bgcolor=\"#aaf555\">$patname</TH></TR>");
  print("<TR><TH>Age:</TH><tH ALIGN=LEFT bgcolor=\"#ccffff\">$patage</TH></TR>");
  print("<TR><TH>Sex:</TH><tH ALIGN=LEFT bgcolor=\"#aaf555\">$patsex</TH></TR>");
  
    print("</table>");
  



  


  print("</td>");



?>

<td>



<table>
<tr><td>



<img src="./img/2007rsna_log.gif">


</td></tr>
<tr><td>
<img src="./pgctn.jpg" width=100 height=100>
<img src="./pgctn2oxirix.jpg" width=100 height=100>
<img src="./pgctn_mobile.jpg" width=200 height=100>
</td></tr>

</table>


</td>
</tr>

<?php

//tr td for total frame
print("<tr>");
print("<td colspan=\"2\">");

  print("<table border=3>\n");
  print("<th>Study Date</th>");

  print("<th>Deploy Series</th>");

  print("<th>order</th>");
  print("<th>Report</th>");
  print("<th>Procedure</th>");
  print("<th>preference</th>");
  print("<th>Img Diag.</th>");



  print("</TR>\n");

while ($studyUID_row = $rtn_studyUID->fetch(PDO::FETCH_ASSOC)) {
	$studyUID = $studyUID_row['studyuid'] ;
	$date = $studyUID_row['studat'] ;
	$stuid = $studyUID_row['stuid'] ;
	$mod = $studyUID_row['study_mod'] ;
	$image_count = $studyUID_row['num_instances'] ;
	$study_report = $studyUID_row['study_report'] ;







$study_ima_num = 0;
$study_sumnail_array = array();


$study_ima_num = $image_count;


$fdate = str_replace(" ","_",$date);
$trimed_mod = trim($mod);
//$trimed_stutim = trim($stutim);
$trimed_stuid = trim($stuid);
$trimed_studyUID = trim($studyUID);


$anker = $trimed_studyUID;

if(!@$top){
$top=50;
$left=550;
}

print("<tr>");

print("<td valign=\"top\">$fdate</td>");

print("<td valign=\"top\">");
print("<div class=\"trHandler\">");

      @$pre_studes = pg_result($rtn_serdes,0,studes);
	$pre_studes = str_replace("?","",$pre_studes);

print("<a href=# onclick=\"trToggle('$anker');return false\"><img border=0 width=17 height=14 src=\"img/folda.gif\" name=\"trImage\">$mod $pre_studes</a>");

print("<input type=\"button\" value=\"study open\" onClick=\" ");


$scwidth = $_GET['scwidth'];
$scheight = $_GET['scheight'];

$show_image_all_scwidth = $scwidth * 0.8;
$show_image_all_scheight = $scheight * 0.8;

$ruid = $studyUID ;

	 print("list.push(window.open('show_image_all.php?requestType=WADO&studyUID=$studyUID&ruid=$ruid&patid=$patid','$studyUID','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=no,resizable=yes,width=$show_image_all_scwidth,height=$show_image_all_scheight'));list_status=list_status + 1;");
	 
print("\">");

print("</div>");



print("<div id=$anker class=\"trHidden\">");





$win_open_list = array();
$win_control_list = array();

print("<script language=\"JavaScript\">");
print("study_series_list['$studyUID']  = new Array;");
print("</script>");

	//get series with studyUID
	$rtn_seriesUID->execute(array($studyUID));
	while ($seriesUID_row = $rtn_seriesUID->fetch(PDO::FETCH_ASSOC)) {
	
	
	$seriesUID = $seriesUID_row['seriesuid'] ;
	$sernum = $seriesUID_row['sernum'] ;
	$series_mod = $seriesUID_row['mod'] ;
	$char = "0";


	$name = $patname;






  $trimed_mod = trim($mod);
$ruid = $studyUID ;






if(@$winnum){
	$winnum = $winnum + 1;
}
else{
	$winnum = 1;
}

$win = "win"."$winnum";
//print("$win<br>");

if(!@$winarray){
	$winarray = array();
	$winarray[] = $win;	
}
else{
	$winarray[] = $win;
}





$rtn_sumnail->execute(array($seriesUID));
	while ($sumnail_row = $rtn_sumnail->fetch(PDO::FETCH_ASSOC)) {
	$path = $sumnail_row['path'] ;
	}
	
$path = $file_root_path . $path;







	

// touch dir prepare procedure
$patid=trim($patid);
$date=trim($date);
$date=str_replace(" ", "",$date);
$studyUID=trim($studyUID);
$seriesUID=trim($seriesUID);	
if(!@$wl){
@$target_dir=touch_dir($patid,$date,$studyUID,$seriesUID,"default");
}else{
$wlww_con = $wl . $ww;
@$target_dir=touch_dir($patid,$date,$studyUID,$seriesUID,$wlww_con);
}
$target_path=($target_dir . "/" );
$file_name=basename($path);//print("path: $path\n");
$target_file_path=$target_path . $file_name . ".dcm";




//Symbolic link original file to target files.

$jpg_file_name = $target_file_path . "-sum_w.jpg";
if(!file_exists($jpg_file_name)){

	if(is_link($target_file_path)){
	if($path != linkinfo($target_file_path)){
	system("rm -f $target_file_path");
	symlink($path,$target_file_path);
	}
	}
	else{
	symlink($path,$target_file_path);
	}

	@$wl_from_dicomtag = get_dicom_value("0028,1050",$path);
	@$ww_from_dicomtag = get_dicom_value("0028,1051",$path);
	@$patposition_from_dicomtag = get_dicom_value("0018,5100",$path);



	$wl_from_dicomtag = trim(floor($wl_from_dicomtag));
	$ww_from_dicomtag = trim(floor($ww_from_dicomtag));
	$patposition_from_dicomtag = trim(floor($patposition_from_dicomtag));
	
	if($wl_from_dicomtag){
	$wl = $wl_from_dicomtag;
	$ww = $ww_from_dicomtag;
	}

if($wl){
$jpg_file_name=dcmtojpg_sum1_w($target_file_path,$wl,$ww);
}else{
$jpg_file_name=dcmtojpg_sum1($target_file_path);
}
}

print("<img src=$jpg_file_name width=64>");
//end sumnail images 

array_push($study_sumnail_array, $jpg_file_name);

//print("$studes" );

print("<A HREF=\"javascript:void(0);\" onclick=\"list.push(window.open('show_image.php?requestType=WADO&studyUID=$studyUID&seriesUID=$seriesUID','$seriesUID','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$ordinary_width,height=$ordinary_height'));list_status=list_status + 1;\">Series Open</a>");

array_push($win_open_list,"list.push(window.open('show_image.php?requestType=WADO&studyUID=$studyUID&seriesUID=$seriesUID','$seriesUID','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$ordinary_width,height=$ordinary_height'));list_status=list_status + 1;");


array_push($win_control_list,"$seriesUID");

print("<script language=\"JavaScript\">");
print("study_series_list['$studyUID'].push('$seriesUID');");
print("</script>");


print("num;" . "_" . "$sernum" . ":");

if($trimed_mod == "XA"){

$window_tag_movie = $seriesUID . "_movie";

print("<A HREF=\"javascript:void(0);\" onclick=\"list.push(window.open('make_mpg.php?patid=$patid&name=$name&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&sernum=$sernum&mod=$mod&studyUID=$studyUID&seriesUID=$seriesUID&ruid=$ruid','$window_tag_movie','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$ordinary_width,height=$ordinary_height'));\">movie</a>");

}

@$zip_serdes = trim($serdes);
$zip_serdes = str_replace(" ","",$zip_serdes);
$zip_serdes = str_replace("*","",$zip_serdes);
$zip_serdes = str_replace(".","",$zip_serdes);
$zip_serdes = str_replace(",","_",$zip_serdes);
$zip_serdes = str_replace("/","",$zip_serdes);
if($zip_serdes and $zip_serdes != "series"){
$zip_serdes = $zip_serdes ;
}else{
$sernum = trim($sernum);
$zip_serdes = $sernum ;
}

$mod = trim($mod);
$mod = str_replace(" ","",$mod);
$mod = str_replace("*","",$mod);
$mod = str_replace(".","",$mod);
$mod = str_replace(",","_",$mod);
$mod = str_replace("/","",$mod);
$mod = str_replace("\s","",$mod);


@$zip_file = $patid . "_"  . $patname4 ."_" . $date ."_" . $mod . "_" . $stutim . "_" . $zip_serdes .  ".zip";


print("<br>");


if($top >= 400){
	$top=50;
}

$top=$top+20;
$left=$left+20;



}



print("<input type=\"button\" value=\"all series open\" onClick=\" ");
foreach ($win_open_list as $value) {
      print ("$value ");
     }
print("\">");

print(" ");

if($trimed_mod == "XA"){

$window_tag_movie = $seriesUID . "_all_movie";

print("<A HREF=\"javascript:void(0);\" onclick=\"list.push(window.open('make_mpg_for_all.php?patid=$patid&name=$name&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&sernum=$sernum&mod=$mod&studyUID=$studyUID&ruid=$ruid','$window_tag_movie','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$ordinary_width,height=$ordinary_height'));\">all movie</a>");

}

print("</div>");


print("$study_ima_num");
foreach ($study_sumnail_array as $sum_image) {
print("<img src=$sum_image  width=\"20\" >");
}



foreach ($win_control_list as $value) {
	print("<form id=$value name=$value>");
    print("<input type=hidden id=image_num name=image_num value=\"\">");
	print("<input type=hidden id=patient_position name=patient_position value=\"\">");
	print("<input type=hidden id=position_x name=position_x value=\"\">");
	print("<input type=hidden id=position_y name=position_y value=\"\">");
	print("<input type=hidden id=position_z name=position_z value=\"\">");
	print("<input type=hidden id=target_orientation name=target_orientation value=\"\">");
	print("</form>");
     }


print("</td>");

  $trimed_mod = trim($mod);

//  $ruid = "$date"."$trimed_mod"."$stutim";
  $ruid = $studyUID ;

if($winnum){
	$winnum = $winnum + 1;
}
else{
	$winnum = 1;
}
$win = "win"."$winnum";
//print("$win<br>");
if(!$winarray){
	$winarray = array();
	$winarray[] = $win;	
}
else{
	$winarray[] = $win;
}

$order_width = 980 ;
$order_height = 980 ;


print("<td ALIGN=LEFT valign=\"top\">");

print("<a href=\"javascript:void(0);\" onclick=\"javascript:list.push(window.open('show_order.php?&date=$date&patid=$patid&name=$patname&studyUID=$studyUID&seriesUID=$seriesUID&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&ruid=$ruid&mod=$mod&patsex= $patsex&patage=$patage&userid=$userid&mod=$mod','$win','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$order_width,height=$order_height'));list_status=list_status + 1;\">order</a>");





print("</td>");

if($winnum){
	$winnum = $winnum + 1;
}
else{
	$winnum = 1;
}
$win = "win"."$winnum";
//print("$win<br>");
if(!$winarray){
	$winarray = array();
	$winarray[] = $win;	
}
else{
	$winarray[] = $win;
}

$report_width = 670 ;
$report_height = 690 ;


print("<td ALIGN=LEFT valign=\"top\">");

print("<div class=\"trHandler\">");

$anker_input = $anker . "input";

print("<a href=# onclick=\"trToggle('$anker_input');return false\"><img border=0 width=17 height=14 src=\"img/folda.gif\" name=\"trImage\">report</a>");


print("</div>");


print("<div id=$anker_input class=\"trHidden\">");

print("<a href=\"javascript:void(0);\" onclick=\"javascript:$win=window.open('update_report.php?date=$date&patid=$patid&name=$patname&studyUID=$studyUID&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&ruid=$ruid&mod=$mod&patsex= $patsex&patage=$patage&userid=$userid&mod=$mod','_blank','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$report_width,height=$report_height');\">Reporting</a><br>");
print("<a href=\"javascript:void(0);\" onclick=\"javascript:$win=window.open('update_report_refer.php?date=$date&patid=$patid&name=$patname&studyUID=$studyUID&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&ruid=$ruid&mod=$mod&patsex= $patsex&patage=$patage&userid=$userid&mod=$mod','_blank','toolbar=no,location=no,top=$top,left=$left,directories=no,status=no,menu=no,scrollbars=yes,resizable=yes,width=$report_width,height=$report_height');\">Ref image</a>");


print("</div>");

print("</td>");


print("<td ALIGN=LEFT valign=\"top\">");

print("<div class=\"trHandler\">");

$anker_report = $anker . "report";

print("<a href=# onclick=\"trToggle('$anker_report');return false\"><img border=0 width=17 height=14 src=\"img/folda.gif\" name=\"trImage\">Procedure</a>");


print("</div>");


print("<div id=$anker_report class=\"trHidden\">");

print("<table>");



print("<tr>");




print("<td ALIGN=LEFT valign=\"top\"><input type=\"button\" value=\"Register Examination\" onClick=\"javascript:WINDOWopen('update_report_order.php?date=$date&patid=$patid&name=$patname&studyUID=$studyUID&seriesUID=$seriesUID&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&study_report=$study_report&ruid=$ruid&mod=$mod&patsex= $patsex&patage=$patage&userid=$userid','550','550');\"></form></td>");


print("</tr>");



print("<tr>");

print("<td ALIGN=LEFT valign=\"top\"><input type=\"button\" value=\"Report Printing\" onClick=\"javascript:WINDOWopen('show_report.php?date=$date&patid=$patid&name=$patname&studyUID=$studyUID&seriesUID=$seriesUID&size=$size&browser=$browser&scwidth=$scwidth&scheight=$scheight&ruid=$ruid&mod=$mod&patsex= $patsex&patage=$patage&userid=$userid','700','700');\"></form></td>");



print("</tr>");





print("</table>");

print("</div>");

print("</td>");

$mod = trim($mod);
$mod = str_replace(" ","",$mod);
$mod = str_replace("*","",$mod);
$mod = str_replace(".","",$mod);
$mod = str_replace(",","_",$mod);
$mod = str_replace("/","",$mod);
$mod = str_replace("\s","",$mod);

$patname_mod = trim($patname);
$patname_mod = str_replace(" ","",$patname_mod);
$patname_mod = str_replace(",","_",$patname_mod);
//$zipfile = $patid . "_"  . $patname_mod ."_" . $date ."_" . $mod . "_" . $stutim .  ".zip";


print("<td valign=\"top\">");

print("<div class=\"trHandler\">");

$anker_pref = $anker . "preference";

print("<a href=# onclick=\"trToggle('$anker_pref');return false\"><img border=0 width=17 height=14 src=\"img/folda.gif\" name=\"trImage\">preference</a>");


print("</div>");


print("<div id=$anker_pref class=\"trHidden\">");


print("<form action=\"add_linker_show.php\" target=_blank>");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=patname_mod value=$patname_mod>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=hidden name=ruid value=$ruid>");
print("<input type=\"submit\" value=\"web reference\">");
print("</form>");

$zipfile = $patid . "_" .  $patname_mod . "_" . $date ."_" . $mod .  "_dcm.zip";

//print("<form action=\"make_dicom_pack.php\" target=\"_self\">");
print("<form action=\"make_dicom_pack.php\">");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=study_uid value=$studyUID>");
print("<input type=hidden name=zipfile value=$zipfile>");
print("<input type=hidden name=patname_mod value=$patname_mod>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=\"submit\" value=\"Pack DICOM\">");
print("</form>");

$zipfile = $patid . "_" .  $patname_mod . "_" . $date ."_" . $mod .  "_jpg.zip";


//print("<form action=\"make_dicom_pack.php\" target=\"_self\">");
print("<form action=\"make_jpeg_pack.php\">");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=study_uid value=$studyUID>");
print("<input type=hidden name=zipfile value=$zipfile>");
print("<input type=hidden name=patname_mod value=$patname_mod>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=\"submit\" value=\"Pack JPEG\">");
print("</form>");

print("<form action=\"select_series_for_volume.php\">");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=study_uid value=$studyUID>");
print("<input type=hidden name=patname_mod value=$patname_mod>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=\"submit\" value=\"3D\">");
print("</form>");




$mod = trim($mod);
$mod = str_replace(" ","",$mod);
$mod = str_replace("｡｡","",$mod);
$mod = str_replace("*","",$mod);
$mod = str_replace(".","",$mod);
$mod = str_replace(",","_",$mod);
$mod = str_replace("/","",$mod);
$mod = str_replace("\s","",$mod);

$patname1 = trim($patname);
$patname2 = str_replace(" ","",$patname1);
$patname3 = str_replace("｡｡","",$patname2);
$patname4 = str_replace(",","_",$patname3);

/*
if($browser == "mac"){

print("<form action=\"make_pgctn2osirix.php\">");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=zipfile value=$zipfile>");
print("<input type=hidden name=patname4 value=$patname4>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=\"submit\" value=\"Switch to OsiriX\">");
print("</form>");


}elseif($browser == "win"){

print("<form action=\"make_pgctn2univiewer.php\">");
print("<input type=hidden name=date value=$date>");
print("<input type=hidden name=patid value=$patid>");
print("<input type=hidden name=patname value=$patname>");
print("<input type=hidden name=mod value=$mod>");
print("<input type=hidden name=size value=$size>");
print("<input type=hidden name=zipfile value=$zipfile_bat>");
print("<input type=hidden name=patname4 value=$patname4>");
print("<input type=hidden name=browser value=$browser>");
print("<input type=hidden name=scwidth value=$scwidth>");
print("<input type=hidden name=scheight value=$scheight>");
print("<input type=hidden name=userid value=$userid>");
print("<input type=hidden name=permission value=$permission>");
print("<input type=hidden name=univiewer_tag value=$univiewer_tag>");
print("<input type=\"submit\" value=\"Switch to Univiewer\">");
print("</form>");


}else{

print("OS check dis");

}

*/

print("</div>");

print("</td>");


print("<td valign=\"top\">");
if(!$study_report or $study_report == "" or  $study_report == "null" ){
print("Reserving");
}elseif($study_report == "report_on" or  fnmatch("*divide*", $study_report)  ){
print("<font color=red>");
print("Requesting");
print("</font>");
}
elseif($study_report == "no_report"){
print("<font color=black>");
print("Unnecessary");
print("</font>");
}
elseif($study_report == "done"){
print("<font color=blue>");
print("Completing");
print("</font>");
}
elseif($study_report == "transient"){
print("<font color=green>");
print("Temporay");
print("</font>");
}
elseif($study_report == "transfer"){
print("<font color=orange>");
print("Requeting to Specialist");
print("</font>");
}
elseif($study_report == "out"){
print("<font color=red>");
print("Requesting to Visiting Diagnosist");
print("</font>");
}
//print("$study_report");
print("</td>");

    print("</tr>\n");


//study & series query end
}


  print("</table>\n");





//td tr for total frame
    print("</td>");
    print("</tr>");
  print("</table>");

db_contact_end($db_handle);
   








?>
<SCRIPT language="JavaScript">
document.forms['brother']=list;
</script>

<INPUT TYPE="BUTTON" VALUE="window close" onClick="win_close()">
<INPUT TYPE="BUTTON" VALUE="reset setup" onClick="initTile()">




<br>

<form action="main_menu.php" >
<input type=hidden name=size value="<? echo$size; ?>">
<input type=hidden name=browser value="<? echo$browser; ?>">
<input type=hidden name=scwidth value="<? echo$scwidth; ?>">
<input type=hidden name=scheight value="<? echo$scheight; ?>">
<input type=hidden name=userid value="<? echo $userid; ?>">
<input type=hidden name=permission value="<? echo $permission; ?>">
<input type="button" value="Back to the Main Menu" onClick="win_close();submit()">

</form>


</center>

<form id=test name=test>
<input type=hidden id=test_col name=test_col value="<? echo$size; ?>">
</form>

</body>
</html>
