瀏覽代碼

Vitals segment overhaul

Vijayakrishnan 3 年之前
父節點
當前提交
28949f2be7

+ 15 - 0
public/css/style.css

@@ -2116,4 +2116,19 @@ body.in-iframe .main-row > .sidebar {
 }
 .visit-segment .mcp-theme-1 .ql-editor[contenteditable] {
     min-height: 200px;
+}
+.visit-segment tr .vitals-copy-trigger {
+    position: absolute;
+    top: 0;
+    left: -10px;
+    width: 20px;
+    height: 100%;
+    align-items: center;
+    justify-content: center;
+    display: none;
+    cursor: pointer;
+    text-decoration: none !important;
+}
+.visit-segment tr:hover .vitals-copy-trigger {
+    display: flex;
 }

+ 98 - 81
resources/views/app/patient/segment-templates/vitals/edit.blade.php

@@ -26,69 +26,60 @@ if (!!@$point->data) {
 
 if(!$contentData) {
     $contentData = [
-        "heightInInches" => [
-            "label" => "Ht. (in.)",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "weightPounds" => [
-            "label" => "Wt. (lbs.)",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "temperatureF" => [
-            "label" => "Temp. (F)",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "systolicBP" => [
-            "label" => "SBP",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "diastolicBP" => [
-            "label" => "DBP",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "pulseRatePerMinute" => [
-            "label" => "Pulse",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "respirationRatePerMinute" => [
-            "label" => "Resp.",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "pulseOx" => [
-            "label" => "Pulse Ox.",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "smokingStatus" => [
-            "label" => "Smoking Status",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
-        "bmi" => [
-            "label" => "BMI (kg/m²)",
-            "value" => "",
-            "date" => date('Y-m-d'),
-        ],
+        "date" => $note->effective_dateest,
+        "heightInInches" => '',
+        "weightPounds" => '',
+        "temperatureF" => '',
+        "systolicBP" => '',
+        "diastolicBP" => '',
+        "pulseRatePerMinute" => '',
+        "respirationRatePerMinute" => '',
+        "pulseOx" => '',
+        "smokingStatus" => '',
+        "bmi" => '',
     ];
 }else {
+    if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;
     foreach ($vitalLabels as $k => $v) {
-        if (!isset($contentData[$k])) {
-            $contentData[$k] = [
-                "label" => $v,
-                "value" => "",
-                "date" => date('Y-m-d'),
-            ];
+        if (!isset($contentData[$k]) || is_array($contentData[$k])) {
+            $contentData[$k] = '';
         }
     }
 }
 
+$previousVitals = Point::where('client_id', $patient->id)
+    ->where('added_in_segment_id', '<>', $segment->id)
+    ->where('category', $category)
+    ->orderBy('id', 'DESC')
+    ->limit(4)
+    ->get();
+
+// convert to new format
+$previousData = [];
+$previousDataAssoc = [];
+foreach ($previousVitals as $p) {
+    if (!!@$p->data) {
+        $parsedP = json_decode($p->data, true);
+        $newFormat = [];
+        foreach ($vitalLabels as $k => $v) {
+            if (isset($parsedP[$k]) && is_array($parsedP[$k]) && isset($parsedP[$k]['value'])) {
+                $newFormat[$k] = $parsedP[$k]['value'];
+            }
+            else if(isset($parsedP[$k]) && !is_array($parsedP[$k])) {
+                $newFormat[$k] = $parsedP[$k];
+            }
+            else {
+                $newFormat[$k] = '';
+            }
+        }
+        $newFormat['date'] = $p->note->effective_dateest;
+        $previousData[] = $newFormat;
+        $previousDataAssoc[$newFormat['date']] = $newFormat; // for easy iter to cols
+    }
+}
+
+$copyTriggerAdded = [];
+
 ?>
 <div visit-moe close-on-save close-on-cancel class="d-block">
     <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
@@ -100,8 +91,16 @@ if(!$contentData) {
             <thead>
             <tr class="bg-light">
                 <th class="px-2 text-secondary border-bottom-0 w-25">Vital</th>
-                <th class="px-2 text-secondary border-bottom-0 w-35">Value</th>
-                <th class="px-2 text-secondary border-bottom-0">Date</th>
+                <th class="px-2 text-secondary border-bottom-0 w-25">{{$contentData['date']}}</th>
+                @if(!$previousData || !count($previousData))
+                    <th class="px-2 text-secondary border-bottom-0">Previous</th>
+                @else
+                    @foreach($previousData as $pDay)
+                        <th class="px-2 text-secondary border-bottom-0 on-hover-opaque position-relative">
+                            {{$pDay['date']}}
+                        </th>
+                    @endforeach
+                @endif
             </tr>
             </thead>
             <tbody>
@@ -109,17 +108,17 @@ if(!$contentData) {
                 <tr>
                     <td>
                         <input type="text" tabindex="-1"
-                               class="form-control form-control-sm events-none"
+                               class="form-control form-control-sm events-none border-0"
                                value="{{ $v }}" readonly>
                     </td>
                     <td class="position-relative">
                         @if($k === "bmi")
                             <input type="text" readonly bmi
-                                   class="form-control form-control-sm vitals-title"
-                                   data-name="bmi->value" value="{{$contentData['bmi']['value']}}">
-                            @if(isset($contentData['bmi']['value']) && $contentData['bmi']['value'] != "" )
+                                   class="form-control form-control-sm vitals-title border-bottom border-top-0 border-left-0 border-right-0"
+                                   data-name="bmi" value="{{$contentData['bmi']}}">
+                            @if(isset($contentData['bmi']) && $contentData['bmi'] != "" )
                                 <p class="py-1 m-0 px-2 font-weight-bold bg-white">
-                                    <?php $bmi = $contentData['bmi']['value']; ?>
+                                    <?php $bmi = $contentData['bmi']; ?>
                                     @if($bmi < 18.5)
                                         <span class="text-sm text-warning-mellow" v-if="+bmi < 18.5">Underweight</span>
                                     @endif
@@ -136,24 +135,32 @@ if(!$contentData) {
                             @endif
                         @elseif($k === "smokingStatus")
                             <input type="text"
-                                   class="form-control form-control-sm"
-                                   data-name="smokingStatus->value"
-                                   data-option-list="smokingStatus" value="{{$contentData['smokingStatus']['value']}}">
+                                   class="form-control form-control-sm border-0"
+                                   data-name="smokingStatus"
+                                   data-option-list="smokingStatus" value="{{$contentData['smokingStatus']}}">
                             <div id="smoking-status-options" class="data-option-list">
                                 <div>Current</div>
                                 <div>Former</div>
                                 <div>Never</div>
                             </div>
                         @else
-                            <input type="text" class="form-control form-control-sm" data-name="{{$k}}->value" {{$k}} value="{{$contentData[$k]['value']}}"
+                            <input type="text" class="form-control form-control-sm border-0" data-name="{{$k}}" {{$k}} value="{{$contentData[$k]}}"
                               @if($k == 'heightInInches' || $k == 'weightPounds') refresh-bmi @endif>
                         @endif
                     </td>
-                    <td>
-                        <input type="date" @if($k == 'bmi') bmi-date @endif @if($k == 'weightPounds') weight-date refresh-bmi @endif  {{ $k === 'bmi' ? 'readonly' : '' }}
-                            class="form-control form-control-sm vitals-title"
-                            data-name="{{$k}}->date" value="{{$contentData[$k]['date']}}">
-                    </td>
+                    @if(!$previousData || !count($previousData))
+                        <td class="bg-light"></td>
+                    @else
+                        @foreach($previousData as $pDay)
+                            <td class="bg-light {{!isset($copyTriggerAdded[$k]) ? 'pl-4 pr-2' : 'px-2'}} py-1 text-secondary position-relative">
+                                {{$previousDataAssoc[$pDay['date']][$k] ?: '-' }}
+                                @if(!isset($copyTriggerAdded[$k]) && $k !== "bmi")
+                                    <a href="#" title="Copy to this note" class="vitals-copy-trigger"><i class="fa fa-chevron-circle-left font-size-14"></i></a>
+                                @endif
+                            </td>
+                            <?php $copyTriggerAdded[$k] = true ?>
+                        @endforeach
+                    @endif
                 </tr>
                 @endforeach
             </tbody>
@@ -165,14 +172,24 @@ if(!$contentData) {
     </form>
 </div>
 <script>
-    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
-       $('[refresh-bmi]').off('change');
-       $('[refresh-bmi]').on('change', function(){
-           var height = parseInt($('[heightInInches]').val());
-           var weight = parseInt($('[weightPounds]').val());
-           var bmi =  Math.round((weight /(height*height)) * 703.06957964)
-           $('[bmi]').val(bmi);
-           $('[bmi-date]').val($('[weight-date]').val());
-       })
+    window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function () {
+        let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+
+        parentSegment.find('[refresh-bmi]').off('change input');
+        parentSegment.find('[refresh-bmi]').on('change input', function () {
+            var height = parseInt(parentSegment.find('[heightInInches]').val());
+            var weight = parseInt(parentSegment.find('[weightPounds]').val());
+            var bmi = Math.round((weight / (height * height)) * 703.06957964)
+            parentSegment.find('[bmi]').val(bmi);
+            parentSegment.find('[bmi-date]').val(parentSegment.find('[weight-date]').val());
+        });
+
+        parentSegment.find('.vitals-copy-trigger').off('click.copy-vital');
+        parentSegment.find('.vitals-copy-trigger').on('click.copy-vital', function () {
+            let td = $(this).closest('td');
+            td.prev().find('input').val($.trim(td.text())).trigger('change');
+            return false;
+        });
+
     };
 </script>

+ 19 - 68
resources/views/app/patient/segment-templates/vitals/summary.blade.php

@@ -26,83 +26,37 @@ if (!!@$point->data) {
 
 if(!$contentData) {
     $contentData = [
-        "heightInInches" => [
-            "label" => "Ht. (in.)",
-            "value" => "",
-            "date" => "",
-        ],
-        "weightPounds" => [
-            "label" => "Wt. (lbs.)",
-            "value" => "",
-            "date" => "",
-        ],
-        "temperatureF" => [
-            "label" => "Temp. (F)",
-            "value" => "",
-            "date" => "",
-        ],
-        "systolicBP" => [
-            "label" => "SBP",
-            "value" => "",
-            "date" => "",
-        ],
-        "diastolicBP" => [
-            "label" => "DBP",
-            "value" => "",
-            "date" => "",
-        ],
-        "pulseRatePerMinute" => [
-            "label" => "Pulse",
-            "value" => "",
-            "date" => "",
-        ],
-        "respirationRatePerMinute" => [
-            "label" => "Resp.",
-            "value" => "",
-            "date" => "",
-        ],
-        "pulseOx" => [
-            "label" => "Pulse Ox.",
-            "value" => "",
-            "date" => "",
-        ],
-        "smokingStatus" => [
-            "label" => "Smoking Status",
-            "value" => "",
-            "date" => "",
-        ],
-        "bmi" => [
-            "label" => "BMI (kg/m²)",
-            "value" => "",
-            "date" => "",
-        ],
+        "date" => $note->effective_dateest,
+        "heightInInches" => '',
+        "weightPounds" => '',
+        "temperatureF" => '',
+        "systolicBP" => '',
+        "diastolicBP" => '',
+        "pulseRatePerMinute" => '',
+        "respirationRatePerMinute" => '',
+        "pulseOx" => '',
+        "smokingStatus" => '',
+        "bmi" => '',
     ];
 }else {
+    if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;
     foreach ($vitalLabels as $k => $v) {
-        if (!isset($contentData[$k])) {
-            $contentData[$k] = [
-                "label" => $v,
-                "value" => "",
-                "date" => "",
-            ];
+        if (!isset($contentData[$k]) || is_array($contentData[$k])) {
+            $contentData[$k] = '';
         }
     }
 }
 ?>
 
+<div class="mb-2">Effective Date: <b>{{$contentData['date']}}</b></div>
 @foreach ($vitalLabels as $k => $v)
 <div class="d-flex vital-item align-items-center">
         <span class="content-html text-nowrap">
             <span>{{$v}}:</span>
-            <?php
-            $vital = [];
-            if(isset($contentData[$k])) {
-                $vital = $contentData[$k];
-            }
-            ?>
-            <b>{{ isset($vital["value"]) && !empty($vital["value"]) ? $vital["value"] : '-' }}</b>
-            @if($k === 'bmi' && isset($vital["value"]) && !empty($vital["value"]))
-                <?php $bmi = floatval($vital["value"]); ?>
+            <?php $vital = @$contentData[$k]; ?>
+            <b>{{ !empty($vital) ? $vital : '-' }}</b>
+            @if($k === 'bmi' && !empty($vital))
+                <?php $bmi = floatval($vital); ?>
                 <span class="ml-2 py-1 m-0 font-weight-bold">
                      @if($bmi < 18.5)
                         <span class="text-sm text-warning-mellow">(Underweight)</span>
@@ -118,9 +72,6 @@ if(!$contentData) {
                     @endif
                 </span>
             @endif
-            @if(!!$vital["date"])
-                <span class="font-weight-normal text-secondary ml-2 text-sm">(as on {{ friendly_date_time($vital["date"], false) }})</span>
-            @endif
         </span>
 </div>
 @endforeach