@extends ('layouts.patient')

@section('inner-content')
    <?php
    $shortCutsObject = [];
    foreach ($pro->shortcuts as $shortcut) {

        // %replaceables%
        $shortcut->text = str_replace("%AGE%", $patient->age_in_years, $shortcut->text);
        $shortcut->text = str_replace("%GENDER%", $patient->sex, $shortcut->text);
        $shortcut->text = str_replace("%NAME%", $patient->displayName(), $shortcut->text);

        $shortCutsObject[] = [
            "name" => $shortcut->shortcut,
            "value" => $shortcut->text
        ];
    }
    ?>
    <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
    <link href="/select2/select2.min.css" rel="stylesheet" />
    <script src="/select2/select2.min.js"></script>
    <div>

        {{-- CARE PLAN START --}}
        <?php $infoLines = json_decode($patient->info_lines);?>
        <?php $infoLines = !$infoLines ? [] : $infoLines; ?>
        <?php $vitalLabels = ['Ht. (in.)','Wt. (lbs.)','Temp. (F)','Pulse','Resp.','Pulse Ox.','SBP','DBP','Smoking Status', 'BMI']; ?>

	    <div class="row client-single-dashboard">
            <div class="col-6">

                {{-- appointments --}}
                @include('app/patient/partials/appointments')

                {{-- canvas based allergies --}}
                <div class="pt-2 mt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'allergies'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.allergies.summary')
                    </div>
                </div>

                {{-- canvas based rx --}}
                <div class="pt-2 mt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'rx', 'class' => 'wide'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.rx.summary')
                    </div>
                </div>

                {{-- programs --}}
                @if($pro->pro_type == 'ADMIN')
                    @include('app/patient/partials/programs')
                @endif

                {{-- devices --}}
                <?php $availableDevices = 0; ?>
                @foreach($devices as $device)
                    @if(!$patient->hasDevice($device))
                        <?php $availableDevices++; ?>
                    @endif
                @endforeach
                <div class="mt-2 pb-1" id="patient-dashboard-devices">
                    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
                        <h6 class="my-0 font-weight-bold text-secondary">Devices</h6>
                        @if($availableDevices > 0)
                        <span class="mx-2 text-secondary">|</span>
                        <span moe>
                            <a start show>Add</a>
                            <form url="/api/clientBdtDevice/create" class="mcp-theme-1">
                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">Device</label>
                                    <select name="deviceUid" class="form-control form-control-sm">
                                        <option value=""> --select-- </option>
                                        @foreach($devices as $device)
                                            @if(!$patient->hasDevice($device))
                                            <option value="{{$device->uid}}">
                                                {{$device->imei}} ({{$device->category}})
                                            </option>
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">Instructions</label>
                                    <input type="text" name="instructions" class="form-control form-control-sm">
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">Internal Memo</label>
                                    <input type="text" name="internalMemo" class="form-control form-control-sm">
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">Status</label>
                                    <input type="text" name="status" class="form-control form-control-sm">
                                </div>
                                <div class="mb-2">
                                    <label class="text-secondary text-sm">Status Memo</label>
                                    <input type="text" name="statusMemo" class="form-control form-control-sm">
                                </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>
                        @endif
                    </div>
                    <table class="table table-sm border-0 my-0 mx-2">
                        <tbody>
                        @foreach($patient->devices as $device)
                            <tr>
                                <td class="text-black p-0 border-0">
                                    <div class="pb-0">
                                        <span relative moe>
                                            <a class="on-hover-opaque" start show title="Update">
                                                <i class="font-size-11 fa fa-edit text-primary"></i>
                                            </a>
                                            <form url="/api/clientBdtDevice/update">
                                                <input type="hidden" name="uid" value="{{ $device->uid }}">
                                                <div class="mb-2">
                                                    <label class="text-secondary text-sm">Instructions</label>
                                                    <input type="text" name="instructions"
                                                           value="{{$device->instructions}}"
                                                           class="form-control form-control-sm">
                                                </div>
                                                <div class="mb-2">
                                                    <label class="text-secondary text-sm">Internal Memo</label>
                                                    <input type="text" name="internalMemo"
                                                           value="{{$device->internal_memo}}"
                                                           class="form-control form-control-sm">
                                                </div>
                                                <div class="mb-2">
                                                    <label class="text-secondary text-sm">Status</label>
                                                    <input type="text" name="status"
                                                           value="{{$device->status}}"
                                                           class="form-control form-control-sm">
                                                </div>
                                                <div class="mb-2">
                                                    <label class="text-secondary text-sm">Status Memo</label>
                                                    <input type="text" name="statusMemo"
                                                           value="{{$device->status_memo}}"
                                                           class="form-control form-control-sm">
                                                </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>
                                        <b>{{$device->device->category}}</b>&nbsp;/&nbsp;IMEI: {{$device->device->imei}}
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                        @if(!$patient->devices || count($patient->devices) === 0)
                            <tr>
                                <td class="text-secondary p-0 border-0">
                                    No devices
                                </td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>

                {{-- device measurements --}}
                {{-- @include('app/patient/partials/device-measurements') --}}

                {{-- measurements --}}
                @include('app/patient/partials/measurements')

                {{-- vitals --}}
                {{--@include('app/patient/partials/vitals')--}}

                {{-- canvas based vitals --}}
                <div class="pt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Vitals</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'vitals', 'class' => 'narrow'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.vitals.summary')
                    </div>
                </div>

            </div>
            <div class="col-6">

                {{-- dx --}}
                {{--@include('app/patient/partials/dx')--}}

                {{-- canvas based dx --}}
                <div class="pt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Current Problems / Focus Areas</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'dx', 'class' => 'wide'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.dx.summary')
                    </div>
                </div>

                {{--<div class="mt-2">
                    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
                        <h6 class="my-0 font-weight-bold text-secondary">History</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <a start show class="py-0 font-weight-normal"
                           href="/patients/view/{{ $patient->uid }}/history">
                            View All
                        </a>
                    </div>
                </div>--}}

                {{-- history_medical --}}
                <div class="pt-2 mt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'pmhx'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.pmhx.summary')
                    </div>
                </div>

                {{-- history_surgical --}}
                <div class="mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'pshx'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.pshx.summary')
                    </div>
                </div>

                {{-- history_family --}}
                <div class="mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'fhx'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.fhx.summary')
                    </div>
                </div>

                {{-- history_social --}}
                <div class="mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'sochx'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.sochx.summary')
                    </div>
                </div>

                {{-- history_ob_and_preg --}}
                <div class="pl-2 mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold">OB & Pregnancy</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/clientInfoLine/create">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_ob_and_preg">
                                <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="OB & Pregnancy History"></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>
                        <div moe>
                            <a start show class="">Multi</a>
                            <form url="/api/clientInfoLine/createMultiple">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_ob_and_preg">
                                <div class="mb-2"><textarea class="form-control form-control-sm" rows="8" name="contentTexts" value="" placeholder="Lines..."></textarea></div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm border-0 m-0">
                        <tbody>
                        @foreach($infoLines as $category => $lines)
                            @if($category === "history_ob_and_preg")
                                @foreach ($lines as $line)
                                    <tr>
                                        {{--<td class="px-2">{{$category}}</td>--}}
                                        <td class="pl-4 py-0 border-0">
                                            <div class="d-flex">
                                                <span 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/clientInfoLine/remove">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <p class="small">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>
                                                </span>
                                                <div moe relative class="mr-2">
                                                    <a class="on-hover-opaque" start show title="Edit">
                                                        <i class="font-size-11 fa fa-edit"></i>
                                                    </a>
                                                    <form url="/api/clientInfoLine/updateContent">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                                        <input type="hidden" name="category" value="history_ob_and_preg">
                                                        <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="{{$line->contentText}}" placeholder="History"></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="">{{$line->contentText}}</span>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>

                {{-- history_hospitalizations_procedures --}}
                <div class="pl-2 mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold">Hospitalizations / Procedures</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/clientInfoLine/create">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_hospitalizations_procedures">
                                <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Hospitalizations / Procedures History"></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>
                        <div moe>
                            <a start show class="">Multi</a>
                            <form url="/api/clientInfoLine/createMultiple">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_hospitalizations_procedures">
                                <div class="mb-2"><textarea class="form-control form-control-sm" rows="8" name="contentTexts" value="" placeholder="Lines..."></textarea></div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm border-0 m-0">
                        <tbody>
                        @foreach($infoLines as $category => $lines)
                            @if($category === "history_hospitalizations_procedures")
                                @foreach ($lines as $line)
                                    <tr>
                                        {{--<td class="px-2">{{$category}}</td>--}}
                                        <td class="pl-4 py-0 border-0">
                                            <div class="d-flex">
                                                <span 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/clientInfoLine/remove">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <p class="small">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>
                                                </span>
                                                <div moe relative class="mr-2">
                                                    <a class="on-hover-opaque" start show title="Edit">
                                                        <i class="font-size-11 fa fa-edit"></i>
                                                    </a>
                                                    <form url="/api/clientInfoLine/updateContent">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                                        <input type="hidden" name="category" value="history_hospitalizations_procedures">
                                                        <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="{{$line->contentText}}" placeholder="History"></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="">{{$line->contentText}}</span>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>

                {{-- history_screenings --}}
                <div class="pl-2 mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold">Screenings</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/clientInfoLine/create">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_screenings">
                                <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Screenings History"></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>
                        <div moe>
                            <a start show class="">Multi</a>
                            <form url="/api/clientInfoLine/createMultiple">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_screenings">
                                <div class="mb-2"><textarea class="form-control form-control-sm" rows="8" name="contentTexts" value="" placeholder="Lines..."></textarea></div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm border-0 m-0">
                        <tbody>
                        @foreach($infoLines as $category => $lines)
                            @if($category === "history_screenings")
                                @foreach ($lines as $line)
                                    <tr>
                                        {{--<td class="px-2">{{$category}}</td>--}}
                                        <td class="pl-4 py-0 border-0">
                                            <div class="d-flex">
                                                <span 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/clientInfoLine/remove">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <p class="small">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>
                                                </span>
                                                <div moe relative class="mr-2">
                                                    <a class="on-hover-opaque" start show title="Edit">
                                                        <i class="font-size-11 fa fa-edit"></i>
                                                    </a>
                                                    <form url="/api/clientInfoLine/updateContent">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                                        <input type="hidden" name="category" value="history_screenings">
                                                        <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="{{$line->contentText}}" placeholder="History"></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="">{{$line->contentText}}</span>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>

                {{-- history_colonoscopy --}}
                <div class="pl-2 mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold">Colonoscopy</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/clientInfoLine/create">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_colonoscopy">
                                <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Colonoscopy History"></div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm border-0 m-0">
                        <tbody>
                        @foreach($infoLines as $category => $lines)
                            @if($category === "history_colonoscopy")
                                @foreach ($lines as $line)
                                    <tr>
                                        {{--<td class="px-2">{{$category}}</td>--}}
                                        <td class="pl-4 py-0 border-0">
                                            <div class="d-flex">
                                                <span 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/clientInfoLine/remove">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <p class="small">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>
                                                </span>
                                                <div moe relative class="mr-2">
                                                    <a class="on-hover-opaque" start show title="Edit">
                                                        <i class="font-size-11 fa fa-edit"></i>
                                                    </a>
                                                    <form url="/api/clientInfoLine/updateContent">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                                        <input type="hidden" name="category" value="history_colonoscopy">
                                                        <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="{{$line->contentText}}" placeholder="History"></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="">{{$line->contentText}}</span>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>

                {{-- history_mammogram --}}
                <div class="pl-2 mt-2">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold">Mammogram</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/clientInfoLine/create">
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="category" value="history_mammogram">
                                <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Mammogram History"></div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm border-0 m-0">
                        <tbody>
                        @foreach($infoLines as $category => $lines)
                            @if($category === "history_mammogram")
                                @foreach ($lines as $line)
                                    <tr>
                                        {{--<td class="px-2">{{$category}}</td>--}}
                                        <td class="pl-4 py-0 border-0">
                                            <div class="d-flex">
                                                <span 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/clientInfoLine/remove">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <p class="small">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>
                                                </span>
                                                <div moe relative class="mr-2">
                                                    <a class="on-hover-opaque" start show title="Edit">
                                                        <i class="font-size-11 fa fa-edit"></i>
                                                    </a>
                                                    <form url="/api/clientInfoLine/updateContent">
                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                                        <input type="hidden" name="category" value="history_mammogram">
                                                        <div class="mb-2"><input type="text" class="form-control form-control-sm" name="contentText" value="{{$line->contentText}}" placeholder="History"></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="">{{$line->contentText}}</span>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>

                {{-- ROS --}}
                <div class="pt-2 mt-2 border-top">
                    <div class="note-section">
                        <div class="d-flex align-items-center pb-2">
                            <h6 class="my-0 font-weight-bold text-secondary">ROS</h6>
                            <span class="mx-2 text-secondary">|</span>
                            @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'ros'])
                            @include('app.patient.note.section_script')
                        </div>
                        <div class="bg-light border p-2 mb-3">
                            @include('app.patient.canvas-sections.ros.summary')
                        </div>
                    </div>
                </div>

                {{-- care-team --}}
                {{--@include('app/patient/partials/care-team')--}}

                {{-- canvas based dx --}}
                <div class="pt-2 mt-2 border-top">
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
                        <span class="mx-2 text-secondary">|</span>
                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'care-team', 'class' => 'wide'])
                    </div>
                    <div class="bg-light border p-2 mb-3">
                        @include('app.patient.canvas-sections.care-team.summary')
                    </div>
                </div>
            </div>
        </div>
        <?php /* <div class="row my-3">
            <div class="col-12">
                {{-- erx --}}
                <div  class="mb-2 pt-3 pb-2 border-top">
                    <style>
                        td.fit {
                            width:1%;
                            white-space:nowrap;
                        }
                    </style>
                    <div class="d-flex align-items-center pb-2">
                        <h6 class="my-0 font-weight-bold text-secondary">ERx</h6>
                        <span class="mx-2 text-secondary">|</span>
                        <div moe>
                            <a start show class="py-0 font-weight-normal">Add</a>
                            <form url="/api/actionItem/create" wide>
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <input type="hidden" name="prescriberProUid" value="{{ $pro->uid }}">
                                <input type="hidden" name="category" value="DRUG">
                                <div class="mb-2">
                                    <label for="" class="control-label text-sm text-secondary mb-1">Pharmacy</label>
                                    <select name="toFacilityUid"
                                            class="form-control form-control-sm">
                                        <option value="">-- Pharmacy --</option>
                                        @foreach ($facilities as $facility)
                                            <option value="{{$facility->uid}}">{{$facility->name}}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Title *" required>
                                </div>
                                <div class="mb-2">
                                    <input type="text" class="form-control form-control-sm" name="contentDetail" value="" placeholder="Directions">
                                </div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-sm table-bordered mb-0" style="table-layout: fixed">
                        <thead>
                        <tr>
                            <th class="px-2 text-secondary border-bottom-0 w-25">Prescription</th>
                            <th class="px-2 text-secondary border-bottom-0 fit">Created</th>
                            <th class="px-2 text-secondary border-bottom-0 fit">Status</th>
                            <th class="px-2 text-secondary border-bottom-0 fit">Pharmacy</th>
                            <th class="px-2 text-secondary border-bottom-0">&nbsp;</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $prevItemType = false; ?>
                        @foreach($patient->actionItems as $item)
                            @if($item->action_item_category === 'DRUG')
                                <tr>
                                    <td class="px-2">
                                        {{$item->content_text}}
                                        <span moe>
                                        <a start show class="on-hover-opaque"><i class="fa fa-edit"></i></a>
                                        <form url="/api/actionItem/updateContent" wide>
                                            <input type="hidden" name="uid" value="{{ $item->uid }}">
                                            <div class="mb-2">
                                                <input type="text" class="form-control form-control-sm" name="contentText" value="{{ $item->content_text }}" placeholder="Title *" required>
                                            </div>
                                            <div class="mb-2">
                                                <input type="text" class="form-control form-control-sm" name="contentDetail" value="{{ $item->content_detail }}" placeholder="Details">
                                            </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>
                                        <div class="text-sm text-secondary">{{$item->content_detail}}</div>
                                    </td>
                                    <td class="px-2">{{friendly_date_time($item->created_at, false)}}</td>
                                    <td class="px-2">
                                        {{ucwords($item->status_category)}}
                                        <span moe>
                                        <a start show class="on-hover-opaque"><i class="fa fa-edit"></i></a>
                                        <form url="/api/actionItem/updateStatus">
                                            <input type="hidden" name="uid" value="{{ $item->uid }}">
                                            <div class="mb-2">
                                                <label for="" class="control-label text-sm text-secondary mb-1">Status *</label>
                                                <select name="statusCategory" class="form-control form-control-sm" required>
                                                    <option {{ $item->status_category === 'OPEN' ? 'selected' : '' }} value="OPEN">Open</option>
                                                    <option {{ $item->status_category === 'CLOSED' ? 'selected' : '' }} value="CLOSED">Closed</option>
                                                </select>
                                            </div>
                                            <div class="mb-2">
                                                <input type="text" class="form-control form-control-sm" name="statusMemo" value="" placeholder="Memo">
                                            </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>
                                    </td>
                                    <td class="px-2">
                                        {{$item->facility ? $item->facility->name : ''}}
                                        <span moe>
                                        <a start show class="on-hover-opaque"><i class="fa fa-edit"></i></a>
                                        <form url="/api/actionItem/updateToFacility">
                                            <input type="hidden" name="uid" value="{{ $item->uid }}">
                                            <div class="mb-2">
                                                <label for="" class="control-label text-sm text-secondary mb-1">Pharmacy *</label>
                                                <select name="toFacilityUid" class="form-control form-control-sm" required>
                                                    <option value="">-- Pharmacy --</option>
                                                    @foreach ($facilities as $facility)
                                                        <option {{ $item->to_facility_id === $facility->id ? 'selected' : '' }} value="{{$facility->uid}}">{{$facility->name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="d-flex align-items-center">
                                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                            </div>
                                        </form>
                                    </span>
                                    </td>
                                    <td class="px-2 text-center">
                                        <div class="d-flex align-items-center justify-content-start">
                                            @if($item->is_signed_by_prescriber)
                                                <span class="text-secondary">
                                            <i class="fa fa-check"></i>
                                            Signed
                                        </span>
                                                <span class="mx-2 text-secondary">|</span>
                                            @else
                                                @if($pro->id === $item->prescriber_pro_id)
                                                    <span moe relative>
                                                <a start show>Sign</a>
                                                <form url="/api/actionItem/signAsPrescriber" right>
                                                    <input type="hidden" name="uid" value="{{ $item->uid }}">
                                                    <p class="small min-width-200px text-left">Sign this action items as the prescriber?</p>
                                                    <div class="d-flex align-items-center">
                                                        <button class="btn btn-sm btn-success mr-2" submit>Yes</button>
                                                        <button class="btn btn-sm btn-default mr-2 border" cancel>No</button>
                                                    </div>
                                                </form>
                                            </span>
                                                    <span class="mx-2 text-secondary">|</span>
                                                @endif
                                            @endif
                                            <span moe relative>
                                        <a start show>eFax</a>
                                        <form url="/api/actionItem/efax" right>
                                            <input type="hidden" name="uid" value="{{ $item->uid }}">
                                            <div class="mb-2">
                                                <input type="text" class="form-control form-control-sm" name="toFaxNumber" value="" placeholder="To Number *" required>
                                            </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>
                                    </span>
                                        </div>
                                    </td>
                                </tr>
                            @endif
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div> */ ?>

        <div class="row my-3">
            <div class="col-12">
                {{-- memos --}}
                <div  class="mb-2 pt-3 pb-2 border-top">
                    <div class="">
                        <div class="d-flex align-items-start pb-2">
                            <h6 class="my-0 font-weight-bold text-secondary">Client Memos</h6>
                        </div>
                        <div moe class="w-50 p-2 border mb-3">
                            <form url="/api/clientMemo/create" show>
                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                                <label class="text-secondary font-weight-bold">+ New Memo</label>
                                <div class="mb-2">
                                    <select class="form-control form-control-sm" name="category" required>
                                        <option value="">-- select --</option>
                                        <option value="Incoming Call">Incoming Call</option>
                                        <option value="Outgoing Call">Outgoing Call</option>
                                        <option value="Call Unspecified">Call Unspecified</option>
                                        <option value="Other">Other</option>
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <textarea class="form-control form-control-sm" rows="5" name="content" placeholder="Content"></textarea>
                                </div>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
                                </div>
                            </form>
                        </div>
                        <table class="table table-striped table-sm table-bordered mb-0">
                            @if($patient->memos && count($patient->memos))
                                <thead>
                                <tr>
                                    <th class="px-2 text-secondary">Category</th>
                                    <th class="px-2 text-secondary w-75">Summary</th>
                                    <th class="px-2 text-secondary">Created</th>
                                    <th class="px-2 text-secondary delete-column">&nbsp;</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($patient->memos as $memo)
                                    <tr>
                                        <td class="px-2 text-nowrap">{{ $memo->category }}</td>
                                        <td class="px-2"><pre class="m-0 break-spaces">{{ $memo->content }}</pre></td>
                                        <td class="px-2 text-nowrap">{{ friendly_date_time($memo->created_at) }}</td>
                                        <td class="px-2 text-center delete-column">
                                            <div moe wide relative class="mr-2">
                                                <a class="on-hover-opaque" start show title="Edit">
                                                    <i class="font-size-11 fa fa-edit"></i>
                                                </a>
                                                <form url="/api/clientMemo/update" right>
                                                    <input type="hidden" name="uid" value="{{ $memo->uid }}">
                                                    <div class="mb-2">
                                                        <select class="form-control form-control-sm" name="category" required>
                                                            <option value="">-- select --</option>
                                                            <option {{ $memo->category === "Incoming Call" ? "selected" : "" }} value="Incoming Call">Incoming Call</option>
                                                            <option {{ $memo->category === "Outgoing Call" ? "selected" : "" }} value="Outgoing Call">Outgoing Call</option>
                                                            <option {{ $memo->category === "Call Unspecified" ? "selected" : "" }} value="Call Unspecified">Call Unspecified</option>
                                                            <option {{ $memo->category === "Other" ? "selected" : "" }} value="Other">Other</option>
                                                        </select>
                                                    </div>
                                                    <div class="mb-2">
                                                        <textarea class="form-control form-control-sm" name="content" rows="5"
                                                            placeholder="Content"><?= $memo->content ?></textarea>
                                                    </div>
                                                    <div class="d-flex align-items-center">
                                                        <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
                                                        <button class="btn btn-sm btn-default mr-2 border" type="button"
                                                                cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </div>
                                            <div moe relative>
                                                <a start show class="on-hover-opaque"><i class="fa fa-trash-alt text-danger"></i></a>
                                                <form url="/api/clientMemo/cancel" right>
                                                    <input type="hidden" name="uid" value="{{ $memo->uid }}">
                                                    <p class="small">Are you sure you want to cancel this memo?</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>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            @else
                                <tbody>
                                <tr>
                                    <td class="text-secondary p-3">No memos have been created for this patient</td>
                                </tr>
                                </tbody>
                            @endif
                        </table>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <script>
        (function() {
            function init() {
                $('select[name="deviceUid"]').select2({
                    width: '100%'
                });
            }
            addMCInitializer('patient-dashboard-devices', init, '#patient-dashboard-devices');
        }).call(window);
    </script>
@endsection
