<section style="padding-top: 0.1rem;">

    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
        <tr>
            <td style="width: 70%">
                <b>Patient Information</b>
            </td>
            <td style="">
                <div style="text-align: right">Date: <b>{{date('Y-m-d')}}</b></div>
            </td>
        </tr>
    </table>

    <div style="font-size: 14px; margin-top: 0.6rem; line-height: 1.4; opacity: 0.6">
        <span>{{ $patient->displayName() }}, {{$patient->sex}}, {{$patient->age_in_years}} years old</span><br>
        <?php
        $addressParts = [];
        if (!!$patient->mailing_address_line1) $addressParts[] = $patient->mailing_address_line1;
        if (!!$patient->mailing_address_line2) $addressParts[] = $patient->mailing_address_line2;
        $addressParts = implode(", ", $addressParts) . ", ";
        $addressPart2 = [];
        if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
        if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
        $addressParts .= implode(", ", $addressPart2);
        ?>
        <span>{!! $addressParts !!}</span>
    </div>
</section>

<?php $rxData = json_decode($ticket->data); ?>
<div style="margin: 1.5rem 0 1rem; font-weight: bold; opacity: 0.5"><span style="font-size: 24px">R</span><span style="font-size: 16px">x</span></div>
<section style="font-size: 15px;">
    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
        <tr>
            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
                <span>1. </span>
            </td>
            <td style="vertical-align: top">
                <div>
                    <p style="margin: 0 0 0.5rem;">
                        <b>{{ $rxData->medication }} {{ $rxData->strength }}
                            @if($rxData->route)
                                - {{ $rxData->route }}
                            @endif
                        </b>
                    </p>
                    <div style="">
                        @if($rxData->frequency)
                            <p style="margin: 0.5rem 0;">Frequency: {{ $rxData->frequency }}</p>
                        @endif
                        @if($rxData->dispense)
                            <p style="margin: 0.5rem 0;">Dispense: {{ $rxData->dispense }}</p>
                        @endif
                        @if($rxData->refills)
                            <p style="margin: 0.5rem 0;">Refills: {{ $rxData->refills }}</p>
                        @endif
                        @if($rxData->purpose)
                            <p style="margin: 0.5rem 0;">Purpose: <b>{{ $rxData->purpose }}</b></p>
                        @endif
                    </div>
                </div>
            </td>
        </tr>
    </table>
</section>
<?php
$additionalItems = @$rxData->items && count($rxData->items) ? $rxData->items : [];
$itemNum = 2;
?>
@foreach($additionalItems as $item)
    <hr style="margin: 0.5rem 0 1rem; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
    <section style="font-size: 15px;">
        <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
            <tr>
                <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
                    <span>{{$itemNum++}}. </span>
                </td>
                <td style="vertical-align: top">
                    <div>
                        <p style="margin: 0 0 0.5rem;">
                            <b>{{ $item->medication }} {{ $item->strength }}
                                @if($item->route)
                                    - {{ $item->route }}
                                @endif
                            </b>
                        </p>
                        <div>
                            @if($item->frequency)
                                <p style="margin: 0.5rem 0;">Frequency: {{ $item->frequency }}</p>
                            @endif
                            @if($item->dispense)
                                <p style="margin: 0.5rem 0;">Dispense: {{ $item->dispense }}</p>
                            @endif
                            @if($item->refills)
                                <p style="margin: 0.5rem 0;">Refills: {{ $item->refills }}</p>
                            @endif
                            @if($item->purpose)
                                <p style="margin: 0.5rem 0;">Purpose: <b>{{ $item->purpose }}</b></p>
                            @endif
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </section>
@endforeach
<hr style="margin: 0.5rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
<p><b>Pharmacy Information</b>:</p>
<div style="font-size: 14px; opacity: 0.75; ">
    <p style="margin: 0.5rem 0;"><b>{{ $rxData->pharmacyName }}</b></p>
    <p style="margin: 0.5rem 0;">{{$rxData->pharmacyAddressMemo}} {{$rxData->pharmacyCity}} {{$rxData->pharmacyState}}</p>
    <p style="margin: 0.5rem 0;">Phone: {{$rxData->pharmacyPhone}}</p>
</div>
