<div class="mt-2 mb-3">
    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
        <h6 class="my-0 font-weight-bold text-secondary">Measurements</h6>
        <span class="mx-2 text-secondary">|</span>
        <div moe>
            <a start show class="py-0 font-weight-normal">Add</a>
            <form url="/api/measurement/create">
                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                <div class="mb-2">
                    <input required autofocus type="text" class="form-control form-control-sm" name="label" value="" placeholder="Type">
                </div>
                <div class="mb-2">
                    <input required type="text" class="form-control form-control-sm" name="value" value="" placeholder="Value">
                </div>
                <div class="mb-2">
                    <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
                </div>
                <div class="d-flex align-items-center">
                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                </div>
            </form>
        </div>
        <span class="mx-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 m-0">
        <tbody>
        @foreach($patient->measurements as $measurement)
            @if(1 || !empty($measurement->label) && !in_array($measurement->label, $vitalLabels))
                @if(!in_array($measurement->label, ["SBP", "DBP"]))
                    @if(!empty($measurement->client_bdt_measurement_id))
                        @if($measurement->label === 'BP' && $measurement->dbp_mm_hg == 0)
                            <?php continue; ?>
                        @endif
                        @if($measurement->label === 'Wt. (lbs.)' && $measurement->value == 0)
                            <?php continue; ?>
                        @endif
                    @endif
                <tr>
                    <td class="text-black p-0 border-0">
                        <div class="d-flex align-items-center">
                            <div moe relative class="mr-2">
                                <a class="on-hover-opaque" start show title="Delete">
                                    <i class="font-size-11 fa fa-trash-alt text-danger"></i>
                                </a>
                                <form url="/api/measurement/remove">
                                    <input type="hidden" name="uid" value="{{ $measurement->uid }}">
                                    <p class="small min-width-200px">Are you sure you want to delete this entry?</p>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                            <div moe class="mr-2">
                                <a class="on-hover-opaque" start show title="Update">
                                    <i class="font-size-11 fa fa-edit text-primary"></i>
                                </a>
                                <form url="/api/measurement/updateBasic">
                                    <input type="hidden" name="uid" value="{{ $measurement->uid }}">
                                    <div class="mb-2">
                                        <input required type="text" class="form-control form-control-sm" name="label" value="{{ $measurement->label }}" placeholder="Type">
                                    </div>
                                    <div class="mb-2">
                                        <input required autofocus type="text" class="form-control form-control-sm" name="value" value="{{ $measurement->value }}" placeholder="Value">
                                    </div>
                                    <div class="mb-2">
                                        <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
                                    </div>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                            <span>
                                {{ $measurement->label == 'Wt. (lbs.)' ? 'WT' : $measurement->label}}:
                            </span>
                            <span class="font-weight-bold ml-1">
                                @if($measurement->label == 'BP')
                                    {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mm Hg
                                @elseif($measurement->label == 'Wt. (lbs.)')
                                    {{round($measurement->numeric_value, 1)}} lbs.
                                @elseif($measurement->numeric_value)
                                    {{round($measurement->numeric_value)}}
                                @else
                                    {{ $measurement->value }}
                                @endif
                            </span>
                            <span class="font-weight-normal text-secondary ml-2 text-sm">({{ $measurement->ts ? friendly_date_time_short_with_tz_from_timestamp_divide1000($measurement->ts, 'EASTERN') : friendly_date_time($measurement->effective_date, false) }})</span>
                        </div>
                    </td>
                </tr>
                @endif
            @endif
        @endforeach
        @if(!$patient->measurements || !count($patient->measurements))
            <tr>
                <td class="text-secondary p-0 border-0 pl-2">
                    No items to show
                </td>
            </tr>
        @endif
        </tbody>
    </table>
</div>
