{% extends "nsclc/base.html" %}

{% block title %}
Patient|Oncogene mutation profiling
{% endblock %}

{% block head %}
	<script type="text/javascript">
		function showUrlInDialogx(url, options){
		  options = options || {};
		  var tag = $("<div></div>"); //This tag will the hold the dialog content.
		  $.ajax({
		    url: url,
		    type: (options.type || 'GET'),
		    beforeSend: options.beforeSend,
		    error: options.error,
		    complete: options.complete,
		    success: function(data, textStatus, jqXHR) {
		      if(typeof data == "object" && data.html) { //response is assumed to be JSON
		        tag.html(data.html).dialog({modal: options.modal, title: data.title}).dialog('open');
		      } else { //response is assumed to be HTML
		        tag.html(data).dialog({modal: options.modal, title: options.title}).dialog('open');
		      }
		      $.isFunction(options.success) && (options.success)(data, textStatus, jqXHR);
		    }
		  });
		}	 	
	 	
		function showUrlInDialog(url){
		  var tag = $("<div></div>");
		  $.ajax({
		    url: url,
		    success: function(data) {
		      tag.html(data).dialog({
				dialogClass: "alert",
				modal: true,
				show: "slide",
				width: 640,
			    open: function(){
			        $("body").css("overflow", "hidden");
			    },
			    close: function(){
			        $("body").css("overflow", "auto");
			    },				
			}).dialog('open');
		    }
		  });
		}	 	
	 	
	</script>
{% endblock %}


{% block content %}


<h2>Patient</h2>
<table>
	<thead>
    <tr>
        <th>病患姓名</th>
        <th>病歷號碼</th>
        <th>出生年月日</th>
        <th>性別</th>
        <th>診斷日期</th>
        <th>組織學型態</th>
        <th>初次腦轉移日期</th>
        <th>醫師</th>
	</tr>
	</thead>
    <tr>
        <td>{{ object.Patient.name }}</td>
        <td>{{ object.Patient.medical_records }}</td>
        <td>{{ object.Patient.birthday }}</td>
        <td>{{ object.Patient.gender }}</td>
        <td>{{ object.DxDate }}</td>
        <td>{{ object.Histology }}</td>
        <td>{{ object.BMDate }}</td>
        {% ifequal object.Physician.dept 'surg' %}
        <td style="background-color:red;">
        {% else %}
        <td style="background-color:green;">
		{% endifequal %}
        {{ object.Physician.name }}</td>

		<td><a href='update/'><img src='{{open_icon_library}}/icons/png/24x24/actions/edit.png' /></a></td>
		<td><a href='delete/'><img src='{{open_icon_library}}/icons/png/24x24/actions/edit-delete.png' /></a></td>
    </tr>
</table>

<br/>

<table>
<tr>
<td>
<table>
{% for field in object.fields %}
<tr>
	<td>{{field.verbose_name}}</td>
<!-- 	<td>{{field.name}}</td> -->
    <td>{{field.value}}</td>

</tr>
{% endfor %}
</table>
</td>
<td>
<table>
{% for field in object.many_to_many %}
<tr>
	<td>{{field.verbose_name}}</td>
<!-- 	<td>{{field.name}}</td> -->
    <td>
    	{% for v in field.value %}
    	{{v}}<br/>
    	{% endfor %}
    </td>

</tr>
{% endfor %}
</table>
</td>
</tr>
</table>


<br/>

{% for treatment in object.Patient.treatment_set.all %}
<table>
	<thead>
        <tr>
            <th>Treament ID</th>
            <th>病床號</th>
            <th>ICD9診斷</th>
            <th>其他診斷</th>
            <th>Tracking Mode</th>
            <th>Date</th>
            <th>Accounting</th>
		</tr>
	</thead>
	<tr>
		<td>{{ treatment.id }}</td>
		<td>{{ treatment.bed }}</td>
		<td>{{ treatment.icd9 }}</td>
		<td>{{ treatment.other_diagnosis }}</td>
		<td>{{ treatment.get_tracking_mode_display }}</td>
		<td>{{ treatment.date_started }} ~ {{ treatment.date_completed }}</td>
		<td>{{ treatment.get_accounting_display }}</td>
	</tr>
</table>
<table>
	<thead>
        <tr>
            <th>Lesion ID</th>
            <th>Target Location</th>
            <th>Anatomic Sublocation</th>
            <th>Pathology</th>
            <th>Target Volume (mm<sup>3</sup>)</th>
            <th>Dimensions (mm)</th>
            <th>Dose(cGy)</th>
            <th>RECIST最佳反應</th>
            <th>電腦刀治療病灶惡化(RECIST)</th>
            <th>電腦刀治療病灶惡化日期</th>
            <th>MRI影像判讀偽惡化</th>
<!--             <th>Prescription Isodose Curve</th>
            <th>Date</th>
            <th>Delete</th>
            <th>Edit</th> -->        
		</tr>
	</thead>
{% for lesion in treatment.lesion_set.all %}

		<tr>
            <td>{{ lesion.id }}</td>
            <td>{{ lesion.sub_location.target_location }}</td>
            <td>{{ lesion.sub_location }}</td>
            <td>{{ lesion.pathology }}</td>
            <td>{{ lesion.volume }}</td>
            <td>{{ lesion.dimensions }}</td>
            <td>{{ lesion.dose }}/{{ lesion.fractions }}</td>
            <td>{{ lesion.ntarget_set.all.0.TargetResponse }}</td>
            <td>{{ lesion.ntarget_set.all.0.TargetControl }}</td>
            <td>{{ lesion.ntarget_set.all.0.TargetControlDate }}</td>
            <td>{{ lesion.ntarget_set.all.0.Pseudoprogression }}</td>
            
            <td>
            	{% if lesion.ntarget_set.all.count %}
				<a href='#' onclick="showUrlInDialog('{% url 'target_detail' pk=lesion.id %}'); return false;"><img src='{{open_icon_library}}/icons/png/24x24/actions/view-list-details.png' /></a>
				<a href='{% url 'target_update' pk=lesion.id %}'><img src='{{open_icon_library}}/icons/png/24x24/actions/edit.png' /></a>
				<a href='{% url 'target_delete' pk=lesion.id %}'><img src='{{open_icon_library}}/icons/png/24x24/actions/edit-delete.png' /></a>
            	{% else %}
				<a href='{% url 'target_add' pk=lesion.id %}'><img src='{{open_icon_library}}/icons/png/24x24/actions/edit-add.png' /></a>
            	{% endif %}
            </td>
<!--             <td>{{ lesion.iso_dose_curve }}%</td>
            <td>{%ifequal lesion.start_date lesion.end_date%}{{lesion.end_date}}{%else%}{{lesion.start_date}} ~ {{lesion.end_date|date:"m-d"}}{%endifequal%}</td>
            <td><a href='/lesion/delete/{{lesion.id}}/'><img src="/site_media/img/actions/edit-delete.png" alt="Delete" border=0 title='Delete lesion'/></a></td>
            <td><a href='/lesion/update/{{lesion.id}}/'><img src="/site_media/img/apps/accessories-text-editor.png" alt="Edit" border=0 title='Edit lesion'/></a></td> -->		</tr>

{% endfor %}
</table>
<br/>
{% endfor %}


{% endblock %}
