Selaa lähdekoodia

merged with dev

root 3 vuotta sitten
vanhempi
commit
7a77b40df1
40 muutettua tiedostoa jossa 3867 lisäystä ja 163 poistoa
  1. 4 0
      app/Http/Controllers/NoteController.php
  2. 11 0
      app/Http/Controllers/PatientController.php
  3. 2 2
      app/Models/Client.php
  4. 8 2
      public/css/style.css
  5. 36 1
      resources/views/app/patient/medications-center.blade.php
  6. 89 0
      resources/views/app/patient/medications-reconcile.blade.php
  7. 2 2
      resources/views/app/patient/note/dashboard.blade.php
  8. 32 0
      resources/views/app/patient/prescriptions-popup/client-status-form.blade.php
  9. 61 0
      resources/views/app/patient/prescriptions-popup/drug-form.blade.php
  10. 23 0
      resources/views/app/patient/prescriptions-popup/hcp-pro-form.blade.php
  11. 30 0
      resources/views/app/patient/prescriptions-popup/imaging-form.blade.php
  12. 5 0
      resources/views/app/patient/prescriptions-popup/index-popup.blade.php
  13. 5 0
      resources/views/app/patient/prescriptions-popup/index.blade.php
  14. 30 0
      resources/views/app/patient/prescriptions-popup/lab-form.blade.php
  15. 1152 0
      resources/views/app/patient/prescriptions-popup/list-popup.blade.php
  16. 59 0
      resources/views/app/patient/prescriptions-popup/logistics-form.blade.php
  17. 25 0
      resources/views/app/patient/prescriptions-popup/other-form.blade.php
  18. 89 0
      resources/views/app/patient/prescriptions-popup/pdf/DRUG.blade.php
  19. 203 0
      resources/views/app/patient/prescriptions-popup/pdf/IMAGING.blade.php
  20. 203 0
      resources/views/app/patient/prescriptions-popup/pdf/LAB.blade.php
  21. 203 0
      resources/views/app/patient/prescriptions-popup/pdf/OTHER.blade.php
  22. 203 0
      resources/views/app/patient/prescriptions-popup/pdf/REFERRAL.blade.php
  23. 203 0
      resources/views/app/patient/prescriptions-popup/pdf/SUPPLY.blade.php
  24. 13 0
      resources/views/app/patient/prescriptions-popup/pdf/pdf-preview-with-cover-sheet.blade.php
  25. 85 0
      resources/views/app/patient/prescriptions-popup/pdf/pdf-preview.blade.php
  26. 32 0
      resources/views/app/patient/prescriptions-popup/pro-status-form.blade.php
  27. 25 0
      resources/views/app/patient/prescriptions-popup/referral-form.blade.php
  28. 16 0
      resources/views/app/patient/prescriptions-popup/sign-as-hcp-form.blade.php
  29. 34 0
      resources/views/app/patient/prescriptions-popup/supply-form.blade.php
  30. 66 0
      resources/views/app/patient/prescriptions-popup/transmit-form.blade.php
  31. 25 6
      resources/views/app/patient/prescriptions/imaging-form.blade.php
  32. 5 0
      resources/views/app/patient/prescriptions/index-popup.blade.php
  33. 25 6
      resources/views/app/patient/prescriptions/lab-form.blade.php
  34. 457 96
      resources/views/app/patient/prescriptions/list.blade.php
  35. 32 33
      resources/views/app/patient/prescriptions/pdf/DRUG.blade.php
  36. 2 7
      resources/views/app/patient/prescriptions/pdf/IMAGING.blade.php
  37. 2 7
      resources/views/app/patient/prescriptions/pdf/LAB.blade.php
  38. 1 1
      resources/views/app/patient/tickets.blade.php
  39. 367 0
      resources/views/layouts/patient.blade.php
  40. 2 0
      routes/web.php

+ 4 - 0
app/Http/Controllers/NoteController.php

@@ -312,6 +312,10 @@ class NoteController extends Controller
         return view('app.patient.medications-center', compact('patient', 'note'));
     }
 
+    public function medicationsReconcile(Request $request, Client $patient, Note $note) {
+        return view('app.patient.medications-reconcile', compact('patient', 'note'));
+    }
+
     public function problemsCenter(Request $request, Client $patient, Note $note) {
         return view('app.patient.problems-center', compact('patient', 'note'));
     }

+ 11 - 0
app/Http/Controllers/PatientController.php

@@ -438,6 +438,17 @@ class PatientController extends Controller
         return view('app.patient.prescriptions.index', compact('patient', 'type', 'currentErx'));
     }
 
+    public function prescriptionsPopup(Request $request, Client $patient, String $type = '', String $currentErx = '') {
+        if(!!$currentErx) {
+            $currentErx = Erx::where('uid', $currentErx)->first();
+        }
+        $note = null;
+        if($request->input('noteUid')) {
+            $note = Note::where('uid', $request->input('noteUid'))->first();
+        }
+        return view('app.patient.prescriptions-popup.list-popup', compact('patient', 'type', 'currentErx', 'note'));
+    }
+
     public function prescriptionsList(Request $request, Client $patient, String $type = '', String $currentErx = '') {
         if(!!$currentErx) {
             $currentErx = Erx::where('uid', $currentErx)->first();

+ 2 - 2
app/Models/Client.php

@@ -94,8 +94,8 @@ class Client extends Model
     public function prescriptions()
     {
         return $this->hasMany(Erx::class, 'client_id', 'id')
-            ->orderByRaw('note_id DESC NULLS LAST')
-            ->orderBy('created_at', 'desc');
+            ->orderBy('created_at', 'desc')
+            ->orderByRaw('note_id DESC NULLS LAST');
     }
 
     public function notesAscending()

+ 8 - 2
public/css/style.css

@@ -1049,8 +1049,11 @@ body .node input[type="number"] {
 .stag-popup.min-height-unset>form {
     min-height: unset !important;
 }
+.stag-popup.medium>form, .stag-popup.medium>.stag-popup-content {
+    width: calc(80vw - 4rem);
+}
 .stag-popup.wide>form, .stag-popup.wide>.stag-popup-content {
-    width: calc(100% - 4rem);
+    width: calc(100vw - 4rem);
 }
 .stag-popup.tall>form, .stag-popup.tall>.stag-popup-content {
     height: 100%;
@@ -1983,10 +1986,13 @@ body.in-iframe .main-row > .sidebar {
     border-right: 1px solid #ddd;
     padding-top: 0.85rem;
     height: 300px;
-    overflow: overlay;
+    overflow: hidden;
     max-height: calc(100vh - 55px);
     background-color: #fff;
 }
+.note-container .note-lhs-tree:hover {
+    overflow: overlay;
+}
 .note-container .note-lhs-tree.fixed {
     position: fixed;
     top: 55px;

+ 36 - 1
resources/views/app/patient/medications-center.blade.php

@@ -50,7 +50,7 @@ $medications = $points;
                         @if($medication->is_removed)
                             <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2"></i>
                         @else
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2"></i>
+                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
                         @endif
                         <div>
                             <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
@@ -555,6 +555,41 @@ $medications = $points;
             initStagSuggest();
 
             $('.additionReasonCategory_ui').trigger('change');
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-auto mr-3');
+            let titleElem = $('#medications-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-baseline');
+
+            // add button for "reconcile active medications"
+            if($('.active-record').length) {
+                $('.btn-reconcile-active').remove();
+                $('<a ' +
+                    'href="/medications-reconcile/{{$patient->uid}}/{{$note->uid}}" ' +
+                    'title="Reconcile Active Medications" ' +
+                    'update-parent ' +
+                    'open-in-stag-popup ' +
+                    'mc-initer="medications-reconcile-{{$note->id}}" ' +
+                    'popup-style="stag-popup-md" ' +
+                    'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
+                    .appendTo(buttonContainer);
+            }
+
+            // add button for "eRx"
+            $('.btn-manage-erx').remove();
+            $('<a ' +
+                'href="/patients/view/{{$patient->uid}}/prescriptions-popup?noteUid={{$note->uid}}&erx_category=DRUG" ' +
+                'title="Manage eRx" ' +
+                'update-parent ' +
+                'open-in-stag-popup ' +
+                'mc-initer="prescriptions-popup-{{$patient->id}}" ' +
+                'popup-style="medium" ' +
+                'class="btn-manage-erx btn btn-sm mr-2 btn-info text-white font-weight-bold">Manage eRx</a>')
+                .appendTo(buttonContainer);
+
+            buttonContainer.insertAfter(titleElem);
         }
         addMCInitializer('medications-center-{{$note->id}}', init, '#medications-center-{{$note->id}}')
     }).call(window);

+ 89 - 0
resources/views/app/patient/medications-reconcile.blade.php

@@ -0,0 +1,89 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$points = Point
+    ::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->where('is_removed_due_to_entry_error', false)
+    ->where('is_removed', false)
+    ->orderBy('created_at')
+    ->get();
+foreach ($points as $point) {
+    if ($point->data) {
+        $point->data = json_decode($point->data);
+    }
+}
+$medications = $points;
+?>
+
+<div class="mt-3 p-3 border-top" id="medications-reconcile-{{$note->id}}">
+    <div class="mb-2 font-weight-bold text-secondary">The following medications will be marked as reconciled</div>
+    <table class="table table-sm table-striped table-bordered">
+        <thead>
+        <tr>
+            <th class="border-bottom-0">Medication</th>
+            <th class="border-bottom-0">Review</th>
+        </tr>
+        </thead>
+        @foreach($medications as $medication)
+        <tr>
+            <td class="w-50">{{$medication->data->name}}</td>
+            <td class="p-0">
+                <input type="text" class="form-control form-control-sm border-0 rounded-0 shadow-none" data-point-uid="{{$medication->uid}}" value="Reconciled">
+            </td>
+        </tr>
+        @endforeach
+    </table>
+    <div class="d-flex align-items-center justify-content-center">
+        <button class="btn btn-sm btn-primary mr-2 btn-save-reviews">Save</button>
+        <button class="btn btn-sm btn-default border mr-2" onclick="closeStagPopup()">Cancel</button>
+    </div>
+</div>
+
+<script>
+    (function() {
+        function init() {
+            $('#medications-reconcile-{{$note->id}} .btn-save-reviews')
+                .off('click')
+                .on('click', function() {
+                    showMask();
+                    let payload = {
+                        noteUid: '{{$note->uid}}',
+                        reviews: []
+                    }
+                    $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function() {
+                         payload.reviews.push({
+                             parentPointUid: $(this).attr('data-point-uid'),
+                             data: JSON.stringify({
+                                 isReconciled: true,
+                                 value: $(this).val()
+                             })
+                         });
+                    });
+
+                    $.ajax({
+                        url: '/api/visitPoint/upsertChildReviewMulti',
+                        type:"POST",
+                        data: JSON.stringify(payload),
+                        contentType:"application/json; charset=utf-8",
+                        dataType:"json",
+                        success: function(_data) {
+                            if(!hasResponseError(_data)) {
+                                closeStagPopup();
+                            }
+                        }
+                    }).then(() => {
+                        hideMask();
+                    });
+
+                });
+        }
+        addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')
+    }).call(window);
+</script>

+ 2 - 2
resources/views/app/patient/note/dashboard.blade.php

@@ -23,7 +23,7 @@
     $isVisitTemplateBased = !!$note->visitTemplate;
     ?>
 
-    <div id="note-single-header" class="pb-3 d-flex align-items-start screen-only">
+    <div id="note-single-header" class="pb-3 d-flex align-items-start screen-only zero-height">
         <h6 class="my-0 text-secondary d-flex align-items-center w-100">
             <a href="/patients/view/{{ $patient->uid }}/notes" class="small text-decoration-none mr-3">
                 <i class="fa fa-chevron-left"></i>
@@ -490,7 +490,7 @@
                     ?>
 
                     <hr>
-                        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Prescriptions" href="#">Prescriptions</a></div>
+                        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Prescriptions" href="#">ERx &amp; Orders</a></div>
                         <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="CM Setup" href="#">CM Setup</a></div>
                         <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="RM Setup" href="#">RM Setup</a></div>
                         <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Supply Orders Summary" href="#">Supply Orders Summary</a></div>

+ 32 - 0
resources/views/app/patient/prescriptions-popup/client-status-form.blade.php

@@ -0,0 +1,32 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1 min-height-unset" stag-popup-key="pp-client-status-popup">
+    <form method="POST" action="" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span>Client Declared Status</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Status</label>
+            <select class="form-control form-control-sm min-width-unset erx-hcp-pro-select"
+                    v-model="currentPrescriptionClientStatus.status">
+                <option value="">-- select --</option>
+                <option value="CREATED">Created</option>
+                <option value="SENT">Sent</option>
+                <option value="RECEIVED_BY_CLIENT">Received by client</option>
+                <option value="RECEIPT_CONFIRMED_BY_FACILITY">Receipt confirmed by facility</option>
+                <option value="CANCELLED">Cancelled</option>
+            </select>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescriptionClientStatus.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="saveClientStatus()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 61 - 0
resources/views/app/patient/prescriptions-popup/drug-form.blade.php

@@ -0,0 +1,61 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-DRUG">
+    <form method="POST" action="" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span>Drug Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+
+        <input type="hidden" data-name="medId">
+        <input type="hidden" data-name="routedMedId">
+        <input type="hidden" data-name="routedDosageFormMedId">
+        <input type="hidden" data-name="gcnSeqno">
+
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Drug</label>
+            <input type="text" class="form-control form-control-sm min-width-unset prescription-medication"
+                   stag-suggest
+                   stag-suggest-ep="/fdb-med-suggest-v2/json">
+        </div>
+
+        <div class="row">
+            <div class="col-4 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Frequency</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           data-option-list="frequency-options" data-field="frequency"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.frequency">
+                    <div id="frequency-options" class="data-option-list">
+                        <div>Once a day</div>
+                        <div>Twice a day</div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-4 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Dispense</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.dispense">
+                </div>
+            </div>
+            <div class="col-4">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Refills</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.refills">
+                </div>
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Purpose</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_DRUG.clinicalDetailJson.purpose">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 23 - 0
resources/views/app/patient/prescriptions-popup/hcp-pro-form.blade.php

@@ -0,0 +1,23 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1 min-height-unset" stag-popup-key="pp-hcp-pro-popup">
+    <form method="POST" action="" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span>HCP Pro</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">HCP Pro</label>
+            <select class="form-control form-control-sm min-width-unset erx-hcp-pro-select"
+                    provider-search
+                    :data-pro-uid="currentPrescriptionHcpPro.newHcpProUid ?? ''"
+                    v-model="currentPrescriptionHcpPro.newHcpProUid">
+            </select>
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="saveHcpPro()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 30 - 0
resources/views/app/patient/prescriptions-popup/imaging-form.blade.php

@@ -0,0 +1,30 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-IMAGING">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Imaging Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Test</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_IMAGING.clinicalDetailJson.test">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">ICDS</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_IMAGING.clinicalDetailJson.icds">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_IMAGING.clinicalDetailJson.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 5 - 0
resources/views/app/patient/prescriptions-popup/index-popup.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    @include('app.patient.prescriptions-popup.list-popup')
+@endsection

+ 5 - 0
resources/views/app/patient/prescriptions-popup/index.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    @include('app.patient.prescriptions-popup.list')
+@endsection

+ 30 - 0
resources/views/app/patient/prescriptions-popup/lab-form.blade.php

@@ -0,0 +1,30 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-LAB">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Lab Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Test</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_LAB.clinicalDetailJson.test">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">ICDS</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_LAB.clinicalDetailJson.icds">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_LAB.clinicalDetailJson.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 1152 - 0
resources/views/app/patient/prescriptions-popup/list-popup.blade.php

@@ -0,0 +1,1152 @@
+<div id="prescriptions-popup-{{$patient->id}}" v-cloak class="mt-3 p-3 border-top">
+    <div class="d-flex align-items-baseline pb-2">
+        <h6 class="my-0 font-weight-bold text-secondary font-size-14">Prescriptions</h6>
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'DRUG')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('DRUG')">+ New eRx</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'LAB')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('LAB')">+ Lab</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'IMAGING')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('IMAGING')">+ Imaging</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'REFERRAL')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('REFERRAL')">+ Referral</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'SUPPLY')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('SUPPLY')">+ Supply</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'OTHER')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
+        @endif
+    </div>
+    <div class="d-flex align-items-start">
+        <table class="table table-striped table-sm table-bordered mb-0 flex-grow-1">
+            <thead>
+            <tr>
+                <th class="px-2 text-secondary border-bottom-0">Created</th>
+                @if(!request()->input('erx_category'))
+                <th class="px-2 text-secondary border-bottom-0">Type</th>
+                @endif
+                <th class="px-2 text-secondary border-bottom-0 w-50">Clinical</th>
+                <th class="px-2 text-secondary border-bottom-0">Prescriber</th>
+                <th class="px-2 text-secondary border-bottom-0" v-if="!currentPrescription">Sign</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr v-for="(prescription, index) in prescriptions" :class="currentPrescription && currentPrescription.id === prescription.id ? 'bg-aliceblue' : ''">
+                <td class="px-2">
+                    <a href="#" v-on:click.prevent="setCurrentPrescription(prescription)"
+                       :class="currentPrescription && currentPrescription.id === prescription.id ? 'font-weight-bold' : ''">@{{prescription.created_at_friendly_short}}</a>
+                    @if(@$note)
+                        <div v-if="prescription.note_id === {{$note->id}}" class="text-info mt-1">* Create on this note</div>
+                    @endif
+                </td>
+                @if(!request()->input('erx_category'))
+                <td class="px-2">@{{prescription.erx_category}}</td>
+                @endif
+                <td class="px-2">
+                    <div class="d-flex align-items-baseline">
+                        {{--
+                        <a v-if="!prescription.has_hcp_pro_signed" class="mr-2" href="#" v-on:click.prevent="editClinicalDetails(prescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                        <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
+                        --}}
+                        <div v-if="prescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
+                            <div class="" v-if="prescription.erx_category === 'DRUG'">
+                                <div class="d-flex align-items-baseline mb-1" v-for="drug in prescription.clinical_detail_json.items">
+                                    <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                    <span class="text-secondary mr-1">@{{drug.frequency ?? ''}}</span>
+                                </div>
+                            </div>
+                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
+                                <b class="mr-2">@{{prescription.clinical_detail_json.test ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.icds ?? '-'}}</span>
+                            </div>
+                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'REFERRAL'">
+                                <b class="mr-2">@{{prescription.clinical_detail_json.to ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.memo ?? '-'}}</span>
+                            </div>
+                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'SUPPLY'">
+                                <b class="mr-2">@{{prescription.clinical_detail_json.item ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.quantity ?? '-'}}</span>
+                            </div>
+                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'OTHER'">
+                                <b class="mr-2">@{{prescription.clinical_detail_json.title ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.memo ?? '-'}}</span>
+                            </div>
+                        </div>
+                        <div v-else>-</div>
+                    </div>
+                </td>
+                <td class="px-2">
+                    <div class="d-flex align-items-baseline">
+                        {{--
+                        <a v-if="!prescription.has_hcp_pro_signed" class="mr-2" href="#" v-on:click.prevent="editHcpPro(prescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                        <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
+                        --}}
+                        <div>@{{prescription.hcpProDisplayName}}</div>
+                    </div>
+                </td>
+                <td class="px-2" v-if="!currentPrescription">
+                    <div v-if="prescription.has_hcp_pro_signed" class="d-flex align-items-baseline">
+                        <i class="text-secondary fa fa-check mr-1"></i>
+                        <span class="text-secondary">Signed</span>
+                    </div>
+                    {{--
+                    <div v-else>
+                        <a v-if="prescription.hcp_pro_id === {{$pro->id}}"
+                           href="#"
+                           v-on:click.prevent="signAsHcpPro(prescription)">Sign</a>
+                        <span v-else>-</span>
+                    </div>
+                    --}}
+                </td>
+            </tr>
+            </tbody>
+        </table>
+        <div v-if="currentPrescription" class="min-width-700px ml-2 border align-self-stretch p-3">
+            <div class="d-flex align-items-center">
+                <h3 class="font-size-16 m-0">
+                    <span class="mr-1 font-size-16">@{{ currentPrescription.erx_category }} / @{{ currentPrescription.created_at_friendly_short }}</span>
+                </h3>
+                <a class="ml-auto" href="#" v-on:click.prevent="setCurrentPrescription(null)">
+                    <i class="fa fa-times-circle on-hover-opaque"></i>
+                </a>
+            </div>
+            <hr class="my-3">
+            <div class="pb-2 d-flex align-items-start">
+                <span class="min-width-140px text-secondary text-sm">Created</span>
+                <div>
+                    <span>@{{currentPrescription.created_at_friendly}}</span>
+                    @if(@$note)
+                        <div v-if="currentPrescription.note_id === {{$note->id}}" class="text-info mt-1 font-weight-bold">* Create on this note</div>
+                    @endif
+                </div>
+            </div>
+            @if(!request()->input('erx_category'))
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">Type</span>
+                <span>@{{currentPrescription.erx_category}}</span>
+            </div>
+            @endif
+            <div class="pb-2 d-flex align-items-baseline" v-if="currentPrescription.erx_category !== 'DRUG'">
+                <span class="min-width-140px text-secondary text-sm">Clinical</span>
+                <div class="d-inline-flex align-items-baseline flex-grow-1">
+                    <a v-if="!currentPrescription.has_hcp_pro_signed" class="mr-2" href="#" v-on:click.prevent="editClinicalDetails(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                    <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
+                    <div v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
+                        <div class="" v-if="currentPrescription.erx_category === 'DRUG'">
+                            <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
+                                <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{drug.frequency ?? ''}}</span>
+                            </div>
+                        </div>
+                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
+                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.test ?? '-'}}</b>
+                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.icds ?? '-'}}</span>
+                        </div>
+                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'REFERRAL'">
+                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.to ?? '-'}}</b>
+                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.memo ?? '-'}}</span>
+                        </div>
+                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'SUPPLY'">
+                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.item ?? '-'}}</b>
+                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.quantity ?? '-'}}</span>
+                        </div>
+                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'OTHER'">
+                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.title ?? '-'}}</b>
+                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.memo ?? '-'}}</span>
+                        </div>
+                    </div>
+                    <div v-else>-</div>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
+                <span class="min-width-140px text-secondary text-sm">Medications</span>
+                <div class="flex-grow-1">
+
+                    <div v-if="currentPrescription.clinical_detail_json">
+                        <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
+                            <a v-if="!currentPrescription.has_hcp_pro_signed" class="mr-2" href="#"
+                               v-on:click.prevent="removeDrugFromERx(drug.medication)">
+                                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                            </a>
+                            <div>
+                                <div class="d-flex align-items-baseline">
+                                    <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                    <span class="text-secondary ml-1">@{{drug.frequency ?? ''}}</span>
+                                </div>
+                                <div class="d-flex align-items-baseline">
+                                    <span class="text-secondary">Dispense:</span>
+                                    <span class="ml-1">@{{ drug.dispense ? drug.dispense : '-' }}</span>
+                                    <span class="text-secondary ml-2">Refills:</span>
+                                    <span class="ml-1">@{{ drug.refills ? drug.refills : '-' }}</span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="d-flex align-items-baseline" v-if="!currentPrescription.has_hcp_pro_signed">
+                        <a href="#" v-on:click.prevent="setAddMode('existing')">+ Existing Medication</a>
+                        <span class="mx-2">|</span>
+                        <a href="#" v-on:click.prevent="setAddMode('new')">+ New Medication</a>
+                    </div>
+                </div>
+            </div>
+
+            <div v-if="addDrugToErxMode === 'existing'" class="border border-info p-2 bg-aliceblue mb-2 rounded">
+                <div class="d-flex align-items-baseline mb-2">
+                    <label for="" class="text-secondary font-weight-bold m-0">Add From Existing Medications</label>
+                    <a href="#" v-on:click.prevent="setAddMode('')" class="ml-auto">Close</a>
+                </div>
+                <table class="m-0 table table-sm border bg-white table-hover">
+                    <tr>
+                        <th>Medication</th>
+                        <th>Dispense</th>
+                        <th>Refills</th>
+                        <th>&nbsp;</th>
+                    </tr>
+                    <tr v-for="drug in existingDrugs" v-if="notAlreadyAdded(drug.data.name)">
+                        <td class="min-width-200px">@{{ drug.data.name }}</td>
+                        <td class="width-70px py-0 pr-0"><input type="text" class="form-control form-control-sm min-width-unset rounded-0 border-top-0 border-bottom-0 border-right-0 shadow-none" v-model="drug.data.dispense"></td>
+                        <td class="width-70px py-0 pl-0"><input type="text" class="form-control form-control-sm min-width-unset rounded-0 border-top-0 border-bottom-0 shadow-none" v-model="drug.data.refills"></td>
+                        <td class="text-right">
+                            <a href="#" v-on:click.prevent="addExistingDrugToERx(drug.uid)" class="text-nowrap">Add to eRx</a>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+
+            <div v-if="addDrugToErxMode === 'new'" class="border border-info p-2 bg-aliceblue mb-2 rounded">
+                <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication-and-add-to-erx">
+                    <input type="hidden" name="noteUid" value="{{$note->uid}}">
+                    <input type="hidden" name="category" value="MEDICATION">
+                    <input type="hidden" name="data">
+
+                    <input type="hidden" data-name="medId">
+                    <input type="hidden" data-name="routedMedId">
+                    <input type="hidden" data-name="routedDosageFormMedId">
+                    <input type="hidden" data-name="gcnSeqno">
+
+                    <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
+                    <input type="hidden" name="isRemoved" value="0">
+                    <input type="hidden" name="removalReasonCategory">
+                    <input type="hidden" name="isRemovedDueToEntryError" value="0">
+
+                    <div class="d-flex align-items-baseline mb-2">
+                        <label for="" class="text-secondary font-weight-bold m-0">Add New Medication</label>
+                        <a href="#" v-on:click.prevent="setAddMode('')" class="ml-auto">Close</a>
+                    </div>
+
+                    <div class="row mb-2">
+                        <div class="col-8 pr-0">
+                            <label class="text-sm text-secondary mb-0">Name</label>
+                            <input type="text" data-name="name" class="form-control form-control-sm" stag-suggest="" stag-suggest-bottom-left="" stag-suggest-ep="/fdb-med-suggest-v2/json" required="" stag-suggest-initialized="1"><div class="stag-suggestions-container position-relative"><div class="suggestions-outer stag-suggestions position-absolute d-none"></div></div>
+                        </div>
+                        <div class="col-4">
+                            <label class="text-sm text-secondary mb-0">Frequency</label>
+                            <input type="text" class="form-control form-control-sm min-width-unset" data-name="frequency" data-option-list="frequency-options" autocomplete="off">
+                            <div id="frequency-options" class="data-option-list">
+                                <div>Once a day</div>
+                                <div>Twice a day</div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-4 pr-0">
+                            <label class="text-sm text-secondary mb-0">Dispense</label>
+                            <input type="text" class="form-control form-control-sm" name="dispense" autocomplete="off">
+                        </div>
+                        <div class="col-4 pr-0">
+                            <label class="text-sm text-secondary mb-0">Refills</label>
+                            <input type="text" class="form-control form-control-sm" name="refills" autocomplete="off">
+                        </div>
+                    </div>
+
+                    <div class="d-flex align-items-center">
+                        <button type="submit" class="btn btn-sm btn-primary mr-2 my-1">Save &amp; Add to eRx</button>
+                    </div>
+                </form>
+            </div>
+
+            <hr class="my-3">
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">Logistics</span>
+                <div class="d-inline-flex align-items-baseline flex-grow-1">
+                    <a class="mr-2" href="#" v-on:click.prevent="editLogisticsDetails(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                    <div v-if="currentPrescription.logistics_detail_json" class="d-flex align-items-baseline">
+                        <div class="d-flex align-items-baseline">
+                            <b class="mr-2">@{{currentPrescription.logistics_detail_json.facilityName ?? '-'}}</b>
+                            <span class="text-secondary mr-1">@{{currentPrescription.logistics_detail_json.facilityCity ?? '-'}}</span>
+                            <span class="text-secondary mr-1">@{{currentPrescription.logistics_detail_json.facilityState ?? '-'}}</span>
+                        </div>
+                    </div>
+                    <div v-else>-</div>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">HCP Pro</span>
+                <div class="d-inline-flex align-items-baseline flex-grow-1">
+                    <a v-if="!currentPrescription.has_hcp_pro_signed" class="mr-2" href="#" v-on:click.prevent="editHcpPro(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                    <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
+                    <div>@{{currentPrescription.hcpProDisplayName}}</div>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">Sign</span>
+                <div v-if="currentPrescription.has_hcp_pro_signed" class="d-inline-flex align-items-baseline">
+                    <i class="text-secondary fa fa-check mr-1"></i>
+                    <span class="text-secondary">Signed</span>
+                </div>
+                <div v-else>
+                    <a v-if="currentPrescription.hcp_pro_id === {{$pro->id}}"
+                       href="#"
+                       v-on:click.prevent="signAsHcpPro(currentPrescription)">Sign</a>
+                    <span v-else>-</span>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">Pro Status</span>
+                <div class="d-inline-flex align-items-baseline">
+                    <a class="mr-2" href="#" v-on:click.prevent="editProStatus(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                    <div v-if="currentPrescription.pro_declared_status" class="d-flex align-items-baseline">
+                        @{{ sanitizeStatus(currentPrescription.pro_declared_status) }}
+                    </div>
+                    <div v-else>-</div>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">Client Status</span>
+                <div class="d-inline-flex align-items-baseline">
+                    <a class="mr-2" href="#" v-on:click.prevent="editClientStatus(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
+                    <div v-if="currentPrescription.client_declared_status" class="d-flex align-items-baseline">
+                        @{{ sanitizeStatus(currentPrescription.client_declared_status) }}
+                    </div>
+                    <div v-else>-</div>
+                </div>
+            </div>
+            <div class="pb-2 d-flex align-items-center">
+                <span class="min-width-140px text-secondary text-sm">PDF</span>
+                <div class="d-inline-flex align-items-baseline">
+                    <a class="pdf-viewer-trigger" native target="_blank"
+                       :href="'/prescription-download-as-pdf/' + currentPrescription.uid">View</a>
+                    <span class="mx-2 text-secondary">|</span>
+                    <a native target="_blank"
+                       :href="'/prescription-download-as-pdf/' + currentPrescription.uid">Download</a>
+                    <span class="mx-2 text-secondary">|</span>
+                    <a href="#" v-on:click.prevent="transmit(currentPrescription)">Transmit</a>
+                </div>
+            </div>
+        </div>
+    </div>
+    @include('app.patient.prescriptions-popup.drug-form')
+    @include('app.patient.prescriptions-popup.lab-form')
+    @include('app.patient.prescriptions-popup.imaging-form')
+    @include('app.patient.prescriptions-popup.referral-form')
+    @include('app.patient.prescriptions-popup.supply-form')
+    @include('app.patient.prescriptions-popup.other-form')
+    @include('app.patient.prescriptions-popup.logistics-form')
+    @include('app.patient.prescriptions-popup.hcp-pro-form')
+    @include('app.patient.prescriptions-popup.sign-as-hcp-form')
+    @include('app.patient.prescriptions-popup.pro-status-form')
+    @include('app.patient.prescriptions-popup.client-status-form')
+    @include('app.patient.prescriptions-popup.transmit-form')
+</div>
+<script>
+    (function() {
+
+        <?php
+        $prescriptions = $patient->prescriptions;
+        $currentPrescription = null;
+        foreach ($prescriptions as $prescription) {
+            if($prescription->clinical_detail_json) {
+                $prescription->clinical_detail_json = json_decode($prescription->clinical_detail_json);
+            }
+            if($prescription->logistics_detail_json) {
+                $prescription->logistics_detail_json = json_decode($prescription->logistics_detail_json);
+            }
+            $prescription->created_at_friendly = friendlier_date_time($prescription->created_at);
+            $prescription->created_at_friendly_short = friendlier_date_time($prescription->created_at, false);
+            $prescription->hcpProDisplayName = $prescription->hcpPro ? $prescription->hcpPro->displayName() : '-';
+            $prescription->hcpProUid = $prescription->hcpPro ? $prescription->hcpPro->uid : '';
+
+            if(!!@$currentErx && $currentErx->uid === $prescription->uid) {
+                $currentPrescription = $prescription;
+            }
+        }
+
+        if(!!request()->input('erx_category')) {
+            $prescriptions = $prescriptions->filter(function($_p) {
+                return $_p->erx_category === request()->input('erx_category');
+            });
+        }
+
+        $existingActiveDrugs = \App\Models\Point
+            ::where('client_id', $patient->id)
+            ->where('category', 'MEDICATION')
+            ->where('is_removed_due_to_entry_error', false)
+            ->where('is_removed', false)
+            ->orderBy('created_at')
+            ->get();
+        foreach ($existingActiveDrugs as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data);
+            }
+        }
+
+        ?>
+
+        function init() {
+
+            window.eRxAppPopup = new Vue({
+                el: '#prescriptions-popup-{{$patient->id}}',
+                delimiters: ['@{{', '}}'],
+                data: {
+
+                    prescriptions: <?= json_encode($prescriptions) ?>,
+
+                    currentPrescriptionAction: '',
+                    currentPrescriptionType: '',
+
+                    addDrugToErxMode: '',
+                    existingDrugs: <?= json_encode($existingActiveDrugs) ?>,
+                    existingDrugToAddUid: '',
+
+                    // selected
+                    currentPrescription:  <?= $currentPrescription ? json_encode($currentPrescription) : 'null' ?>,
+
+                    // for editing clinical details
+                    currentPrescription_DRUG: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'DRUG',
+                        clinicalDetailJson: {
+                            items: [
+                                {
+                                    medication: '',
+                                    frequency: '',
+                                    dispense: '',
+                                    refills: '',
+                                    purpose: ''
+                                }
+                            ]
+                        }
+                    },
+                    currentPrescription_LAB: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'LAB',
+                        clinicalDetailJson: {
+                            test: '',
+                            icds: '',
+                            memo: '',
+                        }
+                    },
+                    currentPrescription_IMAGING: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'IMAGING',
+                        clinicalDetailJson: {
+                            test: '',
+                            icds: '',
+                            memo: '',
+                        }
+                    },
+                    currentPrescription_REFERRAL: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'REFERRAL',
+                        clinicalDetailJson: {
+                            to: '',
+                            memo: '',
+                        }
+                    },
+                    currentPrescription_SUPPLY: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'SUPPLY',
+                        clinicalDetailJson: {
+                            item: '',
+                            quantity: '',
+                            memo: '',
+                        }
+                    },
+                    currentPrescription_OTHER: {
+                        noteUid: '{{ @$note ? $note->uid : '' }}',
+                        clientUid: '{{ $patient->uid }}',
+                        replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                        hcpProUid: '{{$pro->uid}}',
+                        erxCategory: 'OTHER',
+                        clinicalDetailJson: {
+                            title: '',
+                            memo: '',
+                        }
+                    },
+
+                    // for editing logistics - common
+                    currentPrescriptionLogistics: {
+                        uid: '',
+                        logisticsDetailJson: {
+                            facilityName: '',
+                            facilityCity: '',
+                            facilityState: '',
+                            facilityAddressMemo: '',
+                            facilityPhone: '',
+                            facilityFax: '',
+                            facilityZip: '',
+                        }
+                    },
+
+                    // for editing hcp, sign, pro status & client status - common
+                    currentPrescriptionHcpPro: {
+                        uid: '',
+                        newHcpProUid: '',
+                    },
+                    currentPrescriptionSign: {
+                        uid: '',
+                        declaredVersionNumber: '',
+                    },
+                    currentPrescriptionProStatus: {
+                        uid: '',
+                        status: '',
+                        memo: '',
+                    },
+                    currentPrescriptionClientStatus: {
+                        uid: '',
+                        status: '',
+                        memo: '',
+                    },
+                    currentPrescriptionTransmit: {
+                        uid: '',
+                        logistics: '',
+                        toWho: '',
+                        toEmail: '',
+                        toFaxNumber: '',
+                        toFaxNumberAttentionLine: '',
+                        toFaxNumberCoverSheetMemo: '',
+                        copyToPatient: false,
+                        copyToPatientFaxNumber: '',
+                        copyToPatientEmail: '',
+                    }
+                },
+                methods: {
+
+                    // new eRx (only for popup-list)
+                    newERx: function(_type) {
+                        let payload = {
+                            noteUid: '{{ @$note ? $note->uid : '' }}',
+                            clientUid: '{{$patient->uid}}',
+                            hcpProUid: '{{$pro->uid}}',
+                            erxCategory: _type
+                        };
+                        $.post('/api/erx/create', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                        return false;
+                    },
+
+                    // new/edit/save-clinical
+                    newPrescription: function(_type) {
+                        this.currentPrescriptionAction = 'ADD';
+                        this.currentPrescriptionType = _type;
+                        switch (_type) {
+                            case 'DRUG':
+                                this.currentPrescription_DRUG = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        items: [
+                                            {
+                                                medication: '',
+                                                frequency: '',
+                                                dispense: '',
+                                                refills: '',
+                                                purpose: ''
+                                            }
+                                        ]
+                                    }
+                                };
+                                break;
+                            case 'LAB':
+                            case 'IMAGING':
+                                this.currentPrescription_LAB = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        test: '',
+                                        icds: '',
+                                        memo: '',
+                                    }
+                                };
+                                break;
+                            case 'REFERRAL':
+                                this.currentPrescription_LAB = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        to: '',
+                                        memo: '',
+                                    }
+                                };
+                                break;
+                            case 'SUPPLY':
+                                this.currentPrescription_LAB = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        item: '',
+                                        quantity: '',
+                                        memo: '',
+                                    }
+                                };
+                                break;
+                            case 'OTHER':
+                                this.currentPrescription_LAB = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        title: '',
+                                        memo: '',
+                                    }
+                                };
+                                break;
+                        }
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-prescription-popup-' + this.currentPrescriptionType, true);
+                            if(_type === 'DRUG') {
+                                $('[stag-suggest][stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                initStagSuggest();
+                                this.initFdbMedSuggest();
+                            }
+                        });
+                    },
+                    editClinicalDetails: function(_prescription) {
+                        this.currentPrescriptionAction = 'EDIT_CLINICAL';
+                        this.currentPrescriptionType = _prescription.erx_category;
+                        this['currentPrescription_' + this.currentPrescriptionType] = {
+                            uid: _prescription.uid,
+                            clinicalDetailJson: JSON.parse(JSON.stringify(_prescription.clinical_detail_json))
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-prescription-popup-' + this.currentPrescriptionType, true);
+                            if(this.currentPrescriptionType === 'DRUG') {
+                                $('[stag-suggest][stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                initStagSuggest();
+                                this.initFdbMedSuggest();
+
+                                // re-populate drug fields
+                                /*console.log(this.currentPrescription_DRUG);
+                                let parentSegment = $('#prescriptions-popup-{{$patient->id}} [stag-popup-key="prescription-popup-DRUG"]>form').first();
+                                parentSegment.find('input.prescription-medication').val(this.currentPrescription_DRUG.clinicalDetailJson.medication);
+                                parentSegment.find('select.prescription-route')
+                                    .empty()
+                                    .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.route))
+                                    .val(1);
+                                parentSegment.find('select.prescription-dose')
+                                    .empty()
+                                    .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.dose))
+                                    .val(1);
+                                parentSegment.find('select.prescription-strength')
+                                    .empty()
+                                    .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.strength))
+                                    .val(1);*/
+                            }
+                        });
+                    },
+                    savePrescription: function() {
+                        let payload = JSON.parse(JSON.stringify(this['currentPrescription_' + this.currentPrescriptionType]));
+                        payload.clinicalDetailJson = JSON.stringify(payload.clinicalDetailJson);
+                        switch (this.currentPrescriptionAction) {
+                            case 'ADD':
+                                $.post('/api/erx/create', payload, _data => {
+                                    if(!hasResponseError(_data)) {
+                                        toastr.success('Prescription added');
+                                        closeStagPopup();
+                                        refreshDynamicStagPopup();
+                                    }
+                                }, 'json');
+                                break;
+                            case 'EDIT_CLINICAL':
+                                $.post('/api/erx/updateClinicalDetail', payload, _data => {
+                                    if(!hasResponseError(_data)) {
+                                        toastr.success('Prescription updated');
+                                        closeStagPopup();
+                                        refreshDynamicStagPopup();
+                                    }
+                                }, 'json');
+                                break;
+                        }
+                    },
+
+                    // edit logistics
+                    editLogisticsDetails: function(_prescription) {
+                        this.currentPrescriptionAction = 'EDIT_LOGISTICS';
+                        this.currentPrescriptionLogistics = {
+                            uid: _prescription.uid,
+                            logisticsDetailJson: _prescription.logistics_detail_json ? JSON.parse(JSON.stringify(_prescription.logistics_detail_json)) : {
+                                facilityName: '',
+                                facilityCity: '',
+                                facilityState: '',
+                                facilityAddressMemo: '',
+                                facilityPhone: '',
+                                facilityFax: '',
+                                facilityZip: '',
+                            }
+                        }
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-logistics-popup', true);
+                        });
+                    },
+                    saveLogistics: function() {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionLogistics));
+                        payload.logisticsDetailJson = JSON.stringify(payload.logisticsDetailJson);
+                        $.post('/api/erx/updateLogisticsDetail', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Logistics updated');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
+                    // edit hcp (ordering) pro
+                    editHcpPro: function(_prescription) {
+                        this.currentPrescriptionAction = 'EDIT_HCP_PRO';
+                        this.currentPrescriptionType = _prescription.erx_category;
+                        this.currentPrescriptionHcpPro = {
+                            uid: _prescription.uid,
+                            newHcpProUid: _prescription.hcpProUid
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-hcp-pro-popup', true);
+                            $('.erx-hcp-pro-select').removeAttr('pro-suggest-initialized');
+                            initProSuggest();
+                        });
+                    },
+                    saveHcpPro: function() {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionHcpPro));
+                        $.post('/api/erx/updateHcpPro', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('HCP Pro updated');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
+                    // sign
+                    signAsHcpPro: function(_prescription) {
+                        this.currentPrescriptionAction = 'SIGN_AS_HCP';
+                        this.currentPrescriptionType = _prescription.erx_category;
+                        this.currentPrescriptionSign = {
+                            uid: _prescription.uid,
+                            declaredVersionNumber: _prescription.version_number
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-sign-as-hcp-popup', true);
+                        });
+                    },
+                    saveSignAsHcpPro: function() {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionSign));
+                        $.post('/api/erx/signAsHcp', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Signed');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
+                    // edit pro status
+                    editProStatus: function(_prescription) {
+                        this.currentPrescriptionAction = 'EDIT_PRO_DECLARED_STATUS';
+                        this.currentPrescriptionType = _prescription.erx_category;
+                        this.currentPrescriptionProStatus = {
+                            uid: _prescription.uid,
+                            status: _prescription.pro_declared_status,
+                            memo: _prescription.pro_declared_status_memo,
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-pro-status-popup', true);
+                        });
+                    },
+                    saveProStatus: function() {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionProStatus));
+                        $.post('/api/erx/updateProDeclaredStatus', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Pro declared status updated');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
+                    // edit client status
+                    editClientStatus: function(_prescription) {
+                        this.currentPrescriptionAction = 'EDIT_CLIENT_DECLARED_STATUS';
+                        this.currentPrescriptionType = _prescription.erx_category;
+                        this.currentPrescriptionClientStatus = {
+                            uid: _prescription.uid,
+                            status: _prescription.client_declared_status,
+                            memo: _prescription.client_declared_status_memo,
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-client-status-popup', true);
+                        });
+                    },
+                    saveClientStatus: function() {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionClientStatus));
+                        $.post('/api/erx/updateClientDeclaredStatus', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Client declared status updated');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
+                    // sane display status
+                    sanitizeStatus: function(_s) {
+                        _s = _s.toLowerCase().replaceAll('_', ' ');
+                        _s = _s[0].toUpperCase() + _s.substr(1);
+                        return _s;
+                    },
+
+                    // transmit
+                    transmit: function(_prescription) {
+                        this.currentPrescriptionTransmit = {
+                            uid: _prescription.uid,
+                            toWho: _prescription.logistics_detail_json ? _prescription.logistics_detail_json.facilityName : '',
+                            toEmail: '',
+                            toFaxNumber: _prescription.logistics_detail_json ? _prescription.logistics_detail_json.facilityFax : '',
+                            toFaxNumberAttentionLine: '',
+                            toFaxNumberCoverSheetMemo: '',
+                            copyToPatient: false,
+                            copyToPatientFaxNumber: '{{$patient->cell_number}}',
+                            copyToPatientEmail: '{{$patient->email_address}}',
+                            _token: '{{csrf_token()}}'
+                        };
+                        Vue.nextTick(() => {
+                            showStagPopup('pp-transmit-popup');
+                            this.transmitModalPDFPreview();
+                        });
+                    },
+                    transmitModalPDFPreview: function() {
+
+                        let _loadedPDF = null, _numPages = 1, _page = 1;
+
+                        function _load(_url) {
+
+                            _loadedPDF = null;
+                            _numPages = 1;
+                            _page = 1;
+
+                            $('#transmit-pdf-preview>canvas').remove();
+
+                            let url = _url;
+                            let pdfjsLib = window['pdfjs-dist/build/pdf'];
+                            pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
+                            let loadingTask = pdfjsLib.getDocument(url);
+                            loadingTask.promise.then(function (pdf) {
+                                _numPages = pdf.numPages;
+                                _loadedPDF = pdf;
+                                _page = 1;
+                                _render();
+                            }, function (reason) {
+                                // reason.message;
+                            });
+                        }
+                        function _render() {
+
+                            _loadedPDF.getPage(_page).then(function (page) {
+
+                                // create canvas
+                                let canvasElement = $('<canvas/>')
+                                    .addClass('pdf-viewer-page pdf-preview-page')
+                                    .appendTo('#transmit-pdf-preview');
+
+                                let canvas = canvasElement[0];
+                                let viewport = page.getViewport({scale: 0.75});
+                                let context = canvas.getContext('2d');
+                                canvas.height = viewport.height;
+                                canvas.width = viewport.width;
+                                const $canvas = $(canvas);
+                                let renderContext = {
+                                    canvasContext: context,
+                                    viewport: viewport
+                                };
+                                let renderTask = page.render(renderContext);
+                                renderTask.promise.then(function () {
+                                    if(_page < _numPages) {
+                                        _page++;
+                                        _render();
+                                    }
+                                });
+                            });
+                        }
+
+                        _load('/prescription-download-as-pdf/' + this.currentPrescriptionTransmit.uid);
+                    },
+                    doTransmit: function (_item) {
+                        let payload = JSON.parse(JSON.stringify(this.currentPrescriptionTransmit));
+                        $.post('/prescription-transmit/' + payload.uid, payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Transmission initiated');
+                                closeStagPopup();
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                        closeStagPopup();
+                    },
+
+                    // cancel, etc.
+
+                    initFdbMedSuggest: function() {
+
+                        let self = this;
+
+                        let parentSegment = $('#prescriptions-popup-{{$patient->id}} [stag-popup-key="prescription-popup-DRUG"]>form').first();
+
+                        parentSegment.find('input.prescription-medication').off('stag-suggest-selected');
+                        parentSegment.find('input.prescription-medication').on('stag-suggest-selected', (_e, _input, _data) => {
+
+                            // _input is the textbox
+                            // _data is {med_name_id: "50567", text: "Children's Tylenol"}
+
+                            // set vue values
+                            // self.currentPrescription_DRUG.clinicalDetailJson.medication = _data.text;
+
+                        });
+                    },
+                    notAlreadyAdded: function(_name) {
+                        if(!this.currentPrescription ||
+                            !this.currentPrescription.clinical_detail_json ||
+                            !this.currentPrescription.clinical_detail_json.items) return true;
+                        for (let i = 0; i < this.currentPrescription.clinical_detail_json.items.length; i++) {
+                            if(this.currentPrescription.clinical_detail_json.items[i].medication === _name) {
+                                return false;
+                            }
+                        }
+                        return true;
+                    },
+                    addExistingDrugToERx: function(_uid) {
+                        if(!this.currentPrescription.clinical_detail_json) {
+                            this.currentPrescription.clinical_detail_json = {};
+                        }
+                        if(!this.currentPrescription.clinical_detail_json.items) {
+                            this.currentPrescription.clinical_detail_json.items = [];
+                        }
+                        let existing = this.existingDrugs.filter(_x => {
+                            return _x.uid === _uid;
+                        });
+                        if(!existing || !existing.length) return false;
+                        existing = existing[0];
+                        this.currentPrescription.clinical_detail_json.items.push({
+                            medication: existing.data.name,
+                            frequency: existing.data.frequency,
+                            dispense: existing.data.dispense,
+                            refills: existing.data.refills,
+                        });
+                        this.currentPrescription.clinical_detail_json.items = JSON.parse(JSON.stringify(this.currentPrescription.clinical_detail_json.items));
+                        let temp = this.currentPrescription;
+                        this.currentPrescription = null;
+                        this.currentPrescription = temp;
+                        this.setCurrentPrescription(temp);
+
+                        // save erx
+                        $.post('/api/erx/updateClinicalDetail', {
+                            uid: this.currentPrescription.uid,
+                            clinicalDetailJson: JSON.stringify(this.currentPrescription.clinical_detail_json)
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                // nothing to do
+                            }
+                        }, 'json');
+                    },
+                    removeDrugFromERx: function(_name) {
+                        this.currentPrescription.clinical_detail_json.items = this.currentPrescription.clinical_detail_json.items.filter(_x => {
+                            return _x.medication !== _name;
+                        });
+                        let temp = this.currentPrescription;
+                        this.currentPrescription = null;
+                        this.currentPrescription = temp;
+
+                        // save erx
+                        $.post('/api/erx/updateClinicalDetail', {
+                            uid: this.currentPrescription.uid,
+                            clinicalDetailJson: JSON.stringify(this.currentPrescription.clinical_detail_json)
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                // nothing to do
+                            }
+                        }, 'json');
+                    },
+                    setCurrentPrescription: function(_prescription) {
+                        this.currentPrescription = _prescription;
+                    },
+                    setAddMode: function(_mode) {
+                        let self = this;
+                        this.addDrugToErxMode = _mode;
+                        if(this.addDrugToErxMode === 'new') {
+                            Vue.nextTick(() => {
+
+                                let parentSegment = $('#prescriptions-popup-{{$patient->id}}');
+
+                                parentSegment.find('[stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                initStagSuggest();
+
+                                parentSegment.find('input[stag-suggest][data-name="name"]')
+                                    .off('stag-suggest-selected')
+                                    .on('stag-suggest-selected', (_e, _input, _data) => {
+                                        $(_input).closest('form').find('input[data-name="routedMedId"]').val(_data.routed_med_id);
+                                        $(_input).closest('form').find('input[data-name="routedDosageFormMedId"]').val(_data.routed_dosage_form_med_id);
+                                        $(_input).closest('form').find('input[data-name="gcnSeqno"]').val(_data.gcn_seqno);
+                                        $(_input).closest('form').find('input[data-name="medId"]').val(_data.medid);
+                                        return false;
+                                    });
+
+                                // bind events for add-new-med and add-to-erx in one shot
+                                parentSegment.find('#frm-add-medication-and-add-to-erx')
+                                    .off('submit')
+                                    .on('submit', function () {
+
+                                        let form = $(this);
+
+                                        if (!form[0].checkValidity()) {
+                                            form[0].reportValidity();
+                                            return false;
+                                        }
+
+                                        // add [data-name] values to payload
+                                        let dataField = form.find('[name="data"]').first();
+                                        let parsed = null;
+                                        if (dataField.val()) {
+                                            parsed = JSON.parse(dataField.val());
+                                        }
+                                        form.find('[data-name]').each(function () {
+                                            if (!parsed) parsed = {};
+
+                                            let keys = $(this).attr('data-name').split('->');
+                                            let currentNode = parsed;
+                                            for (let i = 0; i < keys.length; i++) {
+                                                if (i !== keys.length - 1) {
+                                                    if (typeof currentNode[keys[i]] === 'undefined') {
+                                                        currentNode[keys[i]] = {};
+                                                    }
+                                                    currentNode = currentNode[keys[i]];
+                                                } else {
+                                                    if ($(this).is(':checkbox')) {
+                                                        currentNode[keys[i]] = $(this).prop('checked');
+                                                    } else {
+                                                        currentNode[keys[i]] = $(this).val();
+                                                    }
+                                                }
+                                            }
+
+                                        });
+                                        if (parsed) {
+                                            dataField.val(JSON.stringify(parsed));
+                                        }
+
+                                        let newERxItem = {
+                                            medication: form.find('[data-name="name"]').val(),
+                                            frequency: form.find('[data-name="frequency"]').val(),
+                                            dispense: form.find('[name="dispense"]').val(),
+                                            refills: form.find('[name="refills"]').val(),
+                                        };
+
+                                        $.post(form.attr('action'), form.serialize(), _data => {
+                                            if (!hasResponseError(_data)) {
+                                                hideMask();
+                                                // refreshDynamicStagPopup();
+                                                // $('.visit-segment[data-segment-template-name="intake_medications"]').find('.refresh-segment').trigger('click');
+
+                                                if(!self.currentPrescription.clinical_detail_json) {
+                                                    self.currentPrescription.clinical_detail_json = {};
+                                                }
+                                                if(!self.currentPrescription.clinical_detail_json.items) {
+                                                    self.currentPrescription.clinical_detail_json.items = [];
+                                                }
+                                                self.currentPrescription.clinical_detail_json.items.push(newERxItem);
+                                                self.currentPrescription.clinical_detail_json.items = JSON.parse(JSON.stringify(self.currentPrescription.clinical_detail_json.items));
+                                                let temp = self.currentPrescription;
+                                                self.currentPrescription = null;
+                                                self.currentPrescription = temp;
+                                                self.setCurrentPrescription(temp);
+
+                                                // save erx
+                                                $.post('/api/erx/updateClinicalDetail', {
+                                                    uid: self.currentPrescription.uid,
+                                                    clinicalDetailJson: JSON.stringify(self.currentPrescription.clinical_detail_json)
+                                                }, _data => {
+                                                    if(!hasResponseError(_data)) {
+                                                        // nothing to do
+
+                                                        self.setAddMode('');
+                                                    }
+                                                }, 'json');
+
+                                            }
+                                        }, 'json');
+                                        return false;
+                                    });
+
+                            });
+                        }
+                    }
+                },
+                mounted: function() {
+                    let self = this;
+                    $(document).on('pro-changed', '.erx-hcp-pro-select', function() {
+                        self.currentPrescriptionHcpPro.newHcpProUid = this.value;
+                    });
+
+                    // auto select latest prescription (if no current is set)
+                    Vue.nextTick(() => {
+                        if(!this.currentPrescription) {
+                            for(let x in this.prescriptions) {
+                                this.setCurrentPrescription(this.prescriptions[x]);
+                                break;
+                            }
+                        }
+                    });
+                }
+            });
+
+        }
+        addMCInitializer('prescriptions-popup-{{$patient->id}}', init, '#prescriptions-popup-{{$patient->id}}')
+    }).call(window);
+</script>

+ 59 - 0
resources/views/app/patient/prescriptions-popup/logistics-form.blade.php

@@ -0,0 +1,59 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-logistics-popup">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Logistics</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Business Name</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityName">
+        </div>
+        <div class="row">
+            <div class="col-4 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">City</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityCity">
+                </div>
+            </div>
+            <div class="col-4 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">State</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityState">
+                </div>
+            </div>
+            <div class="col-4">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">ZIP</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityZip">
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-6 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Phone</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityPhone">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Fax</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityFax">
+                </div>
+            </div>
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="saveLogistics()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 25 - 0
resources/views/app/patient/prescriptions-popup/other-form.blade.php

@@ -0,0 +1,25 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-OTHER">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Other Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Title</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_OTHER.clinicalDetailJson.title">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_OTHER.clinicalDetailJson.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 89 - 0
resources/views/app/patient/prescriptions-popup/pdf/DRUG.blade.php

@@ -0,0 +1,89 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; "><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px; margin-bottom: 1rem;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <tr>
+            <td style="width: 70%">
+                <b>Patient Information</b>
+            </td>
+            <td style="">
+
+            </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 $clinical = json_decode($prescription->clinical_detail_json); ?>
+<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>{{ $clinical->medication }} {{ $clinical->strength }}
+                            @if($clinical->route)
+                                - {{ $clinical->route }}
+                            @endif
+                        </b>
+                    </p>
+                    <div style="">
+                        @if($clinical->frequency)
+                            <p style="margin: 0.5rem 0;">Frequency: {{ $clinical->frequency }}</p>
+                        @endif
+                        @if($clinical->dispense)
+                            <p style="margin: 0.5rem 0;">Dispense: {{ $clinical->dispense }}</p>
+                        @endif
+                        @if($clinical->refills)
+                            <p style="margin: 0.5rem 0;">Refills: {{ $clinical->refills }}</p>
+                        @endif
+                        @if($clinical->purpose)
+                            <p style="margin: 0.5rem 0;">Purpose: <b>{{ $clinical->purpose }}</b></p>
+                        @endif
+                    </div>
+                </div>
+            </td>
+        </tr>
+    </table>
+</section>
+

+ 203 - 0
resources/views/app/patient/prescriptions-popup/pdf/IMAGING.blade.php

@@ -0,0 +1,203 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Patient Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_line1}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">DoB:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->dob}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_city}} {{$patient->home_address_state}} {{$patient->home_address_zip}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Gender:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->sex}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Mobile Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->cell_number ? $patient->cell_number : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient ID:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->chart_number ? $patient->chart_number : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Home Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->phone_home ? $patient->phone_home : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">SSN:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->ssn ? $patient->ssn : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Work Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Billing Information</span>
+        &nbsp;&nbsp;&nbsp;&nbsp;
+        <span style="font-size: 16px; opacity: 0.5;">Bill to: Patient</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Guarantor Information</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Relationship:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Self</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Order Information</span>
+    </div>
+
+    <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Fasting:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
+                {{@$clinical->icds ?: ''}}
+            </td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Collect at Draw Site:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+
+</section>
+
+
+<hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+<div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+    <span style="font-size: 16px">Studies/Imaging</span>
+</div>
+
+<section style="font-size: 15px;">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <?php $testIndex = 1; ?>
+        <tr>
+            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                <span>{{$testIndex++}}. </span>
+            </td>
+            <td style="vertical-align: top">
+                <div style="padding-bottom: 0.3rem;">{{$clinical->test}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+            </td>
+        </tr>
+    </table>
+</section>
+

+ 203 - 0
resources/views/app/patient/prescriptions-popup/pdf/LAB.blade.php

@@ -0,0 +1,203 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Patient Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_line1}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">DoB:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->dob}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_city}} {{$patient->home_address_state}} {{$patient->home_address_zip}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Gender:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->sex}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Mobile Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->cell_number ? $patient->cell_number : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient ID:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->chart_number ? $patient->chart_number : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Home Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->phone_home ? $patient->phone_home : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">SSN:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->ssn ? $patient->ssn : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Work Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Billing Information</span>
+        &nbsp;&nbsp;&nbsp;&nbsp;
+        <span style="font-size: 16px; opacity: 0.5;">Bill to: Patient</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Guarantor Information</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Relationship:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Self</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Order Information</span>
+    </div>
+
+    <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Fasting:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
+                {{@$clinical->icds ?: ''}}
+            </td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Collect at Draw Site:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+
+</section>
+
+
+<hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+<div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+    <span style="font-size: 16px">Lab</span>
+</div>
+
+<section style="font-size: 15px;">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <?php $testIndex = 1; ?>
+        <tr>
+            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                <span>{{$testIndex++}}. </span>
+            </td>
+            <td style="vertical-align: top">
+                <div style="padding-bottom: 0.3rem;">{{$clinical->test}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+            </td>
+        </tr>
+    </table>
+</section>
+

+ 203 - 0
resources/views/app/patient/prescriptions-popup/pdf/OTHER.blade.php

@@ -0,0 +1,203 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Patient Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_line1}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">DoB:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->dob}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_city}} {{$patient->home_address_state}} {{$patient->home_address_zip}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Gender:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->sex}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Mobile Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->cell_number ? $patient->cell_number : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient ID:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->chart_number ? $patient->chart_number : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Home Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->phone_home ? $patient->phone_home : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">SSN:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->ssn ? $patient->ssn : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Work Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Billing Information</span>
+        &nbsp;&nbsp;&nbsp;&nbsp;
+        <span style="font-size: 16px; opacity: 0.5;">Bill to: Patient</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Guarantor Information</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Relationship:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Self</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Order Information</span>
+    </div>
+
+    <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Fasting:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
+                {{@$clinical->icds ?: ''}}
+            </td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Collect at Draw Site:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+
+</section>
+
+
+<hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+<div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+    <span style="font-size: 16px">Details</span>
+</div>
+
+<section style="font-size: 15px;">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <?php $testIndex = 1; ?>
+        <tr>
+            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                <span>{{$testIndex++}}. </span>
+            </td>
+            <td style="vertical-align: top">
+                <div style="padding-bottom: 0.3rem;">{{$clinical->title}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+            </td>
+        </tr>
+    </table>
+</section>
+

+ 203 - 0
resources/views/app/patient/prescriptions-popup/pdf/REFERRAL.blade.php

@@ -0,0 +1,203 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Patient Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_line1}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">DoB:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->dob}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_city}} {{$patient->home_address_state}} {{$patient->home_address_zip}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Gender:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->sex}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Mobile Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->cell_number ? $patient->cell_number : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient ID:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->chart_number ? $patient->chart_number : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Home Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->phone_home ? $patient->phone_home : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">SSN:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->ssn ? $patient->ssn : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Work Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Billing Information</span>
+        &nbsp;&nbsp;&nbsp;&nbsp;
+        <span style="font-size: 16px; opacity: 0.5;">Bill to: Patient</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Guarantor Information</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Relationship:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Self</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Order Information</span>
+    </div>
+
+    <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Fasting:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
+                {{@$clinical->icds ?: ''}}
+            </td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Collect at Draw Site:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+
+</section>
+
+
+<hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+<div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+    <span style="font-size: 16px">Referral Details</span>
+</div>
+
+<section style="font-size: 15px;">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <?php $testIndex = 1; ?>
+        <tr>
+            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                <span>{{$testIndex++}}. </span>
+            </td>
+            <td style="vertical-align: top">
+                <div style="padding-bottom: 0.3rem;">{{$clinical->to}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+            </td>
+        </tr>
+    </table>
+</section>
+

+ 203 - 0
resources/views/app/patient/prescriptions-popup/pdf/SUPPLY.blade.php

@@ -0,0 +1,203 @@
+<section style="padding-top: 0.1rem;">
+
+    <div style="margin: 0 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Specimen/Physician Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Order Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{date('Y-m-d h:i a')}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">NPI:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->hcp_npi}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Test Date:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Ordering Physician:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$prescription->hcpPro->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Practice Fax:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">202-935-1033</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75"><span style="font-size: 16px">Patient Information</span></div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_line1}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">DoB:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->dob}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->home_address_city}} {{$patient->home_address_state}} {{$patient->home_address_zip}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Gender:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->sex}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Mobile Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->cell_number ? $patient->cell_number : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Patient ID:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->chart_number ? $patient->chart_number : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Home Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->phone_home ? $patient->phone_home : '-'}}</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">SSN:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->ssn ? $patient->ssn : '-'}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Work Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Billing Information</span>
+        &nbsp;&nbsp;&nbsp;&nbsp;
+        <span style="font-size: 16px; opacity: 0.5;">Bill to: Patient</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Code:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Primary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Secondary Ins. Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Worker's Comp:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Policy #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Group #:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Emp/Group Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75;">Insured:</td>
+            <td style="padding-bottom: 0.25rem; width: 25%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Guarantor Information</span>
+    </div>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Name:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">{{$patient->displayName()}}</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Relationship:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Self</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Address:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Phone:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">City, State, ZIP:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">-</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+    <hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+    <div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+        <span style="font-size: 16px">Order Information</span>
+    </div>
+
+    <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; font-size: 14px;">
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Fasting:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
+                {{@$clinical->icds ?: ''}}
+            </td>
+        </tr>
+        <tr>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">Collect at Draw Site:</td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
+            <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;"></td>
+            <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;"></td>
+        </tr>
+    </table>
+
+
+</section>
+
+
+<hr style="margin: 1rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+
+<div style="margin: 1.25rem 0 1rem; font-weight: bold; opacity: 0.75">
+    <span style="font-size: 16px">Supply Details</span>
+</div>
+
+<section style="font-size: 15px;">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <?php $testIndex = 1; ?>
+        <tr>
+            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                <span>{{$testIndex++}}. </span>
+            </td>
+            <td style="vertical-align: top">
+                <div style="padding-bottom: 0.3rem;">{{$clinical->item}} <span style="padding-left: 15px;">{{$clinical->quantity}}</span><span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+            </td>
+        </tr>
+    </table>
+</section>
+

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 13 - 0
resources/views/app/patient/prescriptions-popup/pdf/pdf-preview-with-cover-sheet.blade.php


+ 85 - 0
resources/views/app/patient/prescriptions-popup/pdf/pdf-preview.blade.php

@@ -0,0 +1,85 @@
+<!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;
+    }
+    ?>
+    <title>{{$hcpCompany ? $hcpCompany->name : 'Prescription'}}</title>
+</head>
+<body>
+<div style="margin: 0; padding: 1rem; font-family: sans-serif">
+    <header style="padding: 0; border: 0; margin: 0 0 1rem;">
+        <div style="text-align: center">
+            <h3 style="margin-bottom: 1rem;">{{$hcpCompany ? $hcpCompany->name : 'Prescription'}}</h3>
+        </div>
+        <div style="margin-top: 1.5rem; font-size: 19px">{{ $prescription->hcpPro->name_prefix }} {{ $prescription->hcpPro->name_first }} {{ $prescription->hcpPro->name_last }} <span style="font-size: 13px; opacity: 0.75">{{ $prescription->hcpPro->name_suffix }}</span></div>
+        <div style="display: block;">
+            <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+                <tr>
+                    <td style="width: 70%">
+                        @if($hcpCompanyLocation)
+                            <div style="font-size: 14px; margin-top: 0.6rem; line-height: 1.4; opacity: 0.6">
+                                {{$hcpCompanyLocation->line1}} {{$hcpCompanyLocation->line2}}<br>
+                                {{$hcpCompanyLocation->city}} {{$hcpCompanyLocation->state}} {{$hcpCompanyLocation->zip}}
+                            </div>
+                        @endif
+                    </td>
+                    <td style="">
+                        <div style="text-align: right; font-size: 14px; margin-top: 0.6rem; line-height: 1.4; opacity: 0.6">PH: 202-935-1033<br>FAX: 202-935-1033</div>
+                    </td>
+                </tr>
+            </table>
+        </div>
+    </header>
+    <hr style="border-top: 2px solid #5ca4e8; border-bottom: 0; margin: 1rem 0;">
+
+    <?php
+    use App\Models\Erx;
+    /** @var Erx $prescription */
+    $patient = $prescription->patient;
+    ?>
+
+    @include('app.patient.prescriptions-popup.pdf.' . $prescription->erx_category)
+
+    <?php if($prescription->logistics_detail_json): ?>
+        <?php $logistics = json_decode($prescription->logistics_detail_json); ?>
+        <hr style="margin: 0.5rem 0; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+        <p><b>Logistics Information</b>:</p>
+        <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; ?>
+
+    <hr style="margin: 1rem 0 0.5rem; border-top-width: 0; border-bottom-width: 1px; border-color: #bbb">
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <tr>
+            <td style="vertical-align: middle; white-space: nowrap; width: 100px;">
+                Authorizing Signature: Digital Signature Capture at <?= friendlier_date_time($prescription->created_at) ?>
+            </td>
+            <td style="vertical-align: middle;">
+                @if($prescription->hcpPro->signature_base_64)
+                    <img src="{{$prescription->hcpPro->signature_base_64}}" style="max-width: 180px;">
+                @endif
+            </td>
+        </tr>
+    </table>
+</div>
+</body>
+</html>
+

+ 32 - 0
resources/views/app/patient/prescriptions-popup/pro-status-form.blade.php

@@ -0,0 +1,32 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1 min-height-unset" stag-popup-key="pp-pro-status-popup">
+    <form method="POST" action="" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span>Pro Declared Status</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Status</label>
+            <select class="form-control form-control-sm min-width-unset erx-hcp-pro-select"
+                    v-model="currentPrescriptionProStatus.status">
+                <option value="">-- select --</option>
+                <option value="CREATED">Created</option>
+                <option value="SENT">Sent</option>
+                <option value="RECEIVED_BY_CLIENT">Received by client</option>
+                <option value="RECEIPT_CONFIRMED_BY_FACILITY">Receipt confirmed by facility</option>
+                <option value="CANCELLED">Cancelled</option>
+            </select>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescriptionProStatus.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="saveProStatus()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 25 - 0
resources/views/app/patient/prescriptions-popup/referral-form.blade.php

@@ -0,0 +1,25 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-REFERRAL">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Referral Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Refer To</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_REFERRAL.clinicalDetailJson.to">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_REFERRAL.clinicalDetailJson.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 16 - 0
resources/views/app/patient/prescriptions-popup/sign-as-hcp-form.blade.php

@@ -0,0 +1,16 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1 min-height-unset" stag-popup-key="pp-sign-as-hcp-popup">
+    <form method="POST" action="" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span>Sign as HCP Pro</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <p>Sign as HCP Pro?</p>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-success mr-2" v-on:click.prevent="saveSignAsHcpPro()">Sign
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 34 - 0
resources/views/app/patient/prescriptions-popup/supply-form.blade.php

@@ -0,0 +1,34 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-SUPPLY">
+    <form method="POST" action="">
+        <h3 class="stag-popup-title mb-2">
+            <span>Supply Prescription</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <div class="mb-2">
+            <div class="row">
+                <div class="col-8 pr-0">
+                    <label class="text-sm text-secondary mb-1">Item</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_SUPPLY.clinicalDetailJson.item">
+                </div>
+                <div class="col-4">
+                    <label class="text-sm text-secondary mb-1">Quanitity</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_SUPPLY.clinicalDetailJson.quantity">
+                </div>
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo</label>
+            <input type="text" class="form-control form-control-sm min-width-unset"
+                   v-model="currentPrescription_SUPPLY.clinicalDetailJson.memo">
+        </div>
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="savePrescription()">Submit
+            </button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel
+            </button>
+        </div>
+    </form>
+</div>

+ 66 - 0
resources/views/app/patient/prescriptions-popup/transmit-form.blade.php

@@ -0,0 +1,66 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-transmit-popup">
+    <form method="POST" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span><i class="fa fa-fax text-secondary font-size-13"></i> Transmit via Fax or Secure Email</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times"></i></a>
+        </h3>
+        <div class="mb-3 pb-3 border-bottom">
+            <p class="text-secondary text-sm mb-2 text-center">Document Preview</p>
+            <div id="transmit-pdf-preview">
+
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">To</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toWho" class="form-control">
+        </div>
+        <div class="row mb-2">
+            <div class="col-6 pr-0">
+                <div class="">
+                    <label class=" mb-1">Email</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.toEmail" class="form-control">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="">
+                    <label class=" mb-1">Fax Number</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.toFaxNumber" class="form-control">
+                </div>
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">Fax Attention Line</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toFaxNumberAttentionLine" class="form-control">
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">Fax Cover Sheet Memo</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toFaxNumberCoverSheetMemo" class="form-control">
+        </div>
+        <div class="mb-2 pt-2">
+            <label class=" mb-1 d-inline-flex align-items-baseline">
+                <input type="checkbox" v-model="currentPrescriptionTransmit.copyToPatient" class="mr-2">
+                Transmit Copy to Patient
+            </label>
+        </div>
+        <div class="row mb-2" v-show="currentPrescriptionTransmit.copyToPatient">
+            <div class="col-6 pr-0">
+                <div class="">
+                    <label class=" mb-1">Patient Email</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.copyToPatientEmail" class="form-control">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="">
+                    <label class=" mb-1">Patient Fax Number</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.copyToPatientFaxNumber" class="form-control">
+                </div>
+            </div>
+        </div>
+
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="doTransmit()">Submit</button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel</button>
+        </div>
+    </form>
+</div>

+ 25 - 6
resources/views/app/patient/prescriptions/imaging-form.blade.php

@@ -6,14 +6,33 @@
                onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
         </h3>
         <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">Test</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
-                   v-model="currentPrescription_IMAGING.clinicalDetailJson.test">
+            <div class="d-flex align-items-baseline">
+                <label class="text-sm text-secondary mb-0">Tests</label>
+                <span class="mx-2 text-secondary text-sm"></span>
+                <a href="#" class="text-sm" v-on:click.prevent="currentPrescription_IMAGING.clinicalDetailJson.tests.push('')">+ Add</a>
+            </div>
+            <div v-for="(test, testIndex) in currentPrescription_IMAGING.clinicalDetailJson.tests">
+                <input type="text" class="form-control form-control-sm min-width-unset mb-1"
+                       v-model="currentPrescription_IMAGING.clinicalDetailJson.tests[testIndex]">
+            </div>
         </div>
         <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">ICDS</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
-                   v-model="currentPrescription_IMAGING.clinicalDetailJson.icds">
+            <div class="d-flex align-items-baseline">
+                <label class="text-sm text-secondary mb-0">ICDs</label>
+                <span class="mx-2 text-secondary text-sm"></span>
+                <a href="#" class="text-sm" v-on:click.prevent="addICD('IMAGING')">+ Add</a>
+            </div>
+            <div v-for="(icd, icdIndex) in currentPrescription_IMAGING.clinicalDetailJson.icds" class="d-flex align-items-center">
+                <input type="text" class="form-control form-control-sm min-width-unset mb-1 flex-grow-1"
+                       data-field="icd" :data-index="icdIndex" data-category="IMAGING"
+                       v-model="currentPrescription_IMAGING.clinicalDetailJson.icds[icdIndex]">
+                <a v-if="icdIndex>0"
+                   href="#"
+                   class="px-2"
+                   v-on:click.prevent="currentPrescription_IMAGING.clinicalDetailJson.icds.splice(icdIndex, 1)">
+                    <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                </a>
+            </div>
         </div>
         <div class="mb-2">
             <label class="text-sm text-secondary mb-1">Memo</label>

+ 5 - 0
resources/views/app/patient/prescriptions/index-popup.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    @include('app.patient.prescriptions.list-popup')
+@endsection

+ 25 - 6
resources/views/app/patient/prescriptions/lab-form.blade.php

@@ -6,14 +6,33 @@
                onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
         </h3>
         <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">Test</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
-                   v-model="currentPrescription_LAB.clinicalDetailJson.test">
+            <div class="d-flex align-items-baseline">
+                <label class="text-sm text-secondary mb-0">Tests</label>
+                <span class="mx-2 text-secondary text-sm"></span>
+                <a href="#" class="text-sm" v-on:click.prevent="currentPrescription_LAB.clinicalDetailJson.tests.push('')">+ Add</a>
+            </div>
+            <div v-for="(test, testIndex) in currentPrescription_LAB.clinicalDetailJson.tests">
+                <input type="text" class="form-control form-control-sm min-width-unset mb-1"
+                       v-model="currentPrescription_LAB.clinicalDetailJson.tests[testIndex]">
+            </div>
         </div>
         <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">ICDS</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
-                   v-model="currentPrescription_LAB.clinicalDetailJson.icds">
+            <div class="d-flex align-items-baseline">
+                <label class="text-sm text-secondary mb-0">ICDs</label>
+                <span class="mx-2 text-secondary text-sm"></span>
+                <a href="#" class="text-sm" v-on:click.prevent="addICD('LAB')">+ Add</a>
+            </div>
+            <div v-for="(icd, icdIndex) in currentPrescription_LAB.clinicalDetailJson.icds" class="d-flex align-items-center">
+                <input type="text" class="form-control form-control-sm min-width-unset mb-1 flex-grow-1"
+                       data-field="icd" :data-index="icdIndex" data-category="LAB"
+                       v-model="currentPrescription_LAB.clinicalDetailJson.icds[icdIndex]">
+                <a v-if="icdIndex>0"
+                   href="#"
+                   class="px-2"
+                   v-on:click.prevent="currentPrescription_LAB.clinicalDetailJson.icds.splice(icdIndex, 1)">
+                    <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                </a>
+            </div>
         </div>
         <div class="mb-2">
             <label class="text-sm text-secondary mb-1">Memo</label>

+ 457 - 96
resources/views/app/patient/prescriptions/list.blade.php

@@ -1,28 +1,42 @@
 <div id="prescriptions-{{$patient->id}}" v-cloak>
     <div class="d-flex align-items-baseline py-2">
-        <h6 class="my-0 font-weight-bold text-secondary font-size-14">Prescriptions</h6>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('DRUG')">+ Drug</a>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('LAB')">+ Lab</a>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('IMAGING')">+ Imaging</a>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('REFERRAL')">+ Referral</a>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('SUPPLY')">+ Supply</a>
-        <span class="mx-2 text-secondary on-hover-opaque">|</span>
-        <a href="#" v-on:click.prevent="newPrescription('OTHER')">+ Other</a>
+        <h6 class="my-0 font-weight-bold text-secondary font-size-14">ERx &amp; Orders</h6>
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'DRUG')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('DRUG')">+ Drug</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'LAB')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('LAB')">+ Lab</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'IMAGING')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('IMAGING')">+ Imaging</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'REFERRAL')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('REFERRAL')">+ Referral</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'SUPPLY')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('SUPPLY')">+ Supply</a>
+        @endif
+        @if(!request()->input('erx_category') || request()->input('erx_category') === 'OTHER')
+            <span class="mx-2 text-secondary on-hover-opaque">|</span>
+            <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
+        @endif
     </div>
     <div class="d-flex align-items-start">
         <table class="table table-striped table-sm table-bordered mb-0 flex-grow-1">
             <thead>
             <tr>
                 <th class="px-2 text-secondary border-bottom-0">Created</th>
-                <th class="px-2 text-secondary border-bottom-0">Type</th>
-                <th class="px-2 text-secondary border-bottom-0">Clinical</th>
+                @if(!request()->input('erx_category'))
+                    <th class="px-2 text-secondary border-bottom-0">Type</th>
+                @endif
+                <th class="px-2 text-secondary border-bottom-0 w-50">Clinical</th>
                 <th class="px-2 text-secondary border-bottom-0">Prescriber</th>
-                <th class="px-2 text-secondary border-bottom-0">Sign</th>
+                <th class="px-2 text-secondary border-bottom-0" v-if="!currentPrescription">Sign</th>
             </tr>
             </thead>
             <tbody>
@@ -34,7 +48,9 @@
                         <div v-if="prescription.note_id === {{$note->id}}" class="text-info mt-1">* Create on this note</div>
                     @endif
                 </td>
+                @if(!request()->input('erx_category'))
                 <td class="px-2">@{{prescription.erx_category}}</td>
+                @endif
                 <td class="px-2">
                     <div class="d-flex align-items-baseline">
                         {{--
@@ -42,13 +58,16 @@
                         <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
                         --}}
                         <div v-if="prescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
-                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'DRUG'">
-                                <b class="mr-2">@{{prescription.clinical_detail_json.medication ?? '-'}}</b>
-                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.frequency ?? ''}}</span>
+                            <div class="" v-if="prescription.erx_category === 'DRUG'">
+                                <div class="d-flex align-items-baseline mb-1" v-for="drug in prescription.clinical_detail_json.items">
+                                    <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                    <span class="text-secondary mr-1">@{{drug.frequency ?? ''}}</span>
+                                </div>
                             </div>
                             <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
-                                <b class="mr-2">@{{prescription.clinical_detail_json.test ?? '-'}}</b>
-                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.icds ?? '-'}}</span>
+                                <div class="d-flex align-items-baseline mb-1" v-for="test in prescription.clinical_detail_json.tests">
+                                    <b class="mr-2">@{{test ?? '-'}}</b>
+                                </div>
                             </div>
                             <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'REFERRAL'">
                                 <b class="mr-2">@{{prescription.clinical_detail_json.to ?? '-'}}</b>
@@ -75,7 +94,7 @@
                         <div>@{{prescription.hcpProDisplayName}}</div>
                     </div>
                 </td>
-                <td class="px-2">
+                <td class="px-2" v-if="!currentPrescription">
                     <div v-if="prescription.has_hcp_pro_signed" class="d-flex align-items-baseline">
                         <i class="text-secondary fa fa-check mr-1"></i>
                         <span class="text-secondary">Signed</span>
@@ -92,34 +111,10 @@
             </tr>
             </tbody>
         </table>
-        <div v-if="currentPrescription" class="min-width-500px ml-2 border align-self-stretch p-3">
+        <div v-if="currentPrescription" class="min-width-700px ml-2 border align-self-stretch p-3">
             <div class="d-flex align-items-center">
                 <h3 class="font-size-16 m-0">
-                    <div v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
-                            <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.medication ?? '-'}}</b>
-                            <!--<span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.amount ?? '-'}}</span>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.route ?? '-'}}</span>-->
-                        </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
-                            <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.test ?? '-'}}</b>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.icds ?? '-'}}</span>
-                        </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'REFERRAL'">
-                            <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.to ?? '-'}}</b>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.memo ?? '-'}}</span>
-                        </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'SUPPLY'">
-                            <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.item ?? '-'}}</b>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.quantity ?? '-'}}</span>
-                        </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'OTHER'">
-                            <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.title ?? '-'}}</b>
-                            <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.memo ?? '-'}}</span>
-                        </div>
-                    </div>
-                    <div v-else>-</div>
+                    <span class="mr-1 font-size-16">@{{ currentPrescription.erx_category }} / @{{ currentPrescription.created_at_friendly_short }}</span>
                 </h3>
                 <a class="ml-auto" href="#" v-on:click.prevent="currentPrescription=null">
                     <i class="fa fa-times-circle on-hover-opaque"></i>
@@ -135,25 +130,28 @@
                     @endif
                 </div>
             </div>
+            @if(!request()->input('erx_category'))
             <div class="pb-2 d-flex align-items-center">
                 <span class="min-width-140px text-secondary text-sm">Type</span>
                 <span>@{{currentPrescription.erx_category}}</span>
             </div>
-            <div class="pb-2 d-flex align-items-center">
+            @endif
+            <div class="pb-2 d-flex align-items-baseline" v-if="currentPrescription.erx_category !== 'DRUG'">
                 <span class="min-width-140px text-secondary text-sm">Clinical</span>
                 <div class="d-inline-flex align-items-baseline flex-grow-1">
                     <a v-if="!currentPrescription.has_hcp_pro_signed" class="mr-2" href="#" v-on:click.prevent="editClinicalDetails(currentPrescription)"><i class="fa fa-edit on-hover-opaque"></i></a>
                     <span v-else class="mr-2" title="Cannot edit. Prescription already signed."><i class="fa fa-edit on-hover-opaque text-secondary"></i></span>
                     <div v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
-                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.medication ?? '-'}}</b>
-                            <!--<span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
-                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.dispense ?? '-'}}</span>
-                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.refills ?? '-'}}</span>-->
+                        <div class="" v-if="currentPrescription.erx_category === 'DRUG'">
+                            <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
+                                <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                <span class="text-secondary mr-1">@{{drug.frequency ?? ''}}</span>
+                            </div>
                         </div>
                         <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
-                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.test ?? '-'}}</b>
-                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.icds ?? '-'}}</span>
+                            <div class="d-flex align-items-baseline mb-1" v-for="test in currentPrescription.clinical_detail_json.tests">
+                                <b class="mr-2">@{{test ?? '-'}}</b>
+                            </div>
                         </div>
                         <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'REFERRAL'">
                             <b class="mr-2">@{{currentPrescription.clinical_detail_json.to ?? '-'}}</b>
@@ -171,6 +169,119 @@
                     <div v-else>-</div>
                 </div>
             </div>
+            <div class="pb-2 d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
+                <span class="min-width-140px text-secondary text-sm">Medications</span>
+                <div class="flex-grow-1">
+
+                    <div v-if="currentPrescription.clinical_detail_json">
+                        <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
+                            <a v-if="!currentPrescription.has_hcp_pro_signed" class="mr-2" href="#"
+                               v-on:click.prevent="removeDrugFromERx(drug.medication)">
+                                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                            </a>
+                            <div>
+                                <div class="d-flex align-items-baseline">
+                                    <b class="mr-2">@{{drug.medication ?? '-'}}</b>
+                                    <span class="text-secondary ml-1">@{{drug.frequency ?? ''}}</span>
+                                </div>
+                                <div class="d-flex align-items-baseline">
+                                    <span class="text-secondary">Dispense:</span>
+                                    <span class="ml-1">@{{ drug.dispense ? drug.dispense : '-' }}</span>
+                                    <span class="text-secondary ml-2">Refills:</span>
+                                    <span class="ml-1">@{{ drug.refills ? drug.refills : '-' }}</span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    @if(@$note)
+                    <div class="d-flex align-items-baseline" v-if="!currentPrescription.has_hcp_pro_signed">
+                        <a href="#" v-on:click.prevent="setAddMode('existing')">+ Existing Medication</a>
+                        <span class="mx-2">|</span>
+                        <a href="#" v-on:click.prevent="setAddMode('new')">+ New Medication</a>
+                    </div>
+                    @endif
+                </div>
+            </div>
+
+            @if(@$note)
+            <div v-if="addDrugToErxMode === 'existing'" class="border border-info p-2 bg-aliceblue mb-2 rounded">
+                <div class="d-flex align-items-baseline mb-2">
+                    <label for="" class="text-secondary font-weight-bold m-0">Add From Existing Medications</label>
+                    <a href="#" v-on:click.prevent="setAddMode('')" class="ml-auto">Close</a>
+                </div>
+                <table class="m-0 table table-sm border bg-white table-hover">
+                    <tr>
+                        <th>Medication</th>
+                        <th>Dispense</th>
+                        <th>Refills</th>
+                        <th>&nbsp;</th>
+                    </tr>
+                    <tr v-for="drug in existingDrugs" v-if="notAlreadyAdded(drug.data.name)">
+                        <td class="min-width-200px">@{{ drug.data.name }}</td>
+                        <td class="width-70px py-0 pr-0"><input type="text" class="form-control form-control-sm min-width-unset rounded-0 border-top-0 border-bottom-0 border-right-0 shadow-none" v-model="drug.data.dispense"></td>
+                        <td class="width-70px py-0 pl-0"><input type="text" class="form-control form-control-sm min-width-unset rounded-0 border-top-0 border-bottom-0 shadow-none" v-model="drug.data.refills"></td>
+                        <td class="text-right">
+                            <a href="#" v-on:click.prevent="addExistingDrugToERx(drug.uid)" class="text-nowrap">Add to eRx</a>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+
+            <div v-if="addDrugToErxMode === 'new'" class="border border-info p-2 bg-aliceblue mb-2 rounded">
+                <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication-and-add-to-erx">
+                    <input type="hidden" name="noteUid" value="{{$note->uid}}">
+                    <input type="hidden" name="category" value="MEDICATION">
+                    <input type="hidden" name="data">
+
+                    <input type="hidden" data-name="medId">
+                    <input type="hidden" data-name="routedMedId">
+                    <input type="hidden" data-name="routedDosageFormMedId">
+                    <input type="hidden" data-name="gcnSeqno">
+
+                    <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
+                    <input type="hidden" name="isRemoved" value="0">
+                    <input type="hidden" name="removalReasonCategory">
+                    <input type="hidden" name="isRemovedDueToEntryError" value="0">
+
+                    <div class="d-flex align-items-baseline mb-2">
+                        <label for="" class="text-secondary font-weight-bold m-0">Add New Medication</label>
+                        <a href="#" v-on:click.prevent="setAddMode('')" class="ml-auto">Close</a>
+                    </div>
+
+                    <div class="row mb-2">
+                        <div class="col-8 pr-0">
+                            <label class="text-sm text-secondary mb-0">Name</label>
+                            <input type="text" data-name="name" class="form-control form-control-sm" stag-suggest="" stag-suggest-bottom-left="" stag-suggest-ep="/fdb-med-suggest-v2/json" required="" stag-suggest-initialized="1"><div class="stag-suggestions-container position-relative"><div class="suggestions-outer stag-suggestions position-absolute d-none"></div></div>
+                        </div>
+                        <div class="col-4">
+                            <label class="text-sm text-secondary mb-0">Frequency</label>
+                            <input type="text" class="form-control form-control-sm min-width-unset" data-name="frequency" data-option-list="frequency-options" autocomplete="off">
+                            <div id="frequency-options" class="data-option-list">
+                                <div>Once a day</div>
+                                <div>Twice a day</div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-4 pr-0">
+                            <label class="text-sm text-secondary mb-0">Dispense</label>
+                            <input type="text" class="form-control form-control-sm" name="dispense" autocomplete="off">
+                        </div>
+                        <div class="col-4 pr-0">
+                            <label class="text-sm text-secondary mb-0">Refills</label>
+                            <input type="text" class="form-control form-control-sm" name="refills" autocomplete="off">
+                        </div>
+                    </div>
+
+                    <div class="d-flex align-items-center">
+                        <button type="submit" class="btn btn-sm btn-primary mr-2 my-1">Save &amp; Add to eRx</button>
+                    </div>
+                </form>
+            </div>
+            @endif
+
+            <hr class="my-3">
             <div class="pb-2 d-flex align-items-center">
                 <span class="min-width-140px text-secondary text-sm">Logistics</span>
                 <div class="d-inline-flex align-items-baseline flex-grow-1">
@@ -275,11 +386,31 @@
                 $currentPrescription = $prescription;
             }
         }
+
+        if(!!request()->input('erx_category')) {
+            $prescriptions = $prescriptions->filter(function($_p) {
+                return $_p->erx_category === request()->input('erx_category');
+            });
+        }
+
+        $existingActiveDrugs = \App\Models\Point
+            ::where('client_id', $patient->id)
+            ->where('category', 'MEDICATION')
+            ->where('is_removed_due_to_entry_error', false)
+            ->where('is_removed', false)
+            ->orderBy('created_at')
+            ->get();
+        foreach ($existingActiveDrugs as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data);
+            }
+        }
+
         ?>
 
         function init() {
 
-            new Vue({
+            window.eRxApp = new Vue({
                 el: '#prescriptions-{{$patient->id}}',
                 delimiters: ['@{{', '}}'],
                 data: {
@@ -289,6 +420,10 @@
                     currentPrescriptionAction: '',
                     currentPrescriptionType: '',
 
+                    addDrugToErxMode: '',
+                    existingDrugs: <?= json_encode($existingActiveDrugs) ?>,
+                    existingDrugToAddUid: '',
+
                     // selected
                     currentPrescription:  <?= $currentPrescription ? json_encode($currentPrescription) : 'null' ?>,
 
@@ -300,21 +435,15 @@
                         hcpProUid: '{{$pro->uid}}',
                         erxCategory: 'DRUG',
                         clinicalDetailJson: {
-                            medication: '',
-                            route: '',
-                            dose: '',
-                            strength: '',
-                            frequency: '',
-                            dispense: '',
-                            refills: '',
-                            purpose: '',
-
-                            // fdb specific
-                            medNameID: '',
-                            routedMedID: '',
-                            dosageFormMedID: '',
-                            gcnSeqno: '',
-                            medId: '',
+                            items: [
+                                {
+                                    medication: '',
+                                    frequency: '',
+                                    dispense: '',
+                                    refills: '',
+                                    purpose: ''
+                                }
+                            ]
                         }
                     },
                     currentPrescription_LAB: {
@@ -424,6 +553,22 @@
                 },
                 methods: {
 
+                    // new eRx (only for popup-list)
+                    newERx: function(_type) {
+                        let payload = {
+                            noteUid: '{{ @$note ? $note->uid : '' }}',
+                            clientUid: '{{$patient->uid}}',
+                            hcpProUid: '{{$pro->uid}}',
+                            erxCategory: _type
+                        };
+                        $.post('/api/erx/create', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                fastReload();
+                            }
+                        }, 'json');
+                        return false;
+                    },
+
                     // new/edit/save-clinical
                     newPrescription: function(_type) {
                         this.currentPrescriptionAction = 'ADD';
@@ -437,21 +582,15 @@
                                     hcpProUid: '{{$pro->uid}}',
                                     erxCategory: _type,
                                     clinicalDetailJson: {
-                                        medication: '',
-                                        route: '',
-                                        dose: '',
-                                        strength: '',
-                                        frequency: '',
-                                        dispense: '',
-                                        refills: '',
-                                        purpose: '',
-
-                                        // fdb specific
-                                        medNameID: '',
-                                        routedMedID: '',
-                                        dosageFormMedID: '',
-                                        gcnSeqno: '',
-                                        medId: '',
+                                        items: [
+                                            {
+                                                medication: '',
+                                                frequency: '',
+                                                dispense: '',
+                                                refills: '',
+                                                purpose: ''
+                                            }
+                                        ]
                                     }
                                 };
                                 break;
@@ -525,7 +664,12 @@
                         this.currentPrescriptionType = _prescription.erx_category;
                         this['currentPrescription_' + this.currentPrescriptionType] = {
                             uid: _prescription.uid,
-                            clinicalDetailJson: JSON.parse(JSON.stringify(_prescription.clinical_detail_json))
+                            clinicalDetailJson: _prescription.clinical_detail_json ?
+                                JSON.parse(JSON.stringify(_prescription.clinical_detail_json)) :
+                                {
+                                    tests: [''],
+                                    icds: ['']
+                                }
                         };
                         Vue.nextTick(() => {
                             showStagPopup('prescription-popup-' + this.currentPrescriptionType, true);
@@ -535,7 +679,7 @@
                                 this.initFdbMedSuggest();
 
                                 // re-populate drug fields
-                                console.log(this.currentPrescription_DRUG);
+                                /*console.log(this.currentPrescription_DRUG);
                                 let parentSegment = $('#prescriptions-{{$patient->id}} [stag-popup-key="prescription-popup-DRUG"]>form').first();
                                 parentSegment.find('input.prescription-medication').val(this.currentPrescription_DRUG.clinicalDetailJson.medication);
                                 parentSegment.find('select.prescription-route')
@@ -549,7 +693,10 @@
                                 parentSegment.find('select.prescription-strength')
                                     .empty()
                                     .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.strength))
-                                    .val(1);
+                                    .val(1);*/
+                            }
+                            else if(this.currentPrescriptionType === 'LAB' || this.currentPrescriptionType === 'IMAGING') {
+                                this.initICDAutoSuggest();
                             }
                         });
                     },
@@ -562,11 +709,7 @@
                                     if(!hasResponseError(_data)) {
                                         toastr.success('Prescription added');
                                         closeStagPopup();
-                                        @if(@$note)
                                         fastReload();
-                                        @else
-                                        fastLoad('/patients/view/{{$patient->uid}}/prescriptions/' + this.currentPrescriptionType.toLowerCase() + '/' + _data.data);
-                                        @endif
                                     }
                                 }, 'json');
                                 break;
@@ -818,16 +961,234 @@
                             // _data is {med_name_id: "50567", text: "Children's Tylenol"}
 
                             // set vue values
-                            self.currentPrescription_DRUG.clinicalDetailJson.medication = _data.text;
+                            //self.currentPrescription_DRUG.clinicalDetailJson.medication = _data.text;
 
                         });
-                    }
+                    },
+                    notAlreadyAdded: function(_name) {
+                        if(!this.currentPrescription ||
+                            !this.currentPrescription.clinical_detail_json ||
+                            !this.currentPrescription.clinical_detail_json.items) return true;
+                        for (let i = 0; i < this.currentPrescription.clinical_detail_json.items.length; i++) {
+                            if(this.currentPrescription.clinical_detail_json.items[i].medication === _name) {
+                                return false;
+                            }
+                        }
+                        return true;
+                    },
+                    addExistingDrugToERx: function(_uid) {
+                        if(!this.currentPrescription.clinical_detail_json) {
+                            this.currentPrescription.clinical_detail_json = {};
+                        }
+                        if(!this.currentPrescription.clinical_detail_json.items) {
+                            this.currentPrescription.clinical_detail_json.items = [];
+                        }
+                        let existing = this.existingDrugs.filter(_x => {
+                            return _x.uid === _uid;
+                        });
+                        if(!existing || !existing.length) return false;
+                        existing = existing[0];
+                        this.currentPrescription.clinical_detail_json.items.push({
+                            medication: existing.data.name,
+                            frequency: existing.data.frequency,
+                            dispense: existing.data.dispense,
+                            refills: existing.data.refills,
+                        });
+                        this.currentPrescription.clinical_detail_json.items = JSON.parse(JSON.stringify(this.currentPrescription.clinical_detail_json.items));
+                        let temp = this.currentPrescription;
+                        this.currentPrescription = null;
+                        this.currentPrescription = temp;
+                        this.setCurrentPrescription(temp);
+
+                        // save erx
+                        $.post('/api/erx/updateClinicalDetail', {
+                            uid: this.currentPrescription.uid,
+                            clinicalDetailJson: JSON.stringify(this.currentPrescription.clinical_detail_json)
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                // nothing to do
+                            }
+                        }, 'json');
+                    },
+                    removeDrugFromERx: function(_name) {
+                        this.currentPrescription.clinical_detail_json.items = this.currentPrescription.clinical_detail_json.items.filter(_x => {
+                            return _x.medication !== _name;
+                        });
+                        let temp = this.currentPrescription;
+                        this.currentPrescription = null;
+                        this.currentPrescription = temp;
+
+                        // save erx
+                        $.post('/api/erx/updateClinicalDetail', {
+                            uid: this.currentPrescription.uid,
+                            clinicalDetailJson: JSON.stringify(this.currentPrescription.clinical_detail_json)
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                // nothing to do
+                            }
+                        }, 'json');
+                    },
+                    setCurrentPrescription: function(_prescription) {
+                        this.currentPrescription = _prescription;
+                    },
+                    setAddMode: function(_mode) {
+                        let self = this;
+                        this.addDrugToErxMode = _mode;
+                        if(this.addDrugToErxMode === 'new') {
+                            Vue.nextTick(() => {
+
+                                let parentSegment = $('#prescriptions-popup-{{$patient->id}}');
+
+                                parentSegment.find('[stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                initStagSuggest();
+
+                                parentSegment.find('input[stag-suggest][data-name="name"]')
+                                    .off('stag-suggest-selected')
+                                    .on('stag-suggest-selected', (_e, _input, _data) => {
+                                        $(_input).closest('form').find('input[data-name="routedMedId"]').val(_data.routed_med_id);
+                                        $(_input).closest('form').find('input[data-name="routedDosageFormMedId"]').val(_data.routed_dosage_form_med_id);
+                                        $(_input).closest('form').find('input[data-name="gcnSeqno"]').val(_data.gcn_seqno);
+                                        $(_input).closest('form').find('input[data-name="medId"]').val(_data.medid);
+                                        return false;
+                                    });
+
+                                // bind events for add-new-med and add-to-erx in one shot
+                                parentSegment.find('#frm-add-medication-and-add-to-erx')
+                                    .off('submit')
+                                    .on('submit', function () {
+
+                                        let form = $(this);
+
+                                        if (!form[0].checkValidity()) {
+                                            form[0].reportValidity();
+                                            return false;
+                                        }
+
+                                        // add [data-name] values to payload
+                                        let dataField = form.find('[name="data"]').first();
+                                        let parsed = null;
+                                        if (dataField.val()) {
+                                            parsed = JSON.parse(dataField.val());
+                                        }
+                                        form.find('[data-name]').each(function () {
+                                            if (!parsed) parsed = {};
+
+                                            let keys = $(this).attr('data-name').split('->');
+                                            let currentNode = parsed;
+                                            for (let i = 0; i < keys.length; i++) {
+                                                if (i !== keys.length - 1) {
+                                                    if (typeof currentNode[keys[i]] === 'undefined') {
+                                                        currentNode[keys[i]] = {};
+                                                    }
+                                                    currentNode = currentNode[keys[i]];
+                                                } else {
+                                                    if ($(this).is(':checkbox')) {
+                                                        currentNode[keys[i]] = $(this).prop('checked');
+                                                    } else {
+                                                        currentNode[keys[i]] = $(this).val();
+                                                    }
+                                                }
+                                            }
+
+                                        });
+                                        if (parsed) {
+                                            dataField.val(JSON.stringify(parsed));
+                                        }
+
+                                        let newERxItem = {
+                                            medication: form.find('[data-name="name"]').val(),
+                                            frequency: form.find('[data-name="frequency"]').val(),
+                                            dispense: form.find('[name="dispense"]').val(),
+                                            refills: form.find('[name="refills"]').val(),
+                                        };
+
+                                        $.post(form.attr('action'), form.serialize(), _data => {
+                                            if (!hasResponseError(_data)) {
+                                                hideMask();
+                                                // refreshDynamicStagPopup();
+                                                // $('.visit-segment[data-segment-template-name="intake_medications"]').find('.refresh-segment').trigger('click');
+
+                                                if(!self.currentPrescription.clinical_detail_json) {
+                                                    self.currentPrescription.clinical_detail_json = {};
+                                                }
+                                                if(!self.currentPrescription.clinical_detail_json.items) {
+                                                    self.currentPrescription.clinical_detail_json.items = [];
+                                                }
+                                                self.currentPrescription.clinical_detail_json.items.push(newERxItem);
+                                                self.currentPrescription.clinical_detail_json.items = JSON.parse(JSON.stringify(self.currentPrescription.clinical_detail_json.items));
+                                                let temp = self.currentPrescription;
+                                                self.currentPrescription = null;
+                                                self.currentPrescription = temp;
+                                                self.setCurrentPrescription(temp);
+
+                                                // save erx
+                                                $.post('/api/erx/updateClinicalDetail', {
+                                                    uid: self.currentPrescription.uid,
+                                                    clinicalDetailJson: JSON.stringify(self.currentPrescription.clinical_detail_json)
+                                                }, _data => {
+                                                    if(!hasResponseError(_data)) {
+                                                        // nothing to do
+
+                                                        self.setAddMode('');
+                                                    }
+                                                }, 'json');
+
+                                            }
+                                        }, 'json');
+                                        return false;
+                                    });
+
+                            });
+                        }
+                    },
+                    addICD: function(_category) {
+                        this['currentPrescription_' + _category].clinicalDetailJson.icds.push('');
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
+                    },
+                    initICDAutoSuggest: function() {
+                        let self = this;
+                        let parentSegment = $('#prescriptions-{{$patient->id}}');
+                        parentSegment.find('input[type="text"][data-field="icd"]:not([ac-initialized])').each(function() {
+                            var elem = this,
+                                dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
+                                vueIndex = $(this).attr('data-index'),
+                                category = $(this).attr('data-category');
+                            $(elem).attr('id', dynID);
+                            new window.Def.Autocompleter.Search(dynID,
+                                'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name', {
+                                    tableFormat: true,
+                                    valueCols: [0],
+                                    colHeaders: ['Code', 'Name'],
+                                }
+                            );
+                            window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
+                                let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
+                                // self.data['next_cc']['list'][vueIndex].icd = acData[0].code;
+                                // self.data['next_cc']['list'][vueIndex].memo = acData[0].data['name'];
+                                self['currentPrescription_' + category].clinicalDetailJson.icds[vueIndex] = acData[0].code;
+                                return false;
+                            });
+                            $(elem).attr('ac-initialized', 1);
+                        });
+                    },
                 },
                 mounted: function() {
                     let self = this;
                     $(document).on('pro-changed', '.erx-hcp-pro-select', function() {
                         self.currentPrescriptionHcpPro.newHcpProUid = this.value;
                     });
+
+                    // auto select latest prescription (if no current is set)
+                    Vue.nextTick(() => {
+                        if(!this.currentPrescription) {
+                            for(let x in this.prescriptions) {
+                                this.currentPrescription = this.prescriptions[x];
+                                break;
+                            }
+                        }
+                    });
                 }
             });
 

+ 32 - 33
resources/views/app/patient/prescriptions/pdf/DRUG.blade.php

@@ -51,39 +51,38 @@
 </section>
 
 <?php $clinical = json_decode($prescription->clinical_detail_json); ?>
-<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>{{ $clinical->medication }} {{ $clinical->strength }}
-                            @if($clinical->route)
-                                - {{ $clinical->route }}
+<?php if($clinical && @$clinical->items): ?>
+    <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;">
+        <?php $count = 0; ?>
+        <?php foreach ($clinical->items as $item): ?>
+        <table cellpadding="0" cellspacing="0" border="0" style="width: 100%; margin-bottom: 5pt">
+            <tr>
+                <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
+                    <span>{{ ++$count }}. </span>
+                </td>
+                <td style="vertical-align: top">
+                    <div>
+                        <p style="margin: 0">
+                            <b>{{ $item->medication }}</b>
+                        </p>
+                        <div style="">
+                            @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
-                        </b>
-                    </p>
-                    <div style="">
-                        @if($clinical->frequency)
-                            <p style="margin: 0.5rem 0;">Frequency: {{ $clinical->frequency }}</p>
-                        @endif
-                        @if($clinical->dispense)
-                            <p style="margin: 0.5rem 0;">Dispense: {{ $clinical->dispense }}</p>
-                        @endif
-                        @if($clinical->refills)
-                            <p style="margin: 0.5rem 0;">Refills: {{ $clinical->refills }}</p>
-                        @endif
-                        @if($clinical->purpose)
-                            <p style="margin: 0.5rem 0;">Purpose: <b>{{ $clinical->purpose }}</b></p>
-                        @endif
+                        </div>
                     </div>
-                </div>
-            </td>
-        </tr>
-    </table>
-</section>
+                </td>
+            </tr>
+        </table>
+        <?php endforeach; ?>
+    </section>
+<?php endif; ?>
+
 

+ 2 - 7
resources/views/app/patient/prescriptions/pdf/IMAGING.blade.php

@@ -166,7 +166,7 @@
             <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
             <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
             <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
-                {{@$clinical->icds ?: ''}}
+                {{@$clinical->icds ? implode(", ", @$clinical->icds) : '-'}}
             </td>
         </tr>
         <tr>
@@ -177,7 +177,6 @@
         </tr>
     </table>
 
-
 </section>
 
 
@@ -189,13 +188,9 @@
 
 <section style="font-size: 15px;">
     <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
-        <?php $testIndex = 1; ?>
         <tr>
-            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
-                <span>{{$testIndex++}}. </span>
-            </td>
             <td style="vertical-align: top">
-                <div style="padding-bottom: 0.3rem;">{{$clinical->test}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+                {!! @$clinical->tests ? implode("<br>", @$clinical->tests) : '-' !!}
             </td>
         </tr>
     </table>

+ 2 - 7
resources/views/app/patient/prescriptions/pdf/LAB.blade.php

@@ -166,7 +166,7 @@
             <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">Yes&nbsp;&nbsp;/&nbsp;&nbsp;No</td>
             <td style="padding-bottom: 0.25rem; width: 20%; opacity: 0.75;">ICD Codes:</td>
             <td style="padding-bottom: 0.25rem; width: 30%; opacity: 0.75; font-weight: bold;">
-                {{@$clinical->icds ?: ''}}
+                {{@$clinical->icds ? implode(", ", @$clinical->icds) : '-'}}
             </td>
         </tr>
         <tr>
@@ -177,7 +177,6 @@
         </tr>
     </table>
 
-
 </section>
 
 
@@ -189,13 +188,9 @@
 
 <section style="font-size: 15px;">
     <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
-        <?php $testIndex = 1; ?>
         <tr>
-            <td style="width: 20px; vertical-align: top; opacity: 0.75; font-size: 14px">
-                <span>{{$testIndex++}}. </span>
-            </td>
             <td style="vertical-align: top">
-                <div style="padding-bottom: 0.3rem;">{{$clinical->test}} <span style="padding-left: 15px; color: #666">{{$clinical->memo}}</span></div>
+                {!! @$clinical->tests ? implode("<br>", @$clinical->tests) : '-' !!}
             </td>
         </tr>
     </table>

+ 1 - 1
resources/views/app/patient/tickets.blade.php

@@ -55,7 +55,7 @@
     <div class="alert alert-warning border-warning">
         <b>Deprecated:</b> 
         This ERx / Orders feature has been deprecated, and is now read-only. For new prescriptions, please use
-        <a href="{{ route('patients.view.patient-prescriptions', ['patient' => $patient]) }}" class="font-weight-bold">Prescriptions</a>.
+        <a href="{{ route('patients.view.patient-prescriptions', ['patient' => $patient]) }}" class="font-weight-bold">ERx &amp; Orders</a>.
     </div>
 
     <div id="ticketsApp" v-cloak>

+ 367 - 0
resources/views/layouts/patient.blade.php

@@ -3,6 +3,7 @@
 /** @var \App\Models\Client $patient */
 ?>
 @section('content')
+<<<<<<< HEAD
 	<div class="container-fluid h-100">
 		<div class="main-row h-100 {{ !request()->input('popupmode') ? '' : 'px-0' }}">
 			@if(!request()->input('popupmode'))
@@ -221,6 +222,227 @@
 							<a class="nav-link {{ strpos($routeName, 'patients.view.pros') === 0 ? 'active' : '' }}"
 							   href="{{ route('patients.view.pros', ['patient' => $patient]) }}">Pros</a>
 						</li>
+=======
+    <div class="container-fluid h-100">
+        <div class="main-row h-100 {{ !request()->input('popupmode') ? '' : 'px-0' }}">
+            @if(!request()->input('popupmode'))
+            <nav id="sidebarMenu" class="d-md-block bg-light sidebar collapse px-0">
+                <div class="sidebar-sticky pt-3">
+                    <ul class="nav flex-column mcp-theme-1">
+                        <?php $routeName = request()->route()->getName(); ?>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.dashboard') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.dashboard', ['patient' => $patient]) }}">Dashboard</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.calendar') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.calendar', ['patient' => $patient]) }}">Calendar</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.appointments') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.appointments', ['patient' => $patient, 'forPro' => 'all', 'status' => 'all']) }}">Appointments</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.programs') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.programs', ['patient' => $patient]) }}">Programs</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.flowsheets') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.flowsheets', ['patient' => $patient]) }}">Flowsheets</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.vitals-settings') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.vitals-settings', ['patient' => $patient]) }}">Vitals Settings</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.vitals-graph') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.vitals-graph', ['patient' => $patient]) }}">Vitals Graph</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.care-months') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.care-months', ['patient' => $patient]) }}">Care Months</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.devices') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.devices', ['patient' => $patient]) }}">Devices</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.measurements') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.measurements', ['patient' => $patient]) }}">Measurements</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.notes') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.notes', ['patient' => $patient]) }}">Notes</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.generic-bills') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.generic-bills', ['patient' => $patient]) }}">Generic Bills</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.sections') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.sections', ['patient' => $patient]) }}">Sections</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.handouts') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.handouts', ['patient' => $patient]) }}">Handouts</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.rm-setup') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.rm-setup', ['patient' => $patient]) }}">RM Setup</a>
+                        </li>
+                        <?php /* <li class="nav-item">
+                            <a class="nav-link d-flex align-items-center {{ strpos($routeName, 'patients.view.action-items') === 0 ? 'active' : '' }}"
+                               native onclick="return false">
+                                <span class="text-dark">ERx/Orders</span>
+                            </a>
+                            <ul class="m-0 p-0 nav-child-list">
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-erx') === 0 ? 'active' : '' }}"
+                                       href="{{ route('patients.view.action-items-erx', ['patient' => $patient]) }}">ERx</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-lab') === 0 ? 'active' : '' }}"
+                                       href="{{ route('patients.view.action-items-lab', ['patient' => $patient]) }}">Lab</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-imaging') === 0 ? 'active' : '' }}"
+                                       href="{{ route('patients.view.action-items-imaging', ['patient' => $patient]) }}">Imaging</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-equipment') === 0 ? 'active' : '' }}"
+                                       href="{{ route('patients.view.action-items-equipment', ['patient' => $patient]) }}">Equipment</a>
+                                </li>
+                            </ul>
+                        </li> */ ?>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.patient-prescriptions') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.patient-prescriptions', ['patient' => $patient]) }}">ERx &amp; Orders</a>
+                            <?php /*
+                            <ul class="m-0 p-0 nav-child-list">
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === '' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => '']) }}">All</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'erx' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'erx']) }}">Drug</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'lab' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'lab']) }}">Lab</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'imaging' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'imaging']) }}">Imaging</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'referral' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'referral']) }}">Referral</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'supply' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'supply']) }}">Supply</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-erx') === 0 && @$type === 'other' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-erx', ['patient' => $patient, 'type' => 'other']) }}">Other</a>
+                                </li>
+                            </ul>
+                            */ ?>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 ? 'active' : '' }}"
+                               title="Deprecated"
+                               href="{{ route('patients.view.patient-tickets', ['patient' => $patient]) }}">ERx / Orders <span class="text-secondary text-sm"></span>(dep)</a>
+                            <ul class="m-0 p-0 nav-child-list">
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 && @$type === '' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-tickets', ['patient' => $patient, 'type' => '']) }}">All</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 && @$type === 'erx' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-tickets', ['patient' => $patient, 'type' => 'erx']) }}">ERx</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 && @$type === 'lab' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-tickets', ['patient' => $patient, 'type' => 'lab']) }}">Lab</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 && @$type === 'imaging' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-tickets', ['patient' => $patient, 'type' => 'imaging']) }}">Imaging</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link {{ strpos($routeName, 'patients.view.patient-tickets') === 0 && @$type === 'other' ? 'active' : '' }}"
+                                       href="{{ route('patients.view.patient-tickets', ['patient' => $patient, 'type' => 'other']) }}">Other</a>
+                                </li>
+                            </ul>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.supply-orders') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.supply-orders', ['patient' => $patient]) }}">Supply Orders</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.shipments') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.shipments', ['patient' => $patient]) }}">Shipments</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.incoming-reports') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.incoming-reports', ['patient' => $patient]) }}">Incoming Reports</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.allergies') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.allergies', ['patient' => $patient]) }}">Allergies</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.medications') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.medications', ['patient' => $patient]) }}">Medications</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.dx-and-focus-areas') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.dx-and-focus-areas', ['patient' => $patient]) }}">Dx and
+                                Focus Areas</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.care-team') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.care-team', ['patient' => $patient]) }}">Care Team</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.history') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.history', ['patient' => $patient]) }}">History</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.memos') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.memos', ['patient' => $patient]) }}">Memos</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ $routeName === 'patients.view.sms' ? 'active' : '' }}"
+                               href="{{ route('patients.view.sms', ['patient' => $patient]) }}">SMS</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.sms-numbers') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.sms-numbers', ['patient' => $patient]) }}">SMS Numbers</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.documents') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.documents', ['patient' => $patient]) }}">Documents</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.settings') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.settings', ['patient' => $patient]) }}">Settings</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.sms-reminders') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.sms-reminders', ['patient' => $patient]) }}">SMS Reminders</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.measurement-confirmation-numbers') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.measurement-confirmation-numbers', ['patient' => $patient]) }}">Meas. Conf. Numbers</a>
+                        </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.pros') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.pros', ['patient' => $patient]) }}">Pros</a>
+                        </li>
+>>>>>>> 0effe8dc669281a70a2be9972fb8d653f6bae659
 {{--                        <li class="nav-item">--}}
 {{--                            <a class="nav-link" href="/patients/view/{{ $patient->uid }}/intake">Intake</a>--}}
 {{--                        </li>--}}
@@ -811,6 +1033,7 @@
 					@endif
 					{{--<div class="text-container border-bottom d-flex align-items-center mcp-theme-1 px-3">
 
+<<<<<<< HEAD
 						@if($patient->mcp_pro_id !== $pro->id && $patient->active_mcp_request_id)
 							<div moe relative class="ml-2">
 								<a href="" start show class="btn btn-sm btn-success text-white font-weight-bold small">Claim as MCP</a>
@@ -847,6 +1070,150 @@
 						form.find('.if-in-clinic').hide();
 					}
 				});
+=======
+                                    <ul class="vbox ml-auto mt-2 align-self-start patient-header-address">
+                                        <li class="d-flex align-items-start">
+                                            <span class="aligned-icon">
+                                                <i class="fa fa-map-marker-alt" aria-hidden="true"></i>
+                                            </span>
+                                            <div class="position-relative">
+                                                <?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) . "<br/>";
+                                                $addressPart2 = [];
+                                                if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
+                                                if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
+                                                $addressParts .= implode(", ", $addressPart2);
+                                                echo $addressParts;
+                                                ?>
+                                                {{ $patient->mailing_address_zip ? $patient->mailing_address_zip : '' }}
+                                                @if($patient->mailing_address_memo)
+                                                    <span class="position-relative c-pointer text-center stag-tooltip ml-2">
+                                                        <i class="fa fa-info-circle"></i>
+                                                        <div
+                                                            class="position-absolute bg-white border rounded p-2 stag-tooltip-content">
+                                                            <div class="text-left font-weight-bold pb-1">Special Instructions</div>
+                                                            <div
+                                                                class="text-left font-weight-normal">{{$patient->mailing_address_memo}}</div>
+                                                        </div>
+                                                    </span>
+                                                @endif
+                                            </div>
+                                        </li>
+                                        @if($patient->cell_number)
+                                            <li>
+                                                <span class="aligned-icon">
+                                                    <i class="fa fa-phone-alt" aria-hidden="true"></i>
+                                                </span>
+                                                {{$patient->cell_number}}
+                                                <span class="small text-secondary ml-1">
+                                                    {{ $patient->cell_number_memo ? '(' . $patient->cell_number_memo . ')' : '' }}
+                                                </span>
+                                            </li>
+                                        @endif
+                                        @if($patient->phone_home)
+                                            <li>
+                                                <span class="aligned-icon"><i class="fa fa-home" aria-hidden="true"></i></span>
+                                                {{$patient->phone_home}}
+                                            </li>
+                                        @endif
+                                        <li class="{{empty($confirmedEmail) || $confirmedEmail === '-' ? 'screen-only' : ''}}">
+                                            <span class="aligned-icon"><i class="fa fa-envelope" aria-hidden="true"></i></span>
+                                            {{$confirmedEmail}}
+                                        </li>
+                                        <li class="screen-only hide-inside-popup">
+                                            <span class="aligned-icon text-primary">
+                                                <i class="fa fa-link" aria-hidden="true"></i>
+                                            </span>
+                                            <?php $numLinkedAccounts = $patient->linkedAccounts ? count($patient->linkedAccounts) : 0; ?>
+                                            <a href="{{route('patients.view.accounts', ['patient' => $patient])}}">
+                                                {{ $numLinkedAccounts === 0 ? 'No' : $numLinkedAccounts }}
+                                                account{{ $numLinkedAccounts === 1 ? '' : 's' }} linked
+                                            </a>
+                                        </li>
+                                    </ul>
+                                </div>
+                            </div>
+                        </div> <!-- z -->
+                    </div>
+                    @if(0 && $pro->pro_type === 'ADMIN')
+                        <div class="screen-only card-header py-2 d-flex align-items-center mcp-theme-1 bg-aliceblue">
+                            <b class="">Tags ({{count($patient->clientTags)}}):</b>
+                            @foreach($patient->clientTags as $tag)
+                                <div class="d-inline-flex align-items-center ml-2 py-1 px-2 rounded bg-aliceblue text-info">
+                                    <span class="text-sm">{{$tag->tag}}</span>
+                                    <div moe relative class="ml-2">
+                                        <a href="" start show><i class="fa fa-times text-secondary on-hover-opaque"></i></a>
+                                        <form url="/api/clientTag/cancel" class="mcp-theme-1 min-width-200px">
+                                            <input type="hidden" name="uid" value="{{$tag->uid}}">
+                                            <p class="text-nowrap text-dark">Cancel this tag?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                </div>
+                            @endforeach
+                            <div moe relative class="ml-2">
+                                <a href="" start show class="text-sm">+ Add</a>
+                                <form url="/api/clientTag/create" class="mcp-theme-1">
+                                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                    <div class="mb-2">
+                                        <label class="text-secondary text-sm">Tag</label>
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="tag"
+                                               placeholder="Tag" required>
+                                    </div>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                    @endif
+                    {{--<div class="text-container border-bottom d-flex align-items-center mcp-theme-1 px-3">
+
+                        @if($patient->mcp_pro_id !== $pro->id && $patient->active_mcp_request_id)
+                            <div moe relative class="ml-2">
+                                <a href="" start show class="btn btn-sm btn-success text-white font-weight-bold small">Claim as MCP</a>
+                                <form url="/api/mcpRequest/claim" class="mcp-theme-1" right>
+                                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                    <p>Claim this patient?</p>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    </div>--}}
+                    <div class="card-body p-3">
+                        {{--<h1 class="h3">@yield('section-title')</h1>--}}
+                        <div class="mcp-theme-1">
+                            @yield('inner-content')
+                        </div>
+                    </div>
+                </div>
+            </main>
+        </div>
+    </div>
+    <script>
+        (function() {
+            function init() {
+                $('.note-method-select').change(function() {
+                    let form = $(this).closest('form');
+                    if(this.value === 'IN_CLINIC') {
+                        form.find('.if-in-clinic').show();
+                    }
+                    else {
+                        form.find('.if-in-clinic').hide();
+                    }
+                });
+>>>>>>> 0effe8dc669281a70a2be9972fb8d653f6bae659
 
 				$('.note-method-select').each(function() {
 					let form = $(this).closest('form');

+ 2 - 0
routes/web.php

@@ -298,6 +298,7 @@ Route::middleware('pro.auth')->group(function () {
 
             // prescriptions (new)
             Route::get('prescriptions/{type?}/{currentErx?}', 'PatientController@prescriptions')->name('patient-prescriptions');
+            Route::get('prescriptions-popup/{type?}/{currentErx?}', 'PatientController@prescriptionsPopup')->name('patient-prescriptions-popup');
             Route::get('prescriptions-list/{type?}/{currentErx?}', 'PatientController@prescriptionsList')->name('patient-prescriptions-list');
 
             // appointments
@@ -320,6 +321,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/note/pdf/{note}', 'NoteController@downloadAsPdf')->name('note-pdf');
     Route::get('/segment-summary/{segment}', 'NoteController@segmentSummary')->name('segment-summary');
     Route::get('/medications-center/{patient}/{note}', 'NoteController@medicationsCenter')->name('medications-center');
+    Route::get('/medications-reconcile/{patient}/{note}', 'NoteController@medicationsReconcile')->name('medications-reconcile');
     Route::get('/problems-center/{patient}/{note}', 'NoteController@problemsCenter')->name('problems-center');
     Route::get('/goals-center/{patient}/{note}', 'NoteController@goalsCenter')->name('goals-center');
 

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä