{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    {% set disabled = action == 'u' %}
    <div class="small-12 columns">
        <div id="flash-messages-content-page"></div>
        <nav aria-label="You are here:" role="navigation">
            <ul class="breadcrumbs">
                <li>
                    <a href="{{ path('patient') }}">Patient List</a>
                </li>
                <li>
                    <a href="{{ path('patient_detail', {patient_id : patient_id, } ) }}">{{ patient.fullName }}</a>
                </li>
                <li>
                    <span class="show-for-sr">Current: </span> Patient Encounter
                </li>
            </ul>
        </nav>
        {% include '@RxConnexion/Patient/overview.html.twig' with {patient: patient, redFlag: patientRedFlag} %}
        <br />
    </div>
    <form method="POST" action="{{ path('patient_chart_form', {patient_id: patient_id, action: action, id: id}) }}" enctype="multipart/form-data">
        <div class="row max-width-initial">
            <div class="large-12 columns">
                <div class="content-container has-loading">
                    <div class="content-container-content hide">
                        <ul class="tabs custom-tabs" data-tabs role="tablist" id="patient-chart-tabs">
                            <li class="tabs-title {{ tab is null or tab is empty or tab == 'ma' ? 'is-active' : '' }}"><a href="#panel-main" role="tab" tabindex="0" aria-selected="true" >Main</a></li>
                            <li class="tabs-title {{ tab == 'v' ? 'is-active' : '' }}"><a href="#panel-vitals" role="tab" tabindex="1" aria-selected="false" >Vitals</a></li>
                            {#<li class="tabs-title {{ tab == 'a' ? 'is-active' : '' }}"><a href="#panel-assessment" role="tab" tabindex="1" aria-selected="false" >Assessment</a></li>#}
                            <li class="tabs-title {{ tab == 'c' ? 'is-active' : '' }}"><a href="#panel-chart" role="tab" tabindex="2" aria-selected="false" >Assessment</a></li>
                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart File' in userData.accesses %}
                                <li class="tabs-title {{ tab == 'f' ? 'is-active' : '' }}"><a href="#panel-file" role="tab" tabindex="3" aria-selected="false" >File(s)</a></li>
                            {% endif %}
                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart Medical' in userData.accesses %}
                                <li class="tabs-title {{ tab == 'm' ? 'is-active' : '' }}"><a href="#panel-medical" role="tab" tabindex="4" aria-selected="false" >Medical</a></li>
                            {% endif %}
                            {#{% if userData.type == 'Super Admin' or 'Admin Patient Chart Device' in userData.accesses %}
                                <li class="tabs-title {{ tab == 'd' ? 'is-active' : '' }}"><a href="#panel-device" role="tab" tabindex="5" aria-selected="false" >Devices</a></li>
                            {% endif %}
                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart Billing' in userData.accesses %}
                                <li class="tabs-title {{ tab == 'b' ? 'is-active' : '' }}"><a href="#panel-billing" role="tab" tabindex="6" aria-selected="false" >Billing</a></li>
                            {% endif %}
                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart Payment' in userData.accesses %}
                                <li class="tabs-title {{ tab == 'p' ? 'is-active' : '' }}"><a href="#panel-payment" role="tab" tabindex="7" aria-selected="false" >Payment</a></li>
                            {% endif %}#}
                            <li class="tabs-title {{ tab == 'n' ? 'is-active' : '' }}"><a href="#panel-notes" role="tab" tabindex="8" aria-selected="false" >Notes</a></li>
                        </ul>
                        <div class="tabs-content custom-tabs-content" data-tabs-content="patient-chart-tabs">
                            <section role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab is null or tab is empty or tab == 'ma' ? 'is-active' : '' }}" id="panel-main">
                                <div class="row large-text-center">
                                    <div class="large-6 columns">
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.health_facility_desc) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.health_facility_desc) }}
                                                {{ form_widget(form.health_facility) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.billing_full_name) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.billing_full_name) }}
                                                {{ form_widget(form.account_user_billing) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.account_staff_full_name) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.account_staff_full_name) }}
                                                {{ form_widget(form.account_staff) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.provider_desc) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.provider_desc) }}
                                                {{ form_widget(form.provider) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.note_type) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.note_type) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.note) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.note) }}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="large-6 columns">
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.chart_type) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.chart_type) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.chart_status) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.chart_status) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.chart_date) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.chart_date) }}
                                            </div>
                                        </div>
                                        {% if action == 'u' and patientChart.chartType.hasBilling == 1 %}
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.billing_status) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.billing_status) }}
                                            </div>
                                        </div>
                                        {% endif %}
                                        <div class="row">
                                            <div class="large-3 large-text-right columns">
                                                {{ form_label(form.is_endorsed) }}
                                            </div>
                                            <div class="large-1 columns">
                                                {{ form_widget(form.is_endorsed) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.account_user_endorsed_by) }}
                                                {{ form_widget(form.endorsed_by, { 'attr': {'style': 'display:none;'}}) }}
                                            </div>
                                            <div class="large-3 large-text-right columns cc_form" style="display: none;">
                                                <span>CC: <a id="btn-patient-chart-add-cc"><i class="fa fa-plus-circle"></i></a></span>
                                            </div>
                                            <div class="large-8 columns">
                                                <div style="height: 25px;"></div>
                                                <table>
                                                    <tbody id="tbody-account-user-list">
                                                    {% if accountUser is not null and action == 'n' %}
                                                        <tr>
                                                            <td>
                                                                <input type="text"
                                                                       name="patient_chart[patientChartCcs][1][patientChartCcs_accountUser_fullName]"
                                                                       value="{{ accountUser.fullName|default('') }}"
                                                                       class="patient_chart_au_accountUser_fullName"
                                                                       placeholder="User"
                                                                       readonly
                                                                />
                                                                <input type="hidden"
                                                                       name="patient_chart[patientChartCcs][accountUser]"
                                                                       value="{{ accountUser.id|default('') }}"
                                                                       class="patient_chart_au_accountUser"
                                                                />
                                                            </td>
                                                            {#<td>
                                                                <a href="javascript:void(0)" class="btn-patient-list-remove">X</a>
                                                                <input type="hidden"
                                                                       name="ticket[patientTickets][1][id]"
                                                                       class="ticket_pt_id"
                                                                />
                                                            </td>#}
                                                        </tr>
                                                    {% endif %}
                                                    {% for pbb_form in form.patientChartCcs %}
                                                        <tr>
                                                            <td>
                                                                <div style="width: 70%; float: left;">
                                                                    <input type="text"
                                                                           name="patient_chart[patientChartCcs][{{ loop.index0 }}][patientChartCcs_accountUser_fullName]"
                                                                           value="{{ pbb_form.vars.value.accountUser.fullName|default('') }}"
                                                                           class="patient_chart_au_accountUser_fullName"
                                                                           placeholder="CC"
                                                                            {{ disabled ? 'readonly' : '' }}
                                                                    />
                                                                    <input type="hidden"
                                                                           name="patient_chart[patientChartCcs][{{ loop.index0 }}][accountUser]"
                                                                           value="{{ pbb_form.vars.value.accountUser.id|default('') }}"
                                                                           class="patient_chart_au_accountUser"
                                                                    />
                                                                </div>
                                                            </td>
                                                            <td>
                                                                {% if not disabled %}
                                                                    <a href="javascript:void(0)" class="btn-account-user-list-remove">X</a>
                                                                {% endif %}
                                                                <input type="hidden"
                                                                       name="patient_chart[patientChartCcs][{{ loop.index0 }}][id]"
                                                                       class="patientChart_au_id"
                                                                       value="{{ pbb_form.id.vars.value }}" />
                                                            </td>
                                                        </tr>
                                                    {% endfor %}
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.ticket_status) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.ticket_status_id) }}
                                                {{ form_widget(form.ticket_status, { 'attr': {'style': 'display:none;'}}) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.ticket_severity) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.ticket_severity_id) }}
                                                {{ form_widget(form.ticket_severity, { 'attr': {'style': 'display:none;'}}) }}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'v' ? 'is-active' : '' }}" id="panel-vitals">
                                <div class="row large-text-center">
                                    <div class="large-4 columns">
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.height) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.height) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.weight) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.weight) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.bmi) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.bmi) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.nose) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.nose) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.stop_bang) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.stop_bang) }}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="large-4 columns">
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.blood_pressure_first) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.blood_pressure_first) }}
                                                {{ form_widget(form.blood_pressure_second) }}
                                            </div>
                                        </div>
                                        {#<div class="row">#}
                                            {#<div class="large-4 large-text-right columns">#}
                                                {#{{ form_label(form.temperature) }}#}
                                            {#</div>#}
                                            {#<div class="large-8 columns">#}
                                                {#{{ form_widget(form.temperature) }}#}
                                            {#</div>#}
                                        {#</div>#}
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.neck_size) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.neck_size) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.smoker) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.smoker) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.pre_ess) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.pre_ess) }}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="large-4 columns">
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.pulse) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.pulse) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns" style="padding: 0;">
                                                {{ form_label(form.respiratory_rate) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.respiratory_rate) }}
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.otwo_saturation) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.otwo_saturation) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.drinker) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.drinker) }}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-4 large-text-right columns">
                                                {{ form_label(form.post_ess) }}
                                            </div>
                                            <div class="large-8 columns">
                                                {{ form_widget(form.post_ess) }}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'c' ? 'is-active' : '' }}" id="panel-chart">
                                <div class="row large-text-center">
                                    <div class="large-12 columns">
                                        <table width="100%" class="table-children-entity">
                                            {#<thead>
                                            <tr>
                                                <th><label class="required">Encounter Methods</label></th>
                                                <th width="50px"></th>
                                            </tr>
                                            </thead>#}
                                            <tbody id="tbody-chart-type-method">
                                            {% for pctm_form in form.chartTypeMethods %}

                                                {% set ifInitialAHI = '' %}
                                                {% set ifInitialRDI = '' %}
                                                {% if checkExistInitialAssessment is defined %}
                                                    {% set ifInitialRDI = checkExistInitialAssessment.initial_rdi|default(null) %}
                                                    {% set ifInitialAHI = checkExistInitialAssessment.initial_ahi|default(null) %}
                                                    {% set ifBQS = checkExistInitialAssessment.initial_berlin_questionnaire_score|default(null) %}
                                                    {% set ifIESS = checkExistInitialAssessment.initial_epworth_sleepness_scale|default(null) %}
                                                    {% set ifTNPS = checkExistInitialAssessment.time_ninety_percent_spotwo|default(null) %}
                                                    {% set ifIMS = checkExistInitialAssessment.initial_mean_spotwo|default(null) %}
                                                {% endif %}

                                                <tr class="tr-patient-chart-type-method" id="tr-chart-type-method-{{ loop.index0 }}">
                                                    <td>
                                                        <table width="100%">
                                                            <tr style="background-color: white" style="width: 100%;">
                                                                <td>
                                                                    <label style="text-align: left">Initial Berlin Questionnaire Score</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][initialBerlinQuestionnaireScore]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_initialBerlinQuestionnaireScore" type="text" class="" value="{{ pctm_form.vars.value.initialBerlinQuestionnaireScore }}" {{ ifBQS is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Initial Epworth Sleepness Scale</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][initialEpworthSleepnessScale]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_initialEpworthSleepnessScale" type="text" class="" value="{{ pctm_form.vars.value.initialEpworthSleepnessScale }}" {{ ifIESS is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                            </tr>
                                                            <tr style="background-color: white">
                                                                <td>
                                                                    <label style="text-align: left">% time < 90% SpO2</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][timeNinetyPercentSpotwo]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_timeNinetyPercentSpotwo" type="text" class="" value="{{ pctm_form.vars.value.timeNinetyPercentSpotwo }}" {{ ifTNPS is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Initial Mean SpO2</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][initialMeanSpotwo]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_initialMeanSpotwo" type="text" class="" value="{{ pctm_form.vars.value.initialMeanSpotwo }}" {{ ifIMS is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Initial AHI</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][initialAhi]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_initialAhi" type="text" class="" value="{{ ifInitialAHI is not null ? ifInitialAHI : pctm_form.vars.value.initialAhi }}" {{ ifInitialAHI is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Initial RDI</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][initialRdi]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_initialRdi" type="text" class="" value="{{ ifInitialRDI is not null ? ifInitialRDI : pctm_form.vars.value.initialRdi }}" {{ ifInitialRDI is not null and checkExistInitialAssessment.patient_chart_id != patientChart.id ? 'readonly' : '' }}/>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    <label style="text-align: left">Pressure Range From</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][pressureRangeFrom]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_pressureRangeFrom" type="text" class="quantity" value="{{ pctm_form.vars.value.pressureRangeFrom }}" />
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Pressure Range To</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][pressureRangeTo]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_pressureRangeTo" type="text" class="quantity" value="{{ pctm_form.vars.value.pressureRangeTo  }}" />
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Current AHI</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][currentAHI]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_currentAHI" type="text" class="quantity" value="{{ pctm_form.vars.value.currentAHI}}" />
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Current RDI</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][currentRDI]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_currentRDI" type="text" class="quantity" value="{{ pctm_form.vars.value.currentRDI}}"/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Avg Hours Usage/night</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][averageCPAPUsage]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_averageCPAPUsage" type="text" class="amount" value="{{ pctm_form.vars.value.averageCPAPUsage }}"/>
                                                                </td>
                                                            </tr>
                                                            <tr style="background-color: white">
                                                                <td>
                                                                    <label style="text-align: left">Mask Leak</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][maskLeak]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_maskLeak" type="text" class="amount" value="{{ pctm_form.vars.value.maskLeak }}"/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Last Time Accessories Replaced</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][lastDeviceReplaced]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_lastDeviceReplaced" type="text" class="date" value="{{ pctm_form.vars.value.lastDeviceReplaced is empty ? '' : pctm_form.vars.value.lastDeviceReplaced|date('m/d/Y')}}"/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">Neck Size(Inches)</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][neckSize]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_neckSize" type="text" class="amount" value="{{ pctm_form.vars.value.neckSize }}"/>
                                                                </td>
                                                                <td>
                                                                    <label style="text-align: left">ESS</label>
                                                                    <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][ess]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_ess" type="text" class="amount" value="{{ pctm_form.vars.value.ess }}"/>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                        <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][id]" value="{{ pctm_form.vars.value.id }}" type="hidden" />
                                                        <input name="patient_chart[chartTypeMethods][{{ loop.index0 }}][chart_type_method]" value="{{ pctm_form.vars.value.chartTypeMethod.id|default('') }}" type="hidden" />
                                                        <label><strong>{{ pctm_form.vars.value.chartTypeMethod.description }}</strong></label>
                                                        <textarea name="patient_chart[chartTypeMethods][{{ loop.index0 }}][note]" id="patient_chart_chartTypeMethods_{{ loop.index0 }}_note" class="note-ckeditor-field" data-idx="{{ loop.index0 }}">
                                                            {{ pctm_form.vars.value.note }}
                                                        </textarea>
                                                    </td>
                                                </tr>
                                            {% endfor %}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'f' ? 'is-active' : '' }}" id="panel-file">
                                <div class="text-right">
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart File New' in userData.accesses %}
                                        <a href="javascript:void(0)" class="href-patient-chart-file-form href-new-action" data-action="n" data-id="0">Upload File</a>
                                    {% endif %}
                                </div>
                                <table class="display responsive" id="patient-chart-file-datalist" width="100%">
                                    <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>User</th>
                                        <th>Description</th>
                                        <th>Notes</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'm' ? 'is-active' : '' }}" id="panel-medical">
                                <ul class="tabs custom-tabs" data-tabs role="tablist" id="patient-chart-medical-tabs">
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Medical Diagnosis' in userData.accesses %}
                                        <li class="tabs-title {{ tab is null or tab is empty or tab == 'md' ? 'is-active' : '' }}"><a href="#panel-medical-diagnosis" role="tab" tabindex="0" aria-selected="true" >Diagnosis</a></li>
                                    {% endif %}
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Medical Medication' in userData.accesses %}
                                        {% if patient.diagnoses|length != 0 %}
                                            <li class="tabs-title {{ tab == 'mm' ? 'is-active' : '' }}"><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-chart-medical-tabs">
                                    <section role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab is null or tab is empty or tab == 'md' ? 'is-active' : '' }}" id="panel-medical-diagnosis">
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart 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-chart-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>
                                    </section>
                                    <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == '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 Chart 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-chart-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 %}
                                    </section>
                                </div>
                            </section>
                            <div class="tabs-content custom-tabs-content" data-tabs-content="patient-chart-medical-tabs">
                                <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'mm' ? 'is-active' : '' }}" id="panel-device">
                                    <div class="text-right">
                                        {% if userData.type == 'Super Admin' or 'Admin Patient Chart Device 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 Device</a>
                                        {% endif %}
                                    </div>
                                    <table class="display responsive" id="patient-chart-device-datalist" width="100%">
                                        <thead>
                                        <tr>
                                            <th>Code</th>
                                            <th>Description</th>
                                            <th>Start Date</th>
                                            <th>End Date</th>
                                            <th>Quantity</th>
                                            <th>Action</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </section>
                            </div>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'b' ? 'is-active' : '' }}" id="panel-billing">
                                <ul class="tabs custom-tabs" data-tabs role="tablist" id="patient-chart-billing-tabs">
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Billing Procedure' in userData.accesses %}
                                        <li class="tabs-title {{ tab is null or tab is empty or tab == 'bp' ? 'is-active' : '' }}"><a href="#panel-billing-procedure" role="tab" tabindex="0" aria-selected="true" >Billing</a></li>
                                    {% endif %}
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Billing Other' in userData.accesses %}
                                        <li class="tabs-title {{ tab == 'bo' ? 'is-active' : '' }}"><a href="#panel-billing-other" role="tab" tabindex="1" aria-selected="false" >Others</a></li>
                                    {% endif %}
                                </ul>
                                <div class="tabs-content custom-tabs-content" data-tabs-content="patient-chart-billing-tabs">
                                    <section role="tabpanel" aria-hidden="false" class="tabs-panel {{ tab is null or tab is empty or tab == 'bp' ? 'is-active' : '' }}" id="panel-billing-procedure">
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart Billing Procedure New' in userData.accesses %}
                                                <a href="javascript:void(0)" class="href-patient-chart-billing-procedure-form href-new-action" data-action="n" data-id="0">New Billing</a>
                                            {% endif %}
                                        </div>
                                        <table class="display responsive" id="patient-chart-billing-procedure-datalist" width="100%">
                                            <thead>
                                            <tr>
                                                <th>Billing</th>
                                                <th>Amount</th>
                                                <th>Notes</th>
                                                <th>Action</th>
                                            </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </section>
                                    <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'bo' ? 'is-active' : '' }}" id="panel-billing-other">
                                        <div class="text-right">
                                            {% if userData.type == 'Super Admin' or 'Admin Patient Chart Billing Other New' in userData.accesses %}
                                                <a href="javascript:void(0)" class="href-patient-chart-billing-other-procedure-form href-new-action" data-action="n" data-id="0">New Other Billing</a>
                                            {% endif %}
                                        </div>
                                        <table class="display responsive" id="patient-chart-billing-other-datalist" width="100%">
                                            <thead>
                                            <tr>
                                                <th>Amount</th>
                                                <th>Notes</th>
                                                <th>Action</th>
                                            </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </section>
                                </div>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'p' ? 'is-active' : '' }}" id="panel-payment">
                                <div class="text-right">
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Payment New' in userData.accesses %}
                                        <a href="javascript:void(0)" class="href-patient-chart-payment-form href-new-action" data-action="n" data-id="0">New Payment</a>
                                    {% endif %}
                                </div>
                                <table class="display responsive" id="patient-chart-payment-datalist" width="100%">
                                    <thead>
                                    <tr>
                                        <th>Payment</th>
                                        <th>Payment Date</th>
                                        <th>OR#</th>
                                        <th>DR#</th>
                                        <th>Barcode</th>
                                        <th>Check No.</th>
                                        <th>Check Date</th>
                                        <th>Amount</th>
                                        <th>Notes</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </section>
                            <section role="tabpanel" aria-hidden="true" class="tabs-panel {{ tab == 'n' ? 'is-active' : '' }}" id="panel-notes">
                                <div class="text-right">
                                    {% if userData.type == 'Super Admin' or 'Admin Patient Chart Note New' in userData.accesses %}
                                        <a href="javascript:void(0)" class="href-patient-chart-note-form href-new-action" data-action="n" data-id="0">New Notes</a>
                                    {% endif %}
                                </div>
                                <table class="display responsive" id="patient-chart-note-datalist" width="100%">
                                    <thead>
                                    <tr>
                                        <th>Created At</th>
                                        <th>Created By</th>
                                        <th>Notes</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </section>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <hr>
        <div class="small-12 columns">
            <hr class="max-width-initial">
            <div class="button-container">
                <button type="submit" class="button just-continue" name="action" value="{{ action }}"
                        data-message="Are you sure you want to save this information?"
                >Save</button>
                {% if action == 'u' and (userData.type == 'Super Admin' or 'Admin Patient Chart Delete' in userData.accesses) %}
                    <button type="submit" class="ask-continue button alert" name="action" value="d"
                            data-message="Are you sure you want to delete this record?"
                    >Delete</button>
                {% endif %}
                <a href="{{ path('patient_detail', { patient_id : patient_id, tab:'c'}) }}" class="button secondary">Back</a>
            </div>
        </div>
        {{ form_widget(form.action) }}
        {{ form_widget(form.id) }}
        {{ form_widget(form.patient) }}
        {{ form_widget(form._token) }}
    </form>
    <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" 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>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        patient_chart_form.settings.account_user_autocomplete_url = '{{ path('account_user_active_autocomplete') }}';
        patient_chart_form.settings.account_user_ar_autocomplete_url = '{{ path('account_user_billing_autocomplete') }}';
        patient_chart_form.settings.account_user_cbt_autocomplete_url = '{{ path('account_staff_autocomplete') }}';
        patient_chart_form.settings.ticket_status_autocomplete_url = '{{ path('ticket_status_autocomplete') }}';
        patient_chart_form.settings.ticket_severity_autocomplete_url = '{{ path('ticket_severity_autocomplete') }}';
        patient_chart_form.settings.healthFacility_autocomplete_url = '{{ path('health_facility_autocomplete') }}' ;
        patient_chart_form.settings.provider_autocomplete_url = '{{ path('provider_autocomplete') }}' ;
        patient_chart_form.settings.chart_type_method_list_url = '{{ path('chart_type_method_list_by_id') }}' ;
        patient_chart_form.settings.methodCtr = '{{ action == 'u' ? form.chartTypeMethods|length : 0 }}';
        patient_chart_form.settings.file_ajaxUrl = '{{ path('patient_chart_file_ajax_list') }}' ;
        patient_chart_form.settings.file_formUrl = '{{ path('patient_chart_file_form', {patientChart_id : id}) }}' ;
        patient_chart_form.settings.file_formActionUrl = '{{ path('patient_chart_file_save') }}' ;
        patient_chart_form.settings.patient_chart_id = '{{ id }}' ;
        patient_chart_form.settings.patient_chart_type = '{{ patientChart.chartType.description }}' ;
        patient_chart_form.settings.patient_id = '{{ patient_id }}' ;
        patient_chart_form.settings.medical_diagnosis_ajaxUrl = '{{ path('patient_chart_medical_diagnosis_ajax_list') }}' ;
        patient_chart_form.settings.patient_diagnosis_formUrl= '{{ path('patient_diagnosis_form', {patient_id : patient_id}) }}' ;
        patient_chart_form.settings.patient_diagnosis_formActionUrl= '{{ path('patient_diagnosis_save') }}' ;
        patient_chart_form.settings.diagnosis_key= '{{ patient.diagnoses|length  }}';
        patient_chart_form.settings.medical_diagnosis_medication_ajaxUrl = '{{ path('patient_chart_medical_diagnosis_medication_ajax_list') }}' ;
        patient_chart_form.settings.patient_diagnosis_medication_formUrl= '{{ path('patient_diagnosis_medication_form') }}' ;
        patient_chart_form.settings.patient_diagnosis_medication_formActionUrl= '{{ path('patient_diagnosis_medication_save') }}' ;
        patient_chart_form.settings.billing_procedure_ajaxUrl = '{{ path('patient_chart_billing_procedure_ajax_list') }}' ;
        patient_chart_form.settings.billing_procedure_formUrl= '{{ path('patient_chart_procedure_form', {patientChart_id : id}) }}' ;
        patient_chart_form.settings.billing_procedure_formActionUrl= '{{ path('patient_chart_procedure_save') }}' ;
        patient_chart_form.settings.billing_other_ajaxUrl = '{{ path('patient_chart_billing_other_ajax_list') }}' ;
        patient_chart_form.settings.billing_other_procedure_formUrl= '{{ path('patient_chart_other_procedure_form', {patientChart_id : id}) }}' ;
        patient_chart_form.settings.billing_other_procedure_formActionUrl= '{{ path('patient_chart_other_procedure_save') }}' ;
        patient_chart_form.settings.payment_ajaxUrl = '{{ path('patient_chart_payment_ajax_list') }}' ;
        patient_chart_form.settings.payment_formUrl = '{{ path('patient_chart_payment_form', {patientChart_id : id}) }}' ;
        patient_chart_form.settings.payment_formActionUrl = '{{ path('patient_chart_payment_save') }}';
        patient_chart_form.settings.chart_note_ajaxUrl = '{{ path('patient_chart_note_ajax_list') }}';
        patient_chart_form.settings.patient_chart_note_formUrl = '{{ path('patient_chart_note_form', {patientChart_id : id}) }}';
        patient_chart_form.settings.patient_chart_note_formActionUrl = '{{ path('patient_chart_note_save') }}';
        patient_chart_form.settings.chart_procedure_autocomplete = '{{ path('chart_procedure_autocomplete') }}' ;
        patient_chart_form.settings.patient_chart_device_ajaxUrl = '{{ path('patient_chart_device_ajax_list') }}';
        patient_chart_form.settings.ifInitialAHI = '{{ checkExistInitialAssessment.initial_rdi|default(null) }}';
        patient_chart_form.settings.ifInitialRDI = '{{ checkExistInitialAssessment.initial_ahi|default(null) }}';
        patient_chart_form.settings.ifBQS = '{{ checkExistInitialAssessment.initial_berlin_questionnaire_score|default(null) }}';
        patient_chart_form.settings.ifIESS = '{{ checkExistInitialAssessment.initial_epworth_sleepness_scale|default(null) }}';
        patient_chart_form.settings.ifTNPS = '{{ checkExistInitialAssessment.time_ninety_percent_spotwo|default(null) }}';
        patient_chart_form.settings.ifIMS = '{{ checkExistInitialAssessment.initial_mean_spotwo|default(null) }}';
        patient_chart_form.settings.patient_chart_id_assessment = '{{ checkExistInitialAssessment.patient_chart_id|default(null) }}';
        patient_chart_form.settings.patientChartId = '{{ checkExistInitialAssessment.initial_mean_spotwo|default(null) }}';
        {% if accountUser is not null and action == 'n' %}
            patient_chart_form.settings.account_user_ids = [{{ accountUser.id }}]
        {% endif %}
        jQ(document).ready(patient_chart_form.init);
        //]]>
    </script>
{% endblock %}
