Pārlūkot izejas kodu

Merge branch 'dev' into dev-vj

Vijayakrishnan 3 gadi atpakaļ
vecāks
revīzija
4bfd664735

+ 21 - 15
app/Http/Controllers/HomeController.php

@@ -216,10 +216,10 @@ class HomeController extends Controller
 
         $pendingNotesToSign = Note
             ::where(function ($query) use ($performerProID) {
-                $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+                $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->orWhere(function ($query) use ($performerProID) {
-                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->count();
         $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
@@ -227,13 +227,13 @@ class HomeController extends Controller
         // notes pending mcp sign (applicable to dnas only)
         $pendingNotesToSignMCP = Note
             ::where(function ($query) use ($performerProID) {
-                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->count();
         $keyNumbers['$pendingNotesToSignMCP'] = $pendingNotesToSignMCP;
 
         $pendingNotesToSignAllySigned = Note::where(function ($query) use ($performerProID) {
-            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false);;
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false)->where('is_core_note', false);;
         })->count();
         $keyNumbers['pendingNotesToSignAllySigned'] = $pendingNotesToSignAllySigned;
 
@@ -533,12 +533,18 @@ WHERE cl.shadow_pro_id IS NULL
 
         }
 
+        $incomingSmsMessagesPendingReply = DB::select("
+            SELECT cs.* ,c.uid as client_uid, c.name_first as client_name_first, c.name_last as client_name_last FROM client_sms cs LEFT JOIN client c ON c.id = cs.client_id
+            WHERE cs.is_reply_needed = 'YES' AND c.mcp_pro_id = :mcp_pro_id AND incoming_or_outgoing = 'INCOMING'
+            AND (cs.created_at > c.last_sms_sent_to_client_at OR c.last_sms_sent_to_client_at IS NULL)
+        ", ['mcp_pro_id' => $performer->pro->id]);
+
         return view('app/dashboard-mcp', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
             'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'mcpClientMemosCount', 'naClientMemos'));
+            'mcpClientMemos', 'mcpClientMemosCount', 'naClientMemos', 'incomingSmsMessagesPendingReply'));
     }
 
     private function dashboard_DNA(Request $request){
@@ -568,15 +574,15 @@ WHERE cl.shadow_pro_id IS NULL
 
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
 
-        $pendingNotesToSign = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->count();
+        $pendingNotesToSign = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->where('is_core_note', false)->count();
         $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
 
         // notes pending mcp sign (applicable to dnas only)
-        $pendingNotesToSignMCP = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->count();
+        $pendingNotesToSignMCP = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false)->count();
         $keyNumbers['$pendingNotesToSignMCP'] = $pendingNotesToSignMCP;
 
         $pendingNotesToSignAllySigned = Note::where(function ($query) use ($performerProID) {
-            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false);;
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false)->where('is_core_note', false);
         })->count();
         $keyNumbers['pendingNotesToSignAllySigned'] = $pendingNotesToSignAllySigned;
 
@@ -895,10 +901,10 @@ WHERE cl.shadow_pro_id IS NULL
 
         $pendingNotesToSign = Note
             ::where(function ($query) use ($performerProID) {
-                $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+                $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->orWhere(function ($query) use ($performerProID) {
-                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->count();
         $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
@@ -906,13 +912,13 @@ WHERE cl.shadow_pro_id IS NULL
         // notes pending mcp sign (applicable to dnas only)
         $pendingNotesToSignMCP = Note
             ::where(function ($query) use ($performerProID) {
-                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false);
             })
             ->count();
         $keyNumbers['$pendingNotesToSignMCP'] = $pendingNotesToSignMCP;
 
         $pendingNotesToSignAllySigned = Note::where(function ($query) use ($performerProID) {
-            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false);;
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false)->where('is_core_note', false);;
         })->count();
         $keyNumbers['pendingNotesToSignAllySigned'] = $pendingNotesToSignAllySigned;
 
@@ -1243,7 +1249,7 @@ WHERE cl.shadow_pro_id IS NULL
     {
         $performer = $this->performer();
         $pro = $performer->pro;
-        
+
         if($pro->is_enrolled_as_mcp){
             return $this->dashboard_MCP($request);
         }elseif($pro->pro_type === 'ADMIN'){
@@ -1607,9 +1613,9 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $whereCondition = implode(" AND ", $whereCondition);
 
         $matches = DB::select(
-            "SELECT (name || ' ' || address_city || ' ' || address_state || ' ' || address_zip) as text, 
+            "SELECT (name || ' ' || address_city || ' ' || address_state || ' ' || address_zip) as text,
        address_line1 as text2,
-       name, address_city as city, address_state as state, address_zip as zip, phone, fax FROM facility 
+       name, address_city as city, address_state as state, address_zip as zip, phone, fax FROM facility
        WHERE {$whereCondition} ORDER BY name", $whereParams);
         return json_encode([
             "success" => true,

+ 1 - 0
app/Http/Controllers/McpController.php

@@ -186,6 +186,7 @@ class McpController extends Controller
             'records' => Note::where('hcp_pro_id', $this->performer->pro->id)
                 ->where('is_cancelled', '<>', true)
                 ->where('is_signed_by_hcp', '<>', true)
+                ->where('is_core_note', false)
                 ->orderBy('created_at')
                 ->get()
         ];

+ 1 - 1
app/Models/Client.php

@@ -93,7 +93,7 @@ class Client extends Model
     public function notes()
     {
         return $this->hasMany(Note::class, 'client_id', 'id')
-            ->where('id', '<>', $this->core_note_id)
+           // ->where('is_core_note', false)
             ->orderBy('effective_dateest', 'desc');
     }
 

+ 4 - 0
app/Models/ClientSMS.php

@@ -7,4 +7,8 @@ namespace App\Models;
 class ClientSMS extends Model
 {
     protected $table = 'client_sms';
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
 }

+ 1 - 0
app/Models/Pro.php

@@ -343,6 +343,7 @@ class Pro extends Model
     function get_notes_pending_signature_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)
+            ->where('is_core_note', '<>', true)
             ->where('is_signed_by_hcp', '<>', true)
             ->count();
     }

+ 1 - 2
resources/views/app/dashboard-mcp.blade.php

@@ -272,7 +272,6 @@
                     </div>
                 </div>
                 <div class="col-md-9">
-
                     <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
                         <div class="col-md-6 mcp-theme-1">
                             <div class="card mb-4">
@@ -313,7 +312,7 @@
                                         Messages
                                     </strong>
                                 </div>
-                                <div class="card-body">
+                                <div class="card-body p-0">
                                     @include('app.mcp.dashboard.messages')
                                 </div>
                             </div>

+ 28 - 1
resources/views/app/mcp/dashboard/messages.blade.php

@@ -1 +1,28 @@
-<h1>No messages</h1>
+@if(!$incomingSmsMessagesPendingReply || !count($incomingSmsMessagesPendingReply))
+    <div class="px-2 py-3">No messages</div>
+@else
+    <table class="table table-sm m-0">
+        <tbody>
+        @foreach($incomingSmsMessagesPendingReply as $msg)
+            <tr>
+                <td class="px-1">
+                    <a href="{{route('patients.view.sms', $msg->client_uid)}}">
+                        {{$msg->client_name_first}} {{$msg->client_name_last}}
+                    </a>
+                    <div class="text-secondary text-sm text-nowrap">
+                        {{friendlier_date_time($msg->created_at)}}
+                    </div>
+                </td>
+                <td class="px-1">
+                    {{$msg->body}}
+                </td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    @if(count($incomingSmsMessagesPendingReply) > 10)
+        <div class="p-2 border-top bg-light text-center">
+            Showing 1 to 10 of {{$incomingSmsMessagesPendingReply}} unstamped memos
+        </div>
+    @endif
+@endif

+ 0 - 2
resources/views/app/patient/notes.blade.php

@@ -11,8 +11,6 @@
 
                 <div moe>
                     <a start show class="py-0 mb-3">Add</a>
-
-
                     <form url="/api/note/createUsingTemplate"
                           redir="/patients/view/{{$patient->uid}}/notes/view/[data]"
                           class="mcp-theme-1">

+ 27 - 1
resources/views/app/patient/sms.blade.php

@@ -31,16 +31,42 @@
                 <th class="px-2 text-secondary w-25">From</th>
                 <th class="px-2 text-secondary w-25">To</th>
                 <th class="px-2 text-secondary w-50">Content</th>
+                @if($performer->pro->pro_type == 'ADMIN')
+                    <th></th>
+                @endif
             </tr>
             </thead>
             <tbody>
             @foreach($patient->smses as $sms)
-                <tr>
+                <tr class="{{$sms->created_at > $patient->last_sms_sent_to_client_at && $sms->is_reply_needed == 'YES' ? 'bg-warning': ''}}">
                     <td class="px-2">{{ friendly_date_time($sms->created_at) }}</td>
                     <td class="px-2">{{ ucwords($sms->incoming_or_outgoing) }}</td>
                     <td class="px-2">{{ $sms->from_number }}</td>
                     <td class="px-2">{{ $sms->to_number }}</td>
                     <td class="px-2">{{ $sms->body }}</td>
+                    @if($performer->pro->pro_type == 'ADMIN')
+                        <td>
+                            <div moe relative>
+                                <a start show class="">Update Is Reply Needed</a>
+                                <form url="/api/clientSms/updateIsReplyNeeded" class="mcp-theme-1" right>
+                                    <input type="hidden" name="uid" value="{{ $sms->uid }}">
+                                    <div class="mb-2">
+                                        <label for="" class="text-sm text-secondary mb-1">Is reply needed?</label>
+                                        <select class="form-control form-control-sm" name="isReplyNeeded" value="{{$patient->cell_number}}">
+                                            <option value="UNKNOWN">--</option>
+                                            <option value="YES">Yes</option>
+                                            <option value="NO">No</option>
+                                        </select>
+                                    </div>
+
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    @endif
                 </tr>
             @endforeach
             </tbody>