<div class="mt-2">

    <!-- coverage -->
    <div class="d-flex align-items-baseline">
        <label class="m-0 text-secondary font-weight-bold">Covered?</label>
        <div class="ml-2">
            <div class="d-flex align-items-baseline">
                @if($patient->does_insurance_cover_rtm_msk)
                    <span class="mr-2">{{$patient->does_insurance_cover_rtm_msk}}</span>
                @endif
                @if($patient->memo_for_does_insurance_cover_rtm_msk)
                    <span class="mr-2">({{$patient->memo_for_does_insurance_cover_rtm_msk}})</span>
                @endif
                <div moe relative>
                    <a href="#" start show>Edit</a>
                    <form url="/api/clientRtm/updateDoesInsuranceCoverRtmMsk">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">RTM MSK Covered?</label>
                            <select name="doesInsuranceCoverRtmMsk" class="form-control form-control-sm" requied>
                                <option value="">-- select --</option>
                                <option value="YES" {{$patient->does_insurance_cover_rtm_msk === 'YES' ? 'selected' : ''}}>Yes</option>
                                <option value="NO" {{$patient->does_insurance_cover_rtm_msk === 'NO' ? 'selected' : ''}}>No</option>
                                <option value="UNKNOWN" {{$patient->does_insurance_cover_rtm_msk === 'UNKNOWN' ? 'selected' : ''}}>Unknown</option>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">Memo</label>
                            <textarea type="text" class="form-control form-control-sm" name="memoForDoesInsuranceCoverRtmMsk">{{$patient->memo_for_does_insurance_cover_rtm_msk}}</textarea>
                        </div>
                        <div class="d-flex align-items-center">
                            <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                        </div>
                    </form>
                </div>
                <span class="mx-1 text-secondary">|</span>
                <div moe relative>
                    <a href="#" start show>Edit Memo</a>
                    <form url="/api/clientRtm/updateMemoForDoesInsuranceCoverRtmMsk">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">Memo</label>
                            <textarea type="text" class="form-control form-control-sm" name="memoForDoesInsuranceCoverRtmMsk">{{$patient->memo_for_does_insurance_cover_rtm_msk}}</textarea>
                        </div>
                        <div class="d-flex align-items-center">
                            <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    @if($patient->does_insurance_cover_rtm_msk === 'YES')

        <!-- medically needed -->
        <div class="d-flex align-items-baseline mt-2">
            <label class="m-0 text-secondary font-weight-bold">Medically needed?</label>
            <div class="ml-2">
                <div class="d-flex align-items-baseline">
                    @if($patient->is_rtm_msk_medically_needed)
                        <span class="mr-2">{{$patient->is_rtm_msk_medically_needed}}</span>
                    @endif
                    <div moe relative>
                        <a href="#" start show>Edit</a>
                        <form url="/api/clientRtm/updateIsRtmMskMedicallyNeeded">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="text-secondary text-sm mb-1 text-nowrap">RTM MSK Medically Needed?</label>
                                <select name="isRtmMskMedicallyNeeded" class="form-control form-control-sm" requied>
                                    <option value="">-- select --</option>
                                    <option value="YES" {{$patient->is_rtm_msk_medically_needed === 'YES' ? 'selected' : ''}}>Yes</option>
                                    <option value="NO" {{$patient->is_rtm_msk_medically_needed === 'NO' ? 'selected' : ''}}>No</option>
                                    <option value="UNKNOWN" {{$patient->is_rtm_msk_medically_needed === 'UNKNOWN' ? 'selected' : ''}}>Unknown</option>
                                </select>
                            </div>
                            <div class="mb-2">
                                <label class="text-sm text-secondary mb-1">Memo:</label>
                                <textarea type="text" class="form-control form-control-sm" name="rtmMskMedicallyNeededForMemo">{{$patient->rtm_msk_medically_needed_for_memo}}</textarea>
                            </div>
                            <div class="mb-2">
                                <table class="table table-sm table-bordered m-0">
                                    <thead class="bg-light">
                                    <tr>
                                        <th class="text-sm text-secondary font-weight-normal border-bottom-0">ICD</th>
                                        <th class="text-sm text-secondary font-weight-normal border-bottom-0">Description</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" data-target="input[name=rtmMskMedicallyNeededForIcd1Description]" name="rtmMskMedicallyNeededForIcd1" value="{{$patient->rtm_msk_medically_needed_for_icd1}}" placeholder="ICD 1" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd1Description" value="{{$patient->rtm_msk_medically_needed_for_icd1description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd2" data-target="input[name=rtmMskMedicallyNeededForIcd2Description]" value="{{$patient->rtm_msk_medically_needed_for_icd2}}" placeholder="ICD 2" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd2Description" value="{{$patient->rtm_msk_medically_needed_for_icd2description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd3" data-target="input[name=rtmMskMedicallyNeededForIcd3Description]" value="{{$patient->rtm_msk_medically_needed_for_icd3}}" placeholder="ICD 3" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd3Description" value="{{$patient->rtm_msk_medically_needed_for_icd3description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd4" data-target="input[name=rtmMskMedicallyNeededForIcd4Description]" value="{{$patient->rtm_msk_medically_needed_for_icd4}}" placeholder="ICD 4" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd4Description" value="{{$patient->rtm_msk_medically_needed_for_icd4description}}">
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="d-flex align-items-center">
                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        @if($patient->is_rtm_msk_medically_needed === 'YES')

            <!-- icds -->
            <div class="d-flex align-items-baseline mt-2">
                <label class="m-0 text-secondary font-weight-bold text-nowrap">Needed For:</label>
                <div class="ml-2">
                    <div class="d-flex align-items-baseline">
                        <?php
                        $displayData = [
                            'icd_1' => [
                                'title' => 'ICD 1',
                                'reason' => $patient->rtm_msk_medically_needed_for_icd1,
                                'description' => $patient->rtm_msk_medically_needed_for_icd1description
                            ],
                            'icd_2' => [
                                'title' => 'ICD 2',
                                'reason' => $patient->rtm_msk_medically_needed_for_icd2,
                                'description' => $patient->rtm_msk_medically_needed_for_icd2description
                            ],
                            'icd_3' => [
                                'title' => 'ICD 3',
                                'reason' => $patient->rtm_msk_medically_needed_for_icd3,
                                'description' => $patient->rtm_msk_medically_needed_for_icd3description
                            ],
                            'icd_4' => [
                                'title' => 'ICD 4',
                                'reason' => $patient->rtm_msk_medically_needed_for_icd4,
                                'description' => $patient->rtm_msk_medically_needed_for_icd4description
                            ],
                        ];
                        ?>
                        <?php $emptyICDs = true; ?>
                        @foreach($displayData as $rmKey=>$rmData)
                            <?php
                            $emptyICD = true;
                            if (!empty($rmData['reason']) || !empty($rmData['description'])) {
                                $emptyICDs = false;
                                $emptyICD = false;
                            }
                            ?>
                        @endforeach
                        @if(!$emptyICDs)
                            <div>
                                <div class="d-flex flex-wrap">
                                    <?php $emptyICDs = true; ?>
                                    @foreach($displayData as $rmKey=>$rmData)
                                        <?php
                                        $emptyICD = true;
                                        if (!empty($rmData['reason']) || !empty($rmData['description'])) {
                                            $emptyICDs = false;
                                            $emptyICD = false;
                                        }
                                        ?>
                                        @if(!$emptyICD)
                                            <span class="mb-1 mr-2 d-flex align-items-center"><i class="fas fa-circle text-muted mr-1" style="font-size: 5px;"></i> {{$rmData['reason']}} @if(!empty($rmData['description']))({{ $rmData['description'] }})@endif</span>
                                        @endif
                                    @endforeach
                                </div>
                            </div>
                        @endif
                    </div>
                    <div class="d-flex align-items-baseline">
                        @if($patient->rtm_msk_medically_needed_for_memo)
                            <span class="mr-2 mb-1">{{$patient->rtm_msk_medically_needed_for_memo}}</span>
                        @endif
                    </div>
                    <div moe relative>
                        <a start="" show="" href="#">Edit</a>
                        <form url="/api/clientRtm/updateRtmMskMedicallyNeededFor" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="font-weight-bold mb-1">Memo:</label>
                                <textarea type="text" class="form-control form-control-sm" name="rtmMskMedicallyNeededForMemo">{{$patient->rtm_msk_medically_needed_for_memo}}</textarea>
                            </div>
                            <div class="mb-2">
                                <table class="table table-sm table-bordered m-0">
                                    <thead class="bg-light">
                                    <tr>
                                        <th class="border-bottom-0">ICD</th>
                                        <th class="border-bottom-0">Description</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" data-target="input[name=rtmMskMedicallyNeededForIcd1Description]" name="rtmMskMedicallyNeededForIcd1" value="{{$patient->rtm_msk_medically_needed_for_icd1}}" placeholder="ICD 1" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd1Description" value="{{$patient->rtm_msk_medically_needed_for_icd1description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd2" data-target="input[name=rtmMskMedicallyNeededForIcd2Description]" value="{{$patient->rtm_msk_medically_needed_for_icd2}}" placeholder="ICD 2" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd2Description" value="{{$patient->rtm_msk_medically_needed_for_icd2description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd3" data-target="input[name=rtmMskMedicallyNeededForIcd3Description]" value="{{$patient->rtm_msk_medically_needed_for_icd3}}" placeholder="ICD 3" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd3Description" value="{{$patient->rtm_msk_medically_needed_for_icd3description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmMskMedicallyNeededForIcd4" data-target="input[name=rtmMskMedicallyNeededForIcd4Description]" value="{{$patient->rtm_msk_medically_needed_for_icd4}}" placeholder="ICD 4" autocomplete="off" role="combobox" aria-expanded="false">
                                        </td>
                                        <td>
                                            <input type="text" class="form-control form-control-sm" icd-autocomplete-description="" name="rtmMskMedicallyNeededForIcd4Description" value="{{$patient->rtm_msk_medically_needed_for_icd4description}}">
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div>
                                <button submit="" class="btn btn-sm btn-primary mr-1">Submit</button>
                                <button cancel="" class="btn btn-sm btn-default border">Cancel</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            <!-- patient interest -->
            <div class="d-flex align-items-baseline mt-2">
                <label class="m-0 text-secondary font-weight-bold">Patient Interested?</label>
                <div class="ml-2">
                    <div class="d-flex align-items-baseline">
                        @if($patient->does_patient_want_rtm_msk)
                            <span class="mr-2">{{$patient->does_patient_want_rtm_msk}}</span>
                        @endif
                        @if($patient->memo_for_does_patient_want_rtm_msk)
                            <span class="mr-2">({{$patient->memo_for_does_patient_want_rtm_msk}})</span>
                        @endif
                        <div moe relative>
                            <a href="#" start show>Edit</a>
                            <form url="/api/clientRtm/updateDoesPatientWantRtmMsk">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm mb-1">Patient Interested?</label>
                                    <select name="doesPatientWantRtmMsk" class="form-control form-control-sm" requied>
                                        <option value="">-- select --</option>
                                        <option value="YES" {{$patient->does_patient_want_rtm_msk === 'YES' ? 'selected' : ''}}>Yes</option>
                                        <option value="NO" {{$patient->does_patient_want_rtm_msk === 'NO' ? 'selected' : ''}}>No</option>
                                        <option value="UNKNOWN" {{$patient->does_patient_want_rtm_msk === 'UNKNOWN' ? 'selected' : ''}}>Unknown</option>
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm mb-1">Memo</label>
                                    <textarea type="text" class="form-control form-control-sm" name="memoForDoesPatientWantRtmMsk">{{$patient->memo_for_does_patient_want_rtm_msk}}</textarea>
                                </div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                        <span class="mx-1 text-secondary">|</span>
                        <div moe relative>
                            <a href="#" start show>Edit Memo</a>
                            <form url="/api/clientRtm/updateMemoForDoesPatientWantRtmMsk">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm mb-1">Memo</label>
                                    <textarea type="text" class="form-control form-control-sm" name="memoForDoesPatientWantRtmMsk">{{$patient->memo_for_does_patient_want_rtm_msk}}</textarea>
                                </div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <!-- enrollment -->
            <div class="d-flex align-items-baseline mt-2">
                <label class="m-0 text-secondary font-weight-bold">Enrolled?</label>
                <div class="ml-2">
                    <div class="d-flex align-items-baseline">
                        <span class="mr-2">{{$patient->is_enrolled_in_rtm_msk ? 'Yes' : 'No'}}</span>
                        <div moe relative>
                            <a href="#" start show>Edit</a>
                            <form url="/api/clientRtm/updateIsEnrolledInRtmMsk">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm mb-1">Patient Interested?</label>
                                    <select name="isEnrolledInRtmMsk" class="form-control form-control-sm" requied>
                                        <option value="">-- select --</option>
                                        <option value="1" {{$patient->is_enrolled_in_rtm_msk ? 'selected' : ''}}>Yes</option>
                                        <option value="0" {{!$patient->is_enrolled_in_rtm_msk ? 'selected' : ''}}>No</option>
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm mb-1">Effective Date</label>
                                    <input type="date" class="form-control form-control-sm" name="rtmMskEnrollmentDate" value="{{$patient->rtm_msk_enrollment_date}}">
                                </div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            @if($patient->is_enrolled_in_rtm_msk)
                <div class="d-flex align-items-baseline mt-1 pl-3">
                    <label class="m-0 text-secondary font-weight-bold">Date:</label>
                    <div class="ml-2">
                        <div class="d-flex align-items-baseline">
                            @if($patient->rtm_msk_enrollment_date)
                                <span class="mr-2">{{friendly_date($patient->rtm_msk_enrollment_date)}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit Date</a>
                                <form url="/api/clientRtm/updateRtmMskEnrollmentDate">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm mb-1">Effective Date</label>
                                        <input type="date" class="form-control form-control-sm" name="rtmMskEnrollmentDate" value="{{$patient->rtm_msk_enrollment_date}}">
                                    </div>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mt-1 pl-3">
                    <label class="m-0 text-secondary font-weight-bold">HCP:</label>
                    <div class="ml-2">
                        <div class="d-flex align-items-baseline">
                            @if($patient->rtmMskHcp)
                                <span class="mr-2">{{$patient->rtmMskHcp->displayName()}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit</a>
                                <form url="/api/clientRtm/updateRtmMskHcpPro">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">HCP</label>
                                        <select name="rtmMskHcpProUid" provider-search data-pro-uid="{{ @$patient->rtmMskHcp->uid }}" class="form-control form-control-sm">
                                            <option value=""> --select--</option>
                                        </select>
                                    </div>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mt-1 pl-3">
                    <label class="m-0 text-secondary font-weight-bold">Coach:</label>
                    <div class="ml-2">
                        <div class="d-flex align-items-baseline">
                            @if($patient->rtmMskCoach)
                                <span class="mr-2">{{$patient->rtmMskCoach->displayName()}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit</a>
                                <form url="/api/clientRtm/updateRtmMskCoachPro">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Coach</label>
                                        <select name="rtmMskCoachProUid" provider-search data-pro-uid="{{ @$patient->rtmMskCoach->uid }}" class="form-control form-control-sm">
                                            <option value=""> --select--</option>
                                        </select>
                                    </div>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            @endif

            {{-- protocol --}}
            @if($patient->is_enrolled_in_rtm_msk)
            <div class="d-flex align-items-start mt-2">
                <label class="m-0 text-secondary font-weight-bold">Protocol:</label>
                <div class="ml-2">
                    <div class="d-flex align-items-start">
                        @if($patient->rtm_msk_protocol_detail_json)
                            <div class="p-2 mr-2 border">
                                @include('app.patient.rtm.protocol-summary', ['patient' => $patient])
                            </div>
                        @endif
                        <a href="{{ route('protocol-builder', ['patient' => $patient]) }}"
                           native target="_blank"
                           open-in-stag-popup
                           popup-style="overflow-visible stag-popup-md"
                           update-parent
                           mc-initer="protocol-builder-{{$patient->uid}}"
                           title="Protocol Builder">
                            Edit
                        </a>
                    </div>
                </div>
            </div>
        @endif

        @endif

    @endif

</div>
