浏览代码

plan/review - relative friendly dates (x days ago)

Vijayakrishnan 3 年之前
父节点
当前提交
b73533d7ff

+ 17 - 0
app/Helpers/helpers.php

@@ -326,6 +326,23 @@ if(!function_exists('friendlier_date')) {
     }
     }
 }
 }
 
 
+if(!function_exists('relative_friendly_date')) {
+    function relative_friendly_date($value) {
+        if(!$value || empty($value)) return '';
+        try {
+            $result = date_diff(date_create($value), date_create('now'))->days;
+            if ($result > 30) $result = date('F, Y', strtotime($value));
+            else if ($result > 1) $result .= ' days ago';
+            else if ($result === 1) $result = 'yesterday';
+            else if ($result === 0) $result = 'today';
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
 if(!function_exists('unfriendly_date')) {
 if(!function_exists('unfriendly_date')) {
     function unfriendly_date($value) {
     function unfriendly_date($value) {
         if(!$value || empty($value)) return '';
         if(!$value || empty($value)) return '';

+ 3 - 3
resources/views/app/patient/segment-templates/_child_plan/last-plan.php

@@ -1,7 +1,7 @@
 <?php if ($point->lastChildPlan): ?>
 <?php if ($point->lastChildPlan): ?>
     <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
     <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
     <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
     <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
-        <div><?= $parsedPlan->value ?></div>
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
         <div class="text-secondary text-sm"></div>
         <div class="text-secondary text-sm"></div>
 
 
         <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
         <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
@@ -10,9 +10,9 @@
             <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
             <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
                 <span class="text-sm">(updated on this note)</span>
                 <span class="text-sm">(updated on this note)</span>
             <?php else: ?>
             <?php else: ?>
-                <a native target="_blank"
+                <a native target="_blank" class="text-sm"
                    href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>">
                    href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>">
-                    <?= friendlier_date($point->last_child_plan_effective_date) ?>
+                   Updated <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
                 </a>
                 </a>
             <?php endif; ?>
             <?php endif; ?>
         <?php endif; ?>
         <?php endif; ?>

+ 3 - 3
resources/views/app/patient/segment-templates/_child_review/last-review.php

@@ -1,7 +1,7 @@
 <?php if ($point->lastChildReview): ?>
 <?php if ($point->lastChildReview): ?>
     <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
     <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
     <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
     <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
-        <div><?= @$parsedReview->value ?></div>
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
 
 
         <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
         <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
             <span class="text-sm">(updated on the patient's chart)</span>
             <span class="text-sm">(updated on the patient's chart)</span>
@@ -9,9 +9,9 @@
             <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
             <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
                 <span class="text-sm">(updated on this note)</span>
                 <span class="text-sm">(updated on this note)</span>
             <?php else: ?>
             <?php else: ?>
-                <a native target="_blank"
+                <a native target="_blank" class="text-sm"
                    href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>">
                    href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>">
-                    <?= friendlier_date($point->last_child_review_effective_date) ?>
+                    Updated <?= relative_friendly_date($point->last_child_review_effective_date) ?>
                 </a>
                 </a>
             <?php endif; ?>
             <?php endif; ?>
         <?php endif; ?>
         <?php endif; ?>

+ 1 - 1
resources/views/app/patient/wizard-partials/show-plan.blade.php

@@ -13,7 +13,7 @@
                 @else
                 @else
                     <a native target="_blank" class="text-sm"
                     <a native target="_blank" class="text-sm"
                        href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $plan->note]) ?>">
                        href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $plan->note]) ?>">
-                        <?= friendlier_date($plan->note->effective_dateest) ?>
+                       Updated <?= relative_friendly_date($plan->note->effective_dateest) ?>
                     </a>
                     </a>
                 @endif
                 @endif
             @endif
             @endif

+ 1 - 1
resources/views/app/patient/wizard-partials/show-review.blade.php

@@ -13,7 +13,7 @@
                 @else
                 @else
                     <a native target="_blank" class="text-sm"
                     <a native target="_blank" class="text-sm"
                        href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $review->note]) ?>">
                        href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $review->note]) ?>">
-                        <?= friendlier_date($review->note->effective_dateest) ?>
+                       Updated <?= relative_friendly_date($review->note->effective_dateest) ?>
                     </a>
                     </a>
                 @endif
                 @endif
             @endif
             @endif