<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <?php
    $note = null;
    $hcpCompany = null;
    $hcpCompanyProPayer = null;
    $hcpCompanyLocation = null;
    if(@$prescription->note) {
        $note = $prescription->note;
        $hcpCompany = $note->hcpCompany;
        $hcpCompanyProPayer = $note->hcpCompanyProPayer;
        $hcpCompanyLocation = $note->hcpCompanyLocation;
    }
    $companyName = $hcpCompany ? $hcpCompany->name : 'Scholar Medical Group MD LLC';
    $addressLine1 = $hcpCompanyLocation ? $hcpCompanyLocation->line1 : '133 Rollins Ave';
    $addressLine2 = $hcpCompanyLocation ? $hcpCompanyLocation->line2 : 'Ste 3';
    $city = $hcpCompanyLocation ? $hcpCompanyLocation->city : 'Rockville';
    $state = $hcpCompanyLocation ? $hcpCompanyLocation->state : 'MD';
    $zip = $hcpCompanyLocation ? $hcpCompanyLocation->zip : '20852';
    ?>
    <?php
    use App\Models\Erx;
    /** @var Erx $prescription */
    $patient = $prescription->patient;
    ?>
    <title>{{$companyName}}</title>
</head>
<body>
<div style="margin: 0; padding: .3rem; font-family: sans-serif">
    <header style="padding: 0; border: 0; margin: 0">
        <div style="text-align: center">
            <h3 style="margin-bottom:1px;line-height:5px;">{{ $prescription->hcpPro->displayName(true) }}</h3>
            <h4 style="margin-bottom:1px;line-height:5px;">{{$companyName}}</h4>
            <h4 style="margin-bottom:1px;line-height:3px;font-weight:400;">{{$addressLine1}}, {{$addressLine2}}</h4>
            <h4 style="margin-bottom:1rem;line-height:3px;font-weight:400;">{{$city}}, {{$state}} {{$zip}}</h4>
        </div>
        <div style="text-align:center;">
          <span style="width:33.33%; display:inline-block;">Phone: (800) 707-9705</span>
          <span style="width:33.33%; display:inline-block;">Fax: (800) 878-1414</span>
          <span style="width:33.33%; display:inline-block;">NPI: {{$prescription->hcpPro->hcp_npi}}</span>
        </div>
    </header>

    <hr style="border-top: 2px solid #5ca4e8; border-bottom: 0; margin-top:-5px; margin-bottom:.5rem;">

    @include('app.patient.prescriptions.pdf.' . $prescription->erx_category)

    <?php if($prescription->logistics_detail_json): ?>
        <?php $logistics = json_decode($prescription->logistics_detail_json); ?>
        <hr style="margin: 0 0 0.5rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
        <div style="font-size: 14px; opacity: 0.75; ">
            <p style="margin: 0.5rem 0;"><b>{{ $logistics->facilityName }}</b></p>
            <p style="margin: 0.5rem 0;">{{$logistics->facilityCity}} {{$logistics->facilityState}} {{$logistics->facilityZip}}</p>
            <p style="margin: 0.5rem 0;">Phone: {{$logistics->facilityPhone}}</p>
            <p style="margin: 0.5rem 0;">Fax: {{$logistics->facilityFax}}</p>
        </div>
    <?php endif; ?>

    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;padding-left:20%;margin-top:1rem;">
        <tr>
          <td style="vertical-align: bottom;padding-right:.2rem;">Signature:</td>
          <td style="vertical-align: middle;border-bottom:1px solid #aaa;width:100%;padding-bottom:.2rem;padding-left:5rem;">
              @if($prescription->hcpPro->signature_base_64)
                  <img src="{{$prescription->hcpPro->signature_base_64}}" style="max-width: 100px;">
              @endif
          </td>
        </tr>
        <tr>
          <td></td>
            <td style="vertical-align: middle; white-space: nowrap;padding-top:.5rem;padding-left:.5rem;">
                Digital Signature Capture at <?= friendlier_date_time($prescription->created_at) ?>
            </td>
        </tr>
    </table>
</div>
<div style="font-family: sans-serif;position:absolute; bottom:0;margin:0;width:100%;text-align:center;padding-bottom:10px;">EndoChart<sup>®</sup></div>
</body>
</html>
