Browse Source

Note single - Vitals inline CRUD

Vijayakrishnan Krishnan 4 years ago
parent
commit
de65b34166

+ 3 - 139
resources/views/app/patient/dashboard.blade.php

@@ -6,44 +6,9 @@
         {{-- CARE PLAN START --}}
         <?php $infoLines = json_decode($patient->info_lines);?>
         <?php $infoLines = !$infoLines ? [] : $infoLines; ?>
+        <?php $vitalLabels = ['Ht. (in.)','Wt. (lbs.)','Temp. (F)','Pulse','Resp.','Pulse Ox.','SBP','DBP','Smoking Status']; ?>
 
-	<?php
-
-        $vitalMap = [
-                'heightInches' => 'Ht. (in.)',
-				'weightPounds' => 'Wt. (lbs.)',
-				'temperatureF' => 'Temp. (F)',
-				'pulseRatePerMinute' => 'Pulse',
-				'respirationRatePerMinute' => 'Resp.',
-				'pulseOx' => 'Pulse Ox.',
-				'systolicBP' => 'SBP',
-				'diastolicBP' => 'DBP',
-                'smokingStatus' => 'Smoking Status'
-        ];
-
-        $vitalLabels = ['Ht. (in.)','Wt. (lbs.)','Temp. (F)','Pulse','Resp.','Pulse Ox.','SBP','DBP','Smoking Status'];
-
-        $vitalValues = [];
-
-        foreach($vitalLabels as $l){
-            $vitalValues[$l] = [
-                'value' => null,
-                'effectiveDate' => null
-            ];
-        }
-
-        foreach($patient->measurements as $measurement) {
-            if(!empty($measurement->label) && in_array($measurement->label, $vitalLabels)){
-                $vitalValues[$measurement->label] = [
-                    'value'=>$measurement->value,
-                    'effectiveDate' => $measurement->effective_date
-                ];
-            }
-        }
-
-	?>
-
-        <div class="row">
+	    <div class="row">
             <div class="col-6">
 
                 {{-- appointments --}}
@@ -151,108 +116,7 @@
                 </div>
 
                 {{-- vitals --}}
-                <div class="mt-2 pb-1">
-                    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
-                        <h6 class="my-0 font-weight-bold text-secondary">Vitals</h6>
-                        <span class="mx-2 text-secondary">|</span>
-                        <div moe>
-                            <a start show class="py-0 font-weight-normal">Update</a>
-                            <form url="/api/measurement/updateVitals">
-                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                <div class="mb-2">
-                                    Ht. (in.)<br>
-                                    <input type="text" class="form-control form-control-sm" name="heightInches" value="{{$vitalValues['Ht. (in.)']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    Wt. (lbs.)<br>
-                                    <input type="text" class="form-control form-control-sm" name="weightPounds" value="{{$vitalValues['Wt. (lbs.)']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    <label for="" class="control-label mb-0">Temp. (F)</label>
-                                    Temp. (F)<br/>
-                                    <input type="text" class="form-control form-control-sm" name="temperatureF" value="{{$vitalValues['Temp. (F)']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    Pulse<br/>
-                                    <input type="text" class="form-control form-control-sm" name="pulseRatePerMinute" value="{{$vitalValues['Pulse']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    Resp.<br/>
-                                    <input type="text" class="form-control form-control-sm" name="respirationRatePerMinute" value="{{$vitalValues['Resp.']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    Pulse Ox.<br/>
-                                    <input type="text" class="form-control form-control-sm" name="pulseOx" value="{{$vitalValues['Pulse Ox.']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    SBP<br/>
-                                    <input type="text" class="form-control form-control-sm" name="systolicBP" value="{{$vitalValues['SBP']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    DBP<br/>
-                                    <input type="text" class="form-control form-control-sm" name="diastolicBP" value="{{$vitalValues['DBP']['value']}}" placeholder="">
-                                </div>
-				                <div class="mb-2">
-                                    Smoking Status<br/>
-                                    <input type="text" class="form-control form-control-sm" name="smokingStatus" value="{{$vitalValues['Smoking Status']['value']}}" placeholder="">
-                                </div>
-
-                                <div class="d-flex align-items-center">
-                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-                        <span class="mx-2 text-secondary">|</span>
-                        <a start show class="py-0 font-weight-normal"
-                           href="/patients/view/{{ $patient->uid }}/measurements">
-                            View All
-                        </a>
-                    </div>
-                    <table class="table table-sm border-0 m-0">
-                        <tbody>
-                            @foreach($vitalLabels as $label)
-                                <tr>
-                                    <td class="text-black p-0 border-0">
-                                        <div class="d-flex align-items-center">
-                                            <div moe class="mr-2">
-                                                <a class="on-hover-opaque" start show title="Update">
-                                                    <i class="font-size-11 fa fa-edit text-primary"></i>
-                                                </a>
-                                                <form url="/api/measurement/create">
-                                                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                                    <div class="mb-2">
-                                                        <input type="text" class="form-control form-control-sm" name="label" value="{{ $label }}" placeholder="Type">
-                                                    </div>
-                                                    <div class="mb-2">
-                                                        <input autofocus type="text" class="form-control form-control-sm" name="value" value="{{ $vitalValues[$label]['value'] }}" placeholder="Value">
-                                                    </div>
-                                                    <div class="mb-2">
-                                                        <input type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
-                                                    </div>
-                                                    <div class="d-flex align-items-center">
-                                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                                    </div>
-                                                </form>
-                                            </div>
-                                            <span>{{ $label }}:</span>
-                                            <span class="font-weight-bold ml-1">{{ $vitalValues[$label]['value'] }}</span>
-                                            <span class="font-weight-normal text-secondary ml-2 text-sm">(as on {{ friendly_date_time($vitalValues[$label]['effectiveDate'], false) }})</span>
-                                        </div>
-                                    </td>
-                                </tr>
-                        @endforeach
-                        @if(!$patient->measurements || !count($patient->measurements) === 0)
-                            <tr>
-                                <td class="text-secondary p-0 border-0">
-                                    No items to show
-                                </td>
-                            </tr>
-                        @endif
-                        </tbody>
-                    </table>
-                </div>
+                @include('app/patient/partials/vitals')
 
                 {{-- measurements --}}
                 <div class="mt-2 pb-1">

+ 34 - 0
storage/sections/vitals/actions.blade.php

@@ -0,0 +1,34 @@
+<div class="position-relative d-none if-edit ml-3 pl-3 border-left">
+    <a href="#" onclick="$(this).siblings('.embed-section, .embed-mask').removeClass('d-none'); return false;">Current Vitals</a>
+    <div class="embed-section min-width-300px bg-white position-absolute d-none vitals-form">
+        <div>
+            @include('app/patient/partials/vitals', ['selectable' => true])
+        </div>
+        <div class="m-2">
+            <form url="/no-op">
+                <button class="btn btn-primary btn-sm mr-1" type="button" onclick="return applySelectedVitals()">Apply</button>
+                <button class="btn btn-default border btn-sm" type="button" onclick="return cancelVitalsPopup()">Cancel</button>
+            </form>
+        </div>
+    </div>
+</div>
+
+<script>
+    function applySelectedVitals() {
+        let html = [];
+        $('.vital-item-checkbox:checked').each(function() {
+            html.push('<p style="white-space: normal;">' + $.trim($(this).closest('.vital-item').find('.content-html').first().html()) + '</p>');
+        });
+        $('.embed-section, .embed-mask').addClass('d-none');
+        $('.ql-editor[contenteditable]:visible').first().html(html.join('')).focus();
+        return false;
+    }
+    function cancelVitalsPopup() {
+        $('.embed-section, .embed-mask').addClass('d-none');
+        hideMask();
+        hideMoeFormMask();
+        $('.ql-editor[contenteditable]:visible').first().focus();
+        return false;
+    }
+</script>
+

+ 0 - 63
storage/sections/vitals/actions.php

@@ -1,63 +0,0 @@
-<?php
-
-$vitalMap = [
-    'heightInches' => 'Ht. (in.)',
-    'weightPounds' => 'Wt. (lbs.)',
-    'temperatureF' => 'Temp. (F)',
-    'pulseRatePerMinute' => 'Pulse',
-    'respirationRatePerMinute' => 'Resp.',
-    'pulseOx' => 'Pulse Ox.',
-    'systolicBP' => 'SBP',
-    'diastolicBP' => 'DBP',
-    'smokingStatus' => 'Smoking Status'
-];
-$vitalLabels = ['Ht. (in.)', 'Wt. (lbs.)', 'Temp. (F)', 'Pulse', 'Resp.', 'Pulse Ox.', 'SBP', 'DBP', 'Smoking Status'];
-$vitalValues = [];
-foreach ($patient->measurements as $measurement) {
-    if (!empty($measurement->label) && in_array($measurement->label, $vitalLabels)) {
-        $vitalValues[$measurement->label] = [
-            'value' => $measurement->value,
-            'effectiveDate' => $measurement->effective_date
-        ];
-    }
-}
-
-$value = [];
-$rows = [];
-global $defaultData;
-foreach ($vitalValues as $lbl => $line):
-    $rows[] = '<label class="d-flex align-items-center current-vital-item mb-1 c-pointer">' .
-        '<input type="checkbox" checked class="my-0 mr-2">' .
-        '<span>' . $lbl . ': <b>' . $line['value'] . '</b> ' .
-        '<span class="text-sm">(as on ' . friendly_date_time($line['effectiveDate'], false) . ')</span>' .
-        '</span></label>';
-endforeach;
-?>
-
-<div moe class="position-relative d-none if-edit ml-3 pl-3 border-left">
-    <a start show href="#">Current Vitals</a>
-    <form url="/no-op" class="current-vital-form">
-        <div class="min-width-300px">
-            <?= implode("", $rows) ?>
-            <div class="mt-2 mb-0">
-                <button class="btn btn-primary btn-sm mr-1" type="button" onclick="return applySelectedVital()">Apply</button>
-                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-            </div>
-        </div>
-    </form>
-</div>
-
-<script>
-    function applySelectedVital() {
-        let html = [];
-        $('.current-vital-item input:checkbox:checked').each(function() {
-            html.push('<p>' + $(this).next().html() + '</p>');
-        });
-        $('.current-vital-form').hide();
-        hideMask();
-        hideMoeFormMask();
-        $('.ql-editor[contenteditable]:visible').first().html(html.join('')).focus();
-        return false;
-    }
-</script>
-