@extends ('layouts.patient')

@section('inner-content')
<?php
$patientName = implode(', ', array_filter([$patient->name_last, $patient->name_first])) .
    ($patient->name_nickname ? ' (' . $patient->name_nickname . ')' : '');
 ?>
    <div id="client-settings-container">
    <h4 class="font-size-16 m-0 mb-3">Settings</h4>
        <div class="row">
            <div class="col-6">

                @if($pro->pro_type == 'ADMIN')
                <div>
                    <label class="mb-0">Status:</label>
                    <b>{{$patient->client_engagement_status_category ? ucwords(strtolower(str_replace('_', ' ', $patient->client_engagement_status_category == 'DUMMY' ? 'Test Chart' : $patient->client_engagement_status_category))) : '-'}}</b>
                    <div moe class="ml-2 hide-inside-popup">
                        <a start show><i class="fa fa-edit"></i></a>
                        <form url="/api/client/updateClientEngagementAssessmentStatus" class="mcp-theme-1" target="#patient-header-content">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Status</label>
                                <select name="category" class="form-control form-control-sm">
                                    <option value=""> --select--</option>
                                    <option {{ $patient->client_engagement_status_category === 'ACTIVE' ? 'selected' : '' }} value="ACTIVE">Active</option>
                                    <option {{ $patient->client_engagement_status_category === 'INACTIVE' ? 'selected' : '' }} value="INACTIVE">Inactive</option>
                                    <option {{ $patient->client_engagement_status_category === 'ENTRY_ERROR' ? 'selected' : '' }} value="ENTRY_ERROR">Entry Error</option>
                                    <option {{ $patient->client_engagement_status_category === 'DUMMY' ? 'selected' : '' }} value="DUMMY">Test Chart</option>
                                    <option {{ $patient->client_engagement_status_category === 'DECEASED' ? 'selected' : '' }} value="DECEASED">Deceased</option>
                                    <option {{ $patient->client_engagement_status_category === 'DUPLICATE' ? 'selected' : '' }} value="DUPLICATE">Duplicate</option>
                                    <option {{ $patient->client_engagement_status_category === 'NO_LONGER_INTERESTED' ? 'selected' : '' }} value="NO_LONGER_INTERESTED">No Longer Interested</option>
                                    <option {{ $patient->client_engagement_status_category === 'BAD_RECORD' ? 'selected' : '' }} value="BAD_RECORD">Bad Record</option>
                                    <option {{ $patient->client_engagement_status_category === 'NO_LONGER_ELIGIBLE' ? 'selected' : '' }} value="NO_LONGER_ELIGIBLE">No Longer Eligible</option>
                                </select>
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Memo</label>
                                <textarea class="form-control form-control-sm" name="memo"></textarea>
                            </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>
                <hr class="m-negator-3 my-3">
                @endif

                <div class="d-flex align-items-center mb-2">
                    <div class="font-weight-bold">Home Address</div>
                    <span class="text-secondary mx-2">|</span>
                    <div moe wide>
                        <a start show><i class="fa fa-edit"></i> Edit Address</a>
                        <form url="/api/client/editAddress" class="mcp-theme-1" onbeforesubmit="setSettingsMailingAddress">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">

                            <p class="mb-2 font-weight-bold">Home Address</p>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="homeAddressLine1"
                                       placeholder="Address Line 1" value="{{ $patient->home_address_line1 }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="homeAddressLine2"
                                       placeholder="Address Line 2" value="{{ $patient->home_address_line2 }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="homeAddressCity"
                                       placeholder="City" value="{{ $patient->home_address_city }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="homeAddressState"
                                       placeholder="State" value="{{ $patient->home_address_state }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="homeAddressZip" placeholder="ZIP"
                                       value="{{ $patient->home_address_zip }}">
                            </div>

                            <p class="mb-2 mt-3 font-weight-bold">Mailing Address</p>
                            <label class="d-flex align-items-center">
                                @php
                                    $isSame = ($patient->home_address_line1 == $patient->mailing_address_line1 &&
                                                $patient->home_address_line2 == $patient->mailing_address_line2 &&
                                                $patient->home_address_city == $patient->mailing_address_city &&
                                                $patient->home_address_state == $patient->mailing_address_state &&
                                                $patient->home_address_zip == $patient->mailing_address_zip);
                                @endphp
                                <input type="checkbox" id="settingsSameAsHome"
                                       onchange="copyHomeToMailingAndReadOnly(this.checked)" {{ $isSame ? 'checked' : '' }}>
                                <span class="ml-2">Same as home address</span>
                            </label>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="mailingAddressLine1"
                                       placeholder="Address Line 1" value="{{ $patient->mailing_address_line1 }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="mailingAddressLine2"
                                       placeholder="Address Line 2" value="{{ $patient->mailing_address_line2 }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="mailingAddressCity"
                                       placeholder="City" value="{{ $patient->mailing_address_city }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="mailingAddressState"
                                       placeholder="State" value="{{ $patient->mailing_address_state }}">
                            </div>
                            <div class="mb-2">
                                <input type="text" class="form-control form-control-sm" name="mailingAddressZip"
                                       placeholder="ZIP" value="{{ $patient->mailing_address_zip }}">
                            </div>
                            <div class="mb-2">
                        <textarea type="text" class="form-control form-control-sm" name="mailingAddressMemo"
                                  placeholder="Memo">{{ $patient->mailing_address_memo }}</textarea>
                            </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 class="pl-3">
                    <div class="mb-1">
                        Address Line 1: <b>{{ $patient->home_address_line1 }}</b>
                    </div>
                    <div class="mb-1">
                        Address Line 2: <b>{{ $patient->home_address_line2 }}</b>
                    </div>
                    <div class="mb-1">
                        City: <b>{{ $patient->home_address_city }}</b>
                    </div>
                    <div class="mb-1">
                        State: <b>{{ $patient->home_address_state }}</b>
                    </div>
                    <div class="mb-1">
                        ZIP: <b>{{ $patient->home_address_zip }}</b>
                    </div>
                </div>

                <div class="font-weight-bold mb-2 mt-3">Mailing Address</div>
                <div class="pl-3">
                    <div class="mb-1">
                        Address Line 1: <b>{{ $patient->mailing_address_line1 }}</b>
                    </div>
                    <div class="mb-1">
                        Address Line 2: <b>{{ $patient->mailing_address_line2 }}</b>
                    </div>
                    <div class="mb-1">
                        City: <b>{{ $patient->mailing_address_city }}</b>
                    </div>
                    <div class="mb-1">
                        State: <b>{{ $patient->mailing_address_state }}</b>
                    </div>
                    <div class="mb-1">
                        ZIP: <b>{{ $patient->mailing_address_zip }}</b>
                    </div>
                    <div class="mb-1">
                        Special Instructions: <b>{{ $patient->mailing_address_memo }}</b>
                    </div>
                </div>

                <hr class="m-negator-3 my-3">
                <div class="mt-3 mb-2">
                    <div class="d-flex align-items-center mb-2">
                      <h6 class="font-weight-bold mb-0">Name</h6>
                      <div moe wide>
                          <a start show><i class="fa fa-edit ml-2"></i> Edit Name</a>
                          <form url="/api/client/editName" class="mcp-theme-1">
                              <input type="hidden" name="uid" value="{{$patient->uid}}">
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="namePrefix" placeholder="Name Prefix" value="{{$patient->name_prefix}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameFirst" placeholder="Name First" value="{{$patient->name_first}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameMiddle" placeholder="Name Middle" value="{{$patient->name_middle}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameLast" placeholder="Name Last" value="{{$patient->name_last}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameSuffix" placeholder="Name Suffix" value="{{$patient->name_suffix}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameCredential" placeholder="Name Credential" value="{{$patient->name_credential}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameNickname" placeholder="Name Nickname" value="{{$patient->name_nickname}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="nameMaiden" placeholder="Name Maiden" value="{{$patient->name_maiden}}">
                              </div>
                              <div class="mb-2">
                                  <input type="text" class="form-control form-control-sm" name="namePrevious" placeholder="Name Previous" value="{{$patient->name_previous}}">
                              </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 class="mb-1 ml-3">
                        <div class="mb-1">
                            Appears as: <b>{{$patientName}}</b>
                        </div>
                        <div class="mb-1">
                            Name Prefix: <b>{{$patient->name_prefix}}</b>
                        </div>
                        <div class="mb-1">
                            Name First: <b>{{$patient->name_first}}</b>
                        </div>
                        <div class="mb-1">
                            Name Middle: <b>{{$patient->name_middle}}</b>
                        </div>
                        <div class="mb-1">
                            Name Last: <b>{{$patient->name_last}}</b>
                        </div>
                        <div class="mb-1">
                            Name Suffix: <b>{{$patient->name_suffix}}</b>
                        </div>
                        <div class="mb-1">
                            Name Credential: <b>{{$patient->name_credential}}</b>
                        </div>
                        <div class="mb-1">
                            Name Nickname: <b>{{$patient->name_nickname}}</b>
                        </div>
                        <div class="mb-1">
                            Name Maiden: <b>{{$patient->name_maiden}}</b>
                        </div>
                        <div class="mb-1">
                            Name Previous: <b>{{$patient->name_previous}}</b>
                        </div>
                    </div>
                </div>

                <hr class="m-negator-3 my-3">
                <div class="mt-3 mb-2">
                    <div class="font-weight-bold mb-2">Basic Info</div>
                    <div class="ml-3">
                      <div class="mb-1">
                          Sex: <b>{{ $patient->sex ?? '' }}</b>
                          <div moe wide>
                              <a start show><i class="fa fa-edit"></i></a>
                              <form url="/api/client/updateSex" class="mcp-theme-1">
                                  <input type="hidden" name="uid" value="{{$patient->uid}}">
                                  <div class="mb-2">
                                      <label class="mb-1 text-secondary text-sm">Sex</label>
                                      <select class="form-control form-control-sm" name="sex">
                                          <option value="">--select--</option>
                                          <option value="M" @if($patient->sex === 'M') selected @endif>Male</option>
                                          <option value="F" @if($patient->sex === 'F') selected @endif>Female</option>
                                      </select>
                                  </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 class="mb-1">
                          Date of Birth: <b>{{ $patient->dob ?? '' }}</b>
                          <div moe>
                              <a start show><i class="fa fa-edit"></i></a>
                              <form url="/api/client/editDob" class="mcp-theme-1">
                                  <input type="hidden" name="uid" value="{{$patient->uid}}">
                                  <div class="mb-2">
                                      <label class="mb-1 text-secondary text-sm">Date of Birth</label>
                                      <input type="date" class="form-control form-control-sm" name="dob" value="{{ $patient->dob }}" required />
                                  </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>
                </div>
                <hr class="m-negator-3 my-3">

                <div class="d-flex align-items-center mt-3 mb-2">
                    <div class="font-weight-bold">Contact Info</div>
                    <span class="text-secondary mx-2">|</span>
                    <div moe wide>
                        <a start show><i class="fa fa-edit"></i> Edit Contact Info</a>
                        <form url="/api/client/putContactInfo" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Home Phone Number</label>
                                <input type="tel" class="form-control form-control-sm" name="homeNumber"
                                       placeholder="Home Phone Number" value="{{ $patient->phone_home }}">
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Cell Number</label>
                                <input type="tel" class="form-control form-control-sm" name="cellNumber"
                                       placeholder="Cell Number" value="{{ $patient->cell_number }}">
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Cell Number Memo</label>
                                <input type="text" class="form-control form-control-sm" name="cellNumberMemo"
                                       placeholder="Cell Number Memo" value="{{ $patient->cell_number_memo }}">
                            </div>

                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Cell Phone Type</label>
                                <input type="text" class="form-control form-control-sm" name="cellPhoneType"
                                       data-option-list autocomplete="off"
                                       placeholder="Cell Phone Type" value="{{ $patient->cell_phone_type }}">
                                <div class="data-option-list">
                                    <div>Android</div>
                                    <div>iOS</div>
                                </div>
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Cell Phone Model</label>
                                <input type="text" class="form-control form-control-sm" name="cellPhoneModel"
                                       placeholder="Cell Phone Model" value="{{ $patient->cell_phone_model }}">
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Available Video Apps</label>
                                <input type="text" class="form-control form-control-sm" name="availableVideoApps"
                                       placeholder="Available Video Apps" value="{{ $patient->available_video_apps }}">
                            </div>
                            <div class="mb-2">
                                <label class="mb-1 text-secondary text-sm">Email Address</label>
                                <input type="text" class="form-control form-control-sm" name="email" placeholder="Email Address"
                                       value="{{ $patient->email_address }}">
                            </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 class="pl-3">
                    <div class="mb-1">
                        Home Phone: <b>{{ $patient->phone_home }}</b>
                    </div>
                    <div class="mb-1">
                        Cell Phone: <b>{{ $patient->cell_number }}</b> <span
                            class="text-sm text-secondary ml-2">{{ $patient->cell_number_memo ? '(' . $patient->cell_number_memo . ')' : '' }}</span>
                    </div>
                    <div class="mb-1">
                        Cell Phone Type: <b>{{ $patient->cell_phone_type }}</b>
                    </div>
                    <div class="mb-1">
                        Cell Phone Model: <b>{{ $patient->cell_phone_model }}</b>
                    </div>
                    <div class="mb-1">
                        Available Video Apps: <b>{{ $patient->available_video_apps }}</b>
                    </div>
                    <div class="mb-1">
                        Email: <b>{{ $patient->email_address }}</b>
                    </div>
                </div>

                <hr class="m-negator-3 my-3">

                <div class="d-flex align-items-center mt-3 mb-2">
                    <div class="font-weight-bold">Associated Pros</div>
                </div>
                <div class="pl-3">

                    <div class="mb-1">
                        RMM: <b>{{ $patient->rmm ? $patient->rmm->displayName() : '-'}}</b>
                        @if($pro->pro_type === 'ADMIN')
                        <div moe wide>
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/putRmmPro" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">RMM Pro</label>

                                    <select class="form-control form-control-sm" name="rmmProUid" provider-search provider-type="rmm">
                                        <option value="">--select--</option>
                                    </select>
                                </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>
                        @endif
                    </div>
                    <div class="mb-1">
                        RME: <b>{{ $patient->rme ? $patient->rme->displayName() : '-'}}</b>
                        @if($pro->pro_type === 'ADMIN')
                        <div moe wide>
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/putRmePro" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">RME Pro</label>
                                    <select class="form-control form-control-sm" name="rmeProUid" provider-search provider-type="rme">
                                        <option value="">--select--</option>
                                    </select>
                                </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>
                        @endif
                    </div>

                    <div class="mb-1">
                        <label>Care Coordinator:</label> <b>{{$patient->defaultNaPro ? $patient->defaultNaPro->displayName() : '-' }}</b>
                        @if($pro->pro_type == 'ADMIN')
                            <div moe class="ml-2">
                                <a start show><i class="fa fa-edit"></i></a>
                                <form url="/api/client/putDefaultNaPro" class="mcp-theme-1">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Care Coordinator</label>
                                        <select provider-search data-pro-uid="{{ @$patient->defaultNaPro->uid }}"
                                                name="defaultNaProUid"
                                                class="form-control form-control-sm">
                                            <option value=""> --select--</option>
                                            @foreach($pros as $iPro)
                                                <option
                                                    value="{{$iPro->uid}}" {{ $patient->defaultNaPro && $iPro->uid === $patient->defaultNaPro->uid ? 'selected' : '' }}>{{$iPro->displayName()}}</option>
                                            @endforeach
                                        </select>
                                    </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>
                            @if($patient->defaultNaPro)
                                <div moe class="ml-2">
                                    <a start show><i class="fa fa-times"></i></a>
                                    <form url="/api/client/removeDefaultNaPro" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="text-secondary text-sm">Remove Care Coordinator</label>

                                        </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>
                            @endif
                        @endif
                    </div>
                    <div class="mb-1">
                      MCP Pro: <b>{{ $patient->mcp->name_display ?? ''}}</b>
                    </div>
                    <div class="mb-1">
                        RD Pro: <b>{{ $patient->rd ? $patient->rd->displayName() : '-'}}</b>
                        @if($pro->pro_type === 'ADMIN')
                        <div moe wide>
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/putRdPro" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">RD Pro</label>
                                    <select class="form-control form-control-sm" name="rdProUid" provider-search provider-type="rd">
                                        <option value="">--select--</option>
                                    </select>
                                </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>
                        @if($patient->rd)
                            <div moe class="ml-2">
                                <a start show><i class="fa fa-times"></i></a>
                                <form url="/api/client/removeRdPro" class="mcp-theme-1">
                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Remove RD</label>

                                    </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>
                        @endif
                        @endif
                    </div>
                    <div class="mb-1">
                      Physician Pro: <b>{{ $patient->pcp->rd->name_display ?? ''}}</b>
                    </div>
                </div>

                <hr class="m-negator-3 my-3">
                <div class="mt-3 mb-2">
                    <div class="font-weight-bold mb-2">Claim Details</div>
                    <div class="mb-1">
                        Claim Phone Number: <b>{{ $patient->claim_phone_number ?? '' }}</b>
                        <div moe wide>
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/updateClaimPhoneNumber" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Phone Number</label>
                                    <input type="text" class="form-control form-control-sm" name="claimPhoneNumber" />
                                </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 class="mb-1">
                        <div class="d-flex">
                            <span><b>Address</b> | </span>
                            <div class="ml-1">
                            <div moe wide>
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/updateClaimAddress" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Address 1</label>
                                    <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_line1 }}" name="claimAddressLine1" />
                                </div>
                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Address 2</label>
                                    <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_line2 }}" name="claimAddressLine2" />
                                </div>

                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Address City</label>
                                    <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_city }}" name="claimAddressCity" />
                                </div>

                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Address State</label>
                                    <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_state }}" name="claimAddressState" />
                                </div>

                                <div class="mb-2">
                                    <label class="mb-1 text-secondary text-sm">Claim Address Zip</label>
                                    <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_zip }}" name="claimAddressZip" />
                                </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>
                        <div>
                            Claim Address 1: <b>{{ $patient->claim_address_line1 ?? '' }}</b>
                        </div>
                        <div>
                            Claim Address 2: <b>{{ $patient->claim_address_line2 ?? '' }}</b>
                        </div>
                        <div>
                            Claim Address City: <b>{{ $patient->claim_address_city ?? '' }}</b>
                        </div>
                        <div>
                            Claim Address State: <b>{{ $patient->claim_address_state ?? '' }}</b>
                        </div>
                        <div>
                            Claim Address Zip: <b>{{ $patient->claim_address_zip ?? '' }}</b>
                        </div>


                    </div>
                </div>
                <hr class="m-negator-3 my-3">
                <div>
                    <p>Is Eligible For RM: {{$patient->is_eligible_for_rm}}</p>
		            <p>Why Not Eligible For RM Category: {{$patient->why_not_eligible_for_rm_category}}</p>
		            <p>Why Not Eligible For RM Memo: {{$patient->why_not_eligible_for_rm_memo}}</p>
                </div>
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update RM Eligiblity</a>
                    <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Is Eligible For RM </label>
                            <select name="isEligibleForRm" class="form-control">
                                <option value="">-- </option>
                                <option value="YES">Yes</option>
                                <option value="NO">No</option>
                                <option value="UNKNOWN">Unknown</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Why Not Eligible For RM Category</label>
                            <input type="text" name="whyNotEligibleForRmCategory" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Why Not Eligible For RM Memo</label>
                            <input type="text" name="whyNotEligibleForRmMemo" class="form-control">
                        </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>

                <hr class="m-negator-3 my-3">
                <div>
                    <p>Is enrolled to RM: {{$patient->is_enrolled_in_rm}}</p> {{-- correct --}}
                    @if($patient->is_enrolled_in_rm == 'NO') {{-- correct --}}
                        <p>Why Not Enrolled In RM Category:   {{$patient->why_not_enrolled_in_rm_category}}</p>
		                <p>Why Not Enrolled In RM Memo:   {{$patient->why_not_enrolled_in_rm_memo}}</p>
                    @endif
                </div>
                @if($patient->is_enrolled_in_rm == 'YES') {{-- correct --}}
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Set is enrolled to RM to false</a>
                    <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">Reason</label>
                            <select name="whyNotEnrolledInRmCategory" class="form-control" required>
                                <option value="">-- select --</option>
                                <option value="Withdrawn">Withdrawn</option>
                                <option value="Inactive">Inactive</option>
                                <option value="Entry Error">Entry Error</option>
                                <option value="Test Chart">Test Chart</option>
                                <option value="Deceased">Deceased</option>
                                <option value="No Longer Eligible">No Longer Eligible</option>
                            </select>
                        </div>
                        <div class="mb-2">
                            <label class="text-secondary text-sm mb-1">Memo</label>
                            <textarea type="text" name="whyNotEnrolledInRmMemo" class="form-control"></textarea>
                        </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>

                @else
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Set is enrolled to RM to YES</a>
                    <form url="/api/client/setIsEnrolledInRmToTrue" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Are you sure?</label>
                        </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 moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update Why Not Enrolled In RM</a>
                    <form url="/api/client/updateWhyNotEnrolledInRm" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Why Not Enrolled In RM Category</label>
                            <input type="text" name="whyNotEnrolledInRmCategory" value="{{$patient->why_not_enrolled_in_rm_category}}" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Why Not Enrolled In RM Memo</label>
                            <input type="text" name="whyNotEnrolledInRmMemo" value="{{$patient->why_not_enrolled_in_rm_memo}}" class="form-control">
                        </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>
                @endif

                @if($performer->pro->pro_type === 'ADMIN')
                <hr class="m-negator-3 my-3">
                <div>
                    <h3>Admin Engagement Assessment Status</h3>
                    <p>Category: {{$patient->adminEngagementAssessmentStatus->status_category ?? ''}}</p>
		            <p>Memo: {{$patient->adminEngagementAssessmentStatus->status_memo ?? ''}}</p>
		            <p>Detail: {{$patient->adminEngagementAssessmentStatus->status_detail ?? ''}}</p>
                </div>
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update Admin Engagement Assessment Status</a>
                    <form url="/api/client/updateAdminEngagementAssessmentStatus" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Category </label>
                            <select name="category" class="form-control">
                                <option value="NULL">--</option>
                                <option value="ACTIVE">ACTIVE</option>
                                <option value="INACTIVE">INACTIVE</option>
                                <option value="ENTRY_ERROR">ENTRY_ERROR</option>
                                <option value="DUMMY">DUMMY</option>
                                <option value="DECEASED">DECEASED</option>
	                            <option value="DUPLICATE">DUPLICATE</option>
                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option>
                                <option value="BAD_RECORD">BAD_RECORD</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Memo</label>
                            <input type="text" name="memo" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Detail</label>
                            <input type="text" name="detail" class="form-control">
                        </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>
                @endif

                @if($patient->mcp && $performer->pro->id == $patient->mcp->id || true)
                <hr class="m-negator-3 my-3">
                <div>
                    <h3>MCP Engagement Assessment Status</h3>
                    <p>Category: {{$patient->mcpEngagementAssessmentStatus->status_category ?? ''}}</p>
		            <p>Memo: {{$patient->mcpEngagementAssessmentStatus->status_memo ?? ''}}</p>
		            <p>Detail: {{$patient->mcpEngagementAssessmentStatus->status_detail ?? ''}}</p>
                </div>
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update MCP Engagement Assessment Status</a>
                    <form url="/api/client/updateMcpEngagementAssessmentStatus" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Category </label>
                            <select name="category" class="form-control">
                                <option value="NULL">--</option>
                                <option value="ACTIVE">ACTIVE</option>
                                <option value="INACTIVE">INACTIVE</option>
                                <option value="ENTRY_ERROR">ENTRY_ERROR</option>
                                <option value="DUMMY">DUMMY</option>
                                <option value="DECEASED">DECEASED</option>
	                            <option value="DUPLICATE">DUPLICATE</option>
                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option>
                                <option value="BAD_RECORD">BAD_RECORD</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Memo</label>
                            <input type="text" name="memo" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Detail</label>
                            <input type="text" name="detail" class="form-control">
                        </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>
                @endif
                @if($patient->defaultNaPro && $performer->pro->id == $patient->defaultNaPro->id)
                <hr class="m-negator-3 my-3">
                <div>
                    <h3>Default NA Engagement Assessment Status</h3>
                    <p>Category: {{$patient->defaultNaEngagementAssessmentStatus->status_category ?? ''}}</p>
		            <p>Memo: {{$patient->defaultNaEngagementAssessmentStatus->status_memo ?? ''}}</p>
		            <p>Detail: {{$patient->defaultNaEngagementAssessmentStatus->status_detail ?? ''}}</p>
                </div>
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update Default NA Engagement Assessment Status</a>
                    <form url="/api/client/updateDefaultNaEngagementAssessmentStatus" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Category </label>
                            <select name="category" class="form-control">
                                <option value="NULL">--</option>
                                <option value="ACTIVE">ACTIVE</option>
                                <option value="INACTIVE">INACTIVE</option>
                                <option value="ENTRY_ERROR">ENTRY_ERROR</option>
                                <option value="DUMMY">DUMMY</option>
                                <option value="DECEASED">DECEASED</option>
	                            <option value="DUPLICATE">DUPLICATE</option>
                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option>
                                <option value="BAD_RECORD">BAD_RECORD</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Memo</label>
                            <input type="text" name="memo" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Detail</label>
                            <input type="text" name="detail" class="form-control">
                        </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>
                @endif

                @if($performer->pro->pro_type == 'ADMIN')
                <hr class="m-negator-3 my-3">
                <div>
                    <h3>Client Engagement Assessment Status</h3>
                    <p>Category: {{$patient->client_engagement_status_category ?? ''}}</p>
		            <p>Memo: {{$patient->client_engagement_status_category_memo ?? ''}}</p>
		            <p>Detail: {{$patient->client_engagement_status_category_detail ?? ''}}</p>
                </div>
                <div moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i> Update Client Engagement Assessment Status</a>
                    <form url="/api/client/updateClientEngagementAssessmentStatus" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="form-group">
                            <label class="control-label">Category </label>
                            <select name="category" class="form-control">
                                <option {{$patient->client_engagement_status_category == 'NULL' ? 'selected' :''}} value="NULL">--</option>
                                <option {{$patient->client_engagement_status_category == 'ACTIVE' ? 'selected' :''}} value="ACTIVE">ACTIVE</option>
                                <option {{$patient->client_engagement_status_category == 'INACTIVE' ? 'selected' :''}} value="INACTIVE">INACTIVE</option>
                                <option {{$patient->client_engagement_status_category == 'ENTRY_ERROR' ? 'selected' :''}} value="ENTRY_ERROR">ENTRY_ERROR</option>
                                <option {{$patient->client_engagement_status_category == 'DUMMY' ? 'selected' :''}} value="DUMMY">DUMMY</option>
                                <option {{$patient->client_engagement_status_category == 'DECEASED' ? 'selected' :''}} value="DECEASED">DECEASED</option>
	                            <option {{$patient->client_engagement_status_category == 'DUPLICATE' ? 'selected' :''}} value="DUPLICATE">DUPLICATE</option>
                                <option {{$patient->client_engagement_status_category == 'NO_LONGER_INTERESTED' ? 'selected' :''}} value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option>
                                <option {{$patient->client_engagement_status_category == 'BAD_RECORD' ? 'selected' :''}} value="BAD_RECORD">BAD_RECORD</option>
                                <option {{ $patient->client_engagement_status_category === 'NO_LONGER_ELIGIBLE' ? 'selected' : '' }} value="NO_LONGER_ELIGIBLE">No Longer Eligible</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">Memo</label>
                            <input type="text" name="memo" class="form-control" value="{{$patient->client_engagement_status_category_memo}}">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Detail</label>
                            <input type="text" name="detail" class="form-control" value="{{$patient->client_engagement_status_category_detail}}">
                        </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>
                <hr class="m-negator-3 my-3">
                <div>
                <h3><b>AWV Settings</b></h3>
                <?php $patientDetailJson = json_decode($patient->detail_json, true); ?>
                <div class="pl-3">
                    <div class="mb-3">
                        <div class="d-flex align-items-start">
                            <div>
                                <span>2022 AWV Claim</span>
                                <span class="text-secondary mx-2">|</span>
                                <div moe relative>
                                    <a start show href="#"><i class="fa fa-edit"></i></a>
                                    <form url="/api/client/put2022AwvClaim" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="mb-1 text-secondary text-sm">2022 AWV Claim</label>
                                            <input type="text" class="form-control form-control-sm" name="put2022AwvClaim" />
                                        </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>
                        <div><small class="text-muted">{{ $patientDetailJson['2022_awv_claim'] ?? ''  }}</small></div>
                    </div>
                    <div>
                        <div class="d-flex align-items-start">
                            <div>
                                <span>2022 AWV Status:</span>
                                <span class="text-secondary font-weight-bold mx-2">{{ $patientDetailJson['2022_awv_status'] ?? '' }}</span>
                                <div moe relative>
                                    <a start show href="#"><i class="fa fa-edit"></i></a>
                                    <form url="/api/client/put2022AwvStatus" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="mb-1 text-secondary text-sm">2022 AWV Status</label>
                                            <input type="text" class="form-control form-control-sm" name="put2022AwvStatus" />
                                        </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>
                        <div><small class="text-muted">{{ $patient->client_2022_awv_claim_status }}</small></div>
                    </div>
                </div>
                </div>
                <hr class="m-negator-3 my-3">
                <div moe class="ml-2">
                    <h4>Linked companies</h4>
                    <div>
                        @foreach($patient->companyClients as $companyClient)
                            <div class="alert alert-info mt-1 mb-1">
                                <div moe class="d-inline-block">
                                    <a start show><i class="fa fa-times"></i></a>
                                    <form url="/api/companyClient/deactivate" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$companyClient->uid}}">
                                        <div class="form-group">
                                            <p>Are you sure?</p>
                                        </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>
                                {{$companyClient->company->name}}
                            </div>
                        @endforeach
                    </div>
                    <div moe>
                        <a start show><i class="fa fa-edit"></i> Link company</a>
                        <form url="/api/companyClient/create" class="mcp-theme-1">
                            <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                            <div class="form-group">
                                <label class="control-label">Company </label>
                                <select name="companyUid" class="form-control">
                                    <option value="">--select--</option>
                                    @foreach($companies as $company)
                                      @if($company->name)
                                        <option value="{{$company->uid}}">{{$company->name}}</option>
                                      @endif
                                    @endforeach
                                </select>
                            </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>
                @endif
            </div>
            <div class="col-6 border-left">

                <div class="d-flex">
                    <label class="mr-2">RM Company:</label>
                    <b>{{$patient->rmCompany ? $patient->rmCompany->name : '(not set)'}}</b>
                    @if(!$patient->rmCompany)
                        <div moe class="ml-2">
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/putRmCompany" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">RM Company</label>
                                    <select name="rmCompanyUid" class="form-control form-control-sm">
                                        <option value=""> --select--</option>
                                        <?php $allCompanies = \App\Models\Company::orderBy('name')->get(); ?>
                                        @foreach($allCompanies as $rmCompany)
                                            <option value="{{$rmCompany->uid}}">{{$rmCompany->name}}</option>
                                        @endforeach
                                    </select>
                                </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>
                    @else
                        <div moe class="ml-2">
                            <a start show><i class="text-danger fa fa-ban"></i></a>
                            <form url="/api/client/wipeRmCompany" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <p>Wipe RM Company?</p>
                                <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>
                    @endif
                </div>

                <hr class="m-negator-3 my-3">

                <span>
                    <span class="mr-1">MCP Onboarding Active?</span>
                    @if($patient->has_mcp_done_onboarding_visit === 'YES')
                        <b class="text-secondary"><i class="fa fa-check"></i>&nbsp;Already Onboarded</b>
                    @else
                        @if($patient->is_mcp_onboarding_active === 'YES')
                            <b>Yes</b>
                        @elseif($patient->is_mcp_onboarding_active === 'NO')
                            <b>No</b>
                        @else
                            <b>-</b>
                        @endif
                        <div moe class="ml-2">
                            <a start show><i class="fa fa-edit"></i></a>
                            <form url="/api/client/updateMcpOnboardingActiveInfo" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">MCP Onboarding Active?</label>
                                    <select name="isMcpOnboardingActive"
                                            class="form-control form-control-sm"
                                            onchange="$('.if-mcb-ob-not-active')[this.value==='NO' ? 'removeClass' : 'addClass']('d-none')"
                                            required>
                                        <option value=""> --select--</option>
                                        <option value="YES">Yes</option>
                                        <option value="NO">No</option>
                                        <option value="UNKNOWN">Unknown</option>
                                    </select>
                                </div>
                                <div class="if-mcb-ob-not-active d-none">
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Category</label>
                                        <input type="text" class="form-control form-control-sm"
                                               name="whyIsMcpOnboardingNotActiveCategory"
                                               value="{{ $patient->why_is_mcp_onboarding_not_active_category }}">
                                    </div>
                                    <div class="mb-2">
                                        <label class="text-secondary text-sm">Memo</label>
                                        <input type="text" class="form-control form-control-sm"
                                               name="whyIsMcpOnboardingNotActiveMemo"
                                               value="{{ $patient->why_is_mcp_onboarding_not_active_memo }}">
                                    </div>
                                </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>
                    @endif
                    @if($patient->has_mcp_done_onboarding_visit !== 'YES' && $patient->is_mcp_onboarding_active === 'NO')
                        <div class="text-secondary p-2 border my-2 bg-light">
                            <div class="font-weight-bold">{{$patient->why_is_mcp_onboarding_not_active_category}}</div>
                            <div>{{$patient->why_is_mcp_onboarding_not_active_memo}}</div>
                        </div>
                    @endif
                </span>

                <hr class="m-negator-3 my-3">
                <span>MCP: <b>{{ $patient->mcp ? $patient->mcp->displayName() : '-' }}</b></span>
                @if($pro->pro_type == 'ADMIN' || $pro->id == $patient->default_na_pro_id)
                    <div moe class="ml-2">
                        <a start show><i class="fa fa-edit"></i></a>
                        @include('app.patient.partials.put-mcp-form')
                    </div>
                @endif

                <hr class="m-negator-3 my-3">
                <span>Physician: <b>{{ $patient->pcp ? $patient->pcp->displayName() : '-' }}</b></span>
                @if($pro->pro_type == 'ADMIN')
                    <div moe class="ml-2">
                        <a start show><i class="fa fa-edit"></i></a>
                        <form url="/api/client/putPhysicianPro" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div class="mb-2">
                                <label class="text-secondary text-sm">Physician Pro</label>
                                <select name="physicianProUid" class="form-control form-control-sm" provider-search data-pro-uid="{{ @$patient->pcp->uid }}" >
                                    <option value=""> --select--</option>
                                    @foreach($pros as $iPro)
                                        <option
                                            value="{{$iPro->uid}}" {{ $patient->pcp && $iPro->uid === $patient->pcp->uid ? 'selected' : '' }}>{{$iPro->displayName()}}</option>
                                    @endforeach
                                </select>
                            </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>
                @endif

                <hr class="m-negator-3 my-3">
                <span>MCP Onboarding Visit: <b>{{ $patient->has_mcp_done_onboarding_visit }}</b></span>
                <span moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i></a>
                    <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <select name="hasMcpDoneOnboardingVisit"
                                    class="form-control form-control-sm"
                                    onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')">
                                <option value="">-- Select Status --</option>
                                <option
                                    value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
                                <option
                                    value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
                                <option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
                            </select>
                        </div>
                        <div class="mb-2">
                            <input type="date" class="if-visit-done form-control form-control-sm" disabled
                                   name="mcpOnboardingVisitDate" value="{{ date('Y-m-d') }}" max="{{ date('Y-m-d') }}">
                        </div>
                        <div class="mb-2">
                            <select name="mcpOnboardingVisitNoteUid" disabled
                                    class="form-control form-control-sm if-visit-done"
                                    onchange="if(this.value === '-- create --') createNewNote('{{$patient->uid}}', '{{$pro->uid}}', '{{date('Y-m-d')}}');">
                                <option value="">-- Visit Note --</option>
                                <?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
                                @foreach ($notes as $note)
                                    @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                        <option
                                            {{ $patient->mcp_onboarding_visit_note_id === $note->id ? 'selected' : '' }}
                                            value="{{$note->uid}}">{{$note->hcpPro->displayName()}} ({{friendly_date_time($note->effective_dateest, false)}})</option>
                                    @endif
                                @endforeach
                                {{--<option value="-- create --">-- Create Note --</option>--}}
                            </select>
                        </div>
                        <div class="mb-2 if-note-outside-system">
                            <textarea class="form-control form-control-sm" name="reasonOnboardingVisitNoteOutsideSystem"
                                      placeholder="Visit note outside the system reason" spellcheck="false"
                                      data-gramm="false"></textarea>
                        </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>
                </span>

                <hr class="m-negator-3 my-3">
                <span>Send Appointment Confirmation SMS: <b>{{ $patient->send_appointment_confirmation_sms? 'Yes': 'No' }}</b></span>
                @if($patient->send_appointment_confirmation_sms)
                    <span moe class="ml-2">
                        <form show url="/api/client/setSendAppointmentConfirmationSmsToFalse" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div>
                                <button submit class="btn btn-sm btn-primary mr-1">Disable</button>
                            </div>
                        </form>
                    </span>
                @else
                    <span moe class="ml-2">
                        <form show url="/api/client/setSendAppointmentConfirmationSmsToTrue" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <div>
                                <button submit class="btn btn-sm btn-primary mr-1">Enable</button>
                            </div>
                        </form>
                    </span>
                @endif

                <hr class="m-negator-3 my-3">
                <span>Initiative: <b>{{$patient->initiative ? $patient->initiative : 'N/A'}}</b></span>
                <span moe class="ml-2">
                    <a start show><i class="fa fa-edit"></i></a>
                    <form url="/api/client/updateInitiative" class="mcp-theme-1">
                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                        <div class="mb-2">
                            <input type="text" name="initiative" class="form-control form-control-sm" value="{{$patient->initiative}}">
                        </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>
                </span>

                <hr class="m-negator-3 my-3">
                <span>Send SMS for device measurements: <b>{{$patient->send_sms_on_bdt_measurement ? 'YES' : 'NO'}}</b></span>
                @if($patient->send_sms_on_bdt_measurement)
                    <span moe class="ml-2">
                        <a start show>Turn Off</a>
                        <form url="/api/client/setSendSmsOnBdtMeasurementToFalse" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <p>Turn off SMS on device measurements?</p>
                            <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>
                    </span>
                @else
                    <span moe class="ml-2">
                        <a start show>Turn On</a>
                        <form url="/api/client/setSendSmsOnBdtMeasurementToTrue" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <p>Turn on SMS on device measurements?</p>
                            <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>
                    </span>
                @endif

                <hr class="m-negator-3 mt-3">
                <div id="preferredPharmacyApp">
                    <span>Preferred Pharmacy: <b>@{{ pharmacy() }}</b></span>
                    <span moe bottom relative large class="ml-2">
                        <a start show><i class="fa fa-edit"></i></a>
                        <form url="/api/client/updatePreferredPharmacyDetail" class="mcp-theme-1">
                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                            <input type="hidden" name="preferredPharmacyDetail" v-model="json">
                            <div class="row mb-2">
                                <div class="col-12">
                                    <label class="text-sm text-secondary mb-1">Business Name</label>
                                    <input type="text" v-model="payload.pharmacyName" class="form-control form-control-sm">
                                </div>
                            </div>
                            <div class="row mb-2">
                                <div class="col-6">
                                    <label class="text-sm text-secondary mb-1">City</label>
                                    <input type="text" v-model="payload.pharmacyCity" class="form-control form-control-sm">
                                </div>
                                <div class="col-6">
                                    <label class="text-sm text-secondary mb-1">State</label>
                                    <input type="text" v-model="payload.pharmacyState" class="form-control form-control-sm">
                                </div>
                            </div>
                            <div class="row mb-2">
                                <div class="col-12">
                                    <label class="text-sm text-secondary mb-1">Address Memo</label>
                                    <input type="text" v-model="payload.pharmacyAddressMemo" class="form-control form-control-sm">
                                </div>
                            </div>
                            <div class="row mb-2">
                                <div class="col-6">
                                    <label class="text-sm text-secondary mb-1">Phone</label>
                                    <input type="text" v-model="payload.pharmacyPhone" class="form-control form-control-sm">
                                </div>
                                <div class="col-6">
                                    <label class="text-sm text-secondary mb-1">Fax</label>
                                    <input type="text" v-model="payload.pharmacyFax" class="form-control form-control-sm">
                                </div>
                            </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>
                    </span>
                </div>



                @if($pro->pro_type == 'ADMIN')

                    @if($patient->mcp)
                        <hr class="m-negator-3 mt-3">
                        <div>
                            <span>Default MCP Company Pro:
                                <b>{{$patient->default_mcp_company_pro_id? $patient->defaultMcpCompanyPro->company->name . ' / ' . $patient->defaultMcpCompanyPro->pro->displayName():'No'}}</b>
                            </span>
                            @if($patient->default_mcp_company_pro_id)
                                <div moe bottom relative class="ml-1">
                                    <a start show><i class="fa fa-times text-danger"></i></a>
                                    <form url="/api/client/wipeDefaultMcpCompanyPro"
                                          class="mcp-theme-1 min-width-200px" right>
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <p>Remove default MCP company pro?</p>
                                        <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>
                            @else
                                <div moe bottom relative class="ml-2">
                                    <a start show>Edit</a>
                                    <form url="/api/client/putDefaultMcpCompanyPro"
                                          class="mcp-theme-1  min-width-200px">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="text-sm text-secondary mb-1">Payer</label>
                                            <select name="defaultMcpCompanyProUid" class="form-control form-control-sm">
                                                <option value="">-- select --</option>
                                                @foreach($patient->mcp->companyPros as $companyPro)
                                                    <option value="{{$companyPro->uid}}">{{$companyPro->company->name}}</option>
                                                @endforeach
                                            </select>
                                        </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>
                            @endif
                        </div>

                        @if($patient->default_mcp_company_pro_id)
                            <hr class="m-negator-3 mt-3">
                            <div>
                                <span>Default MCP Company Pro Payer:
                                    <b>{{$patient->default_mcp_company_pro_payer_id? $patient->defaultMcpCompanyProPayer->payer->name:'No'}}</b>
                                </span>
                                @if($patient->default_mcp_company_pro_payer_id)
                                    <div moe bottom relative class="ml-1">
                                        <a start show><i class="fa fa-times text-danger"></i></a>
                                        <form url="/api/client/wipeDefaultMcpCompanyProPayer"
                                              class="mcp-theme-1 min-width-200px" right>
                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                            <p>Remove default MCP company pro payer?</p>
                                            <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>
                                @else
                                    <div moe bottom relative class="ml-2">
                                        <a start show>Edit</a>
                                        <form url="/api/client/putDefaultMcpCompanyProPayer"
                                              class="mcp-theme-1  min-width-200px">
                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                            <div class="mb-2">
                                                <label class="text-sm text-secondary mb-1">Payer</label>
                                                <select name="defaultMcpCompanyProPayerUid" class="form-control form-control-sm">
                                                    <option value="">-- select --</option>
                                                    @foreach($patient->defaultMcpCompanyPro->companyProPayers as $companyProPayer)
                                                        <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
                                                    @endforeach
                                                </select>
                                            </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>
                                @endif
                            </div>

                            <hr class="m-negator-3 mt-3">
                            <div>
                                <span>Default MCP Company Location:
                                    <b>{{$patient->default_mcp_company_location_id? implode(" ", [$patient->defaultMcpCompanyLocation->line1, $patient->defaultMcpCompanyLocation->city, $patient->defaultMcpCompanyLocation->state]):'No'}}</b>
                                </span>
                                @if($patient->default_mcp_company_location_id)
                                    <div moe bottom relative class="ml-1">
                                        <a start show><i class="fa fa-times text-danger"></i></a>
                                        <form url="/api/client/wipeDefaultMcpCompanyLocation"
                                              class="mcp-theme-1 min-width-200px" right>
                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                            <p>Remove default MCP company location?</p>
                                            <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>
                                @else
                                    <div moe bottom relative class="ml-2">
                                        <a start show>Edit</a>
                                        <form url="/api/client/putDefaultMcpCompanyLocation"
                                              class="mcp-theme-1  min-width-200px">
                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                            <div class="mb-2">
                                                <label class="text-sm text-secondary mb-1">Payer</label>
                                                <select name="defaultCompanyLocationUid" class="form-control form-control-sm">
                                                    <option value="">-- select --</option>
                                                    @foreach($patient->defaultMcpCompanyPro->company->locations as $location)
                                                        <option value="{{$location->uid}}">
                                                            {{implode(" ", [$location->line1, $location->city, $location->state])}}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </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>
                                @endif
                            </div>
                        @endif
                    @endif


                @endif

                <hr class="m-negator-3 mt-3">
                <div>
                    <div class="d-flex mb-2 align-items-center">
                        <b class="d-block">MCN Query Response</b>
                        @if($pro->pro_type == 'ADMIN')
                            <span class="text-secondary mx-2">|</span>
                            @if(!$patient->is_coverage_manually_verified)
                                <div moe wide>
                                    <a start show><i class="fa fa-edit"></i> <b>Set Part B to Manually Verified</b></a>
                                    <form url="/api/client/markCoverageAsManuallyVerified" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="mb-1 text-secondary text-sm">Manual Verification Memo</label>
                                            <textarea rows="4" type="text" class="form-control form-control-sm" name="memo"
                                                placeholder="Memo">{{ $patient->coverage_manual_verification_memo }}</textarea>
                                        </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>
                            @else
                                <span class="text-info font-weight-bold"><i class="fa fa-check"></i>&nbsp;Part B Manually Verified</span>
                                <div moe wide class="ml-3">
                                    <a start show><i class="fa fa-edit"></i> Undo</a>
                                    <form url="/api/client/undoMarkCoverageAsManuallyVerified" class="mcp-theme-1">
                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                        <div class="mb-2">
                                            <label class="mb-1 text-secondary text-sm">Undo Manual Verification Memo</label>
                                            <textarea rows="4" type="text" class="form-control form-control-sm" name="memo"
                                                    placeholder="Memo">{{ $patient->coverage_manual_verification_memo }}</textarea>
                                        </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>
                            @endif
                        @endif
                    </div>
                    <div class="bg-light border p-2">
                    <?php
                    function displayNode($_key, $_node, $_pro, $_patient) {
                        $keyDisplay = ucwords(str_replace("_", " ", $_key));
                        $nodeOutput = '<div class="mb-1">' . $keyDisplay . ': ';
                        $nodeType = gettype($_node);
                        if(is_array($_node) && count($_node)) {
                            $nodeOutput .= '<div class="border-left pl-3 my-1">';
                            foreach ($_node as $k => $v) {
                                $nodeOutput .= displayNode($k, $v, $_pro, $_patient);
                            }
                            $nodeOutput .= '</div>';
                        }
                        else if(!is_array($_node)) {
                            if($keyDisplay != 'Member Id') {
                                $nodeOutput .= '<b>' . (!empty($_node) ? $_node : '-') . '</b>';
                            }
                            else {
                                $nodeOutput .= '<b class="c-pointer text-primary show-on-click" ' .
                                    'data-pro-uid="' . $_pro->uid . '" ' .
                                    'data-event="View MCN of patient ' . $_patient->displayName() . '"' .
                                    'data-value="' . (!empty($_node) ? $_node : '-') . '">Click to view</b>';
                            }
                        }
                        else {
                            $nodeOutput .= '-';
                        }
                        $nodeOutput .= '</div>';
                        return $nodeOutput;
                    }
                    $mcnResponse = !empty($patient->mcn_response_detail) ? json_decode($patient->mcn_response_detail, true) : [];
                    $output = [];
                    foreach ($mcnResponse as $k => $v) {
                        $output[] = displayNode($k, $v, $pro, $patient);
                    }
                    ?>
                    {!! implode("", $output) !!}
                    </div>
                </div>

            </div>
        </div>

    </div>

    <script>
        window.setSettingsMailingAddress = function () {
            copyHomeToMailingAndReadOnly($('#settingsSameAsHome').is(':checked'));
        }
        window.copyHomeToMailingAndReadOnly = function (_same) {
            if (_same) {
                $('[name="mailingAddressLine1"]').val($('[name="homeAddressLine1"]').val()).prop('readonly', true);
                $('[name="mailingAddressLine2"]').val($('[name="homeAddressLine2"]').val()).prop('readonly', true);
                $('[name="mailingAddressCity"]').val($('[name="homeAddressCity"]').val()).prop('readonly', true);
                $('[name="mailingAddressState"]').val($('[name="homeAddressState"]').val()).prop('readonly', true);
                $('[name="mailingAddressZip"]').val($('[name="homeAddressZip"]').val()).prop('readonly', true);
            } else {
                $('[name="mailingAddressLine1"]').prop('readonly', false);
                $('[name="mailingAddressLine2"]').prop('readonly', false);
                $('[name="mailingAddressCity"]').prop('readonly', false);
                $('[name="mailingAddressState"]').prop('readonly', false);
                $('[name="mailingAddressZip"]').prop('readonly', false);
                $('[name="mailingAddressLine1"]').focus();
            }
        }
        @if($isSame)
        function init() {
            copyHomeToMailingAndReadOnly(true);
        }

        addMCInitializer('copy-mailing-address', init, '#client-settings-container');
        @endif
    </script>

    <script>
        <?php
        $display = '-';
        if (!empty($patient->preferred_pharmacy_detail)) {
            $parsed = json_decode($patient->preferred_pharmacy_detail);
            $parts = array_filter([
                $parsed->pharmacyName,
                $parsed->pharmacyCity,
                $parsed->pharmacyState,
                $parsed->pharmacyAddressMemo,
                $parsed->pharmacyPhone,
                $parsed->pharmacyFax,
            ], function ($_item) {
                return !!$_item;
            });
            $display = implode(", ", $parts);
        }
        ?>
        window.preferredPharmacyApp = new Vue({
            el: '#preferredPharmacyApp',
            delimiters: ['@{{', '}}'],
            data: {
                payload: {
                    pharmacyName: '{{ @$parsed->pharmacyName }}',
                    pharmacyCity: '{{ @$parsed->pharmacyCity }}',
                    pharmacyState: '{{ @$parsed->pharmacyState }}',
                    pharmacyAddressMemo: '{{ @$parsed->pharmacyAddressMemo }}',
                    pharmacyPhone: '{{ @$parsed->pharmacyPhone }}',
                    pharmacyFax: '{{ @$parsed->pharmacyFax }}'
                },
                loaded: {
                    pharmacyName: '{{ @$parsed->pharmacyName }}',
                    pharmacyCity: '{{ @$parsed->pharmacyCity }}',
                    pharmacyState: '{{ @$parsed->pharmacyState }}',
                    pharmacyAddressMemo: '{{ @$parsed->pharmacyAddressMemo }}',
                    pharmacyPhone: '{{ @$parsed->pharmacyPhone }}',
                    pharmacyFax: '{{ @$parsed->pharmacyFax }}'
                },
                json: '',
            },
            watch: {
                payload: {
                    handler: function(val, oldVal) {
                        this.json = JSON.stringify({
                            pharmacyName: this.payload.pharmacyName,
                            pharmacyCity: this.payload.pharmacyCity,
                            pharmacyState: this.payload.pharmacyState,
                            pharmacyAddressMemo: this.payload.pharmacyAddressMemo,
                            pharmacyPhone: this.payload.pharmacyPhone,
                            pharmacyFax: this.payload.pharmacyFax
                        });
                    },
                    deep: true
                },
            },
            methods: {
                pharmacy: function() {
                    return [
                        this.loaded.pharmacyName,
                        this.loaded.pharmacyCity,
                        this.loaded.pharmacyState,
                        this.loaded.pharmacyAddressMemo,
                        this.loaded.pharmacyPhone,
                        this.loaded.pharmacyFax,
                    ].filter(Boolean).join(', ');
                }
            },
            mounted: function() {
                this.json = JSON.stringify({
                    pharmacyName: this.payload.pharmacyName,
                    pharmacyCity: this.payload.pharmacyCity,
                    pharmacyState: this.payload.pharmacyState,
                    pharmacyAddressMemo: this.payload.pharmacyAddressMemo,
                    pharmacyPhone: this.payload.pharmacyPhone,
                    pharmacyFax: this.payload.pharmacyFax
                });
            }
        })
    </script>
@endsection
