Browse Source

Record "view-mcn" pro-event

Vijayakrishnan 3 years ago
parent
commit
98d2b4dca8
2 changed files with 15 additions and 6 deletions
  1. 6 0
      public/js/show-on-click.js
  2. 9 6
      resources/views/app/patient/settings.blade.php

+ 6 - 0
public/js/show-on-click.js

@@ -8,6 +8,12 @@
                 }
                 else {
                     $(this).text($(this).attr('data-value'));
+
+                    // fire pro event
+                    $.post('/api/proEvent/create', {
+                        proUid: $(this).attr('data-pro-uid'),
+                        event: $(this).attr('data-event'),
+                    }, () => {}, 'json');
                 }
                 return false;
             });

+ 9 - 6
resources/views/app/patient/settings.blade.php

@@ -869,15 +869,15 @@
                         @endif
                     </div>
                     <div class="bg-light border p-2">
-                    @php
-                    function displayNode($_key, $_node) {
+                    <?php
+                    function displayNode($_key, $_node, $_pro, $_patient) {
                         $keyDisplay = ucwords(str_replace("_", " ", $_key));
                         $nodeOutput = '<div class="mb-1">' . $keyDisplay . ': ';
                         $nodeType = gettype($_node);
                         if(is_array($_node) && count($_node)) {
                             $nodeOutput .= '<div class="border-left pl-3 my-1">';
                             foreach ($_node as $k => $v) {
-                                $nodeOutput .= displayNode($k, $v);
+                                $nodeOutput .= displayNode($k, $v, $_pro, $_patient);
                             }
                             $nodeOutput .= '</div>';
                         }
@@ -886,7 +886,10 @@
                                 $nodeOutput .= '<b>' . (!empty($_node) ? $_node : '-') . '</b>';
                             }
                             else {
-                                $nodeOutput .= '<b class="c-pointer text-primary show-on-click" data-value="' . (!empty($_node) ? $_node : '-') . '">Click to view</b>';
+                                $nodeOutput .= '<b class="c-pointer text-primary show-on-click" ' .
+                                    'data-pro-uid="' . $_pro->uid . '" ' .
+                                    'data-event="View MCN of patient ' . $_patient->displayName() . '"' .
+                                    'data-value="' . (!empty($_node) ? $_node : '-') . '">Click to view</b>';
                             }
                         }
                         else {
@@ -898,9 +901,9 @@
                     $mcnResponse = !empty($patient->mcn_response_detail) ? json_decode($patient->mcn_response_detail, true) : [];
                     $output = [];
                     foreach ($mcnResponse as $k => $v) {
-                        $output[] = displayNode($k, $v);
+                        $output[] = displayNode($k, $v, $pro, $patient);
                     }
-                    @endphp
+                    ?>
                     {!! implode("", $output) !!}
                     </div>
                 </div>