<tr data-client-uid="{{$iPatient->client_uid}}" data-care-month-uid="{{$iPatient->care_month_uid}}">
    <td class="pl-2">
        <a href="/patients/view/{{ $iPatient->client_uid }}/care-months/view/{{$iPatient->care_month_uid}}" class="text-nowrap"
           native target="_blank"
           open-in-stag-popup
           update-parent="refresh-rpm-row-{{$trIndex}}"
           popup-style="tall overflow-visible"
           mc-initer="care-month-dashboard-{{$iPatient->client_uid}}"
           title="{{$iPatient->client_name}}"
        ><span class="sort-data">{{ $iPatient->client_name }}</span></a>
    </td>

    <td>{{friendly_date($iPatient->dob)}}</td>
    <td>{!! $iPatient->is_client_enrolled_in_rm ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
    <td>{!! $iPatient->is_assigned_cellular_bp_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
    <td>{!! $iPatient->is_assigned_cellular_weight_scale_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
    <td>
        <div class="text-nowrap">
            <span class="sort-data">{{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}</span>/{{$iPatient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}
            @if($iPatient->most_recent_cellular_bp_measurement_at)
                <span class="text-sm text-secondary text-nowrap ml-1"
                      title="{{friendly_date_time($iPatient->most_recent_cellular_bp_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_bp_measurement_at)}})</span>
            @endif
        </div>
    </td>
    <td>
        <div class="text-nowrap">
            <span class="sort-data">{{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}</span>
            @if($iPatient->most_recent_cellular_weight_measurement_at)
                <span class="text-sm text-secondary text-nowrap ml-1"
                      title="{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_weight_measurement_at)}})</span>
            @endif
        </div>
    </td>
    
    <td>
        <div class="d-flex align-items-baseline">
            <i class="mr-1 text-sm fa {{$lastVisitWithinDays ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
            <span class="sort-data">{{$daysDiff !== -1 ? $daysDiff : '-'}}</span>
        </div>
    </td>
    <td>
        <div class="d-flex align-items-baseline">
            <i class="mr-1 text-sm fa {{$iPatient->has_mcp_interacted_with_client_about_rm ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
            <span>{{$iPatient->has_mcp_interacted_with_client_about_rm ? 'Yes' : 'No'}}</span>
            @if($performerRole === 'MCP')
                <div moe large relative class="ml-2">
                    <a start show class="py-0 mb-3 text-sm">Edit</a>
                    <form url="/api/careMonthEntry/createForRm" right hook="refresh-rpm-row-{{$trIndex}}">
                        <input type="hidden" name="careMonthUid" value="{{ $iPatient->care_month_uid }}">
                        <input type="hidden" name="proUid" value="{{ $pro->uid }}">
                        <div class="mb-2">
                            <div class="row">
                                <div class="col-6 pr-0">
                                    <?php
                                    $sD = strtotime($rcmStartDate);
                                    $y = date('Y', $sD);
                                    $m0 = date('m', $sD);
                                    $d = date('t', $sD);
                                    $defaultED = $sD >= strtotime(date('Y-m-d')) ? date('Y-m-d') : $rcmStartDate;
                                    ?>
                                    <label class="text-sm text-secondary mb-1">Effective Date</label>
                                    <input autofocus type="date" min="{{ date($y . '-' . $m0 . '-01') }}" max="{{ date($y . '-' . $m0 . '-' . $d) }}"
                                           value="{{$defaultED}}"
                                           class="form-control form-control-sm w-100" name="effectiveDate"
                                           placeholder="Effective Date" required>
                                </div>
                                <div class="col-6">
                                    <label class="text-sm text-secondary mb-1">Seconds</label>
                                    <input type="number" min="75" max="300" class="form-control form-control-sm w-100 cm-time-value" name="timeInSeconds"
                                           value="75" placeholder="Time (secs.)" required>
                                </div>
                            </div>
                        </div>
                        <div class="mb-2 border border-info p-2 mt-2 bg-light">
                            <span>I have had interactive communication with <b>{{$iPatient->client_name}}</b>.</span>
                            <div class="d-flex border-top mt-2">
                                <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
                                    <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="true" required>
                                    <span>Yes</span>
                                </label>
                                <label class="mt-2 mb-0 d-inline-flex align-items-center">
                                    <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="false" required>
                                    <span>No</span>
                                </label>
                            </div>
                        </div>
                        <div class="mb-2">
                            <label class="text-sm text-secondary mb-1">Memo</label>
                            <textarea class="form-control form-control-sm w-100" name="contentText"
                                      required>Interacted with the patient</textarea>
                        </div>
                        <div class="d-flex align-items-center">
                            <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                        </div>
                    </form>
                </div>
            @endif
        </div>
        {{--@if(!$iPatient->has_mcp_interacted_with_client_about_rm)
            <div class="text-sm font-italic text-secondary">{{$performerRole === 'MCP' ? 'Not' : "MCP hasn't"}} interacted this month!</div>
        @endif--}}
    </td>
    <td>
        <div class="d-flex align-items-baseline">
            <i class="mr-1 text-sm fa {{$iPatient->number_of_days_with_remote_measurements >= 16 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
            <span class="sort-data">{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
            @if($iPatient->number_of_days_with_remote_measurements < 16)
                <div moe relative class="ml-2">
                    <a href="#" start show class="text-sm">SMS</a>
                    <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
                        <input type="hidden" name="uid" value="{{ $iPatient->client_uid }}">
                        <div class="mb-2">
                            <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
                            <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$iPatient->cell_number}}">
                        </div>
                        <div class="mb-2">
                            <label for="" class="text-sm text-secondary mb-1">Message</label>
                            <textarea rows="5" class="form-control form-control-sm" name="message">Hi! This is {{$pro->displayName(true)}}, from Cardio 1st. Please check your blood pressure.</textarea>
                        </div>
                        <div class="d-flex align-items-center">
                            <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
                            <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
                        </div>
                    </form>
                </div>
            @endif
        </div>
        {{--@if($iPatient->number_of_days_with_remote_measurements < 16)
            <div class="text-sm font-italic text-secondary">Meas. days < 16</div>
        @endif--}}
    </td>
    <td>
        <div class="d-flex align-items-baseline">
            @if($performerRole === 'MCP')
                <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
                @if($iPatient->rm_num_measurements_not_stamped_by_mcp)
                    <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
                       native target="_blank"
                       open-in-stag-popup
                       update-parent="refresh-rpm-row-{{$trIndex}}"
                       popup-style="tall overflow-visible"
                       class="ml-2 text-sm"
                       mc-initer="rpm-work-matrix"
                       title="RPM Work Matrix">
                        View
                    </a>
                @endif
            @elseif($performerRole === 'RMM')
                <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_rmm}}</span>
                @if($iPatient->rm_num_measurements_not_stamped_by_rmm)
                    <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
                       native target="_blank"
                       open-in-stag-popup
                       update-parent="refresh-rpm-row-{{$trIndex}}"
                       popup-style="tall overflow-visible"
                       class="ml-2 text-sm"
                       mc-initer="rpm-work-matrix"
                       title="RPM Work Matrix">
                        View
                    </a>
                @endif
            @endif
        </div>
    </td>
    <td>
        @if($performerRole === 'MCP')
            <div class="d-flex align-items-baseline">
                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_mcp >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_mcp % 60)}}s</span>
                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_mcp}}</span>
            </div>
            {{--@if($iPatient->rm_total_time_in_seconds_by_mcp < 1200)
                <div class="text-sm font-italic text-secondary">Entry mins. < 20</div>
            @endif--}}
        @elseif($performerRole === 'RMM')
            <div class="d-flex align-items-baseline">
                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_rmm_pro / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_rmm_pro % 60)}}s</span>
                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_rmm_pro}}</span>
            </div>
            {{--@if($iPatient->rm_total_time_in_seconds_by_rmm_pro < 1200)
                <div class="text-sm font-italic text-secondary">Entry mins. < 20</div>
            @endif--}}
        @endif
    </td>
    <td>
        @if($performerRole === 'MCP')
            @if($lastVisitWithinDays && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_mcp >= 1200)
                <span class="text-success font-weight-bold">
                                                    <i class="fa fa-check"></i>
                                                    Yes
                                                </span>
            @else
                <span class="text-danger font-weight-normal">
                                                    Not yet
                                                </span>
            @endif
        @elseif($performerRole === 'RMM')
            @if($lastVisitWithinDays && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200)
                <span class="text-success font-weight-bold">
                                                    <i class="fa fa-check"></i>
                                                    Yes
                                                </span>
            @else
                <span class="text-danger font-weight-normal">
                                                    Not yet
                                                </span>
            @endif
        @endif
    </td>
</tr>