<div class="d-flex align-items-end mb-3">
    <b class="large">ERx - Open</b>
</div>
<table class="table table-sm table-bordered mb-0">
    <thead>
    <tr class="bg-light">
        <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
        <th class="px-2 text-secondary border-bottom-0 width-30px">View/Open</th>
        <th class="px-2 text-secondary border-bottom-0 width-30px">Patient</th>
        <th class="px-2 text-secondary border-bottom-0">Medication</th>
    </tr>
    </thead>
    <tbody>
    @foreach($tickets as $ticket)
        @if($ticket->category === 'erx')
            <?php $data = json_decode($ticket->data); ?>
            <tr>
                <td class="px-2 text-nowrap">
                    {{friendlier_date_time($ticket->created_at)}}
                </td>
                <td class="px-2 text-nowrap">
                    <div class="d-flex align-items-center flex-nowrap">
                        <a href="/patients/view/{{$ticket->patient->uid}}/tickets/erx/{{$ticket->uid}}?popupmode=1"
                           native target="_blank"
                           class="ticket-popup-trigger d-block text-nowrap mr-3">
                            View
                        </a>
                        <a href="/patients/view/{{$ticket->patient->uid}}/tickets/erx/{{$ticket->uid}}"
                           class="d-block text-nowrap">
                            <i class="fa fa-external-link-alt"></i>
                            Open
                        </a>
                    </div>
                </td>
                <td class="px-2 text-nowrap">
                    <a href="/patients/view/{{$ticket->patient->uid}}/tickets/erx">
                        {{$ticket->patient->displayName()}}
                    </a>
                </td>
                <td class="px-2">
                    <div class="d-flex align-items-center flex-wrap">
                        <span class="font-weight-bold font-size-13">{{$data->medication}}</span>
                        @if($data->strength)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span>{{$data->strength}}</span>
                        </span>
                        @endif
                        @if($data->route)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span>{{$data->route}}</span>
                        </span>
                        @endif
                        @if($data->frequency)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span>{{$data->frequency}}</span>
                        </span>
                        @endif
                        @if($data->dispense)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span>Dispense:</span> {{$data->dispense}}
                        </span>
                        @endif
                        @if($data->frequency)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span><span>Refills:</span> {{$data->refills}}</span>
                        </span>
                        @endif
                        @if($data->dispense)
                            <span class="d-inline-flex align-items-center">
                            <span class="mx-2 text-secondary">•</span>
                            <span><span>Purpose:</span> {{$data->purpose}}</span>
                        </span>
                        @endif
                    </div>
                </td>
<!--                <td class="px-2">
                    <span class="" v-html="pharmacy(item)"></span>
                </td>-->
            </tr>
        @endif
    @endforeach

    </tbody>
</table>