Explorar o código

Global singleton to top-level - on ros/pmhx/fhx/shx and sochx

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

+ 3 - 3
config/app.php

@@ -270,9 +270,9 @@ return [
         'medications',
         'past_medical_history',
         'problems',
-        'family_history',
-        'social_history',
-        'surgical_history',
+        'history_family',
+        'history_social',
+        'history_surgical',
         'nutrition',
         'exercise',
         'behavior',

+ 10 - 7
resources/views/app/patient/segment-templates/history_family/edit.blade.php

@@ -8,10 +8,14 @@ use App\Models\Note;
 
 if(!@$segment) $segment = null;
 
-// try loading afresh - since base section might have gotten dynamically updated
-$point = Point::getGlobalSingletonOfCategory($patient, 'FAMILY_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'FAMILY_HISTORY', $sessionKey, true);
 
-$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -51,14 +55,13 @@ if(!$contentData) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1"
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
                     {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
             @if(!!@$segment)
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            @else
-                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             @endif
-            <input type="hidden" name="category" value="FAMILY_HISTORY">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data">
 
             <div id="edit-univ_history_family-container">

+ 6 - 10
resources/views/app/patient/segment-templates/history_family/summary.blade.php

@@ -6,17 +6,13 @@ use App\Models\Note;
 /** @var Client $patient */
 /** @var Note $note */
 
-$contentData = [
-    "count" => 0,
-    "unknown" => false,
-    "items" => []
-];
-$isempty = false;
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'FAMILY_HISTORY', $sessionKey, true);
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'FAMILY_HISTORY', true);
+$contentData = $parsed = false;
 
-if ($point && @$point->data) {
-    $contentData = $point->data;
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
 }
 
 $labels = [
@@ -41,7 +37,7 @@ $labels = [
     'cancer_uterine_ca' => 'Uterine cancer',
 ];
 
-if(!$contentData['unknown'] && !!$contentData['count']) {
+if($contentData && !$contentData['unknown'] && !!$contentData['count']) {
     for ($i = 0; $i < $contentData['count']; $i++) {
 ?>
 <div class="<?= $i > 0 ? 'mt-2' : '' ?>">

+ 10 - 5
resources/views/app/patient/segment-templates/history_screenings/edit.blade.php

@@ -6,10 +6,14 @@ use App\Models\Note;
 /** @var Client $patient */
 /** @var Note $note */
 
-// try loading afresh - since base section might have gotten dynamically updated
-$point = Point::getGlobalSingletonOfCategory($patient, 'SCREENINGS_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SCREENINGS_HISTORY', $sessionKey, true);
 
-$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -28,9 +32,10 @@ if(!$contentData) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div visit-moe close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="category" value="SCREENINGS_HISTORY">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data">
 
             <div id="edit-univ_history_screenings-container">

+ 5 - 8
resources/views/app/patient/segment-templates/history_screenings/summary.blade.php

@@ -6,16 +6,13 @@ use App\Models\Note;
 /** @var Client $patient */
 /** @var Note $note */
 
-$contentData = [
-    "count" => 0,
-    "items" => []
-];
-$isempty = false;
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SCREENINGS_HISTORY', $sessionKey, true);
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'SCREENINGS_HISTORY', true);
+$contentData = $parsed = false;
 
-if ($point && @$point->data) {
-    $contentData = $point->data;
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
     ?>
     <table class="table table-bordered table-sm mb-0 table-cage">
         <?php

+ 10 - 6
resources/views/app/patient/segment-templates/history_social/edit.blade.php

@@ -34,9 +34,14 @@ $customFields = $pro->canvasCustomItems('sochx');
 
 if(!$customFields) $customFields = [];
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY',true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SOCIAL_HISTORY', $sessionKey, true);
 
-$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -58,14 +63,13 @@ for ($i = 0; $i < count($fields); $i++) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1"
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
                 {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
             @if(!!@$segment)
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            @else
-                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             @endif
-            <input type="hidden" name="category" value="SOCIAL_HISTORY">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data">
 
             <div id="edit-univ_history_social-container">

+ 5 - 9
resources/views/app/patient/segment-templates/history_social/summary.blade.php

@@ -25,17 +25,13 @@ $fields = [
     ]
 ];
 
-$contentData = [
-    "common" => [],
-    "customFields" => [],
-    "comments" => "",
-];
-
-$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SOCIAL_HISTORY', $sessionKey, true);
 
-if ($point && @$point->data) {
+$contentData = $parsed = false;
 
-    $contentData = $point->data;
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
 
     for ($i = 0; $i < count($fields); $i++):
         foreach($fields[$i] as $head => $values):

+ 10 - 6
resources/views/app/patient/segment-templates/history_surgical/edit.blade.php

@@ -31,9 +31,14 @@ $customFields = $pro->canvasCustomItems('pshx');
 
 if(!$customFields) $customFields = [];
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'SURGICAL_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SURGICAL_HISTORY', $sessionKey, true);
 
-$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -55,14 +60,13 @@ for ($i = 0; $i < count($fields); $i++) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1"
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
                 {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
             @if(!!@$segment)
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            @else
-                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             @endif
-            <input type="hidden" name="category" value="SURGICAL_HISTORY">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data">
 
             <div id="edit-univ_history_surgical-container">

+ 5 - 9
resources/views/app/patient/segment-templates/history_surgical/summary.blade.php

@@ -22,17 +22,13 @@ $fields = [
     ]
 ];
 
-$contentData = [
-    "common" => [],
-    "customFields" => [],
-    "comments" => "",
-];
-
-$point = Point::getGlobalSingletonOfCategory($patient, 'SURGICAL_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SURGICAL_HISTORY', $sessionKey, true);
 
-if ($point && @$point->data) {
+$contentData = $parsed = false;
 
-    $contentData = $point->data;
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
 
     for ($i = 0; $i < count($fields); $i++):
         foreach($fields[$i] as $head => $values):

+ 11 - 7
resources/views/app/patient/segment-templates/past_medical_history/edit.blade.php

@@ -43,9 +43,14 @@ $customFields = $pro->canvasCustomItems('pmhx');
 
 if(!$customFields) $customFields = [];
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'PAST_MEDICAL_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PAST_MEDICAL_HISTORY', $sessionKey, true);
 
-$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -69,14 +74,13 @@ for ($i = 0; $i < count($fields); $i++) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1"
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
                 {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
             @if(!!@$segment)
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            @else
-                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             @endif
-            <input type="hidden" name="category" value="PAST_MEDICAL_HISTORY">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data">
 
             <div id="edit-univ_history_past_medical-container">
@@ -118,7 +122,7 @@ for ($i = 0; $i < count($fields); $i++) {
                                                         <a href="#" start show>
                                                             <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
                                                         </a>
-                                                        <div url="/nop" right>
+                                                        <div url="/nop">
                                                             <div class="mb-2">
                                                                 <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
                                                                           v-model="common['{{$fName}}__comments']"></textarea>

+ 9 - 3
resources/views/app/patient/segment-templates/past_medical_history/summary.blade.php

@@ -42,10 +42,16 @@ $contentData = [
 ];
 $isempty = false;
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'PAST_MEDICAL_HISTORY', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PAST_MEDICAL_HISTORY', $sessionKey, true);
 
-if ($point && @$point->data) {
-    $contentData = $point->data;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if ($contentData) {
 
     $blood = [];
     if(isset($contentData['bloodType'])) {

+ 15 - 6
resources/views/app/patient/segment-templates/ros/edit.blade.php

@@ -193,9 +193,19 @@ $fields = [
     ]
 ];
 
-$point = Point::getGlobalSingletonOfCategory($patient, 'ROS', true);
+// only for ros - since ros edit markup is loaded via AJAX GET from the UI
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'ROS', $sessionKey, true);
 
-$contentData = $parsed = ($point && @$point->data && !@($point->data['free_text'])) ? $point->data : false;
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
 
 if(!$contentData) {
     $contentData = [
@@ -217,14 +227,13 @@ for ($i = 0; $i < count($fields); $i++) {
 <hr class="hide-outside-popup mt-3 mb-0">
 <div class="p-3 mcp-theme-1">
     <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
-        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1"
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
                 {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
             @if(!!@$segment)
                 <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            @else
-                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             @endif
-            <input type="hidden" name="category" value="ROS">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="data" value='{!! json_encode($contentData) !!}'>
 
             <div id="edit-ros-container">

+ 4 - 9
resources/views/app/patient/segment-templates/ros/summary.blade.php

@@ -190,16 +190,11 @@ $fields = [
     ]
 ];
 
-$contentData = [
-    "common" => [],
-    "comments" => "",
-];
-$isempty = false;
-
-$point = Point::getGlobalSingletonOfCategory($patient, 'ROS', true);
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'ROS', $sessionKey, true);
 
-if ($point && @$point->data && !@($point->data['free_text'])) {
-    $contentData = $point->data;
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
 
     if(!!@$contentData['declaration']) {
         echo '<div class="mb-2">';