
{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    <style>
        .modalTop {
            top: -8% !important;
        }
        .input-small{
            margin: 0;
            padding: 5px;
            height: auto;
        }
    </style>
    <div id="flash-messages-container">
    </div>
    <div class="row max-width-initial">
        <div class="small-12 columns">
            <nav aria-label="You are here:" role="navigation">
                <ul class="breadcrumbs" style="margin-bottom:0;">
                    <li><a href="{{ path('patient') }}">Patient List</a></li>
                    <li>
                        <span class="show-for-sr">Current: </span> Patient Details
                    </li>
                </ul>
            </nav>
            {% include '@RxConnexion/Patient/overview.html.twig' with {patient: patient, redFlag: patientRedFlag, patientReferringProviderNote: patientReferringProviderNote, patientOverview: patientOverview} %}
            <div class="content-container">
                <div class="content-container-content">
                    <ul class="tabs custom-tabs" data-tabs id="patient-tabs">
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Profile' in userData.accesses %}
                            <li class="tabs-title {{ tab is null or tab is empty or tab == 'p' ? 'is-active' : '' }}"><a href="#panel-profile" aria-selected="true">Profile</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Health Facility' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'hf' ? 'is-active' : '' }}" data-dt-id="patient-health-facility-datalist"><a href="#panel-health-facility" aria-selected="false">Branch</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Encounter' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'c' ? 'is-active' : '' }}" data-dt-id="chart-datalist"><a href="#panel-chart" aria-selected="false">Encounter</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Services' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'ser' ? 'is-active' : '' }}"  data-dt-id="panel-services"><a href="#panel-services" aria-selected="false">Services</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Medical' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'm' ? 'is-active' : '' }}" data-dt-id="panel-medical"><a href="#panel-medical"  aria-selected="false">Medical</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Appointment' in userData.accesses %}
                            <li class="tabs-title {{ tab == 's' ? 'is-active' : '' }}" data-dt-id="patient-schedule-datalist"><a href="#panel-schedule" aria-selected="false">Appointment</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Affiliation' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'a' ? 'is-active' : '' }}" data-dt-id="panel-affiliation"><a href="#panel-affiliation" aria-selected="false">Affiliation</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail File' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'f' ? 'is-active' : '' }}" data-dt-id="file-datalist"><a href="#panel-files" aria-selected="false">Files</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail File From Import' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'cmf' ? 'is-active' : '' }}" data-dt-id="clinicmasterFile-datalist"><a href="#panel-clinicmasterFile" aria-selected="false">Files (Imported)</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Letter' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'l' ? 'is-active' : '' }}" data-dt-id="patient-letter-datalist"><a href="#panel-letters" aria-selected="false">Letters</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Email' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'l' ? 'is-active' : '' }}" data-dt-id="patient-email-datalist"><a href="#panel-email" aria-selected="false">Email</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Billing' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'b' ? 'is-active' : '' }}" data-dt-id="panel-billing"><a href="#panel-billing" aria-selected="false">Billing</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Purchased Items' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'pi' ? 'is-active' : '' }}" data-dt-id="patient-purchased-items-dt"><a href="#panel-purchased-items" aria-selected="false">Purchased Items</a></li>
                        {% endif %}
                        {#{% if userData.type == 'Super Admin' or 'Admin Patient Payment' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'py' ? 'is-active' : '' }}"><a href="#panel-payments" aria-selected="false">Payments</a></li>
                        {% endif %}#}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Red Flag' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'rf' ? 'is-active' : '' }}" data-dt-id="patient-red-flag-datalist"><a href="#panel-redflags" aria-selected="false">Flag</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Ticket' in userData.accesses %}
                            {#<li class="tabs-title {{ tab == 'ti' ? 'is-active' : '' }}"><a href="#panel-ticket" aria-selected="false">Tickets</a></li>#}
                            <li class="tabs-title {{ tab == 'ti' ? 'is-active' : '' }}" data-dt-id="patient-ticket-datalist"><a href="#panel-ticket" aria-selected="false">Endorsements</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Reminder' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'ti' ? 'is-active' : '' }}" data-dt-id="patient-reminder-datalist"><a href="#panel-reminder" aria-selected="false">Reminders</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient History' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'ph' ? 'is-active' : '' }}" data-dt-id="patient-history-datalist"><a href="#panel-patient-history" aria-selected="false">History</a></li>
                        {% endif %}
                        {% if userData.type == 'Super Admin' or 'Admin Patient Detail Note' in userData.accesses %}
                            <li class="tabs-title {{ tab == 'n' ? 'is-active' : '' }}" data-dt-id="panel-notes"><a href="#panel-notes" aria-selected="false">Notes</a></li>
                        {% endif %}
                    </ul>
                    <div class="tabs-content custom-tabs-content" data-tabs-content="patient-tabs">
                        <div class="tabs-panel {{ tab is null or tab is empty or tab == 'q' ? 'is-active' : '' }}" id="panel-profile">
                            {% if userData.type == 'Super Admin' or 'Admin Patient Detail Profile' in userData.accesses %}
                                {% include '@RxConnexion/Patient/patient_profile.html.twig' with {patient: patient, latestPatientChartWithVitals: latestPatientChartWithVitals, patientProfileAssessment:patientProfileAssessment, staticMap: staticMap} %}
                            {% endif %}
                        </div>
                        <div class="tabs-panel {{ tab == 'c' ? 'is-active' : '' }}" id="panel-chart">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Chart Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Encounter</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Chart New' in userData.accesses %}
                                    <a class="href-new-action" href="{{ path('patient_chart_form', {patient_id: patient_id}) }}" >Add Encounter</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="chart-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Branch</th>
                                    <th>Encounter ID</th>
                                    <th>Encounter Type</th>
                                    <th>Encounter Date</th>
                                    <th>Clinician</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'ser' ? 'is-active' : '' }}" id="panel-services">
                            <ul class="tabs custom-tabs" data-tabs id="patient-services-tabs">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Services' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 is null or tab2 is empty or tab2 == '1' ? 'is-active' : '' }}" data-dt-id="patient-services-datalist"><a href="#panel-patient-service-specialist" aria-selected="true">Specialist</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Services' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'pso' ? 'is-active' : '' }}" data-dt-id="patient-services-other-datalist"><a href="#panel-patient-service-other" aria-selected="true">Others</a></li>
                                {% endif %}
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-services-tabs">
                                <div class="tabs-panel {{ tab2 is null or tab2 is empty or tab2 == '1' ? 'is-active' : '' }}" id="panel-patient-service-specialist">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Services New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-services-form href-new-action" data-action="n" data-id="0">New Service</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-services-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Service</th>
                                            <th>Branch</th>
                                            <th>Specialist</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == '2' ? 'is-active' : '' }}" id="panel-patient-service-other">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Services New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-services-other-form href-new-action" data-action="n" data-id="0">New Other Service</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-services-other-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Service</th>
                                            <th>Branch</th>
                                            <th>Specialist</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tabs-panel {{ tab == 'hf' ? 'is-active' : '' }}" id="panel-health-facility">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Health Facility New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-health-facility-form href-new-action" data-action="n" data-id="0">New Branch</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-health-facility-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Branch</th>
                                    <th>Address</th>
                                    <th>Phone No.</th>
                                    <th>Fax No.</th>
                                    <th>Start Date</th>
                                    <th>End Date</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'm' ? 'is-active' : '' }}" id="panel-medical">
                            <ul class="tabs custom-tabs" data-tabs role="tablist" id="patient-medical-tabs">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Medical Diagnosis' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 is null or tab2 is empty or tab2 == 'md' ? 'is-active' : '' }}" data-dt-id="patient-medical-diagnosis-datalist"><a href="#panel-medical-diagnosis" role="tab" tabindex="0" aria-selected="true" >Diagnosis</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Treatment Consideration' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'tc' ? 'is-active' : '' }}" data-dt-id="patient-treatment-consideration-datalist"><a href="#panel-treatment-consideration" role="tab" tabindex="0" aria-selected="true" >Treatment Consideration</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Treatment Plan' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'tp' ? 'is-active' : '' }}" data-dt-id="patient-treatment-plan-datalist"><a href="#panel-treatment-plan" role="tab" tabindex="0" aria-selected="true" >Treatment Plan</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Medical Medication' in userData.accesses %}
                                    {% if patient.diagnoses|length != 0 %}
                                        <li class="tabs-title {{ tab2 == 'mm' ? 'is-active' : '' }}" data-dt-id=""><a href="#panel-medical-medication" role="tab" tabindex="1" aria-selected="false" >Medication</a></li>
                                    {% endif %}
                                {% endif %}
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-medical-tabs">
                                <div role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab2 is null or tab2 is empty or tab2 == 'md' ? 'is-active' : '' }}" id="panel-medical-diagnosis">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Medical Diagnosis New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-chart-medical-diagnosis-form href-new-action" data-action="n" data-id="0">New Diagnosis</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-medical-diagnosis-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Type</th>
                                            <th>Diagnosis</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Notes</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab2 == 'mm' ? 'is-active' : '' }}" id="panel-treatment-consideration">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Treatment Consideration New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-treatment-consideration-form href-new-action" data-action="n" data-id="0">New Treatment Consideration</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-treatment-consideration-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Treatment Consideration</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Notes</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab2 == 'mm' ? 'is-active' : '' }}" id="panel-treatment-plan">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Treatment Plan New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-treatment-plan-form href-new-action" data-action="n" data-id="0">New Treatment Plan</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-treatment-plan-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Treatment Plan</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Notes</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab2 == 'mm' ? 'is-active' : '' }}" id="panel-medical-medication">
                                    {% for key,patientDiagnosis in patient.diagnoses %}
                                        <h5 style="text-align: center">{{ patientDiagnosis.diagnosis.description }}</h5>
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Patient Detail Medical Medication New' in userData.accesses %}
                                                <a href="javascript:void(0)" class="href-patient-chart-medical-diagnosis-medication-form{{ patientDiagnosis.id }} href-new-action" data-pd-id="{{ patientDiagnosis.idEncoded }}" data-action="n" data-id="0">New Medication</a>
                                            {% endif %}
                                        </div>
                                        <table class="display responsive" id="patient-medical-diagnosis-medication-datalist{{ key }}" data-id="{{ patientDiagnosis.id }}" width="100%">
                                            <thead>
                                            <tr>
                                                <th>Medication</th>
                                                <th>Start Date</th>
                                                <th>End Date</th>
                                                <th>Notes</th>
                                                <th>Action</th>
                                            </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>
                        <div class="tabs-panel {{ tab == 'a' ? 'is-active' : '' }}" id="panel-affiliation">
                            <ul class="tabs custom-tabs" data-tabs id="patient-affiliation-tabs">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Insurance' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 is null or tab2 is empty or tab2 == '1' ? 'is-active' : '' }}" data-dt-id="patient-insurance-datalist"><a href="#panel-affiliation-insurance" aria-selected="true">Insurance</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Referring Health Facility' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == '2' ? 'is-active' : '' }}" data-dt-id="patient-referring-health-facility-datalist"><a href="#panel-affiliation-referring-health-facility" aria-selected="true">Referring Affiliate</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Referring Provider' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == '3' ? 'is-active' : '' }}" data-dt-id="patient-referring-provider-datalist"><a href="#panel-affiliation-referring-provider" aria-selected="true">Referring Physician</a></li>
                                {% endif %}
                                {#{% if userData.type == 'Super Admin' or 'Admin Patient Specialist' in userData.accesses %}#}
                                    {#<li class="tabs-title {{ tab2 == '4' ? 'is-active' : '' }}"><a href="#panel-affiliation-specialist" aria-selected="true">Specialist</a></li>#}
                                {#{% endif %}#}
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-affiliation-tabs">
                                <div class="tabs-panel {{ tab2 is null or tab2 is empty or tab2 == '1' ? 'is-active' : '' }}" id="panel-affiliation-insurance">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Insurance New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-insurance-form href-new-action" data-action="n" data-id="0">New Insurance</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-insurance-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Insurance</th>
                                            <th>Insurance No.</th>
                                            <th>PCN/PN/GN</th>
                                            <th>Fax No.</th>
                                            <th>Phone No.</th>
                                            <th>Mobile No.</th>
                                            <th>Expiry</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == '2' ? 'is-active' : '' }}" id="panel-affiliation-referring-health-facility">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or ('Admin Patient Referring Health Facility New' in userData.accesses and 'Admin Patient Referring Provider New' in userData.accesses) %}
                                            <a href="javascript:void(0)" class="href-patient-linked-referring-health-facility-and-provider-form href-new-action" data-action="n" data-id="0">New Linked Referring Affiliate & Physician</a>
                                            <span>|</span>
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Referring Health Facility New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-referring-health-facility-form href-new-action" data-action="n" data-id="0">New Referring Affiliate</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-referring-health-facility-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Branch</th>
                                            <th>Address</th>
                                            <th>Fax No.</th>
                                            <th>Phone No.</th>
                                            <th>Mobile No.</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == '3' ? 'is-active' : '' }}" id="panel-affiliation-referring-provider">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or ('Admin Patient Referring Health Facility New' in userData.accesses and 'Admin Patient Referring Provider New' in userData.accesses) %}
                                            <a href="javascript:void(0)" class="href-patient-linked-referring-health-facility-and-provider-form href-new-action" data-action="n" data-id="0">New Linked Referring Affiliate & Physician</a>
                                            <span>|</span>
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Referring Provider New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-referring-provider-form href-new-action" data-action="n" data-id="0">New Physician</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-referring-provider-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Full Name</th>
                                            <th>Address</th>
                                            <th>Fax No.</th>
                                            <th>Phone No.</th>
                                            <th>Mobile No.</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == '4' ? 'is-active' : '' }}" id="panel-affiliation-specialist">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Specialist New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-specialist-form href-new-action" data-action="n" data-id="0">New Specialist</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-specialist-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Full Name</th>
                                            <th>Address</th>
                                            <th>Phone No.</th>
                                            <th>Mobile No.</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tabs-panel {{ tab == 'f' ? 'is-active' : '' }}" id="panel-files">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient File Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer File</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient File New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-file-form href-new-action" data-action="n" data-id="0">New File</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="file-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Date</th>
                                    <th>User</th>
                                    <th>Description</th>
                                    <th>Type</th>
                                    <th>Notes</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'cmf' ? 'is-active' : '' }}" id="panel-clinicmasterFile">
                            <table class="display responsive" id="clinicmasterFile-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Description</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'n' ? 'is-active' : '' }}" id="panel-notes">
                            <ul class="tabs custom-tabs" data-tabs id="patient-note-tabs">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Clinical Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'cn' ? 'is-active' : '' }}" data-dt-id="patient-note-clinical-datalist"><a href="#panel-note-clinical" aria-selected="true">Clinical</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Billing Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'bn' ? 'is-active' : '' }}" data-dt-id="patient-note-billing-datalist"><a href="#panel-note-billing" aria-selected="true">Billing</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Appointment Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'an' ? 'is-active' : '' }}" data-dt-id="patient-note-appointment-datalist"><a href="#panel-note-appointment" aria-selected="true">Appointment</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Specialist Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'sn' ? 'is-active' : '' }}" data-dt-id="patient-note-specialist-datalist"><a href="#panel-note-specialist" aria-selected="true">Specialist</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Letter Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'ln' ? 'is-active' : '' }}" data-dt-id="patient-note-letter-datalist"><a href="#panel-note-letter" aria-selected="true">Letter</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient All Note' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 is null or tab2 is empty or tab2 == 'on' ? 'is-active' : '' }}" data-dt-id="patient-note-datalist"><a href="#panel-note-old" aria-selected="true">All</a></li>
                                {% endif %}
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-note-tabs">
                                <div class="tabs-panel {{ tab2 == 'cn' ? 'is-active' : '' }}" id="panel-note-clinical">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="{{ constant('RxConnexionBundle\\Entity\\PatientNoteEntity::TYPE_CLINICAL') }}" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-clinical-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'bn' ? 'is-active' : '' }}" id="panel-note-billing">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="{{ constant('RxConnexionBundle\\Entity\\PatientNoteEntity::TYPE_BILLING') }}" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-billing-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'sp' ? 'is-active' : '' }}" id="panel-note-specialist">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="{{ constant('RxConnexionBundle\\Entity\\PatientNoteEntity::TYPE_SPECIALIST') }}" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-specialist-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'an' ? 'is-active' : '' }}" id="panel-note-appointment">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="{{ constant('RxConnexionBundle\\Entity\\PatientNoteEntity::TYPE_APPOINTMENT') }}" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-appointment-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'ln' ? 'is-active' : '' }}" id="panel-note-letter">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="{{ constant('RxConnexionBundle\\Entity\\PatientNoteEntity::TYPE_APPOINTMENT') }}" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-letter-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 is null or tab2 is empty or tab2 == 'on' ? 'is-active' : '' }}" id="panel-note-old">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Note</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Note New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-note-form href-new-action" data-action="n" data-type="" data-id="0">New Notes</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-note-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Type</th>
                                            <th>Created</th>
                                            <th>Created By</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tabs-panel {{ tab == 'l' ? 'is-active' : '' }}" id="panel-letters">
                            <div class="large-5 columns">
                                <div class="input-group">
                                    <label class="input-group-label">Status</label>
                                    <select class="input-group-field" id="letter_status">
                                        <option value="All" selected>All</option>
                                        {% for letterStatus in patientLetterStatus %}
                                            <option value="{{ letterStatus.id }}">{{ letterStatus.description }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                            <div class="large-5 columns"></div>
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Letter Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Letter</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Letter New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-letter-form href-new-action" data-action="n" data-id="0">New Letter</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-letter-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Date</th>
                                    <th>Letter Type</th>
                                    <th>Recipient</th>
                                    <th>Status</th>
                                    <th>Attachments</th>
                                    <th>Pages</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'pe' ? 'is-active' : '' }}" id="panel-email">
                            <div class="large-5 columns">
                                <div class="input-group">
                                    <label class="input-group-label">Status</label>
                                    <select class="input-group-field" id="email_status">
                                        <option value="All" selected>All</option>
                                        <option value="Pending">Pending</option>
                                        <option value="Sent">Sent</option>
                                    </select>
                                </div>
                            </div>
                            <div class="large-5 columns"></div>
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Email New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-email-form href-new-action" data-action="n" data-id="0">New Email</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-email-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Date</th>
                                    <th>Template</th>
                                    <th>Status</th>
                                    <th>Attachments</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'b' ? 'is-active' : '' }}" id="panel-billing">
                            <ul class="tabs custom-tabs" data-tabs id="patient-billing-tabs">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Billing' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 is null or tab2 is empty or tab2 == 'bb' ? 'is-active' : '' }}" data-dt-id="patientBilling-datalist"><a href="#panel-billing-billing" aria-selected="true">Billing</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Rental' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'bpr' ? 'is-active' : '' }}" data-dt-id="patient-rental-datalist"><a href="#panel-billing-rental">Rental</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Payment' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'bp' ? 'is-active' : '' }}" data-dt-id="patientPayment-datalist"><a href="#panel-billing-payment">Payment</a></li>
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Refund' in userData.accesses %}
                                    <li class="tabs-title {{ tab2 == 'bref' ? 'is-active' : '' }}" data-dt-id="patient_billing_refund-datalist"><a href="#panel-billing-refund">Refund</a></li>
                                {% endif %}
                            </ul>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-billing-tabs">
                                <div class="tabs-panel {{ tab2 is null or tab2 is empty or tab2 == 'bb' ? 'is-active' : '' }}" id="panel-billing-billing">
                                    <div class="row max-width-initial">
                                        <div class="large-5 columns">
                                            <div class="input-group">
                                                <label class="input-group-label">Status</label>
                                                <select class="input-group-field" id="billing-status">
                                                    <option value='All' selected>All</option>
                                                    <option value='Paid'>Paid</option>
                                                    <option value='Pending Payment'>Pending Payment</option>
                                                    <option value='Void'>Void</option>
                                                    <option value='Returned'>Returned</option>
                                                    <option value='Refunded'>Refunded</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="large-5 columns"></div>
                                    </div>
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Billing Transfer' in userData.accesses %}
                                            <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Billing</a> |
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Items New' in userData.accesses %}
                                            <a href="{{ path('item') }}" target="_blank" class="href-new-action">Add Item |</a>
                                        {% endif %}
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Billing New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-billing-form href-new-action" data-action="n" data-id="0">Add Billing</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patientBilling-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            {#<th style="width: 75px;">Billing No.</th>#}
                                            <th {#style="width: 75px;"#}>Billing Date</th>
                                            <th {#style="width: 75px;"#}>Invoice No.</th>
                                            <th {#style="width: 75px;"#}>Status</th>
                                            <th {#style="width: 75px;"#}>Branch</th>
                                            <th {#style="width: 75px;"#}>Branch Address</th>
                                            <th {#style="width: 75px;"#}>Payer</th>
                                            {#<th>Details</th>#}
                                            <th {#style="width: 75px;"#} {#class="text-right"#}>Amount Due</th>
                                            <th {#style="width: 75px;"#} {#class="text-right"#}>Amount Paid</th>
                                            <th {#style="width: 75px;"#} {#class="text-right"#}>Amount Refunded</th>
                                            <th {#style="width: 75px;" class="text-right"#}>Balance</th>
                                            {#<th>Notes</th>#}
                                            <th style="width: 75px;" class="text-center">Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'bpr' ? 'is-active' : '' }}" id="panel-billing-rental">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Rental New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-rental-form href-new-action" data-action="n" data-id="0">Add Rental</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-rental-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            {#<th>Invoice No.</th>#}
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Branch</th>
                                            <th>Payer</th>
                                            <th>Payment Day</th>
                                            <th>Amount Amortization</th>
                                            <th>Amount Due</th>
                                            <th>Amount Bal</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'bp' ? 'is-active' : '' }}" id="panel-billing-payment">
                                    <div class="row max-width-initial">
                                        <div class="large-5 columns">
                                            <div class="input-group">
                                                <label class="input-group-label">Status</label>
                                                <select class="input-group-field" id="payment-status">
                                                    <option value='All' selected>All</option>
                                                    <option value='Pending'>Pending</option>
                                                    <option value='Posted'>Posted</option>
                                                    <option value='Void'>Void</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="large-5 columns"></div>
                                    </div>
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Payment New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-payment-form href-new-action" data-action="n" data-id="0">Add Payment</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patientPayment-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Invoice No.</th>
                                            <th>Branch</th>
                                            <th>Status</th>
                                            {#<th>Payment No.</th>#}
                                            <th>Payment Date</th>
                                            <th>Payment Type</th>
                                            <th class="text-right">Amount</th>
                                            <th class="text-center">Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <div class="tabs-panel {{ tab2 == 'bref' ? 'is-active' : '' }}" id="panel-billing-refund">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Billing Refund New' in userData.accesses %}
                                            <a href="javascript:void(0)" class="href-patient-billing-refund-form href-new-action" data-action="n" data-id="0">Add Refund</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient_billing_refund-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Invoice No.</th>
                                            <th>Date</th>
                                            {#<th>Payment No.</th>#}
                                            <th>Amount</th>
                                            <th>Note</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tabs-panel {{ tab == 's' ? 'is-active' : '' }}" id="panel-schedule">
                            <div>
                                {% if userData.type == 'Super Admin' or 'Admin Patient Schedule New' in userData.accesses %}
                                    <label class="text-right"><a href="{{ path('patient_schedule_form', {patient_id: patient_id}) }}" class="href-new-action">New Appointment</a></label>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-schedule-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Schedule ID</th>
                                    <th>Branch</th>
                                    <th>Appointment Date</th>
                                    <th>Clinician</th>
                                    <th>Encounter Type</th>
                                    <th>Start Time</th>
                                    <th>End Time</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                            <br/>
                            <h5 class="subheader">Appointment Notices</h5>
                            <table class="display responsive" id="appointmentNoticeFax-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Date/Time</th>
                                    <th>Schedule ID</th>
                                    <th>Type</th>
                                    <th>Name</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        {#<div class="tabs-panel {{ tab == 'py' ? 'is-active' : '' }}" id="panel-payments">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Payment New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-payment-form href-new-action" data-action="n" data-id="0">Add Payment</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patientPayment-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Invoice No.</th>
                                    <th>Payment No.</th>
                                    <th>Payment Date</th>
                                    <th>Payment Type</th>
                                    <th class="text-right">Amount</th>
                                    <th class="text-center">Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>#}
                        <div class="tabs-panel {{ tab == 'rf' ? 'is-active' : '' }}" id="panel-redflags">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Red Flag Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Flag</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Red Flag New' in userData.accesses %}
                                    {% if redFlagValid != 'exist' %}
                                        <a href="javascript:void(0)" class="href-patient-red-flag-form href-new-action" data-action="n" data-id="0">Add Flag</a>
                                    {% endif %}
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-red-flag-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Start Date</th>
                                    <th>End Date</th>
                                    <th>Flag Note</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>

                        <div class="tabs-panel {{ tab == 'ti' ? 'is-active' : '' }}" id="panel-ticket">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Endorsement Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Endorsement</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Ticket New' in userData.accesses %}
                                    <a href="{{ path('ticket_form', {action : 'n', id : 0, p: patient_id, return: path('patient_detail', {patient_id: patient_id, tab : 'ti'})}) }}" class="href-patient-ticket-form href-new-action" data-action="n" data-id="0">New Endorsement</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-ticket-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Ticket ID</th>
                                    <th>Updated</th>
                                    <th>Assigned To</th>
                                    <th>Status</th>
                                    <th>Severity</th>
                                    <th>Encounter(s)</th>
                                    <th>Latest Note</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'pi' ? 'is-active' : '' }}" id="panel-purchased-items">
                            <div class="row">
                                <div class="columns small-4">
                                    <select id="patient-purchased-items-type">
                                        <option value="">All</option>
                                        <option value="Serialized" selected>Serialized</option>
                                    </select>
                                </div>
                                <div class="columns small-4">
                                    <select id="patient-purchased-status">
                                        <option value="">All</option>
                                        <option value="Sold">Sold</option>
                                        <option value="Trial">Trial</option>
                                        <option value="Trial - Returned">Trial - Returned</option>
                                    </select>
                                </div>
                                <div class="columns small-4">
                                </div>
                            </div>
                            <table class="display responsive" id="patient-purchased-items-dt" width="100%">
                                <thead>
                                <tr>
                                    <th>Item</th>
                                    <th>Serial No.</th>
                                    <th>Invoice No.</th>
                                    <th>Billing Date</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'rem' ? 'is-active' : '' }}" id="panel-reminder">
                            <div class="text-right">
                                {% if userData.type == 'Super Admin' or 'Admin Patient Reminder Transfer' in userData.accesses %}
                                    <a class="href-patient-transfer-form href-new-action" href="javascript:void(0)" >Transfer Reminder</a> |
                                {% endif %}
                                {% if userData.type == 'Super Admin' or 'Admin Patient Remidner New' in userData.accesses %}
                                    <a href="javascript:void(0)" class="href-patient-reminder-form href-new-action" data-action="n" data-id="0">Add Reminder</a>
                                {% endif %}
                            </div>
                            <table class="display responsive" id="patient-reminder-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Reminder Type</th>
                                    <th>Assign To.</th>
                                    <th>Start Date</th>
                                    <th>End Date</th>
                                    <th>Status</th>
                                    <th>Note</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                        <div class="tabs-panel {{ tab == 'ph' ? 'is-active' : '' }}" id="panel-patient-history">
                            <table class="display responsive" id="patient-history-datalist" width="100%">
                                <thead>
                                <tr>
                                    <th>Action</th>
                                    <th>Date</th>
                                    <th>User</th>
                                    <th>Label</th>
                                    <th>Detail</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="reveal large" id="modal"  data-reveal>
        <div id="modal-content"></div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div class="reveal small" id="modal-small" style="top: -12% !important;" data-reveal>
        <div id="modal-content-small"></div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div class="reveal full" id="modal-full" data-reveal>
        <div id="modal-content-full"></div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        patient_detail.settings.patient_id = '{{ patient_id }}';
        patient_detail.settings.patient_id_decoded = '{{ patient.id }}';
        patient_detail.settings.chart_ajaxUrl = '{{ path('patient_chart_ajax_list') }}';
        patient_detail.settings.file_ajaxUrl = '{{ path('patient_file_ajax_list') }}';
        patient_detail.settings.clinicmasterFile_ajaxUrl = '{{ path('clinicmaster_file_ajax_list_patient') }}';
        patient_detail.settings.chart_formUrl = '{{ path('patient_detail', {patient_id :patient_id}) }}';
        patient_detail.settings.file_formUrl = '{{ path('patient_file_form', {patient_id :patient_id}) }}';
        patient_detail.settings.file_formActionUrl = '{{ path('patient_file_save') }}';
        patient_detail.settings.medical_diagnosis_ajaxUrl = '{{ path('patient_chart_medical_diagnosis_ajax_list') }}';
        patient_detail.settings.patient_diagnosis_formUrl= '{{ path('patient_diagnosis_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_diagnosis_formActionUrl= '{{ path('patient_diagnosis_save') }}' ;
        patient_detail.settings.medical_diagnosis_medication_ajaxUrl = '{{ path('patient_chart_medical_diagnosis_medication_ajax_list') }}';
        patient_detail.settings.diagnosis_key = '{{ patient.diagnoses|length  }}';
        patient_detail.settings.patient_diagnosis_medication_formUrl= '{{ path('patient_diagnosis_medication_form') }}' ;
        patient_detail.settings.patient_diagnosis_medication_formActionUrl= '{{ path('patient_diagnosis_medication_save') }}' ;
        patient_detail.settings.insurance_ajaxUrl= '{{ path('patient_insurance_ajax_list') }}' ;
        patient_detail.settings.patient_insurance_formUrl= '{{ path('patient_insurance_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_insurance_formActionUrl= '{{ path('patient_insurance_save') }}' ;
        patient_detail.settings.note_ajaxUrl= '{{ path('patient_note_ajax_list') }}' ;
        patient_detail.settings.note_clinical_ajaxUrl= '{{ path('patient_note_clinical_ajax_list') }}' ;
        patient_detail.settings.note_billing_ajaxUrl= '{{ path('patient_note_billing_ajax_list') }}' ;
        patient_detail.settings.note_appointment_ajaxUrl= '{{ path('patient_note_appointment_ajax_list') }}' ;
        patient_detail.settings.note_specialist_ajaxUrl= '{{ path('patient_note_specialist_ajax_list') }}' ;
        patient_detail.settings.note_letter_ajaxUrl= '{{ path('patient_note_letter_ajax_list') }}' ;
        patient_detail.settings.patient_note_formUrl= '{{ path('patient_note_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_note_formActionUrl= '{{ path('patient_note_save') }}' ;
        patient_detail.settings.schedule_ajaxUrl= '{{ path('patient_schedule_ajax_list') }}' ;
        patient_detail.settings.appointmentNoticeFax_ajaxUrl= '{{ path('patient_appointment_notice_fax_ajax_list') }}' ;
        patient_detail.settings.patient_letter_formUrl= '{{ path('patient_letter_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_letter_formActionUrl= '{{ path('patient_letter_save', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_letter_ajaxUrl= '{{ path('patient_letter_ajax_list') }}' ;
        patient_detail.settings.patient_referring_health_facility_ajaxUrl= '{{ path('patient_referring_health_facility_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_referring_health_facility_formUrl= '{{ path('patient_referring_health_facility_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_referring_health_facility_formActionUrl= '{{ path('patient_referring_health_facility_save') }}' ;
        patient_detail.settings.patient_referring_provider_ajaxUrl= '{{ path('patient_referring_provider_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_referring_provider_formUrl= '{{ path('patient_referring_provider_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_referring_provider_formActionUrl= '{{ path('patient_referring_provider_save') }}' ;
        patient_detail.settings.patient_referring_provider_autocompleteUrl = '{{ path('patient_referring_provider_autocomplete') }}';
        patient_detail.settings.patient_referring_health_facility_autocompleteUrl = '{{ path('patient_referring_health_facility_autocomplete') }}';
        patient_detail.settings.patient_insurance_autocompleteUrl = '{{ path('patient_insurance_autocomplete') }}';
        patient_detail.settings.patient_appointment_notice_fax_formUrl = '{{ path('appointment_notice_form', {patient_id : patient_id}) }}';
        patient_detail.settings.patient_billing_ajaxUrl = '{{ path('patient_billing_ajax_list') }}';
        patient_detail.settings.patient_billing_formUrl = '{{ path('patient_billing_form') }}';
        patient_detail.settings.patient_billing_formActionUrl = '{{ path('patient_billing_save') }}';
        patient_detail.settings.patient_chart_autocompleteUrl = '{{ path('patient_chart_for_billing_autocomplete') }}';
        patient_detail.settings.patient_for_billing_autocompleteUrl = '{{ path('patient_autocomplete_for_billing') }}';
        patient_detail.settings.chart_procedure_autocompleteUrl = '{{ path('chart_procedure_autocomplete') }}';
        patient_detail.settings.patient_payment_ajaxUrl = '{{ path('patient_payment_ajax_list') }}';
        patient_detail.settings.patient_payment_formUrl = '{{ path('patient_payment_form') }}';
        patient_detail.settings.patient_payment_formActionUrl = '{{ path('patient_payment_save') }}';
        patient_detail.settings.item_autocompleteUrl = '{{ path('item_autocomplete') }}';
        patient_detail.settings.itemCategory_autocompleteUrl = '{{ path('item_category_autocomplete') }}';
        patient_detail.settings.accountUser_autocompleteUrl = '{{ path('account_user_autocomplete') }}';
        patient_detail.settings.email_template_autocomplete_url = '{{ path('email_template_autocomplete') }}';

        patient_detail.settings.patient_history_ajaxUrl = '{{ path('patient_history_ajax_list', {patient_id : patient_id}) }}';
        patient_detail.settings.patient_red_flag_ajaxUrl = '{{ path('patient_red_flag_ajax_list', {patient_id : patient_id}) }}';
        patient_detail.settings.patient_red_flag_formUrl = '{{ path('patient_red_flag_form', {patient_id : patient_id}) }}';
        patient_detail.settings.patient_red_flag_formActionUrl = '{{ path('patient_red_flag_save') }}';
        patient_detail.settings.patient_red_flagTab_reloadAction = '{{ path('patient_detail', {patient_id : patient_id, tab:'rf'}) }}';
        patient_detail.settings.patient_export_hl7_formUrl = '{{ path('patient_export_hl7_form', {patient_id: patient_id}) }}';
        patient_detail.settings.patient_export_hl7_formActionUrl = '{{ path('patient_export_hl7', {patient_id: patient_id}) }}';
        {#patient_detail.settings.patient_billing_void_formActionUrl = '{{ path('patient_billing_void') }}';#}
        patient_detail.settings.patient_payment_void_formActionUrl = '{{ path('patient_payment_void') }}';
        patient_detail.settings.patient_health_facility_ajaxUrl= '{{ path('patient_health_facility_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_health_facility_formUrl= '{{ path('patient_health_facility_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_health_facility_formActionUrl= '{{ path('patient_health_facility_save') }}' ;

        patient_detail.settings.patient_specialist_ajaxUrl= '{{ path('patient_specialist_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_specialist_formUrl= '{{ path('patient_specialist_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_specialist_formActionUrl= '{{ path('patient_specialist_save') }}' ;

        patient_detail.settings.patient_services_ajaxUrl= '{{ path('patient_services_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_services_formUrl= '{{ path('patient_services_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_services_formActionUrl= '{{ path('patient_services_save') }}' ;

        patient_detail.settings.patient_services_other_ajaxUrl= '{{ path('patient_services_other_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_services_other_formUrl= '{{ path('patient_services_other_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_services_other_formActionUrl= '{{ path('patient_services_other_save') }}' ;

        patient_detail.settings.patient_billing_refund_ajaxUrl= '{{ path('patient_refund_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_billing_refund_formUrl= '{{ path('patient_refund_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_billing_refund_formActionUrl= '{{ path('patient_refund_save') }}' ;

        patient_detail.settings.patient_letter_note_formUrl= '{{ path('patient_letter_note_form', {patient_letter_id : 'null'}) }}' ;
        patient_detail.settings.patient_letter_note_formActionUrl= '{{ path('patient_letter_note_save') }}' ;

        patient_detail.settings.patient_reminder_ajaxUrl= '{{ path('patient_reminder_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_reminder_formUrl= '{{ path('patient_reminder_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_reminder_formActionUrl= '{{ path('patient_reminder_save') }}';

        patient_detail.settings.patient_rental_ajaxUrl= '{{ path('patient_rental_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_rental_formUrl= '{{ path('patient_rental_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_rental_formActionUrl= '{{ path('patient_rental_save') }}';

        patient_detail.settings.patient_treatment_consideration_ajaxUrl= '{{ path('patient_treatment_consideration_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_treatment_consideration_formUrl= '{{ path('patient_treatment_consideration_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_treatment_consideration_formActionUrl= '{{ path('patient_treatment_consideration_save') }}';

        patient_detail.settings.patient_treatment_plan_ajaxUrl= '{{ path('patient_treatment_plan_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_treatment_plan_formUrl= '{{ path('patient_treatment_plan_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_treatment_plan_formActionUrl= '{{ path('patient_treatment_plan_save') }}';

        patient_detail.settings.patient_email_ajaxUrl= '{{ path('patient_email_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_email_formUrl= '{{ path('patient_email_form', {patient_id : patient_id}) }}' ;
        patient_detail.settings.patient_email_formActionUrl= '{{ path('patient_email_save') }}';

        patient_detail.settings.patient_ticket_ajaxUrl= '{{ path('patient_ticket_ajax_list', {patient_id : patient_id}) }}' ;
        patient_detail.settings.healthFacility_autocompleteUrl = '{{ path('health_facility_autocomplete_for_schedule') }}';
        patient_detail.settings.patient_healthFacility_autocompleteUrl = '{{ path('health_facility_autocomplete') }}';
        patient_detail.settings.invoiceNo = '{{ invoiceNo }}';
        patient_detail.settings.letterId = '{{ letterId }}';
        patient_detail.settings.term_long_term = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::TERM_LONG_TERM_RENTAL') }}';
        patient_detail.settings.term_rent_to_own = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::TERM_RENT_TO_OWN') }}';
        patient_detail.settings.term_warranty = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::TERM_WARRANTY') }}';
        patient_detail.settings.item_type_accessory = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::ITEM_TYPE_ACCESSORY') }}';
        patient_detail.settings.item_type_cpap_package = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::ITEM_TYPE_CPAP_PACKAGE') }}';
        patient_detail.settings.item_type_medical_supplies = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::ITEM_TYPE_MEDICAL_SUPPLIES') }}';
        patient_detail.settings.item_type_part_of_cpap_package = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::ITEM_TYPE_PART_OF_CPAP_PACKAGE') }}';
        patient_detail.settings.cpap_trial = '{{ constant('RxConnexionBundle\\Entity\\PatientBillingBreakdownEntity::ITEM_TYPE_CPAP_TRIAL') }}';
        {#patient_detail.settings.fax_cover_accountUser_autocompleteUrl = '{{ path('account_user_autocomplete') }}';#}
        {#patient_detail.settings.fax_cover_patient_autocompleteUrl = '{{ path('patient_autocomplete') }}';#}
        {#patient_detail.settings.fax_cover_patient_referring_provider_autocompleteUrl = '{{ path('referring_provider_autocomplete') }}';#}
        {#patient_detail.settings.fax_cover_patient_insurance_autocompleteUrl = '{{ path('insurance_autocomplete') }}';#}
        patient_detail.settings.patient_payment_billing_breakdownUrl = '{{ path('patient_billing_breakdown_data') }}';
        patient_detail.settings.patient_billing_refund_breakdownUrl = '{{ path('patient_refund_breakdown_data') }}';
        patient_detail.settings.letter_template_data_url = '{{ path('letter_template_data') }}';

        patient_detail.settings.patient_transfer_formUrl= '{{ path('patient_transfer') }}' ;
        patient_detail.settings.patient_transfer_formActionUrl= '{{ path('patient_transfer_save') }}';

        patient_detail.settings.patient_linked_referring_health_facility_and_provider_formUrl = '{{ path('patient_linked_referring_health_facility_and_provider_form', {patient_id : patient_id}) }}';
        patient_detail.settings.note_template_autocomplete_url = '{{ path('note_template_autocomplete') }}';
        patient_detail.settings.noteTemplateAccess = '{{ noteTemplateAccess }}';

        patient_detail.settings.patient_purchased_items_ajaxUrl = '{{ path('patient_purchased_items_ajax_list') }}';

        patient_detail.settings.referring_health_facility_autocompleteUrl = '{{ path('referring_health_facility_autocomplete') }}';

        patient_detail.settings.patientLocation = {
            'geoLong' : '{{ patient.geoLong }}',
            'geoLat' : '{{ patient.geoLat }}'
        };

        patient_detail.settings.Ids = [];
        patient_detail.settings.tranType = '';
        jQ("#chart-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#file-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-letter-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patientBilling-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-red-flag-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-ticket-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-reminder-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-letter-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-billing-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-clinical-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-appointment-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        jQ("#patient-note-specialist-datalist").on('change',"input[type='checkbox']",function(e){
            var ids = atob(jQ(this).data("id"));
            if(this.checked) {
                patient_detail.settings.Ids.push(ids);
                patient_detail.settings.tranType = jQ(this).data("type");
            } else {
                patient_detail.settings.Ids.splice(patient_detail.settings.Ids.indexOf(ids));
            }
        });

        //]]>
        jQ(document).ready(patient_detail.init);


    </script>
{% endblock %}