= преди 3 години
родител
ревизия
8bb6dd0acc
променени са 100 файла, в които са добавени 9006 реда и са изтрити 173 реда
  1. 6 0
      .env.example
  2. 38 1
      app/Http/Controllers/HomeController.php
  3. 40 0
      app/Http/Controllers/NoteController.php
  4. 64 1
      app/Http/Controllers/PatientController.php
  5. 99 0
      app/Http/Controllers/PracticeManagementController.php
  6. 68 1
      app/Models/Client.php
  7. 31 0
      app/Models/Erx.php
  8. 11 0
      app/Models/Note.php
  9. 5 0
      app/Models/NotePickupForProcessing.php
  10. 88 0
      app/Models/Point.php
  11. 10 0
      app/Models/Pro.php
  12. 22 0
      app/Models/Segment.php
  13. 11 0
      app/Models/SegmentTemplate.php
  14. 10 0
      app/Models/VisitTemplate.php
  15. 3 1
      config/app.php
  16. 15 0
      config/database.php
  17. 347 0
      fdb_notes.txt
  18. 126 1
      public/css/style.css
  19. 6 1
      public/js/mc.js
  20. 4 3
      public/js/pro-suggest.js
  21. 6 0
      public/js/show-on-click.js
  22. 191 0
      public/js/stag-suggest.js
  23. 108 2
      resources/views/app/dashboard.blade.php
  24. 6 0
      resources/views/app/dashboard/incoming_reports.blade.php
  25. 11 0
      resources/views/app/dashboard/measurements.blade.php
  26. 12 0
      resources/views/app/fdb-pg/fdb-allergy-suggest.blade.php
  27. 16 0
      resources/views/app/fdb-pg/fdb-coadministration.blade.php
  28. 25 0
      resources/views/app/fdb-pg/fdb-contraindications.blade.php
  29. 12 0
      resources/views/app/fdb-pg/fdb-dx-suggest.blade.php
  30. 27 0
      resources/views/app/fdb-pg/fdb-geriatric-precautions.blade.php
  31. 25 0
      resources/views/app/fdb-pg/fdb-indications.blade.php
  32. 12 0
      resources/views/app/fdb-pg/fdb-med-suggest.blade.php
  33. 667 0
      resources/views/app/fdb-pg/fdb-rx.blade.php
  34. 27 0
      resources/views/app/fdb-pg/fdb-side-effects.blade.php
  35. 21 21
      resources/views/app/guest/appointment-confirmation.blade.php
  36. 7 5
      resources/views/app/patient/appointment-calendar.blade.php
  37. 254 0
      resources/views/app/patient/care-month/_matrix.blade.php
  38. 5 4
      resources/views/app/patient/care-month/dashboard.blade.php
  39. 5 0
      resources/views/app/patient/care-month/matrix.blade.php
  40. 9 0
      resources/views/app/patient/care-months.blade.php
  41. 3 1
      resources/views/app/patient/incoming-reports.blade.php
  42. 42 0
      resources/views/app/patient/note/_templates-v2-index.blade.php
  43. 2147 0
      resources/views/app/patient/note/dashboard-univ.blade.php
  44. 102 103
      resources/views/app/patient/note/dashboard.blade.php
  45. 5 3
      resources/views/app/patient/note/dashboard_script.blade.php
  46. 6 0
      resources/views/app/patient/note/note-segment-list.blade.php
  47. 34 24
      resources/views/app/patient/note/section.blade.php
  48. 35 0
      resources/views/app/patient/note/segment.blade.php
  49. 228 0
      resources/views/app/patient/note/segment_script.blade.php
  50. 55 0
      resources/views/app/patient/notes.blade.php
  51. 78 0
      resources/views/app/patient/page-sections/cc/form.blade.php
  52. 23 0
      resources/views/app/patient/page-sections/cc/summary.php
  53. 121 0
      resources/views/app/patient/page-sections/rx/form.blade.php
  54. 45 0
      resources/views/app/patient/page-sections/rx/summary.php
  55. 78 0
      resources/views/app/patient/page-sections/subjective/form.blade.php
  56. 23 0
      resources/views/app/patient/page-sections/subjective/summary.php
  57. 20 0
      resources/views/app/patient/page-sections/vitals/default.php
  58. 264 0
      resources/views/app/patient/page-sections/vitals/form.blade.php
  59. 131 0
      resources/views/app/patient/page-sections/vitals/summary.php
  60. 1 1
      resources/views/app/patient/partials/appointment-confirmation-history.blade.php
  61. 32 0
      resources/views/app/patient/prescriptions/client-status-form.blade.php
  62. 73 0
      resources/views/app/patient/prescriptions/drug-form.blade.php
  63. 23 0
      resources/views/app/patient/prescriptions/hcp-pro-form.blade.php
  64. 30 0
      resources/views/app/patient/prescriptions/imaging-form.blade.php
  65. 772 0
      resources/views/app/patient/prescriptions/index.blade.php
  66. 30 0
      resources/views/app/patient/prescriptions/lab-form.blade.php
  67. 59 0
      resources/views/app/patient/prescriptions/logistics-form.blade.php
  68. 25 0
      resources/views/app/patient/prescriptions/other-form.blade.php
  69. 66 0
      resources/views/app/patient/prescriptions/pdf/DRUG.blade.php
  70. 203 0
      resources/views/app/patient/prescriptions/pdf/IMAGING.blade.php
  71. 203 0
      resources/views/app/patient/prescriptions/pdf/LAB.blade.php
  72. 203 0
      resources/views/app/patient/prescriptions/pdf/OTHER.blade.php
  73. 203 0
      resources/views/app/patient/prescriptions/pdf/REFERRAL.blade.php
  74. 203 0
      resources/views/app/patient/prescriptions/pdf/SUPPLY.blade.php
  75. 13 0
      resources/views/app/patient/prescriptions/pdf/pdf-preview-with-cover-sheet.blade.php
  76. 13 0
      resources/views/app/patient/prescriptions/pdf/pdf-preview.blade.php
  77. 32 0
      resources/views/app/patient/prescriptions/pro-status-form.blade.php
  78. 25 0
      resources/views/app/patient/prescriptions/referral-form.blade.php
  79. 16 0
      resources/views/app/patient/prescriptions/sign-as-hcp-form.blade.php
  80. 34 0
      resources/views/app/patient/prescriptions/supply-form.blade.php
  81. 66 0
      resources/views/app/patient/prescriptions/transmit-form.blade.php
  82. 37 0
      resources/views/app/patient/segment-templates/_child_review/edit-review.php
  83. 38 0
      resources/views/app/patient/segment-templates/_child_review/last-review.php
  84. 160 0
      resources/views/app/patient/segment-templates/_common_actions/remove-undo.php
  85. 24 0
      resources/views/app/patient/segment-templates/_simple_text_segment/edit.php
  86. 20 0
      resources/views/app/patient/segment-templates/_simple_text_segment/summary.php
  87. 4 0
      resources/views/app/patient/segment-templates/chief_complaint/edit.blade.php
  88. 3 0
      resources/views/app/patient/segment-templates/chief_complaint/summary.blade.php
  89. 1 0
      resources/views/app/patient/segment-templates/history_family/edit.blade.php
  90. 1 0
      resources/views/app/patient/segment-templates/history_family/summary.blade.php
  91. 1 0
      resources/views/app/patient/segment-templates/history_screenings/edit.blade.php
  92. 1 0
      resources/views/app/patient/segment-templates/history_screenings/summary.blade.php
  93. 267 0
      resources/views/app/patient/segment-templates/history_social/edit.blade.php
  94. 95 0
      resources/views/app/patient/segment-templates/history_social/summary.blade.php
  95. 1 0
      resources/views/app/patient/segment-templates/history_surgical/edit.blade.php
  96. 1 0
      resources/views/app/patient/segment-templates/history_surgical/summary.blade.php
  97. 87 0
      resources/views/app/patient/segment-templates/intake_allergies/edit.blade.php
  98. 48 0
      resources/views/app/patient/segment-templates/intake_allergies/summary.blade.php
  99. 1 0
      resources/views/app/patient/segment-templates/intake_care_team/edit.blade.php
  100. 1 0
      resources/views/app/patient/segment-templates/intake_care_team/summary.blade.php

+ 6 - 0
.env.example

@@ -13,6 +13,12 @@ DB_DATABASE=stag2
 DB_USERNAME=postgres
 DB_PASSWORD=pass
 
+DB_HOST_FDB=127.0.0.1
+DB_PORT_FDB=5432
+DB_DATABASE_FDB=fdb
+DB_USERNAME_FDB=postgres
+DB_PASSWORD_FDB=password
+
 BROADCAST_DRIVER=log
 CACHE_DRIVER=file
 QUEUE_CONNECTION=sync

+ 38 - 1
app/Http/Controllers/HomeController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Lib\Backend;
 use App\Models\Appointment;
+use App\Models\AppointmentConfirmationDecision;
 use App\Models\AppSession;
 use App\Models\ClientMemo;
 use App\Models\ClientProChange;
@@ -393,6 +394,40 @@ class HomeController extends Controller
             ->whereNull('current_client_pro_change_decision_id')
             ->get();
 
+        $proApptUpdates = AppointmentConfirmationDecision
+            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'appointment.start_time')
+            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
+            ->where('appointment_confirmation_decision.was_acknowledged_by_appointment_pro', false)
+            ->where('appointment.status', '!=', 'CREATED')
+            ->where('appointment.status', '!=', 'COMPLETED')
+            ->where('appointment.status', '!=', 'ABANDONED')
+            ->where('appointment.pro_id', $performerProID)
+            ->where('client.mcp_pro_id', $performerProID)
+            ->orderBy('appointment.start_time', 'DESC')
+            ->get();
+
+        $naApptUpdates = AppointmentConfirmationDecision
+            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'pro.name_first as pro_name_first', 'pro.name_last as pro_name_last', 'appointment.start_time')
+            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
+            ->rightJoin('pro', 'pro.id', '=', 'appointment.pro_id')
+            ->where('appointment_confirmation_decision.was_acknowledged_by_client_default_na', false)
+            ->where('appointment.status', '!=', 'CREATED')
+            ->where('appointment.status', '!=', 'COMPLETED')
+            ->where('appointment.status', '!=', 'ABANDONED')
+            ->where('client.default_na_pro_id', $performerProID)
+            ->orderBy('appointment.start_time', 'DESC')
+            ->get();
+
+//        $naApptUpdates = AppointmentConfirmationDecision
+//            ::join('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+//            ->join('client', 'client.id', '=', 'appointment.client_id')
+//            ->where('client.default_na_pro_id', $performerProID)
+//            ->where('appointment_confirmation_decision.was_acknowledged_by_client_default_na', false)
+//            ->orderBy('appointment.start_time DESC')
+//            ->get();
+
         // unstamped client memos
         // for mcp
         $mcpClientMemos = DB::select(
@@ -529,7 +564,8 @@ WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$per
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
             'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'naClientMemos'));
+            'mcpClientMemos', 'naClientMemos',
+            'proApptUpdates', 'naApptUpdates'));
     }
 
     public function dashboardMeasurementsTab(Request $request, $page = 1) {
@@ -580,6 +616,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                 "
 SELECT measurement.uid as uid,
        care_month.uid as care_month_uid,
+       care_month.start_date as care_month_start_date,
        measurement.label,
        measurement.value,
        measurement.sbp_mm_hg,

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

@@ -2,18 +2,22 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\AppSession;
 use App\Models\Page;
 use App\Models\Pro;
 use App\Models\SupplyOrder;
 use App\Models\Ticket;
 use Illuminate\Http\Request;
 use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Blade;
 use Illuminate\Support\Facades\Http;
 
 use App\Models\Note;
 use App\Models\Client;
 use App\Models\Section;
 use App\Models\SectionTemplate;
+use App\Models\Segment;
+use App\Models\SegmentTemplate;
 
 class NoteController extends Controller
 {
@@ -80,6 +84,42 @@ class NoteController extends Controller
             compact('patient', 'note', 'section', 'page'));
     }
 
+    public function getHtmlForSegment($segmentUid, $sessionKey){
+
+        $performer = AppSession::where('session_key', $sessionKey)->first();
+        if(!$performer || !$performer->is_active){
+            return response()->json([
+                'success'=>false,
+                'message'=>'Invalid session key'
+            ]);
+        }
+        $pro = $performer->pro;
+
+        $segment = Segment::where('uid', $segmentUid)->first();
+        $segmentTemplate = $segment->segmentTemplate;
+
+        $note = $segment->note;
+        $patient = $note->client;
+
+        $data = compact('performer', 'pro', 'segment', 'segmentTemplate', 'note', 'patient');
+
+        //try {
+            $summaryHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/summary', $data)->render();
+            $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
+      //  } catch (\Throwable $e) {
+//            return response()->json([
+//                'success'=>false,
+//                'message'=>$e->getMessage()
+//            ]);
+       // }
+
+        return response()->json([
+            'success'=>true,
+            'summaryHtml' => $summaryHtml,
+            'editHtml' => $editHtml
+        ]);
+    }
+
     // JAVA ONLY
     // ... if hcpProId is passed, get from request
     public function getDefaultValueForSection($patientID, $sectionTemplateID)

+ 64 - 1
app/Http/Controllers/PatientController.php

@@ -8,6 +8,7 @@ use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
+use App\Models\Erx;
 use App\Models\Facility;
 use App\Models\Handout;
 use App\Models\IncomingReport;
@@ -26,6 +27,9 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\File;
 
+use Illuminate\Support\Facades\Http;
+use PDF;
+
 class PatientController extends Controller
 {
 
@@ -372,7 +376,7 @@ class PatientController extends Controller
         $pros = [];
 
         if($this->pro && $this->pro->pro_type != 'ADMIN') {
-            $accessiblePros = ProProAccess::where('owner_pro_id', $this->pro->id);
+            $accessiblePros = ProProAccess::where('owner_pro_id', $this->pro->id)->get();
             $accessibleProIds = [];
             foreach($accessiblePros as $accessiblePro){
                 $accessibleProIds[] = $accessiblePro->id;
@@ -394,6 +398,10 @@ class PatientController extends Controller
         return view('app.patient.flowsheets', compact('patient', 'pros', 'filter'));
     }
 
+    public function vitalsSettings(Request $request, Client $patient) {
+        return view('app.patient.vitals-settings', compact('patient'));
+    }
+
     public function vitalsGraph(Request $request, Client $patient, $filter = '') {
         $pros = $this->pros;
         return view('app.patient.vitals-graph', compact('patient', 'pros', 'filter'));
@@ -412,6 +420,54 @@ class PatientController extends Controller
         return view('app.patient.tickets', compact('patient', 'pros', 'allPros', 'type', 'currentTicket'));
     }
 
+    public function prescriptions(Request $request, Client $patient, String $type = '', String $currentErx = '') {
+        if(!!$currentErx) {
+            $currentErx = Erx::where('uid', $currentErx)->first();
+        }
+        return view('app.patient.prescriptions.index', compact('patient', 'type', 'currentErx'));
+    }
+
+    public function downloadPrescriptionAsPdf(Request $request, Erx $prescription){
+        if($request->input('html')) {
+            return view('app.patient.prescriptions.pdf.pdf-preview', compact('prescription'));
+        }
+        else {
+            $pdf = PDF::loadView('app.patient.prescriptions.pdf.pdf-preview', compact('prescription'));
+            return $pdf->download($prescription->created_at .'_' . 'erx.pdf');
+        }
+    }
+
+    public function transmitPrescription(Request $request, Erx $prescription){
+
+        // re-generate pdf with cover sheet as first page and save it to FS
+        $filePath = config('app.temp_dir') . "/{$prescription->uid}.pdf";
+        $pdf = PDF::loadView('app.patient.prescriptions.pdf.pdf-preview-with-cover-sheet', compact('prescription'));
+        $pdf->save($filePath);
+
+        // send it along with the rest of the params to /api/erx/transmit [multi-part POST]
+        $url =  config('stag.backendUrl') . '/erx/transmit';
+        $params = [
+            "uid" => $request->input('uid'),
+            "toWho" => $request->input('toWho'),
+            "toEmail" => $request->input('toEmail'),
+            "toFaxNumber" => $request->input('toFaxNumber'),
+            "toFaxNumberAttentionLine" => $request->input('toFaxNumberAttentionLine'),
+            "toFaxNumberCoverSheetMemo" => $request->input('toFaxNumberCoverSheetMemo'),
+        ];
+        if($request->input('copyToPatient')) {
+            $params["copyToPatientFaxNumber"] = $request->input('copyToPatientFaxNumber');
+            $params["copyToPatientEmail"] = $request->input('copyToPatientEmail');
+        }
+        $pdf = fopen($filePath, 'r');
+        $response = Http
+            ::attach('pdfSystemFile', $filePath, "{$prescription->uid}.pdf")
+            ->withHeaders(['sessionKey' => $request->cookie('sessionKey')])
+            ->post($url, $params)
+            ->json();
+        return $response;
+
+    }
+
     public function supplyOrders(Request $request, Client $patient, SupplyOrder $supplyOrder = null)
     {
         $products = Product::where('is_active', true)->orderBy('created_at', 'desc')->get();
@@ -455,4 +511,11 @@ class PatientController extends Controller
     public function accounts(Request $request, Client $patient) {
         return view('app.patient.accounts', compact('patient'));
     }
+
+    public function careMonthMatrix(Request $request, CareMonth $careMonth) {
+        return view('app.patient.care-month.matrix', [
+            'patient' => $careMonth->patient,
+            'careMonth' => $careMonth,
+        ]);
+    }
 }

+ 99 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -1593,6 +1593,66 @@ ORDER BY claim.created_at DESC
         return  view('app.practice-management.process-notes', compact('mode', 'counts'));
     }
 
+    public function notesProcessingCenter(Request  $request) {
+
+        $notes = Note::where('is_cancelled', false);
+
+        // filters
+        $proUid = $request->input('proUid');
+        if($proUid) {
+            $fPro = Pro::where('uid', $proUid)->first();
+            if($fPro) {
+                $notes = $notes->where('hcp_pro_id', $fPro->id);
+            }
+        }
+        $proSigned = $request->input('proSigned');
+        switch($proSigned) {
+            case 'yes': $notes = $notes->where('is_signed_by_hcp', true); break;
+            case 'no': $notes = $notes->where('is_signed_by_hcp', '!=', true); break;
+        }
+        $billingMarkedDone = $request->input('billingMarkedDone');
+        switch($billingMarkedDone) {
+            case 'yes': $notes = $notes->where('is_billing_marked_done', true); break;
+            case 'no': $notes = $notes->where('is_billing_marked_done', '!=', true); break;
+        }
+        $billingClosed = $request->input('billingClosed');
+        switch($billingClosed) {
+            case 'yes': $notes = $notes->where('is_bill_closed', true); break;
+            case 'no': $notes = $notes->where('is_bill_closed', '!=', true); break;
+        }
+        $claimingClosed = $request->input('claimingClosed');
+        switch($claimingClosed) {
+            case 'yes': $notes = $notes->where('is_claim_closed', true); break;
+            case 'no': $notes = $notes->where('is_claim_closed', '!=', true); break;
+        }
+        $allClaimsSubmitted = $request->input('allClaimsSubmitted');
+        if($allClaimsSubmitted) {
+            // TODO
+        }
+        $goodBad = $request->input('goodBad');
+        switch($goodBad) {
+            case 'good': $notes = $notes->whereRaw("(detail_json)::json->>'isBad' = 'false'"); break;
+            case 'bad': $notes = $notes->whereRaw("(detail_json)::json->>'isBad' = 'true'"); break;
+            case 'unclassified': $notes = $notes->whereRaw("(detail_json)::json->>'isBad' is null"); break;
+        }
+        $startDate = $request->input('startDate');
+        if($startDate) {
+            $notes = $notes->where('effective_dateest', '>=', $startDate);
+        }
+        $endDate = $request->input('endDate');
+        if($endDate) {
+            $notes = $notes->where('effective_dateest', '<=', $endDate);
+        }
+        $mcPartB = $request->input('mcPartB');
+        if($mcPartB) {
+            // TODO
+        }
+
+        $notes = $notes->orderBy('effective_dateest')->paginate();
+
+        return  view('app.practice-management.notes-processing-center', compact('notes'));
+    }
+
     public function getNextNote(Request $request, $mode)
     {
         $note = null;
@@ -1829,4 +1889,43 @@ ORDER BY claim.created_at DESC
 
     }
 
+    public function careMonthReport(Request $request) {
+        $m = $request->input('m');
+        $y = $request->input('y');
+        if(!$m || !$y) {
+            $date = date('Y-m-01');
+        }
+        else {
+            $date = date('Y-m-d', strtotime("$m/1/$y"));
+        }
+
+        $pro = $this->pro;
+
+        $records = DB::select("
+SELECT cm.id                                as care_month_id,
+       cm.uid                               as care_month_uid,
+       c.id                                 as client_id,
+       c.uid                                as client_uid,
+       cm.number_of_days_with_remote_measurements,
+       cm.rm_total_time_in_seconds_by_mcp,
+       cm.rm_total_time_in_seconds_by_rme_pro,
+       cm.rm_total_time_in_seconds_by_rmm_pro,
+       cm.mcp_pro_id,
+       cm.rme_pro_id,
+       cm.rmm_pro_id,
+       (c.name_first || ' ' || c.name_last) as client_name
+FROM care_month cm
+         JOIN client c on cm.client_id = c.id
+WHERE cm.start_date = :startDate
+  AND (cm.mcp_pro_id = :proID OR
+       cm.rme_pro_id = :proID OR
+       cm.rmm_pro_id = :proID)
+ORDER BY c.name_last, c.name_first
+            ",
+            ['startDate' => $date, 'proID' => $pro->id]
+        );
+
+        return view('app.practice-management.care-month-report', compact('records', 'date'));
+    }
+
 }

+ 68 - 1
app/Models/Client.php

@@ -69,6 +69,12 @@ class Client extends Model
             ->orderBy('effective_dateest', 'desc');
     }
 
+    public function prescriptions()
+    {
+        return $this->hasMany(Erx::class, 'client_id', 'id')
+            ->orderBy('created_at', 'desc');
+    }
+
     public function notesAscending()
     {
         return $this->hasMany(Note::class, 'client_id', 'id')
@@ -442,7 +448,7 @@ class Client extends Model
         $pro = $this->rme;
         if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'RME'];
         $pro = $this->defaultNaPro;
-        if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'Default NA'];
+        if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'Nurse'];
 
         // via client pro access
         $cpAccesses = ClientProAccess::where('client_id', $this->id)->where('is_active', true)->get();
@@ -645,4 +651,65 @@ class Client extends Model
         $notes = $notes->orderBy('effective_dateest', 'DESC')->limit(5)->get();
         return $notes;
     }
+
+    public function cmMeasurementsMatrix($_careMonth = null) {
+
+        $days = [];
+
+        $matches = DB::select(
+            "
+SELECT m.id   AS measurement_id,
+       m.uid  AS measurement_uid,
+       cm.id  AS care_month_id,
+       cm.uid AS care_month_uid,
+       m.label,
+       m.value,
+       m.dbp_mm_hg,
+       m.sbp_mm_hg,
+       m.value_pulse,
+       m.value_irregular,
+       m.numeric_value,
+       m.effective_date,
+       m.ts,
+       m.has_been_stamped_by_mcp,
+       m.has_been_stamped_by_non_hcp
+FROM measurement m
+         JOIN care_month cm ON m.care_month_id = cm.id
+WHERE m.care_month_id = :careMonthID
+        AND m.label NOT IN ('SBP', 'DBP')
+        AND m.bdt_measurement_id IS NOT NULL
+        AND m.is_removed IS FALSE
+        AND (m.is_cellular_zero = FALSE or m.is_cellular_zero IS NULL)
+        AND m.ts IS NOT NULL
+        AND m.client_bdt_measurement_id IS NOT NULL
+ORDER BY m.effective_date
+            ",
+            ['careMonthID' => $_careMonth->id]
+        );
+
+        foreach ($matches as $match) {
+            $time = (floor($match->ts / 1000));
+            $realTimezone = resolve_timezone('EASTERN');
+            $date = new \DateTime("@$time");
+            $date->setTimezone(new \DateTimeZone($realTimezone));
+            $match->date = $date->format("m/d/Y");
+            $match->dateYMD = $date->format("Y-m-d");
+            $match->time = $date->format("h:i A");
+
+            // get existing entries for listing
+            $match->entries = CareMonthEntry::where('care_month_id', $match->care_month_id)
+                ->where('is_removed', false)
+                ->where('effective_date', $match->dateYMD)
+                ->orderBy('created_at')
+                ->get();
+
+            if(!isset($days[$match->date])) {
+                $days[$match->date] = [];
+            }
+            $days[$match->date][] = $match;
+        }
+
+        return $days;
+
+    }
 }

+ 31 - 0
app/Models/Erx.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class Erx extends Model
+{
+    protected $table = "erx";
+
+    public function managerPro(){
+        return $this->hasOne(Pro::class, 'id', 'manager_pro_id');
+    }
+
+    public function hcpPro(){
+        return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
+    }
+
+    public function patient(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function client(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function note(){
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
+
+}

+ 11 - 0
app/Models/Note.php

@@ -57,6 +57,13 @@ class Note extends Model
             ->orderBy('position_index', 'asc');
     }
 
+    public function segments()
+    {
+        return $this->hasMany(Segment::class, 'note_id', 'id')
+            ->where('is_active', true)
+            ->orderBy('position_index', 'asc');
+    }
+
     public function reasons()
     {
         return $this->hasMany(NoteReason::class, 'note_id', 'id');
@@ -98,4 +105,8 @@ class Note extends Model
         return $this->hasOne(NotePickupForProcessing::class, 'id', 'current_note_pickup_for_processing_id');
     }
 
+    public function visitTemplate()
+    {
+        return $this->hasOne(VisitTemplate::class, 'id', 'visit_template_id');
+    }
 }

+ 5 - 0
app/Models/NotePickupForProcessing.php

@@ -13,4 +13,9 @@ class NotePickupForProcessing extends Model
         return $this->hasOne(Pro::class, 'id', 'pro_id');
     }
 
+    public function note()
+    {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
+
 }

+ 88 - 0
app/Models/Point.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class Point extends Model
+{
+    protected $table = 'point';
+
+    public function lastChildReview()
+    {
+        return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');
+    }
+
+    public function lastChildReviewNote()
+    {
+        return $this->hasOne(Note::class, 'id', 'last_child_review_point_scoped_note_id');
+    }
+
+    public function lastChildPlan()
+    {
+        return $this->hasOne(Point::class, 'id', 'last_child_plan_point_id');
+    }
+
+    public function lastChildPlanNote()
+    {
+        return $this->hasOne(Note::class, 'id', 'last_child_plan_point_scoped_note_id');
+    }
+
+    public static function getGlobalSingletonOfCategory(Client $_patient, String $_category, $_assoc = false) {
+        $point = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->orderBy('created_at', 'DESC')
+            ->first();
+        if ($point->data) {
+            $point->data = json_decode($point->data, $_assoc);
+        }
+        return $point;
+    }
+
+    public static function getIntakePointsOfCategory(Client $_patient, String $_category, Note $_note, $_assoc = false) {
+        $points = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->where('addition_reason_category', 'ON_INTAKE')
+            ->where(function ($query1) use ($_note) {
+                $query1
+                    ->where('is_removed', false)
+                    ->orWhere(function ($query2) use ($_note) {
+                        $query2->where('is_removed', true)
+                            ->where('removed_in_note_id', $_note->id);
+                    });
+            })
+            ->orderBy('created_at')
+            ->get();
+        foreach ($points as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data, $_assoc);
+            }
+        }
+        return $points;
+    }
+
+    public static function getPlanPointsOfCategory(Client $_patient, String $_category, Note $_note, $_assoc = false) {
+        $points = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->where('addition_reason_category', 'DURING_VISIT')
+            ->where(function ($query1) use ($_note) {
+                $query1
+                    ->where('is_removed', false)
+                    ->orWhere(function ($query2) use ($_note) {
+                        $query2->where('is_removed', true)
+                            ->where('removed_in_note_id', $_note->id);
+                    });
+            })
+            ->orderBy('created_at')
+            ->get();
+        foreach ($points as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data, $_assoc);
+            }
+        }
+        return $points;
+    }
+}

+ 10 - 0
app/Models/Pro.php

@@ -14,6 +14,7 @@ class Pro extends Model
 
     public function displayName() {
         $name = [];
+        if(!empty($this->name_display)) return $this->name_display;
         if(!empty($this->name_last)) $name[] = $this->name_last;
         if(!empty($this->name_first)) $name[] = $this->name_first;
         if(!count($name)) {
@@ -125,6 +126,11 @@ class Pro extends Model
             ->orderBy('position_index', 'asc');
     }
 
+    public function visitTemplates() {
+        //TODO: use visit access
+        return VisitTemplate::all();
+    }
+
     public function currentWork() {
         return ProClientWork::where('pro_id', $this->id)->where('is_active', true)->first();
     }
@@ -581,4 +587,8 @@ class Pro extends Model
         return $this->hasOne(CompanyPro::class, 'id', 'default_company_pro_id');
     }
 
+    public function currentNotePickupForProcessing() {
+        return $this->hasOne(NotePickupForProcessing::class, 'id', 'current_note_pickup_for_processing_id');
+    }
+
 }

+ 22 - 0
app/Models/Segment.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class Segment extends Model
+{
+    protected $table = 'segment';
+
+    public function segmentTemplate() {
+        return $this->hasOne(SegmentTemplate::class, 'id', 'segment_template_id');
+    }
+
+    public function note() {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+}

+ 11 - 0
app/Models/SegmentTemplate.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class SegmentTemplate extends Model
+{
+    protected $table = 'segment_template';
+
+}

+ 10 - 0
app/Models/VisitTemplate.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class VisitTemplate extends Model
+{
+    protected $table = 'visit_template';
+}

+ 3 - 1
config/app.php

@@ -65,7 +65,9 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 6,
+    'asset_version' => 9,
+
+    'temp_dir' => env('TEMP_DIR'),
 
     /*
     |--------------------------------------------------------------------------

+ 15 - 0
config/database.php

@@ -78,6 +78,21 @@ return [
             'sslmode' => 'prefer',
         ],
 
+        'pgsql_fdb' => [
+            'driver' => 'pgsql',
+            'url' => env('DATABASE_URL'),
+            'host' => env('DB_HOST_FDB', '127.0.0.1'),
+            'port' => env('DB_PORT_FDB', '5432'),
+            'database' => env('DB_DATABASE_FDB', 'forge'),
+            'username' => env('DB_USERNAME_FDB', 'forge'),
+            'password' => env('DB_PASSWORD_FDB', ''),
+            'charset' => 'utf8',
+            'prefix' => '',
+            'prefix_indexes' => true,
+            'schema' => 'public',
+            'sslmode' => 'prefer',
+        ],
+
         'sqlsrv' => [
             'driver' => 'sqlsrv',
             'url' => env('DATABASE_URL'),

+ 347 - 0
fdb_notes.txt

@@ -0,0 +1,347 @@
+medSuggest
+https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
+Retrieve the MED Medication Name ID (MED_NAME_ID) from the MED Medication Name Table (RMINMID1_MED_NAME) where the MED Medication Name (MED_NAME) equals the given drug.
+"SELECT med_name_id, med_name FROM rminmid1_med_name WHERE med_status_cd = '0' AND med_name ILIKE :term ORDER BY med_name",
+['term' => '%' . $term . '%']
+
+SELECT * FROM rminmid1_med_name LIMIT 5;
+ med_name_id |           med_name            | med_name_type_cd | med_status_cd 
+-------------+-------------------------------+------------------+---------------
+           1 | sertraline                    | 2                | 0
+           2 | Acetaminophen-Hydrocodone     | 1                | 1
+           3 | hydrocodone-carbinox-pseudoep | 2                | 3
+           4 | Phenylhistine DH              | 1                | 3
+           5 | denture care products         | 2                | 3
+
+
+
+routedMeds
+https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
+Retrieve the Routed Medication ID (ROUTED_MED_ID) and MED Routed Medication Description (MED_ROUTED_MED_ID_DESC) values from the MED Routed Medication Table (RMIRMID1_ROUTED_MED) where the MED Medication Name (MED_NAME_ID) equals the value retrieved in the previous step and the MED Medication Status Code (MED_STATUS_CD) value equals 0 (active). 
+"SELECT routed_med_id, med_routed_med_id_desc FROM rmirmid1_routed_med WHERE med_status_cd = '0' AND med_name_id = :medNameID ORDER BY med_routed_med_id_desc",
+['medNameID' => $medNameID]
+ SELECT * FROM rmirmid1_routed_med  WHERE med_name_id = 1; 
+ routed_med_id | med_name_id | med_route_id | med_routed_med_id_desc | med_status_cd 
+---------------+-------------+--------------+------------------------+---------------
+             1 |           1 |           24 | sertraline oral        | 0
+
+
+routedDosages
+https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
+Retrieve the MED Routed Dosage Form Med ID (ROUTED_DOSAGE_FORM_MED_ID) and from the MED Routed Dosage Form Medication Table (RMIDFID1_ROUTED_DOSE_FORM_MED) where the MED Routed Medication ID (ROUTED_MED_ID) equals the value retrieved in step 2 and th
+"SELECT routed_dosage_form_med_id, med_routed_df_med_id_desc FROM rmidfid1_routed_dose_form_med WHERE med_status_cd = '0' AND routed_med_id = :routedMedID ORDER BY med_routed_df_med_id_desc",
+['routedMedID' => $routedMedID]
+SELECT * FROM rmidfid1_routed_dose_form_med WHERE routed_med_id = 1;
+ routed_dosage_form_med_id | routed_med_id | med_dosage_form_id |  med_routed_df_med_id_desc  | med_status_cd 
+---------------------------+---------------+--------------------+-----------------------------+---------------
+                         1 |             1 |                 81 | sertraline tablet           | 0
+                     20735 |             1 |                 10 | sertraline oral concentrate | 0
+
+
+meds
+https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
+Retrieve the Medication Identifier (MEDID) and MED Medication Description (MED_MEDID_DESC) values from the MED Medication Table (RMIID1_MED) where the MED Routed Dosage Form Med ID (ROUTED_DOSAGE_FORM_MED_ID) equals the value retrieved in the previous step and the MED Medication Status Code (MED_STATUS_CD) value equals 0 (active).
+"SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE med_status_cd = '0' AND routed_dosage_form_med_id = :dosageFormMedId ORDER BY med_medid_desc",
+['dosageFormMedId' => $dosageFormMedId]
+\d rmiid1_med
+Table "public.rmiid1_med"
+          Column           |         Type          | Collation | Nullable | Default 
+---------------------------+-----------------------+-----------+----------+---------
+ medid                     | numeric(8,0)          |           | not null | 
+ routed_dosage_form_med_id | numeric(8,0)          |           | not null | 
+ med_strength              | character varying(15) |           |          | 
+ med_strength_uom          | character varying(15) |           |          | 
+ med_medid_desc            | character varying(70) |           | not null | 
+ gcn_seqno                 | numeric(6,0)          |           | not null | 
+ med_gcnseqno_assign_cd    | character varying(1)  |           | not null | 
+ med_name_source_cd        | character varying(1)  |           | not null | 
+ med_ref_fed_legend_ind    | character varying(1)  |           | not null | 
+ med_ref_dea_cd            | character varying(1)  |           | not null | 
+ med_ref_multi_source_cd   | character varying(1)  |           | not null | 
+ med_ref_gen_drug_name_cd  | character varying(1)  |           | not null | 
+ med_ref_gen_comp_price_cd | character varying(1)  |           | not null | 
+ med_ref_gen_spread_cd     | character varying(1)  |           | not null | 
+ med_ref_innov_ind         | character varying(1)  |           | not null | 
+ med_ref_gen_thera_equ_cd  | character varying(1)  |           | not null | 
+ med_ref_desi_ind          | character varying(1)  |           | not null | 
+ med_ref_desi2_ind         | character varying(1)  |           | not null | 
+ med_status_cd             | character varying(1)  |           | not null | 
+ generic_medid             | numeric(8,0)          |           |          |
+
+sideEffects
+https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+List+of+Side+Effects
+-- Query the GCN_SEQNO column of the SIDE GCN_SEQNO/Drug Side Effect Code Relation Table (RSIDEGC0_GCNSEQNO_LINK) using the drug’s Clinical Formulation ID (GCN_SEQNO) value to retrieve all of its related SIDE Side Effects Code (SIDE) values.
+-- Query the SIDE column of the SIDE Master Table (RSIDEMA3_MSTR) using each SIDE value from the previous step to retrieve the following columns:
+	-- SIDE Frequency of Occurrence Code (SIDE_FREQ)
+	-- SIDE Severity Code (SIDE_SEV)
+	-- FML Disease Identifier (DXID)
+-- Follow the process described in the FML module’s Finding DXID Descriptions and Synonyms application to find each DXID value’s Primary Layman Name.
+SELECT r1.side, sm.side_freq, sm.side_sev, sm.dxid, dx.dxid_desc56 
+FROM rsidegc0_gcnseqno_link r1 
+    JOIN rsidema3_mstr sm ON r1.side = sm.side
+    JOIN rfmldx0_dxid dx ON sm.dxid = dx.dxid
+WHERE r1.gcn_seqno = :gcnSeqNo
+ORDER BY sm.side_sev DESC, sm.side_freq ASC
+['gcnSeqNo' => $gcnSeqNo]
+-- get a drug(routed dosage med) gcn_seqno 
+SELECT gcn_seqno FROM rmiid1_med WHERE routed_dosage_form_med_id  = 20735;
+ gcn_seqno 
+-----------
+     46230
+
+-- get side effects for the genseq
+SELECT * FROM rsidegc0_gcnseqno_link WHERE gcn_seqno = 46230;
+ gcn_seqno | side 
+-----------+------
+     46230 |  560
+     46230 | 2451
+
+
+-- get side effect details 
+SELECT * FROM RSIDEMA3_MSTR WHERE side = 560;
+ side | side_sn |   fdbdx   | side_freq | side_sev | side_viscd | side_labcd | side_phys | side_hyper | dxid  
+------+---------+-----------+-----------+----------+------------+------------+-----------+------------+-------
+  560 |       0 | 03.276100 | 2         | 1        | 2          | 1          | 1         |            |   736
+  560 |       1 | 05.296000 | 2         | 1        | 1          | 0          | 1         |            |   950
+  560 |       2 | 05.296010 | 2         | 1        | 1          | 0          | 1         |            |   951
+  560 |       3 | 05.300007 | 2         | 0        | 1          | 0          | 0         |            | 14664
+  560 |       4 | 05.300906 | 2         | 1        | 1          | 0          | 1         |            |   985
+  560 |       5 | 05.302700 | 0         | 1        | 1          | 0          | 1         |            |   992
+  560 |       6 | 05.302701 | 0         | 1        | 1          | 0          | 1         |            |   993
+  560 |       7 | 05.307900 | 1         | 0        | 1          | 0          | 0         |            |  1018
+
+-- side_feq dictionary 
+1 = Incidence less frequent
+0 = Incidence more frequent
+2 = Incidence rare or very rare
+
+-- side_sev dictionary
+0 = “less severe” if it is non-threatening (such as constipation)
+1 = “severe” if it may be life-threatening (such as agranulocytosis)
+
+-- get the description for a side effect using  dxid 
+SELECT * FROM rfmldx0_dxid WHERE dxid = 736;
+ dxid | dxid_desc56  | dxid_desc100 | dxid_status |   fdbdx   | dxid_disease_duration_cd 
+------+--------------+--------------+-------------+-----------+--------------------------
+  736 | hyponatremia | hyponatremia | 0           | 03.276100 | 3
+
+
+geriatricPrecautions
+https://docs.fdbhealth.com/display/MKDOCUS/Application%3A+Screening+a+Drug+for+Geriatric+Precautions
+-- Select Geriatric Precaution Code (GERI_CODE) from the GERI GCN_SEQNO Link Table (RGERIGC0_GERI_GCNSEQNO_LINK) where the Clinical Formulation ID (GCN_SEQNO) column equals the Clinical Formulation ID (GCN_SEQNO) of the drug to screen.
+-- Select GERI precautions information from the Geriatric Precautions Master Table (RGERIMA1_GERI_MSTR) where the GERI_CODE column equals the GERI_CODE value from the previous step.
+SELECT r1.geri_code, gm.geri_sl, gm.geri_desc, gm.geri_narrative
+FROM rgerigc0_geri_gcnseqno_link r1 
+JOIN rgerima1_geri_mstr gm ON r1.geri_code = gm.geri_code
+WHERE r1.gcn_seqno = :gcnSeqNo
+ORDER BY gm.geri_desc
+['gcnSeqNo' => $gcnSeqNo]
+-- select geriatricPrecautions based for a given drug formulation code 
+SELECT * FROM RGERIGC0_GERI_GCNSEQNO_LINK WHERE gcn_seqno = 46230 LIMIT 5 ;
+ gcn_seqno | geri_code 
+-----------+-----------
+     46230 |       831
+-- get the meaning of the geri_code 
+SELECT geri_code, geri_desc, geri_narrative FROM RGERIMA1_GERI_MSTR WHERE geri_code = 831;
+ geri_code | geri_desc  |                                                                                                                            geri_narrative                                                                                                                             
+-----------+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+       831 | Sertraline | Hepatic-Mild hepatic impairment of aging may predispose the elderly to increased serum levels and increased adverse events.  Endocrine-May exacerbate or cause SIADH
+ or hyponatremia. Monitor sodium level closely when starting or changing dosages in older adults.
+
+
+indications
+https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+Drug%27s+List+of+Indications
+Indications refers to the use of that drug for treating a particular disease
+-- Retrieve the INDM Indications Code (INDCTS) associated to the drug product’s Clinical Formulation ID (GCN_SEQNO) using the INDM GCN_SEQNO/Drug Indications Code Relation Table (RINDMGC0_INDCTS_GCNSEQNO_LINK).
+-- For each Clinical Formulation ID (GCN_SEQNO)/INDCTS combination retrieved in step 2, retrieve the following columns from the INDM Master Table (RINDMMA2_INDCTS_MSTR):
+	-- INDM Sequence Number (INDCTS_SN)
+	-- INDM Labeled Code (INDCTS_LBL)
+	-- FML Disease Identifier (DXID)
+	-- INDM Proxy Indicator (PROXY_IND)
+-- Get the description from https://docs.fdbhealth.com/display/MKDOCUS/Finding+DXID+Descriptions+and+Synonyms
+	-- For DxID 00000595’s Primary Professional Name, find its associated FML 56-character Description column (DXID_DESC56) and FML 100-character Description column (DXID_DESC100) in the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
+SELECT r1.indcts, r2.indcts_sn, r2.indcts_lbl, r2.dxid, r2.proxy_ind, r3.dxid_desc56
+FROM rindmgc0_indcts_gcnseqno_link r1 
+    JOIN rindmma2_indcts_mstr r2 ON r1.indcts = r2.indcts
+    JOIN rfmldx0_dxid r3 ON r2.dxid = r3.dxid
+WHERE r1.gcn_seqno = :gcnSeqNo
+ORDER BY r3.dxid_desc56
+['gcnSeqNo' => $gcnSeqNo]
+-- Select indications for a given gcn_seqno 
+SELECT * FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE gcn_seqno = 46230;
+ gcn_seqno | indcts 
+-----------+--------
+     46230 |    201
+-- get the details of the indicts 
+SELECT * FROM RINDMMA2_INDCTS_MSTR WHERE indcts = 201 AND proxy_ind <> 'Y' LIMIT 5;
+ indcts | indcts_sn | indcts_lbl |   fdbdx   | dxid  | proxy_ind | pred_code 
+--------+-----------+------------+-----------+-------+-----------+-----------
+    201 |         0 | U          | 05.296500 | 12862 | N         | 3
+    201 |         1 | U          | 05.298001 |  8464 | N         | 3
+    201 |         2 | L          | 05.300010 |   970 | N         | 2
+    201 |         3 | L          | 05.300230 |   975 | N         | 2
+    201 |         4 | L          | 05.300300 |   976 | N         | 3
+NB: to remove Non-FDA approved, add where indcts_lbl <> 'U'; //U == unlabeled
+-- get the meaning of DXIDs 
+SELECT * FROM RFMLDX0_DXID WHERE dxid IN (970, 975, 976);
+ dxid |          dxid_desc56          |         dxid_desc100          | dxid_status |   fdbdx   | dxid_disease_duration_cd 
+------+-------------------------------+-------------------------------+-------------+-----------+--------------------------
+  970 | panic disorder                | panic disorder                | 0           | 05.300010 | 1
+  975 | social phobia                 | social phobia                 | 0           | 05.300230 | 2
+  976 | obsessive-compulsive disorder | obsessive-compulsive disorder | 0           | 05.300300 | 2
+
+
+contraindications
+https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+List+of+Drug+Contraindications
+-- Get drug ddxcn from rddcmrm0_routed_med_link
+-- Retrieve the FML Disease Identifier (DXID) values associated with DDXCN 50225 from the DDCM Master Table (RDDCMMA1_CONTRA_MSTR).
+-- Retrieve the FML 100-Character Description (DXID_DESC100) for each DXID value using the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
+SELECT r1.ddxcn, r2.dxid, r2.ddxcn_sl, r3.dxid_desc56
+FROM rddcmrm0_routed_med_link r1 
+    JOIN rddcmma1_contra_mstr r2 ON r1.ddxcn = r2.ddxcn
+    JOIN rfmldx0_dxid r3 ON r2.dxid = r3.dxid
+WHERE r1.routed_med_id = :routedMedID
+ORDER BY r2.ddxcn_sl
+['routedMedID' => $routedMedID]
+
+-- get drug disease contraindications for a given routed_med_id 
+SELECT * FROM RDDCMRM0_ROUTED_MED_LINK  WHERE routed_med_id = 1;
+ routed_med_id | ddxcn 
+---------------+-------
+             1 | 50005
+-- get the details of ddxcn 
+SELECT * FROM RDDCMDD0_CONTRA_DRUG_DESC WHERE ddxcn = 50005;
+ ddxcn | ddxcn_drug_desc 
+-------+-----------------
+ 50005 | SERTRALINE
+
+-- get dxid associated with the ddxcn (get disease id associated with the contraindications)
+SELECT * FROM RDDCMMA1_CONTRA_MSTR WHERE ddxcn = 50005; 
+ddxcn | ddxcn_sn |   fdbdx   | ddxcn_sl |         ddxcn_ref          | dxid  
+-------+----------+-----------+----------+----------------------------+-------
+ 50005 |        0 | 03.276100 | 3        | ZOLOFT PI, 12/2016         |   736
+ 50005 |        1 | 03.253600 | 3        | ZOLOFT PI, 12/2016         |   624
+ 50005 |        2 | 04.286906 | 3        | ZOLOFT PI, 12/2016         |   867
+ 50005 |        3 | 05.296700 | 3        | ZOLOFT PI, 12/2016         |   954
+ 50005 |        4 | 05.300906 | 2        | MEDWATCH, 3/04, PI 5/14    |   985
+ 50005 |        5 | 09.573900 | 2        | ZOLOFT PI, 12/2016         |  2202
+
+-- get human readable meanings of the dxid 
+SELECT * FROM RFMLDX0_DXID WHERE dxid IN (736,624,867,954,985,2202);
+ dxid |        dxid_desc56         |        dxid_desc100        | dxid_status |   fdbdx   | dxid_disease_duration_cd 
+------+----------------------------+----------------------------+-------------+-----------+--------------------------
+  624 | SIADH syndrome             | SIADH syndrome             | 0           | 03.253600 | 3
+  736 | hyponatremia               | hyponatremia               | 0           | 03.276100 | 3
+  867 | increased risk of bleeding | increased risk of bleeding | 0           | 04.286906 | 2
+  954 | bipolar disorder           | bipolar disorder           | 0           | 05.296700 | 2
+  985 | suicidal ideation          | suicidal ideation          | 0           | 05.300906 | 3
+ 2202 | disease of liver           | disease of liver           | 0           | 09.573900 | 2
+
+
+dxSuggest
+https://docs.fdbhealth.com/display/MKDOCUS/Finding+DXID+Descriptions+and+Synonyms
+-- For DxID 00000595’s Primary Professional Name, find its associated FML 56-character Description column (DXID_DESC56) and FML 100-character Description column (DXID_DESC100) in the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
+-- For DxID 00000595’s Professional Synonyms, find its associated FML 56-character Synonym Description (DXID_SYN_DESC56) and FML 100-character Synonym Description (DXID_SYN_DESC100) in the FML Disease Identifier (DxID) Synonym Table (RFMLSYN0_DXID_SYN). Specify a value of 01 for the FML Name Type Code (DXID_SYN_NMTYP) to signify that you wish to retrieve this DxID’s Professional Synonyms.
+-- i.e search where term matches in the main table (rfmldx0_dxid) and in the synonyms table (rfmlsyn0_dxid_syn) on both 56 and 100 character descriptions
+SELECT distinct(r1.dxid), r1.dxid_desc56 
+FROM rfmldx0_dxid r1
+JOIN rfmlsyn0_dxid_syn r2 ON r1.dxid = r2.dxid
+WHERE (r1.dxid_desc56 ILIKE :term OR r1.dxid_desc100 ILIKE :term OR r2.dxid_syn_desc56 ILIKE :term OR r2.dxid_syn_desc100 ILIKE :term)
+ORDER BY r1.dxid_desc56
+['term' => '%' . $term . '%']
+-- DX has 
+	- Primary Professional Name: one and only one - RFMLDX0_DXID
+	RFMLSYN0_DXID_SYN
+	- Professional Synonym: zero, one, or many -  dxid_syn_nmtyp = 01
+	- Primary Layman Name: zero, one, or many - dxid_syn_nmtyp = 02
+	- Layman Synonym: zero, one, or many - dxid_syn_nmtyp = 03
+	- Abbreviation: zero, one, or many - dxid_syn_nmtyp = 04
+ SELECT * FROM RFMLDX0_DXID WHERE dxid = '595';
+ dxid |       dxid_desc56        |       dxid_desc100       | dxid_status |   fdbdx   | dxid_disease_duration_cd 
+------+--------------------------+--------------------------+-------------+-----------+--------------------------
+  595 | type 1 diabetes mellitus | type 1 diabetes mellitus | 0           | 03.250010 | 2
+
+-- get synonyms: 
+ SELECT * FROM RFMLSYN0_DXID_SYN WHERE dxid = 595 AND dxid_syn_nmtyp = '01';
+ dxid_synid | dxid | dxid_syn_nmtyp |           dxid_syn_desc56           |          dxid_syn_desc100           | dxid_syn_status 
+------------+------+----------------+-------------------------------------+-------------------------------------+-----------------
+        384 |  595 | 01             | juvenile diabetes                   | juvenile diabetes                   | 0
+        387 |  595 | 01             | insulin-dependent DM                | insulin-dependent DM                | 0
+        388 |  595 | 01             | insulin-dependent diabetes mellitus | insulin-dependent diabetes mellitus | 0
+        389 |  595 | 01             | ketosis-prone diabetes mellitus     | ketosis-prone diabetes mellitus     | 0
+        390 |  595 | 01             | ketosis-prone diabetes              | ketosis-prone diabetes              | 0
+        391 |  595 | 01             | juvenile-onset diabetes             | juvenile-onset diabetes             | 0
+        392 |  595 | 01             | juvenile-onset diabetes mellitus    | juvenile-onset diabetes mellitus    | 0
+        393 |  595 | 01             | juvenile onset DM                   | juvenile onset DM                   | 0
+        394 |  595 | 01             | type I diabetes mellitus            | type I diabetes mellitus            | 0
+        395 |  595 | 01             | diabetes mellitus type 1            | diabetes mellitus type 1            | 0
+        396 |  595 | 01             | ketosis-prone DM                    | ketosis-prone DM                    | 0
+      58331 |  595 | 01             | insulin dependent diabetes mellitus | insulin dependent diabetes mellitus | 0
+      58407 |  595 | 01             | immune mediated diabetes mellitus   | immune mediated diabetes mellitus   | 0
+
+
+allergySuggest
+https://docs.fdbhealth.com/display/MKDOCUS/Recording+Patient+Allergy+Information
+-- Query the DAM Allergen Concept ID Description column (DAM_CONCEPT_ID_DESC) in the RDAMAPM0_ALRGN_PICKLIST_MSTR table or the RDAMCA0_CONCEPT table to find all entries with the description “carbamates."
+SELECT r1.dam_concept_id, r1.dam_concept_id_typ, r1.dam_concept_id_desc
+FROM rdamca0_concept r1
+WHERE (r1.dam_concept_id_desc ILIKE :term)
+ORDER BY r1.dam_concept_id_desc
+
+
+drugDrugInteraction
+https://docs.fdbhealth.com/display/MKDOCUS/Screening+for+Active+and+Inactive+Ingredient+Drug-Drug+Interactions
+
+drugCoadministration
+https://docs.fdbhealth.com/display/MKDOCUS/Displaying+Coadministration+Text
+
+duplicateTherapy
+https://docs.fdbhealth.com/display/MKDOCUS/Detecting+Therapeutic+Class+Duplications
+-- Retrieve the Routed Medication ID (ROUTED_MED_ID) in the DPT Routed Medication ID Table(rmirmid1_routed_med), or Routed Generic Identifier (ROUTED_GEN_ID) in the DPT Routed Generic Table, or Clinical Formulation ID (GCN_SEQNO) in the DPT GCN_SEQNO Table for the newly prescribed (prospective) drug and for each drug in the patient profile (profiled drugs).
+-- Retrieve the associated DPT Class Identifiers (DPT_CLASS_ID) from the DPT Class Table (RDPTCL0_CLASS_ID) for each prospective drug and each profiled drug.
+-- Compare the DPT_CLASS_IDs and retrieve the DPT Class Description (DPT_CLASS_DESC) record from the RDPTCL0_CLASS_ID table when Duplicate Therapy Class matches occur.
+-- Compare the number of times that a match of a given class is returned with the DPT Duplication Allowance (DPT_ALLOWANCE) from the RDPTCL0_CLASS_ID table. If the number of matches exceeds the DPT_ALLOWANCE value, a duplicate therapy exists. In most instances, the duplication allowance is zero. Programming for a duplication allowance of one or more should occur only for drugs in the same class that are used concurrently, per accepted medical practice.
+
+=====================================================================================================
+Get drugs used to treat a given condition 
+-- get dxid for the condition eg. 'social phobia'
+SELECT * FROM RFMLDX0_DXID WHERE dxid_desc56 ILIKE 'social%';
+ dxid |  dxid_desc56  | dxid_desc100  | dxid_status |   fdbdx   | dxid_disease_duration_cd 
+------+---------------+---------------+-------------+-----------+--------------------------
+  975 | social phobia | social phobia | 0           | 05.300230 | 2
+
+-- get indcts for the condition 
+SELECT DISTINCT(indcts) FROM RINDMMA2_INDCTS_MSTR WHERE dxid = 975 AND proxy_ind <> 'Y' AND indcts_lbl <> 'U';
+ indcts 
+--------
+    201
+   1006
+   1457
+   1695
+
+-- get clinical formulations (gcn_seqno) for the above indcts 
+SELECT * FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695);
+ gcn_seqno | indcts 
+-----------+--------
+     46222 |   1006
+     46223 |   1006
+     46224 |   1006
+     46225 |   1006
+     46226 |   1006
+....
+
+-- get drugs that contain this gcn_seqno 
+SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE gcn_seqno IN (SELECT gcn_seqno FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695));
+SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE gcn_seqno IN (SELECT gcn_seqno FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695));
+ medid  |                    med_medid_desc                     | gcn_seqno 
+--------+-------------------------------------------------------+-----------
+ 157825 | paroxetine ER 37.5 MG tablet,extended release 24 hr   |     50138
+ 159557 | venlafaxine ER 37.5 mg capsule,extended release 24 hr |     46403
+ 160594 | venlafaxine ER 75 mg capsule,extended release 24 hr   |     46404
+ 162880 | paroxetine 10 mg tablet                               |     46222
+ 165384 | Effexor XR 75 mg capsule,extended release             |     46404
+ 166110 | Paxil CR 37.5 MG tablet,extended release              |     50138
+ 182739 | Effexor XR 37.5 mg capsule,extended release           |     46403
+ 183163 | Paxil 20 mg tablet                                    |     46223
+ 184142 | Paxil 10 mg/5 mL oral suspension                      |     46226
+ 187550 | sertraline 100 mg tablet                              |     46229

+ 126 - 1
public/css/style.css

@@ -292,6 +292,9 @@ body>nav.navbar {
 .mcp-theme-1 .width-50px {
     width: 50px !important;
 }
+.mcp-theme-1 .width-60px {
+    width: 60px !important;
+}
 .mcp-theme-1 .width-70px {
     width: 70px !important;
 }
@@ -1018,6 +1021,9 @@ body .node input[type="number"] {
     padding: 0.75rem;
     min-height: 220px;
 }
+.stag-popup.min-height-unset>form {
+    min-height: unset !important;
+}
 .stag-popup.wide>form, .stag-popup.wide>.stag-popup-content {
     width: calc(100% - 4rem);
 }
@@ -1521,7 +1527,7 @@ button.note-templates-trigger-assessment {
 .collapsible-tbody.collapsed {
     display: none;
 }
-#send-fax-pdf-preview {
+#send-fax-pdf-preview, #transmit-pdf-preview {
     max-height: 350px;
     overflow: auto;
     box-shadow: 0 0 2px #ccc;
@@ -1880,4 +1886,123 @@ table.dashboard-stats-table th {
 }
 .min-height-500px {
     min-height: 500px;
+}
+.inline-html-container p {
+    margin-bottom: 0;
+}
+body.in-iframe>.navbar {
+    display: none !important;
+}
+body.in-iframe .stag-content {
+    padding-top: 0 !important;
+}
+body.in-iframe .main-row > .sidebar {
+    top: 0;
+    height: 100%;
+}
+.stag-popup .hide-inside-popup {
+    display: none !important;
+}
+.strike-through {
+    text-decoration: line-through;
+}
+
+/* visit-moe */
+[visit-moe] [url]:not([show]){
+    display: none;
+}
+[visit-moe] {
+    display: inline-block;
+}
+[visit-moe][relative] {
+    position: relative;
+}
+[visit-moe] [url]:not([show]) {
+    z-index: 99999;
+    position: absolute;
+    background-color: white;
+    padding: 10px;
+    border: 1px solid gray;
+}
+[visit-moe][fixed-center] [url]:not([show]) {
+    position: fixed !important;
+    top: 50% !important;
+    left: 50% !important;
+    width: 600px;
+    transform: translate(-50%, -50%) !important;
+}
+[visit-moe] [url][right] {
+    right: 0;
+    min-width: 200px;
+}
+[visit-moe][large] form, [visit-moe][large] [url] {
+    width: 450px;
+}
+[visit-moe][bottom] form {
+    bottom: 100%;
+}
+.note-container {
+    display: flex;
+    align-items: start;
+}
+.note-container .note-lhs-tree {
+    min-width: 220px;
+    max-width: 220px;
+    align-self: stretch;
+    border-right: 1px solid #ddd;
+    padding-top: 0.85rem;
+    height: 300px;
+    overflow: overlay;
+    max-height: calc(100vh - 55px);
+    background-color: #fff;
+}
+.note-container .note-lhs-tree.fixed {
+    position: fixed;
+    top: 55px;
+    max-height: calc(100vh - 55px) !important;
+    height: calc(100vh - 55px) !important;
+}
+.note-container .note-lhs-tree.fixed ~ .note-rhs-content {
+    margin-left: 220px;
+}
+.note-container .note-lhs-tree .note-tree-node.note-tree-heading>a {
+
+}
+.note-container .note-lhs-tree .note-tree-node>a {
+    display: block;
+    padding: 0.15rem 0;
+    padding-left: 0.75rem;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    text-decoration: none;
+    color: #333;
+}
+.note-container .note-lhs-tree .note-tree-node>a:hover {
+    background-color: aliceblue;
+    color: #0d59af !important;
+}
+.note-container .note-lhs-tree .note-tree-node.active>a {
+    background-color: aliceblue;
+    font-weight: bold !important;
+    color: #0d59af !important;
+}
+.note-container .note-lhs-tree .note-tree-children>.note-tree-node>a {
+    padding-left: 2rem;
+}
+.note-container .note-lhs-tree .note-tree-children .note-tree-children>.note-tree-node>a {
+    padding-left: 4rem;
+}
+.note-container .note-rhs-content {
+    flex-grow: 1;
+}
+.spot-highlight {
+    background: aliceblue !important;
+}
+.on-click-menu [menu] {
+    position: absolute;
+    display: none;
+    top: 100%;
+    right: 0;
+    z-index: 1;
 }

+ 6 - 1
public/js/mc.js

@@ -231,7 +231,7 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
     if (_href === '') _href = '/';
 
     // push state
-    if (_history) {
+    if (_history && window.parent === window.top) {
         var target = _href;
         if (target.indexOf('//') !== -1) {
             target = target.split('//')[1];
@@ -248,6 +248,11 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
         }
     }
 
+    // dont show top nav if in iframe
+    if(window !== window.top && window.parent !== window.top) {
+        $('body').addClass('in-iframe');
+    }
+
     if (_useCache && !!fastCache[_href]) {
         onFastLoaded(fastCache[_href], _href, _history);
     } else {

+ 4 - 3
public/js/pro-suggest.js

@@ -100,10 +100,11 @@
                 '</div>').insertAfter(input);
             elem.hide();
 
-            if(!!elem.attr('data-pro-uid')) {
-                $.get('/pro-display-name/' + elem.attr('data-pro-uid'), function(_data) {
+            let proUid = elem.attr('data-pro-uid');
+            if(!!proUid) {
+                $.get('/pro-display-name/' + proUid, function(_data) {
                     input.val(_data).data('original', _data);
-                    elem.empty().append($('<option value="' + elem.attr('data-pro-uid') + '" selected/>').text(_data));
+                    elem.empty().append($('<option value="' + proUid + '" selected/>').text(_data));
                 });
             }
             else {

+ 6 - 0
public/js/show-on-click.js

@@ -8,6 +8,12 @@
                 }
                 else {
                     $(this).text($(this).attr('data-value'));
+
+                    // fire pro event
+                    $.post('/api/proEvent/create', {
+                        proUid: $(this).attr('data-pro-uid'),
+                        event: $(this).attr('data-event'),
+                    }, () => {}, 'json');
                 }
                 return false;
             });

+ 191 - 0
public/js/stag-suggest.js

@@ -0,0 +1,191 @@
+(function () {
+    window.initStagSuggest = function () {
+
+        let suggestionsOuter = null;
+
+        const debounce = (func, wait) => {
+            let timeout;
+            return function executedFunction(...args) {
+                const later = () => {
+                    clearTimeout(timeout);
+                    func(...args);
+                };
+                clearTimeout(timeout);
+                timeout = setTimeout(later, wait);
+            };
+        };
+
+        var lastTerm = '';
+        var returnedFunction = debounce(function (elem) {
+            let term = elem.val();
+            if (!!term && lastTerm !== term) {
+                let ep = $(elem).attr('stag-suggest-ep');
+                $.get(ep + '?term=' + $.trim(term), function (_data) {
+
+                    /*
+                    expected return format:
+                    {
+                        success: true,
+                        data: [
+                            {
+                                x: ...,
+                                y: ...,
+                                text: ...    // "text" key is "mandatory"
+                            },
+                            {
+                                x: ...,
+                                y: ...,
+                                text: ...    // "text" key is "mandatory"
+                            },
+                            ...
+                        ]
+                    }
+                     */
+
+                    suggestionsOuter.empty();
+                    if(!hasResponseError(_data) && _data.data && _data.data.length) {
+                        for (let i = 0; i < _data.data.length; i++) {
+                            let item = $('<a native href="#" class="d-block suggest-item stag-suggest text-nowrap"/>');
+                            for(let x in _data.data[i]) {
+                                if(_data.data[i].hasOwnProperty(x) && x !== 'text') {
+                                    item.attr('data-' + x, _data.data[i][x]);
+                                }
+                            }
+                            item.data('suggest-data', _data.data[i]);
+                            item.html(_data.data[i].text);
+                            suggestionsOuter.append(item);
+                        }
+                    }
+                    else {
+                        suggestionsOuter.html('<span class="d-block no-suggest-items">No matches!</span>');
+                    }
+
+                    suggestionsOuter.removeClass('d-none');
+                }, 'json');
+                lastTerm = term;
+            } else {
+                suggestionsOuter.addClass('d-none');
+            }
+        }, 250);
+
+        function handleKeydown(elem, e) {
+            let term = $.trim(elem.val());
+            let activeItem = suggestionsOuter.find('.suggest-item.active');
+            switch (e.which) {
+                case 27:
+                    suggestionsOuter.addClass('d-none');
+                    return false;
+                case 38:
+                    if (activeItem.prev().length) {
+                        activeItem.prev()
+                            .addClass('active')
+                            .siblings().removeClass('active');
+                        activeItem = suggestionsOuter.find('.suggest-item.active');
+                        if (activeItem.length) {
+                            activeItem[0].scrollIntoView();
+                        }
+                    }
+                    return false;
+                case 40:
+                    if (activeItem.next().length) {
+                        activeItem.next()
+                            .addClass('active')
+                            .siblings().removeClass('active');
+                        activeItem = suggestionsOuter.find('.suggest-item.active');
+                        if (activeItem.length) {
+                            activeItem[0].scrollIntoView();
+                        }
+                    }
+                    return false;
+                case 13:
+                    if (activeItem.length) {
+                        activeItem.first().click();
+                    }
+                    return false;
+                default:
+                    if (!!term) {
+                        suggestionsOuter
+                            .html('<span class="d-block no-suggest-items">Searching...</span>')
+                            .removeClass('d-none');
+                        returnedFunction(elem);
+                    } else {
+                        suggestionsOuter.addClass('d-none');
+                    }
+                    break;
+            }
+        }
+
+        function handleKeypress(elem, e) {
+            var term = $.trim(elem.val());
+            if (!!term) {
+                suggestionsOuter
+                    .html('<span class="d-block no-suggest-items">Searching...</span>')
+                    .removeClass('d-none');
+                returnedFunction(elem);
+            } else {
+                suggestionsOuter.addClass('d-none');
+            }
+        }
+
+        $('[stag-suggest]:not([stag-suggest-initialized])').each(function () {
+            let elem = $(this);
+            elem.next('.stag-suggestions-container').remove();
+            $('<div class="stag-suggestions-container position-relative">' +
+                '<div class="suggestions-outer stag-suggestions position-absolute d-none"></div>' +
+                '</div>').insertAfter(elem);
+
+            elem
+                .off('keydown.stag-suggest')
+                .on('keydown.stag-suggest', function (e) {
+                    suggestionsOuter = $(this).next('.stag-suggestions-container').find('>.suggestions-outer');
+                    return handleKeydown($(this), e);
+                })
+                .off('keypress.stag-suggest')
+                .on('keypress.stag-suggest', function (e) {
+                    suggestionsOuter = $(this).next('.stag-suggestions-container').find('>.suggestions-outer');
+                    return handleKeypress($(this), e);
+                });
+
+            $(this).attr('stag-suggest-initialized', 1);
+        });
+
+        // on auto-suggest selection
+        $(document).off('click', '.suggest-item.stag-suggest');
+        $(document).on('click', '.suggest-item.stag-suggest', function () {
+
+            $('.suggestions-outer.stag-suggestions').addClass('d-none');
+
+            let data = $(this).data('suggest-data'),
+                label = $.trim($(this).text());
+
+            // set value
+            let input = $(this).closest('.position-relative').prev('[stag-suggest]');
+            input.val(label);
+            input.data('suggest-data', data);
+
+            let scope = input.attr('stag-suggest-scope');
+            if(!scope) scope = 'form';
+            scope = $(scope);
+
+            for(let x in data) {
+                if(data.hasOwnProperty(x)) {
+                    input.attr('data-' + x, data[x]);
+
+                    // auto-populate if there's a field matching data-name="x" in the scope
+                    if(scope.find('[data-name="' + x + '"]').length) {
+                        scope.find('[data-name="' + x + '"]').val(data[x]).trigger('change');
+                    }
+
+                }
+            }
+            input.trigger('input');
+            input.trigger('change');
+
+            input.trigger('stag-suggest-selected', [input, data]);
+
+            return false;
+        });
+
+    }
+    addMCInitializer('stag-suggest', window.initStagSuggest);
+})();

+ 108 - 2
resources/views/app/dashboard.blade.php

@@ -203,13 +203,69 @@
 
                 <div class="row">
                     <div class="col-6">
+
+                        <!-- Appointment Updates -->
+                        @if(count($proApptUpdates))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
+                                <table class="table table-sm table-hover table-bordered mb-0">
+                                    <thead>
+                                    <tr>
+                                        <th>Client</th>
+                                        <th>Appt. Date/Time</th>
+                                        <th>Status</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                        @foreach($proApptUpdates as $update)
+                                            <tr>
+                                                <td>{{$update->name_first}} {{$update->name_last}}</td>
+                                                <td>{{friendlier_date_time($update->start_time)}}</td>
+                                                <td>{{$update->status}}</td>
+                                                <td><a href="#" class="ack-pro-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
+                                            </tr>
+                                        @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+
+                        @if(count($naApptUpdates))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
+                                <table class="table table-sm table-hover table-bordered mb-0">
+                                    <thead>
+                                    <tr>
+                                        <th>Client</th>
+                                        <th>Pro</th>
+                                        <th>Appt. Date/Time</th>
+                                        <th>Status</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($naApptUpdates as $update)
+                                        <tr>
+                                            <td>{{$update->name_first}} {{$update->name_last}}</td>
+                                            <td>{{$update->pro_name_first}} {{$update->pro_name_last}}</td>
+                                            <td>{{friendlier_date_time($update->start_time)}}</td>
+                                            <td>{{$update->status}}</td>
+                                            <td><a href="#" class="ack-na-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+
                         <!-- new associations -->
                         @if(count($newMCPAssociations))
                             <div class="mb-3 border rounded px-3 py-2 ack-container">
                                 <p class="pt-1 mb-2"><b>New Patients</b></p>
                                 @foreach($newMCPAssociations as $assoc)
                                     <div class="mb-1">You have been assigned as the MCP for
-                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <span class="d-inline-block width-150px"><a href="/patients/view/{{$assoc->patient->uid}}" class="">{{$assoc->patient->displayName()}}</a>.</span>
                                         <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
                                     </div>
                                 @endforeach
@@ -221,7 +277,7 @@
                                 <p class="pt-1 mb-2"><b>New Patients</b></p>
                                 @foreach($newNAAssociations as $assoc)
                                     <div class="mb-1">You have been assigned as the Care Coordinator for
-                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <span class="d-inline-block width-150px"><a href="/patients/view/{{$assoc->patient->uid}}" class="">{{$assoc->patient->displayName()}}</a>.</span>
                                         <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
                                     </div>
                                 @endforeach
@@ -781,6 +837,56 @@
                     }, 'json');
                     return false;
                 });
+
+            $(document)
+                .off('click', '.ack-pro-appt-update')
+                .on('click', '.ack-pro-appt-update', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let ackContainer = trigger.closest('tbody');
+                                trigger.closest('tr').slideUp('fast', function() {
+                                    $(this).remove();
+                                    if(!ackContainer.find('>tr').length) {
+                                        ackContainer.remove();
+                                    }
+                                });
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+            $(document)
+                .off('click', '.ack-na-appt-update')
+                .on('click', '.ack-na-appt-update', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsClientDefaultNa', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let ackContainer = trigger.closest('tbody');
+                                trigger.closest('tr').slideUp('fast', function() {
+                                    $(this).remove();
+                                    if(!ackContainer.find('>tr').length) {
+                                        ackContainer.remove();
+                                    }
+                                });
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
         }
         addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
     })();

+ 6 - 0
resources/views/app/dashboard/incoming_reports.blade.php

@@ -6,6 +6,8 @@
     <tr>
         <th class="px-2 text-secondary">Created</th>
         <th class="px-2 text-secondary">Patient</th>
+        <th class="px-2 text-secondary">Pro</th>
+        <th class="px-2 text-secondary">Report Date</th>
         <th class="px-2 text-secondary">Report</th>
         <th class="px-2 text-secondary">Title</th>
         <th class="px-2 text-secondary">Category</th>
@@ -26,6 +28,10 @@
                     {{$document->patient->displayName()}}
                 </a>
             </td>
+            <td class="px-2">
+                {{$document->hcp ? $document->hcp->displayName() : '-'}}
+            </td>
+            <td class="px-2">{{ friendly_date_time($document->report_date, false) }}</td>
             <td class="px-2">
                 <div class="d-flex align-items-center">
                     <a class="pdf-viewer-trigger" native target="_blank"

+ 11 - 0
resources/views/app/dashboard/measurements.blade.php

@@ -42,6 +42,7 @@
                             0
                         @endif
                     </td>
+                    <?php /*
                     <td colspan="px-2">
                         <?php
                         $stampEndPoint = '';
@@ -104,6 +105,16 @@
                             </div>
                         @endif
                     </td>
+                    */ ?>
+                    <td class="px-2">
+                        <a native target="_blank"
+                           open-in-stag-popup
+                           update-parent
+                           title="Care Month Matrix: {{date('M Y', strtotime($measurement->care_month_start_date))}}"
+                           href="/patient-care-month-matrix/{{$measurement->care_month_uid}}">
+                            View &amp; Stamp
+                        </a>
+                    </td>
                 </tr>
             <?php endforeach ?>
         @else

+ 12 - 0
resources/views/app/fdb-pg/fdb-allergy-suggest.blade.php

@@ -0,0 +1,12 @@
+@if(!count($matches))
+    <span class="d-block no-suggest-items">No matches!</span>
+@endif
+<?php $activeSet = false; ?>
+@foreach($matches as $match)
+    <a native class="d-block suggest-item fdb-suggest text-nowrap {{ $activeSet ? '' : 'active'  }}" href="#"
+       data-dam-concept-id="{{$match->dam_concept_id}}" data-dam-concept-id-typ="{{$match->dam_concept_id_typ}}">
+        {{$match->dam_concept_id_desc}} <span class="text-sm">({{$match->dam_concept_id_typ == 6 ? 'ingredient' : ($match->dam_concept_id_typ == 1 ? 'allergen group' : 'medication')}})</span>
+    </a>
+    <?php $activeSet = true; ?>
+@endforeach
+

+ 16 - 0
resources/views/app/fdb-pg/fdb-coadministration.blade.php

@@ -0,0 +1,16 @@
+@if(count($coadministration))
+    <div class="d-flex px-2 py-1 bg-white border-bottom align-items-baseline">
+        <span>Count: <b>{{count($coadministration)}}</b></span>
+        <a href="#" class="text-sm ml-auto" onclick="$(this).parent().next('table').toggle(); return false;">Toggle</a>
+    </div>
+    <table class="table table-sm table-striped table-bordered" style="display: none">
+        <tbody>
+        @foreach($coadministration as $item)
+            <tr>
+                <td>{{$item->coadmin_dosing_text}}</td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+@endif
+

+ 25 - 0
resources/views/app/fdb-pg/fdb-contraindications.blade.php

@@ -0,0 +1,25 @@
+@if(!count($contraindications))
+    <span class="d-block no-suggest-items">No contraindications!</span>
+@else
+    <div class="d-flex px-2 py-1 bg-white border-bottom align-items-baseline">
+        <span>Count: <b>{{count($contraindications)}}</b></span>
+        <a href="#" class="text-sm ml-auto" onclick="$(this).parent().next('table').toggle(); return false;">Toggle</a>
+    </div>
+    <table class="table table-sm table-striped table-bordered" style="display: none">
+        <thead>
+        <tr>
+            <th>Severity</th>
+            <th>Contraindication</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($contraindications as $contraindication)
+            <tr>
+                <td class="font-weight-bold">{{$contraindication->ddxcn_sl == 1 ? 'Contraindication' : ($contraindication->ddxcn_sl == 2 ? 'Severe Warning' : 'Moderate Warning')}}</td>
+                <td>{{$contraindication->dxid_desc56}}</td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+@endif
+

+ 12 - 0
resources/views/app/fdb-pg/fdb-dx-suggest.blade.php

@@ -0,0 +1,12 @@
+@if(!count($matches))
+    <span class="d-block no-suggest-items">No matches!</span>
+@endif
+<?php $activeSet = false; ?>
+@foreach($matches as $match)
+    <a native class="d-block suggest-item fdb-suggest text-nowrap {{ $activeSet ? '' : 'active'  }}" href="#"
+       data-dx-id="{{$match->dxid}}">
+        {{$match->dxid_desc56}}
+    </a>
+    <?php $activeSet = true; ?>
+@endforeach
+

+ 27 - 0
resources/views/app/fdb-pg/fdb-geriatric-precautions.blade.php

@@ -0,0 +1,27 @@
+@if(!count($precautions))
+    <span class="d-block no-suggest-items">No geriatric precautions!</span>
+@else
+    <div class="d-flex px-2 py-1 bg-white border-bottom align-items-baseline">
+        <span>Count: <b>{{count($precautions)}}</b></span>
+        <a href="#" class="text-sm ml-auto" onclick="$(this).parent().next('table').toggle(); return false;">Toggle</a>
+    </div>
+    <table class="table table-sm table-striped table-bordered" style="display: none">
+        <thead>
+        <tr>
+            <th>Desc</th>
+            <th>Severity</th>
+            <th>Narrative</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($precautions as $precaution)
+            <tr>
+                <td>{{$precaution->geri_desc}}</td>
+                <td>{{$precaution->geri_sl == 1 ? 'Contraindication' : 'Management or Monitoring Precaution'}}</td>
+                <td>{{$precaution->geri_narrative}}</td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+@endif
+

+ 25 - 0
resources/views/app/fdb-pg/fdb-indications.blade.php

@@ -0,0 +1,25 @@
+@if(!count($indications))
+    <span class="d-block no-suggest-items">No indications!</span>
+@else
+    <div class="d-flex px-2 py-1 bg-white border-bottom align-items-baseline">
+        <span>Count: <b>{{count($indications)}}</b></span>
+        <a href="#" class="text-sm ml-auto" onclick="$(this).parent().next('table').toggle(); return false;">Toggle</a>
+    </div>
+    <table class="table table-sm table-striped table-bordered" style="display: none">
+        <thead>
+        <tr>
+            <th>Indication</th>
+            <th>FDA Approved</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($indications as $indication)
+            <tr>
+                <td class="font-weight-bold">{{$indication->dxid_desc56}}</td>
+                <td>{{$indication->indcts_lbl}}</td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+@endif
+

+ 12 - 0
resources/views/app/fdb-pg/fdb-med-suggest.blade.php

@@ -0,0 +1,12 @@
+@if(!count($matches))
+    <span class="d-block no-suggest-items">No matches!</span>
+@endif
+<?php $activeSet = false; ?>
+@foreach($matches as $match)
+    <a native class="d-block suggest-item fdb-suggest text-nowrap {{ $activeSet ? '' : 'active'  }}" href="#"
+       data-med-name-id="{{$match->med_name_id}}">
+        {{$match->med_name}}
+    </a>
+    <?php $activeSet = true; ?>
+@endforeach
+

+ 667 - 0
resources/views/app/fdb-pg/fdb-rx.blade.php

@@ -0,0 +1,667 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <style>
+      .fdb-suggestions-container .suggestions-outer {
+        right: auto;
+        left: 0;
+      }
+    </style>
+
+    <div class="p-0 mcp-theme-1" id="fdb-pg">
+        <div class="px-3 py-2 bg-light border-bottom d-flex align-items-center font-weight-bold font-size-14">FDB Playground</div>
+        <div class="p-3 bg-light">
+            <div class="row mb-3">
+                <div class="col-6">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Allergies</span>
+                            <a href="#" v-on:click.prevent="addAllergy()" class="ml-3">+ Add</a>
+                        </div>
+                        <table class="table table-sm table-striped table-bordered m-0">
+                        <thead>
+                        <tr>
+                            <th class="border-bottom-0 text-secondary">Allergy</th>
+                            <th class="border-bottom-0 width-100px"></th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr v-for="(item, index) in allergies">
+                            <td class="p-0 position-relative">
+                                <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                                       fdb-allergy-suggest-search :fdb-suggest-group="index">
+                            </td>
+                            <td class="text-center">
+                                <a href="#" v-on:click.prevent="allergies.splice(index, 1); showDrugAllergyNotes();"><i class="fa fa-trash-alt text-danger"></i></a>
+                            </td>
+                        </tr>
+                        </tbody>
+                    </table>
+                    </div>
+                </div>
+                <div class="col-6 pl-0">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Current Problems</span>
+                            <a href="#" v-on:click.prevent="addDx()" class="ml-3">+ Add</a>
+                        </div>
+                        <table class="table table-sm table-striped table-bordered m-0">
+                        <thead>
+                        <tr>
+                            <th class="border-bottom-0 text-secondary">Problem</th>
+                            <th class="border-bottom-0 width-100px"></th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr v-for="(item, index) in dx">
+                            <td class="p-0 position-relative">
+                                <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                                       fdb-dx-suggest-search :fdb-suggest-group="index">
+                            </td>
+                            <td class="text-center">
+                                <a href="#" v-on:click.prevent="dx.splice(index, 1)"><i class="fa fa-trash-alt text-danger"></i></a>
+                            </td>
+                        </tr>
+                        </tbody>
+                    </table>
+                    </div>
+                </div>
+            </div>
+            <div class="bg-white p-3 mb-3 border">
+                <div class="d-flex align-items-baseline mb-2">
+                    <span class="font-size-14 font-weight-bold">Medications</span>
+                    <a href="#" v-on:click.prevent="addRx()" class="ml-3">+ Add</a>
+                </div>
+                <table class="table table-sm table-bordered m-0" style="table-layout: fixed">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0 text-secondary">Medication</th>
+                    <th class="border-bottom-0 text-secondary">Route</th>
+                    <th class="border-bottom-0 text-secondary">Dosage</th>
+                    <th class="border-bottom-0 text-secondary">Strength</th>
+                    <th class="border-bottom-0 text-secondary">Side Effects</th>
+                    <th class="border-bottom-0 text-secondary">Ger. Precautions</th>
+                    <th class="border-bottom-0 text-secondary">Indications</th>
+                    <th class="border-bottom-0 text-secondary">Contraindications</th>
+                    <th class="border-bottom-0 width-100px"></th>
+                </tr>
+                </thead>
+                <tbody>
+                <tr v-for="(item, index) in rx">
+                    <td class="p-0 position-relative">
+                        <input type="text" class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                               fdb-med-suggest-search :fdb-suggest-group="index">
+                    </td>
+                    <td class="p-0 position-relative">
+                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                                fdb-med-suggest-route :fdb-suggest-group="index" v-model="item.routed_med_id"
+                                disabled>
+                        </select>
+                    </td>
+                    <td class="p-0 position-relative">
+                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                                fdb-med-suggest-dosage :fdb-suggest-group="index" v-model="item.routed_dosage_form_med_id"
+                                disabled>
+                        </select>
+                    </td>
+                    <td class="p-0 position-relative">
+                        <select class="rounded-0 border-0 form-control form-control-sm min-width-unset"
+                                fdb-med-suggest-strength :fdb-suggest-group="index" v-model="item.gcn_seqno"
+                                disabled>
+                        </select>
+                    </td>
+
+                    <td class="p-0 overflow-auto side-effects" :fdb-suggest-group="index">
+
+                    </td>
+                    <td class="p-0 overflow-auto geriatric-precautions" :fdb-suggest-group="index">
+
+                    </td>
+                    <td class="p-0 overflow-auto indications" :fdb-suggest-group="index">
+
+                    </td>
+                    <td class="p-0 overflow-auto contraindications" :fdb-suggest-group="index">
+
+                    </td>
+                    <td class="text-center">
+                        <a href="#" v-on:click.prevent="rx.splice(index, 1); showDrugAllergyNotes(); showDrugCoadministrationNotes(); showDuplicateTherapyNotes()"><i class="fa fa-trash-alt text-danger"></i></a>
+                    </td>
+                </tr>
+                </tbody>
+            </table>
+            </div>
+            <div class="row">
+                <div class="col-3">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Drug Allergy Notes</span>
+                        </div>
+                        <div class="drug-allergies"></div>
+                    </div>
+                </div>
+                <div class="col-3 pl-0">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Drug Drug Interaction Notes</span>
+                        </div>
+                        <div class="drug-drug-interaction"></div>
+                    </div>
+                </div>
+                <div class="col-3 pl-0">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Duplicate Therapy Notes</span>
+                        </div>
+                        <div class="duplicate-therapy"></div>
+                    </div>
+                </div>
+                <div class="col-3 pl-0">
+                    <div class="bg-white p-3 border">
+                        <div class="d-flex align-items-baseline mb-2">
+                            <span class="font-size-14 font-weight-bold">Coadministration Notes</span>
+                        </div>
+                        <div class="drug-coadministration"></div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <script>
+        (function() {
+
+            let suggestionsOuter = null;
+
+            const debounce = (func, wait) => {
+                let timeout;
+                return function executedFunction(...args) {
+                    const later = () => {
+                        clearTimeout(timeout);
+                        func(...args);
+                    };
+                    clearTimeout(timeout);
+                    timeout = setTimeout(later, wait);
+                };
+            };
+
+            var lastTerm = '';
+            var returnedFunction = debounce(function (elem) {
+                let term = elem.val();
+                if (!!term && lastTerm !== term) {
+                    let ep = false;
+                    if($(elem).is('[fdb-med-suggest-search]')) {
+                        ep = '/fdb-med-suggest';
+                    }
+                    else if($(elem).is('[fdb-dx-suggest-search]')) {
+                        ep = '/fdb-dx-suggest';
+                    }
+                    else if($(elem).is('[fdb-allergy-suggest-search]')) {
+                        ep = '/fdb-allergy-suggest';
+                    }
+                    $.get(ep + '?term=' + $.trim(term), function (_data) {
+                        suggestionsOuter.html(_data).removeClass('d-none');
+                    });
+                    lastTerm = term;
+                } else {
+                    suggestionsOuter.addClass('d-none');
+                }
+            }, 250);
+
+            function handleKeydown(elem, e) {
+                let term = $.trim(elem.val());
+                let activeItem = suggestionsOuter.find('.suggest-item.active');
+                switch (e.which) {
+                    case 27:
+                        suggestionsOuter.addClass('d-none');
+                        return false;
+                    case 38:
+                        if (activeItem.prev().length) {
+                            activeItem.prev()
+                                .addClass('active')
+                                .siblings().removeClass('active');
+                            activeItem = suggestionsOuter.find('.suggest-item.active');
+                            if (activeItem.length) {
+                                activeItem[0].scrollIntoView();
+                            }
+                        }
+                        return false;
+                    case 40:
+                        if (activeItem.next().length) {
+                            activeItem.next()
+                                .addClass('active')
+                                .siblings().removeClass('active');
+                            activeItem = suggestionsOuter.find('.suggest-item.active');
+                            if (activeItem.length) {
+                                activeItem[0].scrollIntoView();
+                            }
+                        }
+                        return false;
+                    case 13:
+                        if (activeItem.length) {
+                            activeItem.first().click();
+                        }
+                        return false;
+                    default:
+                        if (!!term) {
+                            suggestionsOuter
+                                .html('<span class="d-block no-suggest-items">Searching...</span>')
+                                .removeClass('d-none');
+                            returnedFunction(elem);
+                        } else {
+                            suggestionsOuter.addClass('d-none');
+                        }
+                        break;
+                }
+            }
+
+            function handleKeypress(elem, e) {
+                var term = $.trim(elem.val());
+                if (!!term) {
+                    suggestionsOuter
+                        .html('<span class="d-block no-suggest-items">Searching...</span>')
+                        .removeClass('d-none');
+                    returnedFunction(elem);
+                } else {
+                    suggestionsOuter.addClass('d-none');
+                }
+            }
+
+            function fillSideEffects(_group, _gcn_seqno) {
+                let container = $('.side-effects[fdb-suggest-group=' + _group + ']');
+                container.empty();
+                $.get('/fdb-side-effects?gcn-seq-no=' + _gcn_seqno, _data => {
+                    container.html(_data);
+                });
+            }
+
+            function fillGeriatricPrecautions(_group, _gcn_seqno) {
+                let container = $('.geriatric-precautions[fdb-suggest-group=' + _group + ']');
+                container.empty();
+                $.get('/fdb-geriatric-precautions?gcn-seq-no=' + _gcn_seqno, _data => {
+                    container.html(_data);
+                });
+            }
+
+            function fillIndications(_group, _gcn_seqno) {
+                let container = $('.indications[fdb-suggest-group=' + _group + ']');
+                container.empty();
+                $.get('/fdb-indications?gcn-seq-no=' + _gcn_seqno, _data => {
+                    container.html(_data);
+                });
+            }
+
+            function fillContraindications(_group, _gcn_seqno) {
+                let container = $('.contraindications[fdb-suggest-group=' + _group + ']');
+                container.empty();
+                $.get('/fdb-contraindications?routed-med-id=' + _gcn_seqno, _data => {
+                    container.html(_data);
+                });
+            }
+
+            addMCInitializer('fdb-pg', function() {
+
+                window.fdbPGApp = new Vue({
+                    el: '#fdb-pg',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        allergies: [{
+
+                        }],
+                        dx: [{
+
+                        }],
+                        rx: [{
+
+                        }],
+                    },
+                    methods: {
+                        addRx: function() {
+                            this.rx.push({});
+                            Vue.nextTick(() => {
+                                this.initFDBRxSuggest();
+                                $('[fdb-med-suggest-search]').last().focus();
+                            });
+                        },
+                        addDx: function() {
+                            this.dx.push({});
+                            Vue.nextTick(() => {
+                                this.initFDBDxSuggest();
+                                $('[fdb-dx-suggest-search]').last().focus();
+                            });
+                        },
+                        addAllergy: function() {
+                            this.allergies.push({});
+                            Vue.nextTick(() => {
+                                this.initFDBAllergySuggest();
+                                $('[fdb-allergy-suggest-search]').last().focus();
+                            });
+                        },
+                        showDrugAllergyNotes: function() {
+                            $('.drug-allergies').html('');
+                            if(this.allergies && this.allergies.length && this.rx && this.rx.length) {
+                                $.get('/fdb-drug-allergies', {
+                                    data: JSON.stringify({
+                                        allergies: this.allergies,
+                                        rx: this.rx
+                                    })
+                                }, _data => {
+                                    $('.drug-allergies').html(_data);
+                                });
+                            }
+                        },
+                        showDrugDrugInteractionNotes: function() {
+                            $('.drug-drug-interaction').html('');
+                            if(this.rx && this.rx.length > 1) {
+                                $.get('/fdb-drug-drug-interaction', {
+                                    data: JSON.stringify({
+                                        rx: this.rx
+                                    })
+                                }, _data => {
+                                    $('.drug-drug-interaction').html(_data);
+                                });
+                            }
+                        },
+                        showDrugCoadministrationNotes: function() {
+                            $('.drug-coadministration').html('');
+                            if(this.rx && this.rx.length > 1) {
+                                let gcnSeqNos = [];
+                                for (let i = 0; i < this.rx.length; i++) {
+                                    gcnSeqNos.push(this.rx[i].gcn_seqno);
+                                }
+                                gcnSeqNos = gcnSeqNos.join(",");
+                                $.get('/fdb-drug-coadministration', {
+                                    'gcn-seqnos': gcnSeqNos
+                                }, _data => {
+                                    $('.drug-coadministration').html(_data);
+                                });
+                            }
+                        },
+                        showDuplicateTherapyNotes: function() {
+                            $('.duplicate-therapy').html('');
+                            if(this.rx && this.rx.length > 1) {
+                                $.get('/fdb-duplicate-therapy', {
+                                    data: JSON.stringify({
+                                        rx: this.rx
+                                    })
+                                }, _data => {
+                                    $('.duplicate-therapy').html(_data);
+                                });
+                            }
+                        },
+                        initFDBRxSuggest: function() {
+                            $('[fdb-med-suggest-search]:not([fdb-suggest-initialized])').each(function() {
+                                let elem = $(this);
+                                elem.next('.fdb-suggestions-container').remove();
+                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
+                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
+                                    '</div>').insertAfter(elem);
+
+                                elem
+                                    .off('keydown.fdb-suggest')
+                                    .on('keydown.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeydown($(this), e);
+                                    })
+                                    .off('keypress.fdb-suggest')
+                                    .on('keypress.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeypress($(this), e);
+                                    });
+
+                                $(this).attr('fdb-suggest-initialized', 1);
+                            });
+                        },
+                        initFDBDxSuggest: function() {
+                            $('[fdb-dx-suggest-search]:not([fdb-suggest-initialized])').each(function() {
+                                let elem = $(this);
+                                elem.next('.fdb-suggestions-container').remove();
+                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
+                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
+                                    '</div>').insertAfter(elem);
+
+                                elem
+                                    .off('keydown.fdb-suggest')
+                                    .on('keydown.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeydown($(this), e);
+                                    })
+                                    .off('keypress.fdb-suggest')
+                                    .on('keypress.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeypress($(this), e);
+                                    });
+
+                                $(this).attr('fdb-suggest-initialized', 1);
+                            });
+                        },
+                        initFDBAllergySuggest: function() {
+                            $('[fdb-allergy-suggest-search]:not([fdb-suggest-initialized])').each(function() {
+                                let elem = $(this);
+                                elem.next('.fdb-suggestions-container').remove();
+                                $('<div class="fdb-suggestions-container position-relative" fdb-suggest-group="' + elem.attr('fdb-suggest-group') + '">' +
+                                    '<div class="suggestions-outer fdb-suggestions position-absolute d-none"></div>' +
+                                    '</div>').insertAfter(elem);
+
+                                elem
+                                    .off('keydown.fdb-suggest')
+                                    .on('keydown.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeydown($(this), e);
+                                    })
+                                    .off('keypress.fdb-suggest')
+                                    .on('keypress.fdb-suggest', function (e) {
+                                        suggestionsOuter = $(this).next('.fdb-suggestions-container').find('>.suggestions-outer');
+                                        return handleKeypress($(this), e);
+                                    });
+
+                                $(this).attr('fdb-suggest-initialized', 1);
+                            });
+                        }
+                    },
+                    mounted: function() {
+
+                        let vueApp = this;
+
+                        // on auto-suggest med selection
+                        $(document).off('click', '.suggest-item.fdb-suggest[data-med-name-id]');
+                        $(document).on('click', '.suggest-item.fdb-suggest[data-med-name-id]', function () {
+
+                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');
+
+                            let medNameID = $(this).attr('data-med-name-id'),
+                                label = $.trim($(this).text()),
+                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');
+
+                            // set value
+                            let input = $(this).closest('.position-relative').prev('[fdb-med-suggest-search]');
+                            input.val(label);
+                            input.attr('data-med-name-id', medNameID);
+                            input.trigger('input');
+                            input.trigger('change');
+
+                            // vue value
+                            vueApp.rx[group].rx = label;
+                            vueApp.rx[group].med_name_id = medNameID;
+
+                            $(document).trigger('fdb-med-changed', [group]);
+
+                            return false;
+                        });
+
+                        // on auto-suggest dx selection
+                        $(document).off('click', '.suggest-item.fdb-suggest[data-dx-id]');
+                        $(document).on('click', '.suggest-item.fdb-suggest[data-dx-id]', function () {
+
+                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');
+
+                            let dxID = $(this).attr('data-dx-id'),
+                                label = $.trim($(this).text()),
+                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');
+
+                            // set value
+                            let input = $(this).closest('.position-relative').prev('[fdb-dx-suggest-search]');
+                            input.val(label);
+                            input.attr('data-dx-id', dxID);
+                            input.trigger('input');
+                            input.trigger('change');
+
+                            // vue value
+                            vueApp.dx[group].problem = label;
+                            vueApp.dx[group].dxid = dxID;
+
+                            $(document).trigger('fdb-dx-changed', [group]);
+
+                            return false;
+                        });
+
+                        // on auto-suggest allergy selection
+                        $(document).off('click', '.suggest-item.fdb-suggest[data-dam-concept-id]');
+                        $(document).on('click', '.suggest-item.fdb-suggest[data-dam-concept-id]', function () {
+
+                            $('.suggestions-outer.fdb-suggestions').addClass('d-none');
+
+                            let damConceptID = $(this).attr('data-dam-concept-id'),
+                                damConceptIDTyp = $(this).attr('data-dam-concept-id-typ'),
+                                label = $.trim($(this).text()),
+                                group = $(this).closest('.fdb-suggestions-container').attr('fdb-suggest-group');
+
+                            // set value
+                            let input = $(this).closest('.position-relative').prev('[fdb-allergy-suggest-search]');
+                            input.val(label);
+                            input.attr('data-dam-concept-id', damConceptID);
+                            input.attr('data-dam-concept-id-type', damConceptIDTyp);
+                            input.trigger('input');
+                            input.trigger('change');
+
+                            // vue value
+                            vueApp.allergies[group].allergen = label;
+                            vueApp.allergies[group].dam_concept_id = damConceptID;
+                            vueApp.allergies[group].dam_concept_id_typ = damConceptIDTyp;
+
+                            $(document).trigger('fdb-allergy-changed', [group]);
+
+                            vueApp.showDrugAllergyNotes();
+
+                            return false;
+                        });
+
+                        // med changed, update routes
+                        $(document).off('fdb-med-changed');
+                        $(document).on('fdb-med-changed', function(e, group) {
+
+                            // clear vue values
+                            vueApp.rx[group].routed_med_id = null;
+                            vueApp.rx[group].routed_dosage_form_med_id = null;
+                            vueApp.rx[group].medid = null;
+                            vueApp.rx[group].gcn_seqno = null;
+
+                            let routeSelect = $('[fdb-med-suggest-route][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let dosageSelect = $('[fdb-med-suggest-dosage][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let medNameID = $('[fdb-med-suggest-search][fdb-suggest-group='+group+']').attr('data-med-name-id');
+                            $.get('/fdb-routed-meds?med-name-id=' + medNameID, _data => {
+                                routeSelect
+                                    .empty()
+                                    .append('<option value="">-- select --</option>');
+                                for (let i = 0; i < _data.length; i++) {
+                                    routeSelect.append('<option value="' + _data[i].routed_med_id + '">' + _data[i].med_routed_med_id_desc + '</option>')
+                                }
+                                routeSelect.prop('disabled', false);
+                                if(_data.length === 1) {
+                                    vueApp.rx[group].routed_med_id = _data[0].routed_med_id;
+                                    routeSelect.val(_data[0].routed_med_id).trigger('change');
+                                }
+                            }, 'json');
+                            routeSelect.prop('disabled', false);
+                        });
+
+                        // on route selection
+                        $(document).off('change', '[fdb-med-suggest-route]');
+                        $(document).on('change', '[fdb-med-suggest-route]', function () {
+                            let group = $(this).attr('fdb-suggest-group');
+
+                            // clear vue values
+                            vueApp.rx[group].routed_dosage_form_med_id = null;
+                            vueApp.rx[group].medid = null;
+                            vueApp.rx[group].gcn_seqno = null;
+
+                            let dosageSelect = $('[fdb-med-suggest-dosage][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let routedMedID = $('[fdb-med-suggest-route][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
+                            $.get('/fdb-routed-dosages?routed-med-id=' + routedMedID, _data => {
+                                dosageSelect
+                                    .empty()
+                                    .append('<option value="">-- select --</option>');
+                                for (let i = 0; i < _data.length; i++) {
+                                    dosageSelect.append('<option value="' + _data[i].routed_dosage_form_med_id + '">' + _data[i].med_routed_df_med_id_desc + '</option>')
+                                }
+                                dosageSelect.prop('disabled', false);
+                                if(_data.length === 1) {
+                                    vueApp.rx[group].routed_dosage_form_med_id = _data[0].routed_dosage_form_med_id;
+                                    dosageSelect.val(_data[0].routed_dosage_form_med_id).trigger('change');
+                                }
+                            }, 'json');
+                        });
+
+                        // on dosage selection
+                        $(document).off('change', '[fdb-med-suggest-dosage]');
+                        $(document).on('change', '[fdb-med-suggest-dosage]', function () {
+                            let group = $(this).attr('fdb-suggest-group');
+
+                            vueApp.rx[group].medid = null;
+                            vueApp.rx[group].gcn_seqno = null;
+
+                            let strengthSelect = $('[fdb-med-suggest-strength][fdb-suggest-group='+group+']').empty().prop('disabled', true);
+                            let dosageFormMedID = $('[fdb-med-suggest-dosage][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
+                            $.get('/fdb-meds?dosage-form-med-id=' + dosageFormMedID, _data => {
+                                strengthSelect
+                                    .empty()
+                                    .append('<option value="">-- select --</option>');
+                                for (let i = 0; i < _data.length; i++) {
+                                    strengthSelect.append('<option data-medid="' + _data[i].medid + '" value="' + _data[i].gcn_seqno + '">' + _data[i].med_medid_desc + '</option>')
+                                }
+                                strengthSelect.prop('disabled', false);
+                                if(_data.length === 1) {
+                                    vueApp.rx[group].medid = _data[0].medid;
+                                    vueApp.rx[group].gcn_seqno = _data[0].gcn_seqno;
+                                    strengthSelect.val(_data[0].gcn_seqno).trigger('change');
+                                }
+                            }, 'json');
+                        });
+
+                        // on strength (medid) selection
+                        $(document).off('change', '[fdb-med-suggest-strength]');
+                        $(document).on('change', '[fdb-med-suggest-strength]', function () {
+
+                            let group = $(this).attr('fdb-suggest-group');
+                            vueApp.rx[group].medid = $(this).find('option:selected').attr('data-medid');
+
+                            fillSideEffects($(this).attr('fdb-suggest-group'), $(this).val());
+                            fillGeriatricPrecautions($(this).attr('fdb-suggest-group'), $(this).val());
+                            fillIndications($(this).attr('fdb-suggest-group'), $(this).val());
+
+                            let routedMedID = $('[fdb-med-suggest-route][fdb-suggest-group='+$(this).attr('fdb-suggest-group')+']').val();
+                            fillContraindications($(this).attr('fdb-suggest-group'), routedMedID);
+
+                            vueApp.showDrugAllergyNotes();
+                            vueApp.showDrugDrugInteractionNotes();
+                            vueApp.showDuplicateTherapyNotes();
+                            vueApp.showDrugCoadministrationNotes();
+                        });
+
+                        Vue.nextTick(() => {
+                            this.initFDBAllergySuggest();
+                            this.initFDBDxSuggest();
+                            this.initFDBRxSuggest();
+                            $('[fdb-allergy-suggest-search]').first().focus();
+                        });
+
+                    }
+                })
+
+            }, '#fdb-pg');
+        }).call(window);
+    </script>
+
+@endsection

+ 27 - 0
resources/views/app/fdb-pg/fdb-side-effects.blade.php

@@ -0,0 +1,27 @@
+@if(!count($sides))
+    <span class="d-block no-suggest-items">No side effects!</span>
+@else
+    <div class="d-flex px-2 py-1 bg-white border-bottom align-items-baseline">
+        <span>Count: <b>{{count($sides)}}</b></span>
+        <a href="#" class="text-sm ml-auto" onclick="$(this).parent().next('table').toggle(); return false;">Toggle</a>
+    </div>
+    <table class="table table-sm table-striped table-bordered" style="display: none">
+        <thead>
+        <tr>
+            <th>Side Effect</th>
+            <th>Severity</th>
+            <th>Frequency</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($sides as $side)
+            <tr>
+                <td class="font-weight-bold">{{$side->dxid_desc56}}</td>
+                <td>{{$side->side_sev == 0 ? 'Not Severe' : 'Severe'}}</td>
+                <td>{{$side->side_sev == 0 ? 'High' : ($side->side_sev == 1 ? 'Low' : 'Rare')}}</td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+@endif
+

+ 21 - 21
resources/views/app/guest/appointment-confirmation.blade.php

@@ -25,13 +25,26 @@
                         </p>
                     </div>
 
-                    @if($appointment->status === 'CREATED')
-
-                        <div class="form-group">
-                            <p>Please confirm your appointment</p>
+                    @if(count($appointment->confirmationDecisions))
+                        <p class="mb-2 text-secondary font-weight-bold">Appointment status history</p>
+                        <div class="bg-light px-2 pt-2 border rounded mb-3">
+                            @foreach($appointment->confirmationDecisions as $decision)
+                                <div class="mb-2"><b>{{$decision->accepted_or_rejected_or_waived}}</b> on <b>{{friendlier_date_time($decision->created_at)}}</b>
+                                    @if($decision->session && $decision->session->pro)
+                                        by <b>{{$decision->session->pro->displayName()}}</b>
+                                    @elseif($decision->session && $decision->session->client)
+                                        by <b>{{$decision->session->client->displayName()}}</b>
+                                    @endif
+                                </div>
+                            @endforeach
                         </div>
+                        <p class="text-secondary font-weight-bold mb-2">Update appointment status</p>
+                    @else
+                        <p class="text-secondary font-weight-bold mb-2">Please confirm your appointment</p>
+                    @endif
 
-                        <div class="form-group">
+                    <div class="bg-light px-2 pt-2 border rounded mb-3">
+                        <div class="form-group mb-2">
                             <div class="check d-flex align-items-center mb-2">
                                 <input type="radio" required name="decision" value="ACCEPT" id="appointment_confirmation_accept" class="check-input my-0 mr-2">
                                 <label for="appointment_confirmation_accept" class="check-label my-0">Accept - <b>I confirm my availability at the above mentioned date/time</b></label>
@@ -42,27 +55,14 @@
                             </div>
                         </div>
 
-                        <div class="form-group">
+                        <div class="form-group mb-2">
                             <textarea name="memo" class="form-control form-control-sm" placeholder="Any additional information / reason in case you are rejecting the appointment"></textarea>
                         </div>
 
-                        <div class="form-group">
+                        <div class="form-group mb-2">
                             <button class="btn btn-primary">Submit</button>
                         </div>
-
-                    @else
-
-                        @foreach($appointment->confirmationDecisions as $decision)
-                            <div class="mb-2"><b>{{$decision->accepted_or_rejected}}</b> on <b>{{friendlier_date_time($decision->created_at)}}</b>
-                                @if($decision->session && $decision->session->pro)
-                                    by <b>{{$decision->session->pro->displayName()}}</b>
-                                @elseif($decision->session && $decision->session->client)
-                                    by <b>{{$decision->session->client->displayName()}}</b>
-                                @endif
-                            </div>
-                        @endforeach
-
-                    @endif
+                    </div>
 
                 </form>
                 @endif

+ 7 - 5
resources/views/app/patient/appointment-calendar.blade.php

@@ -141,11 +141,13 @@
                                 :data-pro-uid="newAppointment.proUid"
                                 no-auto-pro-suggest-init
                                 class="form-control form-control-sm">
-                            @foreach($pros as $iPro)
-                                <option value="{{$iPro->uid}}">
-                                    {{$iPro->displayName()}}
-                                </option>
-                            @endforeach
+                            @if($pro->pro_type !== 'ADMIN')
+                                @foreach($pros as $iPro)
+                                    <option value="{{$iPro->uid}}">
+                                        {{$iPro->displayName()}}
+                                    </option>
+                                @endforeach
+                            @endif
                         </select>
                     </div>
                 </div>

+ 254 - 0
resources/views/app/patient/care-month/_matrix.blade.php

@@ -0,0 +1,254 @@
+<?php
+$days = $patient->cmMeasurementsMatrix($careMonth);
+
+$performerRole = false;
+if ($pro->pro_type === 'ADMIN') {
+    $performerRole = 'ADMIN';
+} else if ($careMonth->mcp_pro_id === $pro->id) {
+    $performerRole = 'MCP';
+} else if ($careMonth->rme_pro_id === $pro->id || $careMonth->rmm_pro_id === $pro->id) {
+    $performerRole = 'NON-HCP';
+}
+
+$unstampedMCP = [];
+$unstampedNonHCP = [];
+foreach ($days as $k => $day) {
+    $unstampedMCP[$k] = [];
+    $unstampedNonHCP[$k] = [];
+    foreach ($days[$k] as $mIndex => $m) {
+        if(!$m->has_been_stamped_by_mcp) {
+            $unstampedMCP[$k][] = $m->measurement_uid;
+        }
+        if(!$m->has_been_stamped_by_non_hcp) {
+            $unstampedNonHCP[$k][] = $m->measurement_uid;
+        }
+    }
+}
+
+?>
+<p class="font-weight-bold">Care Month Matrix</p>
+<table class="table table-condensed table-sm table-bordered mt-2 mb-3">
+    <thead>
+    <tr>
+        <th class="px-2 text-secondary align-bottom" rowspan="2">Date</th>
+        <th class="px-2 text-secondary border-bottom-0" colspan="4">Measurements</th>
+        <th class="px-2 text-secondary align-bottom" rowspan="2">{{$performerRole === 'ADMIN' ? 'Stamp Status' : 'Stamp + Entry'}}</th>
+        <th class="px-2 text-secondary" rowspan="2">Entries</th>
+    </tr>
+    <tr>
+        <th class="text-secondary text-sm">Time</th>
+        <th class="text-secondary text-sm">Type</th>
+        <th class="text-secondary text-sm">Value</th>
+        <th class="text-secondary text-sm">Stamp</th>
+    </tr>
+    </thead>
+    <tbody>
+    @foreach($days as $k => $day)
+        @foreach($days[$k] as $mIndex => $m)
+        <tr>
+            @if($mIndex === 0)
+                <td rowspan="{{count($days[$k])}}">
+                    {{$k}}
+                </td>
+            @endif
+            <td>{{$m->time}}</td>
+            <td>
+                @if($m->label === 'BP')
+                    BP
+                @elseif($m->label === 'Wt. (lbs.)')
+                    Weight
+                @endif
+            </td>
+            <td>
+                @if($m->label === 'BP')
+                    {{ $m->sbp_mm_hg }}/{{ $m->dbp_mm_hg }}
+                @elseif($m->label === 'Wt. (lbs.)')
+                    {{ round(floatval($m->numeric_value), 2) }} lbs
+                @endif
+            </td>
+            <td>
+                @if($performerRole === 'MCP')
+                    <div class="width-100px">
+                        @if($m->has_been_stamped_by_mcp)
+                            <span class="text-secondary text-sm">
+                                <i class="fa fa-check"></i>
+                                Stamped
+                            </span>
+                        @else
+                            <div moe relative>
+                                <a href="#" start show>Stamp</a>
+                                <form url="/api/measurement/stampAsMcp" right class="width-300px">
+                                    <input type="hidden" name="uid" value="{{$m->measurement_uid}}">
+                                    <p class="mb-1">Stamp this measurement?</p>
+                                    <div class="mt-2 bg-light border p-2">
+                                        <div class="mb-1 text-secondary">{{ $m->label }}</div>
+                                        <div class="font-weight-bold mb-1">
+                                            @if($m->label === 'BP')
+                                                {{ round($m->sbp_mm_hg, 2) }}/{{ round($m->dbp_mm_hg, 2) }} mmHg
+                                                <span class="font-weight-normal d-inline-block pl-2">Pulse:</span>
+                                                {{ $m->value_pulse }} {{ $m->value_irregular === 0?'Irregular':'' }} {{ $m->value_irregular === 1?'Regular':'' }}
+                                            @elseif($m->label === 'Wt. (lbs.)')
+                                                {{ round($m->numeric_value, 2) }} lbs
+                                            @else
+                                                {{ $m->value }}
+                                            @endif
+                                        </div>
+                                        <div class="text-sm">
+                                            {{ $m->date }} {{ $m->time }} EST
+                                        </div>
+                                    </div>
+                                    <div class="mb-2 border border-info p-2 mt-2 bg-light">
+                                        <span>I have had interactive communication with <b>{{$patient->displayName()}}</b> during this care month.</span>
+                                        <div class="d-flex border-top mt-2">
+                                            <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                                <input type="radio" class="mr-2" name="communicatedToPatient" value="true" required>
+                                                <span>Yes</span>
+                                            </label>
+                                            <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                                <input type="radio" class="mr-2" name="communicatedToPatient" value="false" checked required>
+                                                <span>No</span>
+                                            </label>
+                                        </div>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="mb-1 text-secondary text-sm">Memo</label>
+                                        <textarea class="form-control form-control-sm" name="memo"></textarea>
+                                    </div>
+                                    <div class="form-group m-0">
+                                        <button submit class="btn btn-primary btn-sm mr-2">Submit</button>
+                                        <button cancel class="btn btn-default border btn-sm mr-2">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    </div>
+                @elseif($performerRole === 'NON-MCP')
+                    <div class="width-100px">
+                        @if($m->has_been_stamped_by_non_hcp)
+                            <span class="text-secondary text-sm">
+                                <i class="fa fa-check"></i>
+                                Stamped
+                            </span>
+                        @endif
+                    </div>
+                @endif
+            </td>
+            @if($mIndex === 0)
+                <td rowspan="{{count($days[$k])}}">
+                    @if($performerRole === 'ADMIN')
+                        <div class="my-1">
+                            <span class="text-secondary">MCP Unstamped:</span>
+                            <b class="{{count($unstampedMCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedMCP[$k])}}</b>
+                        </div>
+                        <div class="">
+                            <span class="text-secondary">Non-HCP Unstamped:</span>
+                            <b class="{{count($unstampedNonHCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedNonHCP[$k])}}</b>
+                        </div>
+                    @elseif($performerRole === 'MCP')
+                        @if(count($unstampedMCP[$k]))
+                            <div moe relative class="btn-stamp-all">
+                                <a href="#" start show class="">
+                                    Stamp All &amp; Create Entry
+                                </a>
+                                <form url="/api/measurement/bulkStampAsMcp">
+                                    <input type="hidden" name="measurementUids" value="{{implode('|', $unstampedMCP[$k])}}">
+                                    <p class="mb-1">Stamp all measurements?</p>
+                                    <div class="mb-2 border border-info p-2 mt-2 bg-light width-300px">
+                                        <span>I have had interactive communication with <b>{{$patient->displayName()}}</b> during this care month.</span>
+                                        <div class="d-flex border-top mt-2">
+                                            <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                                <input type="radio" class="mr-2" name="communicatedToPatient" value="true" required>
+                                                <span>Yes</span>
+                                            </label>
+                                            <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                                <input type="radio" class="mr-2" name="communicatedToPatient" value="false" checked required>
+                                                <span>No</span>
+                                            </label>
+                                        </div>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="mb-1 text-secondary text-sm">Memo</label>
+                                        <textarea class="form-control form-control-sm" name="memo"></textarea>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="mb-1 text-secondary text-sm">Minutes</label>
+                                        <input type="number" min="1" max="15" class="form-control form-control-sm w-100" name="entryMinutes"
+                                               value="2" placeholder="Time (mins.)" required>
+                                    </div>
+                                    <div class="form-group m-0">
+                                        <button submit class="btn btn-primary btn-sm mr-2">Submit</button>
+                                        <button cancel class="btn btn-default border btn-sm mr-2">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @else
+                            <span class="text-secondary text-sm d-flex align-items-center">
+                                <i class="fa fa-check mr-2"></i>
+                                <span>All Stamped</span>
+                            </span>
+                        @endif
+                    @elseif($performerRole === 'NON-MCP')
+                    @endif
+                </td>
+                <td rowspan="{{count($days[$k])}}">
+                    @foreach($m->entries as $entry)
+                        <div class="my-1 d-flex align-items-start flex-nowrap">
+                            <b class="mr-2">{{round($entry->time_in_seconds / 60)}}m</b>
+                            <span class="text-secondary mr-2 text-nowrap text-sm">({{date('h:i a', strtotime($entry->created_at))}})</span>
+                            <span class="text-secondary inline-html-container flex-grow-1">{!! $entry->content_text !!}</span>
+                        </div>
+                    @endforeach
+                    @if($performerRole === 'MCP' || $performerRole === 'NON-HCP')
+                        <div moe large>
+                            <a start show class="py-0 mb-3 text-sm">+ Add</a>
+                            <form url="/api/careMonthEntry/createForRm">
+                                <input type="hidden" name="careMonthUid" value="{{ $careMonth->uid }}">
+                                <div class="mb-2">
+                                    <div class="row">
+                                        <div class="col-4 pr-0">
+                                            <select class="form-control form-control-sm w-100" name="proUid" provider-search data-pro-uid="{{ @$pro->uid }}"
+                                                    required>
+                                                <option value="">-- Select Pro --</option>
+                                            </select>
+                                        </div>
+                                        <div class="col-4 pr-0">
+                                            <?php
+                                            $sD = strtotime($careMonth->start_date);
+                                            $y = date('Y', $sD);
+                                            $m0 = date('m', $sD);
+                                            $d = date('t', $sD);
+                                            $yCurrent = date('Y');
+                                            $mCurrent = date('m');
+                                            ?>
+                                            <input autofocus type="date" min="{{ date($y . '-' . $m0 . '-01') }}" max="{{ date($y . '-' . $m0 . '-' . $d) }}"
+                                                   value="{{$m->dateYMD}}"
+                                                   class="form-control form-control-sm w-100" name="effectiveDate"
+                                                   placeholder="Effective Date" required>
+                                        </div>
+                                        <div class="col-4">
+                                            <input type="number" min="0" max="15" class="form-control form-control-sm w-100 cm-time-value" name="timeInMinutes"
+                                                   value="2" placeholder="Time (mins.)" required>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="mb-2">
+                                    <div class="row">
+                                        <div class="col-12">
+                                            <div cm-rte data-content="Reviewed/managed patient measurements" data-name="contentText"></div>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </td>
+            @endif
+        </tr>
+        @endforeach
+    @endforeach
+    </tbody>
+</table>

+ 5 - 4
resources/views/app/patient/care-month/dashboard.blade.php

@@ -387,7 +387,9 @@
                         </div>
                     </div>
 
-                    <!-- <table class="table table-striped table-sm table-bordered mt-2 mb-0">
+                    @include('app.patient.care-month._matrix')
+
+                    <table class="table table-striped table-sm table-bordered mt-2 mb-0 d-none">
                         <thead>
                         <tr>
                             <th class="px-2 text-secondary">Effective Date</th>
@@ -517,7 +519,7 @@
                             </tr>
                         @endif
                         </tbody>
-                    </table> -->
+                    </table>
                 </div>
             </div>
         </div>
@@ -596,9 +598,8 @@
             </div>
         </div> --}}
 
-        <hr class="m-negator mt-4 mb-3">
-
         @if($pro->pro_type === 'ADMIN')
+            <hr class="m-negator mt-4 mb-3">
             <div class="pb-3 screen-only">
                 <div class="ml-auto d-flex align-items-center">
 

+ 5 - 0
resources/views/app/patient/care-month/matrix.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    @include('app.patient.care-month._matrix')
+@endsection

+ 9 - 0
resources/views/app/patient/care-months.blade.php

@@ -112,6 +112,7 @@
                 <th class="px-2 text-secondary border-bottom-0">MCP</th>
                 <th class="px-2 text-secondary border-bottom-0">RMM</th>
                 <th class="px-2 text-secondary border-bottom-0">RME</th>
+                <th class="px-2 text-secondary border-bottom-0">Matrix</th>
             </tr>
             </thead>
             <tbody>
@@ -133,6 +134,14 @@
                     <td class="px-2">{{$careMonth->mcp ? $careMonth->mcp->name_display : '-'}}</td>
                     <td class="px-2">{{$careMonth->rmmPro ? $careMonth->rmmPro->name_display : '-'}}</td>
                     <td class="px-2">{{$careMonth->rmePro ? $careMonth->rmePro->name_display : '-'}}</td>
+                    <td class="px-2">
+                        <a native target="_blank"
+                           open-in-stag-popup
+                           title="Care Month Matrix: {{date('M Y', strtotime($careMonth->start_date))}}"
+                           href="/patient-care-month-matrix/{{$careMonth->uid}}">
+                            View
+                        </a>
+                    </td>
                 </tr>
             @endforeach
             </tbody>

+ 3 - 1
resources/views/app/patient/incoming-reports.blade.php

@@ -501,7 +501,9 @@
                 $('#incoming-reports').find('input.stag-dp')
                     .prop('readonly', true)
                     .addClass('bg-white')
-                    .datepicker();
+                    .datepicker({
+                        dateFormat: 'yy-mm-dd'
+                    });
             }
             addMCInitializer('incoming-reports', init, '#incoming-reports')
         }).call(window);

+ 42 - 0
resources/views/app/patient/note/_templates-v2-index.blade.php

@@ -0,0 +1,42 @@
+<?php
+$templateIndex = json_decode(file_get_contents(storage_path('templates/index.json')));
+$hasTemplates = false;
+if(isset($templateIndex->{$sectionInternalName})) {
+    $hasTemplates = true;
+    $templateName = '';
+    $defaultTemplateName = '';
+    foreach($templateIndex->{$sectionInternalName} as $k => $templateSet) {
+        if($templateName === '') $templateName = $k;
+        if($templateSet->default) $defaultTemplateName = $k;
+    }
+    if($defaultTemplateName !== '') $templateName = $defaultTemplateName;
+?>
+    <span class="mx-2 text-secondary text-sm d-none if-edit">|</span>
+    <span class="position-relative d-none if-edit">
+        <a href="#" class="note-templates-trigger">Templates</a>
+        <div class="note-template-container">
+            <div class="position-relative w-100">
+                <div class="note-template-output">
+                    <div class="font-weight-bold text-secondary">Result:</div>
+                    <div class="note-template-output-text"></div>
+                </div>
+                <div class="note-template-buttons d-flex align-items-center">
+                    <button class="btn btn-sm btn-default bg-white border text-primary border-primary note-template-apply-trigger">Apply</button>
+                    <button class="btn btn-sm btn-default bg-light border text-secondary border-secondary note-template-close-trigger">Close</button>
+                </div>
+            </div>
+            <div class="p-1 border border-bottom">
+                <select class="form-control form-control-sm note-template-set-chooser" data-section="{{$sectionInternalName}}">
+                    @foreach($templateIndex->{$sectionInternalName} as $k => $templateSet)
+                        <option value="{{$k}}" {{$k === $templateName ? 'selected' : ''}}>{{$templateSet->name}}</option>
+                    @endforeach
+                </select>
+            </div>
+            {{--@include('app/patient/note/_template')--}}
+        </div>
+    </span>
+<?php
+}
+?>
+
+

+ 2147 - 0
resources/views/app/patient/note/dashboard-univ.blade.php

@@ -0,0 +1,2147 @@
+<?php
+/** @var App\Models\Note $note */
+/** @var App\Models\Pro $pro */
+/** @var App\Models\Section $section */
+/** @var $allSections */
+?>
+@extends ('layouts.patient')
+
+@section('inner-content')
+
+    <?php
+    $hasBills = false;
+    if($note->bills->count()) {
+        foreach ($note->bills as $bill) {
+            if(!$bill->is_cancelled) {
+                $hasBills = true;
+                break;
+            }
+        }
+    }
+    ?>
+
+    {{--
+    @if(!count($pro->companyProPayers) ||  /* pro has no assoc with any payer */
+                    ($patient->is_part_b_primary !== 'YES' && !$patient->non_mc_primary_payer_id) ||    /* patient is not part_b and has no primary non-mc payer */
+                    ($patient->is_part_b_primary === 'YES' && !$pro->isAssociatedWithMCPayer()) ||      /* patient is part_b but pro has no mc payer assoc */
+                    ($patient->is_part_b_primary !== 'YES' && $patient->non_mc_primary_payer_id &&      /* patient is not part_b and has non-mc-primary, but pro has no assoc with that payer */
+                        !$pro->isAssociatedWithNonMCPayer($patient->non_mc_primary_payer_id))
+                )
+        <div class="alert alert-warning mcp-theme-1 p-3 hide-inside-ticket-popup">
+            <div class="font-size-14 font-weight-bold">
+                <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
+                This patient may not be covered for this visit. Please check with practice administrator.
+            </div>
+        </div>
+    @endif
+    --}}
+
+    <div id="note-single-header" class="pb-3 d-flex align-items-start screen-only">
+        <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>
+            </a>
+            <div class="mr-auto d-inline-flex align-items-center">
+                <span class="text-dark font-weight-bold">Note (univ *)
+                    <span class="text-secondary font-weight-normal">{{ $note->is_cancelled ? '(CANCELLED)' : '' }}</span>
+                </span>
+                @if($pro->pro_type === 'ADMIN')
+                    <a href="#" class="print-note ml-3 btn btn-sm btn-primary text-white font-weight-bold invisible"><i class="fa fa-print"></i> Print</a>
+                    <?php
+                    $isBad = false;
+                    $isGood = false;
+		            if($note->detail_json) {
+                        $parsed = json_decode($note->detail_json);
+                        $isBad = $parsed && @$parsed->isBad;
+			            $isGood = $parsed && @$parsed->isGood;
+                    }
+                    ?>
+                    @if(!$isBad)
+                        <div moe relative>
+                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-danger text-white font-weight-bold invisible"><i class="fa fa-exclamation-triangle"></i> Mark as Bad Note</a>
+                            <form url="/api/note/markNoteAsBad" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>bad</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-success mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <div moe relative>
+                            <a href="#" start show class="print-note ml-2 btn btn-sm btn-info text-white font-weight-bold invisible"><i class="fa fa-undo"></i> Marked as bad! Click to undo.</a>
+                            <form url="/api/note/undoMarkNoteAsBad" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>not bad</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-success mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+		            @if(!$isGood)
+                        <div moe relative>
+                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-success text-white font-weight-bold invisible"><i class="fa fa-check"></i> Mark as Good Note</a>
+                            <form url="/api/note/markNoteAsGood" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>good</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-success mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <div moe relative>
+                            <a href="#" start show class="print-note ml-2 btn btn-sm btn-info text-white font-weight-bold invisible"><i class="fa fa-undo"></i> Marked as good! Click to undo.</a>
+                            <form url="/api/note/undoMarkNoteAsGood" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>not good</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-success mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                @endif
+            </div>
+            @if($patient->has_mcp_done_onboarding_visit !== 'YES')
+                <div class="ml-auto">
+                    <div moe relative>
+                        <a start show class="font-weight-bold">Mark as Onboarding Visit Note</a>
+                        <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1" right>
+                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                            <input type="hidden" name="mcpOnboardingVisitNoteUid" value="{{$note->uid}}">
+                            <input type="hidden" name="hasMcpDoneOnboardingVisit" value="YES">
+                            <input type="hidden" name="mcpOnboardingVisitDate" value="{{$note->effective_dateest}}">
+                            <p class="min-width-200px">Mark this patient's onboarding as completed using this note?</p>
+                            <div>
+                                <button submit class="btn btn-sm btn-success mr-1">Yes</button>
+                                <button cancel class="btn btn-sm btn-default border">No</button>
+                            </div>
+                        </form>
+                    </div>
+
+                </div>
+            @endif
+        </h6>
+    </div>
+
+    <div class="card mb-0 {{ $note->is_cancelled ? 'cancelled-item' : '' }}">
+        <div class="card-header d-flex align-items-start px-3 py-2 border-bottom" id="note-card-header">
+            <div class="pr-2">
+                {{$note->title}}
+                @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                <div moe>
+                    <a href="" show start><i class="fa fa-edit"></i></a>
+                    <form url="/api/note/putTitle">
+                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                        <div class="mb-2">
+                            <input type="text" name="title" value="{{$note->title}}" class="form-control form-control-sm"
+                                   placeholder="Title">
+                        </div>
+                        <div class="form-group mb-0">
+                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+            </div>
+            <div class="px-2 border-left border-right">
+                <div class="d-flex">
+                    <span class="mr-2">{{friendly_date_time($note->effective_dateest, false, '')}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                    <span moe class="ml-auto">
+                        <a href="" show start><i class="fa fa-calendar"></i></a>
+                        <form url="/api/note/putEffectiveDateEST">
+                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                            <div class="mb-2">
+                                <label for="" class="text-secondary text-sm">Effective date EST</label>
+                                <input type="date" name="effectiveDateEST" value="{{$note->effective_dateest}}" class="form-control form-control-sm">
+                            </div>
+                            <div class="mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </span>
+                    @endif
+                </div>
+            </div>
+
+            {{--<div class="px-2 border-left border-right">
+                <div class="d-flex">
+                    <span class="mr-2">{{friendly_time($note->effective_time, '')}}</span>
+                    @if(!$note->is_signed_by_hcp)
+                        <span moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-clock"></i></a>
+                            <form url="/api/note/putEffectiveTime">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <label for="" class="text-secondary text-sm">Effective time </label>
+                                    <input type="time" name="effectiveTime" value="{{ date("H:i", strtotime($note->effective_time)) }}" class="form-control form-control-sm">
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                    @endif
+                </div>
+            </div>--}}
+
+            <div class="px-2 border-right">
+                <div class="d-flex">
+                    <span class="mr-2"><span class="text-secondary">HCP:</span> {{$note->hcpPro->name_display}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                    <div moe class="ml-auto">
+                        <a href="" show start><i class="fa fa-edit"></i></a>
+                        <form url="/api/note/putHcp">
+                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                            <div class="mb-2">
+                                <select provider-search data-pro-uid="{{ @$note->hcpPro->uid }}"
+                                        name="hcpProUid" class="form-control form-control-sm">
+                                    <option value="">-- Select HCP Pro --</option>
+                                </select>
+                            </div>
+                            <div class="mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                    @endif
+                </div>
+            </div>
+
+
+            @if($performer->pro->pro_type == 'ADMIN' || ($note->allyPro && $note->allyPro->uid === $performer->pro->uid))
+                <span class="px-2 border-right d-flex">
+                    @if($note->allyPro)
+                        <span class="mr-2"><span class="text-secondary">NA:</span>  {{$note->allyPro->name_first}} {{$note->allyPro->name_last}}</span>
+                        @if($performer->pro->pro_type == 'ADMIN')
+                            <span class="d-inline-block" moe>
+                                <a class="text-danger" href="" show start>
+                                    <i class="fa fa-times"></i>
+                                </a>
+                                <form url="/api/note/removeNa">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Remove NA?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                        @endif
+                    @else
+                        <span class="mr-2"><span class="text-secondary">NA:</span> - </span>
+                        <span class="d-block" moe>
+                            <a class="" href="" show start>
+                                <i class="fa fa-edit"></i>
+                            </a>
+                            <form url="/api/note/putNa">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="form-group">
+                                    <label for="" class="control-label">NA</label>
+                                    <select provider-search
+                                            name="naProUid" class="form-control form-control-sm">
+                                        <option value="">-- Select Ally Pro --</option>
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                    @endif
+
+                </span>
+            @endif
+
+
+            <div class="px-2 border-right">
+                <div class="d-flex">
+                    <span class="mr-2"><span class="text-secondary">Type:</span> {{$note->new_or_fu_or_na ? ($note->new_or_fu_or_na === 'NEW' ? 'New Patient' : $note->new_or_fu_or_na) : '-'}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                        <div moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-edit"></i></a>
+                            <form url="/api/note/updateNewOrFuOrNa">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <select name="newOrFuOrNa" class="form-control form-control-sm" required>
+                                        <option value="">-- select --</option>
+                                        <option value="NEW" {{ $note->new_or_fu_or_na === "NEW" ? "selected" : "" }}>New</option>
+                                        <option value="FU" {{ $note->new_or_fu_or_na === "FU" ? "selected" : "" }}>Follow-up</option>
+                                        <option value="NA" {{ $note->new_or_fu_or_na === "NA" ? "selected" : "" }}>N/A</option>
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+            </div>
+
+            <div class="px-2">
+                <div class="d-flex">
+                    <span class="mr-2"><span class="text-secondary">Method:</span> {{$note->method ? $note->method : '-'}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                        <div moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-edit"></i></a>
+                            <form url="/api/note/updateMethod">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <select name="method" class="form-control form-control-sm note-method-select" required>
+                                        <option value="AUDIO" {{ $note->method === "AUDIO" ? "selected" : "" }}>Audio</option>
+                                        <option value="VIDEO" {{ $note->method === "VIDEO" ? "selected" : "" }}>Video</option>
+                                        <option value="IN_CLINIC" {{ $note->method === "IN_CLINIC" ? "selected" : "" }}>In-Clinic</option>
+                                        <option value="HOUSE_CALL" {{ $note->method === "HOUSE_CALL" ? "selected" : "" }}>House Call</option>
+                                    </select>
+                                </div>
+                                <div class="form-group if-in-clinic">
+                                    <label for="" class="text-secondary text-sm mb-1">Location</label>
+                                    <select name="hcpCompanyLocationUid" class="form-control">
+                                        <option value=""></option>
+                                        @foreach($pro->companyLocations() as $location)
+                                            <option value="{{$location->uid}}" {{$location->id === $note->hcp_company_location_id ? 'selected' : ''}}>{{$location->line1}} {{$location->city}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+            </div>
+
+            <div class="ml-auto d-flex align-items-start">
+                <div class="">
+                    <div>
+                        @if($note->is_signed_by_hcp)
+                            <span class="text-secondary">
+                        <i class="fa fa-check"></i>
+                        Note Signed
+                        @if($pro->pro_type == 'ADMIN')
+                        <span moe class="ml-2 d-none">
+                            <a class="" href="" show start>Undo sign?</a>
+                            <form url="/api/note/adminUndoSignAsHcp" right>
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p>Undo sign?</p>
+                                <div class="mb-0">
+                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                        @endif
+                    </span>
+                        @else
+                            <div moe
+                                 class="{{ $note->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                 title="{{ $note->hcp_pro_id !== $pro->id ? 'Only the note\'s HCP can sign' : '' }}">
+                                <a class="" href="" show start>Sign Note As HCP</a>
+                                <form url="/api/note/signAsHcp" right>
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Sign this note as HCP?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Sign</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    </div>
+                </div>
+                @if($note->allyPro)
+                <div class="mx-4">
+                    <div>
+                        @if($note->is_signed_by_ally)
+                            <span class="text-secondary">
+                        <i class="fa fa-check"></i>
+                        Note Signed By NA
+                    </span>
+                        @else
+                            <div moe
+                                 class="{{ $note->ally_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                 title="{{ $note->ally_pro_id !== $pro->id ? 'Only the note\'s Ally can sign' : '' }}">
+                                <a class="" href="" show start>Sign Note As NA</a>
+                                <form url="/api/note/signAsAlly" right>
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Sign this NA?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Sign</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    </div>
+                </div>
+                @endif
+                @if($note->is_cancelled || (!$note->is_cancelled && !$note->is_signed_by_hcp))
+                <div class="ml-2 pl-2 border-left">
+                    <div class="d-flex justify-content-end">
+                        @if(!$note->is_cancelled)
+                        <div moe relatve
+                             class="{{ $hasBills ? 'moe-disabled' : '' }}"
+                             title="{{ $hasBills ? 'Cannot cancel note since it has un-cancelled bills in it' : '' }}">
+                            <a class="text-danger" href="" show start>Cancel</a>
+                            <form url="/api/note/cancel" right>
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="small mb-2">Are you sure you want to cancel this note?</p>
+                                <div class="mb-2">
+                                    <textarea name="memo" id="" cols="30" rows="5" placeholder="Memo" class="memo-textarea form-control form-control-sm"></textarea>
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-danger mr-2" submit>Yes</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>No</button>
+                                </div>
+                            </form>
+                        </div>
+                        @else
+                            <span class="text-secondary font-weight-bold">CANCELLED</span>
+                        @endif
+                    </div>
+                </div>
+                @endif
+
+            </div>
+        </div>
+        <div class="card-body p-0">
+            <div class="note-container">
+                <div class="note-lhs-tree" id="note-lhs-tree">
+                    <?php
+                    $previousHeading = null;
+                    $sectionTemplates = $note->noteTemplate->sectionTemplatesRaw();
+                    ?>
+                    @foreach($sectionTemplates as $sectionTemplate)
+                        <?php
+                        if($sectionTemplate->heading !== $previousHeading) {
+                            if(!empty($previousHeading)) {
+                                echo '</div></div>'; // <!-- end the previous parent section -->
+                            }
+                            if(!empty($sectionTemplate->heading)) {
+                                echo '<div class="note-tree-node note-tree-heading">' .
+                                        '<a class="">' . $sectionTemplate->heading . '</a>' .
+                                        '<div class="note-tree-children">'; // <!-- open new node -->
+                            }
+                            $previousHeading = $sectionTemplate->heading;
+                        }
+                        echo '<div class="note-tree-node">' .
+                            '<a native target="_top" data-section-template-name="' . $sectionTemplate->internal_name . '" href="#" >' . $sectionTemplate->title . '</a>' .
+                            '</div>';
+                        ?>
+                    @endforeach
+                    <?php
+                    if(!empty($previousHeading)) {
+                        echo '</div></div>'; // <!-- close any open parent section -->
+                    }
+                    ?>
+                </div>
+                <div class="note-rhs-content">
+                    <div>
+                        <div class="">
+                            <div>
+                                <?php
+                                $shortCutsObject = [];
+                                foreach ($pro->allShortcuts() as $shortcut) {
+
+                                    // %replaceables%
+                                    $shortcut->text = str_replace("%AGE%", $patient->age_in_years, $shortcut->text);
+                                    $shortcut->text = str_replace("%GENDER%", $patient->sex, $shortcut->text);
+                                    $shortcut->text = str_replace("%NAME%", $patient->displayName(), $shortcut->text);
+
+                                    $shortCutsObject[] = [
+                                        "name" => $shortcut->shortcut,
+                                        "value" => $shortcut->text
+                                    ];
+                                }
+                                ?>
+                                <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
+                                <?php
+                                $shortcuts = "";
+                                $latestSectionTS = 0;
+                                ?>
+                                <div class="{{ $note->is_signed_by_hcp ? 'note-signed-by-hcp' : '' }}">
+                                    @include('app.patient.note.note-section-list')
+                                </div>
+                            </div>
+                        </div>
+
+                        <span class="d-none latest-section-ts">{{ $latestSectionTS }}</span>
+
+                        <div class="p-3 border-bottom">
+                            <div class="">
+                                <div class="d-flex align-items-center mb-2">
+                                    <p class="font-weight-bold text-secondary m-0 font-size-14">ERx/Orders Summary</p>
+                                    <span class="mx-2 text-secondary screen-only">|</span>
+                                    <a href="/patients/view/{{$patient->uid}}/tickets/erx/create?popupmode=1&note-uid={{$note->uid}}"
+                                       native target="_blank"
+                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap screen-only">
+                                        + ERx
+                                    </a>
+                                    <span class="mx-2 text-secondary screen-only">|</span>
+                                    <a href="/patients/view/{{$patient->uid}}/tickets/lab/create?popupmode=1&note-uid={{$note->uid}}"
+                                       native target="_blank"
+                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap screen-only">
+                                        + Lab
+                                    </a>
+                                    <span class="mx-2 text-secondary screen-only">|</span>
+                                    <a href="/patients/view/{{$patient->uid}}/tickets/imaging/create?popupmode=1&note-uid={{$note->uid}}"
+                                       native target="_blank"
+                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap screen-only">
+                                        + Imaging
+                                    </a>
+                                    <span class="mx-2 text-secondary screen-only">|</span>
+                                    <a href="/patients/view/{{$patient->uid}}/tickets/other/create?popupmode=1&note-uid={{$note->uid}}"
+                                       native target="_blank"
+                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap screen-only">
+                                        + Other
+                                    </a>
+                                </div>
+
+                                <div class="p-3 border">
+
+                                    <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+                                    <div>
+                                        @if($ticketsOnNote && count($ticketsOnNote))
+                                            <table class="table table-sm table-bordered mb-0">
+                                                <thead>
+                                                <tr class="bg-light">
+                                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
+                                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
+                                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
+                                                    <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
+                                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
+                                                    <th class="px-2 text-secondary border-bottom-0">Detail</th>
+                                                </tr>
+                                                </thead>
+                                                <tbody>
+                                                @foreach($ticketsOnNote as $ticket)
+                                                    <?php $data = json_decode($ticket->data); ?>
+                                                    @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                        <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
+                                                            <td class="px-2 text-nowrap">
+                                                                {{friendly_time($ticket->created_at)}}
+                                                            </td>
+                                                            <td class="px-2 text-nowrap">
+                                                                {{$ticket->category}}
+                                                            </td>
+                                                            <td class="px-2 text-nowrap">
+                                                                @if($ticket->orderingPro)
+                                                                    @if($ticket->orderingPro->id !== $pro->id)
+                                                                        <b>{{$ticket->orderingPro->displayName()}}</b>
+                                                                    @else
+                                                                        You
+                                                                    @endif
+                                                                @else
+                                                                    -
+                                                                @endif
+                                                            </td>
+                                                            <td class="px-2 text-nowrap">
+                                                                <div class="d-flex align-items-center flex-nowrap">
+                                                                    <a href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}?popupmode=1"
+                                                                       native target="_blank"
+                                                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap mr-3">
+                                                                        View
+                                                                    </a>
+                                                                </div>
+                                                            </td>
+                                                            <td class="px-2 text-nowrap">
+                                                                {{$ticket->is_open ? 'Open' : 'Closed'}}
+                                                            </td>
+                                                            <td class="px-2">
+                                                                @if($ticket->category === 'erx')
+                                                                    <div class="font-size-13 mb-1">{{$data->medication}}</div>
+                                                                    <div class="d-flex align-items-center flex-wrap text-secondary">
+                                                                        @if($data->strength)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->strength}}</span>
+                                                        </span>
+                                                                        @endif
+                                                                        @if($data->route)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->route}}</span>
+                                                        </span>
+                                                                        @endif
+                                                                        @if($data->frequency)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->frequency}}</span>
+                                                        </span>
+                                                                        @endif
+                                                                        @if($data->dispense)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>Dispense:</span> {{$data->dispense}}
+                                                        </span>
+                                                                        @endif
+                                                                        @if($data->frequency)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span><span>Refills:</span> {{$data->refills}}</span>
+                                                        </span>
+                                                                        @endif
+                                                                        @if($data->dispense)
+                                                                            <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span><span>Purpose:</span> {{$data->purpose}}</span>
+                                                        </span>
+                                                                        @endif
+                                                                    </div>
+                                                                @endif
+                                                                @if($ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                                    @if(@$data->tests && is_array($data->tests))
+                                                                        <div>
+                                                                            <span class="text-secondary">Tests:</span>
+                                                                            {{implode(", ", $data->tests)}}
+                                                                        </div>
+                                                                    @endif
+                                                                    @if(@$data->icds && is_array($data->icds))
+                                                                        <div>
+                                                                            <span class="text-secondary">ICDs:</span>
+                                                                            {{implode(", ", $data->icds)}}
+                                                                        </div>
+                                                                    @endif
+                                                                @endif
+                                                            </td>
+                                                        </tr>
+                                                    @endif
+                                                @endforeach
+                                                </tbody>
+                                            </table>
+                                        @else
+                                            <div class="text-secondary">None</div>
+                                        @endif
+                                    </div>
+
+                                    <hr class="my-2">
+
+                                    <p class="font-weight-bold text-secondary mb-2 mr-2">Others open as of {{friendlier_date(date('Y-m-d'))}}</p>
+                                    @if($otherOpenTickets && count($otherOpenTickets))
+                                        <table class="table table-sm table-bordered mb-0">
+                                            <thead>
+                                            <tr class="bg-light">
+                                                <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
+                                                <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
+                                                <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
+                                                <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
+                                                <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
+                                                <th class="px-2 text-secondary border-bottom-0">Detail</th>
+                                            </tr>
+                                            </thead>
+                                            <tbody>
+                                            @foreach($otherOpenTickets as $ticket)
+                                                <?php $data = json_decode($ticket->data); ?>
+                                                @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging' || $ticket->category === 'other')
+                                                    <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
+                                                        <td class="px-2 text-nowrap">
+                                                            {{friendly_time($ticket->created_at)}}
+                                                        </td>
+                                                        <td class="px-2 text-nowrap">
+                                                            {{$ticket->category}}
+                                                        </td>
+                                                        <td class="px-2 text-nowrap">
+                                                            @if($ticket->orderingPro)
+                                                                @if($ticket->orderingPro->id !== $pro->id)
+                                                                    <b>{{$ticket->orderingPro->displayName()}}</b>
+                                                                @else
+                                                                    You
+                                                                @endif
+                                                            @else
+                                                                -
+                                                            @endif
+                                                        </td>
+                                                        <td class="px-2 text-nowrap">
+                                                            <div class="d-flex align-items-center flex-nowrap">
+                                                                <a href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}?popupmode=1"
+                                                                   native target="_blank"
+                                                                   class="ticket-popup-trigger note-dashboard-action d-block text-nowrap mr-3">
+                                                                    View
+                                                                </a>
+                                                            </div>
+                                                        </td>
+                                                        <td class="px-2 text-nowrap">
+                                                            {{$ticket->is_open ? 'Open' : 'Closed'}}
+                                                        </td>
+                                                        <td class="px-2">
+                                                            @if($ticket->category === 'erx')
+                                                                <div class="font-size-13 mb-1">{{$data->medication}}</div>
+                                                                <div class="d-flex align-items-center flex-wrap text-secondary">
+                                                                    @if($data->strength)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span>{{$data->strength}}</span>
+                                                                        </span>
+                                                                    @endif
+                                                                    @if($data->route)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span>{{$data->route}}</span>
+                                                                        </span>
+                                                                    @endif
+                                                                    @if($data->frequency)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span>{{$data->frequency}}</span>
+                                                                        </span>
+                                                                    @endif
+                                                                    @if($data->dispense)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span>Dispense:</span> {{$data->dispense}}
+                                                                        </span>
+                                                                    @endif
+                                                                    @if($data->frequency)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span><span>Refills:</span> {{$data->refills}}</span>
+                                                                        </span>
+                                                                    @endif
+                                                                    @if($data->dispense)
+                                                                        <span class="d-inline-flex align-items-center">
+                                                                            <span class="mx-2 text-secondary">•</span>
+                                                                            <span><span>Purpose:</span> {{$data->purpose}}</span>
+                                                                        </span>
+                                                                    @endif
+                                                                </div>
+                                                            @endif
+                                                            @if($ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                                @if(@$data->tests && is_array($data->tests))
+                                                                    <div>
+                                                                        <span class="text-secondary">Tests:</span>
+                                                                        {{implode(", ", $data->tests)}}
+                                                                    </div>
+                                                                @endif
+                                                                @if(@$data->icds && is_array($data->icds))
+                                                                    <div>
+                                                                        <span class="text-secondary">ICDs:</span>
+                                                                        {{implode(", ", $data->icds)}}
+                                                                    </div>
+                                                                @endif
+                                                            @endif
+                                                            @if($ticket->category === 'other')
+                                                                <div>
+                                                                    {{$data->title}}
+                                                                </div>
+                                                            @endif
+                                                        </td>
+                                                    </tr>
+                                                @endif
+                                            @endforeach
+                                            </tbody>
+                                        </table>
+                                    @else
+                                        <div class="text-secondary">None</div>
+                                    @endif
+
+                                </div>
+
+                            </div>
+                        </div>
+
+                        <div class="p-3 border-bottom">
+                            <div class="">
+                                <div class="d-flex align-items-center mb-2">
+                                    <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>
+                                    <span class="mx-2 text-secondary screen-only">|</span>
+                                    <a native target="_blank"
+                                       class="screen-only"
+                                       open-in-stag-popup
+                                       update-parent
+                                       mc-initer="patient-supply-orders"
+                                       title="{{$patient->displayName()}} - Supply Orders"
+                                       href="/patients/view/{{$patient->uid}}/supply-orders?popupmode=1&note-uid={{$note->uid}}&filter=active">
+                                        Manage Supply Orders
+                                    </a>
+                                </div>
+
+                                <div class="p-3 border">
+
+                                    <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+                                    <div>
+                                        @if($supplyOrdersOnNote && count($supplyOrdersOnNote))
+                                            <table class="table table-sm table-bordered mb-0">
+                                                <thead>
+                                                <tr class="bg-light">
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                                    <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                                </tr>
+                                                </thead>
+                                                <tbody>
+                                                @foreach($supplyOrdersOnNote as $iSupplyOrder)
+                                                    <tr class="">
+                                                        <td class="px-2">
+                                                            {{ $iSupplyOrder->product->title }}
+                                                        </td>
+                                                        <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                                        <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                                        <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                                        <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                                        <td class="px-2">
+                                                            @if($iSupplyOrder->shipment_id)
+                                                                <i class="fa fa-building"></i>
+                                                                {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                                            @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                                <span class="text-info">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Cleared for shipment
+                                                        </span>
+                                                            @else
+                                                                <span class="text-warning-mellow">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Not cleared for shipment
+                                                        </span>
+                                                            @endif
+                                                        </td>
+                                                    </tr>
+                                                @endforeach
+                                                </tbody>
+                                            </table>
+                                        @else
+                                            <div class="text-secondary">None</div>
+                                        @endif
+                                    </div>
+
+                                    <hr class="my-2">
+
+                                    <p class="font-weight-bold text-secondary mb-2 mr-2">Others as of {{friendlier_date(date('Y-m-d'))}}</p>
+                                    @if($otherOpenSupplyOrders && count($otherOpenSupplyOrders))
+                                        <table class="table table-sm table-bordered mb-0">
+                                            <thead>
+                                            <tr class="bg-light">
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                                <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                            </tr>
+                                            </thead>
+                                            <tbody>
+                                            @foreach($otherOpenSupplyOrders as $iSupplyOrder)
+                                                <tr class="">
+                                                    <td class="px-2">
+                                                        {{ $iSupplyOrder->product->title }}
+                                                    </td>
+                                                    <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                                    <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                                    <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                                    <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                                    <td class="px-2">
+                                                        @if($iSupplyOrder->shipment_id)
+                                                            <i class="fa fa-building"></i>
+                                                            {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                                        @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                            <span class="text-info">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Cleared for shipment
+                                                        </span>
+                                                        @else
+                                                            <span class="text-warning-mellow">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Not cleared for shipment
+                                                        </span>
+                                                        @endif
+                                                    </td>
+                                                </tr>
+                                            @endforeach
+                                            </tbody>
+                                        </table>
+                                    @else
+                                        <div class="text-secondary">None</div>
+                                    @endif
+
+                                </div>
+
+                            </div>
+                        </div>
+
+                        <div class="p-3 border-bottom">
+                            <div class="">
+                                <div class="d-flex align-items-center mb-2">
+                                    <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
+                                    @include('app/patient/note/_create-note-reason')
+                                </div>
+                                <div class="d-flex align-items-start flex-wrap">
+                                    @if(count($note->reasons))
+                                        @foreach ($note->reasons as $reason)
+                                            <span class="badge badge-info p-2 mb-2 mr-2">
+                                    {{ $reason->description}} ({{ $reason->code }})
+                                </span>
+                                        @endforeach
+                                    @else
+                                        <div class="alert alert-info">No note reasons</div>
+                                    @endif
+                                </div>
+                            </div>
+                        </div>
+                        @if($pro->pro_type === 'ADMIN')
+                            <div class="p-3 border-bottom screen-only">
+                                <div>
+                                    <h2 class="font-weight-bold text-secondary">Bills & Claims Summary</h2>
+                                    <div class="d-flex justify-content-center align-items-start">
+                                        <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped">
+                                            <tbody>
+                                            <tr>
+                                                <td class="text-secondary">Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Is Billing Closed</td>
+                                                <td>{{$note->is_bill_closed ? 'Yes' : 'No'}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Bill Summary</td>
+                                                <td>{{$note->bill_summary ? $note->bill_summary : '-'}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Bill Total Paid</td>
+                                                <td>${{friendly_money($note->bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Billing Closed At</td>
+                                                <td>{{friendlier_date_time($note->bill_closed_at)}}</td>
+                                            </tr>
+                                            </tbody>
+                                        </table>
+                                        <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                            <tbody>
+                                            <tr>
+                                                <td class="text-secondary">Claim Total Exp.</td>
+                                                <td>${{friendly_money($note->claim_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Is Claiming Closed</td>
+                                                <td>{{$note->is_claim_closed ? 'Yes' : 'No'}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Claim Summary</td>
+                                                <td>{{$note->claim_summary ? $note->claim_summary : '-'}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Claim Total Paid</td>
+                                                <td>${{friendly_money($note->claim_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">Claiming Closed At</td>
+                                                <td>{{$note->claim_closed_at ? friendlier_date_time($note->claim_closed_at) : '-'}}</td>
+                                            </tr>
+                                            </tbody>
+                                        </table>
+                                        <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                            <tbody>
+                                            <tr>
+                                                <td class="text-secondary">HCP Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->hcp_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">NA Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->na_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMM Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->rmm_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RME Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->rme_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMS Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->rms_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMG Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->rmg_bill_total_expected)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">CM Bill Total Exp.</td>
+                                                <td>${{friendly_money($note->cm_bill_total_expected)}}</td>
+                                            </tr>
+                                            </tbody>
+                                        </table>
+                                        <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                            <tbody>
+                                            <tr>
+                                                <td class="text-secondary">HCP Bill Total Paid</td>
+                                                <td>${{friendly_money($note->hcp_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">NA Bill Total Paid</td>
+                                                <td>${{friendly_money($note->na_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMM Bill Total Paid</td>
+                                                <td>${{friendly_money($note->rmm_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RME Bill Total Paid</td>
+                                                <td>${{friendly_money($note->rme_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMS Bill Total Paid</td>
+                                                <td>${{friendly_money($note->rms_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">RMG Bill Total Paid</td>
+                                                <td>${{friendly_money($note->rmg_bill_total_paid)}}</td>
+                                            </tr>
+                                            <tr>
+                                                <td class="text-secondary">CM Bill Total Paid</td>
+                                                <td>${{friendly_money($note->cm_bill_total_paid)}}</td>
+                                            </tr>
+                                            <!--                                <tr>
+                                    <td class="text-secondary">HCP Company Pro</td>
+                                    <td>{{$note->hcp_company_pro_id}}</td>
+                                </tr>-->
+                                            </tbody>
+                                        </table>
+                                    </div>
+                                </div>
+                            </div>
+                        @endif
+
+                        @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
+                            <div class="p-3 border-bottom screen-only">
+                                <div class="ml-auto d-inline-flex align-items-center">
+
+                                    <span class="text-secondary font-weight-bold">Pro:&nbsp;</span>
+                                    <b>{{$note->hcpPro ? $note->hcpPro->displayName() : '-'}}</b>
+
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span>
+                            <span class="text-secondary font-weight-bold">Payer 1°: </span>
+                            <b>
+                                {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->company ? $note->hcpCompanyProPayer->company->name : '-'}}
+                                /
+                                {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer ? $note->hcpCompanyProPayer->payer->name : '-'}}
+                            </b>
+                            <span moe class="ml-1">
+                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                <form url="/api/note/putHcpCompanyProPayer">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <div class="mb-2">
+                                        <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
+                                            <option value="">-- select --</option>
+                                            @foreach($note->hcpPro->companyProPayers as $companyProPayer)
+                                                <option value="{{$companyProPayer->uid}}">{{$companyProPayer->company->name}} / {{$companyProPayer->payer->name}}</option>
+                                            @endforeach
+                                        </select>
+                                    </div>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                            @if($note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer)
+                                            <span moe class="ml-1">
+                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                <form url="/api/note/wipeHcpCompanyProPayer">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Wipe payer from this note?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                                        @endif
+                        </span>
+
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span>
+                            <span class="text-secondary font-weight-bold">Payer 2°: </span>
+                        </span>
+
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span>
+                            <span class="text-secondary font-weight-bold">Location: </span><b>{{$note->hcpCompanyLocation ? $note->hcpCompanyLocation->line1 . ', ' . $note->hcpCompanyLocation->city : '-'}}</b>
+                            <span moe class="ml-1">
+                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                <form url="/api/note/putHcpCompanyLocation">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <div class="mb-2">
+                                        <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
+                                            <option value="">-- select --</option>
+                                            @if($note->hcpCompany && $note->hcpCompany->locations)
+                                                @foreach($note->hcpCompany->locations as $location)
+                                                    <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
+                                                @endforeach
+                                            @endif
+                                        </select>
+                                    </div>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                            @if($note->hcpCompanyLocation)
+                                            <span moe class="ml-1">
+                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                <form url="/api/note/wipeHcpCompanyLocation">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Wipe location from this note?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                                        @endif
+                        </span>
+                                </div>
+                            </div>
+                        @endif
+
+                        {{-- bills --}}
+                        @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id) || ($note->allyPro && $pro->id === $note->allyPro->id))
+                            @if($note->bills->count())
+                                <div class="p-3 border-bottom">
+                                    <div class="d-flex align-items-center mb-2">
+                                        <p class="font-weight-bold text-secondary font-size-13 m-0">Bills</p>
+                                        @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
+                                            @include('app/patient/note/_create-bill')
+                                        @endif
+                                    </div>
+
+                                    @if($pro->pro_type === 'ADMIN')
+                                        <table class="table table-sm tabe-striped mb-0 table-bordered">
+                                            <thead class="bg-light">
+                                            <tr class="text-secondary">
+                                                <?php /* <th class="border-bottom-0"></th> */ ?>
+                                                <th class="border-bottom-0">Date</th>
+                                                <th class="border-bottom-0">Service</th>
+                                                <th class="border-bottom-0">Billable</th>
+                                                <th class="border-bottom-0">HCP</th>
+                                                <th class="border-bottom-0 screen-only">Total</th>
+                                                <th class="border-bottom-0">Sign</th>
+                                                <th class="border-bottom-0 screen-only">Bal Post Date</th>
+                                                <th class="border-bottom-0">Verification</th>
+                                                <th class="border-bottom-0">Cancellation</th>
+                                                <th class="border-bottom-0 screen-only">Payment</th>
+                                            </tr>
+                                            </thead>
+                                            <tbody>
+                                            @foreach ($note->bills as $bill)
+                                                <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
+                                                    <?php /* <td class="p-0">
+                                        <table class="table-striped table-sm table-condensed border border-left-0 border-top-0 border-bottom-0">
+                                            <tbody>
+                                                <tr><td>collected_amount</td><td>{{$bill->collected_amount}}</td></tr>
+                                                <tr><td>effective_date</td><td>{{$bill->effective_date}}</td></tr>
+                                                <tr><td>has_hcp_been_paid</td><td>{{$bill->has_hcp_been_paid}}</td></tr>
+                                                <tr><td>hcp_expected_payment_amount</td><td>{{$bill->hcp_expected_payment_amount}}</td></tr>
+                                                <tr><td>hcp_payment_amount</td><td>{{$bill->hcp_payment_amount}}</td></tr>
+                                                <tr><td>is_cancelled</td><td>{{$bill->is_cancelled}}</td></tr>
+                                                <tr><td>hcp_payment_pro_transaction_id</td><td>{{$bill->hcp_payment_pro_transaction_id}}</td></tr>
+                                                <tr><td>balance_post_date</td><td>{{$bill->balance_post_date}}</td></tr>
+                                                <tr><td>is_verified</td><td>{{$bill->is_verified}}</td></tr>
+                                                <tr><td>is_cancellation_acknowledged</td><td>{{$bill->is_cancellation_acknowledged}}</td></tr>
+                                                <tr><td>is_cancelled_by_administrator</td><td>{{$bill->is_cancelled_by_administrator}}</td></tr>
+                                                <tr><td>total_expected</td><td>{{$bill->total_expected}}</td></tr>
+                                                <tr><td>total_paid</td><td>{{$bill->total_paid}}</td></tr>
+                                            </tbody>
+                                        </table>
+                                    </td> */ ?>
+                                                    <td class="text-nowrap">{{friendlier_date_time($bill->effective_date, false)}}</td>
+                                                    <td>{{$bill->code}}</td>
+                                                    <td class="">
+                                                        @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                                            <?php
+                                                            $totalSeconds = $bill->number_of_units * 3600;
+                                                            $remainder = $totalSeconds % 60;
+                                                            if ($remainder !== 0) {
+                                                                if ($remainder < 30) {
+                                                                    $totalSeconds = $totalSeconds - $remainder;
+                                                                }
+                                                                else {
+                                                                    $totalSeconds = $totalSeconds + (60 - $remainder);
+                                                                }
+                                                            }
+                                                            ?>
+                                                            {{ time_in_hrminsec($totalSeconds) }}
+                                                        @else
+                                                            @if(!!$bill->number_of_units)
+                                                                {{ $bill->number_of_units }} unit(s)
+                                                            @else
+                                                                -
+                                                            @endif
+                                                        @endif
+                                                    </td>
+                                                    <td class="">
+                                                        <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }} (HCP)</div>
+                                                        <div class="text-nowrap mt-1 screen-only">
+                                                            <span class="text-secondary">Paid: </span>
+                                                            <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
+                                                        </div>
+                                                        @if(!$bill->has_hcp_been_paid)
+                                                            <div class="text-nowrap mt-1 screen-only">
+                                                                <span class="text-secondary">Expected: </span>
+                                                                <span class="font-weight-bold">${{ $bill->hcp_expected_payment_amount }}</span>
+                                                            </div>
+                                                        @else
+                                                            <div class="text-nowrap mt-1 screen-only">
+                                                                <span class="text-secondary">Amount: </span>
+                                                                <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
+                                                            </div>
+                                                        @endif
+                                                        @if($bill->ally)
+                                                            <hr>
+                                                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->ally->displayName() }} (NA)</div>
+                                                            <div class="text-nowrap mt-1 screen-only">
+                                                                <span class="text-secondary">Paid: </span>
+                                                                <span>{{ $bill->has_na_been_paid ? 'Yes' : 'No' }}</span>
+                                                            </div>
+                                                            @if(!$bill->has_na_been_paid)
+                                                                <div class="text-nowrap mt-1 screen-only">
+                                                                    <span class="text-secondary">Expected: </span>
+                                                                    <span class="font-weight-bold">${{ $bill->na_expected_payment_amount }}</span>
+                                                                </div>
+                                                            @else
+                                                                <div class="text-nowrap mt-1 screen-only">
+                                                                    <span class="text-secondary">Amount: </span>
+                                                                    <span class="font-weight-bold">${{ $bill->na_payment_amount }}</span>
+                                                                </div>
+                                                            @endif
+                                                        @endif
+
+                                                    </td>
+                                                    <td class="pr-3 screen-only">
+                                                        @if($bill->has_hcp_been_paid)
+                                                            <span class="text-secondary">Paid. </span>
+                                                            <span class="font-weight-bold">${{ friendly_money($bill->total_paid) }}</span>
+                                                        @else
+                                                            <span class="text-secondary">Exp. </span>
+                                                            <span class="font-weight-bold">{{ $bill->total_expected ? '$' . friendly_money($bill->total_expected) : '-' }}</span>
+                                                        @endif
+                                                    </td>
+                                                    <td>
+                                                        @if(!$bill->is_cancelled)
+                                                            @if($bill->is_signed_by_hcp)
+                                                                <span class="d-block text-secondary text-nowrap">
+                                                        <i class="fa fa-check"></i>
+                                                        HCP Signed
+                                                    </span>
+                                                            @else
+                                                                <span moe
+                                                                      class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                                      title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                    <a class="" href="" show start>Sign As HCP</a>
+                                                    <form url="/api/bill/signAsHcp">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Sign this bill as HCP?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+
+                                                            @if($bill->is_signed_by_na)
+                                                                <span class="d-block text-secondary text-nowrap">
+                                                    <i class="fa fa-check"></i>
+                                                    NA Signed
+                                                </span>
+                                                            @else
+                                                                <span moe
+                                                                      class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                                      title="{{ $bill->na_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
+                                                    <a class="" href="" show start>Sign As NA</a>
+                                                    <form url="/api/bill/signAsNa">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Sign this bill as NA?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+                                                        @endif
+                                                    </td>
+                                                    <td class="screen-only">
+                                                        @if(!$bill->is_cancelled)
+                                                            <span class="d-block" moe>
+                                                <a class="" href="" show start>
+                                                    {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
+                                                </a>
+                                                <form url="/api/bill/updateBalancePostDate">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Update Balance Post Date</p>
+                                                    <div class="mb-0">
+                                                        <input type="date" class="text form-control form-control-sm" name="balancePostDate" value="{{$bill->balance_post_date}}" placeholder="balance post date"><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                                        @endif
+                                                    </td>
+                                                    <td> <!-- verification -->
+                                                        @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                                            @if(!$bill->is_verified)
+                                                                <div class="text-warning-mellow font-weight-bold">Not Verified</div>
+                                                                <span class="d-block mt-1" moe>
+                                                    <a href="" show start>Mark Verified</a>
+                                                    <form url="/api/bill/markAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @else
+                                                                <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                                                <span class="d-block mt-1" moe>
+                                                    <a class="" href="" show start>Undo</a>
+                                                    <form url="/api/bill/undoMarkAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Undo Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+                                                        @endif
+                                                    </td>
+                                                    <td>  <!-- cancellation -->
+                                                        @if($bill->is_cancelled)
+                                                            <div class="text-warning-mellow font-weight-bold">Cancelled</div>
+                                                            @if($bill->cancellation_memo)
+                                                                <div class="text-dark text-sm font-italic my-1">{{$bill->cancellation_memo}}</div>
+                                                            @endif
+                                                            @if($bill->is_cancelled_by_administrator)
+                                                                <div class="text-secondary text-sm">(by Administrator)</div>
+                                                            @endif
+                                                            <div moe class="mt-1">
+                                                                <a class="" href="" show start>Update Memo</a>
+                                                                <form url="/api/bill/updateCancellationMemo">
+                                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                                    <p>Update Cancellation Memo</p>
+                                                                    <div class="mb-2">
+                                                                        <textarea class="text form-control form-control-sm" name="cancellationMemo" placeholder="">{{$bill->cancellation_memo ? $bill->cancellation_memo : 'Insufficient documentation for billable service.'}}</textarea>
+                                                                    </div>
+                                                                    <div>
+                                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </div>
+                                                        @else
+                                                            <span class="d-block" moe relative="">
+                                                <a class="text-danger" href="" show start>Cancel</a>
+                                                <form url="/api/bill/markCancelled" right="">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p class="mb-2">Cancel this bill?</p>
+                                                    <div class="mb-2">
+                                                        <label class="mb-1 text-secondary">Cancellation Memo</label>
+                                                        <textarea type="text" name="memo" placeholder="Memo" class="form-control form-control-sm">Insufficient documentation for billable service.</textarea>
+                                                    </div>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                                        @endif
+
+                                                        @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                                            <div class="mt-2 text-secondary">
+                                                                <i class="fa fa-exclamation-triangle"></i>
+                                                                Not Acknowledged
+                                                            </div>
+                                                            <div class="d-block mt-1" moe>
+                                                                <a class="" href="" show start>Ack. Cancellation</a>
+                                                                <form url="/api/bill/acknowledgeCancellation">
+                                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                                    <p>Acknowledge Cancellation?</p>
+                                                                    <div class="mb-0">
+                                                                        {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
+                                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </div>
+                                                        @endif
+
+                                                        @if($bill->is_cancellation_acknowledged && !$note->is_billing_marked_done)
+                                                            <div class="mt-2 text-secondary">
+                                                                <i class="fa fa-check"></i>
+                                                                Acknowledged
+                                                            </div>
+                                                            <div class="d-block mt-1" moe>
+                                                                <a class="" href="" show start>Undo Cancellation Ack.</a>
+                                                                <form url="/api/bill/undoAcknowledgeCancellation">
+                                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                                    <p>Undo Acknowledge Cancellation?</p>
+                                                                    <div class="mb-0">
+                                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </div>
+                                                        @endif
+
+                                                    </td>
+                                                    <td class="screen-only"> <!-- submit payment -->
+                                                        <div class="my-1">
+                                                            @if(!$bill->is_cancelled && !$bill->has_hcp_been_paid )
+                                                                @if(+$bill->hcp_expected_payment_amount && $bill->is_signed_by_hcp)
+                                                                    <span class="d-block" moe relative="">
+                                                        <a class="font-weight-bold" href="" show start>Submit Payment For HCP</a>
+                                                        <form url="/api/bill/payHcpAmount" right>
+                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                            <p>Submit Payment</p>
+                                                            <div class="mb-0">
+                                                                <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
+                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                            </div>
+                                                        </form>
+                                                    </span>
+                                                                @else
+                                                                    @if(!+$bill->hcp_expected_payment_amount)
+                                                                        <div class="mb-1 text-danger">
+                                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                                            HCP expected amount is invalid
+                                                                        </div>
+                                                                    @endif
+                                                                    @if(!$bill->is_signed_by_hcp)
+                                                                        <div class="mb-1 text-danger">
+                                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                                            HCP has not signed the bill
+                                                                        </div>
+                                                                    @endif
+                                                                @endif
+                                                            @endif
+                                                        </div>
+                                                        <div class="my-1">
+                                                            @if(!$bill->is_cancelled && !$bill->has_na_been_paid && $bill->ally)
+                                                                @if(+$bill->na_expected_payment_amount && $bill->is_signed_by_na)
+                                                                    <span class="d-block" moe relative="">
+                                                        <a class="font-weight-bold" href="" show start>Submit Payment For NA</a>
+                                                        <form url="/api/bill/payNaAmount" right>
+                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                            <p>Submit Payment For NA</p>
+                                                            <div class="mb-0">
+                                                                <input type="text" class="text form-control form-control-sm" name="naPaymentAmount" value="{{$bill->na_expected_payment_amount}}" placeholder="amount"><br>
+                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                            </div>
+                                                        </form>
+                                                    </span>
+                                                                @else
+                                                                    @if(!+$bill->na_expected_payment_amount)
+                                                                        <div class="mb-1 text-danger">
+                                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                                            NA expected amount is invalid
+                                                                        </div>
+                                                                    @endif
+                                                                    @if(!$bill->is_signed_by_na)
+                                                                        <div class="mb-1 text-danger">
+                                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                                            NA has not signed the bill
+                                                                        </div>
+                                                                    @endif
+                                                                @endif
+                                                            @endif
+                                                        </div>
+                                                    </td>
+                                                </tr>
+                                            @endforeach
+                                            </tbody>
+                                        </table>
+                                    @else
+                                        <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+                                            <thead class="bg-light">
+                                            <tr>
+                                                <th class="border-bottom-0 pl-3">HCP</th>
+                                                @if($note->ally_pro_id === $pro->id)
+                                                    <th class="border-bottom-0 pl-3">NA</th>
+                                                @endif
+                                                <th class="border-bottom-0 w-25 pl-3">Service</th>
+                                                {{--<th class="border-bottom-0 w-25 pl-2">Reason</th>--}}
+                                                <th class="border-bottom-0 pl-3">Billable</th>
+                                                <th class="border-bottom-0 pl-2">Amount</th>
+                                                <th class="border-bottom-0"></th>
+                                            </tr>
+                                            </thead>
+                                            <tbody>
+                                            @foreach ($note->bills as $bill)
+                                                <tr>
+                                                    <td class="pl-3">{{ $bill->hcp->displayName() }}</td>
+                                                    @if($note->ally_pro_id === $pro->id)
+                                                        <td class="pl-3">{{ $note->allyPro->displayName() }}</td>
+                                                    @endif
+                                                    <td class="pl-3 {{ $bill->is_cancelled ? 'text-secondary' : '' }}">{{$bill->code}}</td>
+                                                    {{--<td class="pl-2">
+                                                        {{ $bill->reason1 }}
+                                                        <div class="text-secondary small">{{ $bill->reason2 }}</div>
+                                                    </td>--}}
+                                                    <td class="pl-3">
+                                                        @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                                            <?php
+                                                            $totalSeconds = $bill->number_of_units * 3600;
+                                                            $remainder = $totalSeconds % 60;
+                                                            if ($remainder !== 0) {
+                                                                if ($remainder < 30) {
+                                                                    $totalSeconds = $totalSeconds - $remainder;
+                                                                }
+                                                                else {
+                                                                    $totalSeconds = $totalSeconds + (60 - $remainder);
+                                                                }
+                                                            }
+                                                            ?>
+                                                            {{ time_in_hrminsec($totalSeconds) }}
+                                                        @else
+                                                            @if(!!$bill->number_of_units)
+                                                                {{ $bill->number_of_units }} unit(s)
+                                                            @else
+                                                                -
+                                                            @endif
+                                                        @endif
+                                                    </td>
+                                                    <td class="pl-2">
+                                                        @if($bill->hcp_pro_id === $pro->id)
+                                                            @if($bill->has_hcp_been_paid)
+                                                                <span class="text-dark">Processed:</span><span class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
+                                                            @else
+                                                                <span class="text-dark">Expected:</span><span class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
+                                                            @endif
+                                                        @elseif($bill->na_pro_id === $pro->id)
+                                                            @if($bill->has_na_been_paid)
+                                                                <span class="text-dark">Processed:</span><span class="font-weight-bold text-success ml-2">${{ $bill->na_payment_amount }}</span>
+                                                            @else
+                                                                <span class="text-dark">Expected:</span><span class="font-weight-bold text-dark ml-2">{{ $bill->na_expected_payment_amount ? '$' . $bill->na_expected_payment_amount : '-' }}</span>
+                                                            @endif
+                                                        @endif
+                                                    </td>
+                                                    <td>
+                                                        <div class="d-flex align-items-center">
+                                                            @if(!$bill->is_cancelled)
+                                                                @if($bill->is_signed_by_hcp)
+                                                                    <span class="d-block text-secondary">
+                                                        <i class="fa fa-check"></i>
+                                                        HCP Signed
+                                                    </span>
+                                                                @else
+                                                                    <span moe
+                                                                          class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                                          title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                        <a class="" href="" show start>Sign as HCP</a>
+                                                        <form url="/api/bill/signAsHcp">
+                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                            <p>Sign this bill as HCP?</p>
+                                                            <div class="mb-0">
+                                                                <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                            </div>
+                                                        </form>
+                                                    </span>
+                                                                @endif
+                                                                @if($bill->na_pro_id === $pro->id)
+                                                                    <span class="mx-2 text-secondary">|</span>
+                                                                    @if($bill->is_signed_by_na)
+                                                                        <span class="d-block text-secondary">
+                                                            <i class="fa fa-check"></i>
+                                                            NA Signed
+                                                        </span>
+                                                                    @else
+                                                                        <span moe
+                                                                              class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                                              title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
+                                                            <a class="" href="" show start>Sign as NA</a>
+                                                            <form url="/api/bill/signAsNa">
+                                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                                <p>Sign this bill as NA?</p>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                    @endif
+                                                                @endif
+                                                            @endif
+                                                            @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
+                                                                <span class="mx-2 text-secondary">|</span>
+                                                                <span class="d-block" moe>
+                                                    <a class="text-danger" href="" show start>Submit Payment</a>
+                                                    <form url="/api/bill/payHcpAmount">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Submit payment:</p>
+                                                        <div class="mb-0">
+                                                            <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+                                                            @if(!$bill->has_na_been_paid && $bill->ally && $pro->pro_type === 'ADMIN')
+                                                                <span class="d-block" moe relative="">
+                                                    <a class="font-weight-bold" href="" show start>Submit Payment For NA</a>
+                                                    <form url="/api/bill/payNaAmount" right>
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Submit Payment For NA</p>
+                                                        <div class="mb-0">
+                                                            <input type="text" class="text form-control form-control-sm" name="naPaymentAmount" value="{{$bill->na_expected_payment_amount}}" placeholder="amount"><br>
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+                                                            @if($bill->is_cancelled)
+                                                                <span class="mx-2 text-secondary">|</span>
+                                                                <span class="d-block text-secondary">
+                                                    Cancelled
+                                                </span>
+                                                            @else
+                                                                <span class="mx-2 text-secondary">|</span>
+                                                                <span class="d-block" moe>
+                                                    <a class="text-danger" href="" show start>Cancel</a>
+                                                    <form url="/api/bill/markCancelled" right>
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Cancel this bill?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                                            @endif
+                                                        </div>
+                                                    </td>
+                                                </tr>
+                                            @endforeach
+                                            </tbody>
+                                        </table>
+                                    @endif
+
+                                </div>
+                            @else
+                                <div class="p-3 d-flex  border-bottom">
+                                    <p class="font-weight-bold mb-0 text-secondary">No bills in this note</p>
+                                    @include('app/patient/note/_create-bill')
+                                </div>
+                            @endif
+                        @endif
+
+                        {{-- claims --}}
+                        @if($pro->pro_type === 'ADMIN')
+                            @if($note->claims->count())
+                                <div class="screen-only p-3">
+                                    <div class="d-flex align-items-center mb-2">
+                                        <p class="font-weight-bold text-secondary m-0">Claims</p>
+                                        @include('app/patient/note/_create-claim')
+                                        <div class="ml-auto">
+                                            <select class="form-control form-control-sm"
+                                                    onchange="fastLoad('{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}?claims-filter=' + this.value)">
+                                                <option value="active" {{!request('claims-filter') || request('claims-filter') === 'active' ? 'selected' : ''}}>Active Claims</option>
+                                                <option value="all" {{request('claims-filter') === 'all' ? 'selected' : ''}}>All Claims</option>
+                                            </select>
+                                        </div>
+                                    </div>
+
+                                    <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+                                        <thead class="bg-light">
+                                        <tr>
+                                            <th class="border-bottom-0 pl-2">IID</th>
+                                            <th class="border-bottom-0">Details</th>
+                                            <th class="border-bottom-0">Status</th>
+                                            <th class="border-bottom-0">Submissions</th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                        @foreach ($note->claims as $claim)
+                                            @if($claim->status !== 'CANCELLED' || request('claims-filter') === 'all')
+                                                <tr class="bg-secondary on-hover-opaque">
+                                                    <td colspan="5" class="pt-0 pb-1"></td>
+                                                </tr>
+                                                <tr class="{{ $claim->status === 'CANCELLED' ? 'text-secondary bg-light on-hover-opaque' : '' }}">
+                                                    <td class="pl-2">
+                                                        <div>{{ $claim->iid }}</div>
+                                                        <div class="text-sm text-secondary font-weight-bold mt-1">Current Version:</div>
+                                                        <div class="text-sm text-secondary">{{$claim->currentVersion ? friendlier_date_time($claim->currentVersion->created_at) : '-'}}</div>
+                                                        @if($claim->status === 'CANCELLED')
+                                                            <div class="text-secondary font-weight-bold text-sm mt-1">[CANCELLED]</div>
+                                                        @else
+                                                            <div moe class="text-left mt-1" title="Cancel Claim">
+                                                                <a class="" href="" show start>Cancel</a>
+                                                                <form url="/api/claim/updateStatus">
+                                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                    <input type="hidden" name="status" value="CANCELLED">
+                                                                    <p>Cancel this claim?</p>
+                                                                    <div class="mb-2">
+                                                                        <label for="" class="control-label">Cancellation Memo</label>
+                                                                        <textarea name="memo" class="form-control"></textarea>
+                                                                    </div>
+                                                                    <div class="mb-0">
+                                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </div>
+                                                        @endif
+                                                    </td>
+                                                    <td class="p-0 border-left border-right">
+                                                        @if($claim->lines->count())
+                                                            <table class="table table-sm table-condensed border-0 mb-0">
+                                                                <thead>
+                                                                <tr class="bg-light">
+                                                                    <th class="border-0">CPT</th>
+                                                                    <th class="border-0">DOS</th>
+                                                                    <th class="border-0">ICDs</th>
+                                                                </tr>
+                                                                </thead>
+                                                                <tbody class="pb-3">
+                                                                @foreach($claim->lines as $line)
+                                                                    <tr class="claim-line">
+                                                                        <td>{{$line->cpt}}
+                                                                            <div>Units: <b>{{!@$line->units ? 1 : $line->units}}</b></div>
+                                                                        </td>
+                                                                        <td class="text-nowrap">{{friendlier_date($line->date_of_service)}}</td>
+                                                                        <td>
+                                                                            @if(count($line->claimLineIcds))
+                                                                                @foreach($line->claimLineIcds as $icd)
+                                                                                    <div>
+                                                                                        <b class="c-pointer border-secondary border-bottom" title="{{$icd->description}}">{{$icd->code}}</b>
+                                                                                    </div>
+                                                                                @endforeach
+                                                                            @else
+                                                                                <p>No ICDs set</p>
+                                                                            @endif
+                                                                        </td>
+                                                                    </tr>
+                                                                @endforeach
+                                                                </tbody>
+                                                            </table>
+                                                        @else
+                                                            <p>No lines for this claim</p>
+                                                        @endif
+                                                    </td>
+                                                    <td class="border-right p-0">
+
+                                                        <!-- payer, company, location -->
+                                                        <div class="p-1">
+                                                            <div class="mt-1">
+                                                                <div>
+                                                                    <span class="text-secondary text-sm">Payer (1°): </span>
+                                                                    <b>{{$claim->primaryPayer ? $claim->primaryPayer->name : '-'}}</b>
+                                                                    @if(0 && $claim->status !== 'CANCELLED')
+                                                                        <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putPrimaryPayer">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="primaryPayerUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @foreach($note->hcpPro->companyProPayers as $companyProPayer)
+                                                                            <option value="{{$companyProPayer->payer->uid}}"
+                                                                                    {{$claim->primaryPayer && $claim->primaryPayer->uid === $companyProPayer->payer->uid ? 'selected' : ''}}>{{$companyProPayer->payer->name}}</option>
+                                                                        @endforeach
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                        @if($claim->primaryPayer)
+                                                                            <span moe class="ml-1">
+                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                            <form url="/api/claim/wipePrimaryPayer">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <p>Wipe payer from this claim?</p>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                        @endif
+                                                                    @endif
+                                                                </div>
+                                                                <div class="py-1 border-bottom d-flex align-items-center">
+                                                                    <span class="text-secondary text-sm pr-1">Status: </span>
+                                                                    <div>
+                                                                        {{$claim->status ? $claim->status : '(not set)'}}
+                                                                        @if($claim->status !== 'CANCELLED')
+                                                                            <span moe class="d-inline-block text-left ml-1" title="Update Status">
+                                                                    <a class="" href="" show start><i class="fa fa-edit"></i></a>
+                                                                    <form url="/api/claim/updateStatus">
+                                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                        <div class="mb-2">
+                                                                            <label for="" class="control-label">Status</label>
+                                                                            <select name="status" class="form-control form-control-sm" required>
+                                                                                <option value="">-- select --</option>
+                                                                                <option value="NEW" {{$claim->status === 'NEW' ? 'selected' : ''}}>New</option>
+                                                                                <option value="PICKED_UP" {{$claim->status === 'PICKED_UP' ? 'selected' : ''}}>Picked Up</option>
+                                                                                <option value="SUBMITTED" {{$claim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
+                                                                                <option value="IN_PROCESS" {{$claim->status === 'IN_PROCESS' ? 'selected' : ''}}>In Process</option>
+                                                                                <option value="ACCEPTED" {{$claim->status === 'ACCEPTED' ? 'selected' : ''}}>Accepted</option>
+                                                                                <option value="REJECTED" {{$claim->status === 'REJECTED' ? 'selected' : ''}}>Rejected</option>
+                                                                                <option value="ABANDONED" {{$claim->status === 'ABANDONED' ? 'selected' : ''}}>Abandoned</option>
+                                                                            </select>
+                                                                        </div>
+                                                                        <div class="mb-2">
+                                                                            <label for="" class="control-label">Status Memo</label>
+                                                                            <textarea name="memo" class="form-control"></textarea>
+                                                                        </div>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                                        @endif
+                                                                    </div>
+                                                                    @if($claim->status_memo)
+                                                                        <div class="text-secondary font-italic text-sm">{{$claim->status_memo}}</div>
+                                                                    @endif
+                                                                </div>
+                                                            </div>
+
+                                                            <div class="mt-1">
+                                                                <span class="text-secondary text-sm">Payer (2°): </span>
+                                                                <b>-</b>
+                                                            </div>
+
+                                                            <div class="mt-1">
+                                                                <span class="text-secondary text-sm">Company: </span>
+                                                                <b>{{$claim->companyPro && $claim->companyPro->company ? $claim->companyPro->company->name : '-'}}</b>
+                                                                @if(0 && $claim->status !== 'CANCELLED')
+                                                                    <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putCompanyPro">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="companyProUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @foreach($note->hcpPro->companyProPayers as $companyProPayer)
+                                                                            <option value="{{$companyProPayer->companyPro->uid}}"
+                                                                                    {{$claim->companyPro && $claim->companyPro->uid === $companyProPayer->companyPro->uid ? 'selected' : ''}}>{{$companyProPayer->company->name}}</option>
+                                                                        @endforeach
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                    @if($claim->companyPro && $claim->companyPro->company)
+                                                                        <span moe class="ml-1">
+                                                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                                <form url="/api/claim/wipeCompanyPro">
+                                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                    <p>Wipe company from this claim?</p>
+                                                                    <div class="mb-0">
+                                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </span>
+                                                                    @endif
+                                                                @endif
+                                                            </div>
+
+                                                            <div class="mt-1">
+                                                                <span class="text-secondary text-sm">Location: </span>
+                                                                <b>{{$claim->companyLocation ? $claim->companyLocation->line1 . ', ' . $claim->companyLocation->city : '-'}}</b>
+                                                                @if(0 && $claim->status !== 'CANCELLED')
+                                                                    <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putCompanyLocation">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="companyLocationUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @if($claim->company && $claim->company->locations)
+                                                                            @foreach($claim->company->locations as $location)
+                                                                                <option value="{{$location->uid}}"
+                                                                                        {{$claim->companyLocation && $claim->companyLocation->uid === $location->uid ? 'selected' : ''}}>
+                                                                                    {{$location->line1 . ', ' . $location->city}}
+                                                                                </option>
+                                                                            @endforeach
+                                                                        @endif
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                    @if($claim->companyLocation)
+                                                                        <span moe class="ml-1">
+                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                            <form url="/api/claim/wipeCompanyLocation">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <p>Wipe location from this claim?</p>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                                    @endif
+                                                                @endif
+                                                            </div>
+                                                        </div>
+                                                    </td>
+                                                    <td class="p-0 border-left border-right">
+                                                        <table class="table table-sm table-condensed border-0 mb-0">
+                                                            @if($claim->status !== 'CANCELLED')
+                                                                <thead>
+                                                                <tr class="">
+                                                                    <th colspan="3" class="border-top-0 border-bottom">
+                                                                        <div>
+                                                                <span moe class="d-block" title="Submit Claim">
+                                                                    <a class="" href="" show start>Generate Submission to Payer (1°)</a>
+                                                                    <form url="/api/mbClaim/createFromClaimForPrimaryPayer">
+                                                                        <input type="hidden" name="claimUid" value="{{$claim->uid}}">
+                                                                        <p>Generate Submission?</p>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                                        </div>
+                                                                    </th>
+                                                                </tr>
+                                                                </thead>
+                                                            @endif
+                                                            @if(count($claim->mbClaims))
+                                                                <thead>
+                                                                <tr class="bg-light">
+                                                                    <th class="border-0">Created</th>
+                                                                    <th class="border-0">Status</th>
+                                                                    <th class="border-0">&nbsp;</th>
+                                                                </tr>
+                                                                </thead>
+                                                                <tbody class="pb-3">
+                                                                @foreach($claim->mbClaims as $mbClaim)
+                                                                    <tr>
+                                                                        <td>
+                                                                            @if($mbClaim->claim_version_id !== $claim->current_version_id)
+                                                                                <i class="fa fa-exclamation-triangle text-warning-mellow text-sm" title="This submission was generated using an older version of the claim"></i>
+                                                                            @else
+                                                                                <i class="fa fa-asterisk text-secondary text-sm" title="This submission is up to date"></i>
+                                                                            @endif
+                                                                            <a native target="_blank"
+                                                                               open-in-stag-popup
+                                                                               title="Submission Details"
+                                                                               href="{{route('mb-claim', ['patient' => $patient, 'mbClaim' => $mbClaim])}}">
+                                                                                {{ friendlier_date_time($mbClaim->created_at) }}
+                                                                            </a>
+                                                                        </td>
+                                                                        <td>
+                                                                            {{$mbClaim->status}}
+                                                                            @if($mbClaim->status_memo)
+                                                                                <div class="font-italic text-secondary text-sm">{{$mbClaim->status_memo}}</div>
+                                                                            @endif
+                                                                        </td>
+                                                                        <td class="text-right pr-2">
+                                                                 <span moe relative title="Submit Claim">
+                                                                    <a class="" href="" show start><i class="fa fa-edit"></i></a>
+                                                                    <form url="/api/mbClaim/updateStatus" right>
+                                                                        <input type="hidden" name="uid" value="{{$mbClaim->uid}}">
+                                                                        <div class="form-group">
+                                                                            <label for="" class="control-label">Status</label>
+                                                                            <select name="status" class="form-control form-control-sm" required>
+                                                                                <option value="">-- select --</option>
+                                                                                <option value="NEW" {{$mbClaim->status === 'NEW' ? 'selected' : ''}}>New</option>
+                                                                                <option value="PROCESSING" {{$mbClaim->status === 'PROCESSING' ? 'selected' : ''}}>Processing</option>
+                                                                                <option value="SUBMITTED" {{$mbClaim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
+                                                                            </select>
+                                                                        </div>
+                                                                        <div class="form-group">
+                                                                            <label for="" class="control-label">Status Memo</label>
+                                                                            <textarea name="memo" class="form-control"></textarea>
+                                                                        </div>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                                            <a class="ml-1" target="_blank" native href="/api/mbClaim/downloadEDI/{{$mbClaim->uid}}" show start><i class="fa fa-file-download"></i></a>
+                                                                            <a class="ml-1 text-success" href="" show start><i class="fa fa-arrow-right"></i></a>
+                                                                        </td>
+                                                                    </tr>
+                                                                @endforeach
+                                                                </tbody>
+                                                            @else
+                                                                <tbody>
+                                                                <tr>
+                                                                    <td colspan="3">
+                                                                        <p class="p-1 text-secondary m-0">No submissions in this claim</p>
+                                                                    </td>
+                                                                </tr>
+                                                                </tbody>
+                                                            @endif
+                                                        </table>
+                                                    </td>
+                                                </tr>
+                                            @endif
+                                        @endforeach
+                                        </tbody>
+                                    </table>
+                                </div>
+                            @else
+                                <div class="screen-only my-3 px-3 d-flex">
+                                    <p class="font-weight-bold mb-0 text-secondary">No claims in this note</p>
+                                    @include('app/patient/note/_create-claim')
+                                </div>
+                            @endif
+                        @endif
+
+
+                        <div class="border-top p-3 screen-only">
+                            @if($note->addendums->count())
+                                <div class="">
+                                    <div class="d-flex align-items-center mb-2">
+                                        <p class="font-weight-bold text-secondary m-0">Addendums</p>
+                                        @include('app/patient/note/_create-addendum')
+                                    </div>
+                                    <table class="table table-sm tabe-striped border-left border-right border-bottom m-0">
+                                        <thead class="bg-light">
+                                        <tr>
+                                            <th class="border-bottom-0 pl-2 w-75">Addendum</th>
+                                            <th class="border-bottom-0">Created</th>
+                                            <th class="border-bottom-0 delete-column"></th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                        @foreach ($note->addendums as $addendum)
+                                            <tr>
+                                                <td class="pl-2">{{ $addendum->memo }}</td>
+                                                <td class="">{{ friendly_date_time($addendum->created_at, false)}}</td>
+                                                <td>
+                                                    <div class="d-flex align-items-center">
+                                                        <div moe relative class="mr-2">
+                                                            <a href="" show start><i class="fa fa-pencil-alt"></i></a>
+                                                            <form url="/api/noteAddendum/updateMemo" right>
+                                                                <input type="hidden" name="uid" value="{{$addendum->uid}}">
+                                                                <div class="mb-2 d-block">
+                                                                    <label class="d-block text-sm text-secondary mb-1">Addendum</label>
+                                                                    <textarea class="form-control form-control-sm" name="memo" rows="5">{{$addendum->memo}}</textarea>
+                                                                </div>
+                                                                <div class="form-group mb-0">
+                                                                    <button class="btn btn-primary btn-sm mr-1" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </div>
+                                                        <div moe relative class="mr-1">
+                                                            <a href="" show start class="text-danger"><i class="fa fa-trash"></i></a>
+                                                            <form url="/api/noteAddendum/remove" right>
+                                                                <input type="hidden" name="uid" value="{{$addendum->uid}}">
+                                                                <p>Remove this addendum?</p>
+                                                                <div class="form-group mb-0">
+                                                                    <button class="btn btn-danger btn-sm mr-1" submit>Yes</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                                </div>
+                                                            </form>
+                                                        </div>
+                                                    </div>
+                                                </td>
+                                            </tr>
+                                        @endforeach
+                                        </tbody>
+                                    </table>
+                                </div>
+                            @else
+                                <div class="d-flex">
+                                    <p class="font-weight-bold mb-0 text-secondary">No addendums in this note</p>
+                                    @include('app/patient/note/_create-addendum')
+                                </div>
+                            @endif
+                        </div>
+
+                        <div class="screen-only">
+                            @include('app/patient/note/_cancel-signed-note')
+                        </div>
+
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="note-templates-underlay"></div>
+    @include('app.patient.note.dashboard_script')
+    @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'rx', 'class' => 'wide', 'noEditLink' => true])
+    <script>
+        (function() {
+            function init() {
+                fixTreeTopAndHeight();
+                $(window).on('resize', fixTreeTopAndHeight);
+                $(window).on('scroll', fixTreeTopAndHeight);
+                $('.note-tree-node>a[data-section-template-name]')
+                    .off('click.scroll-to-section')
+                    .on('click.scroll-to-section', function() {
+                         let section = $('div.note-section[data-section-template-name="' + $(this).attr('data-section-template-name') + '"]').first();
+                         if(section.length) {
+                             section[0].scrollIntoView({
+                                 behavior: "smooth",
+                                 block: "center",
+                                 inline: "center"
+                             });
+                             section.addClass('spot-highlight');
+                             setTimeout(() => {
+                                 section.removeClass('spot-highlight');
+                             }, 1500);
+                             $('.note-tree-node.active').removeClass('active');
+                             $(this).closest('.note-tree-node').addClass('active');
+                         }
+                         return false;
+                    });
+            }
+            function fixTreeTopAndHeight() {
+                let tree = $('#note-lhs-tree'), noteCardHeader = $('#note-card-header'),
+                    resultTop = (noteCardHeader.offset().top + noteCardHeader.outerHeight(true)) - $(window).scrollTop();
+                if(resultTop <= 55) {
+                    tree.addClass('fixed');
+                }
+                else {
+                    tree.removeClass('fixed');
+                    tree.css('height', 'calc(100vh - ' + resultTop + 'px)');
+                    tree.css('max-height', 'calc(100vh - ' + resultTop + 'px)');
+                }
+            }
+            addMCInitializer('note-tree', init, '#note-lhs-tree');
+        })();
+    </script>
+@endsection

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

@@ -10,14 +10,17 @@
 
     <?php
     $hasBills = false;
-    if($note->bills->count()) {
+    if ($note->bills->count()) {
         foreach ($note->bills as $bill) {
-            if(!$bill->is_cancelled) {
+            if (!$bill->is_cancelled) {
                 $hasBills = true;
                 break;
             }
         }
     }
+
+    // is based on visit template
+    $isVisitTemplateBased = !!$note->visitTemplate;
     ?>
 
     {{--
@@ -36,7 +39,7 @@
     @endif
     --}}
 
-    <div id="note-single-header" class="pt-2 pb-3 d-flex align-items-start screen-only">
+    <div id="note-single-header" class="pb-3 d-flex align-items-start screen-only">
         <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>
@@ -50,10 +53,10 @@
                     <?php
                     $isBad = false;
                     $isGood = false;
-		    if($note->detail_json) {
+		            if($note->detail_json) {
                         $parsed = json_decode($note->detail_json);
                         $isBad = $parsed && @$parsed->isBad;
-			$isGood = $parsed && @$parsed->isGood;
+			            $isGood = $parsed && @$parsed->isGood;
                     }
                     ?>
                     @if(!$isBad)
@@ -83,7 +86,7 @@
                     @endif
 		     @if(!$isGood)
                         <div moe relative>
-                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-success text-white font-weight-bold invisible"><i class="fa fa-exclamation-triangle"></i> Mark as Good Note</a>
+                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-success text-white font-weight-bold invisible"><i class="fa fa-check"></i> Mark as Good Note</a>
                             <form url="/api/note/markNoteAsGood" class="mcp-theme-1">
                                 <input type="hidden" name="uid" value="{{$note->uid}}">
                                 <p class="min-width-200px">Mark this note as <b>good</b>?</p>
@@ -130,8 +133,8 @@
         </h6>
     </div>
 
-    <div class="card mb-0 {{ $note->is_cancelled ? 'cancelled-item' : '' }}">
-        <span class="card-header d-flex align-items-start px-3 py-2 border-bottom">
+    <span class="card mb-0 {{ $note->is_cancelled ? 'cancelled-item' : '' }}">
+        <div class="card-header d-flex align-items-start px-3 py-2 border-bottom" id="note-card-header">
             <div class="pr-2">
                 {{$note->title}}
                 @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
@@ -207,9 +210,6 @@
                                 <select provider-search data-pro-uid="{{ @$note->hcpPro->uid }}"
                                         name="hcpProUid" class="form-control form-control-sm">
                                     <option value="">-- Select HCP Pro --</option>
-                                    @foreach ($pros as $iPro)
-                                        <option value="{{$iPro->uid}}" {{ $note->hcpPro && $iPro->id === $note->hcpPro->id ? 'selected' : '' }}>{{$iPro->name_display}}</option>
-                                    @endforeach
                                 </select>
                             </div>
                             <div class="mb-0">
@@ -436,6 +436,53 @@
             </div>
         </div>
         <div class="card-body p-0">
+            <div class="note-container">
+                @if($isVisitTemplateBased)
+                <div class="note-lhs-tree" id="note-lhs-tree">
+                    <?php
+                    $previousHeading = null;
+                    $previousSubHeading = null;
+                    ?>
+                    @foreach($note->segments as $segment)
+                        <?php
+                        if ($segment->heading !== $previousHeading) {
+                            if (!empty($previousHeading)) {
+                                echo '</div></div>'; // <!-- end the previous parent section -->
+                            }
+                            if (!empty($segment->heading)) {
+                                echo '<div class="note-tree-node note-tree-heading">' .
+                                    '<a class="">' . $segment->heading . '</a>' .
+                                    '<div class="note-tree-children">'; // <!-- open new node -->
+                            }
+                            $previousHeading = $segment->heading;
+                        }
+                        if ($segment->subheading !== $previousSubHeading) {
+                            if (!empty($previousSubHeading)) {
+                                echo '</div></div>'; // <!-- end the previous parent section -->
+                            }
+                            if (!empty($segment->subheading)) {
+                                echo '<div class="note-tree-node note-tree-heading">' .
+                                    '<a class="">' . $segment->subheading . '</a>' .
+                                    '<div class="note-tree-children">'; // <!-- open new node -->
+                            }
+                            $previousSubHeading = $segment->subheading;
+                        }
+                        echo '<div class="note-tree-node">' .
+                            '<a native target="_top" data-segment-uid="' . $segment->uid . '" href="#" >' . $segment->display_title . '</a>' .
+                            '</div>';
+                        ?>
+                    @endforeach
+                    <?php
+                    if (!empty($previousSubHeading)) {
+                        echo '</div></div>'; // <!-- close any open parent section -->
+                    }
+                    if (!empty($previousHeading)) {
+                        echo '</div></div>'; // <!-- close any open parent section -->
+                    }
+                    ?>
+                </div>
+                @endif
+                <div class="note-rhs-content">
             <div>
                 <div class="">
                     <div>
@@ -455,12 +502,17 @@
                         }
                         ?>
                         <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
+                        <script>window.segmentInitializers = {};</script>
                         <?php
                         $shortcuts = "";
                         $latestSectionTS = 0;
                         ?>
                         <div class="{{ $note->is_signed_by_hcp ? 'note-signed-by-hcp' : '' }}">
-                        @include('app.patient.note.note-section-list')
+                            @if($isVisitTemplateBased)
+                                @include('app.patient.note.note-segment-list')
+                            @else
+                                @include('app.patient.note.note-section-list')
+                            @endif
                         </div>
                     </div>
                 </div>
@@ -2167,107 +2219,54 @@
                 </div>
 
 
+            </div>
+                </div>
             </div>
         </div>
     </div>
     <div class="note-templates-underlay"></div>
     @include('app.patient.note.dashboard_script')
     @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'rx', 'class' => 'wide', 'noEditLink' => true])
-@endsection
-@section('left-nav-content')
-    @if(!$note->is_signed_by_hcp)
-    <div class="left-nav-content" id="note-sections-app">
-        <div class="note-widget-title px-2 py-1">Note Sections</div>
-        <input type="search" class="d-block w-100 border-0 outline-0 px-2 py-1"
-               v-model="q" placeholder="Filter">
-        <div class="border-top py-1">
-            <div v-for="section in sections"
-                 v-show="section.title.toLowerCase().indexOf(q.toLowerCase()) !== -1">
-                <div class="d-flex pr-1 align-items-center note-widget-item c-pointer"
-                     :title="section.title + ' - Click to remove'"
-                     v-if="section.used"
-                     v-on:click.once="remove(section.section_uid)">
-                    <span class="mx-2">
-                        <a class="font-12 text-secondary" href="#">
-                            <i class="fa fa-minus-circle"></i>
-                        </a>
-                    </span>
-                    <span class="font-smaller text-ellipsis">
-                        @{{section.title}}
-                    </span>
-                </div>
-                <div class="d-flex pr-1 align-items-center note-widget-item c-pointer"
-                     :title="section.title + ' - Click to add'"
-                     v-if="!section.used"
-                     v-on:click.once="add(section.uid, section.internal_name)">
-                    <span class="mx-2">
-                        <a class="font-12" href="#">
-                            <i class="fa fa-plus-circle"></i>
-                        </a>
-                    </span>
-                    <span class="font-smaller text-ellipsis">
-                        @{{section.title}}
-                    </span>
-                </div>
-            </div>
-        </div>
-    </div>
+    @if($isVisitTemplateBased)
     <script>
         (function() {
-            function initSectionsWidget() {
-                var allSections = <?= json_encode($allSections) ?>;
-                new Vue({
-                    el: '#note-sections-app',
-                    delimiters: ['@{{', '}}'],
-                    data: {
-                        q: '',
-                        sections: allSections
-                    },
-                    methods: {
-                        add: function(_uid, _section) {
-                                $.post('/api/section/create', {
-                                    noteUid: '{{$note->uid}}',
-                                    sectionTemplateUid: _uid,
-                                }, function(_data) {
-                                    if(_data) {
-                                        if(_data.success) {
-                                            fastReload();
-                                        }
-                                        else {
-                                            toastr.error(_data.message);
-                                        }
-                                    }
-                                    else {
-                                        toastr.error('Unable to add section!');
-                                    }
-                                }, 'json');
-                        },
-                        remove: function(_uid) {
-                            $.post('/api/section/deactivate', {
-                                uid: _uid,
-                                memo: 'Deactivated from note',
-                            }, function(_data) {
-                                if(_data) {
-                                    if(_data.success) {
-                                        fastReload();
-                                    }
-                                    else {
-                                        toastr.error(_data.message);
-                                    }
-                                }
-                                else {
-                                    toastr.error('Unable to remove section!');
-                                }
-                            }, 'json');
+            function init() {
+                fixTreeTopAndHeight();
+                $(window).on('resize', fixTreeTopAndHeight);
+                $(window).on('scroll', fixTreeTopAndHeight);
+                $('.note-tree-node>a[data-segment-uid]')
+                    .off('click.scroll-to-section')
+                    .on('click.scroll-to-section', function() {
+                        let section = $('div.note-section[data-segment-uid="' + $(this).attr('data-segment-uid') + '"]').first();
+                        if(section.length) {
+                            section[0].scrollIntoView({
+                                behavior: "smooth",
+                                block: "center",
+                                inline: "center"
+                            });
+                            section.addClass('spot-highlight');
+                            setTimeout(() => {
+                                section.removeClass('spot-highlight');
+                            }, 1500);
+                            $('.note-tree-node.active').removeClass('active');
+                            $(this).closest('.note-tree-node').addClass('active');
                         }
-                    }
-                });
-
-                $('div[embed]').each(function() {
-                    $(this).load($(this).attr('embed'));
-                });
+                        return false;
+                    });
+            }
+            function fixTreeTopAndHeight() {
+                let tree = $('#note-lhs-tree'), noteCardHeader = $('#note-card-header'),
+                    resultTop = (noteCardHeader.offset().top + noteCardHeader.outerHeight(true)) - $(window).scrollTop();
+                if(resultTop <= 55) {
+                    tree.addClass('fixed');
+                }
+                else {
+                    tree.removeClass('fixed');
+                    tree.css('height', 'calc(100vh - ' + resultTop + 'px)');
+                    tree.css('max-height', 'calc(100vh - ' + resultTop + 'px)');
+                }
             }
-            addMCInitializer('note-sections-widget', initSectionsWidget, '#note-sections-app');
+            addMCInitializer('note-tree', init, '#note-lhs-tree');
         })();
     </script>
     @endif

+ 5 - 3
resources/views/app/patient/note/dashboard_script.blade.php

@@ -77,9 +77,9 @@
 
                 });
 
-                $('.edit-trigger')
-                    .off('click.edit-trigger')
-                    .on('click.edit-trigger', function() {
+                $(document)
+                    .off('click.edit-trigger', '.edit-trigger:not(.edit)')
+                    .on('click.edit-trigger', '.edit-trigger:not(.edit)', function() {
                         let editParent = $(this).closest('.note-section');
                         if(editParent.is('.edit')) {
                             editParent.removeClass('edit');
@@ -289,6 +289,7 @@
                     return false;
                 });
 
+                @if(!$note->visitTemplate)
                 $(document)
                     .off('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)')
                     .on('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)', function(e) {
@@ -298,6 +299,7 @@
                         $(this).find('.edit-trigger').first().click();
                         return false;
                     });
+                @endif
 
                 // $(document)
                 //     .off('mousedown.enable-edit', '.note-section:not(.edit).page-driven')

+ 6 - 0
resources/views/app/patient/note/note-segment-list.blade.php

@@ -0,0 +1,6 @@
+<div class="segments-list">
+    @foreach($note->segments as $segment)
+        @include('app.patient.note.segment')
+    @endforeach
+</div>
+@include('app.patient.note.segment_script')

+ 34 - 24
resources/views/app/patient/note/section.blade.php

@@ -4,7 +4,7 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
     $latestSectionTS = $sectionTS;
 }
 ?>
-<div data-ts="{{$sectionTS}}" class="p-3 border-bottom note-section {{ $section->sectionTemplate->is_page_driven ? 'page-driven' : '' }}"
+<div data-ts="{{$sectionTS}}" class="p-3 border-bottom note-section {{ $section->sectionTemplate->is_page_driven ? '' : '' }}"
     data-section-uid="{{ $section->uid }}"
     data-section-template-uid="{{ $section->sectionTemplate->uid }}"
     data-section-template-name="{{ $section->sectionTemplate->internal_name }}">
@@ -12,7 +12,7 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         @if(!isset($note) || (isset($note) && !$note->is_signed_by_hcp))
             <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
                 {{$section->sectionTemplate->title}}
-                @if(!isset($guestAccessCode) && !$section->sectionTemplate->is_page_driven)
+                @if(!isset($guestAccessCode) )
                     <span class="d-none if-not-edit"><i class="fa fa-edit ml-2"></i></span>
                     <span class="d-none if-edit edit-trigger font-weight-normal ml-2">Collapse</span>
                     <span class="edit-trigger"></span>
@@ -26,14 +26,14 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         <?php $sectionInternalName = $section->sectionTemplate->internal_name; ?>
 
         @if($sectionInternalName === "exam" || $sectionInternalName === "objective")
-        @include('app/patient/note/_templates-exam-index')
+            @include('app/patient/note/_templates-exam-index')
         @else
-        @include('app/patient/note/_templates-index')
+            @include('app/patient/note/_templates-index')
         @endif
 
         @if (!$section->sectionTemplate->is_page_driven)
             @if (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.php'))) {
-            <?php include(storage_path('sections/' . $sectionInternalName . '/actions.php')); ?>
+                <?php include(storage_path('sections/' . $sectionInternalName . '/actions.php')); ?>
             @elseif (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.blade.php')))
                 @include('sections/' . $sectionInternalName . '/actions')
             @endif
@@ -71,35 +71,36 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
                     Remove
                 </a>
                 @if($pro->pro_type === 'ADMIN' || true)
-                <a href="#" class="d-none if-edit ml-2 move-up-trigger" data-uid="{{$section->uid}}" title="Move Up">
-                    <i class="fa fa-arrow-up"></i>
-                </a>
-                <a href="#" class="d-none if-edit ml-2 move-down-trigger" data-uid="{{$section->uid}}" title="Move Down">
-                    <i class="fa fa-arrow-down"></i>
-                </a>
+                    <a href="#" class="d-none if-edit ml-2 move-up-trigger" data-uid="{{$section->uid}}" title="Move Up">
+                        <i class="fa fa-arrow-up"></i>
+                    </a>
+                    <a href="#" class="d-none if-edit ml-2 move-down-trigger" data-uid="{{$section->uid}}" title="Move Down">
+                        <i class="fa fa-arrow-down"></i>
+                    </a>
                 @endif
             </div>
         @endif
     </div>
+
     @if(!isset($guestAccessCode) || $section->guest_access_level == 'READ')
-    <div class="{{isset($guestAccessCode)?'':'d-none'}} if-not-edit  inset-comment summary-container">
-        <?php if ($section->sectionTemplate->is_page_driven): ?>
-            @include("app.patient.page-sections.{$sectionInternalName}.summary")
-        <?php else: ?>
-            {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
-        <?php endif; ?>
-    </div>
+        <div class="{{isset($guestAccessCode)?'':'d-none'}} if-not-edit  inset-comment summary-container">
+            <?php if ($section->sectionTemplate->is_page_driven): ?>
+                @include("app.patient.page-sections.{$sectionInternalName}.summary")
+            <?php else: ?>
+                {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
+            <?php endif; ?>
+        </div>
     @endif
 
     @if(!$section->sectionTemplate->is_page_driven && (!isset($guestAccessCode) || $section->guest_access_level == 'WRITE'))
-    <div class="{{isset($guestAccessCode)?'':'d-none'}} if-edit">
+        <div class="{{isset($guestAccessCode)?'':'d-none'}} if-edit">
 
         <?php
         // if page
-        if ($section->sectionTemplate->is_page_driven) {
-        $contentData = false;
+            if ($section->sectionTemplate->is_page_driven) {
+                $contentData = false;
         ?>
-        @include("app.patient.page-sections.{$sectionInternalName}.form")
+            @include("app.patient.page-sections.{$sectionInternalName}.form")
         <?php
         }
         // if canvas
@@ -133,8 +134,8 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
             }
         ?>
             <input type="hidden" name="data">
-            <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></div>
-        <?php
+                <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></div>
+            <?php
         }
         ?>
 
@@ -145,4 +146,13 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         </div>
     </div>
     @endif
+
+    @if($section->sectionTemplate->is_page_driven && (!isset($guestAccessCode) || $section->guest_access_level == 'WRITE'))
+        <div class="{{isset($guestAccessCode)?'':'d-none'}} if-edit">
+
+
+            @include("app.patient.page-sections.{$sectionInternalName}.form")
+
+        </div>
+    @endif
 </div>

+ 35 - 0
resources/views/app/patient/note/segment.blade.php

@@ -0,0 +1,35 @@
+<div class="p-3 border-bottom note-section visit-segment edit-trigger"
+	 data-segment-uid="{{ $segment->uid }}"
+	 data-segment-template-uid="{{ $segment->segmentTemplate->uid }}"
+	 data-segment-template-name="{{ $segment->segmentTemplate->internal_name }}">
+
+	<div class="d-flex align-items-start">
+
+		<!-- title -->
+		<span class="font-weight-bold mb-2 d-flex align-items-center">
+			{{$segment->display_title}}
+		</span>
+
+		<a class="edit-trigger d-none if-edit c-pointer ml-3">Close</a>
+
+		<!-- refresh -->
+		<span class="mx-2 text-secondary text-sm">|</span>
+		<a class="font-weight-normal refresh-segment c-pointer"
+		   data-segment-uid="{{$segment->uid}}"
+		   title="Update with latest patient data">
+			Refresh
+		</a>
+
+		@include('app/patient/note/_templates-v2-index', ['sectionInternalName' => $segment->segmentTemplate->internal_name])
+
+	</div>
+
+	<div class="d-none if-not-edit inset-comment summary-container">
+		{!! $segment->summary_html !!}
+	</div>
+
+	<div class="d-none if-edit edit-container">
+    	{!! $segment->edit_html !!}
+	</div>
+
+</div>

+ 228 - 0
resources/views/app/patient/note/segment_script.blade.php

@@ -0,0 +1,228 @@
+<script>
+    (function() {
+
+        function updateAllSegmentsInResponse(_response) {
+            if(!hasResponseError(_response)) {
+                for (let i=0; i<_response.data.length; i++) {
+                    updateSegmentFromObject(_response.data[i]);
+                }
+            }
+        }
+
+        function updateSegmentFromObject(_object) {
+            let segment = $('.note-section[data-segment-uid="' + _object.segmentUid + '"]');
+            if(segment && segment.length) {
+                segment.find('.summary-container').html(_object.summaryHtml);
+                segment.find('.edit-container').html(_object.editHtml);
+                initRTEs(segment);
+                initSegmentMoes(segment);
+                initMoes();
+                initStagSuggest();
+                if(window.segmentInitializers) {
+                    let internalName = segment.attr('data-segment-template-name');
+                    if(window.segmentInitializers.hasOwnProperty(internalName) &&
+                        typeof window.segmentInitializers[internalName] === 'function') {
+                        window.segmentInitializers[internalName].call(window);
+                    }
+                }
+            }
+        }
+
+        function initSegmentMoes(_parent) {
+
+            $('body')
+                .off('mousedown.visit-moe-outside-click')
+                .on('mousedown.visit-moe-outside-click', function (e) {
+                    if ($(e.target).closest('[visit-moe]').length) {
+                        return;
+                    }
+                    $('[visit-moe] [url]:not([show])').hide();
+                });
+
+            _parent.find('[visit-moe] [submit]')
+                .off('click.visit-moe-submit')
+                .on('click.visit-moe-submit', function() {
+                    let form = $(this).closest('form');
+
+                    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));
+                    }
+
+                    showMask();
+
+                    let closeOnSave = false, noteSection = form.closest('.note-section');
+                    if($(this).closest('[visit-moe]').is('[close-on-save]')) {
+                        closeOnSave = true;
+                    }
+
+                    $.post(form.attr('url'), form.serialize(), _data => {
+                        hideMask();
+                        updateAllSegmentsInResponse(_data);
+                        if(closeOnSave) {
+                            noteSection.removeClass('edit');
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+            _parent.find('[visit-moe]>a[start]')
+                .off('click.visit-moe-show')
+                .on('click.visit-moe-show', function () {
+                    $('[visit-moe] [url]:not([show])').hide();
+                    $(this)
+                        .closest('[visit-moe]')
+                        .find('form[url]')
+                        .show();
+                    return false;
+                });
+
+            _parent.find('[visit-moe] [cancel]')
+                .off('click.visit-moe-cancel')
+                .on('click.visit-moe-cancel', function() {
+                    $(this).closest('[visit-moe]').find('[url]:not([show])').hide();
+                    if($(this).closest('[visit-moe]').is('[close-on-cancel]')) {
+                        $(this).closest('.note-section').removeClass('edit');
+                    }
+                    return false;
+                });
+        }
+
+        function initRTEs(_parent) {
+            _parent.find('[note-rte]:not(.ql-container)').each(function() {
+
+                $(this).wrap(
+                    $('<div class="border-left border-right rte-holder"/>')
+                        .attr('data-shortcuts', '')
+                );
+
+                // give a unique id to this editor instance
+                var editorID = Math.ceil(Math.random() * 99999),
+                    fieldName = this.name;
+
+                var el = this;
+                var existingContent = $(el).html();
+                var quill = new Quill(el, {
+                    theme: 'snow',
+                    modules: stagQuillConfig
+                });
+
+                var toolbar = $(quill.container).prev('.ql-toolbar');
+
+                // add button for new shortcut
+                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                toolbar.append(newSCButton);
+
+                quill.root.innerHTML = existingContent;
+
+                quill.on('text-change', function(delta, oldDelta, source) {
+                    var content = quill.root.innerHTML;
+                    var dataValue = JSON.stringify({
+                        value: content
+                    });
+                    var dataField = $(el).closest('.note-section').find('input[name=data]').val(dataValue);
+                });
+
+                $(quill.container)
+                    .find('.ql-editor[contenteditable]')
+                    .attr('data-field', fieldName)
+                    .attr('data-editor-id', editorID)
+                    .attr('with-shortcuts', 1);
+            });
+        }
+
+        function init() {
+
+            let parent = $('.segments-list');
+            initRTEs(parent);
+            initSegmentMoes(parent);
+            initStagSuggest();
+
+            // check and run all segment initializers
+            if(window.segmentInitializers) {
+                for(let x in window.segmentInitializers) {
+                    if(window.segmentInitializers.hasOwnProperty(x) && typeof window.segmentInitializers[x] === 'function') {
+                        window.segmentInitializers[x].call(window);
+                    }
+                }
+            }
+
+            // refresh segment
+            $(document)
+                .off('click.refresh-segment', '.refresh-segment')
+                .on('click.refresh-segment', '.refresh-segment', function() {
+                    showMask();
+                    $.post('/api/visit/updateSegmentHtml', {
+                        segmentUid: $(this).attr('data-segment-uid')
+                    }, _data => {
+                        hideMask();
+                        updateAllSegmentsInResponse(_data);
+                    }, 'json');
+                    return false;
+                });
+
+            /*
+            $('[btn-save-form]').on('click', function() {
+                doSave($(this).closest('.note-section'));
+            });
+
+            @if(isset($guestAccessCode))
+                $('.note-section form').append("<input type='hidden' name='guest_access_code' value='{{$guestAccessCode}}'/>");
+            @endif
+
+            // copy link
+            $(document)
+                .off('click.copy', '.copy-link')
+                .on('click.copy', '.copy-link', function() {
+                    var copyText = $('#' + $(this).attr('data-id'));
+                    copyText.focus().select();
+                    document.execCommand("copy");
+                    toastr.success("The link " + copyText.val() + " has been copied to the clipboard");
+                    return false;
+                });
+
+            // [name="data"] change listener
+            $('.note-section input[name="data"], .note-section input[name="items"]').each(function() {
+                initChangeListener($(this));
+            });
+             */
+        }
+
+        addMCInitializer('note-segments-list', init);
+
+    })();
+</script>

+ 55 - 0
resources/views/app/patient/notes.blade.php

@@ -100,6 +100,61 @@
                     </div>
                 </form>
             </div>
+            <div moe>
+                <a start show class="py-0 mb-3">Add Visit</a>
+                <form url="/api/visit/create"
+                      redir="/patients/view/{{$patient->uid}}/notes/view/[data]"
+                      class="mcp-theme-1">
+                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                    @if($pro->is_hcp)
+                    <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
+                    @else
+                    <input type="hidden" name="naProUid" value="{{$pro->uid}}">
+                    @endif
+                    <input type="hidden" name="effectiveDate" value="{{date("Y-m-d")}}">
+                    <input type="hidden" name="effectiveTime" value="{{date("h:i")}}">
+                    <input type="text" class="form-control form-control-sm" placeholder="title" name="title" id="note-create-title" value="">
+                    <div class="form-group mb-2">
+                        <label for="" class="text-secondary text-sm mb-1">Note Template *</label>
+                        <select name="visitTemplateUid" class="form-control form-control-sm"
+                                onchange="$('#note-create-title').val($(this).find('option:selected').text())"
+                                required>
+                            <option value=""> --select--</option>
+                            @foreach($pro->visitTemplates() as $visitTemplate)
+                                <option value="{{$visitTemplate->uid}}">{{$visitTemplate->title}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="mb-2">
+                        <label for="" class="text-secondary text-sm mb-1">New/Fu</label>
+                        <select name="newOrFuOrNa" class="form-control form-control-sm note-method-select" required>
+                            <option value="NEW">New</option>
+                            <option value="FU">Follow-Up</option>
+                        </select>
+                    </div>
+                    <div class="mb-2">
+                        <label for="" class="text-secondary text-sm mb-1">Method *</label>
+                        <select name="noteContactMethod" class="form-control form-control-sm note-method-select" required>
+                            <option value="AUDIO">Audio</option>
+                            <option value="VIDEO">Video</option>
+                            <option value="IN_CLINIC">In-Clinic</option>
+                            <option value="HOUSE_CALL">House Call</option>
+                        </select>
+                    </div>
+                    <div class="form-group if-in-clinic">
+                        <label for="" class="text-secondary text-sm mb-1">Location</label>
+                        <select name="hcpCompanyLocationUid" class="form-control">
+                            <option value=""></option>
+                            @foreach($pro->companyLocations() as $location)
+                                <option value="{{$location->uid}}">{{$location->line1}} {{$location->city}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="form-group m-0">
+                        <button submit class="btn btn-primary btn-sm">submit</button>
+                    </div>
+                </form>
+            </div>
             <select class="ml-auto max-width-300px form-control form-control-sm"
                     onchange="fastLoad('/patients/view/{{$patient->uid}}/notes/' + this.value, true, false, false)">
                 <option value="active" {{ $filter === 'active' ? 'selected' : '' }}>Active notes</option>

+ 78 - 0
resources/views/app/patient/page-sections/cc/form.blade.php

@@ -0,0 +1,78 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'CHIEF_COMPLAINT')->first();
+
+
+$contentData = [
+    'value'=>''
+];
+
+if($page){
+    $contentData = json_decode($page->data, true);
+}
+?>
+<div id="ccSection">
+    <div class="form-group mb-2">
+        <input type="hidden" name="data" id="cc-data">
+        <div note-rte note-rte-ros data-content="{{isset($contentData['value'])?$contentData['value']:'' }}" class="form-group mb-2 border-left border-right rte-holder"></div>
+    </div>
+    <div class="form-group mb-2">
+        <button class="btn btn-sm btn-outline-primary" @click="save">Submit</button>
+    </div>
+</div>
+
+<script>
+    (function() {
+        function init() {
+            window.clientVitalsApp = new Vue({
+                el: '#ccSection',
+                data: {
+                    value: '',
+                },
+                mounted: function() {
+                    $(this.$el).closest('#ccSection').find('[name="data"]').val(this.value);
+                },
+                watch: {
+                    value: {
+                        handler: function(val, oldVal) {
+                            $(this.$el).closest('#ccSection').find('[name="data"]').val(this.value);
+                        },
+                        deep: true
+                    },
+                },
+                methods: {
+
+                    save: function(){
+                        console.log(this.value);
+                        showMask();
+                        console.log("DATA", this.value);
+
+                        var payload = {
+                            noteUid:  '{{$note->uid}}',
+                            parentPageUid: null,
+                            clientUid: '{{$patient->uid}}',
+                            category: 'CHIEF_COMPLAINT',
+                            key: null,
+                            data: $(this.$el).closest('#ccSection').find('[name="data"]').val()
+                        }
+                        console.log("PAYLOAD:  ", payload);
+                        $.post('/api/page/changeOrCreateNoteScoped', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Medication updated!');
+                                closeStagPopup();
+                            }
+                        }, 'json');
+                        hideMask();
+                        fastReload();
+                        return false;
+
+                    }
+                }
+            });
+        }
+        addMCInitializer('client-cc', init, '#ccSection');
+    })();
+</script>
+

+ 23 - 0
resources/views/app/patient/page-sections/cc/summary.php

@@ -0,0 +1,23 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'CHIEF_COMPLAINT')->first();
+
+$contentData = [
+    'value'=>''
+];
+if($page && $page->data){
+    $contentData = json_decode($page->data, true);
+}
+
+?>
+
+<?php if(!$page): ?>
+    <div>No CC data</div>
+<?php else: ?>
+    <div class="d-flex">
+        <div><?php echo $contentData['value'] ?></div>
+    </div>
+<?php endif; ?>
+

+ 121 - 0
resources/views/app/patient/page-sections/rx/form.blade.php

@@ -0,0 +1,121 @@
+<?php
+
+use App\Models\Page;
+
+$medicationsAddedOnIntake = Page::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->whereRaw("(is_active IS TRUE AND added_during_note_uid = ? AND added_reason_category = 'ADDED_ON_INTAKE') ",[$note->uid])
+    ->get();
+
+$medicationsRemovedOnIntake = Page::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->whereRaw("(is_active IS FALSE AND deactivated_during_note_uid  = ? AND deactivation_reason_category = 'REMOVED_ON_INTAKE')", [$note->uid])
+    ->get();
+
+
+?>
+<div id="medicationSection">
+    <table>
+        <thead>
+        <tr>
+            <th>Medication</th>
+            <th></th>
+            <th></th>
+            <th></th>
+        </tr>
+        </thead>
+        @foreach($medicationsAddedOnIntake as $medOnIntake)
+        <tr>
+            <td>{{$medOnIntake->key }}</td>
+            <td>Dose</td>
+            <td>Route</td>
+            <td>Frequency</td>
+            <td>Description</td>
+            <td></td>
+        </tr>
+        @endforeach
+        <tr>
+            <td>
+                <input type="text" v-model="currentMed.name" placeholder="name">
+            </td>
+            <td>
+                <input type="text" v-model="currentMed.dose" placeholder="dose">
+            </td>
+            <td>
+                <input type="text" v-model="currentMed.route" placeholder="route">
+            </td>
+            <td>
+                <input type="text" v-model="currentMed.frequency" placeholder="frequency">
+            </td>
+            <td>
+                <input type="text" v-model="currentMed.description" placeholder="description">
+            </td>
+            <td>
+                <button class="btn btn-sm btn-outline-primary" @click="save">Submit</button>
+            </td>
+        </tr>
+    </table>
+</div>
+
+<script>
+    (function() {
+        function init() {
+            window.clientVitalsApp = new Vue({
+                el: '#medicationSection',
+                data: {
+                    value: '',
+                    currentMed: {
+                        name:'',
+                        dose:'',
+                        route:'',
+                        frequency:'',
+                        description:''
+                    }
+                },
+                mounted: function() {
+                    $(this.$el).closest('#medicationSection').find('[name="data"]').val(this.value);
+                },
+                watch: {
+                    value: {
+                        handler: function(val, oldVal) {
+                            $(this.$el).closest('#medicationSection').find('[name="data"]').val(this.value);
+                        },
+                        deep: true
+                    },
+                },
+                methods: {
+
+                    save: function(){
+                        console.log(this.value);
+                        showMask();
+                        console.log("DATA", this.value);
+                        this.currentMed.isActive = true;
+                        this.currentMed.addedReasonCategory = 'ADDED_ON_INTAKE'; // ADDED_BY_HCP_DURING_NOTE, ADDED_ON_INTAKE;
+                        this.currentMed.addedReasonCategoryMemo = 'added on intake';
+                        var payload = {
+                            noteUid:  '{{$note->uid}}',
+                            parentPageUid: null,
+                            clientUid: '{{$patient->uid}}',
+                            category: 'MEDICATION',
+                            key: this.currentMed.name,
+                            data: JSON.stringify(this.currentMed)
+                        }
+                        console.log("PAYLOAD:  ", payload);
+                        $.post('/api/page/changeOrCreateClientScoped', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Medication updated!');
+                                closeStagPopup();
+                            }
+                        }, 'json');
+                        hideMask();
+                        fastReload();
+                        return false;
+
+                    }
+                }
+            });
+        }
+        addMCInitializer('client-medication', init, '#medicationSection');
+    })();
+</script>
+

+ 45 - 0
resources/views/app/patient/page-sections/rx/summary.php

@@ -0,0 +1,45 @@
+<?php
+
+use App\Models\Page;
+
+$medicationsAddedOnIntake = Page::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->whereRaw("(is_active IS TRUE AND  added_reason_category = 'ADDED_ON_INTAKE') ") //TODO fix query
+    ->get();
+
+$medicationsRemovedOnIntake = Page::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->whereRaw("(is_active IS FALSE AND deactivated_during_note_uid  = ? AND deactivation_reason_category = 'REMOVED_ON_INTAKE')", [$note->uid])
+    ->get();
+
+?>
+
+<?php if(!count($medicationsAddedOnIntake)): ?>
+    <div>No medications</div>
+<?php else: ?>
+    <div><h1><?php echo count($medicationsAddedOnIntake); ?></h1></div>
+    <div class="d-flex">
+        <table>
+            <thead>
+            <tr>
+                <th>Medication</th>
+                <th>Dose</th>
+                <th>Route</th>
+                <th>Frequency</th>
+                <th></th>
+            </tr>
+            </thead>
+            <?php foreach($medicationsAddedOnIntake as $medOnIntake): ?>
+            <tr>
+                <td><?php echo $medOnIntake->key ?></td>
+                <td><?php echo $medOnIntake->data_dose ?></td>
+                <td><?php echo $medOnIntake->data_route ?></td>
+                <td><?php echo $medOnIntake->data_frequency ?></td>
+                <td></td>
+            </tr>
+            <?php endforeach; ?>
+
+        </table>
+    </div>
+<?php endif; ?>
+

+ 78 - 0
resources/views/app/patient/page-sections/subjective/form.blade.php

@@ -0,0 +1,78 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'SUBJECTIVE_GENERAL')->first();
+
+
+$contentData = [
+    'value'=>''
+];
+
+if($page){
+    $contentData = json_decode($page->data, true);
+}
+?>
+<div id="subjectiveSection">
+    <div class="form-group mb-2">
+        <input type="hidden" name="data" id="subjective-data">
+        <div note-rte note-rte-ros data-content="{{isset($contentData['value'])?$contentData['value']:'' }}" class="form-group mb-2 border-left border-right rte-holder"></div>
+    </div>
+    <div class="form-group mb-2">
+        <button class="btn btn-sm btn-outline-primary" @click="save">Submit</button>
+    </div>
+</div>
+
+<script>
+    (function() {
+        function init() {
+            window.clientVitalsApp = new Vue({
+                el: '#subjectiveSection',
+                data: {
+                    value: '',
+                },
+                mounted: function() {
+                    $(this.$el).closest('#subjectiveSection').find('[name="data"]').val(this.value);
+                },
+                watch: {
+                    value: {
+                        handler: function(val, oldVal) {
+                            $(this.$el).closest('#subjectiveSection').find('[name="data"]').val(this.value);
+                        },
+                        deep: true
+                    },
+                },
+                methods: {
+
+                    save: function(){
+                        console.log(this.value);
+                        showMask();
+                        console.log("DATA", this.value);
+
+                        var payload = {
+                            noteUid:  '{{$note->uid}}',
+                            parentPageUid: null,
+                            clientUid: '{{$patient->uid}}',
+                            category: 'SUJECTIVE_GENERAL',
+                            key: null,
+                            data: $(this.$el).closest('#subjectiveSection').find('[name="data"]').val()
+                        }
+                        console.log("PAYLOAD:  ", payload);
+                        $.post('/api/page/changeOrCreateNoteScoped', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Record updated!');
+                                closeStagPopup();
+                            }
+                        }, 'json');
+                        hideMask();
+                        fastReload();
+                        return false;
+
+                    }
+                }
+            });
+        }
+        addMCInitializer('client-subjective', init, '#subjectiveSection');
+    })();
+</script>
+

+ 23 - 0
resources/views/app/patient/page-sections/subjective/summary.php

@@ -0,0 +1,23 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'SUBJECTIVE_GENERAL')->first();
+
+$contentData = [
+    'value'=>''
+];
+if($page && $page->data){
+    $contentData = json_decode($page->data, true);
+}
+
+?>
+
+<?php if(!$page): ?>
+    <div>No Subject data</div>
+<?php else: ?>
+    <div class="d-flex">
+        <div><?php echo $contentData['value'] ?></div>
+    </div>
+<?php endif; ?>
+

+ 20 - 0
resources/views/app/patient/page-sections/vitals/default.php

@@ -0,0 +1,20 @@
+<?php
+
+
+use App\Models\Page;
+
+$page = Page::where('client_id', $patient->id)->where('category', 'VITALS')->first();
+
+$contentData = [];
+
+if($page){
+    $contentData = json_decode($page->data, true);
+}else{
+    if ($patient->canvas_data) {
+        $canvasData = json_decode($patient->canvas_data, true);
+        if (isset($canvasData["vitals"])) {
+            $contentData = $canvasData["vitals"];
+        }
+    }
+}
+

+ 264 - 0
resources/views/app/patient/page-sections/vitals/form.blade.php

@@ -0,0 +1,264 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'VITALS')->first();
+
+$contentData = [];
+
+if($page){
+    $contentData = json_decode($page->data, true);
+}
+
+$vitalLabels = [
+    "heightInInches" => "Ht. (in.)",
+    "weightPounds" => "Wt. (lbs.)",
+    "temperatureF" => "Temp. (F)",
+    "systolicBP" => "SBP",
+    "diastolicBP" => "DBP",
+    "pulseRatePerMinute" => "Pulse",
+    "respirationRatePerMinute" => "Resp.",
+    "pulseOx" => "Pulse Ox.",
+    "smokingStatus" => "Smoking Status",
+    "bmi" => "BMI (kg/m²)",
+];
+if(!$contentData) {
+    $contentData = [
+        "heightInInches" => [
+            "label" => "Ht. (in.)",
+            "value" => "",
+            "date" => "",
+        ],
+        "weightPounds" => [
+            "label" => "Wt. (lbs.)",
+            "value" => "",
+            "date" => "",
+        ],
+        "temperatureF" => [
+            "label" => "Temp. (F)",
+            "value" => "",
+            "date" => "",
+        ],
+        "systolicBP" => [
+            "label" => "SBP",
+            "value" => "",
+            "date" => "",
+        ],
+        "diastolicBP" => [
+            "label" => "DBP",
+            "value" => "",
+            "date" => "",
+        ],
+        "pulseRatePerMinute" => [
+            "label" => "Pulse",
+            "value" => "",
+            "date" => "",
+        ],
+        "respirationRatePerMinute" => [
+            "label" => "Resp.",
+            "value" => "",
+            "date" => "",
+        ],
+        "pulseOx" => [
+            "label" => "Pulse Ox.",
+            "value" => "",
+            "date" => "",
+        ],
+        "smokingStatus" => [
+            "label" => "Smoking Status",
+            "value" => "",
+            "date" => "",
+        ],
+        "bmi" => [
+            "label" => "BMI (kg/m²)",
+            "value" => "",
+            "date" => "",
+        ],
+    ];
+}
+else {
+    // ensure $contentData has all the expected vitals and correct labels!
+    foreach ($vitalLabels as $k => $v) {
+        if(!isset($contentData[$k])) {
+            $contentData[$k] = [
+                "label" => $v,
+                "value" => "",
+                "date" => "",
+            ];
+        }
+    }
+}
+
+$formID = rand(0, 100000);
+?>
+<div id="vitalsSection">
+    <h3 class="stag-popup-title mb-2 border-bottom-0 pb-1 hide-if-note">
+        <span>Vitals</span>
+        <a href="#" onclick="return closeStagPopup()"
+           class="ml-auto text-secondary">
+            <i class="fa fa-times-circle"></i>
+        </a>
+    </h3>
+
+    <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+    <table class="table table-sm table-bordered mb-2 table-edit-sheet">
+        <thead>
+        <tr class="bg-light">
+            <th class="px-2 text-secondary border-bottom-0 w-25">Vital</th>
+            <th class="px-2 text-secondary border-bottom-0 w-35">Value</th>
+            <th class="px-2 text-secondary border-bottom-0">Date</th>
+        </tr>
+        </thead>
+        <tbody>
+            @foreach($vitalLabels as $k => $v)
+                <tr>
+                    <td>
+                        <input type="text" tabindex="-1"
+                               class="form-control form-control-sm events-none"
+                               data-field="title" value="{{ $v }}" readonly>
+                    </td>
+                    <td class="position-relative">
+                        @if($k === "bmi")
+                            <input type="text" readonly
+                                   class="form-control form-control-sm vitals-title"
+                                   data-field="value" v-model="bmi">
+                            <p class="py-1 m-0 px-2 font-weight-bold bg-white" v-if="!!bmi">
+                                <span class="text-sm text-warning-mellow" v-if="+bmi < 18.5">Underweight</span>
+                                <span class="text-sm text-success" v-if="+bmi >= 18.5 && +bmi < 25">Healthy Weight</span>
+                                <span class="text-sm text-warning-mellow" v-if="+bmi >= 25 && +bmi < 30">Overweight</span>
+                                <span class="text-sm text-warning-mellow" v-if="+bmi >= 30">Obese</span>
+                            </p>
+                        @elseif($k === "smokingStatus")
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   data-field="value" v-model="items['smokingStatus'].value"
+                                   data-option-list="smokingStatus"
+                                   v-on:change="autoDate(items['smokingStatus'], 'smokingStatus')" v-on:keyup="autoDate(items['smokingStatus'], 'smokingStatus')">
+                            <div id="smoking-status-options" class="data-option-list">
+                                <div>Current</div>
+                                <div>Former</div>
+                                <div>Never</div>
+                            </div>
+                        @else
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   data-field="value" v-model="items['{{ $k }}'].value"
+                                   v-on:change="autoDate(items['{{ $k }}'], '{{ $k }}')" v-on:keyup="autoDate(items['{{ $k }}'], '{{ $k }}')">
+                        @endif
+                    </td>
+                    <td>
+                        <input type="date" {{ $k === 'bmi' ? 'readonly' : '' }}
+                               class="form-control form-control-sm vitals-title"
+                               data-field="date" v-model="items['{{ $k }}'].date">
+                    </td>
+                </tr>
+
+            @endforeach
+        </tbody>
+    </table>
+    <div>
+        <button class="btn btn-sm btn-outline-primary" @click="save">Submit</button>
+    </div>
+</div>
+<script>
+    (function() {
+        function init() {
+            window.clientVitalsApp = new Vue({
+                el: '#vitalsSection',
+                data: {
+                    today: '{{ date("Y-m-d") }}',
+                    items: <?= json_encode($contentData) ?>,
+                    itemsOriginal: <?= json_encode($contentData) ?>
+                },
+                mounted: function() {
+                    $(this.$el).closest('#vitalsSection').find('[name="data"]').val(
+                        JSON.stringify(this.cleanObject(this.items))
+                    );
+                },
+                watch: {
+                    items: {
+                        handler: function(val, oldVal) {
+                            $(this.$el).closest('#vitalsSection').find('[name="data"]').val(
+                                JSON.stringify(this.cleanObject(this.items))
+                            );
+                        },
+                        deep: true
+                    },
+                },
+                computed: {
+                    bmi: function () {
+                        let result = '';
+                        let h = this.items.heightInInches, w = this.items.weightPounds;
+                        if(!h || !w) {
+                            return result;
+                        }
+                        h = h.value;
+                        w = w.value;
+                        try {
+                            h = parseFloat(h);
+                            w = parseFloat(w);
+                            if(!h || !w) {
+                                this.items.bmi.value = '';
+                                return result;
+                            }
+                            let result = (w / [ h * h]) * 703;
+                            return result.toFixed(1);
+                        }
+                        catch (e) {
+                            return result;
+                        }
+                    }
+                },
+                methods: {
+                    autoDate: function(_item, _index) {
+                        console.log('ALIX autoDate for', _index)
+                        if((_item.value !== this.itemsOriginal[_index].value) && !_item.date) {
+                            _item.date = this.today;
+                        }
+                    },
+                    cleanObject: function(_source) {
+                        let plObject = {};
+                        for (let y in _source) {
+                            if(_source.hasOwnProperty(y)) {
+                                plObject[y] = _source[y];
+                            }
+                        }
+                        plObject.bmi = {
+                            label: "BMI (kg/m²)",
+                            value: this.bmi,
+                            date: this.bmi ? this.today : '',
+                        };
+                        return plObject;
+                    },
+                    save: function(){
+                        console.log(this.items);
+                        showMask();
+                        console.log("DATA", this.items);
+
+                        var payload = {
+                             noteUid:  '{{$note->uid}}',
+                             parentPageUid: null,
+                             clientUid: '{{$patient->uid}}',
+                             category: 'VITALS',
+                             key: null,
+                             data: JSON.stringify(this.items)
+                        }
+                        console.log("PAYLOAD:  ", payload);
+                        $.post('/api/page/changeOrCreateNoteScoped', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Record updated!');
+                                closeStagPopup();
+                            }
+                        }, 'json');
+                        hideMask();
+                        fastReload();
+                        return false;
+
+                    }
+                }
+            });
+        }
+        addMCInitializer('client-vitals', init, '#vitalsSection');
+    })();
+</script>

+ 131 - 0
resources/views/app/patient/page-sections/vitals/summary.php

@@ -0,0 +1,131 @@
+<?php
+
+use App\Models\Page;
+
+$page = Page::where('note_id', $note->id)->where('category', 'VITALS')->first();
+$vitalLabels = [
+    "heightInInches" => "Ht. (in.)",
+    "weightPounds" => "Wt. (lbs.)",
+    "temperatureF" => "Temp. (F)",
+    "systolicBP" => "SBP",
+    "diastolicBP" => "DBP",
+    "pulseRatePerMinute" => "Pulse",
+    "respirationRatePerMinute" => "Resp.",
+    "pulseOx" => "Pulse Ox.",
+    "smokingStatus" => "Smoking Status",
+    "bmi" => "BMI (kg/m²)",
+];
+$contentData = [
+    "heightInInches" => [
+        "label" => "Ht. (in.)",
+        "value" => "",
+        "date" => "",
+    ],
+    "weightPounds" => [
+        "label" => "Wt. (lbs.)",
+        "value" => "",
+        "date" => "",
+    ],
+    "temperatureF" => [
+        "label" => "Temp. (F)",
+        "value" => "",
+        "date" => "",
+    ],
+    "systolicBP" => [
+        "label" => "SBP",
+        "value" => "",
+        "date" => "",
+    ],
+    "diastolicBP" => [
+        "label" => "DBP",
+        "value" => "",
+        "date" => "",
+    ],
+    "pulseRatePerMinute" => [
+        "label" => "Pulse",
+        "value" => "",
+        "date" => "",
+    ],
+    "respirationRatePerMinute" => [
+        "label" => "Resp.",
+        "value" => "",
+        "date" => "",
+    ],
+    "pulseOx" => [
+        "label" => "Pulse Ox.",
+        "value" => "",
+        "date" => "",
+    ],
+    "smokingStatus" => [
+        "label" => "Smoking Status",
+        "value" => "",
+        "date" => "",
+    ],
+    "bmi" => [
+        "label" => "BMI (kg/m²)",
+        "value" => "",
+        "date" => "",
+    ],
+];
+
+
+if($page){
+    $contentData = json_decode($page->data, true);
+}else{
+    if($patient->canvas_data) {
+        $canvasData = json_decode($patient->canvas_data, true);
+        if(isset($canvasData["vitals"])) {
+            $contentData = $canvasData["vitals"];
+            // ensure $contentData has all the expected vitals and correct labels!
+        }
+    }
+}
+
+foreach ($vitalLabels as $k => $v) {
+    if(!isset($contentData[$k])) {
+        $contentData[$k] = [
+            "label" => $v,
+            "value" => "",
+            "date" => "",
+        ];
+    }
+}
+
+foreach ($vitalLabels as $k => $v) {
+?>
+    <div class="d-flex vital-item align-items-center">
+        <span class="content-html text-nowrap">
+            <span><?= $v ?>:</span>
+            <?php
+            $vital = [];
+            if(isset($contentData[$k])) {
+                $vital = $contentData[$k];
+            }
+            ?>
+            <b><?= isset($vital["value"]) && !empty($vital["value"]) ? $vital["value"] : '-' ?></b>
+            <?php if($k === 'bmi' && isset($vital["value"]) && !empty($vital["value"])):
+                $bmi = floatval($vital["value"]);
+                ?>
+                <span class="ml-2 py-1 m-0 font-weight-bold">
+                    <?php if($bmi < 18.5): ?>
+                        <span class="text-sm text-warning-mellow">(Underweight)</span>
+                    <?php endif; ?>
+                    <?php if($bmi >= 18.5 && $bmi < 25): ?>
+                        <span class="text-sm text-success">(Healthy Weight)</span>
+                    <?php endif; ?>
+                    <?php if($bmi >= 25 && $bmi < 30): ?>
+                        <span class="text-sm text-warning-mellow">(Overweight)</span>
+                    <?php endif; ?>
+                    <?php if($bmi >= 30): ?>
+                        <span class="text-sm text-warning-mellow">(Obese)</span>
+                    <?php endif; ?>
+                </span>
+            <?php endif; ?>
+            <?php if(!!$vital["date"]): ?>
+                <span class="font-weight-normal text-secondary ml-2 text-sm">(as on <?= friendly_date_time($vital["date"], false) ?>)</span>
+            <?php endif; ?>
+        </span>
+    </div>
+<?php
+}
+?>

+ 1 - 1
resources/views/app/patient/partials/appointment-confirmation-history.blade.php

@@ -17,7 +17,7 @@ $cDecisions = $appointment->confirmationDecisions;
     <p class="my-2"><b>Decisions</b></p>
     @foreach($cDecisions as $cDecision)
         <div class="bg-light p-1 my-1 border border">
-            <b class="{{$cDecision->accepted_or_rejected === 'ACCEPTED' ? 'text-success' : 'text-warning-mellow'}}">{{$cDecision->accepted_or_rejected}}</b> on {{ friendly_date_time($cDecision->created_at) }}
+            <b class="{{$cDecision->accepted_or_rejected_or_waived === 'ACCEPTED' ? 'text-success' : 'text-warning-mellow'}}">{{$cDecision->accepted_or_rejected_or_waived}}</b> on {{ friendly_date_time($cDecision->created_at) }}
             @if($cDecision->memo)
                 <div class="text-sm">
                     <i>{{$cDecision->memo}}</i>

+ 32 - 0
resources/views/app/patient/prescriptions/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="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>

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

@@ -0,0 +1,73 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="prescription-popup-DRUG">
+    <form method="POST" action="">
+        <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>
+        <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"
+                   v-model="currentPrescription_DRUG.clinicalDetailJson.medication">
+        </div>
+        <div class="row">
+            <div class="col-6 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Strength</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.strength">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Amount</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.amount">
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-6 pr-0">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Route</label>
+                    <input type="text" class="form-control form-control-sm min-width-unset"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.route">
+                </div>
+            </div>
+            <div class="col-6">
+                <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"
+                           v-model="currentPrescription_DRUG.clinicalDetailJson.frequency">
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-6 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-6">
+                <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/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="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/imaging-form.blade.php

@@ -0,0 +1,30 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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>

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

@@ -0,0 +1,772 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    <div id="prescriptions-{{$patient->id}}">
+        <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>
+        </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>
+                    <th class="px-2 text-secondary border-bottom-0">Prescriber</th>
+                    <th class="px-2 text-secondary border-bottom-0">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="currentPrescription=prescription"
+                           :class="currentPrescription && currentPrescription.id === prescription.id ? 'font-weight-bold' : ''">@{{prescription.created_at_friendly_short}}</a>
+                    </td>
+                    <td class="px-2">@{{prescription.erx_category}}</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="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="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.strength ?? '-'}}</span>
+                                    <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.amount ?? '-'}}</span>
+                                    <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.route ?? '-'}}</span>
+                                </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">
+                        <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-500px 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>
+                    </h3>
+                    <a class="ml-auto" href="#" v-on:click.prevent="currentPrescription=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-center">
+                    <span class="min-width-140px text-secondary text-sm">Created</span>
+                    <span>@{{currentPrescription.created_at_friendly}}</span>
+                </div>
+                <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">
+                    <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.amount ?? '-'}}</span>
+                                <span class="text-secondary mr-1">@{{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">@{{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-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.drug-form')
+        @include('app.patient.prescriptions.lab-form')
+        @include('app.patient.prescriptions.imaging-form')
+        @include('app.patient.prescriptions.referral-form')
+        @include('app.patient.prescriptions.supply-form')
+        @include('app.patient.prescriptions.other-form')
+        @include('app.patient.prescriptions.logistics-form')
+        @include('app.patient.prescriptions.hcp-pro-form')
+        @include('app.patient.prescriptions.sign-as-hcp-form')
+        @include('app.patient.prescriptions.pro-status-form')
+        @include('app.patient.prescriptions.client-status-form')
+        @include('app.patient.prescriptions.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;
+                }
+            }
+            ?>
+
+            function init() {
+
+                window.booApp = new Vue({
+                    el: '#prescriptions-{{$patient->id}}',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        prescriptions: <?= json_encode($prescriptions) ?>,
+
+                        currentPrescriptionAction: '',
+                        currentPrescriptionType: '',
+
+                        // selected
+                        currentPrescription:  <?= $currentPrescription ?>,
+
+                        // for editing clinical details
+                        currentPrescription_DRUG: {
+                            noteUid: null, // TODO: this won't be null if created from a note
+                            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: {
+                                medication: '',
+                                strength: '',
+                                amount: '',
+                                route: '',
+                                frequency: '',
+                                dispense: '',
+                                refills: '',
+                                purpose: '',
+                            }
+                        },
+                        currentPrescription_LAB: {
+                            noteUid: null, // TODO: this won't be null if created from a note
+                            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: null, // TODO: this won't be null if created from a note
+                            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: null, // TODO: this won't be null if created from a note
+                            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: null, // TODO: this won't be null if created from a note
+                            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: null, // TODO: this won't be null if created from a note
+                            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/edit/save-clinical
+                        newPrescription: function(_type) {
+                            this.currentPrescriptionAction = 'ADD';
+                            this.currentPrescriptionType = _type;
+                            switch (_type) {
+                                case 'DRUG':
+                                    this.currentPrescription_DRUG = {
+                                        noteUid: null, // TODO: this won't be null if created from a note
+                                        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: {
+                                            medication: '',
+                                            strength: '',
+                                            amount: '',
+                                            route: '',
+                                            frequency: '',
+                                            dispense: '',
+                                            refills: '',
+                                            purpose: '',
+                                        }
+                                    };
+                                    break;
+                                case 'LAB':
+                                case 'IMAGING':
+                                    this.currentPrescription_LAB = {
+                                        noteUid: null, // TODO: this won't be null if created from a note
+                                        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: null, // TODO: this won't be null if created from a note
+                                        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: null, // TODO: this won't be null if created from a note
+                                        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: null, // TODO: this won't be null if created from a note
+                                        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('prescription-popup-' + this.currentPrescriptionType, true);
+                            });
+                        },
+                        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('prescription-popup-' + this.currentPrescriptionType, true);
+                            });
+                        },
+                        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();
+                                            fastLoad('/patients/view/{{$patient->uid}}/prescriptions/' + this.currentPrescriptionType.toLowerCase() + '/' + _data.data);
+                                        }
+                                    }, 'json');
+                                    break;
+                                case 'EDIT_CLINICAL':
+                                    $.post('/api/erx/updateClinicalDetail', payload, _data => {
+                                        if(!hasResponseError(_data)) {
+                                            toastr.success('Prescription updated');
+                                            closeStagPopup();
+                                            fastReload();
+                                        }
+                                    }, '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('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();
+                                    fastReload();
+                                }
+                            }, '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('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();
+                                    fastReload();
+                                }
+                            }, '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('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();
+                                    fastReload();
+                                }
+                            }, '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('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();
+                                    fastReload();
+                                }
+                            }, '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('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();
+                                    fastReload();
+                                }
+                            }, '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('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();
+                                    fastReload();
+                                }
+                            }, 'json');
+                            closeStagPopup();
+                        },
+
+                        // cancel, etc.
+
+                    },
+                    mounted: function() {
+                        let self = this;
+                        $(document).on('pro-changed', '.erx-hcp-pro-select', function() {
+                            self.currentPrescriptionHcpPro.newHcpProUid = this.value;
+                        });
+                    }
+                });
+
+            }
+            addMCInitializer('prescriptions-{{$patient->id}}', init, '#prescriptions-{{$patient->id}}')
+        }).call(window);
+    </script>
+@endsection

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

@@ -0,0 +1,30 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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>

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

@@ -0,0 +1,59 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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/other-form.blade.php

@@ -0,0 +1,25 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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>

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

@@ -0,0 +1,66 @@
+<section style="padding-top: 0.1rem;">
+
+    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%">
+        <tr>
+            <td style="width: 70%">
+                <b>Patient Information</b>
+            </td>
+            <td style="">
+                <div style="text-align: right">Date: <b>{{date('Y-m-d')}}</b></div>
+            </td>
+        </tr>
+    </table>
+
+    <div style="font-size: 14px; margin-top: 0.6rem; line-height: 1.4; opacity: 0.6">
+        <span>{{ $patient->displayName() }}, {{$patient->sex}}, {{$patient->age_in_years}} years old</span><br>
+        <?php
+        $addressParts = [];
+        if (!!$patient->mailing_address_line1) $addressParts[] = $patient->mailing_address_line1;
+        if (!!$patient->mailing_address_line2) $addressParts[] = $patient->mailing_address_line2;
+        $addressParts = implode(", ", $addressParts) . ", ";
+        $addressPart2 = [];
+        if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
+        if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
+        $addressParts .= implode(", ", $addressPart2);
+        ?>
+        <span>{!! $addressParts !!}</span>
+    </div>
+</section>
+
+<?php $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/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/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/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/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/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>
+

Файловите разлики са ограничени, защото са твърде много
+ 13 - 0
resources/views/app/patient/prescriptions/pdf/pdf-preview-with-cover-sheet.blade.php


Файловите разлики са ограничени, защото са твърде много
+ 13 - 0
resources/views/app/patient/prescriptions/pdf/pdf-preview.blade.php


+ 32 - 0
resources/views/app/patient/prescriptions/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="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/referral-form.blade.php

@@ -0,0 +1,25 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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/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="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/supply-form.blade.php

@@ -0,0 +1,34 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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/transmit-form.blade.php

@@ -0,0 +1,66 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="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>

+ 37 - 0
resources/views/app/patient/segment-templates/_child_review/edit-review.php

@@ -0,0 +1,37 @@
+<?php
+if (!@$intakeOrVisit) {
+    $intakeOrVisit = 'INTAKE'; // default
+}
+$epPart = ($intakeOrVisit === 'INTAKE') ? 'Review' : 'Plan';
+$currentValue = '';
+if($intakeOrVisit === 'INTAKE') {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        $currentValue = $parsedReview->value;
+    }
+}
+else {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildPlan->data);
+        $currentValue = $parsedReview->value;
+    }
+}
+?>
+<div visit-moe relative>
+    <a start show href="#">Edit</a>
+    <form url="/api/visitPoint/upsertChild<?= $epPart ?>" class="mcp-theme-1" right>
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="data">
+
+        <p class="mb-2"><b>Review</b></p>
+
+        <div class="mb-2">
+            <textarea data-name="value" class="form-control form-control-sm" rows="3"><?= $currentValue ?></textarea>
+        </div>
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        </div>
+    </form>
+</div>

+ 38 - 0
resources/views/app/patient/segment-templates/_child_review/last-review.php

@@ -0,0 +1,38 @@
+<?php
+if (!@$intakeOrVisit) {
+    $intakeOrVisit = 'INTAKE'; // default
+}
+?>
+<?php if ($intakeOrVisit === 'INTAKE'): ?>
+    <?php if ($point->lastChildReview): ?>
+        <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+        <div><?= $parsedReview->value ?></div>
+        <div class="text-secondary text-sm"></div>
+        <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+            <span class="text-secondary text-sm">(reviewed on this note)</span>
+        <?php else: ?>
+            <a native target="_blank"
+               href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>">
+                <?= friendlier_date_time($point->last_child_review_effective_date) ?>
+            </a>
+        <?php endif; ?>
+    <?php else: ?>
+        <span class="text-secondary text-sm">None</span>
+    <?php endif; ?>
+<?php else: ?>
+    <?php if ($point->lastChildPlan): ?>
+        <?php $parsedReview = json_decode($point->lastChildPlan->data); ?>
+        <div><?= $parsedReview->value ?></div>
+        <div class="text-secondary text-sm"></div>
+        <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+            <span class="text-secondary text-sm">(reviewed on this note)</span>
+        <?php else: ?>
+            <a native target="_blank"
+               href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>">
+                <?= friendlier_date_time($point->last_child_plan_effective_date) ?>
+            </a>
+        <?php endif; ?>
+    <?php else: ?>
+        <span class="text-secondary text-sm">None</span>
+    <?php endif; ?>
+<?php endif; ?>

+ 160 - 0
resources/views/app/patient/segment-templates/_common_actions/remove-undo.php

@@ -0,0 +1,160 @@
+<?php
+if(!@$intakeOrVisit) {
+    $intakeOrVisit = 'INTAKE'; // default
+}
+$whenLabel = ($intakeOrVisit === 'INTAKE') ? 'on intake' : 'during visit';
+$epPart = ($intakeOrVisit === 'INTAKE') ? 'OnIntake' : 'DuringVisit';
+?>
+<?php if ($point->is_removed): ?>
+    <?php if ($point->is_removed_due_to_entry_error): ?>
+        <span class="font-weight-bold text-secondary mr-2 text-nowrap">Entry error</span>
+    <?php else: ?>
+        <span class="font-weight-bold text-secondary mr-2 text-nowrap">Removed <?= $whenLabel ?></span>
+    <?php endif; ?>
+    <div visit-moe>
+        <form show url="/api/visitPoint/undoMarkRemoved" class="mcp-theme-1">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <a submit href="#">Undo</a>
+        </form>
+    </div>
+<?php else: ?>
+    <?php if($point->added_in_note_id === $note->id): ?>
+        <span class="font-weight-bold text-success mx-2 text-nowrap">* Added <?= $whenLabel ?></span>
+    <?php endif; ?>
+    <div visit-moe>
+        <a start show href="#">Remove</a>
+        <form url="/api/visitPoint/markRemoved<?= $epPart ?>" class="mcp-theme-1">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+
+            <p class="mb-2"><b>Remove <?= $label ?> <?= $whenLabel ?></b></p>
+
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Removal Reason</label>
+                <textarea name="removalReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
+            </div>
+            <?php if($point->added_in_note_id === $note->id): ?>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Is Entry Error?  *</label>
+                    <select name="isRemovedDueToEntryError" class="form-control form-control-sm" required>
+                        <option value="">-- select --</option>
+                        <option value="1" selected>Yes</option>
+                        <option value="0">No</option>
+                    </select>
+                </div>
+            <?php else: ?>
+                <input type="hidden" name="isRemovedDueToEntryError" value="0">
+            <?php endif; ?>
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Removal Effective Date</label>
+                <input type="date" name="removalEffectiveDate"
+                       value="<?= date('Y-m-d') ?>"
+                       max="<?= date('Y-m-d') ?>"
+                       class="form-control form-control-sm">
+            </div>
+            <div>
+                <button submit class="btn btn-sm btn-danger mr-2">Remove</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+
+<!-- additional actions -->
+<div class="ml-2 position-relative on-click-menu">
+    <span class="d-block btn btn-sm btn-default px-1 py-0 border font-weight-bold text-secondary align-middle">&hellip;</span>
+    <div menu class="bg-white border">
+
+        <!-- if removed -->
+            <!-- ACT: update removal reason memo -->
+            <!-- if entry error -->
+                <!-- ACT: mark as not entry error-->
+            <!-- if not entry error-->
+                <!-- ACT: mark as entry error-->
+        <!-- if not removed -->
+            <!-- ACT: update addition reason memo -->
+            <!-- ACT: mark added during visit -->
+
+        <?php if ($point->is_removed): ?>
+            <div class="border-bottom">
+                <div visit-moe>
+                    <a start show href="#" class="px-2 py-1 d-block text-nowrap">Update removal reason</a>
+                    <form url="/api/visitPoint/updateRemovalReasonMemo" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                        <p class="mb-2"><b>Update Removal Reason</b></p>
+                        <div class="mb-2">
+                            <label class="text-sm text-secondary mb-1">Removal Reason</label>
+                            <textarea name="removalReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
+                        </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>
+            <?php if ($point->is_removed_due_to_entry_error): ?>
+                <div class="border-bottom">
+                    <div visit-moe>
+                        <form show url="/api/visitPoint/setIsRemovedDueToEntryErrorToFalse" class="mcp-theme-1">
+                            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                            <a submit href="#" class="text-nowrap px-2 py-1 d-block">Mark as not entry error</a>
+                        </form>
+                    </div>
+                </div>
+            <?php else: ?>
+                <div class="border-bottom">
+                    <div visit-moe>
+                        <form show url="/api/visitPoint/setIsRemovedDueToEntryErrorToTrue" class="mcp-theme-1">
+                            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                            <a submit href="#" class="text-nowrap px-2 py-1 d-block">Mark as entry error</a>
+                        </form>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php else: ?>
+            <div class="border-bottom">
+                <div visit-moe>
+                    <a start show href="#" class="px-2 py-1 d-block text-nowrap">Update addition reason</a>
+                    <form url="/api/visitPoint/updateAdditionReasonMemo" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                        <p class="mb-2"><b>Update Addition Reason</b></p>
+                        <div class="mb-2">
+                            <label class="text-sm text-secondary mb-1">Addition Reason</label>
+                            <textarea name="additionReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
+                        </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>
+            <div class="border-bottom">
+                <div visit-moe>
+                    <a start show href="#" class="px-2 py-1 d-block text-nowrap">Mark as added <?= $whenLabel ?></a>
+                    <form url="/api/visitPoint/markAdded<?= $epPart ?>" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                        <p class="mb-2"><b>Mark as added <?= $whenLabel ?></b></p>
+                        <div class="mb-2">
+                            <label class="text-sm text-secondary mb-1">Addition Reason</label>
+                            <textarea name="additionReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
+                        </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>
+        <?php endif; ?>
+
+
+    </div>
+</div>

+ 24 - 0
resources/views/app/patient/segment-templates/_simple_text_segment/edit.php

@@ -0,0 +1,24 @@
+<?php
+
+use App\Models\Point;
+
+$point = Point::where('added_in_segment_id', $segment->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data">
+        <div note-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+        ><?= $parsed && $parsed->value ? $parsed->value : '' ?></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>

+ 20 - 0
resources/views/app/patient/segment-templates/_simple_text_segment/summary.php

@@ -0,0 +1,20 @@
+<?php
+
+use App\Models\Point;
+
+$point = Point::where('added_in_segment_id', $segment->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div>
+    <?php
+    if (!!$parsed && @$parsed->value) {
+        echo $parsed->value;
+    }
+    else {
+        echo "-";
+    }
+    ?>
+</div>

+ 4 - 0
resources/views/app/patient/segment-templates/chief_complaint/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'CHIEF_COMPLAINT';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/chief_complaint/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'CHIEF_COMPLAINT';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 1 - 0
resources/views/app/patient/segment-templates/history_family/edit.blade.php

@@ -0,0 +1 @@
+<h1>Edit for history_family</h1>

+ 1 - 0
resources/views/app/patient/segment-templates/history_family/summary.blade.php

@@ -0,0 +1 @@
+<h1>Summary for history_family</h1>

+ 1 - 0
resources/views/app/patient/segment-templates/history_screenings/edit.blade.php

@@ -0,0 +1 @@
+<h1>Edit for history_screenings</h1>

+ 1 - 0
resources/views/app/patient/segment-templates/history_screenings/summary.blade.php

@@ -0,0 +1 @@
+<h1>Summary for history_screenings</h1>

+ 267 - 0
resources/views/app/patient/segment-templates/history_social/edit.blade.php

@@ -0,0 +1,267 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY',true);
+
+$socHx = $point->data;
+
+$fields = [
+    [
+        "Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
+    ],
+    [
+        "Alcohol" => ["Do not drink", "Drink daily", "Frequently drink", "Hx of Alcoholism", "Occasional drink"],
+        "Drug Abuse" => ["IVDU", "Illicit drug use", "No illicit drug use"],
+    ],
+    [
+        "Cardiovascular" => ["Eat healthy meals", "Regular exercise", "Take daily aspirin"],
+        "Safety" => ["Household Smoke detector", "Keep Firearms in home", "Wear seatbelts"],
+    ],
+    [
+        "Sexual Activity" => ["Exposure to STI", "Homosexual encounters", "Not sexually active", "Safe sex practices", "Sexually active"],
+        "Birth Gender" => ["Male", "Female", "Undifferentiated"],
+    ]
+];
+
+$customFields = [];
+/*
+ // TODO
+$customFields = $pro->canvasCustomItems('sochx');
+$customFields = array_map(function($_item) {
+    return $_item['label'];
+}, $customFields->toArray());
+*/
+if (!$socHx) {
+    $socHx = [
+        "common" => [],
+        "custom" => [],
+        "comments" => "",
+    ];
+}
+
+$contentData = $socHx;
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="SOCIAL_HISTORY">
+        <input type="hidden" name="data">
+        <div class="row">
+            <?php for ($i = 0; $i < count($fields); $i++): ?>
+                <div class="col-md-3">
+                    <?php foreach ($fields[$i] as $head => $values): ?>
+                        <div class="font-weight-bold mb-2"><?= $head ?></div>
+                        <div class="mb-3">
+                            <?php for ($k = 0; $k < count($values); $k++): ?>
+                                <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
+                                <label class="d-flex align-items-center mb-1">
+                                    <input type="checkbox" class="m-0"
+                                           data-name="common-><?= $fName ?>"
+                                        <?= @$contentData['common'][$fName] ? 'checked' : '' ?>
+                                    >
+                                    <span class="mx-2"><?= $values[$k] ?></span>
+                                    <!--<div moe>
+                                        <a href="#" start show>
+                                            <i v-show="common['<?= $fName ?>']" class="fa-comment"
+                                               :class="common['<?= $fName ?>__comments'] ? 'fas' : 'far'"></i>
+                                        </a>
+                                        <div url="/nop">
+                                            <div class="mb-2">
+                                        <textarea class="form-control form-control-sm ns-custom-comment"
+                                                  data-name="common['<?= $fName ?>__comments']"></textarea>
+                                            </div>
+                                            <div class="">
+                                                <button type="button" class="btn btn-sm btn-primary" cancel>Close
+                                                </button>
+                                            </div>
+                                        </div>
+                                    </div>-->
+                                </label>
+                            <?php endfor; ?>
+                        </div>
+                    <?php endforeach; ?>
+                </div>
+            <?php endfor; ?>
+        </div>
+
+        <?php /*
+            <div class="row border-top pt-3">
+                <div class="col-12">
+                    <div class="d-flex align-items-center mb-2">
+                        <span class="font-weight-bold">Custom Items</span>
+                        <span class="mx-2 text-secondary">|</span>
+                        <div moe>
+                            <a href="#" start show>Add</a>
+                            <div custom-item-form url="/api/sectionTemplateCustomItem/create">
+                                <div class="mb-2">
+                                    <input type="text" placeholder="Label"
+                                           v-model="newCustomItemLabel"
+                                           class="form-control form-control-sm label_new_custom_item">
+                                </div>
+                                <div>
+                                    <button type="button" class="btn btn-sm btn-primary mr-1"
+                                            v-on:click.prevent="saveCustomItem(newCustomItemLabel)">Submit</button>
+                                    <button type="button" class="btn btn-sm btn-default border"
+                                            v-on:click.prevent="cancelCustomItem()">Cancel</button>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    {{-- custom items --}}
+                    <div class="d-flex align-items-start flex-wrap custom-items-container">
+                        <div class="w-25" v-for="item in customFields">
+                            <label class="d-flex align-items-center mb-1">
+                                <input type="checkbox" class="m-0"
+                                       v-model="item.value">
+                                <span class="mx-2">@{{ item.label }}</span>
+                                <div moe>
+                                    <a href="#" start show>
+                                        <i v-show="item.value" class="fa-comment" :class="item.comments ? 'fas' : 'far'"></i>
+                                    </a>
+                                    <div url="/nop">
+                                        <div class="mb-2">
+                                            <textarea class="form-control form-control-sm ns-custom-comment" v-model="item.comments"></textarea>
+                                        </div>
+                                        <div class="">
+                                            <button type="button" class="btn btn-sm btn-primary" cancel>Close</button>
+                                        </div>
+                                    </div>
+                                </div>
+                            </label>
+                        </div>
+                    </div>
+
+                </div>
+            </div>
+            */ ?>
+
+        <div class="row mb-3">
+            <div class="col-12">
+                <textarea type="text" class="form-control form-control-sm p-2 mt-2"
+                          data-name="comments"
+                          placeholder="Comments"><?= @$contentData['comments'] ?: '' ?></textarea>
+            </div>
+        </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>
+
+<script>
+    (function () {
+        let model = <?= json_encode($contentData) ?>;
+        model.newCustomItemLabel = '';
+        let customFields = <?= json_encode($customFields) ?>;
+        if (!model.customFields) {
+            model.customFields = [];
+        }
+        for (let i = 0; i < customFields.length; i++) {
+            let found = model.customFields.filter(function (_item) {
+                return _item.label === customFields[i];
+            }).length;
+            if (!found) {
+                model.customFields.push({
+                    label: customFields[i],
+                    value: '',
+                    comments: '',
+                })
+            }
+        }
+
+        function init() {
+            window.clientSocHXApp = new Vue({
+                el: '#sochxSection',
+                data: model,
+                mounted: function () {
+                    $('#sochxSection [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                    $('#sochxSection').find('[name="data"]').val(JSON.stringify({
+                        common: this.cleanObject(this.common),
+                        customFields: this.customFields,
+                        comments: this.comments,
+                    }));
+                },
+                watch: {
+                    $data: {
+                        handler: function (val, oldVal) {
+                            $('#sochxSection').find('[name="data"]').val(JSON.stringify({
+                                common: this.cleanObject(this.common),
+                                customFields: this.customFields,
+                                comments: this.comments,
+                            }));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    cleanObject: function (_source) {
+                        let plObject = {};
+                        for (let y in _source) {
+                            if (_source.hasOwnProperty(y)) {
+                                plObject[y] = _source[y];
+                            }
+                        }
+                        return plObject;
+                    },
+                    saveCustomItem: function (_label) {
+                        if (!_label) return false;
+                        showMask();
+                        let self = this;
+                        $.post('/api/clientCanvasCustomItem/create', {
+                            proUid: '{{ $pro->uid }}',
+                            key: 'sochx',
+                            label: _label
+                        }, function (_data) {
+                            hideMask();
+                            if (_data && _data.success) {
+                                self.appendCustomItem(_label);
+                                hideMoeFormMask();
+                                $('[custom-item-form]').hide();
+                            } else {
+                                toastr.error(_data.message);
+                            }
+                        }, 'json');
+                        return false;
+                    },
+                    cancelCustomItem: function () {
+                        hideMoeFormMask();
+                        $('div[moe]').hide();
+                        return false;
+                    },
+                    appendCustomItem: function (_name) {
+                        this.customFields.push({
+                            label: _name,
+                            value: '',
+                            comments: '',
+                        });
+                        Vue.nextTick(function () {
+                            $('.custom-items-container [moe][initialized]').removeAttr('initialized');
+                            initMoes();
+                        });
+                    }
+                }
+            });
+        }
+
+        window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
+            // any JS can come here
+            // will be run on page-load as well as whenever this segment is refreshed
+        };
+
+        // addMCInitializer('client-sochx', init, '#sochxSection');
+    })();
+</script>

+ 95 - 0
resources/views/app/patient/segment-templates/history_social/summary.blade.php

@@ -0,0 +1,95 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY', true);
+
+$contentData = $point->data;
+
+$fields = [
+    [
+        "Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
+    ],
+    [
+        "Alcohol" => ["Do not drink", "Drink daily", "Frequently drink", "Hx of Alcoholism", "Occasional drink"],
+        "Drug Abuse" => ["IVDU", "Illicit drug use", "No illicit drug use"],
+    ],
+    [
+        "Cardiovascular" => ["Eat healthy meals", "Regular exercise", "Take daily aspirin"],
+        "Safety" => ["Household Smoke detector", "Keep Firearms in home", "Wear seatbelts"],
+    ],
+    [
+        "Sexual Activity" => ["Exposure to STI", "Homosexual encounters", "Not sexually active", "Safe sex practices", "Sexually active"],
+        "Birth Gender" => ["Male", "Female", "Undifferentiated"],
+    ]
+];
+
+$isempty = false;
+if(!$contentData) {
+    $contentData = [
+        "common" => [],
+        "customFields" => [],
+        "comments" => "",
+    ];
+    $isempty = true;
+}
+
+if($isempty) {
+    echo '<span class="text-secondary">No social history in the system</span>';
+}
+else {
+
+    for ($i = 0; $i < count($fields); $i++):
+        foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                if(@$contentData['common'][$fName]): ?>
+                    <div>
+                        <?= ucwords($head) ?>
+                        <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                        <span class="font-weight-bold"><?= $values[$k] ?></span>
+                        <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                            <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                        <?php endif; ?>
+                    </div>
+                <?php
+                endif;
+            endfor;
+        endforeach;
+    endfor;
+
+    // custom fields
+    if(@$contentData['customFields'] && count($contentData['customFields'])):
+        ?> <div class="mt-2"> <?php
+        for ($i = 0; $i < count($contentData['customFields']); $i++):
+            $item = $contentData['customFields'][$i];
+            if($item['value']): ?>
+                <div>
+                    Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                        <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+            <?php
+            endif;
+        endfor;
+        ?> </div> <?php
+    endif;
+
+    if(isset($contentData['comments'])) { ?>
+        <div class="mt-2 mb-1">
+            <div class="font-weight-bold">Comments:</div>
+            <div><?= $contentData['comments'] ?></div>
+        </div>
+    <?php }
+}
+?>

+ 1 - 0
resources/views/app/patient/segment-templates/history_surgical/edit.blade.php

@@ -0,0 +1 @@
+<h1>Edit for history_surgical</h1>

+ 1 - 0
resources/views/app/patient/segment-templates/history_surgical/summary.blade.php

@@ -0,0 +1 @@
+<h1>Summary for history_surgical</h1>

+ 87 - 0
resources/views/app/patient/segment-templates/intake_allergies/edit.blade.php

@@ -0,0 +1,87 @@
+<?php
+
+use App\Models\Point;
+use \App\Models\Client;
+use \App\Models\Note;
+use \App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+$allergies = Point::getIntakePointsOfCategory($patient, 'ALLERGY', $note);
+
+?>
+<div>
+
+    <div class="d-flex mb-2">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+            <thead>
+            <tr class="">
+                <th class="border-bottom-0">Allergy</th>
+                <th class="border-bottom-0">Last Review</th>
+                <th class="border-bottom-0">Review Today</th>
+            </tr>
+            </thead>
+            <?php foreach($allergies as $allergy): ?>
+                <tr>
+                    <td>
+                        <div class="d-flex align-items-baseline">
+                            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+                            </div>
+
+                            <!-- common actions -->
+                            <div class="ml-auto d-inline-flex align-items-baseline pr-2">
+                                <?php
+                                $point = $allergy;
+                                $label = 'Allergy';
+                                include resource_path('views/app/patient/segment-templates/_common_actions/remove-undo.php');
+                                ?>
+                            </div>
+                        </div>
+                    </td>
+                    <td>
+                        <?php
+                        $point = $allergy;
+                        include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                        ?>
+                    </td>
+                    <td>
+                        <?php
+                        $point = $allergy;
+                        include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                        ?>
+                    </td>
+                </tr>
+            <?php endforeach; ?>
+        </table>
+    </div>
+
+    <div visit-moe class="mt-1">
+        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add allergy patient is ALREADY having, prior to this visit</a>
+        <form url="/api/visitPoint/addTopLevelOnIntake" class="mcp-theme-1">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="category" value="ALLERGY">
+            <input type="hidden" name="data">
+
+            <p class="mb-2"><b>Add Allergy (on intake)</b></p>
+
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Name</label>
+                <input type="text" data-name="name" class="form-control form-control-sm">
+            </div>
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Description</label>
+                <input type="text" data-name="description" class="form-control form-control-sm">
+            </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>
+

+ 48 - 0
resources/views/app/patient/segment-templates/intake_allergies/summary.blade.php

@@ -0,0 +1,48 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$allergies = Point
+    ::where('client_id', $patient->id)
+    ->where('category', 'ALLERGY')
+    ->where('addition_reason_category', 'ON_INTAKE')
+    ->where(function ($query1) use ($note) {
+        $query1
+            ->where('is_removed', false)
+            ->orWhere(function ($query2) use ($note) {
+                $query2->where('is_removed', true)
+                    ->where('is_removed_due_to_entry_error', false)
+                    ->where('removed_in_note_id', $note->id);
+            });
+    })
+    ->orderBy('created_at')
+    ->get();
+
+foreach ($allergies as $allergy) {
+    if ($allergy->data) {
+        $allergy->data = json_decode($allergy->data);
+    }
+}
+
+?>
+
+<?php if (!count($allergies)): ?>
+    <div class="text-secondary">No allergies</div>
+<?php else: ?>
+    <?php foreach ($allergies as $allergy): ?>
+        <div class="d-flex align-items-baseline mb-2">
+            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+            </div>
+            <?php if ($allergy->is_removed): ?>
+                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+            <?php elseif ($allergy->added_in_note_id === $note->id): ?>
+                <span class="ml-2 text-sm text-success">* Added on intake</span>
+            <?php endif; ?>
+        </div>
+    <?php endforeach; ?>
+<?php endif; ?>
+

+ 1 - 0
resources/views/app/patient/segment-templates/intake_care_team/edit.blade.php

@@ -0,0 +1 @@
+<h1>Edit for intake_care_team</h1>

+ 1 - 0
resources/views/app/patient/segment-templates/intake_care_team/summary.blade.php

@@ -0,0 +1 @@
+<h1>Summary for intake_care_team</h1>

Някои файлове не бяха показани, защото твърде много файлове са промени