소스 검색

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

= 3 년 전
부모
커밋
33af39a596
50개의 변경된 파일2927개의 추가작업 그리고 1236개의 파일을 삭제
  1. 0 63
      .env.example
  2. 26 0
      app/Helpers/helpers.php
  3. 8 6
      app/Http/Controllers/HomeController.php
  4. 12 0
      app/Http/Controllers/NoteController.php
  5. 5 0
      app/Models/Client.php
  6. 6 0
      app/Models/Note.php
  7. 26 0
      app/Models/Point.php
  8. 1 1
      config/app.php
  9. 3 0
      public/css/style.css
  10. 1 0
      resources/views/app/dashboard/measurements.blade.php
  11. 33 3
      resources/views/app/patient/care-month/_matrix.blade.php
  12. 1 0
      resources/views/app/patient/care-months.blade.php
  13. 190 5
      resources/views/app/patient/note/dashboard.blade.php
  14. 5 0
      resources/views/app/patient/note/dashboard_script.blade.php
  15. 433 0
      resources/views/app/patient/note/pdf.blade.php
  16. 12 10
      resources/views/app/patient/note/segment.blade.php
  17. 9 4
      resources/views/app/patient/note/segment_script.blade.php
  18. 20 11
      resources/views/app/patient/prescriptions/drug-form.blade.php
  19. 157 12
      resources/views/app/patient/prescriptions/index.blade.php
  20. 17 8
      resources/views/app/patient/segment-templates/intake_allergies/summary.blade.php
  21. 21 14
      resources/views/app/patient/segment-templates/intake_care_team/summary.blade.php
  22. 104 10
      resources/views/app/patient/segment-templates/intake_goals/edit.blade.php
  23. 32 13
      resources/views/app/patient/segment-templates/intake_goals/summary.blade.php
  24. 1 1
      resources/views/app/patient/segment-templates/intake_interventions/edit.blade.php
  25. 19 10
      resources/views/app/patient/segment-templates/intake_interventions/summary.blade.php
  26. 10 0
      resources/views/app/patient/segment-templates/intake_medications/edit.blade.php
  27. 18 10
      resources/views/app/patient/segment-templates/intake_medications/summary.blade.php
  28. 21 9
      resources/views/app/patient/segment-templates/intake_problems/summary.blade.php
  29. 18 12
      resources/views/app/patient/segment-templates/medrisk_vigilence/summary.blade.php
  30. 1 1
      resources/views/app/patient/segment-templates/objective_measurements/edit.blade.php
  31. 1 1
      resources/views/app/patient/segment-templates/objective_measurements/summary.blade.php
  32. 82 31
      resources/views/app/patient/segment-templates/plan_allergies/edit.blade.php
  33. 45 12
      resources/views/app/patient/segment-templates/plan_allergies/summary.blade.php
  34. 102 43
      resources/views/app/patient/segment-templates/plan_care_team/edit.blade.php
  35. 51 19
      resources/views/app/patient/segment-templates/plan_care_team/summary.blade.php
  36. 177 28
      resources/views/app/patient/segment-templates/plan_goals/edit.blade.php
  37. 62 17
      resources/views/app/patient/segment-templates/plan_goals/summary.blade.php
  38. 99 40
      resources/views/app/patient/segment-templates/plan_interventions/edit.blade.php
  39. 49 14
      resources/views/app/patient/segment-templates/plan_interventions/summary.blade.php
  40. 117 59
      resources/views/app/patient/segment-templates/plan_medications/edit.blade.php
  41. 46 14
      resources/views/app/patient/segment-templates/plan_medications/summary.blade.php
  42. 7 5
      resources/views/app/patient/segment-templates/plan_problems/edit.blade.php
  43. 32 21
      resources/views/app/patient/segment-templates/plan_problems/summary.blade.php
  44. 72 729
      resources/views/app/patient/vitals-settings.blade.php
  45. 144 0
      resources/views/app/patient/vitals-settings/bmi-management-form.blade.php
  46. 64 0
      resources/views/app/patient/vitals-settings/bmi-management-summary.blade.php
  47. 298 0
      resources/views/app/patient/vitals-settings/bp-management-form.blade.php
  48. 258 0
      resources/views/app/patient/vitals-settings/bp-management-summary.blade.php
  49. 10 0
      resources/views/app/patients.blade.php
  50. 1 0
      routes/web.php

+ 0 - 63
.env.example

@@ -1,63 +0,0 @@
-APP_NAME=Stag
-APP_ENV=local
-APP_KEY=base64:1yKRgeLWTeEXTfh51vXtJaf6GJaRUn4NHzdlOdyDpRY=
-APP_DEBUG=true
-APP_URL=http://localhost
-
-LOG_CHANNEL=stack
-
-DB_CONNECTION=pgsql
-DB_HOST=127.0.0.1
-DB_PORT=5432
-DB_DATABASE=stag2
-DB_USERNAME=postgres
-DB_PASSWORD=pass
-
-DB_HOST_FDB=127.0.0.1
-DB_PORT_FDB=5432
-DB_DATABASE_FDB=fdb
-DB_USERNAME_FDB=postgres
-DB_PASSWORD_FDB=password
-
-BROADCAST_DRIVER=log
-CACHE_DRIVER=file
-QUEUE_CONNECTION=sync
-SESSION_DRIVER=file
-SESSION_LIFETIME=120
-
-REDIS_HOST=127.0.0.1
-REDIS_PASSWORD=null
-REDIS_PORT=6379
-
-MAIL_MAILER=smtp
-MAIL_HOST=smtp.mailtrap.io
-MAIL_PORT=2525
-MAIL_USERNAME=null
-MAIL_PASSWORD=null
-MAIL_ENCRYPTION=null
-MAIL_FROM_ADDRESS=null
-MAIL_FROM_NAME="${APP_NAME}"
-
-AWS_ACCESS_KEY_ID=
-AWS_SECRET_ACCESS_KEY=
-AWS_DEFAULT_REGION=us-east-1
-AWS_BUCKET=
-
-PUSHER_APP_ID=
-PUSHER_APP_KEY=
-PUSHER_APP_SECRET=
-PUSHER_APP_CLUSTER=mt1
-
-MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
-MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
-
-BACKEND_URL="http://localhost:8080/api"
-ADMIN_PORTAL_URL="http://localhost:3000"
-
-AUTH_URL="http://localhost:3002"
-
-BACKEND_WS_URL=http://localhost:8080/ws
-AGORA_APPID=9d04292b03524927a8fe9d937a448d85
-AGORA_MODE=screen
-
-ENABLE_SOCKETS=false

+ 26 - 0
app/Helpers/helpers.php

@@ -617,3 +617,29 @@ if(!function_exists('minutes_to_hhmm')) {
         return $h . ':' . $m;
     }
 }
+if(!function_exists('vsValue')) {
+    function vsValue($_v, $patient = null, $_direct = false)
+    {
+        if ($_direct) {
+            return $_v ? $_v : '<span class="font-weight-normal text-info font-italic">empty</span>';
+        }
+        return @($patient->{$_v}) ? $patient->{$_v} : '<span class="font-weight-normal text-info font-italic">empty</span>';
+    }
+}
+if(!function_exists('vsElement')) {
+    function vsElement($_v, $type, $name, $patient)
+    {
+        return '<input type="' . $type . '" class="form-control form-control-sm min-width-unset rounded-0" ' .
+            'name="' . $name . '" ' .
+            'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
+    }
+}
+
+if(!function_exists('vsRoElement')) {
+    function vsRoElement($_v, $type, $name, $patient)
+    {
+        return '<input type="' . $type . '" readonly class="form-control form-control-sm min-width-unset rounded-0" ' .
+            'name="' . $name . '" ' .
+            'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
+    }
+}

+ 8 - 6
app/Http/Controllers/HomeController.php

@@ -462,11 +462,11 @@ WHERE
         note.ally_pro_id = :pro_id AND
         note.is_cancelled = FALSE AND
         (
-            SELECT count(bill.id) 
-            FROM bill 
-            WHERE 
-                  bill.is_cancelled = FALSE AND 
-                  bill.generic_pro_id = :pro_id AND 
+            SELECT count(bill.id)
+            FROM bill
+            WHERE
+                  bill.is_cancelled = FALSE AND
+                  bill.generic_pro_id = :pro_id AND
                   bill.note_id = note.id
         ) = 0
         "), ["pro_id" => $performerProID]);
@@ -625,6 +625,7 @@ SELECT measurement.uid as uid,
        measurement.value_pulse,
        measurement.value_irregular,
        measurement.ts,
+       client.id as client_id,
        client.mcp_pro_id,
        client.default_na_pro_id,
        client.rmm_pro_id,
@@ -639,6 +640,7 @@ FROM measurement
 WHERE measurement.label NOT IN ('SBP', 'DBP')
   AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
   AND measurement.is_removed IS FALSE
+  AND measurement.has_been_stamped_by_mcp IS FALSE
   AND measurement.ts IS NOT NULL
   AND measurement.client_bdt_measurement_id IS NOT NULL
   AND (measurement.status IS NULL OR (measurement.status <> 'ACK' AND measurement.status <> 'INVALID_ACK'))
@@ -998,7 +1000,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
     }
 
     public function logInAs(Request $request)
-    {   
+    {
         if($this->pro->pro_type != 'ADMIN'){
             return redirect()->to(route('dashboard'));
         }

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

@@ -287,6 +287,18 @@ class NoteController extends Controller
         return view('app.patient.note.plan-log', compact('point'));
     }
 
+    // print/pdf
+    public function downloadAsPdf(Request $request, Note $note) {
+        $patient = $note->client;
+        if($request->input('html')) {
+            return view('app.patient.note.pdf', compact('note', 'patient'));
+        }
+        else {
+            $pdf = \PDF::loadView('app.patient.note.pdf', compact('note', 'patient'));
+            return $pdf->stream($note->created_at .'_' . 'note.pdf');
+        }
+    }
+
     // TODO move to utility
     private function callJava($request, $endPoint, $data, $guestAccessCode = null)
     {

+ 5 - 0
app/Models/Client.php

@@ -645,6 +645,11 @@ class Client extends Model
             ->orderBy('code', 'ASC');
     }
 
+    public function cmSetupNote()
+    {
+        return $this->hasOne(Note::class, 'id', 'cm_setup_note_id');
+    }
+
     public function defaultMcpCompanyPro()
     {
         return $this->hasOne(CompanyPro::class, 'id', 'default_mcp_company_pro_id');

+ 6 - 0
app/Models/Note.php

@@ -38,6 +38,12 @@ class Note extends Model
         return $this->hasOne(Pro::class, 'id', 'ally_pro_id');
     }
 
+    public function cmSetupClaim()
+    {
+        return $this->hasOne(Claim::class, 'id', 'cm_setup_claim_id')
+            ->where('status', '<>', 'CANCELLED');
+    }
+
     public function bills()
     {
         return $this->hasMany(Bill::class, 'note_id', 'id')

+ 26 - 0
app/Models/Point.php

@@ -15,6 +15,32 @@ class Point extends Model
             ->orderBy('created_at', 'DESC');
     }
 
+    public function childReviewAddedInNote($_note)
+    {
+        $review = Point::where('added_in_note_id', $_note->id)
+            ->where('category', 'REVIEW')
+            ->where('parent_point_id', $this->id)
+            ->orderBy('created_at', 'DESC')
+            ->first();
+        if(!!$review) {
+            $review->data = json_decode($review->data);
+        }
+        return $review;
+    }
+
+    public function childPlanAddedInNote($_note)
+    {
+        $review = Point::where('added_in_note_id', $_note->id)
+            ->where('category', 'PLAN')
+            ->where('parent_point_id', $this->id)
+            ->orderBy('created_at', 'DESC')
+            ->first();
+        if(!!$review) {
+            $review->data = json_decode($review->data);
+        }
+        return $review;
+    }
+
     public function lastChildReview()
     {
         return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');

+ 1 - 1
config/app.php

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

+ 3 - 0
public/css/style.css

@@ -298,6 +298,9 @@ body>nav.navbar {
 .mcp-theme-1 .width-70px {
     width: 70px !important;
 }
+.mcp-theme-1 .min-width-70px {
+    min-width: 70px !important;
+}
 .mcp-theme-1 .width-90px {
     width: 90px !important;
 }

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

@@ -110,6 +110,7 @@
                         <a native target="_blank"
                            open-in-stag-popup
                            update-parent
+                           mc-initer="cm-matrix-{{$measurement->client_id}}"
                            title="Care Month Matrix: {{date('M Y', strtotime($measurement->care_month_start_date))}}"
                            href="/patient-care-month-matrix/{{$measurement->care_month_uid}}">
                             View &amp; Stamp

+ 33 - 3
resources/views/app/patient/care-month/_matrix.blade.php

@@ -26,8 +26,14 @@ foreach ($days as $k => $day) {
 }
 
 ?>
-<p class="font-weight-bold">Care Month Matrix</p>
-<table class="table table-condensed table-sm table-bordered mt-2 mb-3">
+<div class="d-flex align-items-baseline">
+    <a class="font-weight-bold" href="#" tab-link="matrix">Care Month Matrix</a>
+    <span class="mx-2 text-secondary text-sm">|</span>
+    <a class="" href="#" tab-link="bmi-summary">BMI Management Settings</a>
+    <span class="mx-2 text-secondary text-sm">|</span>
+    <a class="" href="#" tab-link="bp-summary">BP Management Settings</a>
+</div>
+<table class="table table-condensed table-sm table-bordered my-3 cm-tab" tab-key="matrix">
     <thead>
     <tr>
         <th class="px-2 text-secondary align-bottom" rowspan="2">Date</th>
@@ -251,4 +257,28 @@ foreach ($days as $k => $day) {
         @endforeach
     @endforeach
     </tbody>
-</table>
+</table>
+<div class="my-3 border p-3 d-none cm-tab" tab-key="bmi-summary">
+    @include('app.patient.vitals-settings.bmi-management-summary')
+</div>
+<div class="my-3 border p-3 d-none cm-tab" tab-key="bp-summary">
+    @include('app.patient.vitals-settings.bp-management-summary')
+</div>
+
+<script>
+    (function() {
+        function init() {
+            $('a[tab-link]')
+                .off('click')
+                .on('click', function () {
+                    let tab = $(this).attr('tab-link');
+                    $(this).siblings().removeClass('font-weight-bold');
+                    $(this).addClass('font-weight-bold');
+                    $('.cm-tab').addClass('d-none');
+                    $('.cm-tab[tab-key="' + tab + '"]').removeClass('d-none');
+                    return false;
+                });
+        }
+        addMCInitializer('cm-matrix-{{$patient->id}}', init);
+    }).call(window);
+</script>

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

@@ -137,6 +137,7 @@
                     <td class="px-2">
                         <a native target="_blank"
                            open-in-stag-popup
+                           mc-initer="cm-matrix-{{$patient->id}}"
                            title="Care Month Matrix: {{date('M Y', strtotime($careMonth->start_date))}}"
                            href="/patient-care-month-matrix/{{$careMonth->uid}}">
                             View

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

@@ -49,7 +49,13 @@
                     <span class="text-secondary font-weight-normal">{{ $note->is_cancelled ? '(CANCELLED)' : '' }}</span>
                 </span>
                 @if($pro->pro_type === 'ADMIN')
-                    <a href="#" class="print-note ml-3 btn btn-sm btn-primary text-white font-weight-bold invisible"><i class="fa fa-print"></i> Print</a>
+                    @if(!!$note->visitTemplate)
+                        <a native target="_blank"
+                           href="{{route('note-pdf', ['note' => $note])}}"
+                           class="ml-3 btn btn-sm btn-primary text-white font-weight-bold"><i class="fa fa-print"></i> Print</a>
+                    @else
+                        <a href="#" class="print-note ml-3 btn btn-sm btn-primary text-white font-weight-bold invisible"><i class="fa fa-print"></i> Print</a>
+                    @endif
                     <?php
                     $isBad = false;
                     $isGood = false;
@@ -332,11 +338,12 @@
             <div class="ml-auto d-flex align-items-start">
                 <div class="">
                     <div>
-                        
+
+                        @if($note->is_signed_by_hcp )
                             <div class="text-secondary">
                                 <i class="fa fa-check"></i>
                                 Note Signed
-                                @if($pro->pro_type == 'ADMIN')
+                                {{--@if($pro->pro_type == 'ADMIN')
                                 <span moe class="ml-2">
                                     <a class="" href="" show start>Undo sign?</a>
                                     <form url="/api/note/adminUndoSignAsHcp" right>
@@ -349,7 +356,9 @@
                                     </form>
                                 </span>
                                 @endif
+                                @endif--}}
                             </div>
+                        @endif
                         @if(!$note->is_signed_by_hcp )
                             <div moe
                                  class="{{ $note->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
@@ -519,7 +528,7 @@
 
                 <span class="d-none latest-section-ts">{{ $latestSectionTS }}</span>
 
-                <div class="p-3 border-bottom">
+                <div class="p-3 border-bottom screen-only">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0 font-size-14">ERx/Orders Summary</p>
@@ -791,7 +800,183 @@
                     </div>
                 </div>
 
-                <div class="p-3 border-bottom">
+                <div class="p-3 border-bottom screen-only">
+                    <div class="d-flex align-items-center mb-3">
+                        <p class="font-weight-bold text-secondary m-0 font-size-14">CM Setup</p>
+                    </div>
+
+                    <div class="mb-3 d-flex align-items-center">
+                        <span class="min-width-140px">CM Setup Status:</span>
+                        <div class="d-inline-flex align-items-center flex-grow-1">
+                            @if($patient->has_cm_setup_been_performed)
+                                <span class="text-nowrap text-success">
+                                    <i class="fa fa-check"></i>
+                                    <b>Performed</b>
+                                </span>
+                                <div moe class="ml-3">
+                                    <a href="" show start>Undo</a>
+                                    <form url="/api/note/undoMarkCmSetupPerformed">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Undo CM setup to not-performed?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <span class="text-nowrap text-warning-mellow">
+                                    <i class="fa fa-times"></i>
+                                    <b>Not Performed</b>
+                                </span>
+                                <div moe class="ml-3">
+                                    <a href="" show start>Mark as performed</a>
+                                    <form url="/api/note/markCmSetupPerformedAsMcp">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Mark CM setup as performed?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+                        </div>
+                    </div>
+
+                    @if($pro->pro_type === 'ADMIN')
+                        <div class="d-flex align-items-center">
+                            <span class="min-width-140px">CM Setup Claim:</span>
+                            <div class="d-inline-flex align-items-center flex-grow-1">
+                                @if(!!$note->cmSetupClaim)
+                                    <span class="text-nowrap text-success">
+                                        <i class="fa fa-check"></i>
+                                        <b>Created</b>
+                                    </span>
+                                @else
+                                    <span class="text-nowrap text-warning-mellow">
+                                        <i class="fa fa-times"></i>
+                                        <b>Not Created</b>
+                                    </span>
+                                    <div moe class="ml-3">
+                                        <a href="" show start>Generate</a>
+                                        <form url="/api/note/generateCmSetupClaim">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Generate CM setup claim?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+                        </div>
+                    @endif
+
+                </div>
+
+                <div class="p-3 border-bottom screen-only">
+
+                    <div class="d-flex align-items-center mb-3">
+                        <p class="font-weight-bold text-secondary m-0 font-size-14">RM Setup</p>
+                    </div>
+
+                    <div class="row" id="vitals-settings-{{$patient->uid}}">
+                        <div class="col-4 border-right">
+                            <div class="d-flex align-items-baseline">
+                                <b>BMI Management</b>
+                                <span class="mx-2 text-secondary">|</span>
+                                @include('app.patient.vitals-settings.bmi-management-form')
+                            </div>
+                            <div class="pt-3">
+                                @include('app.patient.vitals-settings.bmi-management-summary')
+                            </div>
+                        </div>
+                        <div class="col-8">
+                            <div class="d-flex align-items-baseline">
+                                <b>BP Management</b>
+                                <span class="mx-2 text-secondary">|</span>
+                                @include('app.patient.vitals-settings.bp-management-form')
+                            </div>
+                            <div class="pt-3">
+                                @include('app.patient.vitals-settings.bp-management-summary')
+                            </div>
+                        </div>
+                    </div>
+
+                    <script>
+                        (function () {
+                            function calculateUsualBmi() {
+                                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                                    w = $('#bmi-management-settings [name="usualWeightInPounds"]').val();
+                                let bmiElem = $('#bmi-management-settings [name="usualBmi"]').val(''),
+                                    bmiCategoryElem = $('#bmi-management-settings [name="usualBmiCategory"]').val('');
+                                calculateBmi(h, w, bmiElem, bmiCategoryElem);
+                                return false;
+                            }
+
+                            function calculateIdealBmi() {
+                                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                                    w = $('#bmi-management-settings [name="idealWeightInPounds"]').val();
+                                let bmiElem = $('#bmi-management-settings [name="idealBmi"]').val(''),
+                                    bmiCategoryElem = $('#bmi-management-settings [name="idealBmiCategory"]').val('');
+                                calculateBmi(h, w, bmiElem, bmiCategoryElem);
+                                return false;
+                            }
+
+                            function calculateBmi(h, w, bmiElem, bmiCategoryElem) {
+                                let bmi = 0,
+                                    bmiCategory = '';
+                                try {
+                                    h = +h;
+                                    w = +w;
+                                    bmi = (w / (h * h)) * 703;
+                                    bmiElem.val(bmi.toFixed(1));
+                                    if (bmi < 18.5) {
+                                        bmiCategory = '(Underweight)';
+                                    }
+                                    if (bmi >= 18.5 && bmi < 25) {
+                                        bmiCategory = '(Healthy)';
+                                    }
+                                    if (bmi >= 25 && bmi < 30) {
+                                        bmiCategory = '(Overweight)';
+                                    }
+                                    if (bmi >= 30) {
+                                        bmiCategory = '(Obese)';
+                                    }
+                                    bmiCategoryElem.val(bmiCategory);
+                                } catch (e) {
+                                    return false;
+                                }
+                            }
+
+                            function init() {
+                                $(document)
+                                    .off('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]')
+                                    .on('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]', function () {
+                                            return calculateUsualBmi();
+                                        });
+                                $(document)
+                                    .off('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]')
+                                    .on('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]', function () {
+                                            return calculateIdealBmi();
+                                        });
+
+                                $('#bmi-management-settings [name="currentHeightInInches"]').trigger('change');
+                            }
+
+                            addMCInitializer('vitals-settings-{{$patient->uid}}', init, '#vitals-settings-{{$patient->uid}}')
+                        }).call(window);
+                    </script>
+
+                </div>
+
+                <div class="p-3 border-bottom screen-only">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>

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

@@ -81,6 +81,11 @@
                     .off('click.edit-trigger', '.edit-trigger:not(.edit)')
                     .on('click.edit-trigger', '.edit-trigger:not(.edit)', function() {
                         let editParent = $(this).closest('.note-section');
+
+                        // TEMP: disable edit mode for medrisk_vigilance
+                        // TODO: do this in the proper place
+                        if(editParent.is('[data-segment-template-name="medrisk_vigilence"]')) return false;
+
                         if(editParent.is('.edit')) {
                             editParent.removeClass('edit');
                         }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 433 - 0
resources/views/app/patient/note/pdf.blade.php


+ 12 - 10
resources/views/app/patient/note/segment.blade.php

@@ -1,4 +1,4 @@
-<div class="p-3 border-bottom note-section visit-segment edit-trigger"
+<div class="p-3 border-bottom note-section visit-segment {{$note->is_signed_by_hcp ? '' : 'edit-trigger'}}"
 	 data-segment-uid="{{ $segment->uid }}"
 	 data-segment-template-uid="{{ $segment->segmentTemplate->uid }}"
 	 data-segment-template-name="{{ $segment->segmentTemplate->internal_name }}">
@@ -20,17 +20,19 @@
 			{{$segment->display_title}}
 		</span>
 
-		<a class="edit-trigger d-none if-edit c-pointer ml-3">Close</a>
+		@if(!$note->is_signed_by_hcp)
+			<a class="edit-trigger d-none if-edit c-pointer ml-3">Close</a>
 
-		<!-- refresh -->
-		<span class="mx-2 text-secondary text-sm">|</span>
-		<a class="font-weight-normal refresh-segment c-pointer"
-		   data-segment-uid="{{$segment->uid}}"
-		   title="Update with latest patient data">
-			Refresh
-		</a>
+			<!-- refresh -->
+			<span class="mx-2 text-secondary text-sm">|</span>
+			<a class="font-weight-normal refresh-segment c-pointer"
+			   data-segment-uid="{{$segment->uid}}"
+			   title="Update with latest patient data">
+				Refresh
+			</a>
 
-		@include('app/patient/note/_templates-v2-index', ['sectionInternalName' => $segment->segmentTemplate->internal_name])
+			@include('app/patient/note/_templates-v2-index', ['sectionInternalName' => $segment->segmentTemplate->internal_name])
+		@endif
 
 	</div>
 

+ 9 - 4
resources/views/app/patient/note/segment_script.blade.php

@@ -189,13 +189,18 @@
             initStagSuggest();
 
             // check and run all segment initializers
-            if(window.segmentInitializers) {
-                for(let x in window.segmentInitializers) {
-                    if(window.segmentInitializers.hasOwnProperty(x) && typeof window.segmentInitializers[x] === 'function') {
-                        window.segmentInitializers[x].call(window);
+            try {
+                if(window.segmentInitializers) {
+                    for(let x in window.segmentInitializers) {
+                        if(window.segmentInitializers.hasOwnProperty(x) && typeof window.segmentInitializers[x] === 'function') {
+                            window.segmentInitializers[x].call(window);
+                        }
                     }
                 }
             }
+            catch (e) {
+                console.warn('Error running 1 or more segment initializers.')
+            }
 
             // refresh segment
             $(document)

+ 20 - 11
resources/views/app/patient/prescriptions/drug-form.blade.php

@@ -7,38 +7,47 @@
         </h3>
         <div class="mb-2">
             <label class="text-sm text-secondary mb-1">Drug</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
-                   v-model="currentPrescription_DRUG.clinicalDetailJson.medication">
+            <input type="text" class="form-control form-control-sm min-width-unset prescription-medication"
+                   stag-suggest
+                   stag-suggest-ep="/fdb-med-suggest/json">
         </div>
         <div class="row">
             <div class="col-6 pr-0">
                 <div class="mb-2">
-                    <label class="text-sm text-secondary mb-1">Strength</label>
-                    <input type="text" class="form-control form-control-sm min-width-unset"
-                           v-model="currentPrescription_DRUG.clinicalDetailJson.strength">
+                    <label class="text-sm text-secondary mb-1">Route</label>
+                    <select class="form-control form-control-sm min-width-unset prescription-route"
+                            disabled>
+                    </select>
                 </div>
             </div>
             <div class="col-6">
                 <div class="mb-2">
-                    <label class="text-sm text-secondary mb-1">Amount</label>
-                    <input type="text" class="form-control form-control-sm min-width-unset"
-                           v-model="currentPrescription_DRUG.clinicalDetailJson.amount">
+                    <label class="text-sm text-secondary mb-1">Dosage</label>
+                    <select class="form-control form-control-sm min-width-unset prescription-dose"
+                            disabled>
+                    </select>
                 </div>
             </div>
         </div>
         <div class="row">
             <div class="col-6 pr-0">
                 <div class="mb-2">
-                    <label class="text-sm text-secondary mb-1">Route</label>
-                    <input type="text" class="form-control form-control-sm min-width-unset"
-                           v-model="currentPrescription_DRUG.clinicalDetailJson.route">
+                    <label class="text-sm text-secondary mb-1">Strength</label>
+                    <select class="form-control form-control-sm min-width-unset prescription-strength"
+                            disabled>
+                    </select>
                 </div>
             </div>
             <div class="col-6">
                 <div class="mb-2">
                     <label class="text-sm text-secondary mb-1">Frequency</label>
                     <input type="text" class="form-control form-control-sm min-width-unset"
+                           data-option-list="frequency-options" data-field="frequency"
                            v-model="currentPrescription_DRUG.clinicalDetailJson.frequency">
+                    <div id="frequency-options" class="data-option-list">
+                        <div>Once a day</div>
+                        <div>Twice a day</div>
+                    </div>
                 </div>
             </div>
         </div>

+ 157 - 12
resources/views/app/patient/prescriptions/index.blade.php

@@ -100,9 +100,9 @@
                         <div v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
                             <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
                                 <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.medication ?? '-'}}</b>
-                                <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
+                                <!--<span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
                                 <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.amount ?? '-'}}</span>
-                                <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.route ?? '-'}}</span>
+                                <span class="text-secondary mr-1 font-size-16">@{{currentPrescription.clinical_detail_json.route ?? '-'}}</span>-->
                             </div>
                             <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'LAB' || currentPrescription.erx_category === 'IMAGING'">
                                 <b class="mr-2 font-size-16">@{{currentPrescription.clinical_detail_json.test ?? '-'}}</b>
@@ -144,9 +144,9 @@
                         <div v-if="currentPrescription.clinical_detail_json" class="d-inline-flex align-items-baseline">
                             <div class="d-flex align-items-baseline" v-if="currentPrescription.erx_category === 'DRUG'">
                                 <b class="mr-2">@{{currentPrescription.clinical_detail_json.medication ?? '-'}}</b>
-                                <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
-                                <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.amount ?? '-'}}</span>
-                                <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.route ?? '-'}}</span>
+                                <!--<span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.strength ?? '-'}}</span>
+                                <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.dispense ?? '-'}}</span>
+                                <span class="text-secondary mr-1">@{{currentPrescription.clinical_detail_json.refills ?? '-'}}</span>-->
                             </div>
                             <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>
@@ -276,7 +276,7 @@
 
             function init() {
 
-                window.booApp = new Vue({
+                new Vue({
                     el: '#prescriptions-{{$patient->id}}',
                     delimiters: ['@{{', '}}'],
                     data: {
@@ -286,7 +286,7 @@
                         currentPrescriptionType: '',
 
                         // selected
-                        currentPrescription:  <?= $currentPrescription ?>,
+                        currentPrescription:  <?= $currentPrescription ? json_encode($currentPrescription) : 'null' ?>,
 
                         // for editing clinical details
                         currentPrescription_DRUG: {
@@ -297,13 +297,20 @@
                             erxCategory: 'DRUG',
                             clinicalDetailJson: {
                                 medication: '',
-                                strength: '',
-                                amount: '',
                                 route: '',
+                                dose: '',
+                                strength: '',
                                 frequency: '',
                                 dispense: '',
                                 refills: '',
                                 purpose: '',
+
+                                // fdb specific
+                                medNameID: '',
+                                routedMedID: '',
+                                dosageFormMedID: '',
+                                gcnSeqno: '',
+                                medId: '',
                             }
                         },
                         currentPrescription_LAB: {
@@ -409,7 +416,7 @@
                             copyToPatient: false,
                             copyToPatientFaxNumber: '',
                             copyToPatientEmail: '',
-                        },
+                        }
                     },
                     methods: {
 
@@ -427,13 +434,20 @@
                                         erxCategory: _type,
                                         clinicalDetailJson: {
                                             medication: '',
-                                            strength: '',
-                                            amount: '',
                                             route: '',
+                                            dose: '',
+                                            strength: '',
                                             frequency: '',
                                             dispense: '',
                                             refills: '',
                                             purpose: '',
+
+                                            // fdb specific
+                                            medNameID: '',
+                                            routedMedID: '',
+                                            dosageFormMedID: '',
+                                            gcnSeqno: '',
+                                            medId: '',
                                         }
                                     };
                                     break;
@@ -495,6 +509,11 @@
                             }
                             Vue.nextTick(() => {
                                 showStagPopup('prescription-popup-' + this.currentPrescriptionType, true);
+                                if(_type === 'DRUG') {
+                                    $('[stag-suggest][stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                    initStagSuggest();
+                                    this.initFdbMedSuggest();
+                                }
                             });
                         },
                         editClinicalDetails: function(_prescription) {
@@ -506,6 +525,28 @@
                             };
                             Vue.nextTick(() => {
                                 showStagPopup('prescription-popup-' + this.currentPrescriptionType, true);
+                                if(this.currentPrescriptionType === 'DRUG') {
+                                    $('[stag-suggest][stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                                    initStagSuggest();
+                                    this.initFdbMedSuggest();
+
+                                    // re-populate drug fields
+                                    console.log(this.currentPrescription_DRUG);
+                                    let parentSegment = $('#prescriptions-{{$patient->id}} [stag-popup-key="prescription-popup-DRUG"]>form').first();
+                                    parentSegment.find('input.prescription-medication').val(this.currentPrescription_DRUG.clinicalDetailJson.medication);
+                                    parentSegment.find('select.prescription-route')
+                                        .empty()
+                                        .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.route))
+                                        .val(1);
+                                    parentSegment.find('select.prescription-dose')
+                                        .empty()
+                                        .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.dose))
+                                        .val(1);
+                                    parentSegment.find('select.prescription-strength')
+                                        .empty()
+                                        .append($('<option/>').attr('value', 1).text(this.currentPrescription_DRUG.clinicalDetailJson.strength))
+                                        .val(1);
+                                }
                             });
                         },
                         savePrescription: function() {
@@ -756,6 +797,110 @@
 
                         // cancel, etc.
 
+                        initFdbMedSuggest: function() {
+
+                            let self = this;
+
+                            let parentSegment = $('#prescriptions-{{$patient->id}} [stag-popup-key="prescription-popup-DRUG"]>form').first();
+
+                            parentSegment.find('input.prescription-medication').off('stag-suggest-selected');
+                            parentSegment.find('input.prescription-medication').on('stag-suggest-selected', (_e, _input, _data) => {
+
+                                // _input is the textbox
+                                // _data is {med_name_id: "50567", text: "Children's Tylenol"}
+
+                                // set vue values
+                                self.currentPrescription_DRUG.clinicalDetailJson.medication = _data.text;
+                                self.currentPrescription_DRUG.clinicalDetailJson.medNameID = _data.med_name_id;
+
+                                let routeSelect = parentSegment.find('.prescription-route').empty().prop('disabled', true);
+                                let dosageSelect = parentSegment.find('.prescription-dose').empty().prop('disabled', true);
+                                let strengthSelect = parentSegment.find('.prescription-strength').empty().prop('disabled', true);
+
+                                $.get('/fdb-routed-meds?med-name-id=' + _data.med_name_id, _data => {
+                                    routeSelect
+                                        .empty()
+                                        .append('<option value="">-- select --</option>');
+                                    for (let i = 0; i < _data.length; i++) {
+                                        routeSelect.append('<option value="' + _data[i].routed_med_id + '">' + _data[i].med_routed_med_id_desc + '</option>')
+                                    }
+                                    routeSelect.prop('disabled', false);
+                                    if (_data.length === 1) {
+                                        routeSelect.val(_data[0].routed_med_id).trigger('change');
+                                    }
+                                }, 'json');
+                            });
+
+                            // on route selection
+                            parentSegment.find('select.prescription-route').off('change');
+                            parentSegment.find('select.prescription-route').on('change', function () {
+
+                                let elem = $(this);
+
+                                // set vue values
+                                self.currentPrescription_DRUG.clinicalDetailJson.routedMedID = elem.val();
+                                self.currentPrescription_DRUG.clinicalDetailJson.route = elem.find('option:selected').text();
+
+                                // clear
+                                let dosageSelect = parentSegment.find('.prescription-dose').empty().prop('disabled', true);
+                                let strengthSelect = parentSegment.find('.prescription-strength').empty().prop('disabled', true);
+
+                                $.get('/fdb-routed-dosages?routed-med-id=' + self.currentPrescription_DRUG.clinicalDetailJson.routedMedID, _data => {
+                                    dosageSelect
+                                        .empty()
+                                        .append('<option value="">-- select --</option>');
+                                    for (let i = 0; i < _data.length; i++) {
+                                        dosageSelect.append('<option value="' + _data[i].routed_dosage_form_med_id + '">' + _data[i].med_routed_df_med_id_desc + '</option>')
+                                    }
+                                    dosageSelect.prop('disabled', false);
+                                    if(_data.length === 1) {
+                                        dosageSelect.val(_data[0].routed_dosage_form_med_id).trigger('change');
+                                    }
+                                }, 'json');
+                            });
+
+                            // on dosage selection
+                            parentSegment.find('select.prescription-dose').off('change');
+                            parentSegment.find('select.prescription-dose').on('change', function () {
+
+                                let elem = $(this);
+
+                                // set vue values
+                                self.currentPrescription_DRUG.clinicalDetailJson.dosageFormMedID = elem.val();
+                                self.currentPrescription_DRUG.clinicalDetailJson.dose = elem.find('option:selected').text();
+
+                                // clear
+                                let strengthSelect = parentSegment.find('.prescription-strength').empty().prop('disabled', true);
+
+                                $.get('/fdb-meds?dosage-form-med-id=' + self.currentPrescription_DRUG.clinicalDetailJson.dosageFormMedID, _data => {
+                                    strengthSelect
+                                        .empty()
+                                        .append('<option value="">-- select --</option>');
+                                    for (let i = 0; i < _data.length; i++) {
+                                        strengthSelect.append('<option data-medid="' + _data[i].medid + '" value="' + _data[i].gcn_seqno + '">' + _data[i].med_medid_desc + '</option>')
+                                    }
+                                    strengthSelect.prop('disabled', false);
+                                    if(_data.length === 1) {
+                                        strengthSelect.val(_data[0].gcn_seqno).trigger('change');
+                                    }
+                                }, 'json');
+                            });
+
+                            // on strength (medid) selection
+                            parentSegment.find('select.prescription-strength').off('change');
+                            parentSegment.find('select.prescription-strength').on('change', function () {
+
+                                let elem = $(this);
+
+                                // set vue values
+                                self.currentPrescription_DRUG.clinicalDetailJson.gcnSeqno = $(this).val();
+                                self.currentPrescription_DRUG.clinicalDetailJson.medId = $(this).find('option:selected').attr('data-medid');
+                                self.currentPrescription_DRUG.clinicalDetailJson.strength = $(this).find('option:selected').text();
+
+                                console.log(self.currentPrescription_DRUG.clinicalDetailJson);
+
+                            });
+                        }
                     },
                     mounted: function() {
                         let self = this;

+ 17 - 8
resources/views/app/patient/segment-templates/intake_allergies/summary.blade.php

@@ -12,15 +12,24 @@ $allergies = Point::getIntakePointsOfCategory($patient, 'ALLERGY', $note);
     <div class="text-secondary">No allergies</div>
 <?php else: ?>
     <?php foreach ($allergies as $allergy): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
-                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                    <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+                </div>
+                <?php if ($allergy->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                <?php elseif ($allergy->added_in_note_id === $note->id): ?>
+                    <span class="ml-2 text-sm text-success">* Added on intake</span>
+                <?php endif; ?>
             </div>
-            <?php if ($allergy->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-            <?php elseif ($allergy->added_in_note_id === $note->id): ?>
-                <span class="ml-2 text-sm text-success">* Added on intake</span>
+            <?php $review = $allergy->childReviewAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+                <div class="pl-3 mt-1">
+                    <div class="text-secondary font-weight-bold">Review</div>
+                    <div>{!! $review->data->value !!}</div>
+                </div>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>

+ 21 - 14
resources/views/app/patient/segment-templates/intake_care_team/summary.blade.php

@@ -12,21 +12,28 @@ $careTeamMembers = Point::getIntakePointsOfCategory($patient, 'CARE_TEAM_MEMBER'
     <div class="text-secondary">No care team members</div>
 <?php else: ?>
     <?php foreach($careTeamMembers as $careTeamMember): ?>
-        <div class="mb-2 d-flex align-items-baseline">
-            <div class="<?= $careTeamMember->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($careTeamMember->data->name) ? @($careTeamMember->data->name) : '-' ?></b>
-                <?= !!@($careTeamMember->data->spacialty) ? '/&nbsp;' . @($careTeamMember->data->spacialty) : '' ?>
-                <?= !!@($careTeamMember->data->organization) ? '/&nbsp;' . @($careTeamMember->data->organization) : '' ?>
-                <br>
-                <?= !!@($careTeamMember->data->phone) ? 'Ph: ' . @($careTeamMember->data->phone) : '' ?>
-                <?= !!@($careTeamMember->data->fax) ? '/&nbsp;Fax: ' . @($careTeamMember->data->fax) : '' ?>
-                <br>
-                <?= !!@($careTeamMember->data->date) ? 'Date: ' . @($careTeamMember->data->date) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                <div class="<?= $careTeamMember->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($careTeamMember->data->name) ? @($careTeamMember->data->name) : '-' ?></b>
+                    <?= !!@($careTeamMember->data->spacialty) ? '/&nbsp;' . @($careTeamMember->data->spacialty) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->organization) ? '/&nbsp;' . @($careTeamMember->data->organization) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->phone) ? 'Ph: ' . @($careTeamMember->data->phone) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->fax) ? '/&nbsp;Fax: ' . @($careTeamMember->data->fax) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->date) ? 'Date: ' . @($careTeamMember->data->date) : '' ?>
+                </div>
+                <?php if ($careTeamMember->is_removed): ?>
+                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                <?php elseif ($careTeamMember->added_in_note_id === $note->id): ?>
+                <span class="ml-2 text-sm text-success">* Added on intake</span>
+                <?php endif; ?>
+            </div>
+            <?php $review = $careTeamMember->childReviewAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Review</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($careTeamMember->is_removed): ?>
-            <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-            <?php elseif ($careTeamMember->added_in_note_id === $note->id): ?>
-            <span class="ml-2 text-sm text-success">* Added on intake</span>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>

+ 104 - 10
resources/views/app/patient/segment-templates/intake_goals/edit.blade.php

@@ -18,25 +18,34 @@ $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
         <table class="table table-sm table-bordered table-striped mb-0 bg-white">
             <thead>
             <tr class="">
+                <th class="border-bottom-0">Category</th>
                 <th class="border-bottom-0">Goal</th>
                 <th class="border-bottom-0">Last Review</th>
                 <th class="border-bottom-0">Last Plan</th>
                 <th class="border-bottom-0">Review Today</th>
             </tr>
             </thead>
+            <?php $previousCategory = null; ?>
             <?php foreach($goals as $goal): ?>
+                <?php if(@($goal->data->category)): ?>
+                <?php $point = $goal; ?>
                 <tr>
+                    <td>
+                        <?php if($previousCategory === $goal->data->category): ?>
+                            <span class="text-secondary"><?= $goal->data->category ?></span>
+                        <?php else: ?>
+                            <span class="font-weight-bold"><?= $goal->data->category ?></span>
+                        <?php endif; ?>
+                    </td>
                     <td>
                         <div class="d-flex align-items-baseline">
                             <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
-                                <b><?= !!@($goal->data->name) ? @($goal->data->name) : '-' ?></b>
-                                <?= !!@($goal->data->description) ? '/&nbsp;' . @($goal->data->description) : '' ?>
+                                <?= !!@($goal->data->goal) ? @($goal->data->goal) : '' ?>
                             </div>
 
                             <!-- common actions -->
                             <div class="ml-auto d-inline-flex align-items-baseline pr-2">
                                 <?php
-                                $point = $goal;
                                 $label = 'Goal';
                                 include resource_path('views/app/patient/segment-templates/_common_actions/remove-undo.php');
                                 ?>
@@ -65,7 +74,6 @@ $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
                         <div class="d-flex align-items-start">
                             <div class="flex-grow-1">
                                 <?php
-                                $point = $goal;
                                 include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
                                 ?>
                             </div>
@@ -81,18 +89,19 @@ $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
                     </td>
                     <td>
                         <?php
-                        $point = $goal;
                         include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
                         ?>
                     </td>
                 </tr>
+                <?php $previousCategory = $goal->data->category; ?>
+                <?php endif; ?>
             <?php endforeach; ?>
         </table>
     </div>
 
     <div visit-moe class="mt-1">
         <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add goal patient is ALREADY having, prior to this visit</a>
-        <form url="/api/visitPoint/addTopLevelOnIntake" class="mcp-theme-1">
+        <form url="/api/visitPoint/addTopLevelOnIntake" class="mcp-theme-1 max-width-500px min-width-500px">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="category" value="GOAL">
             <input type="hidden" name="data">
@@ -100,12 +109,82 @@ $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
             <p class="mb-2"><b>Add Goal (on intake)</b></p>
 
             <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <input type="text" data-name="name" class="form-control form-control-sm">
+                <label class="text-sm text-secondary mb-1">Category</label>
+                <select type="text" data-name="category" class="form-control form-control-sm">
+                    <option value="">-- select --</option>
+                    <option value="NUTRITION">NUTRITION</option>
+                    <option value="ACTIVITY">ACTIVITY</option>
+                    <option value="SLEEP">SLEEP</option>
+                    <option value="SOCIAL CONNECTION">SOCIAL CONNECTION</option>
+                    <option value="STRESS REDUCTION">STRESS REDUCTION</option>
+                    <option value="RISKY SUBSTANCE AVOIDANCE">RISKY SUBSTANCE AVOIDANCE</option>
+                    <option value="OTHER">OTHER</option>
+                </select>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="NUTRITION">
+                <div class="mb-1">Specific - What specific food would you like to add/change?</div>
+                <div class="mb-1">Measurable - How much or how many will you add or change?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you do? (improvement over perfection)</div>
+                <div class="mb-2">Time-Connected - How often or for how long will you make this change?</div>
+                <div class="font-italic"><b>Example:</b> "I will add 1 cup of berries to breakfast and a small apple or orange as an afternoon snack at least five days this week."</div>
             </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="ACTIVITY">
+                <div class="mb-1">Specific - What specific activity would you like to add/change?</div>
+                <div class="mb-1">Measurable - How much activity, how many sessions?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you actually do? (know your limits, start small, build)</div>
+                <div class="mb-2">Time-Connected - How frequent or how long will you do the activity?</div>
+                <div class="font-italic"><b>Example:</b> "I will walk with a friend or family member for at least 20 minutes after dinner, every weekday for the next two months."</div>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="SLEEP">
+                <div class="mb-1">Specific - What are you going to do to improve your sleep quality/quantity?</div>
+                <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                <div class="font-italic"><b>Example:</b> "I will begin a new bedtime routine of shutting off the television and instead, read a book for at least 30 minutes before bed, four nights this week."</div>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="SOCIAL CONNECTION">
+                <div class="mb-1">Specific - What are you going to do to improve feelings of connectedness?</div>
+                <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                <div class="font-italic"><b>Example:</b> "I will increase my feeling of social connectedness by joining a group fitness class that meets for an hour, three nights of the week."</div>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="STRESS REDUCTION">
+                <div class="mb-1">Specific - What are you going to do to manage your stress?</div>
+                <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                <div class="font-italic"><b>Example:</b> "I will write about what I am thankful for at least 10 minutes three times per week."</div>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="RISKY SUBSTANCE AVOIDANCE">
+                <div class="mb-1">Specific - What are you going to do to decrease your substance use?</div>
+                <div class="mb-1">Measurable - How much will you reduce it by?</div>
+                <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                <div class="font-italic"><b>Example:</b> "I will swap my morning cigarette with chewing gum at least 5 days this week for the next four weeks. I will ask my partner to help keep me on track and use the free texting service for more support."</div>
+            </div>
+
+            <div class="bg-light border mb-2 p-2 help-text d-none" data-category="OTHER">
+                <div class="">Ensure that the goal is Specific, Measurable, Attainable, Realistic and Time-Connected.</div>
+            </div>
+
             <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Description</label>
-                <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
+                <label class="text-sm text-secondary mb-1">Goal</label>
+                <div note-rte
+                     class="form-group mb-2 border-left border-right rte-holder"
+                     data-field-name="goal"></div>
             </div>
 
             <div>
@@ -116,3 +195,18 @@ $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
     </div>
 </div>
 
+<script>
+    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
+        // any JS can come here
+        // will be run on page-load as well as whenever this segment is refreshed
+
+        let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+        parentSegment.find('select[data-name="category"]')
+            .off('change')
+            .on('change', function() {
+                parentSegment.find('.help-text').addClass('d-none');
+                parentSegment.find('.help-text[data-category="' + this.value + '"]').removeClass('d-none');
+            });
+
+    };
+</script>

+ 32 - 13
resources/views/app/patient/segment-templates/intake_goals/summary.blade.php

@@ -6,22 +6,41 @@ use App\Models\Point;
 
 $goals = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
 
+$grouped = [];
+foreach($goals as $goal) {
+    if(!@($goal->data->category)) continue;
+    if(!isset($grouped[$goal->data->category])) {
+        $grouped[$goal->data->category] = [];
+    }
+    $grouped[$goal->data->category][] = $goal;
+}
 ?>
 
-<?php if (!count($goals)): ?>
-    <div class="text-secondary">No care team members</div>
+<?php if (!count($grouped)): ?>
+    <div class="text-secondary">No goals</div>
 <?php else: ?>
-    <?php foreach ($goals as $goal): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($goal->data->name) ? @($goal->data->name) : '-' ?></b>
-                <?= !!@($goal->data->description) ? '/&nbsp;' . @($goal->data->description) : '' ?>
+    <?php foreach($grouped as $k => $group): ?>
+        <b><?= $k ?></b>
+        <?php foreach($group as $goal): ?>
+            <div class="pl-2 mb-2">
+                <div class="d-flex align-items-baseline">
+                    <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
+                        <?= !!@($goal->data->goal) ? @($goal->data->goal) : '' ?>
+                    </div>
+                    <?php if ($goal->is_removed): ?>
+                        <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                    <?php elseif ($goal->added_in_note_id === $note->id): ?>
+                        <span class="ml-2 text-sm text-success">* Added on intake</span>
+                    <?php endif; ?>
+                </div>
+                <?php $review = $goal->childReviewAddedInNote($note); ?>
+                <?php if(!!$review): ?>
+                <div class="pl-3 mt-1">
+                    <div class="text-secondary font-weight-bold">Review</div>
+                    <div>{!! $review->data->value !!}</div>
+                </div>
+                <?php endif; ?>
             </div>
-            <?php if ($goal->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-            <?php elseif ($goal->added_in_note_id === $note->id): ?>
-                <span class="ml-2 text-sm text-success">* Added on intake</span>
-            <?php endif; ?>
-        </div>
+        <?php endforeach; ?>
     <?php endforeach; ?>
 <?php endif; ?>

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

@@ -111,7 +111,7 @@ $interventions = Point::getIntakePointsOfCategory($patient, 'INTERVENTION', $not
             <p class="mb-2"><b>Add Intervention (on intake)</b></p>
 
             <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
+                <label class="text-sm text-secondary mb-1">Category</label>
                 <select type="text" data-name="category" class="form-control form-control-sm">
                     <option value="">-- select --</option>
                     <option value="Self-Monitoring">Self-Monitoring</option>

+ 19 - 10
resources/views/app/patient/segment-templates/intake_interventions/summary.blade.php

@@ -15,22 +15,31 @@ foreach($interventions as $intervention) {
 }
 ?>
 
-<?php if (!count($interventions)): ?>
+<?php if (!count($grouped)): ?>
     <div class="text-secondary">No interventions</div>
 <?php else: ?>
     <?php foreach($grouped as $k => $group): ?>
         <b><?= $k ?></b>
         <?php foreach($group as $intervention): ?>
-            <div class="mb-2 d-flex align-items-baseline pl-3">
-                <div class="<?= $intervention->is_removed ? 'strike-through' : '' ?>">
-                    <?= !!@($intervention->data->intervention) ? @($intervention->data->intervention) : '' ?>
-                    <br>
-                    <span class="text-secondary"><?= !!@($intervention->data->description) ? @($intervention->data->description) : '' ?></span>
+            <div class="mb-2 pl-3">
+                <div class="d-flex align-items-baseline">
+                    <div class="<?= $intervention->is_removed ? 'strike-through' : '' ?>">
+                        <?= !!@($intervention->data->intervention) ? @($intervention->data->intervention) : '' ?>
+                        <br>
+                        <span class="text-secondary"><?= !!@($intervention->data->description) ? @($intervention->data->description) : '' ?></span>
+                    </div>
+                    <?php if ($intervention->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                    <?php elseif ($intervention->added_in_note_id === $note->id): ?>
+                    <span class="ml-2 text-sm text-success">* Added on intake</span>
+                    <?php endif; ?>
+                </div>
+                <?php $review = $intervention->childReviewAddedInNote($note); ?>
+                <?php if(!!$review): ?>
+                <div class="pl-3 mt-1">
+                    <div class="text-secondary font-weight-bold">Review</div>
+                    <div>{!! $review->data->value !!}</div>
                 </div>
-                <?php if ($intervention->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-                <?php elseif ($intervention->added_in_note_id === $note->id): ?>
-                <span class="ml-2 text-sm text-success">* Added on intake</span>
                 <?php endif; ?>
             </div>
         <?php endforeach; ?>

+ 10 - 0
resources/views/app/patient/segment-templates/intake_medications/edit.blade.php

@@ -33,6 +33,7 @@ $medications = Point::getIntakePointsOfCategory($patient, 'MEDICATION', $note);
                                 <?= !!@($medication->data->route) ? '/&nbsp;' . @($medication->data->route) : '' ?>
                                 <?= !!@($medication->data->dose) ? '/&nbsp;' . @($medication->data->dose) : '' ?>
                                 <?= !!@($medication->data->strength) ? '/&nbsp;' . @($medication->data->strength) : '' ?>
+                                <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
                             </div>
 
                             <!-- common actions -->
@@ -136,6 +137,15 @@ $medications = Point::getIntakePointsOfCategory($patient, 'MEDICATION', $note);
                         disabled>
                 </select>
             </div>
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Frequency</label>
+                <input type="text" class="form-control form-control-sm" data-name="frequency"
+                       data-option-list="frequency-options" autocomplete="off">
+                <div id="frequency-options" class="data-option-list">
+                    <div>Once a day</div>
+                    <div>Twice a day</div>
+                </div>
+            </div>
             <div class="mb-2">
                 <label class="text-sm text-secondary mb-1">Description</label>
                 <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>

+ 18 - 10
resources/views/app/patient/segment-templates/intake_medications/summary.blade.php

@@ -12,17 +12,25 @@ $medications = Point::getIntakePointsOfCategory($patient, 'MEDICATION', $note);
     <div class="text-secondary">No medications</div>
 <?php else: ?>
     <?php foreach ($medications as $medication): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $medication->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
-                <?= !!@($medication->data->dose) ? '/&nbsp;' . @($medication->data->dose) : '' ?>
-                <?= !!@($medication->data->route) ? '/&nbsp;' . @($medication->data->route) : '' ?>
-                <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                <div class="<?= $medication->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
+                    <?= !!@($medication->data->strength) ? '/&nbsp;' . @($medication->data->strength) : '' ?>
+                    <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
+                </div>
+                <?php if ($medication->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                <?php elseif ($medication->added_in_note_id === $note->id): ?>
+                    <span class="ml-2 text-sm text-success">* Added on intake</span>
+                <?php endif; ?>
+            </div>
+            <?php $review = $medication->childReviewAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Review</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($medication->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-            <?php elseif ($medication->added_in_note_id === $note->id): ?>
-                <span class="ml-2 text-sm text-success">* Added on intake</span>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>

+ 21 - 9
resources/views/app/patient/segment-templates/intake_problems/summary.blade.php

@@ -12,16 +12,28 @@ $problems = Point::getIntakePointsOfCategory($patient, 'PROBLEM', $note);
     <div class="text-secondary">No problems</div>
 <?php else: ?>
     <?php foreach ($problems as $problem): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $problem->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
-                <?= !!@($problem->data->icd) ? '/&nbsp;' . @($problem->data->icd) : '' ?>
-                <?= !!@($problem->data->description) ? '/&nbsp;' . @($problem->data->description) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                <div class="<?= $problem->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
+                    <?= !!@($problem->data->icd) ? '/&nbsp;' . @($problem->data->icd) : '' ?>
+                    <?= !!@($problem->data->description) ? '/&nbsp;' . @($problem->data->description) : '' ?>
+                </div>
+                <?php if ($problem->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                <?php elseif ($problem->added_in_note_id === $note->id): ?>
+                    <span class="ml-2 text-sm text-success">* Added on intake</span>
+                <?php endif; ?>
+            </div>
+            <?php $review = $problem->childReviewAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Review</div>
+                <?php
+                $review = $review->data;
+                include resource_path('views/app/patient/segment-templates/_review/problem/view.php');
+                ?>
             </div>
-            <?php if ($problem->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed on intake</span>
-            <?php elseif ($problem->added_in_note_id === $note->id): ?>
-                <span class="ml-2 text-sm text-success">* Added on intake</span>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>

+ 18 - 12
resources/views/app/patient/segment-templates/medrisk_vigilence/summary.blade.php

@@ -22,54 +22,52 @@ $ddi = drug_drug_interaction_info($drugs);
 // dam
 $dam = drug_allergy_info($drugs, $allergies);
 
+$hasMRVData = false;
+
 ?>
 
 @if(!!$dptInfo)
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Duplicate Therapy Notes</p>
         <div class="mt-3 ml-3">
             {!! $dptInfo !!}
         </div>
     </div>
-
 @endif
 
 @if(!!$coadministration)
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Coadministration Notes</p>
         <div class="mt-3 ml-3">
             {!! $coadministration !!}
         </div>
     </div>
-
 @endif
 
 @if(!!$dam)
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Drug Allergy Notes</p>
         <div class="mt-3 ml-3">
             {!! $dam !!}
         </div>
     </div>
-
 @endif
 
 @if(!!$ddi)
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Drug-Drug Interaction Notes</p>
         <div class="mt-3 ml-3">
             {!! $ddi !!}
         </div>
     </div>
-
 @endif
 
 @if(count($sideeffects))
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Side Effects</p>
         @foreach($sideeffects as $drug => $sideeffect)
@@ -83,11 +81,10 @@ $dam = drug_allergy_info($drugs, $allergies);
             </div>
         @endforeach
     </div>
-
 @endif
 
 @if(count($contraindications))
-
+    <?php $hasMRVData = true; ?>
     <div class="m-neg-3 p-3 mb-3 mt-2 border bg-white mr-0">
         <p class="font-weight-bold m-0 font-size-14 text-info">Contraindications</p>
         @foreach($contraindications as $drug => $contraindication)
@@ -101,6 +98,15 @@ $dam = drug_allergy_info($drugs, $allergies);
             </div>
         @endforeach
     </div>
-
 @endif
 
+<script>
+    (function() {
+        window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
+            @if(!!$hasMRVData)
+            toastr.info('Medrisk Vigilance Updated', null, { timeOut: 10000 });
+            @endif
+        };
+    }).call(window);
+</script>
+

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

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

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

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

+ 82 - 31
resources/views/app/patient/segment-templates/plan_allergies/edit.blade.php

@@ -12,13 +12,23 @@ use \App\Models\Segment;
 $allergies = Point::getPlanPointsOfCategory($patient, 'ALLERGY', $note);
 $intakeOrVisit = 'PLAN';
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'ALLERGIES_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
 ?>
 <div>
 
-    <div class="d-flex mb-2">
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
+                <th class="border-bottom-0 width-100px text-info">Relevant to<br>this visit</th>
                 <th class="border-bottom-0">Allergy</th>
                 <th class="border-bottom-0">Last Review</th>
                 <th class="border-bottom-0">Last Plan</th>
@@ -29,6 +39,13 @@ $intakeOrVisit = 'PLAN';
                 <?php $point = $allergy; ?>
                 <tr>
                     <td>
+                    <div class="d-flex align-items-center">
+                        <input type="checkbox" class="m-0 chk-relevance"
+                               data-uid="{{$allergy->uid}}" {{in_array($allergy->uid, $relevance) ? 'checked' : ''}}>
+                        <span>&nbsp;</span>
+                    </div>
+                </td>
+                <td>
                         <div class="d-flex align-items-baseline">
                             <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
                                 <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
@@ -87,38 +104,48 @@ $intakeOrVisit = 'PLAN';
                 </tr>
             <?php endforeach; ?>
         </table>
-    </div>
 
-    <div visit-moe class="mt-1">
-        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new allergy, added during this visit</a>
-        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="ALLERGY">
-            <input type="hidden" name="data">
-
-            <p class="mb-2"><b>Add Allergy (plan)</b></p>
-
-            <input type="hidden" data-name="damConceptId">
-            <input type="hidden" data-name="damConceptIdType">
-
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <input type="text" data-name="name" class="form-control form-control-sm"
-                       stag-suggest
-                       stag-suggest-ep="/fdb-allergy-suggest/json">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Description</label>
-                <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
-            </div>
-
-            <div>
-                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
+    <div class="d-flex align-items-center">
+        <div visit-moe>
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="ALLERGIES_RELEVANT_TO_NOTE">
+                <input type="hidden" name="data">
+                <button submit class="btn btn-sm btn-info font-weight-bold">Save Relevance</button>
+            </form>
+        </div>
+        <div visit-moe large class="ml-auto mt-1 max-width-500px">
+            <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new allergy, added during this visit</a>
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1" right>
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="ALLERGY">
+                <input type="hidden" name="data">
+
+                <p class="mb-2"><b>Add Allergy (plan)</b></p>
+
+                <input type="hidden" data-name="damConceptId">
+                <input type="hidden" data-name="damConceptIdType">
+
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Name</label>
+                    <input type="text" data-name="name" class="form-control form-control-sm"
+                           stag-suggest
+                           stag-suggest-ep="/fdb-allergy-suggest/json">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Description</label>
+                    <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
+                </div>
+
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
     </div>
 </div>
+
 <script>
     window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
         // any JS can come here
@@ -132,5 +159,29 @@ $intakeOrVisit = 'PLAN';
                 $('input[data-name="damConceptIdType"]').val(_data.dam_concept_id_typ);
             });
 
+        // relevance
+        $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
+        $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
+            if(!!uids) {
+                uids = JSON.parse(uids);
+            }
+            else {
+                uids = [];
+            }
+            let uid = $(this).attr('data-uid'), found = uids.indexOf(uid) > -1;
+            if(this.checked === found) {
+                return false;
+            }
+            if(this.checked) {
+                uids.push(uid);
+            }
+            else {
+                uids = uids.filter(_x => _x !== uid);
+            }
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            return false;
+        });
+
     };
 </script>

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

@@ -6,27 +6,60 @@ use App\Models\Point;
 
 $allergies = Point::getPlanPointsOfCategory($patient, 'ALLERGY', $note);
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'ALLERGIES_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')
+    ->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
+$numRelevant = 0;
 ?>
 
 <?php if (!count($allergies)): ?>
     <div class="text-secondary">No allergies</div>
 <?php else: ?>
     <?php foreach ($allergies as $allergy): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
-                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                @if(in_array($allergy->uid, $relevance))
+                    <span class="text-info mr-1 text-sm">
+                        <i class="fa fa-star text-sm"></i>
+                    </span>
+                    <?php $numRelevant++; ?>
+                @endif
+                <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                    <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+                </div>
+                <?php if ($allergy->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                <?php elseif ($allergy->added_in_note_id === $note->id): ?>
+                    <?php if ($allergy->addition_reason_category === 'DURING_VISIT'): ?>
+                        <span class="ml-2 text-sm text-success">* Added during visit</span>
+                    <?php else: ?>
+                        <span class="ml-2 text-sm text-info">* Added on intake</span>
+                    <?php endif;?>
+                <?php endif; ?>
+            </div>
+            <?php $review = $allergy->childPlanAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Plan</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($allergy->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-            <?php elseif ($allergy->added_in_note_id === $note->id): ?>
-                <?php if ($allergy->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                <?php else: ?>
-                    <span class="ml-2 text-sm text-info">* Added on intake</span>
-                <?php endif;?>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>
+    @if($numRelevant)
+        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
+            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
+            <span class="text-sm">Allergies relevant to this note</span>
+        </div>
+    @endif
 <?php endif; ?>
 

+ 102 - 43
resources/views/app/patient/segment-templates/plan_care_team/edit.blade.php

@@ -12,13 +12,23 @@ use \App\Models\Segment;
 $careTeamMembers = Point::getPlanPointsOfCategory($patient, 'CARE_TEAM_MEMBER', $note);
 $intakeOrVisit = 'PLAN';
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'CARE_TEAM_MEMBERS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
 ?>
 <div>
 
-    <div class="d-flex mb-2">
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
+                <th class="border-bottom-0 width-100px text-info">Relevant to<br>this visit</th>
                 <th class="border-bottom-0">Care Team Member</th>
                 <th class="border-bottom-0">Last Review</th>
                 <th class="border-bottom-0">Last Plan</th>
@@ -28,6 +38,13 @@ $intakeOrVisit = 'PLAN';
             <?php foreach($careTeamMembers as $careTeamMember): ?>
                 <?php $point = $careTeamMember; ?>
                 <tr>
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <input type="checkbox" class="m-0 chk-relevance"
+                                   data-uid="{{$careTeamMember->uid}}" {{in_array($careTeamMember->uid, $relevance) ? 'checked' : ''}}>
+                            <span>&nbsp;</span>
+                        </div>
+                    </td>
                     <td>
                         <div class="d-flex align-items-baseline">
                             <div class="<?= $careTeamMember->is_removed ? 'strike-through' : '' ?>">
@@ -93,51 +110,93 @@ $intakeOrVisit = 'PLAN';
                 </tr>
             <?php endforeach; ?>
         </table>
-    </div>
 
-    <div visit-moe class="mt-1">
-        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new care team member, added during this visit</a>
-        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="CARE_TEAM_MEMBER">
-            <input type="hidden" name="data">
+    <div class="d-flex align-items-center">
+        <div visit-moe>
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="CARE_TEAM_MEMBERS_RELEVANT_TO_NOTE">
+                <input type="hidden" name="data">
+                <button submit class="btn btn-sm btn-info font-weight-bold">Save Relevance</button>
+            </form>
+        </div>
+        <div visit-moe large class="ml-auto mt-1 max-width-500px">
+            <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new care team member, added during this visit</a>
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1" right>
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="CARE_TEAM_MEMBER">
+                <input type="hidden" name="data">
 
-            <p class="mb-2"><b>Add Care Team Member (on intake)</b></p>
+                <p class="mb-2"><b>Add Care Team Member (on intake)</b></p>
 
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <input type="text" data-name="name" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Specialty</label>
-                <input type="text" data-name="specialty" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Organization</label>
-                <input type="text" data-name="organization" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Phone</label>
-                <input type="text" data-name="phone" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Fax</label>
-                <input type="text" data-name="fax" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Date</label>
-                <input type="date" data-name="date" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Memo</label>
-                <textarea type="text" data-name="memo" class="form-control form-control-sm"></textarea>
-            </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Name</label>
+                    <input type="text" data-name="name" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Specialty</label>
+                    <input type="text" data-name="specialty" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Organization</label>
+                    <input type="text" data-name="organization" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Phone</label>
+                    <input type="text" data-name="phone" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Fax</label>
+                    <input type="text" data-name="fax" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Date</label>
+                    <input type="date" data-name="date" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Memo</label>
+                    <textarea type="text" data-name="memo" class="form-control form-control-sm"></textarea>
+                </div>
 
-            <div>
-                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
     </div>
 </div>
 
+<script>
+    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function () {
+        // any JS can come here
+        // will be run on page-load as well as whenever this segment is refreshed
+
+        let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+
+        // relevance
+        $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
+        $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
+            if(!!uids) {
+                uids = JSON.parse(uids);
+            }
+            else {
+                uids = [];
+            }
+            let uid = $(this).attr('data-uid'), found = uids.indexOf(uid) > -1;
+            if(this.checked === found) {
+                return false;
+            }
+            if(this.checked) {
+                uids.push(uid);
+            }
+            else {
+                uids = uids.filter(_x => _x !== uid);
+            }
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            return false;
+        });
+
+    };
+</script>

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

@@ -6,32 +6,64 @@ use App\Models\Point;
 
 $careTeamMembers = Point::getPlanPointsOfCategory($patient, 'CARE_TEAM_MEMBER', $note);
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'CARE_TEAM_MEMBERS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')
+    ->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
+$numRelevant = 0;
 ?>
 
 <?php if (!count($careTeamMembers)): ?>
     <div class="text-secondary">No care team members</div>
 <?php else: ?>
     <?php foreach($careTeamMembers as $careTeamMember): ?>
-        <div class="mb-2 d-flex align-items-baseline">
-            <div class="<?= $careTeamMember->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($careTeamMember->data->name) ? @($careTeamMember->data->name) : '-' ?></b>
-                <?= !!@($careTeamMember->data->spacialty) ? '/&nbsp;' . @($careTeamMember->data->spacialty) : '' ?>
-                <?= !!@($careTeamMember->data->organization) ? '/&nbsp;' . @($careTeamMember->data->organization) : '' ?>
-                <br>
-                <?= !!@($careTeamMember->data->phone) ? 'Ph: ' . @($careTeamMember->data->phone) : '' ?>
-                <?= !!@($careTeamMember->data->fax) ? '/&nbsp;Fax: ' . @($careTeamMember->data->fax) : '' ?>
-                <br>
-                <?= !!@($careTeamMember->data->date) ? 'Date: ' . @($careTeamMember->data->date) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                @if(in_array($careTeamMember->uid, $relevance))
+                    <span class="text-info mr-1 text-sm">
+                        <i class="fa fa-star text-sm"></i>
+                    </span>
+                    <?php $numRelevant++; ?>
+                @endif
+                <div class="<?= $careTeamMember->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($careTeamMember->data->name) ? @($careTeamMember->data->name) : '-' ?></b>
+                    <?= !!@($careTeamMember->data->spacialty) ? '/&nbsp;' . @($careTeamMember->data->spacialty) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->organization) ? '/&nbsp;' . @($careTeamMember->data->organization) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->phone) ? 'Ph: ' . @($careTeamMember->data->phone) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->fax) ? '/&nbsp;Fax: ' . @($careTeamMember->data->fax) . '<br>' : '' ?>
+                    <?= !!@($careTeamMember->data->date) ? 'Date: ' . @($careTeamMember->data->date) : '' ?>
+                </div>
+                <?php if ($careTeamMember->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                <?php elseif ($careTeamMember->added_in_note_id === $note->id): ?>
+                    <?php if ($careTeamMember->addition_reason_category === 'DURING_VISIT'): ?>
+                        <span class="ml-2 text-sm text-success">* Added during visit</span>
+                    <?php else: ?>
+                        <span class="ml-2 text-sm text-info">* Added on intake</span>
+                    <?php endif;?>
+                <?php endif; ?>
+            </div>
+            <?php $review = $careTeamMember->childPlanAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Plan</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($careTeamMember->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-            <?php elseif ($careTeamMember->added_in_note_id === $note->id): ?>
-                <?php if ($careTeamMember->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                <?php else: ?>
-                    <span class="ml-2 text-sm text-info">* Added on intake</span>
-                <?php endif;?>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>
-<?php endif; ?>
+    @if($numRelevant)
+        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
+            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
+            <span class="text-sm">Care team members relevant to this note</span>
+        </div>
+    @endif
+<?php endif; ?>
+

+ 177 - 28
resources/views/app/patient/segment-templates/plan_goals/edit.blade.php

@@ -11,27 +11,54 @@ use \App\Models\Segment;
 
 $goals = Point::getPlanPointsOfCategory($patient, 'GOAL', $note);
 $intakeOrVisit = 'PLAN';
+
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'GOALS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
 ?>
 <div>
 
-    <div class="d-flex mb-2">
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
+                <th class="border-bottom-0 width-100px text-info">Relevant to<br>this visit</th>
+                <th class="border-bottom-0">Category</th>
                 <th class="border-bottom-0">Goal</th>
                 <th class="border-bottom-0">Last Review</th>
                 <th class="border-bottom-0">Last Plan</th>
                 <th class="border-bottom-0">Plan Today</th>
             </tr>
             </thead>
+            <?php $previousCategory = null; ?>
             <?php foreach($goals as $goal): ?>
+                <?php if(@($goal->data->category)): ?>
                 <?php $point = $goal; ?>
                 <tr>
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <input type="checkbox" class="m-0 chk-relevance"
+                                   data-uid="{{$goal->uid}}" {{in_array($goal->uid, $relevance) ? 'checked' : ''}}>
+                            <span>&nbsp;</span>
+                        </div>
+                    </td>
+                    <td>
+                        <?php if($previousCategory === $goal->data->category): ?>
+                        <span class="text-secondary"><?= $goal->data->category ?></span>
+                        <?php else: ?>
+                        <span class="font-weight-bold"><?= $goal->data->category ?></span>
+                        <?php endif; ?>
+                    </td>
                     <td>
                         <div class="d-flex align-items-baseline">
                             <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
-                                <b><?= !!@($goal->data->name) ? @($goal->data->name) : '-' ?></b>
-                                <?= !!@($goal->data->description) ? '/&nbsp;' . @($goal->data->description) : '' ?>
+                                <?= !!@($goal->data->goal) ? @($goal->data->goal) : '' ?>
                             </div>
 
                             <!-- common actions -->
@@ -84,33 +111,155 @@ $intakeOrVisit = 'PLAN';
                         ?>
                     </td>
                 </tr>
+                <?php $previousCategory = $goal->data->category; ?>
+                <?php endif; ?>
             <?php endforeach; ?>
         </table>
-    </div>
 
-    <div visit-moe class="mt-1">
-        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new goal, added during this visit</a>
-        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="GOAL">
-            <input type="hidden" name="data">
-
-            <p class="mb-2"><b>Add Goal (plan)</b></p>
-
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <input type="text" data-name="name" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Description</label>
-                <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
-            </div>
-
-            <div>
-                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
+    <div class="d-flex align-items-center">
+        <div visit-moe>
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="GOALS_RELEVANT_TO_NOTE">
+                <input type="hidden" name="data">
+                <button submit class="btn btn-sm btn-info font-weight-bold">Save Relevance</button>
+            </form>
+        </div>
+        <div visit-moe large class="ml-auto mt-1 max-width-500px">
+            <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new goal, added during this visit</a>
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1 max-width-500px min-width-500px" right>
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="GOAL">
+                <input type="hidden" name="data">
+
+                <p class="mb-2"><b>Add Goal (plan)</b></p>
+
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Category</label>
+                    <select type="text" data-name="category" class="form-control form-control-sm">
+                        <option value="">-- select --</option>
+                        <option value="NUTRITION">NUTRITION</option>
+                        <option value="ACTIVITY">ACTIVITY</option>
+                        <option value="SLEEP">SLEEP</option>
+                        <option value="SOCIAL CONNECTION">SOCIAL CONNECTION</option>
+                        <option value="STRESS REDUCTION">STRESS REDUCTION</option>
+                        <option value="RISKY SUBSTANCE AVOIDANCE">RISKY SUBSTANCE AVOIDANCE</option>
+                        <option value="OTHER">OTHER</option>
+                    </select>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="NUTRITION">
+                    <div class="mb-1">Specific - What specific food would you like to add/change?</div>
+                    <div class="mb-1">Measurable - How much or how many will you add or change?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you do? (improvement over perfection)</div>
+                    <div class="mb-2">Time-Connected - How often or for how long will you make this change?</div>
+                    <div class="font-italic"><b>Example:</b> "I will add 1 cup of berries to breakfast and a small apple or orange as an afternoon snack at least five days this week."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="ACTIVITY">
+                    <div class="mb-1">Specific - What specific activity would you like to add/change?</div>
+                    <div class="mb-1">Measurable - How much activity, how many sessions?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you actually do? (know your limits, start small, build)</div>
+                    <div class="mb-2">Time-Connected - How frequent or how long will you do the activity?</div>
+                    <div class="font-italic"><b>Example:</b> "I will walk with a friend or family member for at least 20 minutes after dinner, every weekday for the next two months."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="SLEEP">
+                    <div class="mb-1">Specific - What are you going to do to improve your sleep quality/quantity?</div>
+                    <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                    <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                    <div class="font-italic"><b>Example:</b> "I will begin a new bedtime routine of shutting off the television and instead, read a book for at least 30 minutes before bed, four nights this week."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="SOCIAL CONNECTION">
+                    <div class="mb-1">Specific - What are you going to do to improve feelings of connectedness?</div>
+                    <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                    <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                    <div class="font-italic"><b>Example:</b> "I will increase my feeling of social connectedness by joining a group fitness class that meets for an hour, three nights of the week."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="STRESS REDUCTION">
+                    <div class="mb-1">Specific - What are you going to do to manage your stress?</div>
+                    <div class="mb-1">Measurable - How much time, how many sessions?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                    <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                    <div class="font-italic"><b>Example:</b> "I will write about what I am thankful for at least 10 minutes three times per week."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="RISKY SUBSTANCE AVOIDANCE">
+                    <div class="mb-1">Specific - What are you going to do to decrease your substance use?</div>
+                    <div class="mb-1">Measurable - How much will you reduce it by?</div>
+                    <div class="mb-1">Attainable - Do you have what it takes to follow through?</div>
+                    <div class="mb-1">Realistic - What can you actually do? (improvement over perfection)</div>
+                    <div class="mb-2">Time-Connected - How frequent? How long will you commit?</div>
+                    <div class="font-italic"><b>Example:</b> "I will swap my morning cigarette with chewing gum at least 5 days this week for the next four weeks. I will ask my partner to help keep me on track and use the free texting service for more support."</div>
+                </div>
+
+                <div class="bg-light border mb-2 p-2 help-text d-none" data-category="OTHER">
+                    <div class="">Ensure that the goal is Specific, Measurable, Attainable, Realistic and Time-Connected.</div>
+                </div>
+
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Goal</label>
+                    <div note-rte
+                         class="form-group mb-2 border-left border-right rte-holder"
+                         data-field-name="goal"></div>
+                </div>
+
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
     </div>
 </div>
 
+<script>
+    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function () {
+        // any JS can come here
+        // will be run on page-load as well as whenever this segment is refreshed
+
+        let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+
+        // relevance
+        $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
+        $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
+            if(!!uids) {
+                uids = JSON.parse(uids);
+            }
+            else {
+                uids = [];
+            }
+            let uid = $(this).attr('data-uid'), found = uids.indexOf(uid) > -1;
+            if(this.checked === found) {
+                return false;
+            }
+            if(this.checked) {
+                uids.push(uid);
+            }
+            else {
+                uids = uids.filter(_x => _x !== uid);
+            }
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            return false;
+        });
+
+        parentSegment.find('select[data-name="category"]')
+            .off('change')
+            .on('change', function() {
+                parentSegment.find('.help-text').addClass('d-none');
+                parentSegment.find('.help-text[data-category="' + this.value + '"]').removeClass('d-none');
+            });
+
+        parentSegment.find('.chk-relevance').trigger('change');
+    };
+</script>

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

@@ -6,26 +6,71 @@ use App\Models\Point;
 
 $goals = Point::getPlanPointsOfCategory($patient, 'GOAL', $note);
 
+$grouped = [];
+foreach($goals as $goal) {
+    if(!@($goal->data->category)) continue;
+    if(!isset($grouped[$goal->data->category])) {
+        $grouped[$goal->data->category] = [];
+    }
+    $grouped[$goal->data->category][] = $goal;
+}
+
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'GOALS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')
+    ->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
+$numRelevant = 0;
 ?>
 
-<?php if (!count($goals)): ?>
+<?php if (!count($grouped)): ?>
     <div class="text-secondary">No goals</div>
 <?php else: ?>
-    <?php foreach ($goals as $goal): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($goal->data->name) ? @($goal->data->name) : '-' ?></b>
-                <?= !!@($goal->data->description) ? '/&nbsp;' . @($goal->data->description) : '' ?>
+    <?php foreach($grouped as $k => $group): ?>
+        <b><?= $k ?></b>
+        <?php foreach ($group as $goal): ?>
+            <div class="pl-2 mb-2">
+                <div class="d-flex align-items-baseline">
+                    @if(in_array($goal->uid, $relevance))
+                        <span class="text-info mr-1 text-sm">
+                            <i class="fa fa-star text-sm"></i>
+                        </span>
+                        <?php $numRelevant++; ?>
+                    @endif
+                    <div class="<?= $goal->is_removed ? 'strike-through' : '' ?>">
+                        <?= !!@($goal->data->goal) ? @($goal->data->goal) : '' ?>
+                    </div>
+                    <?php if ($goal->is_removed): ?>
+                        <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                    <?php elseif ($goal->added_in_note_id === $note->id): ?>
+                        <?php if ($goal->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="ml-2 text-sm text-success">* Added during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+                <?php $review = $goal->childPlanAddedInNote($note); ?>
+                <?php if(!!$review): ?>
+                <div class="pl-3 mt-1">
+                    <div class="text-secondary font-weight-bold">Plan</div>
+                    <div>{!! $review->data->value !!}</div>
+                </div>
+                <?php endif; ?>
             </div>
-            <?php if ($goal->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-            <?php elseif ($goal->added_in_note_id === $note->id): ?>
-                <?php if ($goal->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                <?php else: ?>
-                    <span class="ml-2 text-sm text-info">* Added on intake</span>
-                <?php endif;?>
-            <?php endif; ?>
-        </div>
+        <?php endforeach; ?>
     <?php endforeach; ?>
-<?php endif; ?>
+    @if($numRelevant)
+        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
+            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
+            <span class="text-sm">Goals relevant to this note</span>
+        </div>
+    @endif
+<?php endif; ?>
+

+ 99 - 40
resources/views/app/patient/segment-templates/plan_interventions/edit.blade.php

@@ -12,13 +12,23 @@ use \App\Models\Segment;
 $interventions = Point::getPlanPointsOfCategory($patient, 'INTERVENTION', $note);
 $intakeOrVisit = 'PLAN';
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'INTERVENTIONS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
 ?>
 <div>
 
-    <div class="d-flex mb-2">
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
+                <th class="border-bottom-0 width-100px text-info">Relevant to<br>this visit</th>
                 <th class="border-bottom-0">Category</th>
                 <th class="border-bottom-0">Intervention</th>
                 <th class="border-bottom-0">Last Review</th>
@@ -30,6 +40,13 @@ $intakeOrVisit = 'PLAN';
             <?php foreach($interventions as $intervention): ?>
                 <?php $point = $intervention; ?>
                 <tr>
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <input type="checkbox" class="m-0 chk-relevance"
+                                   data-uid="{{$intervention->uid}}" {{in_array($intervention->uid, $relevance) ? 'checked' : ''}}>
+                            <span>&nbsp;</span>
+                        </div>
+                    </td>
                     <td>
                         <?php if($previousCategory === $intervention->data->category): ?>
                             <span class="text-secondary"><?= $intervention->data->category ?></span>
@@ -98,48 +115,90 @@ $intakeOrVisit = 'PLAN';
                 <?php $previousCategory = $intervention->data->category; ?>
             <?php endforeach; ?>
         </table>
-    </div>
 
-    <div visit-moe class="mt-1">
-        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new intervention, added during this visit</a>
-        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="INTERVENTION">
-            <input type="hidden" name="data">
+    <div class="d-flex align-items-center">
+        <div visit-moe>
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="INTERVENTIONS_RELEVANT_TO_NOTE">
+                <input type="hidden" name="data">
+                <button submit class="btn btn-sm btn-info font-weight-bold">Save Relevance</button>
+            </form>
+        </div>
+        <div visit-moe large class="ml-auto mt-1 max-width-500px">
+            <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new intervention, added during this visit</a>
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1" right>
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="INTERVENTION">
+                <input type="hidden" name="data">
 
-            <p class="mb-2"><b>Add Intervention (on intake)</b></p>
+                <p class="mb-2"><b>Add Intervention (on intake)</b></p>
 
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <select type="text" data-name="category" class="form-control form-control-sm">
-                    <option value="">-- select --</option>
-                    <option value="Self-Monitoring">Self-Monitoring</option>
-                    <option value="Labs">Labs</option>
-                    <option value="Radiology / Imaging">Radiology / Imaging</option>
-                    <option value="Screenings">Screenings</option>
-                    <option value="Medication Rx">Medication Rx</option>
-                    <option value="Physical Therapy Rx">Physical Therapy Rx</option>
-                    <option value="Occupational Therapy Rx">Occupational Therapy Rx</option>
-                    <option value="Referral to Specialist / HCP">Referral to Specialist / HCP</option>
-                    <option value="Clinical Instructions / Other">Clinical Instructions / Other</option>
-                    <option value="SMS Reminders">SMS Reminders</option>
-                    <option value="Handouts / Education Provided">Handouts / Education Provided</option>
-                </select>
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Intervention</label>
-                <input type="text" data-name="intervention" class="form-control form-control-sm">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Description</label>
-                <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
-            </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Name</label>
+                    <select type="text" data-name="category" class="form-control form-control-sm">
+                        <option value="">-- select --</option>
+                        <option value="Self-Monitoring">Self-Monitoring</option>
+                        <option value="Labs">Labs</option>
+                        <option value="Radiology / Imaging">Radiology / Imaging</option>
+                        <option value="Screenings">Screenings</option>
+                        <option value="Medication Rx">Medication Rx</option>
+                        <option value="Physical Therapy Rx">Physical Therapy Rx</option>
+                        <option value="Occupational Therapy Rx">Occupational Therapy Rx</option>
+                        <option value="Referral to Specialist / HCP">Referral to Specialist / HCP</option>
+                        <option value="Clinical Instructions / Other">Clinical Instructions / Other</option>
+                        <option value="SMS Reminders">SMS Reminders</option>
+                        <option value="Handouts / Education Provided">Handouts / Education Provided</option>
+                    </select>
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Intervention</label>
+                    <input type="text" data-name="intervention" class="form-control form-control-sm">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Description</label>
+                    <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
+                </div>
 
-            <div>
-                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
     </div>
 </div>
 
+<script>
+    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function () {
+        // any JS can come here
+        // will be run on page-load as well as whenever this segment is refreshed
+
+        let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+
+        // relevance
+        $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
+        $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
+            if(!!uids) {
+                uids = JSON.parse(uids);
+            }
+            else {
+                uids = [];
+            }
+            let uid = $(this).attr('data-uid'), found = uids.indexOf(uid) > -1;
+            if(this.checked === found) {
+                return false;
+            }
+            if(this.checked) {
+                uids.push(uid);
+            }
+            else {
+                uids = uids.filter(_x => _x !== uid);
+            }
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            return false;
+        });
+
+    };
+</script>

+ 49 - 14
resources/views/app/patient/segment-templates/plan_interventions/summary.blade.php

@@ -14,6 +14,19 @@ foreach($interventions as $intervention) {
     }
     $grouped[$intervention->data->category][] = $intervention;
 }
+
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'INTERVENTIONS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')
+    ->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
+$numRelevant = 0;
 ?>
 
 <?php if (!count($interventions)): ?>
@@ -22,22 +35,44 @@ foreach($interventions as $intervention) {
     <?php foreach($grouped as $k => $group): ?>
         <b><?= $k ?></b>
         <?php foreach($group as $intervention): ?>
-            <div class="mb-2 d-flex align-items-baseline pl-3">
-                <div class="<?= $intervention->is_removed ? 'strike-through' : '' ?>">
-                    <?= !!@($intervention->data->intervention) ? @($intervention->data->intervention) : '' ?>
-                    <br>
-                    <span class="text-secondary"><?= !!@($intervention->data->description) ? @($intervention->data->description) : '' ?></span>
+            <div class="mb-2 pl-3">
+                <div class="d-flex align-items-baseline">
+                    @if(in_array($intervention->uid, $relevance))
+                        <span class="text-info mr-1 text-sm">
+                            <i class="fa fa-star text-sm"></i>
+                        </span>
+                        <?php $numRelevant++; ?>
+                    @endif
+                    <div class="<?= $intervention->is_removed ? 'strike-through' : '' ?>">
+                        <?= !!@($intervention->data->intervention) ? @($intervention->data->intervention) : '' ?>
+                        <br>
+                        <span class="text-secondary"><?= !!@($intervention->data->description) ? @($intervention->data->description) : '' ?></span>
+                    </div>
+                    <?php if ($intervention->is_removed): ?>
+                        <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                    <?php elseif ($intervention->added_in_note_id === $note->id): ?>
+                        <?php if ($intervention->addition_reason_category === 'DURING_VISIT'): ?>
+                        <span class="ml-2 text-sm text-success">* Added during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+                <?php $review = $intervention->childPlanAddedInNote($note); ?>
+                <?php if(!!$review): ?>
+                <div class="pl-3 mt-1">
+                    <div class="text-secondary font-weight-bold">Plan</div>
+                    <div>{!! $review->data->value !!}</div>
                 </div>
-                <?php if ($intervention->is_removed): ?>
-                    <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-                <?php elseif ($intervention->added_in_note_id === $note->id): ?>
-                    <?php if ($intervention->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                    <?php else: ?>
-                        <span class="ml-2 text-sm text-info">* Added on intake</span>
-                    <?php endif;?>
                 <?php endif; ?>
             </div>
         <?php endforeach; ?>
     <?php endforeach; ?>
-<?php endif; ?>
+    @if($numRelevant)
+        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
+            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
+            <span class="text-sm">Interventions relevant to this note</span>
+        </div>
+    @endif
+<?php endif; ?>
+

+ 117 - 59
resources/views/app/patient/segment-templates/plan_medications/edit.blade.php

@@ -12,11 +12,20 @@ use App\Models\Segment;
 $medications = Point::getPlanPointsOfCategory($patient, 'MEDICATION', $note);
 $intakeOrVisit = 'PLAN';
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'MEDICATIONS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
 ?>
 <div>
 
-    <div class="d-flex mb-2">
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 <th class="border-bottom-0">Medication</th>
@@ -28,6 +37,13 @@ $intakeOrVisit = 'PLAN';
             <?php foreach($medications as $medication): ?>
                 <?php $point = $medication; ?>
                 <tr>
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <input type="checkbox" class="m-0 chk-relevance"
+                                   data-uid="{{$medication->uid}}" {{in_array($medication->uid, $relevance) ? 'checked' : ''}}>
+                            <span>&nbsp;</span>
+                        </div>
+                    </td>
                     <td>
                         <div class="d-flex align-items-baseline">
                             <div class="<?= $medication->is_removed ? 'strike-through' : '' ?>">
@@ -35,6 +51,7 @@ $intakeOrVisit = 'PLAN';
                                 <?= !!@($medication->data->route) ? '/&nbsp;' . @($medication->data->route) : '' ?>
                                 <?= !!@($medication->data->dose) ? '/&nbsp;' . @($medication->data->dose) : '' ?>
                                 <?= !!@($medication->data->strength) ? '/&nbsp;' . @($medication->data->strength) : '' ?>
+                                <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
                             </div>
 
                             <!-- common actions -->
@@ -89,62 +106,80 @@ $intakeOrVisit = 'PLAN';
                 </tr>
             <?php endforeach; ?>
         </table>
-    </div>
 
-    <div visit-moe large class="mt-1">
-        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new medication, prescribed during this visit</a>
-        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="MEDICATION">
-            <input type="hidden" name="data">
-
-            <input type="hidden" data-name="medNameId">
-            <input type="hidden" data-name="route">
-            <input type="hidden" data-name="dose">
-            <input type="hidden" data-name="strength">
-            <input type="hidden" data-name="medId">
-
-            <p class="mb-2"><b>Add Medication (during visit)</b></p>
-
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Name</label>
-                <input type="text"
-                       data-name="name"
-                       class="form-control form-control-sm"
-                       stag-suggest
-                       stag-suggest-ep="/fdb-med-suggest/json">
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Route</label>
-                <select data-name="routedMedId"
-                        class="form-control form-control-sm"
-                        disabled>
-                </select>
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Dosage</label>
-                <select data-name="routedDosageFormMedId"
-                        class="form-control form-control-sm"
-                        disabled>
-                </select>
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Strength</label>
-                <select data-name="gcnSeqno"
-                        class="form-control form-control-sm"
-                        disabled>
-                </select>
-            </div>
-            <div class="mb-2">
-                <label class="text-sm text-secondary mb-1">Description</label>
-                <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
-            </div>
-
-            <div>
-                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
+    <div class="d-flex align-items-center">
+        <div visit-moe>
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="MEDICATIONS_RELEVANT_TO_NOTE">
+                <input type="hidden" name="data">
+                <button submit class="btn btn-sm btn-info font-weight-bold">Save Relevance</button>
+            </form>
+        </div>
+        <div visit-moe large class="ml-auto mt-1 max-width-500px">
+            <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new medication, prescribed during this visit</a>
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                <input type="hidden" name="category" value="MEDICATION">
+                <input type="hidden" name="data">
+
+                <input type="hidden" data-name="medNameId">
+                <input type="hidden" data-name="route">
+                <input type="hidden" data-name="dose">
+                <input type="hidden" data-name="strength">
+                <input type="hidden" data-name="medId">
+
+                <p class="mb-2"><b>Add Medication (during visit)</b></p>
+
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Name</label>
+                    <input type="text"
+                           data-name="name"
+                           class="form-control form-control-sm"
+                           stag-suggest
+                           stag-suggest-ep="/fdb-med-suggest/json">
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Route</label>
+                    <select data-name="routedMedId"
+                            class="form-control form-control-sm"
+                            disabled>
+                    </select>
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Dosage</label>
+                    <select data-name="routedDosageFormMedId"
+                            class="form-control form-control-sm"
+                            disabled>
+                    </select>
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Strength</label>
+                    <select data-name="gcnSeqno"
+                            class="form-control form-control-sm"
+                            disabled>
+                    </select>
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Frequency</label>
+                    <input type="text" class="form-control form-control-sm" data-name="frequency"
+                           data-option-list="frequency-options" autocomplete="off" value="">
+                    <div id="frequency-options" class="data-option-list">
+                        <div>Once a day</div>
+                        <div>Twice a day</div>
+                    </div>
+                </div>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Description</label>
+                    <textarea type="text" data-name="description" class="form-control form-control-sm"></textarea>
+                </div>
+
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
     </div>
 </div>
 
@@ -240,6 +275,29 @@ $intakeOrVisit = 'PLAN';
 
         });
 
-    };
-</script>
+        // relevance
+        $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
+        $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
+            if(!!uids) {
+                uids = JSON.parse(uids);
+            }
+            else {
+                uids = [];
+            }
+            let uid = $(this).attr('data-uid'), found = uids.indexOf(uid) > -1;
+            if(this.checked === found) {
+                return false;
+            }
+            if(this.checked) {
+                uids.push(uid);
+            }
+            else {
+                uids = uids.filter(_x => _x !== uid);
+            }
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            return false;
+        });
 
+    };
+</script>

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

@@ -6,29 +6,61 @@ use App\Models\Point;
 
 $medications = Point::getPlanPointsOfCategory($patient, 'MEDICATION', $note);
 
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'MEDICATIONS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')
+    ->first();
+if (!!@$relevance->data) {
+    $relevance = json_decode($relevance->data, true);
+}
+else {
+    $relevance = [];
+}
+
+$numRelevant = 0;
 ?>
 
 <?php if (!count($medications)): ?>
     <div class="text-secondary">No medications</div>
 <?php else: ?>
     <?php foreach ($medications as $medication): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            <div class="<?= $medication->is_removed ? 'strike-through' : '' ?>">
-                <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
-                <?= !!@($medication->data->dose) ? '/&nbsp;' . @($medication->data->dose) : '' ?>
-                <?= !!@($medication->data->route) ? '/&nbsp;' . @($medication->data->route) : '' ?>
-                <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                @if(in_array($medication->uid, $relevance))
+                    <span class="text-info mr-1 text-sm">
+                        <i class="fa fa-star text-sm"></i>
+                    </span>
+                    <?php $numRelevant++; ?>
+                @endif
+                <div class="<?= $medication->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
+                    <?= !!@($medication->data->strength) ? '/&nbsp;' . @($medication->data->strength) : '' ?>
+                    <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
+                </div>
+                <?php if ($medication->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                <?php elseif ($medication->added_in_note_id === $note->id): ?>
+                    <?php if ($medication->addition_reason_category === 'DURING_VISIT'): ?>
+                        <span class="ml-2 text-sm text-success">* Added during visit</span>
+                    <?php else: ?>
+                        <span class="ml-2 text-sm text-info">* Added on intake</span>
+                    <?php endif;?>
+                <?php endif; ?>
+            </div>
+            <?php $review = $medication->childPlanAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Plan</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($medication->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-            <?php elseif ($medication->added_in_note_id === $note->id): ?>
-                <?php if ($medication->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                <?php else: ?>
-                    <span class="ml-2 text-sm text-info">* Added on intake</span>
-                <?php endif;?>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>
+    @if($numRelevant)
+        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
+            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
+            <span class="text-sm">Medications relevant to this note</span>
+        </div>
+    @endif
 <?php endif; ?>
 

+ 7 - 5
resources/views/app/patient/segment-templates/plan_problems/edit.blade.php

@@ -12,7 +12,9 @@ use \App\Models\Segment;
 $problems = Point::getPlanPointsOfCategory($patient, 'PROBLEM', $note);
 $intakeOrVisit = 'PLAN';
 
-$relevance = Point::where('added_in_segment_id', $segment->id)->where('category', 'PROBLEMS_RELEVANT_TO_NOTE')->orderBy('id', 'DESC')->first();
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'PROBLEMS_RELEVANT_TO_NOTE')
+    ->orderBy('id', 'DESC')->first();
 if (!!@$relevance->data) {
     $relevance = json_decode($relevance->data, true);
 }
@@ -105,7 +107,7 @@ else {
 
     <div class="d-flex align-items-center">
         <div visit-moe>
-            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="relevance-form">
+            <form start show url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="<?= $segment->uid ?>-relevance-form">
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
                 <input type="hidden" name="category" value="PROBLEMS_RELEVANT_TO_NOTE">
                 <input type="hidden" name="data">
@@ -114,7 +116,7 @@ else {
         </div>
         <div visit-moe large class="ml-auto mt-1 max-width-500px">
             <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new problem, added during this visit</a>
-            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
+            <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1" right>
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
                 <input type="hidden" name="category" value="PROBLEM">
                 <input type="hidden" name="data">
@@ -193,7 +195,7 @@ else {
         // relevance
         $(document).off('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance');
         $(document).on('change', '[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] .chk-relevance', function () {
-            let uids = $('#relevance-form').find('[name="data"]').val();
+            let uids = $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val();
             if(!!uids) {
                 uids = JSON.parse(uids);
             }
@@ -210,7 +212,7 @@ else {
             else {
                 uids = uids.filter(_x => _x !== uid);
             }
-            $('#relevance-form').find('[name="data"]').val(JSON.stringify(uids));
+            $('#<?= $segment->uid ?>-relevance-form').find('[name="data"]').val(JSON.stringify(uids));
             return false;
         });
 

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

@@ -6,7 +6,9 @@ use App\Models\Point;
 
 $problems = Point::getPlanPointsOfCategory($patient, 'PROBLEM', $note);
 
-$relevance = Point::where('added_in_segment_id', $segment->id)->where('category', 'PROBLEMS_RELEVANT_TO_NOTE')->orderBy('id', 'DESC')->first();
+$relevance = Point::where('added_in_segment_id', $segment->id)
+    ->where('category', 'PROBLEMS_RELEVANT_TO_NOTE')->orderBy('id', 'DESC')
+    ->first();
 if (!!@$relevance->data) {
     $relevance = json_decode($relevance->data, true);
 }
@@ -21,33 +23,42 @@ $numRelevant = 0;
     <div class="text-secondary">No problems</div>
 <?php else: ?>
     <?php foreach ($problems as $problem): ?>
-        <div class="d-flex align-items-baseline mb-2">
-            @if(in_array($problem->uid, $relevance))
-                <span class="text-info mr-1 text-sm">
-                    <i class="fa fa-star text-sm"></i>
-                </span>
-                <?php $numRelevant++; ?>
-            @endif
-            <div class="<?= $problem->is_removed ? 'strike-through' : '' ?> <?= !in_array($problem->uid, $relevance) ? 'on-hover-opaque' : '' ?>">
-                <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
-                <?= !!@($problem->data->icd) ? '/&nbsp;' . @($problem->data->icd) : '' ?>
-                <?= !!@($problem->data->description) ? '/&nbsp;' . @($problem->data->description) : '' ?>
+        <div class="mb-2">
+            <div class="d-flex align-items-baseline">
+                @if(in_array($problem->uid, $relevance))
+                    <span class="text-info mr-1 text-sm">
+                        <i class="fa fa-star text-sm"></i>
+                    </span>
+                    <?php $numRelevant++; ?>
+                @endif
+                <div class="<?= $problem->is_removed ? 'strike-through' : '' ?> <?= !in_array($problem->uid, $relevance) ? 'on-hover-opaque' : '' ?>">
+                    <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
+                    <?= !!@($problem->data->icd) ? '/&nbsp;' . @($problem->data->icd) : '' ?>
+                    <?= !!@($problem->data->description) ? '/&nbsp;' . @($problem->data->description) : '' ?>
+                </div>
+                <?php if ($problem->is_removed): ?>
+                    <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                <?php elseif ($problem->added_in_note_id === $note->id): ?>
+                    <?php if ($problem->addition_reason_category === 'DURING_VISIT'): ?>
+                        <span class="ml-2 text-sm text-success">* Added during visit</span>
+                    <?php else: ?>
+                        <span class="ml-2 text-sm text-info">* Added on intake</span>
+                    <?php endif;?>
+                <?php endif; ?>
+            </div>
+            <?php $review = $problem->childPlanAddedInNote($note); ?>
+            <?php if(!!$review): ?>
+            <div class="pl-3 mt-1">
+                <div class="text-secondary font-weight-bold">Plan</div>
+                <div>{!! $review->data->value !!}</div>
             </div>
-            <?php if ($problem->is_removed): ?>
-                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
-            <?php elseif ($problem->added_in_note_id === $note->id): ?>
-                <?php if ($problem->addition_reason_category === 'DURING_VISIT'): ?>
-                    <span class="ml-2 text-sm text-success">* Added during visit</span>
-                <?php else: ?>
-                    <span class="ml-2 text-sm text-info">* Added on intake</span>
-                <?php endif;?>
             <?php endif; ?>
         </div>
     <?php endforeach; ?>
     @if($numRelevant)
         <div class="d-flex align-items-baseline text-info mr-1 mt-3">
             <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
-            <span class="text-sm">Problem(s) relevant to this note</span>
+            <span class="text-sm">Problems relevant to this note</span>
         </div>
     @endif
 <?php endif; ?>

+ 72 - 729
resources/views/app/patient/vitals-settings.blade.php

@@ -7,750 +7,93 @@
     <hr class="m-neg-4">
 
     <div class="row" id="vitals-settings-{{$patient->uid}}">
-        <div class="col-6">
+        <div class="col-5 border-right">
             <div class="d-flex align-items-baseline">
                 <b>BMI Management</b>
                 <span class="mx-2 text-secondary">|</span>
-                <div moe large>
-                    <a href="#" start show>Update</a>
-                    <form url="/api/client/updateBmiManagementValue">
-                        <input type="hidden" name="uid" value="{{$patient->uid}}">
-                        <p>BMI Management</p>
-                        <div class="mb-2">
-                            <label class="text-sm text-secondary mb-1">Is Weight Monitoring Needed?</label>
-                            <select type="text" class="form-control form-control-sm min-width-unset" condition name="isWeightMonitoringNeeded">
-                                <option value="">-- select --</option>
-                                <option {{$patient->is_weight_monitoring_needed === 'YES' ? 'selected' : '' }} value="YES">Yes</option>
-                                <option {{$patient->is_weight_monitoring_needed === 'NO' ? 'selected' : '' }} value="NO">No</option>
-                                <option {{$patient->is_weight_monitoring_needed === 'UNKNOWN' ? 'selected' : '' }} value="UNKNOWN">Unknown</option>
-                            </select>
-                        </div>
-                        <div condition-key="isWeightMonitoringNeeded" condition-value="YES">
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Why Is Weight Monitoring Needed?</label>
-                                <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeeded" value="{{$patient->why_is_weight_monitoring_needed}}">
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 1</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededIcd1" value="{{$patient->why_is_weight_monitoring_needed_icd1}}">
-                                </div>
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 2</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededIcd2" value="{{$patient->why_is_weight_monitoring_needed_icd2}}">
-                                </div>
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 3</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededIcd3" value="{{$patient->why_is_weight_monitoring_needed_icd3}}">
-                                </div>
-                                <div class="col-3">
-                                    <label class="text-sm text-secondary mb-1">ICD 4</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededIcd4" value="{{$patient->why_is_weight_monitoring_needed_icd4}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-6 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Description 1</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededDescription1" value="{{$patient->why_is_weight_monitoring_needed_description1}}">
-                                </div>
-                                <div class="col-6">
-                                    <label class="text-sm text-secondary mb-1">Description 2</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededDescription2" value="{{$patient->why_is_weight_monitoring_needed_description2}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-6 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Description 3</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededDescription3" value="{{$patient->why_is_weight_monitoring_needed_description3}}">
-                                </div>
-                                <div class="col-6">
-                                    <label class="text-sm text-secondary mb-1">Description 4</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeededDescription4" value="{{$patient->why_is_weight_monitoring_needed_description4}}">
-                                </div>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Has Heart Failure Dx?</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="hasHeartFailureDx">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->has_heart_failure_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
-                                    <option {{$patient->has_heart_failure_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
-                                    <option {{$patient->has_heart_failure_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Weight Management Goal Category</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="weightManagementGoalCategory">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->weight_management_goal_category === 'LOSE' ? 'selected' : ''}} value="LOSE">Lose</option>
-                                    <option {{$patient->weight_management_goal_category === 'GAIN' ? 'selected' : ''}} value="GAIN">Gain</option>
-                                    <option {{$patient->weight_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
-                                </select>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Baseline Weight (lbs)</label>
-                                    <input type="number" class="form-control form-control-sm min-width-unset" name="baselineWeight" value="{{$patient->baseline_weight}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Baseline Min (lbs)</label>
-                                    <input type="number" class="form-control form-control-sm min-width-unset" name="baselineWeightMin" value="{{$patient->baseline_weight_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">Baseline Max (lbs)</label>
-                                    <input type="number" class="form-control form-control-sm min-width-unset" name="baselineWeightMax" value="{{$patient->baseline_weight_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Ideal Weight (lbs)</label>
-                                    <input type="number" class="form-control form-control-sm min-width-unset" name="idealWeight" value="{{$patient->ideal_weight}}">
-                                </div>
-                            </div>
-                        </div>
-                        <div class="pt-2">
-                            <button class="btn btn-success btn-sm" submit>Submit</button>
-                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                        </div>
-                    </form>
-                </div>
+                @include('app.patient.vitals-settings.bmi-management-form')
+            </div>
+            <div class="pt-3">
+                @include('app.patient.vitals-settings.bmi-management-summary')
             </div>
-            <table class="table table-sm table-condensed table-bordered table-hover mt-3">
-                <tbody>
-                <tr>
-                    <td>Is Weight Monitoring Needed?</td>
-                    <td class="font-weight-bold">{{$patient->is_weight_monitoring_needed}}</td>
-                </tr>
-                @if($patient->is_weight_monitoring_needed === 'YES')
-                    <tr>
-                        <td>Why Is Weight Monitoring Needed</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 1</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_icd1}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 2</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_icd2}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 3</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_icd3}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 4</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_icd4}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 1</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_description1}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 2</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_description2}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 3</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_description3}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 4</td>
-                        <td class="font-weight-bold">{{$patient->why_is_weight_monitoring_needed_description4}}</td>
-                    </tr>
-                    <tr>
-                        <td>Has Heart Failure Dx?</td>
-                        <td class="font-weight-bold">{{$patient->has_heart_failure_dx}}</td>
-                    </tr>
-                    <tr>
-                        <td>Weight Management Goal Category</td>
-                        <td class="font-weight-bold">{{$patient->weight_management_goal_category}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline Weight (lbs)</td>
-                        <td class="font-weight-bold">{{$patient->baseline_weight}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline Min (lbs)</td>
-                        <td class="font-weight-bold">{{$patient->baseline_weight_min}}</td>
-                    </tr>
-                    <tr class="col-4">
-                        <td>Baseline Max (lbs)</td>
-                        <td class="font-weight-bold">{{$patient->baseline_weight_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal Weight (lbs)</td>
-                        <td class="font-weight-bold">{{$patient->ideal_weight}}</td>
-                    </tr>
-
-                @endif
-                </tbody>
-            </table>
         </div>
-        <div class="col-6">
+        <div class="col-7">
             <div class="d-flex align-items-baseline">
                 <b>BP Management</b>
                 <span class="mx-2 text-secondary">|</span>
-                <div moe large>
-                    <a href="#" start show>Update</a>
-                    <form url="/api/client/updateBpManagementValue">
-                        <input type="hidden" name="uid" value="{{$patient->uid}}">
-                        <p>BP Management</p>
-                        <div class="mb-2">
-                            <label class="text-sm text-secondary mb-1">Is BP Monitoring Needed?</label>
-                            <select type="text" class="form-control form-control-sm min-width-unset" condition name="isBpMonitoringNeeded">
-                                <option value="">-- select --</option>
-                                <option {{$patient->is_bp_monitoring_needed === 'YES' ? 'selected' : '' }} value="YES">Yes</option>
-                                <option {{$patient->is_bp_monitoring_needed === 'NO' ? 'selected' : '' }} value="NO">No</option>
-                                <option {{$patient->is_bp_monitoring_needed === 'UNKNOWN' ? 'selected' : '' }} value="UNKNOWN">Unknown</option>
-                            </select>
-                        </div>
-                        <div condition-key="isBpMonitoringNeeded" condition-value="YES">
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Why Is BP Monitoring Needed?</label>
-                                <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeeded" value="{{$patient->why_is_bp_monitoring_needed}}">
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 1</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededIcd1" value="{{$patient->why_is_bp_monitoring_needed_icd1}}">
-                                </div>
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 2</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededIcd2" value="{{$patient->why_is_bp_monitoring_needed_icd2}}">
-                                </div>
-                                <div class="col-3 pr-0">
-                                    <label class="text-sm text-secondary mb-1">ICD 3</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededIcd3" value="{{$patient->why_is_bp_monitoring_needed_icd3}}">
-                                </div>
-                                <div class="col-3">
-                                    <label class="text-sm text-secondary mb-1">ICD 4</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededIcd4" value="{{$patient->why_is_bp_monitoring_needed_icd4}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-6 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Description 1</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededDescription1" value="{{$patient->why_is_bp_monitoring_needed_description1}}">
-                                </div>
-                                <div class="col-6">
-                                    <label class="text-sm text-secondary mb-1">Description 2</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededDescription2" value="{{$patient->why_is_bp_monitoring_needed_description2}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-6 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Description 3</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededDescription3" value="{{$patient->why_is_bp_monitoring_needed_description3}}">
-                                </div>
-                                <div class="col-6">
-                                    <label class="text-sm text-secondary mb-1">Description 4</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeededDescription4" value="{{$patient->why_is_bp_monitoring_needed_description4}}">
-                                </div>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Has Pre-Hypertension Dx?</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="hasPrehypertensionDx">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->has_prehypertension_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
-                                    <option {{$patient->has_prehypertension_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
-                                    <option {{$patient->has_prehypertension_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Has Hypertension Dx?</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="hasHypertensionDx">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->has_hypertension_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
-                                    <option {{$patient->has_hypertension_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
-                                    <option {{$patient->has_hypertension_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Is Prescribed Hypertension Medicine?</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="isPrescribedHypertensionMedicine">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->is_prescribed_hypertension_medicine === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
-                                    <option {{$patient->is_prescribed_hypertension_medicine === 'NO' ? 'selected' : ''}} value="NO">No</option>
-                                    <option {{$patient->is_prescribed_hypertension_medicine === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Is goal to reduce hypertension medicine?</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="isGoalToReduceHypertensionMedicine">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
-                                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'NO' ? 'selected' : ''}} value="NO">No</option>
-                                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Goal to reduce hypertension medicine</label>
-                                <input type="text" class="form-control form-control-sm min-width-unset" name="goalToReduceHypertensionMedicine" value="{{$patient->goal_to_reduce_hypertension_medicine}}">
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">SBP Management Goal Category</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="sbpManagementGoalCategory">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->sbp_management_goal_category === 'LOSE' ? 'selected' : ''}} value="LOSE">Lose</option>
-                                    <option {{$patient->sbp_management_goal_category === 'GAIN' ? 'selected' : ''}} value="GAIN">Gain</option>
-                                    <option {{$patient->sbp_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">DBP Management Goal Category</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="dbpManagementGoalCategory">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->dbp_management_goal_category === 'LOSE' ? 'selected' : ''}} value="LOSE">Lose</option>
-                                    <option {{$patient->dbp_management_goal_category === 'GAIN' ? 'selected' : ''}} value="GAIN">Gain</option>
-                                    <option {{$patient->dbp_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <label class="text-sm text-secondary mb-1">Pulse Management Goal Category</label>
-                                <select type="text" class="form-control form-control-sm min-width-unset" name="pulseManagementGoalCategory">
-                                    <option value="">-- select --</option>
-                                    <option {{$patient->pulse_management_goal_category === 'LOSE' ? 'selected' : ''}} value="LOSE">Lose</option>
-                                    <option {{$patient->pulse_management_goal_category === 'GAIN' ? 'selected' : ''}} value="GAIN">Gain</option>
-                                    <option {{$patient->pulse_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
-                                </select>
-                            </div>
-
-                            <p><b>Baseline AM Resting BP</b></p>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingSbp" value="{{$patient->baseline_am_resting_sbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingSbpMin" value="{{$patient->baseline_am_resting_sbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">SBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingSbpMax" value="{{$patient->baseline_am_resting_sbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingDbp" value="{{$patient->baseline_am_resting_dbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingDbpMin" value="{{$patient->baseline_am_resting_dbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">DBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingDbpMax" value="{{$patient->baseline_am_resting_dbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingPulse" value="{{$patient->baseline_am_resting_pulse}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingPulseMin" value="{{$patient->baseline_am_resting_pulse_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">Pulse Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselineAmRestingPulseMax" value="{{$patient->baseline_am_resting_pulse_max}}">
-                                </div>
-                            </div>
-
-
-
-                            <p><b>Baseline PM Resting BP</b></p>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingSbp" value="{{$patient->baseline_pm_resting_sbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingSbpMin" value="{{$patient->baseline_pm_resting_sbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">SBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingSbpMax" value="{{$patient->baseline_pm_resting_sbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingDbp" value="{{$patient->baseline_pm_resting_dbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingDbpMin" value="{{$patient->baseline_pm_resting_dbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">DBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingDbpMax" value="{{$patient->baseline_pm_resting_dbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingPulse" value="{{$patient->baseline_pm_resting_pulse}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingPulseMin" value="{{$patient->baseline_pm_resting_pulse_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">Pulse Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="baselinePmRestingPulseMax" value="{{$patient->baseline_pm_resting_pulse_max}}">
-                                </div>
-                            </div>
-
-
-
-                            <p><b>Ideal AM Resting BP</b></p>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingSbp" value="{{$patient->ideal_am_resting_sbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingSbpMin" value="{{$patient->ideal_am_resting_sbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">SBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingSbpMax" value="{{$patient->ideal_am_resting_sbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingDbp" value="{{$patient->ideal_am_resting_dbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingDbpMin" value="{{$patient->ideal_am_resting_dbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">DBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingDbpMax" value="{{$patient->ideal_am_resting_dbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingPulse" value="{{$patient->ideal_am_resting_pulse}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingPulseMin" value="{{$patient->ideal_am_resting_pulse_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">Pulse Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealAmRestingPulseMax" value="{{$patient->ideal_am_resting_pulse_max}}">
-                                </div>
-                            </div>
-
-
-
-                            <p><b>Ideal PM Resting BP</b></p>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingSbp" value="{{$patient->ideal_pm_resting_sbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">SBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingSbpMin" value="{{$patient->ideal_pm_resting_sbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">SBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingSbpMax" value="{{$patient->ideal_pm_resting_sbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingDbp" value="{{$patient->ideal_pm_resting_dbp}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">DBP Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingDbpMin" value="{{$patient->ideal_pm_resting_dbp_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">DBP Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingDbpMax" value="{{$patient->ideal_pm_resting_dbp_max}}">
-                                </div>
-                            </div>
-                            <div class="row mb-2">
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingPulse" value="{{$patient->ideal_pm_resting_pulse}}">
-                                </div>
-                                <div class="col-4 pr-0">
-                                    <label class="text-sm text-secondary mb-1">Pulse Min</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingPulseMin" value="{{$patient->ideal_pm_resting_pulse_min}}">
-                                </div>
-                                <div class="col-4">
-                                    <label class="text-sm text-secondary mb-1">Pulse Max</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset" name="idealPmRestingPulseMax" value="{{$patient->ideal_pm_resting_pulse_max}}">
-                                </div>
-                            </div>
-
-                        </div>
-                        <div class="pt-2">
-                            <button class="btn btn-success btn-sm" submit>Submit</button>
-                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                        </div>
-                    </form>
-                </div>
+                @include('app.patient.vitals-settings.bp-management-form')
+            </div>
+            <div class="pt-3">
+                @include('app.patient.vitals-settings.bp-management-summary')
             </div>
-            <table class="table table-sm table-condensed table-bordered table-hover mt-3">
-                <tbody>
-                <tr>
-                    <td>Is BP Monitoring Needed?</td>
-                    <td class="font-weight-bold">{{$patient->is_bp_monitoring_needed}}</td>
-                </tr>
-                @if($patient->is_bp_monitoring_needed === 'YES')
-                    <tr>
-                        <td>Why Is Weight Monitoring Needed</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 1</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_icd1}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 2</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_icd2}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 3</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_icd3}}</td>
-                    </tr>
-                    <tr>
-                        <td>ICD 4</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_icd4}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 1</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_description1}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 2</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_description2}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 3</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_description3}}</td>
-                    </tr>
-                    <tr>
-                        <td>Description 4</td>
-                        <td class="font-weight-bold">{{$patient->why_is_bp_monitoring_needed_description4}}</td>
-                    </tr>
-                    <tr>
-                        <td>Has Pre-Hypertension Dx?</td>
-                        <td class="font-weight-bold">{{$patient->has_prehypertension_dx}}</td>
-                    </tr>
-                    <tr>
-                        <td>Has Hypertension Dx?</td>
-                        <td class="font-weight-bold">{{$patient->has_hypertension_dx}}</td>
-                    </tr>
-
-                    <tr>
-                        <td>Is prescribed hypertension medicine?</td>
-                        <td class="font-weight-bold">{{$patient->is_prescribed_hypertension_medicine}}</td>
-                    </tr>
-                    <tr>
-                        <td>Is goal to reduce hypertension medicine?</td>
-                        <td class="font-weight-bold">{{$patient->is_goal_to_reduce_hypertension_medicine}}</td>
-                    </tr>
-                    <tr>
-                        <td>Goal to reduce hypertension medicine</td>
-                        <td class="font-weight-bold">{{$patient->goal_to_reduce_hypertension_medicine}}</td>
-                    </tr>
-                    <tr>
-                        <td>SBP management goal category</td>
-                        <td class="font-weight-bold">{{$patient->sbp_management_goal_category}}</td>
-                    </tr>
-                    <tr class="col-4">
-                        <td>DBP management goal category</td>
-                        <td class="font-weight-bold">{{$patient->dbp_management_goal_category}}</td>
-                    </tr>
-                    <tr>
-                        <td>Pulse management goal category</td>
-                        <td class="font-weight-bold">{{$patient->pulse_management_goal_category}}</td>
-                    </tr>
-
-
-
-                    <tr>
-                        <td>Baseline AM resting SBP</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_sbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting SBP min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_sbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting SBP max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_sbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting DBP</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_dbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting DBP min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_dbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting DBP max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_dbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting pulse</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_pulse}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting pulse min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_pulse_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline AM resting pulse max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_am_resting_pulse_max}}</td>
-                    </tr>
-
-                    <tr>
-                        <td>Baseline PM resting SBP</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_sbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting SBP min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_sbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting SBP max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_sbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting DBP</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_dbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting DBP min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_dbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting DBP max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_dbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting pulse</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_pulse}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting pulse min</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_pulse_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Baseline PM resting pulse max</td>
-                        <td class="font-weight-bold">{{$patient->baseline_pm_resting_pulse_max}}</td>
-                    </tr>
-
-
-                    <tr>
-                        <td>Ideal AM resting SBP</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_sbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting SBP min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_sbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting SBP max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_sbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting DBP</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_dbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting DBP min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_dbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting DBP max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_dbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting pulse</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_pulse}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting pulse min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_pulse_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal AM resting pulse max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_am_resting_pulse_max}}</td>
-                    </tr>
-
-                    <tr>
-                        <td>Ideal PM resting SBP</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_sbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting SBP min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_sbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting SBP max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_sbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting DBP</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_dbp}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting DBP min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_dbp_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting DBP max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_dbp_max}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting pulse</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_pulse}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting pulse min</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_pulse_min}}</td>
-                    </tr>
-                    <tr>
-                        <td>Ideal PM resting pulse max</td>
-                        <td class="font-weight-bold">{{$patient->ideal_pm_resting_pulse_max}}</td>
-                    </tr>
-
-                @endif
-                </tbody>
-            </table>
         </div>
     </div>
 
     <script>
-        (function() {
+        (function () {
+            function calculateUsualBmi() {
+                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                    w = $('#bmi-management-settings [name="usualWeightInPounds"]').val();
+                let bmiElem = $('#bmi-management-settings [name="usualBmi"]').val(''),
+                    bmiCategoryElem = $('#bmi-management-settings [name="usualBmiCategory"]').val('');
+                calculateBmi(h, w, bmiElem, bmiCategoryElem);
+                return false;
+            }
+
+            function calculateIdealBmi() {
+                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                    w = $('#bmi-management-settings [name="idealWeightInPounds"]').val();
+                let bmiElem = $('#bmi-management-settings [name="idealBmi"]').val(''),
+                    bmiCategoryElem = $('#bmi-management-settings [name="idealBmiCategory"]').val('');
+                calculateBmi(h, w, bmiElem, bmiCategoryElem);
+                return false;
+            }
+
+            function calculateBmi(h, w, bmiElem, bmiCategoryElem) {
+                let bmi = 0,
+                    bmiCategory = '';
+                try {
+                    h = +h;
+                    w = +w;
+                    bmi = (w / (h * h)) * 703;
+                    bmiElem.val(bmi.toFixed(1));
+                    if (bmi < 18.5) {
+                        bmiCategory = '(Underweight)';
+                    }
+                    if (bmi >= 18.5 && bmi < 25) {
+                        bmiCategory = '(Healthy)';
+                    }
+                    if (bmi >= 25 && bmi < 30) {
+                        bmiCategory = '(Overweight)';
+                    }
+                    if (bmi >= 30) {
+                        bmiCategory = '(Obese)';
+                    }
+                    bmiCategoryElem.val(bmiCategory);
+                } catch (e) {
+                    return false;
+                }
+            }
+
             function init() {
-                $('[condition]')
-                    .off('change.condition')
-                    .on('change.condition', function() {
-                        let form = $(this).closest('form');
-                        form.find('[condition-key="' + this.name + '"]').hide();
-                        form.find('[condition-key="' + this.name + '"][condition-value="' + this.value + '"]').show();
-                    })
-                    .trigger('change');
+                $(document)
+                    .off('change input paste keyup',
+                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]')
+                    .on('change input paste keyup',
+                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]', function () {
+                            return calculateUsualBmi();
+                        });
+                $(document)
+                    .off('change input paste keyup',
+                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]')
+                    .on('change input paste keyup',
+                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]', function () {
+                            return calculateIdealBmi();
+                        });
+
+                $('#bmi-management-settings [name="currentHeightInInches"]').trigger('change');
             }
+
             addMCInitializer('vitals-settings-{{$patient->uid}}', init, '#vitals-settings-{{$patient->uid}}')
         }).call(window);
     </script>

+ 144 - 0
resources/views/app/patient/vitals-settings/bmi-management-form.blade.php

@@ -0,0 +1,144 @@
+<div moe large id="bmi-management-settings">
+    <a href="#" start show>Update</a>
+    <form url="/api/client/updateBmiManagementSettingsValue">
+        <input type="hidden" name="uid" value="{{$patient->uid}}">
+        <p class="text-secondary font-weight-bold font-size-14">BMI Management</p>
+
+        <div class="mb-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Current Height:</span>
+            <div class="width-100px mr-2"><?= vsElement('current_height_in_inches', 'number', 'currentHeightInInches', $patient) ?></div>
+            <span class="text-secondary">(in.)</span>
+        </div>
+
+        <hr class="my-3">
+
+        <div class="mb-1 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Weight (usual):</span>
+            <div class="width-100px mr-2"><?= vsElement('usual_weight_in_pounds', 'number', 'usualWeightInPounds', $patient) ?></div>
+            <span class="text-secondary">(lbs)</span>
+        </div>
+        <div class="mb-1 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Ranging between</span>
+            <div class="width-100px"><?= vsElement('usual_weight_in_pounds_min', 'number', 'usualWeightInPoundsMin', $patient) ?></div>
+            <span class="text-secondary mx-2">and</span>
+            <div class="width-100px"><?= vsElement('usual_weight_in_pounds_max', 'number', 'usualWeightInPoundsMax', $patient) ?></div>
+        </div>
+        <div class="mb-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">BMI (usual):</span>
+            <div class="width-100px mr-2"><?= vsRoElement('usual_bmi', 'number', 'usualBmi', $patient) ?></div>
+            <span class="text-secondary">
+                <input type="text" readonly=""
+                       class="form-control form-control-sm min-width-unset rounded-0 border-0 bg-transparent font-weight-bold"
+                       name="usualBmiCategory"
+                       value="{{$patient->usual_bmi_category ?: ''}}">
+            </span>
+        </div>
+
+        <hr class="my-3">
+
+        <div class="mb-1 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Weight (ideal):</span>
+            <div class="width-100px mr-2"><?= vsElement('ideal_weight_in_pounds', 'number', 'idealWeightInPounds', $patient) ?></div>
+            <span class="text-secondary">(lbs)</span>
+        </div>
+        <div class="mb-1 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Ranging between</span>
+            <div class="width-100px"><?= vsElement('ideal_weight_in_pounds_min', 'number', 'idealWeightInPoundsMin', $patient) ?></div>
+            <span class="text-secondary mx-2">and</span>
+            <div class="width-100px"><?= vsElement('ideal_weight_in_pounds_max', 'number', 'idealWeightInPoundsMax', $patient) ?></div>
+        </div>
+        <div class="mb-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">BMI (ideal):</span>
+            <div class="width-100px mr-2"><?= vsRoElement('ideal_bmi', 'number', 'idealBmi', $patient) ?></div>
+            <span class="text-secondary">
+                <input type="text" readonly=""
+                       class="form-control form-control-sm min-width-unset rounded-0 border-0 bg-transparent font-weight-bold"
+                       name="idealBmiCategory"
+                       value="{{$patient->ideal_bmi_category ?: ''}}">
+            </span>
+        </div>
+
+        <hr class="my-3">
+
+        <div class="mb-2 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Goal:</span>
+            <div class="width-150px">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="weightManagementGoalCategory">
+                    <option value="">-- select --</option>
+                    <option {{$patient->weight_management_goal_category === 'LOWER' ? 'selected' : ''}} value="LOWER">Lower</option>
+                    <option {{$patient->weight_management_goal_category === 'INCREASE' ? 'selected' : ''}} value="INCREASE">Increase</option>
+                    <option {{$patient->weight_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
+                </select>
+            </div>
+        </div>
+
+        <div class="mb-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px">Reports heart failure?</span>
+            <div class="width-150px">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="hasHeartFailureDx">
+                    <option value="">-- select --</option>
+                    <option {{$patient->has_heart_failure_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->has_heart_failure_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->has_heart_failure_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+
+        <div class="mb-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px mr-2">Weight monitoring prescribed?</span>
+            <div class="width-150px">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="isWeightMonitoringNeeded">
+                    <option value="">-- select --</option>
+                    <option {{$patient->is_weight_monitoring_needed === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->is_weight_monitoring_needed === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->is_weight_monitoring_needed === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+
+        <hr class="my-3">
+
+        <div class="text-secondary min-width-140px mb-1">ICDs</div>
+        <table class="table table-sm table-striped table-bordered mb-3">
+            <thead>
+            <tr class="bg-light text-secondary">
+                <th class="border-bottom-0 width-30px">#</th>
+                <th class="border-bottom-0 w-25">Code</th>
+                <th class="border-bottom-0">Description</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr>
+                <td class="p-0 align-middle text-center">1</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_icd1', 'text', 'whyIsWeightMonitoringNeededIcd1', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_description1', 'text', 'whyIsWeightMonitoringNeededDescription1', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">2</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_icd2', 'text', 'whyIsWeightMonitoringNeededIcd2', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_description2', 'text', 'whyIsWeightMonitoringNeededDescription2', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">3</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_icd3', 'text', 'whyIsWeightMonitoringNeededIcd3', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_description3', 'text', 'whyIsWeightMonitoringNeededDescription3', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">4</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_icd4', 'text', 'whyIsWeightMonitoringNeededIcd4', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_weight_monitoring_needed_description4', 'text', 'whyIsWeightMonitoringNeededDescription4', $patient) ?></td>
+            </tr>
+            </tbody>
+        </table>
+
+        <div class="text-secondary min-width-140px mb-1">Remarks on clinical need:</div>
+        <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsWeightMonitoringNeeded" value="{{$patient->why_is_weight_monitoring_needed}}">
+
+        <hr class="my-3">
+
+        <div class="pt-2">
+            <button class="btn btn-success btn-sm" submit>Submit</button>
+            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        </div>
+    </form>
+</div>

+ 64 - 0
resources/views/app/patient/vitals-settings/bmi-management-summary.blade.php

@@ -0,0 +1,64 @@
+<div class="mb-3">
+    <span class="text-secondary">Height:</span>
+    <b>
+        <?= ($patient->current_height_in_inches ? floor($patient->current_height_in_inches / 12) : '-') ?>'
+        <?= ($patient->current_height_in_inches ? floor($patient->current_height_in_inches % 12) : '-') ?>"
+    </b>
+</div>
+
+<div class="mb-1">
+    <span class="text-secondary">Weight (usual):</span>
+    <b><?= vsValue('usual_weight_in_pounds', $patient) ?></b>
+    <span class="text-secondary">(range <?= vsValue('usual_weight_in_pounds_min', $patient) ?> to <?= vsValue('usual_weight_in_pounds_max', $patient) ?>)</span>
+</div>
+
+<div class="mb-3 ml-3">
+    <span class="text-secondary">BMI (usual):</span>
+    <b><?= vsValue('usual_bmi', $patient) ?></b>
+    <span class="text-secondary"><?= vsValue('usual_bmi_category', $patient) ?></span>
+</div>
+
+<div class="mb-1">
+    <span class="text-secondary">Weight (ideal):</span>
+    <b><?= vsValue('ideal_weight_in_pounds', $patient) ?></b>
+    <span class="text-secondary">(range <?= vsValue('ideal_weight_in_pounds_min', $patient) ?> to <?= vsValue('ideal_weight_in_pounds_max', $patient) ?>)</span>
+</div>
+
+<div class="mb-3 ml-3">
+    <span class="text-secondary">BMI (ideal):</span>
+    <b><?= vsValue('ideal_bmi', $patient) ?></b>
+    <span class="text-secondary"><?= vsValue('ideal_bmi_category', $patient) ?></span>
+</div>
+
+<div class="mb-3">
+    <span class="text-secondary">Goal:</span>
+    <span><?= vsValue('weight_management_goal_category', $patient) ?></span>
+</div>
+<!--<div class="mb-3">
+    <span class="text-secondary">Remarks:</span>
+    <span>___</span>
+</div>-->
+
+<div class="mb-3">
+    <span class="text-secondary">CHF?:</span>
+    <span><?= vsValue('has_heart_failure_dx', $patient) ?></span>
+</div>
+
+<div class="mb-2">
+    <span class="text-secondary">ICDs:</span>
+    <?php
+    $icds = [];
+    for ($i = 1; $i <= 4; $i++) {
+        if($patient->{'why_is_weight_monitoring_needed_icd' . $i}) {
+            $icd = '[' . $patient->{'why_is_weight_monitoring_needed_icd' . $i} . ']';
+            if($patient->{'why_is_weight_monitoring_needed_description' . $i}) {
+                $icd .= ' ' . $patient->{'why_is_weight_monitoring_needed_description' . $i};
+            }
+            $icds[] = $icd;
+        }
+    }
+    $icds = implode(', ', $icds);
+    ?>
+    <span>{{$icds}}</span>
+</div>
+

+ 298 - 0
resources/views/app/patient/vitals-settings/bp-management-form.blade.php

@@ -0,0 +1,298 @@
+<div moe large>
+    <a href="#" start show>Update</a>
+    <form url="/api/client/updateBpManagementSettingsValue">
+        <input type="hidden" name="uid" value="{{$patient->uid}}">
+        <p class="text-secondary font-weight-bold font-size-14">BP Management</p>
+
+        <div class="text-secondary font-weight-bold mb-3">Usual BP:</div>
+        <div class="pl-3 mb-2">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-sun"></i>
+                AM
+            </div>
+            <div class="pl-3">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-70px">SBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_sbp', 'number', 'usualAmRestingSbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_sbp_min', 'number', 'usualAmRestingSbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_am_resting_sbp_max', 'number', 'usualAmRestingSbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-70px">DBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_dbp', 'number', 'usualAmRestingDbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_dbp_min', 'number', 'usualAmRestingDbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_am_resting_dbp_max', 'number', 'usualAmRestingDbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-70px">Pulse:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_pulse', 'number', 'usualAmRestingPulse', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_am_resting_pulse_min', 'number', 'usualAmRestingPulseMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_am_resting_pulse_max', 'number', 'usualAmRestingPulseMax', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+        <div class="pl-3 mb-3">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-moon"></i>
+                PM
+            </div>
+            <div class="pl-3">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-70px">SBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_sbp', 'number', 'usualPmRestingSbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_sbp_min', 'number', 'usualPmRestingSbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_pm_resting_sbp_max', 'number', 'usualPmRestingSbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-70px">DBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_dbp', 'number', 'usualPmRestingDbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_dbp_min', 'number', 'usualPmRestingDbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_pm_resting_dbp_max', 'number', 'usualPmRestingDbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-70px">Pulse:</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_pulse', 'number', 'usualPmRestingPulse', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('usual_pm_resting_pulse_min', 'number', 'usualPmRestingPulseMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('usual_pm_resting_pulse_max', 'number', 'usualPmRestingPulseMax', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+        <hr class="my-3">
+
+        <div class="text-secondary font-weight-bold mb-3">Ideal BP:</div>
+        <div class="pl-3 mb-3">
+            <div class="pl-3">
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">SBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_sbp', 'number', 'idealAmRestingSbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_sbp_min', 'number', 'idealAmRestingSbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('ideal_am_resting_sbp_max', 'number', 'idealAmRestingSbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <select class="form-control form-control-sm min-width-unset rounded-0" name="sbpManagementGoalCategory">
+                            <option value="">-- select --</option>
+                            <option {{$patient->sbp_management_goal_category === 'LOWER' ? 'selected' : ''}} value="LOWER">Lower</option>
+                            <option {{$patient->sbp_management_goal_category === 'INCREASE' ? 'selected' : ''}} value="INCREASE">Increase</option>
+                            <option {{$patient->sbp_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">DBP:</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_dbp', 'number', 'idealAmRestingDbp', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_dbp_min', 'number', 'idealAmRestingDbpMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('ideal_am_resting_dbp_max', 'number', 'idealAmRestingDbpMax', $patient) ?></div>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <select class="form-control form-control-sm min-width-unset rounded-0" name="dbpManagementGoalCategory">
+                            <option value="">-- select --</option>
+                            <option {{$patient->dbp_management_goal_category === 'LOWER' ? 'selected' : ''}} value="LOWER">Lower</option>
+                            <option {{$patient->dbp_management_goal_category === 'INCREASE' ? 'selected' : ''}} value="INCREASE">Increase</option>
+                            <option {{$patient->dbp_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">Pulse:</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_pulse', 'number', 'idealAmRestingPulse', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center text-sm">ranging between</span>
+                    <div class="width-70px mr-2"><?= vsElement('ideal_am_resting_pulse_min', 'number', 'idealAmRestingPulseMin', $patient) ?></div>
+                    <span class="text-secondary mr-2">and</span>
+                    <div class="width-70px"><?= vsElement('ideal_am_resting_pulse_max', 'number', 'idealAmRestingPulseMax', $patient) ?></div>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary min-width-70px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <select class="form-control form-control-sm min-width-unset rounded-0" name="pulseManagementGoalCategory">
+                            <option value="">-- select --</option>
+                            <option {{$patient->pulse_management_goal_category === 'LOWER' ? 'selected' : ''}} value="LOWER">Lower</option>
+                            <option {{$patient->pulse_management_goal_category === 'INCREASE' ? 'selected' : ''}} value="INCREASE">Increase</option>
+                            <option {{$patient->pulse_management_goal_category === 'MAINTAIN' ? 'selected' : ''}} value="MAINTAIN">Maintain</option>
+                        </select>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <hr class="my-3">
+
+        <div class="text-secondary font-weight-bold mb-3">Alerts</div>
+        <div class="pl-3 mb-3">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-circle text-danger"></i>
+                Red
+            </div>
+            <div class="pl-3">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">SBP: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_sbp_above', 'number', 'redAlertWhenSbpAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_sbp_below', 'number', 'redAlertWhenSbpBelow', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">DBP: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_dbp_above', 'number', 'redAlertWhenDbpAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_dbp_below', 'number', 'redAlertWhenDbpBelow', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">Pulse: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_pulse_above', 'number', 'redAlertWhenPulseAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('red_alert_when_pulse_below', 'number', 'redAlertWhenPulseBelow', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+        <div class="pl-3 mb-2">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-circle text-warning-mellow"></i>
+                Yellow
+            </div>
+            <div class="pl-3">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">SBP: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_sbp_above', 'number', 'yellowAlertWhenSbpAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_sbp_below', 'number', 'yellowAlertWhenSbpBelow', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">DBP: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_dbp_above', 'number', 'yellowAlertWhenDbpAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_dbp_below', 'number', 'yellowAlertWhenDbpBelow', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary width-100px">Pulse: above</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_pulse_above', 'number', 'yellowAlertWhenPulseAbove', $patient) ?></div>
+                    <span class="text-secondary mr-2 text-center">or below</span>
+                    <div class="width-70px mr-2"><?= vsElement('yellow_alert_when_pulse_below', 'number', 'yellowAlertWhenPulseBelow', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+        <hr class="my-3">
+
+        <div class="mb-2 d-flex align-items-start">
+            <span class="text-secondary min-width-140px w-50">Reports prehypertension?</span>
+            <div class="w-50">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="hasPrehypertensionDx">
+                    <option value="">-- select --</option>
+                    <option {{$patient->has_prehypertension_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->has_prehypertension_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->has_prehypertension_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+        <div class="mb-2 d-flex align-items-start">
+            <span class="text-secondary min-width-140px w-50">Reports hypertension?</span>
+            <div class="w-50">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="hasHypertensionDx">
+                    <option value="">-- select --</option>
+                    <option {{$patient->has_hypertension_dx === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->has_hypertension_dx === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->has_hypertension_dx === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+        <div class="mb-2 d-flex align-items-start">
+            <span class="text-secondary min-width-140px w-50">Reports hypertension medicine?</span>
+            <div class="w-50">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="isPrescribedHypertensionMedicine">
+                    <option value="">-- select --</option>
+                    <option {{$patient->is_prescribed_hypertension_medicine === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->is_prescribed_hypertension_medicine === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->is_prescribed_hypertension_medicine === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+        <div class="mb-2 d-flex align-items-start">
+            <span class="text-secondary min-width-140px w-50">Is it a goal to reduce<br>hypertension medicine?</span>
+            <div class="w-50">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="isGoalToReduceHypertensionMedicine">
+                    <option value="">-- select --</option>
+                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->is_goal_to_reduce_hypertension_medicine === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+
+        <div class="text-secondary min-width-140px mb-1">Describe the goal:</div>
+        <input type="text" class="form-control form-control-sm min-width-unset" name="goalToReduceHypertensionMedicineMemo" value="{{$patient->goal_to_reduce_hypertension_medicine_memo}}">
+
+        <div class="my-3 d-flex align-items-center">
+            <span class="text-secondary min-width-140px w-50">BP monitoring prescribed?</span>
+            <div class="w-50">
+                <select type="text" class="form-control form-control-sm min-width-unset" name="isBpMonitoringNeeded">
+                    <option value="">-- select --</option>
+                    <option {{$patient->is_bp_monitoring_needed === 'YES' ? 'selected' : ''}} value="YES">Yes</option>
+                    <option {{$patient->is_bp_monitoring_needed === 'NO' ? 'selected' : ''}} value="NO">No</option>
+                    <option {{$patient->is_bp_monitoring_needed === 'UNKNOWN' ? 'selected' : ''}} value="UNKNOWN">Unknown</option>
+                </select>
+            </div>
+        </div>
+
+        <hr class="my-3">
+
+        <div class="text-secondary min-width-140px mb-1">ICDs</div>
+        <table class="table table-sm table-striped table-bordered mb-3">
+            <thead>
+            <tr class="bg-light text-secondary">
+                <th class="border-bottom-0 width-30px">#</th>
+                <th class="border-bottom-0 w-25">Code</th>
+                <th class="border-bottom-0">Description</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr>
+                <td class="p-0 align-middle text-center">1</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_icd1', 'text', 'whyIsBpMonitoringNeededIcd1', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_description1', 'text', 'whyIsBpMonitoringNeededDescription1', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">2</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_icd2', 'text', 'whyIsBpMonitoringNeededIcd2', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_description2', 'text', 'whyIsBpMonitoringNeededDescription2', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">3</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_icd3', 'text', 'whyIsBpMonitoringNeededIcd3', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_description3', 'text', 'whyIsBpMonitoringNeededDescription3', $patient) ?></td>
+            </tr>
+            <tr>
+                <td class="p-0 align-middle text-center">4</td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_icd4', 'text', 'whyIsBpMonitoringNeededIcd4', $patient) ?></td>
+                <td class="p-0 align-middle text-center"><?= vsElement('why_is_bp_monitoring_needed_description4', 'text', 'whyIsBpMonitoringNeededDescription4', $patient) ?></td>
+            </tr>
+            </tbody>
+        </table>
+
+        <div class="text-secondary min-width-140px mb-1">Remarks on clinical need:</div>
+        <input type="text" class="form-control form-control-sm min-width-unset" name="whyIsBpMonitoringNeeded" value="{{$patient->why_is_bp_monitoring_needed}}">
+
+
+
+        <div class="pt-2">
+            <button class="btn btn-success btn-sm" submit>Submit</button>
+            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        </div>
+    </form>
+</div>

+ 258 - 0
resources/views/app/patient/vitals-settings/bp-management-summary.blade.php

@@ -0,0 +1,258 @@
+<div class="row">
+    <div class="col-6 border-right">
+        <div class="text-secondary font-weight-bold mb-3">Usual BP:</div>
+        <div class=" mb-3">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-sun"></i>
+                AM
+            </div>
+            <div class="">
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">SBP:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_am_resting_sbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_am_resting_sbp_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_am_resting_sbp_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">DBP:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_am_resting_dbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_am_resting_dbp_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_am_resting_dbp_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">Pulse:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_am_resting_pulse', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_am_resting_pulse_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_am_resting_pulse_max', $patient) ?>)</span>
+                </div>
+            </div>
+        </div>
+        <div class=" ">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-moon"></i>
+                PM
+            </div>
+            <div class="">
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">SBP:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_pm_resting_sbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_pm_resting_sbp_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_pm_resting_sbp_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">DBP:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_pm_resting_dbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_pm_resting_dbp_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_pm_resting_dbp_max', $patient) ?>)</span>
+                </div>
+                <div class="d-flex align-items-center">
+                    <span class="text-secondary width-50px">Pulse:</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('usual_pm_resting_pulse', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('usual_pm_resting_pulse_min', $patient) ?>
+                    to
+                    <?= vsValue('usual_pm_resting_pulse_max', $patient) ?>)</span>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="col-6">
+        <div class="text-secondary font-weight-bold mb-3">Ideal BP:</div>
+        <div class=" ">
+            <div class="">
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">SBP:</span>
+                    <div class="font-weight-bold"><?= vsValue('ideal_am_resting_sbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('ideal_am_resting_sbp_min', $patient) ?>
+                    to
+                    <?= vsValue('ideal_am_resting_sbp_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary width-50px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <?= vsValue('sbp_management_goal_category', $patient) ?>
+                    </div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">DBP:</span>
+                    <div class="font-weight-bold"><?= vsValue('ideal_am_resting_dbp', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('ideal_am_resting_dbp_min', $patient) ?>
+                    to
+                    <?= vsValue('ideal_am_resting_dbp_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary width-50px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <?= vsValue('dbp_management_goal_category', $patient) ?>
+                    </div>
+                </div>
+                <div class="mb-1 d-flex align-items-center">
+                    <span class="text-secondary width-50px">Pulse:</span>
+                    <div class="font-weight-bold"><?= vsValue('ideal_am_resting_pulse', $patient) ?></div>
+                    <span class="text-secondary">(range
+                    <?= vsValue('ideal_am_resting_pulse_min', $patient) ?>
+                    to
+                    <?= vsValue('ideal_am_resting_pulse_max', $patient) ?>)</span>
+                </div>
+                <div class="mb-3 d-flex align-items-center">
+                    <span class="text-secondary width-50px">Goal: &nbsp;</span>
+                    <div class="flex-grow-1">
+                        <?= vsValue('pulse_management_goal_category', $patient) ?>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<hr class="my-3">
+
+<div class="text-secondary font-weight-bold mb-3">Alerts</div>
+
+<div class="row">
+    <div class="col-6 border-right">
+        <div class="">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-circle text-danger"></i>
+                Red
+            </div>
+            <div class="">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary">SBP: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_sbp_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_sbp_below', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary">DBP: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_dbp_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_dbp_below', $patient) ?></div>
+                </div>
+                <div class="d-flex align-items-center">
+                    <span class="text-secondary">Pulse: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_pulse_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('red_alert_when_pulse_below', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="col-6">
+        <div class="">
+            <div class="text-secondary font-weight-bold mb-2">
+                <i class="fa fa-circle text-warning-mellow"></i>
+                Yellow
+            </div>
+            <div class="">
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary">SBP: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_sbp_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_sbp_below', $patient) ?></div>
+                </div>
+                <div class="mb-2 d-flex align-items-center">
+                    <span class="text-secondary">DBP: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_dbp_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_dbp_below', $patient) ?></div>
+                </div>
+                <div class="d-flex align-items-center">
+                    <span class="text-secondary">Pulse: above</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_pulse_above', $patient) ?></div>
+                    <span class="text-secondary text-center">or below</span>
+                    <div class="px-2 font-weight-bold"><?= vsValue('yellow_alert_when_pulse_below', $patient) ?></div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<hr class="my-3">
+
+<div class="row mb-2">
+    <div class="col-6 border-right">
+        <div class="d-flex align-items-start">
+            <span class="text-secondary min-width-140px pr-3">Reports prehypertension?</span>
+            <div>
+                <?= vsValue('has_prehypertension_dx', $patient) ?>
+            </div>
+        </div>
+    </div>
+    <div class="col-6">
+        <div class="d-flex align-items-start">
+            <span class="text-secondary min-width-140px pr-3">Reports hypertension?</span>
+            <div>
+                <?= vsValue('has_hypertension_dx', $patient) ?>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="row mb-2">
+    <div class="col-6 border-right">
+        <div class="d-flex align-items-start">
+            <span class="text-secondary min-width-140px pr-3">Reports hypertension medicine?</span>
+            <div>
+                <?= vsValue('is_prescribed_hypertension_medicine', $patient) ?>
+            </div>
+        </div>
+    </div>
+    <div class="col-6">
+        <div class="d-flex align-items-start">
+            <span class="text-secondary min-width-140px pr-3">Is it a goal to reduce<br>hypertension medicine?</span>
+            <div>
+                <?= vsValue('is_goal_to_reduce_hypertension_medicine', $patient) ?>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="row mb-2">
+    <div class="col-6 border-right">
+        <div class="d-flex align-items-start">
+            <span class="text-secondary min-width-140px pr-3">Describe the goal</span>
+            <div>
+                <?= vsValue('goal_to_reduce_hypertension_medicine_memo', $patient) ?>
+            </div>
+        </div>
+    </div>
+    <div class="col-6">
+        <div class="d-flex align-items-center">
+            <span class="text-secondary min-width-140px pr-3">BP monitoring prescribed?</span>
+            <div>
+                <?= vsValue('is_bp_monitoring_needed', $patient) ?>
+            </div>
+        </div>
+    </div>
+</div>
+
+<hr class="my-3">
+
+<div class="mb-2">
+    <span class="text-secondary">ICDs:</span>
+    <?php
+    $icds = [];
+    for ($i = 1; $i <= 4; $i++) {
+        if($patient->{'why_is_bp_monitoring_needed_icd' . $i}) {
+            $icd = '[' . $patient->{'why_is_bp_monitoring_needed_icd' . $i} . ']';
+            if($patient->{'why_is_bp_monitoring_needed_description' . $i}) {
+                $icd .= ' ' . $patient->{'why_is_bp_monitoring_needed_description' . $i};
+            }
+            $icds[] = $icd;
+        }
+    }
+    $icds = implode(', ', $icds);
+    ?>
+    <span>{{$icds}}</span>
+</div>

+ 10 - 0
resources/views/app/patients.blade.php

@@ -68,6 +68,7 @@
                     <th class="border-0">Patient</th>
                     <th class="border-0 px-1">OB</th>
                     <th class="border-0">Signed<br>Notes</th>
+                    <th class="border-0">CM<br>Setup</th>
                     <th class="border-0">Created At</th>
 		            <th class="border-0">Address</th>
                     @if($showProgramsColumn)<th class="border-0">Program(s)</th>@endif
@@ -108,6 +109,15 @@
                                 {{$numSignedNotes ? $numSignedNotes :'-'}}
                             </span>
                         </td>
+                        <td>
+                            @if($patient->has_cm_setup_been_performed)
+                                <i class="fa fa-check text-secondary on-hover-opaque"></i>
+                                <br>
+                                <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote])}}">Note</a>
+                            @else
+                                -
+                            @endif
+                        </td>
                         <td>
                             {{ friendly_date_time_short_with_tz($patient->created_at, true, 'EASTERN') }}
                             <hr>

+ 1 - 0
routes/web.php

@@ -307,6 +307,7 @@ Route::middleware('pro.auth')->group(function () {
 
     Route::get('/point/review-log/{point}', 'NoteController@reviewLog')->name('point-review-log');
     Route::get('/point/plan-log/{point}', 'NoteController@planLog')->name('point-plan-log');
+    Route::get('/note/pdf/{note}', 'NoteController@downloadAsPdf')->name('note-pdf');
 
     //mb claim single view
     Route::get('mb-claims/view/{mbClaim}', 'PatientController@mbClaim')->name('mb-claim');

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.