{% load calculate_age %}
{% load stack %}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<script Language="JavaScript"><!--
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.ChartNo.value == "")
  {
    alert("請在 \"ChartNo\" 欄位輸入一數值。");
    theForm.ChartNo.focus();
    return (false);
  }

  if (theForm.ChartNo.value.length < 6)
  {
    alert("在 \"ChartNo\" 欄位，至少請輸入 6 的字元。");
    theForm.ChartNo.focus();
    return (false);
  }

  if (theForm.ChartNo.value.length > 7)
  {
    alert("在 \"ChartNo\" 欄位，最多請輸入 7 的字元。");
    theForm.ChartNo.focus();
    return (false);
  }
  return (true);
}
//--></script>
<html>
<head>
<title>電腦刀治療紀錄</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" fprolloverstyle="">		A:hover {
			color: red;
		}
</style>
</head>

<body>
<div id="PrintButton"  style="position: absolute; left:0in; top:0in; width:120px; height: 50px; z-index: 20">
    <button id=BUTTON1 language=JavaScript name="b_print" onclick="doprint();" style="HEIGHT:25px; WIDTH:140px; background-color:#D0E8FF;">
        <font size="2" color="#ff0000">列 印 記 錄 摘 要</font>
    </button>
</div>

<center>
  <table width="563" height="0" border="0" cellpadding="0" cellspacing="0" id="tbl" name="tbl">
  <tr>
  <td width="563" height="0" align="center"><font size="4" face="標楷體" color="#003366">
      國 立 台 灣 大 學 醫 學 院 附 設 醫 院</font></td>
  </tr>
  <tr>
  <td width="563" height="0" align="center"><font size="3" face="標楷體" color="#003366">National Taiwan University Hospital</font></td>
  </tr>
  <td width="563" height="40" align="center">
  <font size="5" face="標楷體" color="#003366">電腦刀(CyberKnife) 治療紀錄</font></td>
  </tr>
  </table>

<div class="pagination">
    <center><table name="tbl" id="tbl" border="0" cellpadding="0" cellspacing="0" width="660"><tr>
	<td style='width:33%'>
        {% if contacts.has_previous %}
	    <p align=center>
            <a href="?page={{ contacts.previous_page_number }}">previous</a>
	    </p>
        {% endif %}
	</td>

	<td style='width:33%'>
	    <p align=center>
        {% ifnotequal contacts.paginator.num_pages 1 %}
            Page {{ contacts.number }} of {{ contacts.paginator.num_pages }}
        {% endifnotequal %}
 	    
	    </p>
	</td>

	<td style='width:33%'>
        {% if contacts.has_next %}
	    <p align=center>
            <a href="?page={{ contacts.next_page_number }}">next</a>
	    </p>
        {% endif %}
	</td>
    </td></table></center>
</div>

</center>

{% with contacts.object_list as lesions %}
<center>

<table name="tbl" id="tbl" border="0" cellpadding="0" cellspacing="0" width="660">
        <tr>
            <td height="20"><font size="3" >姓名：{{treatment.patient.name}}</font></td>
            <td height="20"><font size="3" >性別：
{% ifequal treatment.patient.gender 1 %}
男
{% else %}
女
{% endifequal %}
	    </font></td>
            <td height="20"><font size="3" >生日：{{treatment.patient.birthday}}</font></td>
            <td height="20"><font size="3" >年齡：{{ treatment.patient.birthday|timesince:treatment.date_started }}</font></td>
            <td height="20"><font size="3" >病歷號碼：{{treatment.patient.medical_records}}</font></td>
        </tr>
</table>
<table name="tbl" id="tbl" border="0" cellpadding="0" cellspacing="0" width="660">
        <tr>
            <td height="20"><font size="3" >治療日期：{{treatment.date_started}}
{% ifnotequal treatment.date_started treatment.date_completed %}
	    ~ {{treatment.date_completed}}
{% endifnotequal %}
	    </font></td>
            <td height="20"><font size="3" >報告日期：{% now "Y-m-d" %}</font></td>
            <td height="20"><font size="3" >醫師：
{% if treatment.surgeon %}
{{treatment.surgeon}},
{% endif %}
{{treatment.oncologist}}</font></td>
        </tr>
</table>
<br/>

<!--662-->

<table  width="650" height="740" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" id="outside" name="outside">
<thead align="center">
<tr><th>Lesion No.</th>
{%for lesion in lesions%}
<td>{{contacts.start_index|add:forloop.counter0}}</td>
{%endfor%}</tr>
</thead>
<tbody align="center">

<tr><th>Location</th>
{%for lesion in lesions%}
<td>{{lesion.sub_location.target_location}}-{{lesion.sub_location}}</td>
{%endfor%}</tr>

<tr><th>Tumor dimension (mm)</th>
{%for lesion in lesions%}
<td>{{lesion.dimensions}}</td>
{%endfor%}</tr>

<tr><th>Tumor volume(mm<sup>3</sup>)</th>
{%for lesion in lesions%}
<td>{{lesion.volume}}</td>
{%endfor%}</tr>

<tr><th>Volume treated at ref. dose (mm<sup>3</sup>)</th>
{%for lesion in lesions%}
<td>
<script type="text/javascript">
document.write(({{lesion.ci}}*{{lesion.volume}}*{{lesion.coverage}}/100).toFixed(2));
</script>
</td>
{%endfor%}</tr>

<!--
<tr><th>Plan name</th>
{%for lesion in lesions%}
<td>{{lesion.plan_name|default:"　"}}</td>
{%endfor%}</tr>
-->

<tr><th>Collimator size(mm)</th>
{%for lesion in lesions%}
<td>{{lesion.collimator}}</td>
{%endfor%}</tr>

<tr><th>Path No.</th>
{%for lesion in lesions%}
<td>{{lesion.path_no}}</td>
{%endfor%}</tr>

<tr><th>Beam No.</th>
{%for lesion in lesions%}
<td>{{lesion.beam_no}}</td>
{%endfor%}</tr>

<!--
<tr><th>Beam No. per node</th>
{%for lesion in lesions%}
<td>　</td>
{%endfor%}</tr>
-->

<tr><th>MU limit(Max./Min.)</th>
{%for lesion in lesions%}
<td>{{lesion.mu_max}}/{{lesion.mu_min}}</td>
{%endfor%}</tr>

<!--
<tr><th>Constraints No.</th>
{%for lesion in lesions%}
<td>　</td>
{%endfor%}</tr>
-->

<tr><th>Px dose(cGy)</th>
{%for lesion in lesions%}
<td>{{lesion.dose}}</td>
{%endfor%}</tr>

<tr><th>Fraction No.</th>
{%for lesion in lesions%}
<td>{{lesion.fractions}}</td>
{%endfor%}</tr>

<tr><th>Px isodose line(%)</th>
{%for lesion in lesions%}
<td>{{lesion.iso_dose_curve}}</td>
{%endfor%}</tr>

<tr><th>Max. dose(cGy)</th>
{%for lesion in lesions%}
<td>{{lesion.dmax}}</td>
{%endfor%}</tr>

<tr><th>Min. dose(cGy)</th>
{%for lesion in lesions%}
<td>{{lesion.dmin}}</td>
{%endfor%}</tr>

<tr><th>Mean dose(cGy)</th>
{%for lesion in lesions%}
<td>{{ 100|stnew|stpush:100|stpush:lesion.coverage|stsub|stpush:lesion.dose|stpush:lesion.dmin|stadd|stmult|stpush:lesion.dose|stpush:lesion.dmax|stadd|stpush:lesion.coverage|stmult|stadd|stpush:200|stdiv|stget|floatformat:2 }}</td>
{%endfor%}</tr>

<tr><th>Coverage % at ref. dose</th>
{%for lesion in lesions%}
<td>{{lesion.coverage}}</td>
{%endfor%}</tr>

<tr><th>CI: PIV/TIV</th>
{%for lesion in lesions%}
<td>{{lesion.ci}}</td>
{%endfor%}</tr>

<tr><th>nCI: PIVxTV/TIV<sup>2</sup></th>
{%for lesion in lesions%}
<td>{{lesion.nci}}</td>
{%endfor%}</tr>

<tr><th>HI: Dmax/RxDose</th>
{%for lesion in lesions%}
<td>
<script type="text/javascript">
document.write((100.0/{{lesion.iso_dose_curve}}).toFixed(2));
</script>
</td>
{%endfor%}</tr>

<tr><th>Date</th>
{%for lesion in lesions%}
<td>{%ifequal lesion.start_date lesion.end_date%}{{lesion.end_date}}{%else%}{{lesion.start_date}} ~ {{lesion.end_date|date:"m-d"}}{%endifequal%}</td>
{%endfor%}</tr>

<tr><th>Memo</th>
{%for lesion in lesions%}
<td>{{lesion.memo|default:"　"}}</td>
{%endfor%}</tr>

</tbody>
</table>
</center>
{% endwith %}


<!--
<div id="Foot">
<br>
<center>
<hr><br><br>
<font size="1">系統分析設計：資訊室    吳立婷    分機：1096<br>最後更新日期：2006/2/10</font><br>
</center>
</div>
-->

</body>

</html>
<script language="JavaScript">
function doprint() {
	// 列印前先將 "列印"按鈕 hide 起來
	//PrintButton.style.display='none';
	//QueryChartNo.style.display='none';
	//RTInsert.style.display='none';
	//Foot.style.display='none';
	var odiv = document.getElementsByTagName("div")
	for(i=0; i < odiv.length; i++){
		//alert(odiv.length);
		//alert(odiv[i].id);
		if( odiv[i].id != "" )
		odiv[i].style.display='none';
	}
	window.print();
	// 列印完之後再將 "列印"按鈕 show 出來
//	QueryChartNo.style.display='inline';
//	PrintButton.style.display='inline';
//	RTInsert.style.display='inline';
//	Foot.style.display='inline';
//	for(i=0; i < odiv.length; i++)
//		odiv[i].style.display='inline';
}
</script>

