<div class="mt-2 pb-1">
    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
        <h6 class="my-0 font-weight-bold text-secondary">Cellular Measurements</h6>
        <span class="mx-2 text-secondary">|</span>
        <a start show class="py-0 font-weight-normal"
           href="/patients/view/{{ $patient->uid }}/measurements">
            View All
        </a>
    </div>
    <table class="table table-sm border-0 my-0 mx-2">
        <tbody>
        <?php
        $validCount = 0;
        foreach($patient->deviceMeasurements as $measurement) {
            $displayMeasurement = true;
            if($measurement->measurement->device_category === 'WEIGHT') {
                if(round(($measurement->measurement->value_weight / 1000)*2.20462, 1) <= 0) {
                    $displayMeasurement = false;
                }
            }
            else if($measurement->measurement->device_category === 'BP') {
                if(floatval($measurement->measurement->systolic_bp_in_mm_hg) <= 0 || floatval($measurement->measurement->diastolic_bp_in_mm_hg) <= 0) {
                    $displayMeasurement = false;
                }
            }
            if($displayMeasurement) {
                $validCount++;
            ?>
            <tr>
                <td class="text-black p-0 border-0">
                    <div class="pb-1 d-flex align-items-center">
                        <span class="text-secondary mr-2">{{ $measurement->measurement->device_category }}:</span>
                        @if($measurement->measurement->device_category === 'WEIGHT')
                            <b>{{ round(($measurement->measurement->value_weight / 1000)*2.20462, 1) }} lb</b>
                        @elseif($measurement->measurement->device_category === 'BP')
                            <b>{{ $measurement->measurement->systolic_bp_in_mm_hg }}/{{ $measurement->measurement->diastolic_bp_in_mm_hg }} mmHg</b>
                        @endif
                        <span class="font-weight-normal text-secondary ml-2 text-sm">({{ friendly_date_time($measurement->measurement->created_at, true) }})</span>
                        <span class="ml-2 text-sm {{$measurement->status === 'NEW' ? 'text-info' : ($measurement->status === 'ACCEPTED' ? 'text-success' : 'text-sacondary')}}">{{$measurement->status}}</span>
                        <span>
                                        <span moe class="ml-2" relative>
                                            <a href="#" start show><i class="on-hover-opaque font-size-11 fa fa-edit text-primary"></i></a>
                                            <form url="/api/clientBdtMeasurement/updateStatus" right>
                                                <input type="hidden" name="uid" value="{{ $measurement->uid }}">
                                                <div class="mb-2">
                                                    <select name="status" class="form-control form-control-sm" required>
                                                        <option value="">-- select --</option>
                                                        <option {{$measurement->status === 'NEW' ? 'selected' : ''  }} value="NEW">NEW</option>
                                                        <option {{$measurement->status === 'ACCEPTED' ? 'selected' : ''  }} value="ACCEPTED">ACCEPTED</option>
                                                        <option {{$measurement->status === 'REJECTED' ? 'selected' : ''  }} value="REJECTED">REJECTED</option>
                                                    </select>
                                                </div>
                                                <div class="mb-2">
                                                    <input type="text" name="statusMemo" placeholder="Status memo" class="form-control form-control-sm">
                                                </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>
                                        </span>
                                    </span>
                    </div>
                </td>
            </tr>
        <?php }
        }
        if(!$validCount) { ?>
            <tr>
                <td class="text-secondary p-0 border-0">
                    No measurements
                </td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
</div>
