Explorar o código

All wizard - divisions and badges as per new spec

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
e37306c89f

+ 34 - 32
app/Models/Point.php

@@ -170,24 +170,21 @@ class Point extends Model
     public static function getPointsOfCategoryExtended(Client $_patient, String $_category, Note $_note) {
         $points = Point
             ::where('client_id', $_patient->id)
-            ->where('category', $_category)
-            ->where(function ($q) use($_note) {
-                $q
-                    ->where('is_removed_due_to_entry_error', false)
-                    ->orWhere('removed_in_note_id', '<>', $_note->id);
-            })
-            ->orderBy('is_removed')
-            ->orderBy('added_in_note_id', 'DESC')
-            ->orderBy('removal_effective_date', 'DESC')
-            ->orderByRaw('removed_in_note_id DESC NULLS FIRST')
-            ->orderBy('created_at')
-            ->get();
+            ->where('category', $_category);
+
+        if($_category !== 'GOAL') {
+            $points = $points->orderByRaw("((data)::json->'name')::text ASC");
+        }
+        else {
+            $points = $points->orderByRaw("((data)::json->'goal')::text ASC");
+        }
+
+        $points = $points->get();
 
         $pointsByType = [
-            "new" => [],
-            "preExisting" => [],
-            "historic" => [],
-            "eeFromOtherNote" => []
+            "ACTIVE" => [],
+            "HISTORIC" => [],
+            "ENTRY_ERROR" => [],
         ];
 
         foreach ($points as $point) {
@@ -195,26 +192,31 @@ class Point extends Model
                 $point->data = json_decode($point->data);
             }
 
-            if(!$point->is_removed && $point->added_in_note_id === $_note->id) {
-                $point->state = 1;
-                $pointsByType["new"][] = $point;
-            }
-            elseif(!$point->is_removed && $point->added_in_note_id !== $_note->id) {
-                $point->state = 2;
-                $pointsByType["preExisting"][] = $point;
+            if(!$point->is_removed) {
+                $point->state = "ACTIVE";
+                $pointsByType["ACTIVE"][] = $point;
             }
-            elseif($point->is_removed && !$point->is_removed_due_to_entry_error) {
-                $point->state = 3;
-                $pointsByType["historic"][] = $point;
-            }
-            elseif($point->is_removed_due_to_entry_error) {
-                $point->state = 4;
-                $pointsByType["eeFromOtherNote"][] = $point;
+            elseif($point->is_removed) {
+                if(!$point->is_removed_due_to_entry_error) {
+                    $point->state = "HISTORIC";
+                    $pointsByType["HISTORIC"][] = $point;
+                }
+                else {
+                    $point->state = "ENTRY_ERROR";
+                    $pointsByType["ENTRY_ERROR"][] = $point;
+                }
             }
         }
 
-        $points = array_merge($pointsByType["new"], $pointsByType["preExisting"], $pointsByType["historic"], $pointsByType["eeFromOtherNote"]);
+        $points = array_merge($pointsByType["ACTIVE"], $pointsByType["HISTORIC"], $pointsByType["ENTRY_ERROR"]);
 
-        return $points;
+        return [
+            $points,
+            [
+                "ACTIVE" => count($pointsByType["ACTIVE"]),
+                "HISTORIC" => count($pointsByType["HISTORIC"]),
+                "ENTRY_ERROR" => count($pointsByType["ENTRY_ERROR"]),
+            ]
+        ];
     }
 }

+ 7 - 54
resources/views/app/patient/allergies-center.blade.php

@@ -8,14 +8,13 @@ use App\Models\Segment;
 /** @var Client $patient */
 /** @var Note $note */
 
-$allergies = Point::getPointsOfCategoryExtended($patient, 'ALLERGY', $note);
+list($allergies, $counts) = Point::getPointsOfCategoryExtended($patient, 'ALLERGY', $note);
 ?>
 
 <div class="mt-3 p-3 border-top min-height-500px" id="allergies-center-{{$note->id}}">
     <div>
 
-        <div class="mb-2 font-weight-bold font-size-14 text-secondary">Allergies</div>
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -33,67 +32,21 @@ $allergies = Point::getPointsOfCategoryExtended($patient, 'ALLERGY', $note);
             <?php $prevRowState = -1; ?>
             <?php foreach($allergies as $allergy): ?>
             <?php $point = $allergy; ?>
-            @if($prevRowState !== -1 && $prevRowState !== $allergy->state)
-                <tr>
-                    <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
-                </tr>
+            @if($prevRowState !== $allergy->state)
+                @include('app.patient.wizard-partials.state-row', ['point' => $allergy])
             @endif
             <?php $prevRowState = $allergy->state; ?>
             <?php $rel = $allergy->relevanceToNote($note); ?>
             <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
                 @if($patient->core_note_id !== $note->id)
-                <td class="text-center">
-                    <a href="#" class="toggle-relevance"
-                       data-relevant="{{$rel ? '1' : '0'}}"
-                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
-                       data-point-uid="{{$allergy->uid}}"
-                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
-                        @if($rel)
-                            <i class="fa fa-star text-sm text-info"></i>
-                        @else
-                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
-                        @endif
-                    </a>
-                </td>
+                    @include('app.patient.wizard-partials.relevance-column', ['point' => $allergy])
                 @endif
                 <td>
                     <div class="d-flex align-items-baseline">
-                        @if($allergy->state === 1)
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($allergy->state === 2)
-                            <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($allergy->state === 3)
-                            <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($allergy->state === 4)
-                            <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
-                        @endif
+                        @include('app.patient.wizard-partials.state-icon', ['point' => $allergy])
                         <div>
                             <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
-                            @if($allergy->added_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Added
-                                    @if($patient->core_note_id !== $note->id)
-                                    during this visit
-                                    @else
-                                    from the patient's chart
-                                    @endif
-                                    @if($allergy->addition_reason_category === 'ON_INTAKE')
-                                        (existing)
-                                    @elseif($allergy->addition_reason_category === 'DURING_VISIT')
-                                        (new)
-                                    @endif
-                                </div>
-                            @endif
-                            @if($allergy->is_removed && $allergy->removed_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Removed
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                </div>
-                            @endif
+                            @include('app.patient.wizard-partials.state-badge', ['point' => $allergy, 'addedVerb' => 'Prescribed', 'removedVerb' => 'Discontinued'])
                         </div>
                     </div>
                 </td>

+ 7 - 53
resources/views/app/patient/careteam-center.blade.php

@@ -8,13 +8,13 @@ use App\Models\Segment;
 /** @var Client $patient */
 /** @var Note $note */
 
-$careTeamMembers = Point::getPointsOfCategoryExtended($patient, 'CARE_TEAM_MEMBER', $note);
+list($careTeamMembers, $counts) = Point::getPointsOfCategoryExtended($patient, 'CARE_TEAM_MEMBER', $note);
 ?>
 
 <div class="mt-3 p-3 border-top min-height-500px" id="careteam-center-{{$note->id}}">
     <div>
 
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -32,67 +32,21 @@ $careTeamMembers = Point::getPointsOfCategoryExtended($patient, 'CARE_TEAM_MEMBE
             <?php $prevRowState = -1; ?>
             <?php foreach($careTeamMembers as $careTeamMember): ?>
             <?php $point = $careTeamMember; ?>
-            @if($prevRowState !== -1 && $prevRowState !== $careTeamMember->state)
-                <tr>
-                    <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
-                </tr>
+            @if($prevRowState !== $careTeamMember->state)
+                @include('app.patient.wizard-partials.state-row', ['point' => $careTeamMember])
             @endif
             <?php $prevRowState = $careTeamMember->state; ?>
             <?php $rel = $careTeamMember->relevanceToNote($note); ?>
             <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
                 @if($patient->core_note_id !== $note->id)
-                <td class="text-center">
-                    <a href="#" class="toggle-relevance"
-                       data-relevant="{{$rel ? '1' : '0'}}"
-                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
-                       data-point-uid="{{$careTeamMember->uid}}"
-                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
-                        @if($rel)
-                            <i class="fa fa-star text-sm text-info"></i>
-                        @else
-                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
-                        @endif
-                    </a>
-                </td>
+                    @include('app.patient.wizard-partials.relevance-column', ['point' => $careTeamMember])
                 @endif
                 <td>
                     <div class="d-flex align-items-baseline">
-                        @if($careTeamMember->state === 1)
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($careTeamMember->state === 2)
-                            <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($careTeamMember->state === 3)
-                            <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($careTeamMember->state === 4)
-                            <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
-                        @endif
+                        @include('app.patient.wizard-partials.state-icon', ['point' => $careTeamMember])
                         <div>
                             <b><?= !!@($careTeamMember->data->name) ? @($careTeamMember->data->name) : '-' ?></b>
-                            @if($careTeamMember->added_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Added
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                    @if($careTeamMember->addition_reason_category === 'ON_INTAKE')
-                                        (existing)
-                                    @elseif($careTeamMember->addition_reason_category === 'DURING_VISIT')
-                                        (new)
-                                    @endif
-                                </div>
-                            @endif
-                            @if($careTeamMember->is_removed && $careTeamMember->removed_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Removed
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                </div>
-                            @endif
+                            @include('app.patient.wizard-partials.state-badge', ['point' => $careTeamMember, 'addedVerb' => 'Prescribed', 'removedVerb' => 'Discontinued'])
                         </div>
                     </div>
                 </td>

+ 7 - 53
resources/views/app/patient/goals-center.blade.php

@@ -8,13 +8,13 @@ use App\Models\Segment;
 /** @var Client $patient */
 /** @var Note $note */
 
-$goals = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
+list($goals, $counts) = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
 ?>
 
 <div class="mt-3 p-3 border-top min-height-500px" id="goals-center-{{$note->id}}">
     <div>
 
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -32,67 +32,21 @@ $goals = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
             <?php $prevRowState = -1; ?>
             <?php foreach($goals as $goal): ?>
             <?php $point = $goal; ?>
-            @if($prevRowState !== -1 && $prevRowState !== $goal->state)
-                <tr>
-                    <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
-                </tr>
+            @if($prevRowState !== $goal->state)
+                @include('app.patient.wizard-partials.state-row', ['point' => $goal])
             @endif
             <?php $prevRowState = $goal->state; ?>
             <?php $rel = $goal->relevanceToNote($note); ?>
             <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
                 @if($patient->core_note_id !== $note->id)
-                <td class="text-center">
-                    <a href="#" class="toggle-relevance"
-                       data-relevant="{{$rel ? '1' : '0'}}"
-                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
-                       data-point-uid="{{$goal->uid}}"
-                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
-                        @if($rel)
-                            <i class="fa fa-star text-sm text-info"></i>
-                        @else
-                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
-                        @endif
-                    </a>
-                </td>
+                    @include('app.patient.wizard-partials.relevance-column', ['point' => $goal])
                 @endif
                 <td>
                     <div class="d-flex align-items-baseline">
-                        @if($goal->state === 1)
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($goal->state === 2)
-                            <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($goal->state === 3)
-                            <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($goal->state === 4)
-                            <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
-                        @endif
+                        @include('app.patient.wizard-partials.state-icon', ['point' => $goal])
                         <div>
                             <b><?= !!@($goal->data->goal) ? @($goal->data->goal) : '-' ?></b>
-                            @if($goal->added_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Added
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                    @if($goal->addition_reason_category === 'ON_INTAKE')
-                                        (existing)
-                                    @elseif($goal->addition_reason_category === 'DURING_VISIT')
-                                        (new)
-                                    @endif
-                                </div>
-                            @endif
-                            @if($goal->is_removed && $goal->removed_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Removed
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                </div>
-                            @endif
+                            @include('app.patient.wizard-partials.state-badge', ['point' => $goal, 'addedVerb' => 'Prescribed', 'removedVerb' => 'Discontinued'])
                         </div>
                     </div>
                 </td>

+ 247 - 293
resources/views/app/patient/medications-center.blade.php

@@ -8,14 +8,14 @@ use App\Models\Segment;
 /** @var Client $patient */
 /** @var Note $note */
 
-$medications = Point::getPointsOfCategoryExtended($patient, 'MEDICATION', $note);
+list($medications, $counts) = Point::getPointsOfCategoryExtended($patient, 'MEDICATION', $note);
 
 ?>
 
 <div class="mt-3 p-3 border-top min-height-500px" id="medications-center-{{$note->id}}">
     <div>
 
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -32,322 +32,276 @@ $medications = Point::getPointsOfCategoryExtended($patient, 'MEDICATION', $note)
             </thead>
             <?php $prevRowState = -1; ?>
             <?php foreach($medications as $medication): ?>
-            <?php $point = $medication; ?>
-            @if($prevRowState !== -1 && $prevRowState !== $medication->state)
-                <tr>
-                    <td colspan="10" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
-                </tr>
-            @endif
-            <?php $prevRowState = $medication->state; ?>
-            <?php $rel = $medication->relevanceToNote($note); ?>
-            <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
-                @if($patient->core_note_id !== $note->id)
-                <td class="text-center">
-                    <a href="#" class="toggle-relevance"
-                       data-relevant="{{$rel ? '1' : '0'}}"
-                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
-                       data-point-uid="{{$medication->uid}}"
-                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
-                        @if($rel)
-                            <i class="fa fa-star text-sm text-info"></i>
-                        @else
-                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
-                        @endif
-                    </a>
-                </td>
+                <?php $point = $medication; ?>
+                @if($prevRowState !== $medication->state)
+                    @include('app.patient.wizard-partials.state-row', ['point' => $medication])
                 @endif
-                <td>
-                    <div class="d-flex align-items-baseline">
-                        @if($medication->state === 1)
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($medication->state === 2)
-                            <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($medication->state === 3)
-                            <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($medication->state === 4)
-                            <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
-                        @endif
-                        <div>
-                            <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
-                            @if($medication->added_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Added
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                    @if($medication->addition_reason_category === 'ON_INTAKE')
-                                        (existing)
-                                    @elseif($medication->addition_reason_category === 'DURING_VISIT')
-                                        (new)
-                                    @endif
-                                </div>
-                            @endif
-                            @if($medication->is_removed && $medication->removed_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Discontinued
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                </div>
-                            @endif
+                <?php $prevRowState = $medication->state; ?>
+                <?php $rel = $medication->relevanceToNote($note); ?>
+                <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
+                    @if($patient->core_note_id !== $note->id)
+                        @include('app.patient.wizard-partials.relevance-column', ['point' => $medication])
+                    @endif
+                    <td>
+                        <div class="d-flex align-items-baseline">
+                            @include('app.patient.wizard-partials.state-icon', ['point' => $medication])
+                            <div>
+                                <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
+                                @include('app.patient.wizard-partials.state-badge', ['point' => $medication, 'addedVerb' => 'Prescribed', 'removedVerb' => 'Discontinued'])
+                            </div>
                         </div>
-                    </div>
-                </td>
-                <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            $point = $medication;
-                            include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                            ?>
+                    </td>
+                    <td>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                $point = $medication;
+                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-nowrap">
+                                <a class="pl-2 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Review log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                                   href="/point/review-log/<?= $medication->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                            </div>
                         </div>
-                        <div class="d-inline-flex flex-nowrap">
-                            <a class="pl-2 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Review log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
-                               href="/point/review-log/<?= $medication->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
+                    </td>
+                    <td>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-nowrap">
+                                <a class="pl-2 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Plan log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                                   href="/point/plan-log/<?= $medication->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                /*$segment = $note->getSegmentByInternalName('plan_medications');
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                }*/
+                                ?>
+                            </div>
                         </div>
-                    </div>
-                </td>
-                <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                            ?>
+                    </td>
+                    <td>
+                        @if($medication->is_removed)
+                            NO
+                        @else
+                            <b>YES</b>
+                        @endif
+                    </td>
+                    <td>
+                        <?= !!@($medication->data->start_date) ? friendly_date($medication->data->start_date) : '-' ?>
+                        @if(!!@($medication->data->prescriber))
+                            <div class="mt-1 text-sm text-secondary">By: <?= !!@($medication->data->prescriber) ? @($medication->data->prescriber) : '-' ?></div>
+                        @endif
+                    </td>
+                    <td>
+                        <?= !!@($medication->removal_effective_date) ? friendly_date($medication->removal_effective_date) : '-' ?>
+                        @if(!!@($medication->removal_reason_memo))
+                            <div class="mt-1 text-sm text-secondary">By: <?= !!@($medication->removal_reason_memo) ? @($medication->removal_reason_memo) : '-' ?></div>
+                        @endif
+                    </td>
+                    <td>
+                        <div moe huge relative>
+                            <a start show href="#" title="Edit">Edit</a>
+                            <form url="/api/visitPoint/updateTopLevel" class="mcp-theme-1 frm-edit-medication" right>
+                                <input type="hidden" name="uid" value="<?= $medication->uid ?>">
+                                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                                <p class="mb-2"><b>Update Medication</b></p>
+
+                                <input type="hidden" name="data" value='{{json_encode($medication->data)}}'>
+
+                                @if($medication->added_in_note_id === $note->id)
+
+                                    <input type="hidden" data-name="medId" value="{{@$medication->data->medId}}">
+                                    <input type="hidden" data-name="routedMedId" value="{{@$medication->data->routedMedId}}">
+                                    <input type="hidden" data-name="routedDosageFormMedId" value="{{@$medication->data->routedDosageFormMedId}}">
+                                    <input type="hidden" data-name="gcnSeqno" value="{{@$medication->data->gcnSeqno}}">
+
+                                    <div class="mb-2">
+                                        <label class="text-sm mb-1 font-weight-bold">Drug</label>
+                                        <input type="text" class="form-control form-control-sm min-width-unset prescription-medication"
+                                               data-name="name"
+                                               value="{{@$medication->data->name}}"
+                                               stag-suggest
+                                               stag-suggest-ep="/fdb-med-suggest-v2/json">
+                                    </div>
+
+                                @else
+
+                                    <div class="mb-2 bg-light p-2 border">
+                                        <p class="mb-1 font-weight-bold">
+                                        {{ @$medication->data->name }}
+                                        </p>
+                                        @if($patient->core_note_id !== $note->id)
+                                            <div class="text-secondary text-sm">Clinical details cannot be modified since the medication was added prior to this visit.</div>
+                                        @else
+                                            <div class="text-secondary text-sm">Clinical details cannot be modified since the medication was added on a previous visit.</div>
+                                        @endif
+                                    </div>
+
+                                @endif
+
+                                @include('app.patient.wizard-partials.common-fields', ['label' => 'medication', 'point' => $medication, 'addVerbPT' => 'Prescribed', 'planLabel' => 'Directions/Plan'])
+
+                                <div class="mt-3 pt-2 d-flex align-items-center border-top">
+                                    <button type="submit" class="btn-save-medication btn btn-sm btn-primary mr-2">Save</button>
+                                    <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
+                                </div>
+                            </form>
                         </div>
-                        <div class="d-inline-flex flex-nowrap">
-                            <a class="pl-2 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Plan log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
-                               href="/point/plan-log/<?= $medication->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            /*$segment = $note->getSegmentByInternalName('plan_medications');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                            }*/
-                            ?>
+                    </td>
+                </tr>
+            <?php endforeach; ?>
+    </table>
+
+    <div class="d-flex align-items-center">
+        <div class="mt-1 w-100 border p-3 bg-aliceblue border-info rounded">
+            <!--<a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new medication, prescribed during this visit</a>-->
+            <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication">
+                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                <input type="hidden" name="category" value="MEDICATION">
+                <input type="hidden" name="data">
+
+                <input type="hidden" data-name="medId">
+                <input type="hidden" data-name="routedMedId">
+                <input type="hidden" data-name="routedDosageFormMedId">
+                <input type="hidden" data-name="gcnSeqno">
+
+                <input type="hidden" name="isRemovedDueToEntryError" value="0">
+
+                <div class="row">
+                    <div class="col-8">
+                        <p class="mb-2"><b>Add Medication</b></p>
+                        <div class="mb-2">
+                            <label class="mb-0 font-weight-bold">Name</label>
+                            <input type="text"
+                                   data-name="name"
+                                   class="form-control form-control-sm"
+                                   stag-suggest
+                                   stag-suggest-bottom-left
+                                   stag-suggest-ep="/fdb-med-suggest-v2/json"
+                                   required>
                         </div>
-                    </div>
-                </td>
-                <td>
-                    @if($medication->is_removed)
-                        NO
-                    @else
-                        <b>YES</b>
-                    @endif
-                </td>
-                <td>
-                    <?= !!@($medication->data->start_date) ? friendly_date($medication->data->start_date) : '-' ?>
-                    @if(!!@($medication->data->prescriber))
-                        <div class="mt-1 text-sm text-secondary">By: <?= !!@($medication->data->prescriber) ? @($medication->data->prescriber) : '-' ?></div>
-                    @endif
-                </td>
-                <td>
-                    <?= !!@($medication->removal_effective_date) ? friendly_date($medication->removal_effective_date) : '-' ?>
-                    @if(!!@($medication->removal_reason_memo))
-                        <div class="mt-1 text-sm text-secondary">By: <?= !!@($medication->removal_reason_memo) ? @($medication->removal_reason_memo) : '-' ?></div>
-                    @endif
-                </td>
-                <td>
-                    <div moe huge relative>
-                        <a start show href="#" title="Edit">Edit</a>
-                        <form url="/api/visitPoint/updateTopLevel" class="mcp-theme-1 frm-edit-medication" right>
-                            <input type="hidden" name="uid" value="<?= $medication->uid ?>">
-                            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-                            <p class="mb-2"><b>Update Medication</b></p>
-
-                            <input type="hidden" name="data" value='{{json_encode($medication->data)}}'>
-
-                            @if($medication->added_in_note_id === $note->id)
-
-                                <input type="hidden" data-name="medId" value="{{@$medication->data->medId}}">
-                                <input type="hidden" data-name="routedMedId" value="{{@$medication->data->routedMedId}}">
-                                <input type="hidden" data-name="routedDosageFormMedId" value="{{@$medication->data->routedDosageFormMedId}}">
-                                <input type="hidden" data-name="gcnSeqno" value="{{@$medication->data->gcnSeqno}}">
-
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 font-weight-bold">Drug</label>
-                                    <input type="text" class="form-control form-control-sm min-width-unset prescription-medication"
-                                           data-name="name"
-                                           value="{{@$medication->data->name}}"
-                                           stag-suggest
-                                           stag-suggest-ep="/fdb-med-suggest-v2/json">
-                                </div>
-
-                            @else
-
-                                <div class="mb-2 bg-light p-2 border">
-                                    <p class="mb-1 font-weight-bold">
-                                    {{ @$medication->data->name }}
-                                    </p>
-                                    @if($patient->core_note_id !== $note->id)
-                                        <div class="text-secondary text-sm">Clinical details cannot be modified since the medication was added prior to this visit.</div>
-                                    @else
-                                        <div class="text-secondary text-sm">Clinical details cannot be modified since the medication was added on a previous visit.</div>
-                                    @endif
-                                </div>
-
-                            @endif
 
-                            @include('app.patient.wizard-partials.common-fields', ['label' => 'medication', 'point' => $medication, 'addVerbPT' => 'Prescribed', 'planLabel' => 'Directions/Plan'])
+                        <?php $point = null; ?>
+                        @include('app.patient.wizard-partials.common-fields', ['label' => 'medication', 'addVerbPT' => 'Prescribed', 'planLabel' => 'Directions/Plan'])
 
-                            <div class="mt-3 pt-2 d-flex align-items-center border-top">
-                                <button type="submit" class="btn-save-medication btn btn-sm btn-primary mr-2">Save</button>
-                                <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
-                            </div>
-                        </form>
                     </div>
-                </td>
-            </tr>
-            <?php endforeach; ?>
-        </table>
-
-        <div class="d-flex align-items-center">
-            <div class="mt-1 w-100 border p-3 bg-aliceblue border-info rounded">
-                <!--<a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new medication, prescribed during this visit</a>-->
-                <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication">
-                    <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-                    <input type="hidden" name="category" value="MEDICATION">
-                    <input type="hidden" name="data">
-
-                    <input type="hidden" data-name="medId">
-                    <input type="hidden" data-name="routedMedId">
-                    <input type="hidden" data-name="routedDosageFormMedId">
-                    <input type="hidden" data-name="gcnSeqno">
-
-                    <input type="hidden" name="isRemovedDueToEntryError" value="0">
-
-                    <div class="row">
-                        <div class="col-8">
-                            <p class="mb-2"><b>Add Medication</b></p>
-                            <div class="mb-2">
-                                <label class="mb-0 font-weight-bold">Name</label>
-                                <input type="text"
-                                       data-name="name"
-                                       class="form-control form-control-sm"
-                                       stag-suggest
-                                       stag-suggest-bottom-left
-                                       stag-suggest-ep="/fdb-med-suggest-v2/json"
-                                       required>
+                    <div class="col-4 border-left">
+
+                        <?php
+                        $problems = \App\Models\Point::getPointsOfCategory($patient, "PROBLEM");
+                        ?>
+                        @if(count($problems))
+                            <h6 class="my-0 font-weight-bold text-secondary mb-2">Active Problems</h6>
+                            <div class="bg-light border px-2 pt-2 pb-1 mb-0">
+                                @foreach($problems as $problem)
+                                    <div class="mb-1">
+                                        <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
+                                    </div>
+                                @endforeach
                             </div>
+                            <hr class="my-3 m-neg-3">
+                        @endif
 
-                            <?php $point = null; ?>
-                            @include('app.patient.wizard-partials.common-fields', ['label' => 'medication', 'addVerbPT' => 'Prescribed', 'planLabel' => 'Directions/Plan'])
-
-                        </div>
-                        <div class="col-4 border-left">
-
-                            <?php
-                            $problems = \App\Models\Point::getPointsOfCategory($patient, "PROBLEM");
-                            ?>
-                            @if(count($problems))
-                                <h6 class="my-0 font-weight-bold text-secondary mb-2">Active Problems</h6>
-                                <div class="bg-light border px-2 pt-2 pb-1 mb-0">
-                                    @foreach($problems as $problem)
-                                        <div class="mb-1">
-                                            <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
-                                        </div>
-                                    @endforeach
-                                </div>
-                                <hr class="my-3 m-neg-3">
-                            @endif
-
-                            <div class="fdb-rx-vigilance max-height-400px overflow-auto">
+                        <div class="fdb-rx-vigilance max-height-400px overflow-auto">
 
-                            </div>
                         </div>
                     </div>
+                </div>
 
-                    <div class="d-flex align-items-center">
-                        <button type="submit" class="btn btn-sm btn-primary mr-2">Save Medication</button>
-                        <button type="button" class="btn btn-sm btn-default border-secondary bg-white border mr-2" onclick="return closeStagPopup()">Close</button>
-                    </div>
-                </form>
-            </div>
+                <div class="d-flex align-items-center">
+                    <button type="submit" class="btn btn-sm btn-primary mr-2">Save Medication</button>
+                    <button type="button" class="btn btn-sm btn-default border-secondary bg-white border mr-2" onclick="return closeStagPopup()">Close</button>
+                </div>
+            </form>
         </div>
     </div>
 </div>
+</div>
 
 <script>
-    (function() {
-        function init() {
-            let parentSegment = $('#medications-center-{{$note->id}}');
-            parentSegment.find('input[stag-suggest][data-name="name"]')
-                .off('stag-suggest-selected')
-                .on('stag-suggest-selected', (_e, _input, _data) => {
-                    $(_input).closest('form').find('input[data-name="routedMedId"]').val(_data.routed_med_id);
-                    $(_input).closest('form').find('input[data-name="routedDosageFormMedId"]').val(_data.routed_dosage_form_med_id);
-                    $(_input).closest('form').find('input[data-name="gcnSeqno"]').val(_data.gcn_seqno);
-                    $(_input).closest('form').find('input[data-name="medId"]').val(_data.medid);
-
-                    $('.fdb-rx-vigilance').html('<span class="text-secondary font-italic">Please wait ...</span>');
-                    $.post('/fdb-rx-vigilance/{{$patient->uid}}', {
-                        _token: '{{csrf_token()}}',
-                        medId: _data.medid,
-                        routedMedId: _data.routed_med_id,
-                        routedDosageFormMedId: _data.routed_dosage_form_med_id,
-                        gcnSeqno: _data.gcn_seqno,
-                        name: _input.val(),
-                    }, _data => {
-                        $('.fdb-rx-vigilance').html(_data);
-                    });
-
-                    return false;
+(function() {
+    function init() {
+        let parentSegment = $('#medications-center-{{$note->id}}');
+        parentSegment.find('input[stag-suggest][data-name="name"]')
+            .off('stag-suggest-selected')
+            .on('stag-suggest-selected', (_e, _input, _data) => {
+                $(_input).closest('form').find('input[data-name="routedMedId"]').val(_data.routed_med_id);
+                $(_input).closest('form').find('input[data-name="routedDosageFormMedId"]').val(_data.routed_dosage_form_med_id);
+                $(_input).closest('form').find('input[data-name="gcnSeqno"]').val(_data.gcn_seqno);
+                $(_input).closest('form').find('input[data-name="medId"]').val(_data.medid);
+
+                $('.fdb-rx-vigilance').html('<span class="text-secondary font-italic">Please wait ...</span>');
+                $.post('/fdb-rx-vigilance/{{$patient->uid}}', {
+                    _token: '{{csrf_token()}}',
+                    medId: _data.medid,
+                    routedMedId: _data.routed_med_id,
+                    routedDosageFormMedId: _data.routed_dosage_form_med_id,
+                    gcnSeqno: _data.gcn_seqno,
+                    name: _input.val(),
+                }, _data => {
+                    $('.fdb-rx-vigilance').html(_data);
                 });
 
-            @include('app.patient.wizard-partials.common-script', ['label' => 'medication'])
-
-            // custom buttons on title bar
-            $('.button-container').remove();
-            let buttonContainer = $('<div/>').addClass('button-container ml-auto mr-3');
-            let titleElem = $('#medications-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
-            titleElem.next().removeClass('ml-auto');
-            titleElem.parent().addClass('align-items-baseline');
-
-            // add button for "reconcile active medications"
-            if($('.active-record').length) {
-                $('.btn-reconcile-active').remove();
-                $('<a ' +
-                    'href="/medications-reconcile/{{$patient->uid}}/{{$note->uid}}" ' +
-                    'title="Reconcile Active Medications" ' +
-                    'update-parent ' +
-                    'open-in-stag-popup ' +
-                    'mc-initer="medications-reconcile-{{$note->id}}" ' +
-                    'popup-style="stag-popup-md" ' +
-                    'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
-                    .appendTo(buttonContainer);
-            }
-
-            // add button for "eRx"
-            $('.btn-manage-erx').remove();
+                return false;
+            });
+
+        @include('app.patient.wizard-partials.common-script', ['label' => 'medication'])
+
+        // custom buttons on title bar
+        $('.button-container').remove();
+        let buttonContainer = $('<div/>').addClass('button-container ml-auto mr-3');
+        let titleElem = $('#medications-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+        titleElem.next().removeClass('ml-auto');
+        titleElem.parent().addClass('align-items-baseline');
+
+        // add button for "reconcile active medications"
+        if($('.active-record').length) {
+            $('.btn-reconcile-active').remove();
             $('<a ' +
-                'href="/patients/view/{{$patient->uid}}/prescriptions-popup?noteUid={{$note->uid}}&erx_category=DRUG" ' +
-                'title="Manage eRx" ' +
+                'href="/medications-reconcile/{{$patient->uid}}/{{$note->uid}}" ' +
+                'title="Reconcile Active Medications" ' +
                 'update-parent ' +
                 'open-in-stag-popup ' +
-                'mc-initer="prescriptions-popup-{{$patient->id}}" ' +
-                'popup-style="medium" ' +
-                'class="btn-manage-erx btn btn-sm mr-2 btn-info text-white font-weight-bold">Manage eRx</a>')
+                'mc-initer="medications-reconcile-{{$note->id}}" ' +
+                'popup-style="stag-popup-md" ' +
+                'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
                 .appendTo(buttonContainer);
-
-            buttonContainer.insertAfter(titleElem);
-
-            initSegmentMoes(parentSegment);
-            __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
         }
-        addMCInitializer('medications-center-{{$note->id}}', init, '#medications-center-{{$note->id}}');
-    }).call(window);
+
+        // add button for "eRx"
+        $('.btn-manage-erx').remove();
+        $('<a ' +
+            'href="/patients/view/{{$patient->uid}}/prescriptions-popup?noteUid={{$note->uid}}&erx_category=DRUG" ' +
+            'title="Manage eRx" ' +
+            'update-parent ' +
+            'open-in-stag-popup ' +
+            'mc-initer="prescriptions-popup-{{$patient->id}}" ' +
+            'popup-style="medium" ' +
+            'class="btn-manage-erx btn btn-sm mr-2 btn-info text-white font-weight-bold">Manage eRx</a>')
+            .appendTo(buttonContainer);
+
+        buttonContainer.insertAfter(titleElem);
+
+        initSegmentMoes(parentSegment);
+        __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+    }
+    addMCInitializer('medications-center-{{$note->id}}', init, '#medications-center-{{$note->id}}');
+}).call(window);
 </script>

+ 7 - 58
resources/views/app/patient/problems-center.blade.php

@@ -8,7 +8,7 @@ use App\Models\Segment;
 /** @var Client $patient */
 /** @var Note $note */
 
-$problems = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
+list($problems, $counts) = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
 $ccSegment = $note->getSegmentByInternalName('chief_complaint');
 ?>
 
@@ -27,7 +27,7 @@ $ccSegment = $note->getSegmentByInternalName('chief_complaint');
         @endif
 
         <div class="mb-2 font-weight-bold font-size-14 text-secondary">Problems</div>
-        <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -45,75 +45,24 @@ $ccSegment = $note->getSegmentByInternalName('chief_complaint');
             <?php $prevRowState = -1; ?>
             <?php foreach($problems as $problem): ?>
             <?php $point = $problem; ?>
-            @if($prevRowState !== -1 && $prevRowState !== $problem->state)
-                <tr>
-                    <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
-                </tr>
+            @if($prevRowState !== $problem->state)
+                @include('app.patient.wizard-partials.state-row', ['point' => $problem])
             @endif
             <?php $prevRowState = $problem->state; ?>
             <?php $rel = $problem->relevanceToNote($note); ?>
             <tr class="{{$rel ? 'relevant-to-visit' : ''}}">
                 @if($patient->core_note_id !== $note->id)
-                <td class="text-center">
-                    <a href="#" class="toggle-relevance"
-                       data-relevant="{{$rel ? '1' : '0'}}"
-                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
-                       data-point-uid="{{$problem->uid}}"
-                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
-                        @if($rel)
-                            <i class="fa fa-star text-sm text-info"></i>
-                        @else
-                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
-                        @endif
-                    </a>
-                </td>
+                    @include('app.patient.wizard-partials.relevance-column', ['point' => $problem])
                 @endif
                 <td>
                     <div class="d-flex align-items-baseline">
-                        @if($problem->state === 1)
-                            <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($problem->state === 2)
-                            <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($problem->state === 3)
-                            <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
-                        @elseif($problem->state === 4)
-                            <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
-                        @endif
+                        @include('app.patient.wizard-partials.state-icon', ['point' => $problem])
                         <div>
                             <div>
                                 <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
                                 <?= !!@($problem->data->icd) ? '/&nbsp;' . @($problem->data->icd) : '' ?>
                             </div>
-                            @if($problem->added_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Added
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                    @if($problem->addition_reason_category === 'ON_INTAKE')
-                                        (existing)
-                                    @elseif($problem->addition_reason_category === 'DURING_VISIT')
-                                        (new)
-                                    @endif
-                                </div>
-                            @endif
-                            @if($problem->is_removed && $problem->removed_in_note_id === $note->id)
-                                <div class="mt-1 text-sm text-secondary">
-                                    Removed
-                                    @if($patient->core_note_id !== $note->id)
-                                        during this visit
-                                    @else
-                                        from the patient's chart
-                                    @endif
-                                </div>
-                            @endif
-                            @if($rel)
-                                <div class="mt-1">
-                                    <span class="text-sm text-white bg-info rounded px-2 py-1 font-weight-bold">Visit reason</span>
-                                </div>
-                            @endif
+                            @include('app.patient.wizard-partials.state-badge', ['point' => $problem, 'addedVerb' => 'Prescribed', 'removedVerb' => 'Discontinued'])
                         </div>
                     </div>
                 </td>

+ 13 - 0
resources/views/app/patient/wizard-partials/relevance-column.blade.php

@@ -0,0 +1,13 @@
+<td class="text-center">
+    <a href="#" class="toggle-relevance"
+       data-relevant="{{$rel ? '1' : '0'}}"
+       data-rel-uid="{{$rel ? $rel->uid : ''}}"
+       data-point-uid="{{$point->uid}}"
+       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
+        @if($rel)
+            <i class="fa fa-star text-sm text-info"></i>
+        @else
+            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
+        @endif
+    </a>
+</td>

+ 27 - 0
resources/views/app/patient/wizard-partials/state-badge.blade.php

@@ -0,0 +1,27 @@
+@if($point->state === 'ACTIVE')
+    @if($point->added_in_note_id === $note->id && $point->addition_reason_category === 'DURING_VISIT')
+        <div class="text-sm text-secondary">{{@$addedVerb ?: 'Added'}} During Visit</div>
+    @elseif($point->added_in_note_id === $note->id && $point->addition_reason_category === 'ON_INTAKE')
+        <div class="text-sm text-secondary">New Record - Pre-existing</div>
+    @elseif($point->added_in_note_id !== $note->id)
+        <div class="text-sm text-secondary">Record Present Before Visit</div>
+    @endif
+@elseif($point->state === 'HISTORIC')
+    @if($point->removed_in_note_id === $note->id && $point->removal_reason_category === 'DURING_VISIT')
+        <div class="text-sm text-secondary">{{@$removedVerb ?: 'Removed'}}  During Visit</div>
+        @if($point->added_in_note_id === $note->id && $point->addition_reason_category === 'ON_INTAKE')
+            <div class="text-sm text-secondary">(New Historic Record)</div>
+        @endif
+    @elseif($point->removed_in_note_id === $note->id && $point->removal_reason_category === 'ON_INTAKE')
+        <div class="text-sm text-secondary">Marked {{@$removedVerb ?: 'Removed'}}  on Intake</div>
+        @if($point->added_in_note_id === $note->id && $point->addition_reason_category === 'ON_INTAKE')
+            <div class="text-sm text-secondary">(New Historic Record)</div>
+        @endif
+    @elseif($point->removed_in_note_id !== $note->id)
+        <div class="text-sm text-secondary">Historic Record Removed In A Previous Visit</div>
+    @endif
+@elseif($point->state === 'ENTRY_ERROR')
+    @if($point->removed_in_note_id === $note->id)
+        <div class="text-sm text-danger">Marked as Entry Error During Visit</div>
+    @endif
+@endif

+ 7 - 0
resources/views/app/patient/wizard-partials/state-icon.blade.php

@@ -0,0 +1,7 @@
+@if($point->state === 'ACTIVE')
+    <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
+@elseif($point->state === 'HISTORIC')
+    <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
+@elseif($point->state === 'ENTRY_ERROR')
+    <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
+@endif

+ 15 - 0
resources/views/app/patient/wizard-partials/state-row.blade.php

@@ -0,0 +1,15 @@
+<tr>
+    <td colspan="10" class="p-0 pb-0 bg-light">
+        <div class="px-2 pt-2 pb-1 d-lg-flex align-items-center on-hover-opaque">
+            @if($point->state === 'ACTIVE')
+                <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
+            @elseif($point->state === 'HISTORIC')
+                <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
+            @elseif($point->state === 'ENTRY_ERROR')
+                <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
+            @endif
+            <span class="text-secondary text-sm font-weight-bold">{{$point->state}} ({{$counts[$point->state]}})</span>
+        </div>
+        <hr class="m-0">
+    </td>
+</tr>