{% extends "base.html" %}

{% block head %}
  <script>
    $(document).ready(function(){
      $("#id_Date").datepicker();
    });
  </script>
{% endblock %}


{% block title %}
Follow-up new volume
{% endblock %}

{% block content %}
    <h2>Follow-up new volume</h2>
    <table>
    <thead>
        <tr>
            <th>Patient ID</th><td>{{ patient.id }}</td>
            <th>姓名</th><td>{{ patient.name }}</td>
            <th>病歷號</th><td>{{ patient.medical_records }}</td>
            <th>性別</th><td>{{ patient.get_gender_display }}</td>
            <th>生日</th><td>{{ patient.birthday }}</td>
        </tr>
        <tr>
            <th>地址</th><td>{{ patient.address }}</td>
            <th>電話</th><td>{{ patient.phone }}</td>
            <th>身份證號</th><td>{{ patient.id_cards }}</td>
            <th>Memo</th><td>{{ patient.memo }}</td>
            <th></th><td>
            {% if patient.dead %}
            <em>{{patient.dead}}已死亡</em>
            {% endif %}
            </td>
        </tr>
        <tr>
            <th>身高(cm)</th><td>{{ patient.height }}</td>
            <th>體重(kg)</th><td>{{ patient.weight }}</td>
            <!-- 
            <th>已追蹤日期</th><td>{{ patient.last_followup }}</td>
            <th>預追蹤日期</th><td>{{ patient.next_followup }}</td>
            -->
        </tr>
    </thead>
    </table>
    <hr/>
    {% for treatment in patient.treatment_set.all %}
    <table>
    <thead>
        <tr>
            <th>Lesion ID</th>
            <th>Target Location</th>
            <th>Anatomic Sublocation</th>
            <th>Pathology</th>
            <th>Date</th>
            <th>Target Volume (mm<sup>3</sup>)</th>
            <th>Prescription Dose (cGy)</th>
            <th>Number of Fractions</th>
            <th>Prescription Isodose Curve</th>
        </tr>
    </thead>
    <tbody>
      {% 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>{%ifequal lesion.start_date lesion.end_date%}{{lesion.end_date}}{%else%}{{lesion.start_date}} ~ {{lesion.end_date|date:"m-d"}}{%endifequal%}</td>
            <td>{{ lesion.volume }}</td>
            <td>{{ lesion.dose }}</td>
            <td>{{ lesion.fractions }}</td>
            <td>{{ lesion.iso_dose_curve }}%</td>
        </tr>
    </tbody>
    <thead>
          <tr>
              <th></th>
              <th></th>
              <th></th>
              <th>Follow ID</th>
              <th>Date</th>
              <th>Followup volume (mm3)</th>
              <th>A (mm)</th>
              <th>B (mm)</th>
              <th>C (mm)</th>
              <th>Memo</th>
              <th>Delete</th>
          </tr>
    </thead>
    <tbody>
        {% for followup in lesion.lesionfollow_set.all %}
          <tr>
              <td></td>
              <td></td>
              <td></td>
              <td>{{ followup.id }}</td>
              <td>{{ followup.Date }}</td>
              <td>{{ followup.Volume }}</td>
              <td>{{ followup.A }}</td>
              <td>{{ followup.B }}</td>
              <td>{{ followup.C }}</td>
              <td>{{ followup.Memo }}</td>
              <td><a href='/followup/delete_volume/{{followup.id}}/'>
                <img src="/site_media/img/actions/edit-delete.png" alt="Delete" border=0 title='Delete treatment'/>
              </a></td>
          </tr>
        {% endfor %}
      {% endfor %}
    </tbody>
    </table>
    {% endfor %}
    <hr/>
    <form action="." class="cssform" method="post">{% csrf_token %}
      <p>{{form.Lesion.label_tag}}
        <select name="Lesion" id="id_Lesion">  
        {% for treatment in patient.treatment_set.all %}
        {% for lesion in treatment.lesion_set.all %}
        <option value="{{lesion.id}}">{{lesion.id}}</option>
        {% endfor %} 
        {% endfor %} 
      </select>
      {{form.Lesion.errors}}</p>
      <p>{{form.Date.label_tag}}<input type="text" name="Date" id="id_Date" value="{{idate}}"/>{{form.Date.errors}}</p>
      <p>{{form.Volume.label_tag}}{{form.Volume}}{{form.Volume.errors}}</p>
      <p>{{form.A.label_tag}}{{form.A}}{{form.A.errors}}</p>
      <p>{{form.B.label_tag}}{{form.B}}{{form.B.errors}}</p>
      <p>{{form.C.label_tag}}{{form.C}}{{form.C.errors}}</p>
      <p>{{form.Memo.label_tag}}{{form.Memo}}{{form.Memo.errors}}</p>
      <input type="submit" value="Submit" />
    </form>      
{% endblock %}