{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h5 class="report-header" style="width: 200%">{{ page_title }}</h5>
    <table class="report-data" width="200%">
        <thead class="header">
        <tr>
            <th>Referral Date</th>
            <th>Received Date</th>
            <th>Patient</th>
            <th>Patient Type</th>
            <th>Referring Branch</th>
            <th>Clinician</th>
            <th>Diagnosis</th>
            <th>Latest Encounter</th>
            <th>Latest Encounter Date</th>
            <th>Latest Encounter Status</th>
            <th>BMI</th>
            <th>O2 Saturation</th>
            <th>Initial AHI</th>
            <th>Current AHI</th>
            <th>Servicing Branch</th>
            <th>Service</th>
            <th>Specialist</th>
            <th>Latest Specialist Encounter</th>
            <th>Latest Specialist Encounter Date</th>
            <th>Latest Specialist Encounter Status</th>
            <th width="15%">Note</th>
        </tr>
        </thead>
        <tbody>
        {% set totalCount = 0 %}
        {% for record in records %}
            {% set trC = loop.index > 1 and loop.index % 2 == 0 ? 'even' : 'odd' %}
            {% set totalCount = totalCount + 1 %}
            <tr class="{{ trC }}">
                <td>{{ record.referralDate }}</td>
                <td>{{ record.receiveDate }}</td>
                <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode}) }}" target="_blank">{{ record.patientName }}</a></td>
                <td>{{ record.patientType }}</td>
                <td>{{ record.healthFacility }}</td>
                <td>{{ record.providerFullName }}</td>
                <td>{{ record.diagnosisDesc }}</td>
                <td>{{ record.chartType }}</td>
                <td>{{ record.chartDate }}</td>
                <td>{{ record.chartStatus }}</td>
                <td>{{ record.bmi }}</td>
                <td>{{ record.otwo_saturation }}</td>
                <td>{{ record.init_ahi }}</td>
                <td>{{ record.ahi }}</td>
                <td>{{ record.servicingHealthFacility }}</td>
                <td>{{ record.serviceDesc }}</td>
                <td>{{ record.specialistFullName }}</td>
                <td>{{ record.sp_chartType }}</td>
                <td>{{ record.sp_chartDate }}</td>
                <td>{{ record.sp_chartStatus }}</td>
                <td>{{ record.note|raw }}</td>
            </tr>
        {% endfor %}
    </table>
    <div>Total Records: {{ totalCount }}</div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}