Browse Source

New note - default to "Follow up" if NEw note exists for pro

Vijayakrishnan 3 years ago
parent
commit
f6de839dbe
2 changed files with 5 additions and 1 deletions
  1. 4 0
      app/Models/Client.php
  2. 1 1
      resources/views/app/patient/notes.blade.php

+ 4 - 0
app/Models/Client.php

@@ -631,4 +631,8 @@ class Client extends Model
         return $this->hasOne(CompanyLocation::class, 'id', 'default_mcp_company_location_id');
     }
 
+    public function hasNewNoteForPro($_pro) {
+        $count = Note::where('client_id', $this->id)->where('hcp_pro_id', $_pro->id)->where('is_cancelled', false)->where('new_or_fu_or_na', 'NEW')->count();
+        return !!$count;
+    }
 }

+ 1 - 1
resources/views/app/patient/notes.blade.php

@@ -21,7 +21,7 @@
                         <label for="" class="text-secondary text-sm mb-1">Type *</label>
                         <select name="newOrFuOrNa" class="form-control">
                             <option value="NEW">New Patient</option>
-                            <option value="FU">Follow Up</option>
+                            <option value="FU" {{$pro->is_hcp && $patient->hasNewNoteForPro($pro) ? 'selected' : ''}}>Follow Up</option>
                             <option value="NA">N/A</option>
                         </select>
                     </div>