<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_lung)
                    <span class="mr-2">{{$patient->does_insurance_cover_rtm_lung}}</span>
                @endif
                @if($patient->memo_for_does_insurance_cover_rtm_lung)
                    <span class="mr-2">({{$patient->memo_for_does_insurance_cover_rtm_lung}})</span>
                @endif
                <div moe relative>
                    <a href="#" start show>Edit</a>
                    <form url="/api/clientRtm/updateDoesInsuranceCoverRtmLung">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">RTM Lung Covered?</label>
                            <select name="doesInsuranceCoverRtmLung" class="form-control form-control-sm" requied>
                                <option value="">-- select --</option>
                                <option value="YES" {{$patient->does_insurance_cover_rtm_lung === 'YES' ? 'selected' : ''}}>Yes</option>
                                <option value="NO" {{$patient->does_insurance_cover_rtm_lung === 'NO' ? 'selected' : ''}}>No</option>
                                <option value="UNKNOWN" {{$patient->does_insurance_cover_rtm_lung === '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="memoForDoesInsuranceCoverRtmLung">{{$patient->memo_for_does_insurance_cover_rtm_lung}}</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/updateMemoForDoesInsuranceCoverRtmLung">
                        <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="memoForDoesInsuranceCoverRtmLung">{{$patient->memo_for_does_insurance_cover_rtm_lung}}</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_lung === '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_lung_medically_needed)
                        <span class="mr-2">{{$patient->is_rtm_lung_medically_needed}}</span>
                    @endif
                    <div moe relative>
                        <a href="#" start show>Edit</a>
                        <form url="/api/clientRtm/updateIsRtmLungMedicallyNeeded">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="text-secondary text-sm mb-1 text-nowrap">RTM Lung Medically Needed?</label>
                                <select name="isRtmLungMedicallyNeeded" class="form-control form-control-sm" requied>
                                    <option value="">-- select --</option>
                                    <option value="YES" {{$patient->is_rtm_lung_medically_needed === 'YES' ? 'selected' : ''}}>Yes</option>
                                    <option value="NO" {{$patient->is_rtm_lung_medically_needed === 'NO' ? 'selected' : ''}}>No</option>
                                    <option value="UNKNOWN" {{$patient->is_rtm_lung_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="rtmLungMedicallyNeededForMemo">{{$patient->rtm_lung_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=rtmLungMedicallyNeededForIcd1Description]" name="rtmLungMedicallyNeededForIcd1" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd1Description" value="{{$patient->rtm_lung_medically_needed_for_icd1description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd2" data-target="input[name=rtmLungMedicallyNeededForIcd2Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd2Description" value="{{$patient->rtm_lung_medically_needed_for_icd2description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd3" data-target="input[name=rtmLungMedicallyNeededForIcd3Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd3Description" value="{{$patient->rtm_lung_medically_needed_for_icd3description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd4" data-target="input[name=rtmLungMedicallyNeededForIcd4Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd4Description" value="{{$patient->rtm_lung_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_lung_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_lung_medically_needed_for_icd1,
                                'description' => $patient->rtm_lung_medically_needed_for_icd1description
                            ],
                            'icd_2' => [
                                'title' => 'ICD 2',
                                'reason' => $patient->rtm_lung_medically_needed_for_icd2,
                                'description' => $patient->rtm_lung_medically_needed_for_icd2description
                            ],
                            'icd_3' => [
                                'title' => 'ICD 3',
                                'reason' => $patient->rtm_lung_medically_needed_for_icd3,
                                'description' => $patient->rtm_lung_medically_needed_for_icd3description
                            ],
                            'icd_4' => [
                                'title' => 'ICD 4',
                                'reason' => $patient->rtm_lung_medically_needed_for_icd4,
                                'description' => $patient->rtm_lung_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_lung_medically_needed_for_memo)
                            <span class="mr-2 mb-1">{{$patient->rtm_lung_medically_needed_for_memo}}</span>
                        @endif
                    </div>
                    <div moe relative>
                        <a start="" show="" href="#">Edit</a>
                        <form url="/api/clientRtm/updateRtmLungMedicallyNeededFor" 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="rtmLungMedicallyNeededForMemo">{{$patient->rtm_lung_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=rtmLungMedicallyNeededForIcd1Description]" name="rtmLungMedicallyNeededForIcd1" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd1Description" value="{{$patient->rtm_lung_medically_needed_for_icd1description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd2" data-target="input[name=rtmLungMedicallyNeededForIcd2Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd2Description" value="{{$patient->rtm_lung_medically_needed_for_icd2description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd3" data-target="input[name=rtmLungMedicallyNeededForIcd3Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd3Description" value="{{$patient->rtm_lung_medically_needed_for_icd3description}}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" class="icd-input search_field" icd-autocomplete-code="" name="rtmLungMedicallyNeededForIcd4" data-target="input[name=rtmLungMedicallyNeededForIcd4Description]" value="{{$patient->rtm_lung_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="rtmLungMedicallyNeededForIcd4Description" value="{{$patient->rtm_lung_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_lung)
                            <span class="mr-2">{{$patient->does_patient_want_rtm_lung}}</span>
                        @endif
                        @if($patient->memo_for_does_patient_want_rtm_lung)
                            <span class="mr-2">({{$patient->memo_for_does_patient_want_rtm_lung}})</span>
                        @endif
                        <div moe relative>
                            <a href="#" start show>Edit</a>
                            <form url="/api/clientRtm/updateDoesPatientWantRtmLung">
                                <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="doesPatientWantRtmLung" class="form-control form-control-sm" requied>
                                        <option value="">-- select --</option>
                                        <option value="YES" {{$patient->does_patient_want_rtm_lung === 'YES' ? 'selected' : ''}}>Yes</option>
                                        <option value="NO" {{$patient->does_patient_want_rtm_lung === 'NO' ? 'selected' : ''}}>No</option>
                                        <option value="UNKNOWN" {{$patient->does_patient_want_rtm_lung === '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="memoForDoesPatientWantRtmLung">{{$patient->memo_for_does_patient_want_rtm_lung}}</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/updateMemoForDoesPatientWantRtmLung">
                                <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="memoForDoesPatientWantRtmLung">{{$patient->memo_for_does_patient_want_rtm_lung}}</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_lung ? 'Yes' : 'No'}}</span>
                        <div moe relative>
                            <a href="#" start show>Edit</a>
                            <form url="/api/clientRtm/updateIsEnrolledInRtmLung">
                                <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="isEnrolledInRtmLung" class="form-control form-control-sm" requied>
                                        <option value="">-- select --</option>
                                        <option value="1" {{$patient->is_enrolled_in_rtm_lung ? 'selected' : ''}}>Yes</option>
                                        <option value="0" {{!$patient->is_enrolled_in_rtm_lung ? '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="rtmLungEnrollmentDate" value="{{$patient->rtm_lung_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_lung)
                <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_lung_enrollment_date)
                                <span class="mr-2">{{friendly_date($patient->rtm_lung_enrollment_date)}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit Date</a>
                                <form url="/api/clientRtm/updateRtmLungEnrollmentDate">
                                    <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="rtmLungEnrollmentDate" value="{{$patient->rtm_lung_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->rtmLungHcp)
                                <span class="mr-2">{{$patient->rtmLungHcp->displayName()}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit</a>
                                <form url="/api/clientRtm/updateRtmLungHcpPro">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">HCP</label>
                                        <select name="rtmLungHcpProUid" provider-search data-pro-uid="{{ @$patient->rtmLungHcp->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->rtmLungCoach)
                                <span class="mr-2">{{$patient->rtmLungCoach->displayName()}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit</a>
                                <form url="/api/clientRtm/updateRtmLungCoachPro">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Coach</label>
                                        <select name="rtmLungCoachProUid" provider-search data-pro-uid="{{ @$patient->rtmLungCoach->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_lung)
                <div class="d-flex align-items-baseline mt-2">
                    <label class="m-0 text-secondary font-weight-bold">Protocol:</label>
                    <div class="ml-2">
                        <div class="d-flex align-items-baseline">
                            @if($patient->rtm_lung_protocol_detail_json)
                                <span class="mr-2">{{$patient->rtm_lung_protocol_detail_json}}</span>
                            @endif
                            <div moe relative>
                                <a href="#" start show>Edit</a>
                                <form url="/api/clientRtm/updateRtmLungProtocolDetailJson">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm mb-1">Protocol</label>
                                        <textarea class="form-control form-control-sm" name="rtmLungProtocolDetailJson">{{$patient->rtm_lung_protocol_detail_json}}</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>
            @endif

        @endif

    @endif

</div>
