Ver Fonte

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2

Josh há 3 anos atrás
pai
commit
7d12f9a9cc
25 ficheiros alterados com 774 adições e 433 exclusões
  1. 2 0
      .env-example
  2. 4 0
      app/Helpers/fdb.php
  3. 10 0
      app/Http/Controllers/McpController.php
  4. 3 1
      config/app.php
  5. 4 1
      public/js/option-list.js
  6. 3 3
      public/js/stag-popup.js
  7. 2 2
      resources/views/app/mcp/patients-table.blade.php
  8. 8 1
      resources/views/app/mcp/patients_filters.blade.php
  9. 37 0
      resources/views/app/patient/dashboard.blade.php
  10. 6 256
      resources/views/app/patient/incoming-reports.blade.php
  11. 11 0
      resources/views/app/patient/note/dashboard.blade.php
  12. 46 15
      resources/views/app/patient/prescriptions-popup/imaging-form.blade.php
  13. 57 15
      resources/views/app/patient/prescriptions-popup/lab-form.blade.php
  14. 234 24
      resources/views/app/patient/prescriptions-popup/list-popup.blade.php
  15. 45 33
      resources/views/app/patient/prescriptions/imaging-form.blade.php
  16. 56 33
      resources/views/app/patient/prescriptions/lab-form.blade.php
  17. 232 36
      resources/views/app/patient/prescriptions/list.blade.php
  18. 1 1
      resources/views/app/patient/segment-templates/chief_complaint/summary.blade.php
  19. 1 1
      resources/views/app/patient/segment-templates/plan_allergies/summary.blade.php
  20. 1 1
      resources/views/app/patient/segment-templates/plan_care_team/summary.blade.php
  21. 1 1
      resources/views/app/patient/segment-templates/plan_goals/summary.blade.php
  22. 1 1
      resources/views/app/patient/segment-templates/plan_medications/summary.blade.php
  23. 1 1
      resources/views/app/patient/segment-templates/plan_problems/summary.blade.php
  24. 4 3
      resources/views/app/pdf/viewer.blade.php
  25. 4 4
      resources/views/layouts/patient.blade.php

+ 2 - 0
.env-example

@@ -53,3 +53,5 @@ AUTH_URL="http://localhost:3002"
 BACKEND_WS_URL=http://localhost:8080/ws
 AGORA_APPID=9d04292b03524927a8fe9d937a448d85
 AGORA_MODE=screen
+
+POINT_IMPL_DATE=2021-10-29

+ 4 - 0
app/Helpers/fdb.php

@@ -505,6 +505,8 @@ WHERE r1.ddi_codex IN (" . implode(',', array_map(function ($_x) {
 if(!function_exists('duplicate_therapy_info')) {
     function duplicate_therapy_info($_drugs) {
 
+        if(!$_drugs || count($_drugs) < 2) return '';
+
         $dptClasses = [];
         foreach ($_drugs as $drug) {
             $drug->dpt = getDptClassFromGcnSeqNo($drug->data->gcnSeqno);
@@ -532,6 +534,8 @@ if(!function_exists('duplicate_therapy_info')) {
 if(!function_exists('duplicate_therapy_info_with_pivot')) {
     function duplicate_therapy_info_with_pivot($_pivot, $_drugs) {
 
+        if(!$_drugs || count($_drugs) < 1) return '';
+
         $_pivot->dpt = getDptClassFromGcnSeqNo($_pivot->data->gcnSeqno);
 
         $dptClasses = [];

+ 10 - 0
app/Http/Controllers/McpController.php

@@ -64,6 +64,16 @@ class McpController extends Controller
         ]
         */
 
+        if ($request->input('name')) {
+            $name = trim($request->input('name'));
+            if ($name) {
+                $patients = $patients->where(function ($q) use ($name) {
+                    $q->where('name_first', 'ILIKE', '%' . $name . '%')
+                        ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
+                });
+            }
+        }
+
         $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2');
         $this->filterSimpleQuery($request, $patients, 'sex', 'sex');
         $this->filterMultiQuery($request, $patients, 'usual_bmi', 'bmi_category', 'bmi_value_1', 'bmi_value_2');

+ 3 - 1
config/app.php

@@ -65,12 +65,14 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 21,
+    'asset_version' => 22,
 
     'temp_dir' => env('TEMP_DIR'),
 
     'stagfe6_url' => env('STAGFE6_URL'),
 
+    'point_impl_date' => env('POINT_IMPL_DATE', '2021-10-29'),
+
     /*
     |--------------------------------------------------------------------------
     | Application Timezone

+ 4 - 1
public/js/option-list.js

@@ -14,7 +14,10 @@
     function init() {
         $(document)
             .off('mousedown.option-list', '.data-option-list>div')
-            .on('mousedown.option-list', '.data-option-list>div', function() {
+            .on('mousedown.option-list', '.data-option-list>div', function(_e) {
+                _e.stopPropagation();
+                _e.preventDefault();
+                markEventAsConsumed(_e);
                 $(this).parent().prev('input[data-option-list]').val('').focus();
                 document.execCommand('insertText', false, $(this).text());
                 $(this).closest('.data-option-list').hide();

+ 3 - 3
public/js/stag-popup.js

@@ -184,9 +184,9 @@ function hasResponseError(_data) {
 (function() {
     window.initStagPopupEvents = function () {
         $(document)
-            .off('click.stag-popup-discard', '.stag-popup')
-            .on('click.stag-popup-discard', '.stag-popup', function(_e) {
-                if($(_e.target).is('.stag-popup')) {
+            .off('mousedown.stag-popup-discard', '.stag-popup')
+            .on('mousedown.stag-popup-discard', '.stag-popup', function(_e) {
+                if($(_e.target).is('.stag-popup') && !isEventConsumed(_e)) {
                     closeStagPopup();
                     return false;
                 }

+ 2 - 2
resources/views/app/mcp/patients-table.blade.php

@@ -26,7 +26,7 @@
 				</a>
 			</td>
 			<td>{{$patient->displayName()}}</td>
-			<td>{{ friendly_date_time($patient->dob, false) }} {{ $patient->age_in_years ? '(' . $patient->age_in_years . ' y.o)' : '(-)' }}</td>
+			<td class="text-nowrap">{{ friendly_date_time($patient->dob, false) }} {{ $patient->age_in_years ? '(' . $patient->age_in_years . ' y.o)' : '(-)' }}</td>
 			<td>{{ $patient->sex }}</td>
 			<td>{{ $patient->usual_bmi }}</td>
 			<td>
@@ -70,5 +70,5 @@
 
 </table>
 <div class="p-3">
-	{{$patients->links()}}
+	{{$patients->withQueryString()->links()}}
 </div>

+ 8 - 1
resources/views/app/mcp/patients_filters.blade.php

@@ -8,6 +8,12 @@
 	}
 </style>
 <form id="mcp-patients-filters" method="GET" action="{{ route('mcp.patients') }}" class="row align-items-end" v-cloak>
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Name:</label>
+			<input name="name" class="form-control input-sm" v-model="filters.name">
+		</div>
+	</div>
 	<!-- AGE	 -->
 	<div class="col-md-2">
 		<div class="form-group">
@@ -197,7 +203,7 @@
 		<div class="form-group d-flex">
 			<label>&nbsp;</label>
 			<button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
-			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+			<a href="#" v-on:click.prevent="fastLoad('{{route('mcp.patients')}}')" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
 		</div>
 	</div>
 </form>
@@ -205,6 +211,7 @@
 <?php
 $loadedFilters = $filters;
 $allFilterKeys = [
+	'name',
 	'age_category',
 	'age_value_1',
 	'age_value_2',

+ 37 - 0
resources/views/app/patient/dashboard.blade.php

@@ -25,6 +25,7 @@
         <?php $infoLines = json_decode($patient->info_lines);?>
         <?php $infoLines = !$infoLines ? [] : $infoLines; ?>
         <?php $vitalLabels = ['Ht. (in.)','Wt. (lbs.)','Temp. (F)','Pulse','Resp.','Pulse Ox.','SBP','DBP','Smoking Status', 'BMI']; ?>
+        <?php $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_create($patient->created_at))->invert === 1); ?>
 
 	    <div class="row client-single-dashboard">
             <div class="col-6">
@@ -33,6 +34,7 @@
                 @include('app/patient/partials/appointments')
 
                 {{-- canvas based allergies --}}
+                @if($isOldClient)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
@@ -42,6 +44,7 @@
                         @include('app.patient.canvas-sections.allergies.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- allergies - point -->
                 <?php
@@ -50,7 +53,9 @@
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                         @if($patient->coreNote)
                             <a native target="_blank"
                                class="c-pointer d-inline-flex align-items-center ml-3 text-decoration-none"
@@ -79,6 +84,7 @@
                 </div>
 
                 {{-- canvas based rx --}}
+                @if($isOldClient)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
@@ -88,6 +94,7 @@
                         @include('app.patient.canvas-sections.rx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- meds - point -->
                 <?php
@@ -96,7 +103,9 @@
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                         @if($patient->coreNote)
                             <a native target="_blank"
                                class="c-pointer d-inline-flex align-items-center ml-3 text-decoration-none"
@@ -250,6 +259,7 @@
                 {{--@include('app/patient/partials/vitals')--}}
 
                 {{-- canvas based vitals --}}
+                @if($isOldClient)
                 <div class="pt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Vitals</h6>
@@ -259,6 +269,7 @@
                         @include('app.patient.canvas-sections.vitals.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- vitals - point -->
                 <?php $latestVitals = \App\Models\Point::where('client_id', $patient->id)->where('category', 'VITALS')->orderBy('id', 'DESC')->first(); ?>
@@ -271,7 +282,9 @@
                                 </span>
                             @endif
                         </h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @if(!!$latestVitals)
@@ -289,6 +302,7 @@
                 @include('app/patient/partials/medical-team')
 
                 {{-- canvas based dx --}}
+                @if($isOldClient)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Current Problems / Focus Areas</h6>
@@ -298,6 +312,7 @@
                         @include('app.patient.canvas-sections.dx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- probs - point -->
                 <?php
@@ -306,7 +321,9 @@
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Current Problems / Focus Areas</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                         @if($patient->coreNote)
                             <a native target="_blank"
                                class="c-pointer d-inline-flex align-items-center ml-3 text-decoration-none"
@@ -336,6 +353,7 @@
                 </div>
 
                 {{-- history_medical --}}
+                @if($isOldClient)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
@@ -345,12 +363,15 @@
                         @include('app.patient.canvas-sections.pmhx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- pmhx - point -->
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @include('app.patient.segment-templates.past_medical_history.summary', compact('patient'))
@@ -358,6 +379,7 @@
                 </div>
 
                 {{-- history_surgical --}}
+                @if($isOldClient)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
@@ -367,12 +389,15 @@
                         @include('app.patient.canvas-sections.pshx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- pshx - point -->
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @include('app.patient.segment-templates.history_surgical.summary', compact('patient'))
@@ -380,6 +405,7 @@
                 </div>
 
                 {{-- history_family --}}
+                @if($isOldClient)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
@@ -389,12 +415,15 @@
                         @include('app.patient.canvas-sections.fhx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- fhx - point -->
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @include('app.patient.segment-templates.history_family.summary', compact('patient'))
@@ -402,6 +431,7 @@
                 </div>
 
                 {{-- history_social --}}
+                @if($isOldClient)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
@@ -411,12 +441,15 @@
                         @include('app.patient.canvas-sections.sochx.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- sochx - point -->
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @include('app.patient.segment-templates.history_social.summary', compact('patient'))
@@ -798,6 +831,7 @@
                 </div>
 
                 {{-- canvas based careteam --}}
+                @if($isOldClient)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
@@ -807,6 +841,7 @@
                         @include('app.patient.canvas-sections.care-team.summary')
                     </div>
                 </div>
+                @endif
 
                 <!-- careteam - point -->
                 <?php
@@ -815,7 +850,9 @@
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
+                        @if($isOldClient)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
+                        @endif
                     </div>
                     <div class="bg-light border p-2 mb-3">
                         @foreach($careTeamMembers as $careTeamMember)

+ 6 - 256
resources/views/app/patient/incoming-reports.blade.php

@@ -75,7 +75,7 @@
                                 {{$document->hcp ? $document->hcp->displayName() : '-'}}
                             </td>
                             <td class="px-2">
-                                <a href="{{route('patients.view.incoming-reports', ['patient' => $patient, 'currentReport' => $document])}}"
+                                <a mc-initer="incoming-reports" href="{{route('patients.view.incoming-reports', ['patient' => $patient, 'currentReport' => $document])}}"
                                    class="{{@$currentReport->uid === $document->uid ? 'font-weight-bold' : ''}}">
                                     {{ $document->title ? $document->title : '(not set)' }}
                                 </a>
@@ -181,7 +181,7 @@
                                 </div>
                                 @if(!$currentReport->is_entry_error)
                                     <div moe relative class="mr-2 pr-1">
-                                        <a start show class="on-hover-opaque" title="Mark as entry-error"><i class="fa fa-ban text-danger"></i></a>
+                                        <a href="#" start show class="on-hover-opaque" title="Mark as entry-error"><i class="fa fa-ban text-danger"></i></a>
                                         <form url="/api/incomingReport/setIsEntryErrorToTrue" right>
                                             <input type="hidden" name="uid" value="{{ $currentReport->uid }}">
                                             <p class="small">Are you sure you want to set this report as entry error?</p>
@@ -193,7 +193,7 @@
                                     </div>
                                 @else
                                     <div moe relative class="mr-2">
-                                        <a start show class="on-hover-opaque" title="Undo mark as entry-error"><i class="fa fa-undo"></i></a>
+                                        <a href="#" start show class="on-hover-opaque" title="Undo mark as entry-error"><i class="fa fa-undo"></i></a>
                                         <form url="/api/incomingReport/setIsEntryErrorToFalse" right>
                                             <input type="hidden" name="uid" value="{{ $currentReport->uid }}">
                                             <p class="small">Are you sure you want to set unset this report as entry error?</p>
@@ -206,268 +206,17 @@
                                 @endif
                             @endif
                         </div>
-                        <a class="ml-auto" href="{{route('patients.view.incoming-reports', ['patient' => $patient, 'currentReport' => null])}}">
+                        <a class="ml-auto" mc-initer="incoming-reports" href="{{route('patients.view.incoming-reports', ['patient' => $patient, 'currentReport' => null])}}">
                             <i class="fa fa-times-circle on-hover-opaque"></i>
                         </a>
                     </div>
                     <hr class="mt-3 mb-0 row">
-                    <?php /*
-                    <div class="mb-3">
-                        <label class="text-secondary text-sm mb-1">Reason</label>
-                        <div moe class="d-block">
-                            <a start show>{{$supplyOrder->reason ? $supplyOrder->reason : '(not set)'}}</a>
-                            <form url="/api/supplyOrder/updateReason">
-                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                <div class="mb-2">
-                                    <label class="text-secondary mb-1 text-sm">Reason *</label>
-                                    <input type="text" class="form-control form-control-sm" required
-                                           name="reason" value="{{$supplyOrder->reason}}">
-                                </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>
-                    </div>
-                    <div class="mb-3">
-                        <label class="text-secondary text-sm mb-1">Address</label>
-                        <div moe class="d-block">
-                            <a start show>
-                                {{$supplyOrder->mailing_address_full ? implode(" ", [$supplyOrder->mailing_address_line1, $supplyOrder->mailing_address_line2, $supplyOrder->mailing_address_city, $supplyOrder->mailing_address_state, $supplyOrder->mailing_address_zip]) : '(not set)'}}
-                            </a>
-                            <form url="/api/supplyOrder/updateMailingAddress">
-                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">Address Line1</label>
-                                    <input type="text" class="form-control form-control-sm" name="mailingAddressLine1" value="{{$supplyOrder->mailing_address_line1}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">Address Line2</label>
-                                    <input type="text" class="form-control form-control-sm" name="mailingAddressLine2" value="{{$supplyOrder->mailing_address_line2}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">Address City</label>
-                                    <input type="text" class="form-control form-control-sm" name="mailingAddressCity" value="{{$supplyOrder->mailing_address_city}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">Address State</label>
-                                    <input type="text" class="form-control form-control-sm" name="mailingAddressState" value="{{$supplyOrder->mailing_address_state}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">Address Zip</label>
-                                    <input type="text" class="form-control form-control-sm" name="mailingAddressZip" value="{{$supplyOrder->mailing_address_zip}}">
-                                </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>
-                    </div>
-                    <div class="mb-3 d-none">
-                        <label class="text-secondary text-sm mb-1">Requested Ship Date</label>
-                        <div moe class="d-block">
-                            <a start show>{{$supplyOrder->requested_date ? friendlier_date_time($supplyOrder->requested_date) : '(not set)'}}</a>
-                            <form url="/api/supplyOrder/updateRequestedDate">
-                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                <div class="mb-2">
-                                    <label class="text-secondary mb-1 text-sm">Requested Ship Date</label>
-                                    <input type="date" class="form-control form-control-sm"
-                                           name="requestedDate" value="">
-                                </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>
-                    </div>
-                    <div class="mb-3">
-                        <label class="text-secondary text-sm mb-1">Client Understanding Memo</label>
-                        <div moe class="d-block">
-                            @if($supplyOrder->client_understanding_memo)
-                                <a start show>{{$supplyOrder->client_understanding_memo}}</a>
-                            @else
-                                <a start show>(not set)</a>
-                            @endif
-                            <form url="/api/supplyOrder/updateClientUnderstandingMemo">
-                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                <div class="mb-2">
-                                    <label class="text-secondary mb-1 text-sm">Client Understanding Memo</label>
-                                    <input type="text" class="form-control form-control-sm"
-                                           name="clientUnderstandingMemo" value="{{$supplyOrder->client_understanding_memo}}">
-                                </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>
-
-                    </div>
-                    <div class="mb-3">
-                        <label class="text-secondary text-sm mb-1">Pro Signature</label>
-                        <div class="d-flex align-items-center">
-                            @if($supplyOrder->is_signed_by_pro)
-                                <div class="text-info">
-                                    Signed by <b>{{$supplyOrder->signedPro->displayName()}}</b>
-                                    on {{friendlier_date_time($supplyOrder->pro_signed_at)}}
-                                </div>
-                            @else
-                                <div class="text-warning-mellow font-weight-bold">Not Signed</div>
-                                <div class="ml-3">
-                                    <div moe>
-                                        <a start show class="py-0">Sign</a>
-                                        <form url="/api/supplyOrder/signAsPro">
-                                            <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                            <p class="small">Sign this supply order?</p>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-success mr-2" submit>Sign</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                </div>
-                            @endif
-                        </div>
-                    </div>
-                    <div class="mb-3">
-                        <label class="text-secondary text-sm mb-1">Patient Signature</label>
-                        <div class="d-flex align-items-center">
-                            @if($supplyOrder->is_signed_by_client)
-                                <div class="text-info">
-                                    Signed by <b>{{$patient->displayName()}}</b>
-                                    on {{friendlier_date_time($supplyOrder->client_signed_at)}}
-                                </div>
-                            @elseif($supplyOrder->is_client_signature_waived)
-                                <div class="text-info">
-                                    Waived by <b>{{$supplyOrder->waiverPro->displayName()}}</b>
-                                    on {{friendlier_date_time($supplyOrder->client_signature_waived_at)}}
-                                </div>
-                                <div class="ml-3">
-                                    <div moe bottom relative="">
-                                        <a start show class="py-0">Undo</a>
-                                        <form url="/api/supplyOrder/undoWaiveClientSignature" right>
-                                            <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                            <p class="small">Undo waiving patient signature?</p>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit>Yes</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>No</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                </div>
-                            @else
-                                <div class="text-warning-mellow font-weight-bold">Not Signed</div>
-                                <div class="ml-3">
-                                    <div moe bottom relative="">
-                                        <a start show class="py-0">Email</a>
-                                        <form url="/api/supplyOrder/sendClientSignatureRequestByEmail">
-                                            <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                            <p class="small">Request patient signature via email?</p>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit>Submit</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                </div>
-                                <span class="mx-2 text-secondary">|</span>
-                                <div class="">
-                                    <div moe bottom relative="">
-                                        <a start show class="py-0">SMS</a>
-                                        <form url="/api/supplyOrder/sendClientSignatureRequestBySms">
-                                            <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                            <p class="small">Request patient signature via SMS?</p>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit>Submit</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                </div>
-                                <span class="mx-2 text-secondary">|</span>
-                                <div class="">
-                                    <a href="#" class="text-secondary on-hover-opaque">Problem Signing</a>
-                                </div>
-                                <span class="mx-2 text-secondary">|</span>
-                                <div class="">
-                                    <div moe bottom relative="">
-                                        <a start show class="py-0">Waive</a>
-                                        <form url="/api/supplyOrder/waiveClientSignature" right>
-                                            <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                            <p class="small mb-2">Waive patient signature?</p>
-                                            <div class="mb-2">
-                                                <label class="text-secondary mb-1 text-sm">Memo</label>
-                                                <input type="text" class="form-control form-control-sm"
-                                                       name="memo" value="{{$supplyOrder->client_signature_waiver_memo}}">
-                                            </div>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit>Submit</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                </div>
-                            @endif
-                        </div>
-                        @if($supplyOrder->client_signature_last_requested_at &&
-                            !$supplyOrder->is_signed_by_client &&
-                            !$supplyOrder->is_client_signature_waived)
-                            <div class="text-sm my-1 text-info">Client signature last requested on {{friendlier_date_time($iSupplyOrder->client_signature_last_requested_at)}}</div>
-                        @endif
-                        @if($supplyOrder->does_client_have_problem_signing &&
-                            !$supplyOrder->is_signed_by_client &&
-                            !$supplyOrder->is_client_signature_waived)
-                            <div class="text-sm my-1 text-warning-mellow">
-                                Client has problem signing
-                                @if($supplyOrder->client_problem_signing)
-                                    <i class="text-sm">{{$supplyOrder->client_problem_signing}}</i>
-                                @endif
-                            </div>
-                        @endif
-                    </div>
-                    <hr class="my-3">
-                    <div class="d-flex align-items-center">
-                        @if($supplyOrder->is_cleared_for_shipment)
-                            <div class="text-info mb-2">
-                                <i class="fa fa-check"></i> Cleared for shipment by <b>{{$supplyOrder->clearedForShipmentPro->displayName()}}</b>
-                                on {{friendlier_date_time($supplyOrder->cleared_for_shipment_at)}}
-                            </div>
-                        @elseif($supplyOrder->is_signed_by_pro && ($supplyOrder->is_signed_by_client || $supplyOrder->is_client_signature_waived))
-                            <div moe bottom relative="" class="mb-2">
-                                <a start show class="py-0 text-success font-weight-bold">Clear for Shipment</a>
-                                <form url="/api/supplyOrder/clearForShipment">
-                                    <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                    <p class="small mb-2">Clear this supply order for shipment?</p>
-                                    <div class="d-flex align-items-center">
-                                        <button class="btn btn-sm btn-primary mr-2" submit>Submit</button>
-                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                    </div>
-                                </form>
-                            </div>
-                        @endif
-                    </div>
-                    <div class="d-flex align-items-center">
-                        <div moe bottom relative="">
-                            <a start show class="py-0 text-danger">Cancel Supply Order</a>
-                            <form url="/api/supplyOrder/cancel">
-                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
-                                <p class="small text-nowrap mb-2">Cancel this supply order?</p>
-                                <div class="d-flex align-items-center">
-                                    <button class="btn btn-sm btn-primary mr-2" submit>Yes</button>
-                                    <button class="btn btn-sm btn-default mr-2 border" cancel>No</button>
-                                </div>
-                            </form>
-                        </div>
-                    </div>
-                    */ ?>
                     <div class="pdf-viewer-auto row px-3" pdf-url="/api/incomingReport/download/{{ $currentReport->uid }}"></div>
                 </div>
             @endif
         </div>
     </div>
+    @include('app/pdf/viewer')
     <script>
         function submitIncomingReport(_form) {
             showMask();
@@ -504,6 +253,7 @@
                     .datepicker({
                         dateFormat: 'yy-mm-dd'
                     });
+                runMCInitializer('inline-pdf-viewer');
             }
             addMCInitializer('incoming-reports', init, '#incoming-reports')
         }).call(window);

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

@@ -2344,6 +2344,17 @@
                                 </div>
                             </div>
                         </div>
+                        <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                            <div native target="_blank"
+                                 class="c-pointer d-inline-flex align-items-center incoming-reports-trigger px-2 py-1"
+                                 open-in-stag-popup
+                                 mc-initer="incoming-reports"
+                                 title="Incoming Reports"
+                                 popup-style="wide overflow-visible"
+                                 href="/patients/view/{{$patient->uid}}/incoming-reports">
+                                <span>Inc. Reports</span>
+                            </div>
+                        </div>
                         <div class="ml-auto mr-5 nbt-container border-info d-inline-flex align-self-stretch align-items-center">
                             <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
                             <span class="autosave-indicator saved text-sm text-secondary">

+ 46 - 15
resources/views/app/patient/prescriptions-popup/imaging-form.blade.php

@@ -1,25 +1,56 @@
-<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-IMAGING">
-    <form method="POST" action="">
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="pp-prescription-popup-IMAGING">
+    <form method="POST" action="" class="overflow-visible">
         <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 class="d-flex align-items-baseline">
+            <span class="font-weight-bold mr-3">Test Sets</span>
+            <a href="#" v-on:click.prevent="addTestSet()">Add Test Set</a>
         </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 v-for="(item, itemIndex) in currentPrescription_IMAGING.clinicalDetailJson.items" class="border bg-light px-2 pt-2 pb-1 my-2">
+            <div class="row">
+                <div class="col-6 pr-2">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">Tests</span>
+                        <a href="#" v-on:click.prevent="addTest(item)">Add Test</a>
+                    </div>
+                    <div v-for="(test, testIndex) in item.tests" class="d-flex align-items-baseline mb-1">
+                        <div class="position-relative flex-grow-1">
+                            <input type="text" class="min-width-unset form-control form-control-sm" v-model="test.desc">
+                        </div>
+                        <a href="#" v-if="item.tests && item.tests.length > 1" v-on:click.prevent="deleteTest(item, testIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.tests && item.tests.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
+                <div class="col-6 pl-2 border-left">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">ICDs</span>
+                        <a href="#" v-on:click.prevent="addICD(item)">Add ICD</a>
+                    </div>
+                    <div v-for="(icd, icdIndex) in item.icds" class="d-flex align-items-baseline mb-1">
+                        <input type="text" class="min-width-unset form-control form-control-sm width-100px mr-2"
+                               data-field="icd" :data-item-index="itemIndex" :data-icd-index="icdIndex" data-category="IMAGING"
+                               v-model="icd.code">
+                        <input type="text" class="min-width-unset form-control form-control-sm flex-grow-1" v-model="icd.desc">
+                        <a href="#" v-if="item.icds && item.icds.length > 1" v-on:click.prevent="deleteICD(item, icdIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.icds && item.icds.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </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="savePrescription()">Submit
             </button>

+ 57 - 15
resources/views/app/patient/prescriptions-popup/lab-form.blade.php

@@ -1,25 +1,67 @@
-<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-prescription-popup-LAB">
-    <form method="POST" action="">
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="pp-prescription-popup-LAB">
+    <form method="POST" action="" class="overflow-visible">
         <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 class="d-flex align-items-baseline">
+            <span class="font-weight-bold mr-3">Test Sets</span>
+            <a href="#" v-on:click.prevent="addTestSet()">Add Test Set</a>
         </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 v-for="(item, itemIndex) in currentPrescription_LAB.clinicalDetailJson.items" class="border bg-light px-2 pt-2 pb-1 my-2">
+            <div class="row">
+                <div class="col-6 pr-2">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">Tests</span>
+                        <a href="#" v-on:click.prevent="addTest(item)">Add Test</a>
+                    </div>
+                    <div v-for="(test, testIndex) in item.tests" class="d-flex align-items-baseline mb-1">
+                        <div class="position-relative flex-grow-1">
+                            <input type="text" class="min-width-unset form-control form-control-sm" data-option-list v-model="test.desc">
+                            <div class="data-option-list">
+                                <div>Complete Blood Count</div>
+                                <div>Prothrombin Time</div>
+                                <div>Basic Metabolic Panel</div>
+                                <div>Comprehensive Metabolic Panel</div>
+                                <div>Lipid Panel</div>
+                                <div>Liver Panel</div>
+                                <div>Thyroid Stimulating Hormone</div>
+                                <div>Hemoglobin A1C</div>
+                                <div>Urinalysis</div>
+                            </div>
+                        </div>
+                        <a href="#" v-if="item.tests && item.tests.length > 1" v-on:click.prevent="deleteTest(item, testIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.tests && item.tests.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
+                <div class="col-6 pl-2 border-left">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">ICDs</span>
+                        <a href="#" v-on:click.prevent="addICD(item)">Add ICD</a>
+                    </div>
+                    <div v-for="(icd, icdIndex) in item.icds" class="d-flex align-items-baseline mb-1">
+                        <input type="text" class="min-width-unset form-control form-control-sm width-100px mr-2"
+                               data-field="icd" :data-item-index="itemIndex" :data-icd-index="icdIndex" data-category="LAB"
+                               v-model="icd.code">
+                        <input type="text" class="min-width-unset form-control form-control-sm flex-grow-1" v-model="icd.desc">
+                        <a href="#" v-if="item.icds && item.icds.length > 1" v-on:click.prevent="deleteICD(item, icdIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.icds && item.icds.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </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="savePrescription()">Submit
             </button>

+ 234 - 24
resources/views/app/patient/prescriptions-popup/list-popup.blade.php

@@ -26,7 +26,7 @@
             <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
         @endif
     </div>
-    <div class="d-flex align-items-start">
+    <div class="d-flex align-items-start bg-white">
         <table class="table table-striped table-sm table-bordered mb-0 flex-grow-1">
             <thead>
             <tr>
@@ -67,9 +67,21 @@
                                     <b class="mr-2">@{{drug.medication ?? '-'}}</b>
                                 </div>
                             </div>
-                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
-                                <b class="mr-2">@{{prescription.clinical_detail_json.test ?? '-'}}</b>
-                                <span class="text-secondary mr-1">@{{prescription.clinical_detail_json.icds ?? '-'}}</span>
+                            <div v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
+                                <div class="px-2 py-1 mb-1 border bg-light"  v-for="item in prescription.clinical_detail_json.items">
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="text-secondary mr-2">Tests:</span>
+                                        <span class="flex-grow-1">
+                                            <b v-for="test in item.tests" class="mr-2">@{{ test.desc }}</b>
+                                        </span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline">
+                                        <span class="text-secondary mr-2">ICDs:</span>
+                                        <span class="flex-grow-1">
+                                            <b v-for="icd in item.icds" class="mr-2">@{{ icd.code }}</b>
+                                        </span>
+                                    </div>
+                                </div>
                             </div>
                             <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'REFERRAL'">
                                 <b class="mr-2">@{{prescription.clinical_detail_json.to ?? '-'}}</b>
@@ -143,15 +155,27 @@
                 <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 v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline flex-grow-1">
                         <div class="" v-if="currentPrescription.erx_category === 'DRUG'">
                             <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
                                 <b class="mr-2">@{{drug.medication ?? '-'}}</b>
                             </div>
                         </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
-                            <b class="mr-2">@{{currentPrescription.clinical_detail_json.test ?? '-'}}</b>
-                            <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.icds ?? '-'}}</span>
+                        <div v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'" class="flex-grow-1">
+                            <div class="border bg-light mb-1 px-2 py-1 flex-grow-1" v-for="item in currentPrescription.clinical_detail_json.items">
+                                <div class="d-flex align-items-baseline mb-1">
+                                    <span class="text-secondary mr-2">Tests:</span>
+                                    <span class="flex-grow-1">
+                                        <b v-for="test in item.tests" class="mr-2">@{{ test.desc }}</b>
+                                    </span>
+                                </div>
+                                <div class="d-flex align-items-baseline">
+                                    <span class="text-secondary mr-2">ICDs:</span>
+                                    <span class="flex-grow-1">
+                                        <b v-for="icd in item.icds" class="mr-2">@{{ icd.code }}</b>
+                                    </span>
+                                </div>
+                            </div>
                         </div>
                         <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'REFERRAL'">
                             <b class="mr-2">@{{currentPrescription.clinical_detail_json.to ?? '-'}}</b>
@@ -463,9 +487,21 @@ GROUP BY erx_category");
                         hcpProUid: '{{$pro->uid}}',
                         erxCategory: 'LAB',
                         clinicalDetailJson: {
-                            test: '',
-                            icds: '',
-                            memo: '',
+                            items: [
+                                {
+                                    tests: [
+                                        {
+                                            desc: '',
+                                        }
+                                    ],
+                                    icds: [
+                                        {
+                                            code: '',
+                                            desc: '',
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     },
                     currentPrescription_IMAGING: {
@@ -475,9 +511,21 @@ GROUP BY erx_category");
                         hcpProUid: '{{$pro->uid}}',
                         erxCategory: 'IMAGING',
                         clinicalDetailJson: {
-                            test: '',
-                            icds: '',
-                            memo: '',
+                            items: [
+                                {
+                                    tests: [
+                                        {
+                                            desc: '',
+                                        }
+                                    ],
+                                    icds: [
+                                        {
+                                            code: '',
+                                            desc: '',
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     },
                     currentPrescription_REFERRAL: {
@@ -596,6 +644,100 @@ GROUP BY erx_category");
                         }, 'json');
                         return false;
                     },
+                    addTestSet: function() {
+                        this['currentPrescription_' + this.currentPrescriptionType].clinicalDetailJson.items.push({
+                            tests: [
+                                {
+                                    desc: '',
+                                }
+                            ],
+                            icds: [
+                                {
+                                    code: '',
+                                    desc: '',
+                                }
+                            ]
+                        });
+                    },
+                    addTest: function(_item) {
+                        _item.tests.push({
+                            desc: ''
+                        });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
+                    },
+                    addICD: function(_item) {
+                        _item.icds.push({
+                            desc: ''
+                        });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
+                    },
+                    deleteTest: function(_item, _index) {
+                        _item.tests.splice(_index, 1);
+                    },
+                    deleteICD: function(_item, _index) {
+                        _item.icds.splice(_index, 1);
+                    },
+                    getBlankPrescriptionClinicalData: function(_type) {
+                        let data = null;
+                        switch (_type) {
+                            case 'DRUG':
+                                data = {
+                                    items: [
+                                        {
+                                            medication: '',
+                                            dispense: '',
+                                            refills: '',
+                                            purpose: ''
+                                        }
+                                    ]
+                                };
+                                break;
+                            case 'LAB':
+                            case 'IMAGING':
+                                data = {
+                                    items: [
+                                        {
+                                            tests: [
+                                                {
+                                                    desc: '',
+                                                }
+                                            ],
+                                            icds: [
+                                                {
+                                                    code: '',
+                                                    desc: '',
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                };
+                                break;
+                            case 'REFERRAL':
+                                data = {
+                                    to: '',
+                                    memo: '',
+                                };
+                                break;
+                            case 'SUPPLY':
+                                data = {
+                                    item: '',
+                                    quantity: '',
+                                    memo: '',
+                                };
+                                break;
+                            case 'OTHER':
+                                data = {
+                                    title: '',
+                                    memo: '',
+                                };
+                                break;
+                        }
+                        return data;
+                    },
 
                     // new/edit/save-clinical
                     newPrescription: function(_type) {
@@ -622,7 +764,6 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'LAB':
-                            case 'IMAGING':
                                 this.currentPrescription_LAB = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
@@ -630,14 +771,52 @@ GROUP BY erx_category");
                                     hcpProUid: '{{$pro->uid}}',
                                     erxCategory: _type,
                                     clinicalDetailJson: {
-                                        test: '',
-                                        icds: '',
-                                        memo: '',
+                                        items: [
+                                            {
+                                                tests: [
+                                                    {
+                                                        desc: '',
+                                                    }
+                                                ],
+                                                icds: [
+                                                    {
+                                                        code: '',
+                                                        desc: '',
+                                                    }
+                                                ]
+                                            }
+                                        ]
+                                    }
+                                };
+                                break;
+                            case 'IMAGING':
+                                this.currentPrescription_IMAGING = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        items: [
+                                            {
+                                                tests: [
+                                                    {
+                                                        desc: '',
+                                                    }
+                                                ],
+                                                icds: [
+                                                    {
+                                                        code: '',
+                                                        desc: '',
+                                                    }
+                                                ]
+                                            }
+                                        ]
                                     }
                                 };
                                 break;
                             case 'REFERRAL':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_REFERRAL = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -650,7 +829,7 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'SUPPLY':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_SUPPLY = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -664,7 +843,7 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'OTHER':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_OTHER = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -691,7 +870,9 @@ GROUP BY erx_category");
                         this.currentPrescriptionType = _prescription.erx_category;
                         this['currentPrescription_' + this.currentPrescriptionType] = {
                             uid: _prescription.uid,
-                            clinicalDetailJson: JSON.parse(JSON.stringify(_prescription.clinical_detail_json))
+                            clinicalDetailJson: _prescription.clinical_detail_json ?
+                                JSON.parse(JSON.stringify(_prescription.clinical_detail_json)) :
+                                this.getBlankPrescriptionClinicalData(this.currentPrescriptionType)
                         };
                         Vue.nextTick(() => {
                             showStagPopup('pp-prescription-popup-' + this.currentPrescriptionType, true);
@@ -717,6 +898,9 @@ GROUP BY erx_category");
                                     .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.strength))
                                     .val(1);*/
                             }
+                            else if(this.currentPrescriptionType === 'LAB' || this.currentPrescriptionType === 'IMAGING') {
+                                this.initICDAutoSuggest();
+                            }
                         });
                     },
                     savePrescription: function() {
@@ -1020,7 +1204,6 @@ GROUP BY erx_category");
                         if(!this.currentPrescription.clinical_detail_json.items) {
                             this.currentPrescription.clinical_detail_json.items = [];
                         }
-
                         this.currentPrescription.clinical_detail_json.items.push({
                             medication: existing.data.name,
                             dispense: existing.data.dispense,
@@ -1139,6 +1322,7 @@ GROUP BY erx_category");
                                                 // refreshDynamicStagPopup();
                                                 // $('.visit-segment[data-segment-template-name="intake_medications"]').find('.refresh-segment').trigger('click');
 
+
                                                 if(!self.currentPrescription.clinical_detail_json) {
                                                     self.currentPrescription.clinical_detail_json = {};
                                                 }
@@ -1171,7 +1355,33 @@ GROUP BY erx_category");
 
                             });
                         }
-                    }
+                    },
+                    initICDAutoSuggest: function() {
+                        let self = this;
+                        let parentSegment = $('#prescriptions-popup-{{$patient->id}}');
+                        parentSegment.find('input[type="text"][data-field="icd"]:not([ac-initialized])').each(function() {
+                            var elem = this,
+                                dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
+                                itemIndex = $(this).attr('data-item-index'),
+                                icdIndex = $(this).attr('data-icd-index'),
+                                category = $(this).attr('data-category');
+                            $(elem).attr('id', dynID);
+                            new window.Def.Autocompleter.Search(dynID,
+                                'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name', {
+                                    tableFormat: true,
+                                    valueCols: [0],
+                                    colHeaders: ['Code', 'Name'],
+                                }
+                            );
+                            window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
+                                let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
+                                self['currentPrescription_' + category].clinicalDetailJson.items[itemIndex].icds[icdIndex].code = acData[0].code;
+                                self['currentPrescription_' + category].clinicalDetailJson.items[itemIndex].icds[icdIndex].desc = acData[0].data['name'];
+                                return false;
+                            });
+                            $(elem).attr('ac-initialized', 1);
+                        });
+                    },
                 },
                 mounted: function() {
                     let self = this;

+ 45 - 33
resources/views/app/patient/prescriptions/imaging-form.blade.php

@@ -1,44 +1,56 @@
-<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="prescription-popup-IMAGING">
-    <form method="POST" action="">
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="prescription-popup-IMAGING">
+    <form method="POST" action="" class="overflow-visible">
         <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">
-            <div class="d-flex align-items-baseline">
-                <label class="text-sm text-secondary mb-0">Tests</label>
-                <span class="mx-2 text-secondary text-sm"></span>
-                <a href="#" class="text-sm" v-on:click.prevent="currentPrescription_IMAGING.clinicalDetailJson.tests.push('')">+ Add</a>
-            </div>
-            <div v-for="(test, testIndex) in currentPrescription_IMAGING.clinicalDetailJson.tests">
-                <input type="text" class="form-control form-control-sm min-width-unset mb-1"
-                       v-model="currentPrescription_IMAGING.clinicalDetailJson.tests[testIndex]">
-            </div>
+
+        <div class="d-flex align-items-baseline">
+            <span class="font-weight-bold mr-3">Test Sets</span>
+            <a href="#" v-on:click.prevent="addTestSet()">Add Test Set</a>
         </div>
-        <div class="mb-2">
-            <div class="d-flex align-items-baseline">
-                <label class="text-sm text-secondary mb-0">ICDs</label>
-                <span class="mx-2 text-secondary text-sm"></span>
-                <a href="#" class="text-sm" v-on:click.prevent="addICD('IMAGING')">+ Add</a>
+
+        <div v-for="(item, itemIndex) in currentPrescription_IMAGING.clinicalDetailJson.items" class="border bg-light px-2 pt-2 pb-1 my-2">
+            <div class="row">
+                <div class="col-6 pr-2">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">Tests</span>
+                        <a href="#" v-on:click.prevent="addTest(item)">Add Test</a>
+                    </div>
+                    <div v-for="(test, testIndex) in item.tests" class="d-flex align-items-baseline mb-1">
+                        <div class="position-relative flex-grow-1">
+                            <input type="text" class="min-width-unset form-control form-control-sm" v-model="test.desc">
+                        </div>
+                        <a href="#" v-if="item.tests && item.tests.length > 1" v-on:click.prevent="deleteTest(item, testIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.tests && item.tests.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
+                <div class="col-6 pl-2 border-left">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">ICDs</span>
+                        <a href="#" v-on:click.prevent="addICD(item)">Add ICD</a>
+                    </div>
+                    <div v-for="(icd, icdIndex) in item.icds" class="d-flex align-items-baseline mb-1">
+                        <input type="text" class="min-width-unset form-control form-control-sm width-100px mr-2"
+                               data-field="icd" :data-item-index="itemIndex" :data-icd-index="icdIndex" data-category="IMAGING"
+                               v-model="icd.code">
+                        <input type="text" class="min-width-unset form-control form-control-sm flex-grow-1" v-model="icd.desc">
+                        <a href="#" v-if="item.icds && item.icds.length > 1" v-on:click.prevent="deleteICD(item, icdIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.icds && item.icds.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
             </div>
-            <div v-for="(icd, icdIndex) in currentPrescription_IMAGING.clinicalDetailJson.icds" class="d-flex align-items-center">
-                <input type="text" class="form-control form-control-sm min-width-unset mb-1 flex-grow-1"
-                       data-field="icd" :data-index="icdIndex" data-category="IMAGING"
-                       v-model="currentPrescription_IMAGING.clinicalDetailJson.icds[icdIndex]">
-                <a v-if="icdIndex>0"
-                   href="#"
-                   class="px-2"
-                   v-on:click.prevent="currentPrescription_IMAGING.clinicalDetailJson.icds.splice(icdIndex, 1)">
-                    <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
-                </a>
-            </div>
-        </div>
-        <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">Memo</label>
-            <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>

+ 56 - 33
resources/views/app/patient/prescriptions/lab-form.blade.php

@@ -1,44 +1,67 @@
-<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="prescription-popup-LAB">
-    <form method="POST" action="">
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="prescription-popup-LAB">
+    <form method="POST" action="" class="overflow-visible">
         <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">
-            <div class="d-flex align-items-baseline">
-                <label class="text-sm text-secondary mb-0">Tests</label>
-                <span class="mx-2 text-secondary text-sm"></span>
-                <a href="#" class="text-sm" v-on:click.prevent="currentPrescription_LAB.clinicalDetailJson.tests.push('')">+ Add</a>
-            </div>
-            <div v-for="(test, testIndex) in currentPrescription_LAB.clinicalDetailJson.tests">
-                <input type="text" class="form-control form-control-sm min-width-unset mb-1"
-                       v-model="currentPrescription_LAB.clinicalDetailJson.tests[testIndex]">
-            </div>
+
+        <div class="d-flex align-items-baseline">
+            <span class="font-weight-bold mr-3">Test Sets</span>
+            <a href="#" v-on:click.prevent="addTestSet()">Add Test Set</a>
         </div>
-        <div class="mb-2">
-            <div class="d-flex align-items-baseline">
-                <label class="text-sm text-secondary mb-0">ICDs</label>
-                <span class="mx-2 text-secondary text-sm"></span>
-                <a href="#" class="text-sm" v-on:click.prevent="addICD('LAB')">+ Add</a>
+
+        <div v-for="(item, itemIndex) in currentPrescription_LAB.clinicalDetailJson.items" class="border bg-light px-2 pt-2 pb-1 my-2">
+            <div class="row">
+                <div class="col-6 pr-2">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">Tests</span>
+                        <a href="#" v-on:click.prevent="addTest(item)">Add Test</a>
+                    </div>
+                    <div v-for="(test, testIndex) in item.tests" class="d-flex align-items-baseline mb-1">
+                        <div class="position-relative flex-grow-1">
+                            <input type="text" class="min-width-unset form-control form-control-sm" data-option-list v-model="test.desc">
+                            <div class="data-option-list">
+                                <div>Complete Blood Count</div>
+                                <div>Prothrombin Time</div>
+                                <div>Basic Metabolic Panel</div>
+                                <div>Comprehensive Metabolic Panel</div>
+                                <div>Lipid Panel</div>
+                                <div>Liver Panel</div>
+                                <div>Thyroid Stimulating Hormone</div>
+                                <div>Hemoglobin A1C</div>
+                                <div>Urinalysis</div>
+                            </div>
+                        </div>
+                        <a href="#" v-if="item.tests && item.tests.length > 1" v-on:click.prevent="deleteTest(item, testIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.tests && item.tests.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
+                <div class="col-6 pl-2 border-left">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-secondary mr-3">ICDs</span>
+                        <a href="#" v-on:click.prevent="addICD(item)">Add ICD</a>
+                    </div>
+                    <div v-for="(icd, icdIndex) in item.icds" class="d-flex align-items-baseline mb-1">
+                        <input type="text" class="min-width-unset form-control form-control-sm width-100px mr-2"
+                               data-field="icd" :data-item-index="itemIndex" :data-icd-index="icdIndex" data-category="LAB"
+                               v-model="icd.code">
+                        <input type="text" class="min-width-unset form-control form-control-sm flex-grow-1" v-model="icd.desc">
+                        <a href="#" v-if="item.icds && item.icds.length > 1" v-on:click.prevent="deleteICD(item, icdIndex)" class="pl-2">
+                            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+                        </a>
+                        <span v-if="item.icds && item.icds.length === 1" class="pl-2">
+                            <i class="fa fa-trash-alt text-secondary on-hover-opaque"></i>
+                        </span>
+                    </div>
+                </div>
             </div>
-            <div v-for="(icd, icdIndex) in currentPrescription_LAB.clinicalDetailJson.icds" class="d-flex align-items-center">
-                <input type="text" class="form-control form-control-sm min-width-unset mb-1 flex-grow-1"
-                       data-field="icd" :data-index="icdIndex" data-category="LAB"
-                       v-model="currentPrescription_LAB.clinicalDetailJson.icds[icdIndex]">
-                <a v-if="icdIndex>0"
-                   href="#"
-                   class="px-2"
-                   v-on:click.prevent="currentPrescription_LAB.clinicalDetailJson.icds.splice(icdIndex, 1)">
-                    <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
-                </a>
-            </div>
-        </div>
-        <div class="mb-2">
-            <label class="text-sm text-secondary mb-1">Memo</label>
-            <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>

+ 232 - 36
resources/views/app/patient/prescriptions/list.blade.php

@@ -26,7 +26,7 @@
             <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
         @endif
     </div>
-    <div class="d-flex align-items-start">
+    <div class="d-flex align-items-start bg-white">
         <table class="table table-striped table-sm table-bordered mb-0 flex-grow-1">
             <thead>
             <tr>
@@ -70,9 +70,20 @@
                                     <b class="mr-2">@{{drug.medication ?? '-'}}</b>
                                 </div>
                             </div>
-                            <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
-                                <div class="d-flex align-items-baseline mb-1" v-for="test in prescription.clinical_detail_json.tests">
-                                    <b class="mr-2">@{{test ?? '-'}}</b>
+                            <div v-if="prescription.erx_category === 'LAB' || prescription.erx_category === 'IMAGING'">
+                                <div class="px-2 py-1 mb-1 border bg-light"  v-for="item in prescription.clinical_detail_json.items">
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="text-secondary mr-2">Tests:</span>
+                                        <span class="flex-grow-1">
+                                            <b v-for="test in item.tests" class="mr-2">@{{ test.desc }}</b>
+                                        </span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline">
+                                        <span class="text-secondary mr-2">ICDs:</span>
+                                        <span class="flex-grow-1">
+                                            <b v-for="icd in item.icds" class="mr-2">@{{ icd.code }}</b>
+                                        </span>
+                                    </div>
                                 </div>
                             </div>
                             <div class="d-flex align-items-baseline" v-if="prescription.erx_category === 'REFERRAL'">
@@ -147,15 +158,26 @@
                 <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 v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline flex-grow-1">
                         <div class="" v-if="currentPrescription.erx_category === 'DRUG'">
                             <div class="d-flex align-items-baseline mb-1" v-for="drug in currentPrescription.clinical_detail_json.items">
                                 <b class="mr-2">@{{drug.medication ?? '-'}}</b>
                             </div>
                         </div>
-                        <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
-                            <div class="d-flex align-items-baseline mb-1" v-for="test in currentPrescription.clinical_detail_json.tests">
-                                <b class="mr-2">@{{test ?? '-'}}</b>
+                        <div v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'" class="flex-grow-1">
+                            <div class="border bg-light mb-1 px-2 py-1 flex-grow-1" v-for="item in currentPrescription.clinical_detail_json.items">
+                                <div class="d-flex align-items-baseline mb-1">
+                                    <span class="text-secondary mr-2">Tests:</span>
+                                    <span class="flex-grow-1">
+                                        <b v-for="test in item.tests" class="mr-2">@{{ test.desc }}</b>
+                                    </span>
+                                </div>
+                                <div class="d-flex align-items-baseline">
+                                    <span class="text-secondary mr-2">ICDs:</span>
+                                    <span class="flex-grow-1">
+                                        <b v-for="icd in item.icds" class="mr-2">@{{ icd.code }}</b>
+                                    </span>
+                                </div>
                             </div>
                         </div>
                         <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'REFERRAL'">
@@ -472,9 +494,21 @@ GROUP BY erx_category");
                         hcpProUid: '{{$pro->uid}}',
                         erxCategory: 'LAB',
                         clinicalDetailJson: {
-                            test: '',
-                            icds: '',
-                            memo: '',
+                            items: [
+                                {
+                                    tests: [
+                                        {
+                                            desc: '',
+                                        }
+                                    ],
+                                    icds: [
+                                        {
+                                            code: '',
+                                            desc: '',
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     },
                     currentPrescription_IMAGING: {
@@ -484,9 +518,21 @@ GROUP BY erx_category");
                         hcpProUid: '{{$pro->uid}}',
                         erxCategory: 'IMAGING',
                         clinicalDetailJson: {
-                            test: '',
-                            icds: '',
-                            memo: '',
+                            items: [
+                                {
+                                    tests: [
+                                        {
+                                            desc: '',
+                                        }
+                                    ],
+                                    icds: [
+                                        {
+                                            code: '',
+                                            desc: '',
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     },
                     currentPrescription_REFERRAL: {
@@ -601,11 +647,132 @@ GROUP BY erx_category");
                         };
                         $.post('/api/erx/create', payload, _data => {
                             if(!hasResponseError(_data)) {
-                                fastReload();
+                                if(_type === 'LAB' || _type === 'IMAGING') {
+                                    // don't reload the page; add new obj to list and open it's edit-clinical
+                                    if(!this.prescriptions) {
+                                        this.prescriptions = [];
+                                    }
+                                    this.prescriptions.unshift({
+                                        clinical_detail_json: null,
+                                        created_at_friendly: "{{friendly_date(date('Y-m-d'))}}",
+                                        created_at_friendly_short: "{{friendly_date(date('Y-m-d'))}}",
+                                        erx_category: _type,
+                                        hcpProDisplayName: "{{$pro->displayName()}}",
+                                        hcpProUid: "{{$pro->uid}}",
+                                        hcp_pro_id: {{$pro->id}},
+                                        hcp_pro_signed_at: null,
+                                        hcp_pro_signed_by_session_id: null,
+                                        note_id: {{$note->id}},
+                                        uid: _data.data,
+                                        version_number: 1,
+                                    });
+                                    this.currentPrescription = this.prescriptions[0];
+
+                                    Vue.nextTick(() => {
+                                        this.editClinicalDetails(this.currentPrescription);
+                                    });
+                                }
+                                else {
+                                    fastReload();
+                                }
                             }
                         }, 'json');
                         return false;
                     },
+                    addTestSet: function() {
+                        this['currentPrescription_' + this.currentPrescriptionType].clinicalDetailJson.items.push({
+                            tests: [
+                                {
+                                    desc: '',
+                                }
+                            ],
+                            icds: [
+                                {
+                                    code: '',
+                                    desc: '',
+                                }
+                            ]
+                        });
+                    },
+                    addTest: function(_item) {
+                        _item.tests.push({
+                            desc: ''
+                        });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
+                    },
+                    addICD: function(_item) {
+                        _item.icds.push({
+                            desc: ''
+                        });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
+                    },
+                    deleteTest: function(_item, _index) {
+                        _item.tests.splice(_index, 1);
+                    },
+                    deleteICD: function(_item, _index) {
+                        _item.icds.splice(_index, 1);
+                    },
+                    getBlankPrescriptionClinicalData: function(_type) {
+                        let data = null;
+                        switch (_type) {
+                            case 'DRUG':
+                                data = {
+                                    items: [
+                                        {
+                                            medication: '',
+                                            dispense: '',
+                                            refills: '',
+                                            purpose: ''
+                                        }
+                                    ]
+                                };
+                                break;
+                            case 'LAB':
+                            case 'IMAGING':
+                                data = {
+                                    items: [
+                                        {
+                                            tests: [
+                                                {
+                                                    desc: '',
+                                                }
+                                            ],
+                                            icds: [
+                                                {
+                                                    code: '',
+                                                    desc: '',
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                };
+                                break;
+                            case 'REFERRAL':
+                                data = {
+                                    to: '',
+                                    memo: '',
+                                };
+                                break;
+                            case 'SUPPLY':
+                                data = {
+                                    item: '',
+                                    quantity: '',
+                                    memo: '',
+                                };
+                                break;
+                            case 'OTHER':
+                                data = {
+                                    title: '',
+                                    memo: '',
+                                };
+                                break;
+                        }
+                        return data;
+                    },
 
                     // new/edit/save-clinical
                     newPrescription: function(_type) {
@@ -632,7 +799,6 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'LAB':
-                            case 'IMAGING':
                                 this.currentPrescription_LAB = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
@@ -640,14 +806,52 @@ GROUP BY erx_category");
                                     hcpProUid: '{{$pro->uid}}',
                                     erxCategory: _type,
                                     clinicalDetailJson: {
-                                        test: '',
-                                        icds: '',
-                                        memo: '',
+                                        items: [
+                                            {
+                                                tests: [
+                                                    {
+                                                        desc: '',
+                                                    }
+                                                ],
+                                                icds: [
+                                                    {
+                                                        code: '',
+                                                        desc: '',
+                                                    }
+                                                ]
+                                            }
+                                        ]
+                                    }
+                                };
+                                break;
+                            case 'IMAGING':
+                                this.currentPrescription_IMAGING = {
+                                    noteUid: '{{ @$note ? $note->uid : '' }}',
+                                    clientUid: '{{ $patient->uid }}',
+                                    replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
+                                    hcpProUid: '{{$pro->uid}}',
+                                    erxCategory: _type,
+                                    clinicalDetailJson: {
+                                        items: [
+                                            {
+                                                tests: [
+                                                    {
+                                                        desc: '',
+                                                    }
+                                                ],
+                                                icds: [
+                                                    {
+                                                        code: '',
+                                                        desc: '',
+                                                    }
+                                                ]
+                                            }
+                                        ]
                                     }
                                 };
                                 break;
                             case 'REFERRAL':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_REFERRAL = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -660,7 +864,7 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'SUPPLY':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_SUPPLY = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -674,7 +878,7 @@ GROUP BY erx_category");
                                 };
                                 break;
                             case 'OTHER':
-                                this.currentPrescription_LAB = {
+                                this.currentPrescription_OTHER = {
                                     noteUid: '{{ @$note ? $note->uid : '' }}',
                                     clientUid: '{{ $patient->uid }}',
                                     replacesCancelledErxUid: null, // TODO: step-2 support UI to mark a new one as replacing a cancelled one
@@ -703,10 +907,7 @@ GROUP BY erx_category");
                             uid: _prescription.uid,
                             clinicalDetailJson: _prescription.clinical_detail_json ?
                                 JSON.parse(JSON.stringify(_prescription.clinical_detail_json)) :
-                                {
-                                    tests: [''],
-                                    icds: ['']
-                                }
+                                this.getBlankPrescriptionClinicalData(this.currentPrescriptionType)
                         };
                         Vue.nextTick(() => {
                             showStagPopup('prescription-popup-' + this.currentPrescriptionType, true);
@@ -753,6 +954,7 @@ GROUP BY erx_category");
                             case 'EDIT_CLINICAL':
                                 $.post('/api/erx/updateClinicalDetail', payload, _data => {
                                     if(!hasResponseError(_data)) {
+                                        // debugger
                                         toastr.success('Prescription updated');
                                         closeStagPopup();
                                         fastReload();
@@ -1190,19 +1392,14 @@ GROUP BY erx_category");
                             });
                         }
                     },
-                    addICD: function(_category) {
-                        this['currentPrescription_' + _category].clinicalDetailJson.icds.push('');
-                        Vue.nextTick(() => {
-                            this.initICDAutoSuggest();
-                        });
-                    },
                     initICDAutoSuggest: function() {
                         let self = this;
                         let parentSegment = $('#prescriptions-{{$patient->id}}');
                         parentSegment.find('input[type="text"][data-field="icd"]:not([ac-initialized])').each(function() {
                             var elem = this,
                                 dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
-                                vueIndex = $(this).attr('data-index'),
+                                itemIndex = $(this).attr('data-item-index'),
+                                icdIndex = $(this).attr('data-icd-index'),
                                 category = $(this).attr('data-category');
                             $(elem).attr('id', dynID);
                             new window.Def.Autocompleter.Search(dynID,
@@ -1214,9 +1411,8 @@ GROUP BY erx_category");
                             );
                             window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
                                 let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
-                                // self.data['next_cc']['list'][vueIndex].icd = acData[0].code;
-                                // self.data['next_cc']['list'][vueIndex].memo = acData[0].data['name'];
-                                self['currentPrescription_' + category].clinicalDetailJson.icds[vueIndex] = acData[0].code;
+                                self['currentPrescription_' + category].clinicalDetailJson.items[itemIndex].icds[icdIndex].code = acData[0].code;
+                                self['currentPrescription_' + category].clinicalDetailJson.items[itemIndex].icds[icdIndex].desc = acData[0].data['name'];
                                 return false;
                             });
                             $(elem).attr('ac-initialized', 1);

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

@@ -10,7 +10,7 @@ if ($point && !!@$point->data) {
 }
 
 if(!$parsed || !@$parsed->free_text) {
-    $problemPoints = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
+    list($problemPoints, $counts) = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
     $problemNames = [];
     foreach ($problemPoints as $problemPoint) {
         if($problemPoint->relevanceToNote($note)) {

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

@@ -4,7 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$allergies = Point::getPointsOfCategoryExtended($patient, 'ALLERGY', $note);
+list($allergies, $counts) = Point::getPointsOfCategoryExtended($patient, 'ALLERGY', $note);
 
 $numRelevant = 0;
 $numVisible = 0;

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

@@ -4,7 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$careTeamMembers = Point::getPointsOfCategoryExtended($patient, 'CARE_TEAM_MEMBER', $note);
+list($careTeamMembers, $counts) = Point::getPointsOfCategoryExtended($patient, 'CARE_TEAM_MEMBER', $note);
 
 $numRelevant = 0;
 $numVisible = 0;

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

@@ -4,7 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$goals = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
+list($goals, $counts) = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
 
 $goals = array_filter($goals, function ($_x) use ($note) {
     $rel = $_x->relevanceToNote($note);

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

@@ -4,7 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$medications = Point::getPointsOfCategoryExtended($patient, 'MEDICATION', $note);
+list($medications, $counts) = Point::getPointsOfCategoryExtended($patient, 'MEDICATION', $note);
 
 $numRelevant = 0;
 $numVisible = 0;

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

@@ -4,7 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$problems = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
+list($problems, $counts) = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
 
 $numRelevant = 0;
 $numVisible = 0;

+ 4 - 3
resources/views/app/pdf/viewer.blade.php

@@ -1,3 +1,4 @@
+<?php $viewerID = rand(10000, 99999); ?>
 <script>
     (function () {
 
@@ -7,7 +8,7 @@
             $('body').append(
                 '<div class="stag-popup stag-popup-md stag-popup-right mcp-theme-1" ' +
                 'stag-popup-key="pdf-viewer" ' +
-                'id="stagPdfViewer">' +
+                'id="stagPdfViewer-{{$viewerID}}">' +
                 '<form>' +
                 '<h3 class="stag-popup-title">' +
                 '<span>PDF Viewer</span>' +
@@ -20,7 +21,7 @@
             );
 
             new Vue({
-                el: '#stagPdfViewer',
+                el: '#stagPdfViewer-{{$viewerID}}',
                 data: {
                     loadedPDF: null,
                     page: 1,
@@ -89,7 +90,7 @@
                     $(document)
                         .off('click.pdf-viewer', '.pdf-viewer-trigger')
                         .on('click.pdf-viewer', '.pdf-viewer-trigger', function () {
-                            self.parent = $('#stagPdfViewer>form');
+                            self.parent = $('#stagPdfViewer-{{$viewerID}}>form');
                             self.load(this.href, $(this).attr('pdf-viewer-element'));
                             if(!$(this).attr('pdf-viewer-element')) {
                                 showStagPopup('pdf-viewer');

+ 4 - 4
resources/views/layouts/patient.blade.php

@@ -304,8 +304,8 @@ $isVisitNote = ($routeName === 'patients.view.notes.view.dashboard' && @$note &&
 						</div>
 					</div>
 				@endif
-				<div class="card {{$isVisitNote ? 'card m-0 border-0 rounded-0' : 'mt-3'}}" id="patient-header">
-					<div class="card-header py-1 hide-inside-ticket-popup">
+				<div class="card {{$isVisitNote ? 'card m-0 border-0 rounded-0' : 'my-3'}}" id="patient-header">
+					<div class="card-header py-1 hide-inside-ticket-popup hide-inside-popup">
 						<?php
 						$thumbnail = $patient->profile_picture_base64;
 						$initials = !$thumbnail ? substr($patient->name_first, 0, 1) . substr($patient->name_last, 0, 1) : '';
@@ -728,7 +728,7 @@ $isVisitNote = ($routeName === 'patients.view.notes.view.dashboard' && @$note &&
                                     </section>
 									
                                     <section class="hide-inside-popup screen-only vbox mt-2 align-self-start ml-1">
-                                        @if($performer->pro->pro_type == 'ADMIN' || true)
+                                        @if($performer->pro->pro_type == 'ADMIN')
                                         <div>
                                             <button class="col-2-button" onclick="return openInRHS('/pro/check-video/{{ $patient->uid }}')">Check Video</button>
                                         </div>
@@ -810,7 +810,7 @@ $isVisitNote = ($routeName === 'patients.view.notes.view.dashboard' && @$note &&
 						</div> <!-- z -->
 					</div>
 					@if($pro->pro_type === 'ADMIN')
-						<div class="screen-only card-header py-2 d-flex align-items-center mcp-theme-1 bg-aliceblue">
+						<div class="screen-only card-header py-2 d-flex align-items-center mcp-theme-1 bg-aliceblue hide-inside-popup">
 							<b class="">Tags ({{count($patient->clientTags)}}):</b>
 							@foreach($patient->clientTags as $tag)
 								<div class="d-inline-flex align-items-center ml-2 py-1 px-2 rounded bg-aliceblue text-info">