update message summary
This commit is contained in:
@@ -10,6 +10,9 @@ use App\Models\Message;
|
|||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
use App\Models\Livechat;
|
use App\Models\Livechat;
|
||||||
use App\Models\Person;
|
use App\Models\Person;
|
||||||
|
use App\Models\Prescription;
|
||||||
|
use App\Models\PrescriptionItem;
|
||||||
|
use App\Models\Drug;
|
||||||
use App\Models\OLDLMS\User;
|
use App\Models\OLDLMS\User;
|
||||||
use App\Models\OLDLMS\UserDetail;
|
use App\Models\OLDLMS\UserDetail;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -234,8 +237,6 @@ class ChatController extends Controller
|
|||||||
if($address){
|
if($address){
|
||||||
$address = $address->sAlamat;
|
$address = $address->sAlamat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ini Untul Chat
|
// Ini Untul Chat
|
||||||
@@ -259,6 +260,19 @@ class ChatController extends Controller
|
|||||||
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
||||||
$healthSertificate = True;
|
$healthSertificate = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$prescription = Prescription::where('livechat_id', $livechat->id)->first();
|
||||||
|
$prescriptionItems = PrescriptionItem::with('drug')->where('prescription_id',$prescription->id)->get();
|
||||||
|
$prescriptions = [];
|
||||||
|
if ($prescriptionItems){
|
||||||
|
foreach($prescriptionItems as $item){
|
||||||
|
$row['medicine'] = $item->drug->name;
|
||||||
|
$row['direction'] = $item->direction;
|
||||||
|
$row['signa'] = $item->signa;
|
||||||
|
$row['note'] = $item->note;
|
||||||
|
array_push($prescriptions, $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Berikan respons yang sesuai ke klien
|
// Berikan respons yang sesuai ke klien
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Message sent successfully',
|
'message' => 'Message sent successfully',
|
||||||
@@ -292,6 +306,7 @@ class ChatController extends Controller
|
|||||||
'to' => $data->lastItem(),
|
'to' => $data->lastItem(),
|
||||||
],
|
],
|
||||||
'summary' => $consultationSummary,
|
'summary' => $consultationSummary,
|
||||||
|
'prescription' => $prescriptions
|
||||||
|
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\View;
|
|||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Kreait\Firebase\Messaging\CloudMessage;
|
use Kreait\Firebase\Messaging\CloudMessage;
|
||||||
use Kreait\Laravel\Firebase\Facades\Firebase;
|
use Kreait\Laravel\Firebase\Facades\Firebase;
|
||||||
|
use App\Events\ChatMessageSent;
|
||||||
|
|
||||||
class ChatDoctorController extends Controller
|
class ChatDoctorController extends Controller
|
||||||
{
|
{
|
||||||
@@ -249,6 +250,14 @@ class ChatDoctorController extends Controller
|
|||||||
|
|
||||||
$user = UserLMS::where('nID',$livechat->patient_id)->first();
|
$user = UserLMS::where('nID',$livechat->patient_id)->first();
|
||||||
|
|
||||||
|
// Ambil Send End Chat
|
||||||
|
$message = Message::create([
|
||||||
|
'content' => 'end-chat',
|
||||||
|
'from_user' => $livechat->doctor_id,
|
||||||
|
'channel_id' => $channel->id,
|
||||||
|
'type' => 'end-chat'
|
||||||
|
]);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
if ($user->nIDUser) { // Jika Dependent yang request
|
if ($user->nIDUser) { // Jika Dependent yang request
|
||||||
$user = UserLMS::where('nIDUser',$livechat->patient_id)->first();
|
$user = UserLMS::where('nIDUser',$livechat->patient_id)->first();
|
||||||
@@ -287,6 +296,7 @@ class ChatDoctorController extends Controller
|
|||||||
'organization_id' => $livechat->organization_id,
|
'organization_id' => $livechat->organization_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$prescriptionItem = [];
|
||||||
if ($request->prescriptions) {
|
if ($request->prescriptions) {
|
||||||
foreach ($request->prescriptions as $prescription) {
|
foreach ($request->prescriptions as $prescription) {
|
||||||
$prescriptionItem = PrescriptionItem::create([
|
$prescriptionItem = PrescriptionItem::create([
|
||||||
@@ -299,6 +309,27 @@ class ChatDoctorController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$channel = Channel::where([
|
||||||
|
'member_id' => $livechat->patient_id,
|
||||||
|
'doctor_id' => $livechat->doctor_id
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'livechat' => $livechat,
|
||||||
|
'prescription_items' => $prescriptionItem
|
||||||
|
];
|
||||||
|
|
||||||
|
// Ambil data dari request
|
||||||
|
$message = Message::create([
|
||||||
|
'content' => 'summary',
|
||||||
|
'from_user' => $livechat->doctor_id,
|
||||||
|
'channel_id' => $channel->id,
|
||||||
|
'type' => 'summary'
|
||||||
|
]);
|
||||||
|
|
||||||
|
ChatMessageSent::dispatch($message);
|
||||||
|
|
||||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||||
} else {
|
} else {
|
||||||
return response()->json(['message' => 'Livechat not found'], 404);
|
return response()->json(['message' => 'Livechat not found'], 404);
|
||||||
|
|||||||
@@ -15,4 +15,9 @@ class Prescription extends Model
|
|||||||
'organization_id',
|
'organization_id',
|
||||||
'icd_code'
|
'icd_code'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function items()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PrescriptionItem::class, 'prescription_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,8 @@ class PrescriptionItem extends Model
|
|||||||
'signa',
|
'signa',
|
||||||
'direction'
|
'direction'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function drug(){
|
||||||
|
return $this->hasOne(Drug::class, 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user