소스 검색

Merge branch 'dev' into dev-vj

Vijayakrishnan 4 년 전
부모
커밋
918a57fdba

+ 60 - 1
app/Http/Controllers/GuestController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\Appointment;
 use App\Models\CareMonth;
 use App\Models\CareMonthEntry;
 use App\Models\Client;
@@ -12,6 +13,7 @@ use App\Models\Section;
 use App\Models\SectionTemplate;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\File;
+use Illuminate\Support\Facades\Http;
 use Illuminate\Support\Facades\Response;
 
 class GuestController extends Controller
@@ -26,7 +28,8 @@ class GuestController extends Controller
 
         $patient = null;
         if($section->note){
-           $patient = $section->note->client;
+            abort_if($section->note->is_signed_by_hcp, 401, 'Note is already signed.');
+            $patient = $section->note->client;
         }else{
             $patient = $section->client;
         }
@@ -50,4 +53,60 @@ class GuestController extends Controller
         );
     }
 
+    public function appointmentConfirmation(Request $request, $appointmentUid )
+    {
+        $appointment = Appointment::where('uid', $appointmentUid)->first();
+        abort_if(!count($appointment->confirmationRequests), 404, 'No confirmation requests on this appointment.');
+        abort_if(!$appointment, 404, 'Invalid url');
+        abort_if($appointment->status == 'CANCELLED', 404, 'Appointment has been cancelled');
+        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed'); 
+        abort_if($appointment->status == 'ABANDONED', 404, 'Appointment has been abandoned');
+       
+       return view('app.guest.appointment-confirmation', compact('appointment'));
+    }
+
+    public function processAppointmentConfirmation(Request $request){
+        $appointmentUid = $request->get('appointment_uid');
+        $appointment = Appointment::where('uid', $appointmentUid)->first();
+        abort_if(!count($appointment->confirmationRequests), 404, 'No confirmation requests on this appointment.');
+        abort_if(!$appointment, 404, 'Invalid url');
+        abort_if($appointment->status == 'CANCELLED', 404, 'Appointment has been cancelled');
+        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed'); 
+        abort_if($appointment->status == 'ABANDONED', 404, 'Appointment has been abandoned');
+
+        $decision = $request->get('decision');
+        $memo = $request->get('memo');
+        $response = null;
+        $data = [
+            'uid' => $appointment->uid,
+            'memo' => $memo
+        ];
+
+        $url = '/appointment/confirmationDecisionAccept';
+        if($decision == 'REJECT'){
+            $url = '/appointment/confirmationDecisionReject';
+        }
+
+        $response = $this->calljava($request, $url, $data);
+
+        if($response['success']){
+            return redirect()->back()->with('success', true);
+        }
+        return redirect()->back()->with('error', true);
+    }
+
+    // TODO move to utility
+    private function callJava($request, $endPoint, $data)
+    {
+        $url =  config('stag.backendUrl') . $endPoint;
+        
+        $response = Http::asForm()
+            ->withHeaders([
+                'secret' => 'superman'
+            ])
+            ->post($url, $data)
+            ->json();
+        return $response;
+    }
+
 }

+ 1 - 1
app/Http/Controllers/HomeController.php

@@ -335,7 +335,7 @@ class HomeController extends Controller
             default:
                 break;
         }
-        $patients = $query->orderBy('name_last', 'asc')->orderBy('name_first', 'asc')->get();
+        $patients = $query->orderBy('created_at', 'asc')->orderBy('name_last', 'asc')->orderBy('name_first', 'asc')->get();
         return view('app/patients', compact('patients', 'filter'));
     }
 

+ 4 - 0
app/Models/Appointment.php

@@ -17,4 +17,8 @@ class Appointment extends Model
     public function pro() {
         return $this->hasOne(Pro::class, 'id', 'pro_id');
     }
+
+    public function confirmationRequests() {
+        return $this->hasMany(AppointmentConfirmationRequest::class, 'appointment_id', 'id');
+    }
 }

+ 13 - 0
app/Models/AppointmentConfirmationRequest.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class AppointmentConfirmationRequest extends Model
+{
+    protected $table = 'appointment_confirmation_request';
+
+}

+ 52 - 0
resources/views/app/guest/appointment-confirmation.blade.php

@@ -0,0 +1,52 @@
+@extends ('layouts.guest_template')
+@section('content')
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+            <h1>Appointment Confirmation</h1>
+            <div>
+                @if(session('success'))
+                    <div class="alert alert-info">Submitted successfully</div>
+                @endif
+                @if(session('error'))
+                    <div class="alert alert-danger">Error while submitting the data. Please contact the administrator</div>
+                @endif
+                <form action="{{route('process-appointment_confirmation')}}" method="POST">
+                    @csrf
+                    <input type="hidden" name="appointment_uid" value="{{$appointment->uid}}">
+
+                    <div class="form-group">
+                        <p>Hi {{$appointment->client->name_first}} {{$appointment->client->name_last}}!</p>
+                    </div>
+
+                    <div class="form-group">
+                        <p>Please confirm your appointment</p>
+                    </div>
+
+                    <div class="form-group">
+                        <div class="check">
+                            <input type="radio" name="decision" value="ACCEPT" id="appointment_confirmation_accept" class="check-input">
+                            <label for="appointment_confirmation_accept" class="check-label">Accept</label>
+                        </div>
+                        <div class="check">
+                            <input type="radio" name="decision" value="REJECT" id="appointment_confirmation_reject" class="check-input">
+                            <label for="appointment_confirmation_reject" class="check-label">Reject</label>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <textarea name="memo" class="form-control"></textarea>
+                    </div>
+
+                    <div class="form-group">
+                        <button class="btn btn-primary">Submit</button>
+                    </div>
+
+                </form>
+            </div>
+        </div>
+    </div>
+
+</div>
+
+@endsection

+ 1 - 1
resources/views/app/log-in-as.blade.php

@@ -25,7 +25,7 @@
                     <td>{{$pro->cell_number}}</td>
                     <td>{{$pro->email}}</td>
                     <td>
-                        <form action="{{route('process-log-in-as')}}" method="POST">
+                        <form action="{{route('process-log-in-as')}}" method="POST"  target="_top">
                             @csrf
                             <input type="hidden" name="proUid" value="{{$pro->uid}}">
                             <button class="btn btn-primary">Login</button>

+ 4 - 0
resources/views/app/patients.blade.php

@@ -19,8 +19,10 @@
             <table class="table table-condensed p-0 m-0">
                 <thead class="bg-light">
                 <tr>
+                    <th></th>
                     <th class="px-3 border-0">#</th>
                     <th class="border-0">Name</th>
+                    <th class="border-0">Created At</th>
                     <th class="border-0">DOB</th>
                     <th class="border-0">Sex</th>
                     <th class="border-0">MCN</th>
@@ -32,6 +34,7 @@
                 <tbody>
                 @foreach($patients as $patient)
                     <tr>
+                        <td>{{$loop->index + 1}}</td>
                         <td class="px-3">
                             <a href="{{route('patients.view.dashboard', $patient)}}">
                                 {{$patient->chart_number}}
@@ -43,6 +46,7 @@
                             <span title="MCP Onboarding Visit Pending"><i class="fa fa-exclamation-triangle"></i></span>
                             @endif
                         </td>
+                        <td>{{friendly_date_time_short_with_tz($patient->created_at, true, 'EASTERN')}}</td>
                         <td>{{ friendly_date_time($patient->dob, false) }}</td>
                         <td>{{ $patient->sex === 'M' ? 'Male' : ($patient->sex === 'F' ? 'Female' : '-') }}</td>
                         <td>

+ 1 - 1
resources/views/layouts/template.blade.php

@@ -106,7 +106,7 @@
             @if($pro->pro_type == 'ADMIN')
             <div class="ml-1 d-inline-block text-secondary">|</div>
             <div class="d-flex align-items-center">
-                <a href="{{route('log-in-as')}}" class="small text-white ml-1">Log In As</a>
+                <a href="{{route('log-in-as')}}"  native target="_top"  class="small text-white ml-1">Log In As</a>
             </div>
             @endif
 

+ 2 - 0
routes/web.php

@@ -41,6 +41,8 @@ Route::post('/set_security_questions', 'HomeController@postSetSecurityQuestions'
 
 Route::get("/guest/section/{accessToken}", 'GuestController@section')->name('guest_section_access');
 Route::get("/guest/handout/{handoutClientUid}", 'GuestController@handout')->name('guest_handout_access');
+Route::get("/appointment-confirmation/{appointmentUid}", 'GuestController@appointmentConfirmation')->name('appointment_confirmation');
+Route::post("/process-appointment-confirmation", 'GuestController@processAppointmentConfirmation')->name('process-appointment_confirmation');
 
 Route::middleware('pro.auth')->group(function () {