瀏覽代碼

Support for note-point driven relevance (engine)

Vijayakrishnan 3 年之前
父節點
當前提交
8127dd61b6
共有 3 個文件被更改,包括 50 次插入0 次删除
  1. 11 0
      app/Models/NotePoint.php
  2. 8 0
      app/Models/Point.php
  3. 31 0
      resources/views/app/patient/note/segment_script.blade.php

+ 11 - 0
app/Models/NotePoint.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class NotePoint extends Model
+{
+    protected $table = 'note_point';
+
+}

+ 8 - 0
app/Models/Point.php

@@ -78,6 +78,14 @@ class Point extends Model
         return $this->hasOne(Note::class, 'id', 'added_in_note_id');
     }
 
+    public function relevanceToNote($_note) {
+        return NotePoint
+            ::where('is_active', true)
+            ->where('note_id', $_note->id)
+            ->where('point_id', $this->id)
+            ->first();
+    }
+
     public static function getGlobalSingletonOfCategory(Client $_patient, String $_category, $_assoc = false) {
         $point = Point
             ::where('client_id', $_patient->id)

+ 31 - 0
resources/views/app/patient/note/segment_script.blade.php

@@ -330,6 +330,37 @@
                 initChangeListener($(this));
             });
              */
+
+            // relevance
+            $(document).off('change', '.visit-segment[data-segment-template-name] .chk-relevance');
+            $(document).on('change', '.visit-segment[data-segment-template-name] .chk-relevance', function () {
+                let segment = $(this).closest('.visit-segment');
+                if(this.checked) {
+                    $.post('/api/visitPoint/markPointRelevantToNote', {
+                        noteUid: '{{$note->uid}}',
+                        pointUid: $(this).attr('data-point-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            segment.find('.refresh-segment').trigger('click');
+                        }
+                    }, 'json');
+                }
+                else {
+                    if($(this).attr('data-rel-uid')) {
+                        $.post('/api/visitPoint/undoMarkPointRelevantToNote', {
+                            uid: $(this).attr('data-rel-uid')
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                segment.find('.refresh-segment').trigger('click');
+                            }
+                        }, 'json');
+                    }
+                    else {
+                        console.log('Error - missing rel uid');
+                    }
+                }
+                return false;
+            });
         }
 
         addMCInitializer('note-segments-list', init, '#note-segments-list');