{% extends "base.html" %}

{% block title %}
Treatment detail
{% endblock %}

{% block content %}
    <h2>Treatment detail</h2>

    <table>
    <thead>
        <tr>
            <th>Patient ID</th><td>{{ patient.id }}</td>
            <th>姓名</th><td><a href='/patient/detail/{{patient.id}}/'>{{ patient.name }}</a></td>
            <th>病歷號</th><td>{{ patient.medical_records }}</td>
            <th>性別</th><td>{{ patient.get_gender_display }}</td>
            <th>生日</th><td>{{ patient.birthday }}</td>
            <td rowspan=2>
                <a href='/patient/detail/{{patient.id}}/'><img src="/site_media/img/actions/document-open.png" alt="Detail" border=0 title="All {{patient.name}}'s treatments"/></a>
                <a href='/patient/update/{{patient.id}}/'><img src="/site_media/img/apps/accessories-text-editor.png" alt="Edit" border=0 title='Edit {{patient.name}}'/></a>
                <a href='/patient/print/{{patient.id}}/' target='_blank'><img src="/site_media/img/actions/document-print.png" alt="Print" border=0 title='Print summary'/></a>
            </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>
        </tr>
        <tr>
            <th>已追蹤日期</th><td>{{ patient.last_followup }}</td>
            <th>預追蹤日期</th><td>{{ patient.next_followup }}</td>
        </tr>
    </thead>
    </table>
    <hr>

    <table>
        <thead>
            <tr>
                <th>送案日期</th>
                <th>疾病分類號</th>
                <th>其他診斷</th>
                <th>申請原因</th>
                <th>核定結果</th>
            </tr>
        </thead>
        <tbody>
            {% for nhiorder in nhiorders %}
            <tr>
                <td>{{nhiorder.PackageTime}}</td>
                <td>{{nhiorder.Diagnosis}}</td>
                <td>{{nhiorder.other_diagnosis}}</td>
                <td>{{nhiorder.Reason}}</td>
                <td>{{nhiorder.Quantity}}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <hr>

    <table>
    <thead>
        <tr>
            <th>Treatment ID</th><td>{{ treatment.id }}</td>
            <th>病床號</th><td>{{ treatment.bed }}</td>
            <th>ICD</th><td colspan=3>
            {% if treatment.icd10cm %}
             {{ treatment.icd10cm }}
            {% else %}
             {{ treatment.icd9 }}
            {% endif %}
            	</td>
            <th>其他診斷</th><td colspan=3>{{ treatment.other_diagnosis }}</td>
            <td rowspan=3>
                <a href='/treatment/update/{{treatment.id}}/'><img src="/site_media/img/apps/accessories-text-editor.png" alt="Edit" border=0 title='Edit treatment'/></a>
                <a href='/treatment/print/{{treatment.id}}/' target='_blank'><img src="/site_media/img/actions/document-print.png" alt="Print" border=0 title='Print treatment'/></a>
                <a href='/treatment/report/{{treatment.id}}/' target='_blank'><img src="/site_media/img/actions/edit-find-replace.png" alt="Report" border=0 title="Report treatment"/></a>
                <a href='/treatment/record/{{treatment.id}}/' target='_blank'><img height="32" src="/site_media/img/history-logo.jpg" alt="History" border=0 title='Print treatment'/></a>
            </td>
        </tr>
        <tr>
            <th>Oncologist</th><td>{{ treatment.oncologist }}</td>
            <th>Surgeon</th><td>{{ treatment.surgeon }}</td>
            <th>Date</th><td>{%if treatment.date_started == treatment.date_completed%}{{treatment.date_completed}}{%else%}{{treatment.date_started}}~{{treatment.date_completed}}{%endif%}</td>
            <th>記帳別</th><td>{{ treatment.get_accounting_display }}</td>
            <th>Karnofsky score</th><td>{{ treatment.karnofsky_score }}</td>
        </tr>
        <tr>
            <th>Disease Stage</th><td>{{ treatment.disease_stage }}</td>
            <th>Primary Tumor Site</th><td>{{ treatment.primary_tumor_site }}</td>
            <th>已</th><td>{{ treatment.input }}</td>
            <th>待</th><td>{{ treatment.output }}</td>
            <th>Memo</th><td>{{ treatment.memo }}</td>
        </tr>
    </thead>
    </table>
    <hr>

    {% if vevents %}
    <table>
    <thead>
        <tr>
            <th>Event ID</th>
            <th>Mode</th>
            <th>Remark</th>
            <th>Start</th>
            <th>Duration</th>
            <th>Description</th>
            <th>批價相關資訊</th>
            <th>Delete</th>
            <th>Edit</th>
        </tr>
    </thead>
    <tbody>
        {% for vevent in vevents %}
        <tr>
            <td>{{ vevent.id }}</td>
            <td>{{ vevent.get_mode_display }}</td>
            <td>{{ vevent.mode_remark|default:"" }}</td>
            <td>{{ vevent.DTSTART }}</td>
            <td>{{ vevent.DURATION | date:"H:i"}}</td>
            <td>{{ vevent.DESCRIPTION|default:"" }}</td>
            <td>{{ vevent.price }}</td>
            <td><a href='/event/delete/{{vevent.id}}/'><img src="/site_media/img/actions/edit-delete.png" alt="Delete" border=0 title='Delete event'/></a></td>
            <td><a href='/event/update/{{vevent.id}}/'><img src="/site_media/img/apps/accessories-text-editor.png" alt="Edit" border=0 title='Edit event'/></a></td>
        </tr>
        {% endfor %}
    </tbody>
    </table>
    {% endif %}
    <a href='/event/create/{{treatment.id}}/'>New event</a>
    <hr>

    {% if lesions %}
    <table>
    <thead>
        <tr>
            <th>Lesion ID</th>
            <th>Target Location</th>
            <th>Anatomic Sublocation</th>
            <th>Pathology</th>
            <th>Target Volume</th>
            <th>Prescription Dose (cGy)</th>
            <th>Number of Fractions</th>
            <th>Prescription Isodose Curve</th>
            <th>Coverage</th>
            <th>Date</th>
            <th>Delete</th>
            <th>Edit</th>
        </tr>
    </thead>
    <tbody>
        {% for lesion in lesions %}
        <tr>
            <td>{{ lesion.id }}</td>
            <td>{{ lesion.sub_location.target_location }}</td>
            <td>{{ lesion.sub_location }}</td>
            <td>{{ lesion.pathology }}</td>
            <td>
                {% if lesion.volume_measure %}
                {{ lesion.volume_measure.cubic_centimeter }} cm<sup>3</sup>
                {% else %}
                {{ lesion.volume }} mm<sup>3</sup>
                {% endif %}
            </td>
            <td>{{ lesion.dose }}</td>
            <td>{{ lesion.fractions }}</td>
            <td>{{ lesion.iso_dose_curve }}%</td>
            <td>{{ lesion.coverage }}%</td>
            <td>{%if lesion.start_date == lesion.end_date%}{{lesion.end_date}}{%else%}{{lesion.start_date}} ~ {{lesion.end_date|date:"m-d"}}{%endif%}</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 %}
    </tbody>
    </table>
    {% endif %}

    <a href='/lesion/create/{{treatment.id}}/'/>New lesion</a>


{% endblock %}
