Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
913
Modules/Client/Http/Controllers/Api/DailyMonitoringController.php
Executable file
913
Modules/Client/Http/Controllers/Api/DailyMonitoringController.php
Executable file
@@ -0,0 +1,913 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\DailyMonitoring;
|
||||
use App\Models\RequestDailyMonitoring;
|
||||
use App\Models\MedicalPlan;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\File as Files;
|
||||
use Modules\Internal\Transformers\DailyMonitoringResource;
|
||||
use App\Models\File;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
/**
|
||||
* Bagaskoro BSD 27-10-2023
|
||||
*
|
||||
* Controller untuk daily monitoring
|
||||
*/
|
||||
class DailyMonitoringController extends Controller
|
||||
{
|
||||
protected $path_for_store = 'public/lab_result';
|
||||
protected function messages()
|
||||
{
|
||||
return [
|
||||
'required' => ':attribute harus diisi',
|
||||
'integer' => ':attribute harus angka',
|
||||
'unique' => ':attribute (:input) sudah ada',
|
||||
'max' => ':attribute maximal :max karakter',
|
||||
'exists' => ':attribute (:input) tidak ditemukan',
|
||||
'numeric' => ':attribute harus angka',
|
||||
'digits_between'=> ':attribute maximal :max digit minimal :min digit'
|
||||
];
|
||||
}
|
||||
|
||||
public function GetMemberList(Request $request)
|
||||
{
|
||||
$startDate = $request->start_date ? Carbon::parse($request->start_date) : Carbon::today();
|
||||
$endDate = $request->end_date ? Carbon::parse($request->end_date)->addDay() : Carbon::today()->addDay();
|
||||
|
||||
$memberList = DB::table('request_log_daily_monitorings')
|
||||
->leftJoin('request_logs', 'request_log_daily_monitorings.request_log_id', '=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->leftJoin('organizations', 'organizations.id', '=', 'request_logs.organization_id')
|
||||
->select(
|
||||
'members.member_id',
|
||||
'members.name',
|
||||
'members.birth_date',
|
||||
'request_logs.type_of_member as member_type',
|
||||
'members.members_effective_date AS startdate',
|
||||
'members.members_expire_date AS enddate',
|
||||
'request_logs.submission_date as addmision_date',
|
||||
'organizations.name as provider',
|
||||
'request_logs.organization_id',
|
||||
'request_logs.code',
|
||||
// Using a subquery to fetch medical_plan
|
||||
DB::raw('(SELECT plan FROM request_log_medical_plan rdm WHERE rdm.request_log_daily_monitoring_id = request_log_daily_monitorings.id AND type = 1 LIMIT 1) as medical_plan'),
|
||||
DB::raw('(SELECT plan FROM request_log_medical_plan rdm WHERE rdm.request_log_daily_monitoring_id = request_log_daily_monitorings.id AND type = 2 LIMIT 1) as non_medical_plan'),
|
||||
'request_log_daily_monitorings.*'
|
||||
)
|
||||
->whereNull('request_logs.deleted_at') // Use whereNull() for checking NULL
|
||||
->when($request->search, function ($q, $search) {
|
||||
$q->where(function ($subQ) use ($search) {
|
||||
$subQ->where('members.member_id', 'LIKE', "%{$search}%");
|
||||
$subQ->orWhere('members.name', 'LIKE', "%{$search}%");
|
||||
});
|
||||
})
|
||||
->when($startDate, function ($q) use ($startDate) {
|
||||
$q->where('request_log_daily_monitorings.submission_date', '>=', $startDate);
|
||||
})
|
||||
->when($endDate, function ($q) use ($endDate) {
|
||||
$q->where('request_log_daily_monitorings.submission_date', '<=', Carbon::parse($endDate)->addDay());
|
||||
})
|
||||
->orderBy('request_logs.created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
return Helper::paginateResources(DailyMonitoringResource::collection($memberList));
|
||||
}
|
||||
|
||||
/**
|
||||
* Claim List - by member id
|
||||
*/
|
||||
public function GetClaimList(Request $request, $member_id)
|
||||
{
|
||||
$memberDetail = DB::table('members')
|
||||
->select('id','member_id','name')
|
||||
->where('member_id', $member_id)
|
||||
->first();
|
||||
|
||||
$claimList = DB::table('request_logs')
|
||||
->leftJoin('services', 'services.code', '=', 'request_logs.service_code')
|
||||
->leftJoin('members', 'members.id', '=', 'request_logs.member_id')
|
||||
->select('request_logs.id','request_logs.submission_date AS admission_date','request_logs.discharge_date','request_logs.code','services.name as service_name','request_logs.status','members.name', 'members.member_id')
|
||||
->where('request_logs.service_code', 'IP')
|
||||
->where('request_logs.deleted_at', null)
|
||||
// ->where('request_logs.status_final_log', 'approved')
|
||||
->where("request_logs.member_id", "=", $memberDetail->id)
|
||||
->where("request_logs.organization_id", "=", $request->organization_id)
|
||||
->when($request->search, function ($q, $search) {
|
||||
$q->where('request_logs.code', 'LIKE', "%".$search."%");
|
||||
})
|
||||
->orderBy("request_logs.created_at", "desc")
|
||||
// ->get()
|
||||
->paginate();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => [
|
||||
'member_detail'=> $memberDetail,
|
||||
'claim_list' => $claimList,
|
||||
]
|
||||
],200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail Monitoring List - by claim_code
|
||||
*/
|
||||
public function GetDetailMonitoringList(Request $request, $request_code)
|
||||
{
|
||||
// get id request log
|
||||
$request_logs = DB::table('request_logs')
|
||||
->select('id','organization_id')
|
||||
->where('code', $request_code)
|
||||
->first();
|
||||
|
||||
$detail_list = RequestDailyMonitoring::where('request_log_id', empty($request_logs) == false ? $request_logs->id : '')
|
||||
->orderBy("submission_date", "desc")
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => [
|
||||
'detail_list'=> $detail_list,
|
||||
'organization_id' => $request_logs ? $request_logs->organization_id : 0
|
||||
]
|
||||
],200);
|
||||
}
|
||||
|
||||
public function GetDetailMonitoringListbyID(Request $request, $id)
|
||||
{
|
||||
|
||||
$detail = RequestDailyMonitoring::where('id', $id)
|
||||
->orderBy("created_at", "desc")
|
||||
->first();
|
||||
|
||||
if ($detail) {
|
||||
// Ubah menjadi array agar bisa dimodifikasi
|
||||
$detailArray = $detail->toArray();
|
||||
|
||||
// Ubah nama key dari request_log_id menjadi log_id
|
||||
$detailArray['log_code'] = $detailArray['request_log_id'];
|
||||
unset($detailArray['request_log_id']);
|
||||
} else {
|
||||
$detailArray = null;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => $detailArray,
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
public function UpdateDetailMonitoringbyID(Request $request)
|
||||
{
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'log_code' => 'required',
|
||||
'reason' => 'required',
|
||||
],$this->messages());
|
||||
|
||||
// validation error
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $validator->getMessageBag()
|
||||
],400);
|
||||
}
|
||||
try {
|
||||
// insert claim daily monitoring
|
||||
$db_response = RequestDailyMonitoring::where('id', $request->id)
|
||||
->update([
|
||||
'request_log_id' => $request->log_code,
|
||||
'submission_date' => $request->submission_date,
|
||||
'subject' => $request->subject,
|
||||
'object' => $request->objective,
|
||||
'sistole' => $request->sistole,
|
||||
'diastole' => $request->diastole,
|
||||
'body_temperature' => $request->body_temperature,
|
||||
'respiration_rate' => $request->respiration_rate,
|
||||
'analysis' => $request->analysis,
|
||||
'lab_date' => $request->lab_date,
|
||||
'provider' => $request->provider,
|
||||
'examination' => $request->examination,
|
||||
'doctor_1' => $request->doctor_1,
|
||||
'doctor_2' => $request->doctor_2,
|
||||
'temp_diagnosis' => $request->temp_diagnosis,
|
||||
'final_diagnosis' => $request->final_diagnosis,
|
||||
'approval_pendamping' => $request->approval_pendamping,
|
||||
'description' => $request->keterangan,
|
||||
'note' => $request->catatan,
|
||||
'reason' => $request->reason,
|
||||
'created_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
// cek medical plan
|
||||
$num_medical_plan = 0;
|
||||
foreach ($request->medical_plan as $row) {
|
||||
if ($row['medical_plan_str']) {
|
||||
$num_medical_plan++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_medical_plan == 0) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => [
|
||||
'medical_plan' => ['medical plan harus diisi']
|
||||
],
|
||||
'data' => []
|
||||
],400);
|
||||
}
|
||||
if ($request->medical_plan){
|
||||
// delete medical plan
|
||||
DB::table('request_log_medical_plan')
|
||||
->where([
|
||||
'request_log_daily_monitoring_id' => $request->id,
|
||||
'type' => 1
|
||||
])
|
||||
->delete();
|
||||
// insert medical plan
|
||||
foreach ($request->medical_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $request->id,
|
||||
'plan' => $row['medical_plan_str'],
|
||||
'type' => 1,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->non_medikamentosa_plan){
|
||||
// delete medical plan
|
||||
DB::table('request_log_medical_plan')
|
||||
->where([
|
||||
'request_log_daily_monitoring_id' => $request->id,
|
||||
'type' => 2
|
||||
])
|
||||
->delete();
|
||||
// insert non medical plan
|
||||
foreach ($request->non_medikamentosa_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $request->id,
|
||||
'plan' => $row['non_medikamentosa_plan_str'],
|
||||
'type' => 2,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// insert file result
|
||||
if ($request->confirmation_medical_leter){
|
||||
// $fileCurrents = File::where([
|
||||
// 'fileable_id' => $request->id,
|
||||
// 'type' => 'confirmation-medical-letter',
|
||||
// ])->get();
|
||||
// if ($fileCurrents){
|
||||
// foreach($fileCurrents as $fileCurrent){
|
||||
// if (Files::exists($fileCurrent->path)) {
|
||||
// Files::delete();
|
||||
// }
|
||||
// File::find($fileCurrent->id)->delete();
|
||||
// }
|
||||
// }
|
||||
foreach ($request->confirmation_medical_leter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $request->id,
|
||||
'type' => 'confirmation-medical-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
if ($request->medical_action_letter){
|
||||
// $fileCurrents = File::where([
|
||||
// 'fileable_id' => $request->id,
|
||||
// 'type' => 'medical-action-letter',
|
||||
// ])->get();
|
||||
// if ($fileCurrents){
|
||||
// foreach($fileCurrents as $fileCurrent){
|
||||
// if (Files::exists($fileCurrent->path)) {
|
||||
// Files::delete();
|
||||
// }
|
||||
// File::find($fileCurrent->id)->delete();
|
||||
// }
|
||||
// }
|
||||
foreach ($request->medical_action_letter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $request->id,
|
||||
'type' => 'medical-action-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
if ($request->result){
|
||||
// $fileCurrents = File::where([
|
||||
// 'fileable_id' => $request->id,
|
||||
// 'type' => 'laboratorium-result',
|
||||
// ])->get();
|
||||
// if ($fileCurrents){
|
||||
// foreach($fileCurrents as $fileCurrent){
|
||||
// if (Files::exists($fileCurrent->path)) {
|
||||
// Files::delete();
|
||||
// }
|
||||
// File::find($fileCurrent->id)->delete();
|
||||
// }
|
||||
// }
|
||||
foreach ($request->result as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $request->id,
|
||||
'type' => 'laboratorium-result',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
],200);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Detail Monitoring List
|
||||
*/
|
||||
public function AddDetailMonitoringList(Request $request, $claim_code)
|
||||
{
|
||||
$request->merge(['claim_code' => $claim_code]);
|
||||
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'claim_code' => 'required|exists:claim_requests,code',
|
||||
'subject' => 'required',
|
||||
'sistole' => 'required|numeric',
|
||||
'diastole' => 'required|numeric',
|
||||
'body_temperature' => 'required|numeric',
|
||||
'respiration_rate' => 'required|numeric',
|
||||
'analysis' => 'required',
|
||||
'complaints' => 'required',
|
||||
'medical_plan' => 'required',
|
||||
],$this->messages());
|
||||
|
||||
// validation error
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $validator->getMessageBag()
|
||||
],400);
|
||||
}
|
||||
|
||||
// get claim request
|
||||
$claim_request = DB::table('claim_requests')
|
||||
->select('id')
|
||||
->where('code', $claim_code)
|
||||
->first();
|
||||
|
||||
// get claim
|
||||
$claim = DB::table('claims')
|
||||
->select('id')
|
||||
->where('claim_request_id', $claim_request->id)
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// insert claim daily monitoring
|
||||
$db_response = DailyMonitoring::create([
|
||||
'claim_id' => $claim->id,
|
||||
'subject' => $request->subject,
|
||||
'objective' => $request->objective,
|
||||
'sistole' => $request->sistole,
|
||||
'diastole' => $request->diastole,
|
||||
'body_temperature' => $request->body_temperature,
|
||||
'respiration_rate' => $request->respiration_rate,
|
||||
'analysis' => $request->analysis,
|
||||
'complaints' => $request->complaints,
|
||||
]);
|
||||
|
||||
|
||||
// cek medical plan
|
||||
$num_medical_plan = 0;
|
||||
|
||||
foreach ($request->medical_plan as $row) {
|
||||
if ($row['medical_plan_str']) {
|
||||
$num_medical_plan++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_medical_plan == 0) {
|
||||
DB::rollBack();
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => [
|
||||
'medical_plan' => ['medical plan harus diisi']
|
||||
],
|
||||
'data' => []
|
||||
],400);
|
||||
}
|
||||
|
||||
// insert medical plan
|
||||
foreach ($request->medical_plan as $row) {
|
||||
MedicalPlan::create([
|
||||
'claim_daily_monitoring_id' => $db_response->id,
|
||||
'plan' => $row['medical_plan_str'],
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
],200);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Detail Request LOG LIST
|
||||
*/
|
||||
public function AddDetailMonitoringListRequestLog(Request $request, $request_code)
|
||||
{
|
||||
$request->merge(['request_code' => $request_code]);
|
||||
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'request_code' => 'required|exists:request_logs,code',
|
||||
'subject' => 'required',
|
||||
'submission_date' => 'required',
|
||||
'body_temperature' => 'required',
|
||||
'sistole' => 'required',
|
||||
'diastole' => 'required',
|
||||
'respiration_rate' => 'required',
|
||||
'analysis' => 'required',
|
||||
'medical_plan' => 'required',
|
||||
'non_medikamentosa_plan' => 'required',
|
||||
],$this->messages());
|
||||
|
||||
// validation error
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $validator->getMessageBag()
|
||||
],400);
|
||||
}
|
||||
|
||||
// get claim request
|
||||
$request_log = DB::table('request_logs')
|
||||
->select('id')
|
||||
->where('code', $request_code)
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// insert claim daily monitoring
|
||||
$db_response = RequestDailyMonitoring::create([
|
||||
'request_log_id' => $request_log->id,
|
||||
'submission_date' => $request->submission_date,
|
||||
'subject' => $request->subject,
|
||||
'object' => $request->objective,
|
||||
'sistole' => $request->sistole,
|
||||
'diastole' => $request->diastole,
|
||||
'body_temperature' => $request->body_temperature,
|
||||
'respiration_rate' => $request->respiration_rate,
|
||||
'analysis' => $request->analysis,
|
||||
'lab_date' => $request->lab_date,
|
||||
'provider' => $request->provider,
|
||||
'examination' => $request->examination,
|
||||
'created_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
|
||||
// cek medical plan
|
||||
$num_medical_plan = 0;
|
||||
foreach ($request->medical_plan as $row) {
|
||||
if ($row['medical_plan_str']) {
|
||||
$num_medical_plan++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_medical_plan == 0) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => [
|
||||
'medical_plan' => ['medical plan harus diisi']
|
||||
],
|
||||
'data' => []
|
||||
],400);
|
||||
}
|
||||
|
||||
// insert medical plan
|
||||
foreach ($request->medical_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $db_response->id,
|
||||
'plan' => $row['medical_plan_str'],
|
||||
'type' => 1,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
|
||||
// insert non medical plan
|
||||
foreach ($request->non_medikamentosa_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $db_response->id,
|
||||
'plan' => $row['non_medikamentosa_plan_str'],
|
||||
'type' => 2,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
|
||||
// insert file result
|
||||
if ($request->confirmation_medical_leter){
|
||||
foreach ($request->confirmation_medical_leter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'confirmation-medical-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
if ($request->medical_action_letter){
|
||||
foreach ($request->medical_action_letter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'medical-action-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
if ($request->result){
|
||||
foreach ($request->result as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'laboratorium-result',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
],200);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function AddListRequestLog(Request $request)
|
||||
{
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'log_code' => 'required|exists:request_logs,id',
|
||||
'subject' => 'required',
|
||||
'submission_date' => 'required',
|
||||
'body_temperature' => 'required',
|
||||
'sistole' => 'required',
|
||||
'diastole' => 'required',
|
||||
'respiration_rate' => 'required',
|
||||
'analysis' => 'required',
|
||||
'medical_plan' => 'required',
|
||||
'non_medikamentosa_plan' => 'required',
|
||||
],$this->messages());
|
||||
|
||||
// validation error
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $validator->getMessageBag()
|
||||
],400);
|
||||
}
|
||||
|
||||
// get claim request
|
||||
$request_log = DB::table('request_logs')
|
||||
->select('id')
|
||||
->where('id', $request->log_code)
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// insert claim daily monitoring
|
||||
$db_response = RequestDailyMonitoring::create([
|
||||
'request_log_id' => $request->log_code,
|
||||
'submission_date' => $request->submission_date,
|
||||
'doctor_1' => $request->doctor_1,
|
||||
'doctor_2' => $request->doctor_2,
|
||||
'temp_diagnosis' => $request->temp_diagnosis,
|
||||
'final_diagnosis' => $request->final_diagnosis,
|
||||
'approval_pendamping' => $request->approval_pendamping,
|
||||
'description' => $request->keterangan,
|
||||
'note' => $request->catatan,
|
||||
'subject' => $request->subject,
|
||||
'object' => $request->objective,
|
||||
'sistole' => $request->sistole,
|
||||
'diastole' => $request->diastole,
|
||||
'body_temperature' => $request->body_temperature,
|
||||
'respiration_rate' => $request->respiration_rate,
|
||||
'analysis' => $request->analysis,
|
||||
'lab_date' => $request->lab_date,
|
||||
'provider' => $request->provider,
|
||||
'examination' => $request->examination,
|
||||
'created_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
|
||||
// cek medical plan
|
||||
$num_medical_plan = 0;
|
||||
foreach ($request->medical_plan as $row) {
|
||||
if ($row['medical_plan_str']) {
|
||||
$num_medical_plan++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_medical_plan == 0) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => [
|
||||
'medical_plan' => ['medical plan harus diisi']
|
||||
],
|
||||
'data' => []
|
||||
],400);
|
||||
}
|
||||
|
||||
// insert medical plan
|
||||
foreach ($request->medical_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $db_response->id,
|
||||
'plan' => $row['medical_plan_str'],
|
||||
'type' => 1,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
|
||||
// insert non medical plan
|
||||
foreach ($request->non_medikamentosa_plan as $row) {
|
||||
DB::table('request_log_medical_plan')->insert([
|
||||
'request_log_daily_monitoring_id' => $db_response->id,
|
||||
'plan' => $row['non_medikamentosa_plan_str'],
|
||||
'type' => 2,
|
||||
'created_at' => date('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
|
||||
// insert file result
|
||||
if ($request->confirmation_medical_leter){
|
||||
foreach ($request->confirmation_medical_leter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'confirmation-medical-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
if ($request->medical_action_letter){
|
||||
foreach ($request->medical_action_letter as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'medical-action-letter',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
if ($request->result){
|
||||
foreach ($request->result as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$orignalName = $file->getClientOriginalName();
|
||||
$fileName = $name . '.' . $extension;
|
||||
$path = $file->storeAs($this->path_for_store, $fileName);
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'laboratorium-result',
|
||||
'name' => $name,
|
||||
'original_name' => $orignalName,
|
||||
'extension' => $extension,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
// $file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
],200);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Listing Daily Monitoring
|
||||
*/
|
||||
public function deleteDetailMonitoringListRequestLog(Request $request, $id)
|
||||
{
|
||||
$listDailyMonitoring = RequestDailyMonitoring::find($id);
|
||||
$listDailyMonitoring->reason = $request->reason;
|
||||
$listDailyMonitoring->save();
|
||||
|
||||
if (!$listDailyMonitoring) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => "Data not found.",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$listDailyMonitoring->delete();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "Delete success",
|
||||
'data' => $listDailyMonitoring
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete File Daily Monitoring
|
||||
*/
|
||||
public function deleteFileDetailMonitoringListRequestLog(Request $request, $id){
|
||||
$fileCurrent = File::where([
|
||||
'id' => $id,
|
||||
])->first();
|
||||
if ($fileCurrent){
|
||||
if (Files::exists($fileCurrent->path)) {
|
||||
Files::delete();
|
||||
}
|
||||
$fileCurrent->deleted_at = now();
|
||||
$fileCurrent->reason = $request->reason;
|
||||
$fileCurrent->deleted_by = auth()->user()->id;
|
||||
$fileCurrent->save();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "Delete success",
|
||||
'data' => $fileCurrent
|
||||
], 200);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => "Data not found.",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Status Request LOG
|
||||
*/
|
||||
public function UpdateListRequestLog(Request $request, $request_code)
|
||||
{
|
||||
// get claim request
|
||||
$request_log = DB::table('request_logs')
|
||||
->where('code', $request_code)
|
||||
->update([
|
||||
'discharge_date' => now(),
|
||||
'updated_by' => auth()->user()->id,
|
||||
'updated_at' => now()
|
||||
]);
|
||||
if ($request_log) {
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
], 200);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ use Modules\Internal\Http\Controllers\Api\FormulariumTemplateController;
|
||||
use Modules\Internal\Http\Controllers\Api\AuditTrailController;
|
||||
use Modules\Internal\Http\Controllers\Api\CorporateController;
|
||||
use Modules\Internal\Http\Controllers\Api\NavigationController;
|
||||
use Modules\Client\Http\Controllers\Api\DailyMonitoringController;
|
||||
use Modules\Internal\Http\Controllers\Api\RequestLogController;
|
||||
|
||||
use Modules\Internal\Http\Controllers\Api\UserManagementController;
|
||||
|
||||
@@ -35,6 +37,8 @@ use Modules\Internal\Http\Controllers\Api\UserManagementController;
|
||||
|
||||
Route::prefix('client')->group(function () {
|
||||
|
||||
Route::get('codeLog', [RequestLogController::class, 'codeLog']);
|
||||
|
||||
Route::controller(AuthController::class)->group(function () {
|
||||
Route::post('login', 'login');
|
||||
Route::post('verify-code', 'validateOtp');
|
||||
@@ -80,6 +84,15 @@ Route::prefix('client')->group(function () {
|
||||
Route::get('download-ecard/{member_id}', [CorporateMemberController::class, 'downloadEcard']);
|
||||
Route::get('view_card/{member_id}', [CorporateMemberController::class, 'viewECard']);
|
||||
});
|
||||
|
||||
Route::get('memberlist', [DailyMonitoringController::class, 'GetMemberList']);
|
||||
|
||||
// Daily Monitoring
|
||||
Route::prefix('daily_monitoring')->group(function () {
|
||||
Route::get('detail/{claim_code}/list', [DailyMonitoringController::class, 'GetDetailMonitoringList']);
|
||||
Route::get('detail/{id}/edit', [DailyMonitoringController::class, 'GetDetailMonitoringListbyID']);
|
||||
});
|
||||
|
||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||
|
||||
Route::post('claim-requests', [ClaimRequestController::class, 'store'])->name('claim-requests.store');
|
||||
|
||||
@@ -127,6 +127,69 @@ class ClaimController extends Controller
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
|
||||
public function getClaimDetails(Request $request)
|
||||
{
|
||||
// Get the 'ids' array from the request
|
||||
$ids = $request->input('ids');
|
||||
|
||||
// Ensure the 'ids' array is not empty
|
||||
if (empty($ids)) {
|
||||
return response()->json(['error' => 'No IDs provided'], 400);
|
||||
}
|
||||
|
||||
// Use the SQL Query Builder with whereIn to fetch data
|
||||
$claimDetails = DB::table('claim_requests')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->whereIn('claim_requests.id', $ids)
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.invoice_no',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'request_logs.created_at as submission_date',
|
||||
'request_logs.submission_date as addmission_date',
|
||||
'request_logs.discharge_date',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->get();
|
||||
|
||||
// Return the fetched claim details as a JSON response
|
||||
return response()->json($claimDetails);
|
||||
}
|
||||
|
||||
|
||||
public function filesProvider(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 50;
|
||||
|
||||
503
Modules/Internal/Http/Controllers/Api/DashboardController.php
Executable file
503
Modules/Internal/Http/Controllers/Api/DashboardController.php
Executable file
@@ -0,0 +1,503 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use App\Models\OLDLMS\Dokter;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$start_date = $request->start_date
|
||||
? Carbon::parse($request->start_date)->startOfDay()->toDateTimeString()
|
||||
: null;
|
||||
|
||||
$end_date = $request->end_date
|
||||
? Carbon::parse($request->end_date)->endOfDay()->toDateTimeString()
|
||||
: null;
|
||||
|
||||
$type = $request->type; // 0 = harian, 1 = mingguan, 2 = bulanan
|
||||
$status = $request->status; // 0 = semua, 1 = berhasil, 2 = abandon, 3 = gagal
|
||||
|
||||
// Menyesuaikan filter berdasarkan type (harian, mingguan, bulanan)
|
||||
// if ($type == 1) {
|
||||
// // Filter mingguan
|
||||
// $start_date = Carbon::now()->startOfWeek()->toDateTimeString();
|
||||
// $end_date = Carbon::now()->endOfWeek()->toDateTimeString();
|
||||
|
||||
// } elseif ($type == 2) {
|
||||
// // Filter bulanan
|
||||
// $start_date = Carbon::now()->startOfMonth()->toDateTimeString();
|
||||
// $end_date = Carbon::now()->endOfMonth()->toDateTimeString();
|
||||
// }
|
||||
|
||||
// Query awal
|
||||
$query = Livechat::query();
|
||||
|
||||
// Filter berdasarkan tanggal
|
||||
if ($start_date && $end_date) {
|
||||
$query->whereBetween('dRequestTime', [$start_date, $end_date]);
|
||||
}
|
||||
|
||||
// Filter berdasarkan status
|
||||
if ($status == 1) {
|
||||
$query->where('sStatus', '2'); // Berhasil
|
||||
} elseif ($status == 2) {
|
||||
$query->where('sStatus', '1'); // Abandon
|
||||
} elseif ($status == 3) {
|
||||
$query->whereNotIn('sStatus', ['1', '2']); // Gagal (selain 1 dan 2)
|
||||
}
|
||||
|
||||
$liveChat = $query->get();
|
||||
|
||||
// Mapping status transaksi
|
||||
$statusMapping = [
|
||||
"2" => "Berhasil",
|
||||
"1" => "Abandon",
|
||||
];
|
||||
|
||||
// Inisialisasi counter status
|
||||
$statusCount = [
|
||||
"Berhasil" => 0,
|
||||
"Abandon" => 0,
|
||||
"Gagal" => 0,
|
||||
];
|
||||
|
||||
// Hitung jumlah status
|
||||
foreach ($liveChat as $chat) {
|
||||
$statusLabel = isset($statusMapping[$chat->sStatus])
|
||||
? $statusMapping[$chat->sStatus]
|
||||
: "Gagal";
|
||||
$statusCount[$statusLabel]++;
|
||||
}
|
||||
|
||||
// Format response seperti yang diminta
|
||||
$transaksiData = [
|
||||
["name" => "Berhasil", "value" => $statusCount["Berhasil"], "color" => "#4CAF50"],
|
||||
["name" => "Gagal", "value" => $statusCount["Gagal"], "color" => "#F44336"],
|
||||
["name" => "Abandon", "value" => $statusCount["Abandon"], "color" => "#9E9E9E"],
|
||||
];
|
||||
|
||||
return response()->json($transaksiData);
|
||||
}
|
||||
|
||||
public function listBarChart(Request $request)
|
||||
{
|
||||
$start_date = $request->start_date
|
||||
? Carbon::parse($request->start_date)->startOfDay()
|
||||
: Carbon::now()->startOfMonth();
|
||||
|
||||
$end_date = $request->end_date
|
||||
? Carbon::parse($request->end_date)->endOfDay()
|
||||
: Carbon::now()->endOfMonth();
|
||||
|
||||
$status = $request->status; // 0 = semua, 1 = berhasil, 2 = abandon, 3 = gagal
|
||||
$type = $request->type; // 0 = harian, 1 = mingguan, 2 = bulanan
|
||||
|
||||
// Query awal
|
||||
$query = Livechat::query();
|
||||
|
||||
// Filter berdasarkan rentang tanggal yang dimasukkan user
|
||||
$query->whereBetween('dRequestTime', [$start_date, $end_date]);
|
||||
|
||||
// Filter berdasarkan status
|
||||
if ($status == 1) {
|
||||
$query->where('sStatus', '2'); // Berhasil
|
||||
} elseif ($status == 2) {
|
||||
$query->where('sStatus', '1'); // Abandon
|
||||
} elseif ($status == 3) {
|
||||
$query->whereNotIn('sStatus', ['1', '2']); // Gagal (selain 1 dan 2)
|
||||
}
|
||||
|
||||
$liveChat = $query->get();
|
||||
|
||||
// Mengelompokkan data berdasarkan tipe request (harian, mingguan, atau bulanan)
|
||||
$groupedData = [];
|
||||
|
||||
foreach ($liveChat as $chat) {
|
||||
if ($type == 1) {
|
||||
// Mingguan (contoh: "01 Jan 2025 - 07 Jan 2025")
|
||||
$weekStart = Carbon::parse($chat->dRequestTime)->startOfWeek();
|
||||
$weekEnd = Carbon::parse($chat->dRequestTime)->endOfWeek();
|
||||
$groupKey = $weekStart->format('d M Y') . ' - ' . $weekEnd->format('d M Y');
|
||||
} elseif ($type == 2) {
|
||||
// Bulanan (contoh: "Jan 2025")
|
||||
$groupKey = Carbon::parse($chat->dRequestTime)->translatedFormat('M Y');
|
||||
} else {
|
||||
// Harian (format "1 Jan 2025 - 2 Feb 2025")
|
||||
$groupKey = Carbon::parse($chat->dRequestTime)->format('j M Y');
|
||||
}
|
||||
|
||||
if (!isset($groupedData[$groupKey])) {
|
||||
$groupedData[$groupKey] = [
|
||||
"date" => $groupKey,
|
||||
"Berhasil" => 0,
|
||||
"Abandon" => 0,
|
||||
"Gagal" => 0,
|
||||
];
|
||||
}
|
||||
|
||||
if ($chat->sStatus == "2") {
|
||||
$groupedData[$groupKey]["Berhasil"]++;
|
||||
} elseif ($chat->sStatus == "1") {
|
||||
$groupedData[$groupKey]["Abandon"]++;
|
||||
} else {
|
||||
$groupedData[$groupKey]["Gagal"]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Konversi hasil ke dalam array untuk response JSON
|
||||
$result = array_values($groupedData);
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
|
||||
public function listDokter(Request $request)
|
||||
{
|
||||
$idDokter = [
|
||||
'68268',
|
||||
'75047',
|
||||
'75046',
|
||||
'75045',
|
||||
'75044',
|
||||
'75043',
|
||||
'75027',
|
||||
'75021',
|
||||
'75020',
|
||||
]; // List dokter
|
||||
|
||||
$listDokters = Dokter::with([])->whereIn('nIDUser', $idDokter)->get();
|
||||
|
||||
$result = $listDokters->map(function ($dokter) {
|
||||
return [
|
||||
'id' => $dokter->nIDUser,
|
||||
'code' => $dokter->nIDUser,
|
||||
'name' => $dokter->user->fullName,
|
||||
'online' => $dokter->sStatus,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
public function listPerformaDokter(Request $request)
|
||||
{
|
||||
$start_date = $request->start_date
|
||||
? Carbon::parse($request->start_date)->startOfDay()
|
||||
: Carbon::now()->startOfMonth();
|
||||
|
||||
$end_date = $request->end_date
|
||||
? Carbon::parse($request->end_date)->endOfDay()
|
||||
: Carbon::now()->endOfMonth();
|
||||
|
||||
$status = $request->status; // 0 = semua, 1 = berhasil, 2 = abandon, 3 = gagal
|
||||
$type = $request->type; // 0 = harian, 1 = mingguan, 2 = bulanan
|
||||
|
||||
$nIDDokter = $request->nIDDokter;
|
||||
|
||||
// Query awal
|
||||
$query = Livechat::with('doctor');
|
||||
|
||||
// Filter berdasarkan rentang tanggal yang dimasukkan user
|
||||
$query->whereBetween('dRequestTime', [$start_date, $end_date]);
|
||||
|
||||
if (!empty($nIDDokter)) {
|
||||
$query->whereIn('nIDDokter', $nIDDokter);
|
||||
}
|
||||
|
||||
// Filter berdasarkan status
|
||||
if ($status == 1) {
|
||||
$query->where('sStatus', '2'); // Berhasil
|
||||
} elseif ($status == 2) {
|
||||
$query->where('sStatus', '1'); // Abandon
|
||||
} elseif ($status == 3) {
|
||||
$query->whereNotIn('sStatus', ['1', '2']); // Gagal
|
||||
}
|
||||
|
||||
// Ambil data livechat
|
||||
$liveChats = $query->get();
|
||||
|
||||
// Data akhir yang akan dikembalikan
|
||||
$groupedData = [];
|
||||
|
||||
foreach ($liveChats as $chat) {
|
||||
$dokterId = $chat->nIDDokter;
|
||||
$dokterName = $chat->doctor->user->fullName ?? 'Unknown'; // Ambil nama dokter dari relasi
|
||||
if (!isset($groupedData[$dokterId])) {
|
||||
$groupedData[$dokterId] = [
|
||||
"name" => $dokterName,
|
||||
"Berhasil" => 0,
|
||||
"Abandon" => 0,
|
||||
"Gagal" => 0,
|
||||
];
|
||||
}
|
||||
|
||||
if ($chat->sStatus == "2") {
|
||||
$groupedData[$dokterId]["Berhasil"]++;
|
||||
} elseif ($chat->sStatus == "1") {
|
||||
$groupedData[$dokterId]["Abandon"]++;
|
||||
} else {
|
||||
$groupedData[$dokterId]["Gagal"]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Konversi hasil ke dalam array untuk response JSON
|
||||
$result = array_values($groupedData);
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
return Icd::when($request->search ?? null, function($icd, $search) {
|
||||
$icd->where('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('code', 'LIKE', '%'.$search.'%');
|
||||
})->limit(10)->get();
|
||||
}
|
||||
|
||||
public function import(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
]);
|
||||
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
|
||||
$import = new ImportService();
|
||||
$import->read(Storage::path('temp/'.$file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
||||
|
||||
$imported_icd_data = 0;
|
||||
$failed_icd_data = [];
|
||||
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||
$doc_headers_indexes = [];
|
||||
foreach ($sheet->getRowIterator() as $index => $row) {
|
||||
if ($index == 1) { // First Row Must be Header
|
||||
foreach ($row->getCells() as $index => $cell) {
|
||||
$title = $cell->getValue();
|
||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
||||
$title = rtrim($title);
|
||||
$title = ltrim($title);
|
||||
$doc_headers_indexes[$index] = $title;
|
||||
}
|
||||
|
||||
// Write Header to File
|
||||
$result_headers = array_merge($doc_headers_indexes, ['Ingest Code', 'Ingest Note']);
|
||||
$import->addArrayToRow($result_headers);
|
||||
|
||||
// TODO Validate if First Row not Header
|
||||
} else { // Next Row Should be Data
|
||||
$row_data = [];
|
||||
$row_map = [
|
||||
0 => 'ICD_Code',
|
||||
1 => 'Description',
|
||||
];
|
||||
|
||||
foreach ($row->getCells() as $header_index => $cell) {
|
||||
if (isset($row_map[$header_index])) {
|
||||
$value = $cell->getValue();
|
||||
$value = preg_replace( "/\r|\n/", " ", $value );
|
||||
$value = preg_replace('/\xc2\xa0/', " ", $value );
|
||||
$value = rtrim($value);
|
||||
$value = ltrim($value);
|
||||
$row_data[$row_map[$header_index]] = $cell->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
try { // Process the Row Data
|
||||
if (
|
||||
empty($row_data['ICD_Code']) &&
|
||||
empty($row_data['Description'])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Save the Row
|
||||
$icdService = new IcdService();
|
||||
$icdService->handleIcdRow($row_data, $id);
|
||||
|
||||
// Write Success Result to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
'Ingest Code' => 200,
|
||||
'Ingest Note' => 'Success',
|
||||
]), $sheet->getName());
|
||||
$imported_icd_data++;
|
||||
|
||||
} catch (ImportRowException $e) {
|
||||
// Write Data Validation Error to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
'Ingest Code' => $e->getCode(),
|
||||
'Ingest Note' => $e->getMessage(),
|
||||
]), $sheet->getName());
|
||||
$failed_icd_data[] = ['row_number' => $index, 'error' => $e->getMessage(), 'data' => $row_data];
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception($e);
|
||||
// Write Server Error to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
'Ingest Code' => 500,
|
||||
'Ingest Note' => env('APP_DEBUG') ? $e->getMessage() : 'Server Error',
|
||||
]), $sheet->getName());
|
||||
$failed_icd_data[] = ['row_number' => $index, 'error' => $e->getMessage(), 'data' => $row_data];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break; // Only Read First Row
|
||||
}
|
||||
$import->reader->close();
|
||||
Storage::delete('temp/'.$file_name);
|
||||
$import->writer->close();
|
||||
|
||||
return [
|
||||
'total_successed_row' => $imported_icd_data,
|
||||
'total_failed_row' => count($failed_icd_data),
|
||||
'failed_row' => $failed_icd_data,
|
||||
'result_file' => [
|
||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
||||
'name' => 'result-'.$file_name,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function activation(Request $request, $diagnosis_id)
|
||||
{
|
||||
$request->validate([
|
||||
'active' => 'required'
|
||||
]);
|
||||
|
||||
$Icd = Icd::findOrFail($diagnosis_id);
|
||||
$Icd->active = $request->active == '1';
|
||||
|
||||
if ($Icd->save()) {
|
||||
return response()->json([
|
||||
'icd' => $Icd,
|
||||
'message' => 'Status Updated Successfully'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function generateIcdList(Request $request, $diagnosis_id){
|
||||
// Mendapatkan data yang akan diekspor (misalnya, dari database)
|
||||
$data = Icd::where('icd_template_id', $diagnosis_id)->get()->toArray();
|
||||
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/TemplateICDList.xlsx'));
|
||||
/** Create a style with the StyleBuilder */
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
->build();
|
||||
|
||||
// Menulis header kolom
|
||||
$headers_map_to_table_fields = $this->icdService->listing_doc_headers;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields, $style);
|
||||
|
||||
$writer->addRow($headerRow);
|
||||
|
||||
// Menulis data
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $item) {
|
||||
$rowData = [
|
||||
// $item['rev'], // Rev
|
||||
// $item['version'], // Version
|
||||
$item['code'], // Code
|
||||
// $item['parent_code'], // Parent Code
|
||||
$item['name'], // Name
|
||||
// $item['description'], // Description
|
||||
// $item['active'] == 1 ? 'Active' : 'Inactive', // Status
|
||||
// $item['type'], // Type
|
||||
];
|
||||
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
}
|
||||
|
||||
// Menutup penulis
|
||||
$writer->close();
|
||||
|
||||
// Mengembalikan response untuk mengunduh file
|
||||
$filePath = public_path('files/TemplateICDList.xlsx');
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Diagnosis ICD List " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/TemplateICDList.xlsx')
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,627 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\File;
|
||||
use App\Helpers\Helper;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Common\Entity\Style\CellAlignment;
|
||||
|
||||
class InvoicePaymentController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 10;
|
||||
$results = DB::table('invoice_payments')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('invoice_payments.invoice_number', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('invoice_payments.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('invoice_payments.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('status') , function ($query, $status) {
|
||||
$query->where(function ($query) use ($status) {
|
||||
$query->where('invoice_payments.status', '=', $status);
|
||||
});
|
||||
})
|
||||
// ->where('claim_management', '=', 1)
|
||||
->select(
|
||||
'invoice_payments.id',
|
||||
'invoice_payments.invoice_number',
|
||||
'invoice_payments.start_date',
|
||||
'invoice_payments.end_date',
|
||||
'invoice_payments.created_at',
|
||||
'invoice_payments.status',
|
||||
)
|
||||
->groupBy('invoice_payments.invoice_number')
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
public function claim(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 10;
|
||||
$results = DB::table('claim_requests')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->leftJoin('invoice_payment_details', function ($join) {
|
||||
$join->on('invoice_payment_details.claim_request_id', '=', 'claim_requests.id')
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
})
|
||||
// ->leftJoin('member_plans', 'member_plans.member_id', '=', 'members.id')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('members.name', 'like', "%" . $search . "%");
|
||||
$query->orWhere('claim_requests.code', 'like', "%" . $search . "%");
|
||||
$query->orWhere('request_logs.code', 'like', "%" . $search . "%");
|
||||
$query->orWhere('members.member_id', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('claim_requests.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('claim_requests.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('provider') , function ($query, $provider) {
|
||||
$query->where(function ($query) use ($provider) {
|
||||
$query->where('request_logs.organization_id', '=', $provider);
|
||||
});
|
||||
})
|
||||
->where('claim_management', '=', 1)
|
||||
->when($request->input('param') !== 'Edit', function ($query) {
|
||||
$query->whereNotIn('claim_requests.id', function ($query) {
|
||||
$query->select('claim_request_id')
|
||||
->from('invoice_payment_details');
|
||||
});
|
||||
})
|
||||
->when($request->input('param') === 'Edit', function ($query) use ($request) {
|
||||
$query->where(function ($q) use ($request) {
|
||||
$q->whereNotIn('claim_requests.id', function ($subquery) {
|
||||
$subquery->select('claim_request_id')
|
||||
->from('invoice_payment_details')
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
})
|
||||
->orWhereIn('claim_requests.id', function ($subquery) use ($request) {
|
||||
$subquery->select('claim_request_id')
|
||||
->from('invoice_payment_details')
|
||||
->where('invoice_payment_details.invoice_payment_id', $request->input('invoiceID'))
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
});
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'claim_requests.created_at',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->groupBy('claim_requests.id')
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
public function detail($id)
|
||||
{
|
||||
$invoice['invoice_payments'] = DB::table('invoice_payments')
|
||||
->where('invoice_payments.id', $id)
|
||||
->select('invoice_payments.*')
|
||||
->get();
|
||||
|
||||
$invoice['invoice_payment_details'] = DB::table('invoice_payment_details')
|
||||
->leftJoin('claim_requests', 'claim_requests.id', '=', 'invoice_payment_details.claim_request_id')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->where('invoice_payment_details.invoice_payment_id', $id)
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0)
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.invoice_no',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'request_logs.created_at as submission_date',
|
||||
'request_logs.submission_date as addmission_date',
|
||||
'request_logs.discharge_date',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->groupBy('claim_requests.id')
|
||||
->get();
|
||||
$payments = DB::table('invoice_payments')
|
||||
->leftJoin('files', function ($join) {
|
||||
$join->on('files.fileable_id', '=', 'invoice_payments.id')
|
||||
->where('files.type', 'files-proof-payment')
|
||||
->whereNull('files.deleted_by')
|
||||
->orWhere('files.deleted_by', 0);
|
||||
})
|
||||
->where('invoice_payments.invoice_number', $invoice['invoice_payments'][0]->invoice_number)
|
||||
->select(
|
||||
'invoice_payments.id',
|
||||
'files.id as file_id',
|
||||
'invoice_payments.amount_paid',
|
||||
'invoice_payments.payment_number',
|
||||
DB::raw("CONCAT('" . env('APP_URL') . "/storage/', files.path) as path"),
|
||||
'files.original_name'
|
||||
)
|
||||
->orderBy('invoice_payments.payment_number', 'asc')
|
||||
->get();
|
||||
|
||||
$invoice['files'] = $payments->groupBy('payment_number')->map(function ($group) {
|
||||
return [
|
||||
'id' => $group->first()->id,
|
||||
'amount_paid' => $group->first()->amount_paid,
|
||||
'payment_number' => $group->first()->payment_number,
|
||||
'files' => $group->map(function ($file) {
|
||||
return [
|
||||
'file_id' => $file->file_id,
|
||||
'path' => $file->path,
|
||||
'original_name' => $file->original_name
|
||||
];
|
||||
})->toArray()
|
||||
];
|
||||
})->values()->toArray();
|
||||
|
||||
if ($invoice['invoice_payments']->isEmpty()) {
|
||||
return response()->json(['message' => 'Invoice tidak ditemukan'], 404);
|
||||
}
|
||||
|
||||
return response()->json($invoice);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'payments' => $request->payments
|
||||
];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'invoice_number' => 'required',
|
||||
'invoice_date' => 'required',
|
||||
'start_date' => 'required',
|
||||
'end_date' => 'required',
|
||||
'payments' => 'required',
|
||||
'invoice_payment_details' => 'required',
|
||||
], [
|
||||
'invoice_number.required' => trans('Validation.required',['attribute' => 'Nomor Invoice']),
|
||||
'invoice_date.required' => trans('Validation.required',['attribute' => 'Tanggal Invoice']),
|
||||
'start_date.required' => trans('Validation.required',['attribute' => 'Tanggal Mulai']),
|
||||
'end_date.required' => trans('Validation.required',['attribute' => 'Tanggal Akhir']),
|
||||
'payments.required' => trans('Validation.required',['attribute' => 'Jumlah Bayar']),
|
||||
'invoice_payment_details.required' => trans('Validation.required',['attribute' => 'Nomor Claim']),
|
||||
]);
|
||||
if ($validator->fails())
|
||||
{
|
||||
return response()->json(['message' => $validator->errors()], 400);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$invoiceNumber = $request->invoice_number;
|
||||
foreach ($request->payments as $valuePayments) {
|
||||
if($request->param === 'Edit')
|
||||
{
|
||||
$invoiceNumber = DB::table('invoice_payments')
|
||||
->where('id', $valuePayments['id'])
|
||||
->value('invoice_number');
|
||||
}
|
||||
// **Cek apakah invoice_number sudah ada di database**
|
||||
$existingInvoice = DB::table('invoice_payments')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('payment_number', $valuePayments['paymentNumber'])
|
||||
// ->where('amount_paid', $this->normalizeCurrency($valuePayments['amount']))
|
||||
->exists();
|
||||
|
||||
//Insert
|
||||
if (!$existingInvoice) {
|
||||
$lastInsertedId = DB::table('invoice_payments')
|
||||
->insertGetId([
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'payment_number' => $valuePayments['paymentNumber'],
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->start_date,
|
||||
'amount_paid' => $this->normalizeCurrency($valuePayments['amount']),
|
||||
'status' => 'submitted',
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
foreach ($request->invoice_payment_details as $value)
|
||||
{
|
||||
// **Cek apakah claim_request_id sudah ada untuk invoice_payment_id ini**
|
||||
$existingClaim = DB::table('invoice_payment_details')
|
||||
->where('claim_request_id', $value)
|
||||
->exists();
|
||||
|
||||
if (!$existingClaim) {
|
||||
DB::table('invoice_payment_details')
|
||||
->insert([
|
||||
'invoice_payment_id' => $lastInsertedId,
|
||||
'claim_request_id' => $value,
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (!empty($valuePayments['files']) && is_array($valuePayments['files'])) {
|
||||
foreach ($valuePayments['files'] as $file) {
|
||||
$pathFile = File::storeFile('files-proof-payment', $lastInsertedId, $file);
|
||||
File::updateOrCreate([
|
||||
'fileable_type' => 'App\Models\InvoicePayment',
|
||||
'fileable_id' => $lastInsertedId,
|
||||
'type' => 'files-proof-payment',
|
||||
'name' => File::getFileName('files-proof-payment', $lastInsertedId, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Edit
|
||||
$invoicePaymentId = DB::table('invoice_payments')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('payment_number', $valuePayments['paymentNumber'])
|
||||
->value('id');
|
||||
|
||||
DB::table('invoice_payments')
|
||||
->where('id', $invoicePaymentId)
|
||||
->update([
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'amount_paid' => $this->normalizeCurrency($valuePayments['amount']),
|
||||
'updated_by' => auth()->user()->id,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$existingClaims = DB::table('invoice_payment_details')
|
||||
->where('invoice_payment_id', $invoicePaymentId)
|
||||
->pluck('claim_request_id')
|
||||
->toArray();
|
||||
|
||||
$newClaims = $request->invoice_payment_details;
|
||||
|
||||
// Data yang mau di-insert
|
||||
$claimsToInsert = array_diff($newClaims, $existingClaims);
|
||||
foreach ($claimsToInsert as $claim) {
|
||||
DB::table('invoice_payment_details')->insert([
|
||||
'invoice_payment_id' => $invoicePaymentId,
|
||||
'claim_request_id' => $claim,
|
||||
'updated_by' => auth()->user()->id,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Data yang mau di-delete (tidak ada di data baru)
|
||||
$claimsToDelete = array_diff($existingClaims, $newClaims);
|
||||
if (!empty($claimsToDelete)) {
|
||||
DB::table('invoice_payment_details')
|
||||
->where('invoice_payment_id', $invoicePaymentId)
|
||||
->whereIn('claim_request_id', $claimsToDelete)
|
||||
->update([
|
||||
'deleted_by' => auth()->user()->id,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Handle existing files
|
||||
$existingFiles = DB::table('files')
|
||||
->where('files.fileable_id', $invoicePaymentId)
|
||||
|
||||
->where('files.type', 'files-proof-payment')
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
$newFiles = [];
|
||||
if (!empty($valuePayments['existingFiles']) && is_array($valuePayments['existingFiles'])) {
|
||||
$newFiles = array_column($valuePayments['existingFiles'], 'file_id');
|
||||
}
|
||||
|
||||
|
||||
$filesToDelete = array_diff($existingFiles, $newFiles);
|
||||
|
||||
if (!empty($filesToDelete)) {
|
||||
DB::table('files')
|
||||
->whereIn('id', $filesToDelete)
|
||||
->update([
|
||||
'deleted_by' => auth()->user()->id,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//File New
|
||||
if (!empty($valuePayments['files']) && is_array($valuePayments['files'])) {
|
||||
foreach ($valuePayments['files'] as $file) {
|
||||
$pathFile = File::storeFile('files-proof-payment', $invoicePaymentId, $file);
|
||||
File::updateOrCreate([
|
||||
'fileable_type' => 'App\Models\InvoicePayment',
|
||||
'fileable_id' => $invoicePaymentId,
|
||||
'type' => 'files-proof-payment',
|
||||
'name' => File::getFileName('files-proof-payment', $invoicePaymentId, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['message' => 'Data berhasil disimpan'], 200);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeCurrency($amount) {
|
||||
return (int) preg_replace('/\D/', '', $amount);
|
||||
}
|
||||
|
||||
public function submitStatus(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'valueStatus' => 'required|in:submitted,accepted,partial_paid,paid,decline',
|
||||
'valueID' => 'required|integer|exists:invoice_payments,id',
|
||||
]);
|
||||
|
||||
$update = DB::table('invoice_payments')
|
||||
->where('id', $request->valueID)
|
||||
->update([
|
||||
'status' => $request->valueStatus,
|
||||
'updated_at' => now(),
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
if (!$update) {
|
||||
return response()->json(['message' => 'Data tidak ditemukan atau tidak diperbarui'], 404);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Status berhasil diperbarui']);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$start_date = $request->input('start_date') ? $request->input('start_date') : 'all';
|
||||
$end_date = $request->input('end_date') ? $request->input('end_date') : 'all';
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile(public_path('files/Report-Data-Invoice-Management-'.$start_date.'-'.$end_date.'.xlsx'));
|
||||
$header = [
|
||||
'No',
|
||||
'Nomor Invoice',
|
||||
'Pembayaran Ke',
|
||||
'Tanggal Invoice',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Nominal Pembayaran',
|
||||
'Created At',
|
||||
'Updated At',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($header, $style);
|
||||
$writer->addRow($headerRow);
|
||||
// ============================
|
||||
$results = DB::table('invoice_payments')
|
||||
// ->leftJoin('member_plans', 'member_plans.member_id', '=', 'members.id')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('invoice_payments.invoice_number', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('claim_requests.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('claim_requests.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'invoice_payments.*')
|
||||
->get();
|
||||
$no=0;
|
||||
$gr_total = 0;
|
||||
$header = [
|
||||
'No',
|
||||
'Nomor Invoice',
|
||||
'Pembayaran Ke',
|
||||
'Tanggal Invoice',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Nominal Pembayaran',
|
||||
'Created At',
|
||||
'Updated At',
|
||||
];
|
||||
foreach($results as $item)
|
||||
{
|
||||
$gr_total += $item->amount_paid;
|
||||
$no++;
|
||||
$rowData = [
|
||||
$no,
|
||||
$item->invoice_number,
|
||||
$item->payment_number,
|
||||
$item->invoice_date,
|
||||
$item->start_date,
|
||||
$item->end_date,
|
||||
$item->amount_paid,
|
||||
$item->created_at,
|
||||
$item->updated_at
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
//->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData, $style);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
$footer = [
|
||||
'Grand Total',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$gr_total,
|
||||
'',
|
||||
'',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$footerRow = WriterEntityFactory::createRowFromArray($footer, $style);
|
||||
$writer->addRow($footerRow);
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => 'Report-Data-Invoice-Management-'. $start_date.'-'.$end_date,
|
||||
"file_url" => url('files/Report-Data-Invoice-Management-'. $start_date.'-'.$end_date.'.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -674,6 +674,313 @@ class LivechatController extends Controller
|
||||
|
||||
$fileUrl = url('storage/temp/' . $fileName);
|
||||
|
||||
return Helper::responseJson([
|
||||
"file_url" => $fileUrl
|
||||
]);
|
||||
}
|
||||
|
||||
public function exportMonthly(Request $request)
|
||||
{
|
||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
||||
|
||||
$liveChats = Livechat::with('userInsurance',
|
||||
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
||||
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
||||
'appointment:nID,sPaymentStatus,sPaymentMethod',
|
||||
'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment',
|
||||
'healthCare:nID,sHealthCare',
|
||||
'prescription',
|
||||
'rujukan'
|
||||
)
|
||||
->whereHas('userInsurance', function (Builder $query) {
|
||||
// Kondisi pada relasi userInsurance
|
||||
$query->where('nIDInsurance', 107); // khusus inhealth
|
||||
})
|
||||
->where(function (Builder $query) use ($startDate, $endDate) {
|
||||
// $query->where('nIDAppointment', '!=', null);
|
||||
// $query->where('nIDAppointment', '!=', '');
|
||||
if ($startDate) {
|
||||
$query->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
if ($endDate) {
|
||||
$endDate = date('Y-m-d', strtotime($endDate . ' +1 day'));
|
||||
$query->where('dCreateOn', '<', $endDate);
|
||||
}
|
||||
})
|
||||
->orderBy('nID', 'desc')
|
||||
->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn', 'sNoSpj', 'dRequestTime', 'dAcceptTime', 'dStartTime', 'dEndTime']);
|
||||
|
||||
$headers = [
|
||||
['value' => 'ConsultationId', 'cell' => 'A1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'No SJP', 'cell' => 'B1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'PKSKD', 'cell' => 'C1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'PKSNM', 'cell' => 'D1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Card Number', 'cell' => 'E1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'NamaPasien', 'cell' => 'F1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'JenisKelamin', 'cell' => 'G1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'TanggalLahir', 'cell' => 'H1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Usia', 'cell' => 'I1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Produk', 'cell' => 'J1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Plan', 'cell' => 'K1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'DependencyStatus', 'cell' => 'L1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'TanggalKonsultasi', 'cell' => 'M1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Keluhan', 'cell' => 'N1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Kode Diagnosa', 'cell' => 'O1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Diagnosa', 'cell' => 'P1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'StartTime', 'cell' => 'Q1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'EndTime', 'cell' => 'R1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'DurasiKonsultasi', 'cell' => 'S1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'StatusKonsultasi', 'cell' => 'T1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'PrescriptionNumber', 'cell' => 'U1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'NamaDokter', 'cell' => 'V1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Jenis Dokter', 'cell' => 'W1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Rujuk (Ya/Tidak)', 'cell' => 'X1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Obat', 'cell' => 'AA1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'By', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
];
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($header['cell'], $header['value']);
|
||||
|
||||
// if ($header['mergeCell'] === true) {
|
||||
// $sheet->mergeCells($header['cell'] . ':' . $header['mergeToCell']);
|
||||
// }
|
||||
|
||||
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
||||
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
}
|
||||
|
||||
$startFrom = 2;
|
||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
$paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'N/A';
|
||||
$fullNameDoctor = '-';
|
||||
if (!empty($liveChat->doctor->user)) {
|
||||
$fullNameDoctor = '';
|
||||
|
||||
if ($liveChat->doctor->user->detail !== null) {
|
||||
if ($liveChat->doctor->user->detail->sTitlePrefix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitlePrefix . '. ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->full_name !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->full_name . ' ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->detail->sTitleSuffix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitleSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$recordType = 'P';
|
||||
if ($nIDUser){
|
||||
$recordType = 'D';
|
||||
}
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$statusLivechat = "Request TC";
|
||||
break;
|
||||
case 1:
|
||||
$statusLivechat = "Accepted by Doctor but User not Payment";
|
||||
break;
|
||||
case 2:
|
||||
$statusLivechat = "Payment Success";
|
||||
break;
|
||||
case 3:
|
||||
$statusLivechat = "Decline by Doctor";
|
||||
break;
|
||||
case 4:
|
||||
$statusLivechat = "Payment Expired";
|
||||
break;
|
||||
default:
|
||||
$statusLivechat = "Cancel by Patient";
|
||||
}
|
||||
|
||||
$requestTime = Carbon::parse($liveChat->dRequestTime);
|
||||
$acceptTime = Carbon::parse($liveChat->dAcceptTime);
|
||||
$startTime = Carbon::parse($liveChat->dStartTime);
|
||||
$endTime = Carbon::parse($liveChat->dEndTime);
|
||||
|
||||
// Hitung selisih waktu response
|
||||
if ($requestTime && $acceptTime) {
|
||||
$diff = $requestTime->diff($acceptTime);
|
||||
$responseTimeDiff = sprintf('%02d:%02d:%02d', $diff->h, $diff->i, $diff->s);
|
||||
} else {
|
||||
$responseTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Hitung selisih waktu chat
|
||||
if ($startTime && $endTime) {
|
||||
$diffChatTime = $startTime->diff($endTime);
|
||||
$chatTimeDiff = sprintf('%02d:%02d:%02d', $diffChatTime->h, $diffChatTime->i, $diffChatTime->s);
|
||||
} else {
|
||||
$chatTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Set nilai responseTime dan chatTime
|
||||
$responseTime = $responseTimeDiff;
|
||||
$chatTime = $chatTimeDiff;
|
||||
|
||||
|
||||
$diagnosa = '-';
|
||||
$diagnosaCode = '-';
|
||||
if($liveChat->summary){
|
||||
$diagnosis = explode(', ', $liveChat->summary->sAssessment);
|
||||
|
||||
if ($diagnosis) {
|
||||
$diagnosaArray = [];
|
||||
$diagnosaCodeArray = [];
|
||||
foreach($diagnosis as $data){
|
||||
$diagnosaArray[] = Helper::diagnosisName($data); // Tambahkan diagnosis ke array
|
||||
$diagnosaCodeArray[] = $data; // Tambahkan diagnosis ke array
|
||||
}
|
||||
|
||||
$diagnosa = implode('; ', $diagnosaArray); // Gabungkan array dengan tanda koma
|
||||
$diagnosaCode = implode('; ', $diagnosaCodeArray); // Gabungkan array dengan tanda koma
|
||||
}
|
||||
}
|
||||
|
||||
$tebusResep = 'Belum Ditebus';
|
||||
$paymentTebus = '-';
|
||||
if ($liveChat->prescription){
|
||||
// Tanggal target (misalnya, dari database atau input)
|
||||
$tanggalResep = Carbon::parse($liveChat->prescription->dTanggalResep);
|
||||
|
||||
// Tanggal hari ini
|
||||
$tanggalNow = Carbon::now();
|
||||
|
||||
// Menghitung selisih hari
|
||||
$selisihHari = $tanggalNow->diffInDays($tanggalResep);
|
||||
if ($selisihHari > 1){
|
||||
$tebusResep = 'Resep Kadaluarsa';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->sIsDownload == 1){
|
||||
$tebusResep = 'Offline';
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
};
|
||||
} else {
|
||||
$tebusResep = '-';
|
||||
}
|
||||
|
||||
switch ($liveChat->user->nIDHubunganKeluarga) {
|
||||
case 9:
|
||||
$nIDHubunganKeluarga = "Peserta"; // Parent
|
||||
break;
|
||||
case 4:
|
||||
$nIDHubunganKeluarga = 'Istri'; // Spouse
|
||||
break;
|
||||
case 5:
|
||||
$nIDHubunganKeluarga = 'Anak'; // Child
|
||||
break;
|
||||
case 3:
|
||||
$nIDHubunganKeluarga = 'Suami'; // Husband
|
||||
break;
|
||||
default:
|
||||
$nIDHubunganKeluarga = '-'; // No need to set $nIDHubunganKeluarga as it's already set to default value
|
||||
break;
|
||||
}
|
||||
|
||||
if ($liveChat->user->relation && $nIDHubunganKeluarga == '-'){
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$obat = '-';
|
||||
if($liveChat->prescription){
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$obatArray[] = $data->sItemName .' - '. $data->nQty;
|
||||
}
|
||||
|
||||
$obat = implode('; ',$obatArray);
|
||||
}
|
||||
};
|
||||
$sheet->setCellValue('A' . $startFrom, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('B' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||
$sheet->setCellValue('C' . $startFrom, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
$sheet->setCellValue('D' . $startFrom, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||
$sheet->setCellValue('E' . $startFrom, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||
$sheet->setCellValue('F' . $startFrom, $liveChat->user->full_name ?? '-');
|
||||
$sheet->setCellValue('G' . $startFrom, $liveChat->user->detail->dTanggalLahir ?? '-');
|
||||
$sheet->setCellValue('H' . $startFrom, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
||||
$sheet->setCellValue('I' . $startFrom, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
||||
$sheet->setCellValue('J' . $startFrom, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
||||
$sheet->setCellValue('K' . $startFrom, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
||||
$sheet->setCellValue('L' . $startFrom, $nIDHubunganKeluarga ?? '-');
|
||||
$sheet->setCellValue('M' . $startFrom, $requestTime->format('Y-m-d'));
|
||||
$sheet->setCellValue('N' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
$sheet->setCellValue('O' . $startFrom, $diagnosaCode ?? '-');
|
||||
$sheet->setCellValue('P' . $startFrom, $diagnosa ?? '-');
|
||||
$sheet->setCellValue('Q' . $startFrom, $startTime->format('H:i:s'));
|
||||
$sheet->setCellValue('R' . $startFrom, $endTime->format('H:i:s'));
|
||||
$sheet->setCellValue('S' . $startFrom, $chatTime);
|
||||
// $sheet->setCellValue('O' . $startFrom, $recordType);
|
||||
// $sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
||||
// $sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
||||
$sheet->setCellValue('T' . $startFrom, $statusLivechat);
|
||||
$sheet->setCellValue('U' . $startFrom, $liveChat->prescription->sKodeResep ?? '-');
|
||||
$sheet->setCellValue('V' . $startFrom, $fullNameDoctor);
|
||||
$sheet->setCellValue('W' . $startFrom, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||
$sheet->setCellValue('X' . $startFrom, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||
$sheet->setCellValue('Y' . $startFrom, $liveChat->rujukan->sDepartement ?? '-' );
|
||||
|
||||
$sheet->setCellValue('Z' . $startFrom, '-');
|
||||
$sheet->setCellValue('AA' . $startFrom, $tebusResep);
|
||||
|
||||
$sheet->setCellValue('AB' . $startFrom, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
||||
|
||||
// $sheet->setCellValue('AF' . $startFrom, $paymentTebus);
|
||||
// $sheet->setCellValue('AG' . $startFrom, $liveChat->rujukan->nIDHealthcare ?? '-');
|
||||
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||
$startFrom++;
|
||||
}
|
||||
|
||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB'] as $header) {
|
||||
// if ($header === 'A') {
|
||||
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px');
|
||||
// } elseif ($header === 'H' || $header === 'I') {
|
||||
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
|
||||
// } else {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true);
|
||||
// }
|
||||
}
|
||||
|
||||
// $spreadsheet->getActiveSheet()->getStyle('A2:A' . $startFrom)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
|
||||
$sheet->getDefaultRowDimension()->setRowHeight(-1);
|
||||
$sheet->setTitle('Live Chat Report');
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
ob_start();
|
||||
$writer->save('php://output');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$fileName = 'result-' . now()->getPreciseTimestamp(3) . '-livechat-report.xlsx';
|
||||
Storage::disk('public')->put('temp/' . $fileName, $content);
|
||||
|
||||
$fileUrl = url('storage/temp/' . $fileName);
|
||||
|
||||
return Helper::responseJson([
|
||||
"file_url" => $fileUrl
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||
use Modules\Internal\Http\Controllers\Api\CityController;
|
||||
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
||||
use Modules\Internal\Http\Controllers\Api\ClaimRequestController;
|
||||
use Modules\Internal\Http\Controllers\Api\InvoicePaymentController;
|
||||
use Modules\Internal\Http\Controllers\Api\KatalogDokterController;
|
||||
use Modules\Internal\Http\Controllers\Api\RequestLogController;
|
||||
use Modules\Internal\Http\Controllers\Api\RequestLogBenefitController;
|
||||
@@ -27,6 +28,7 @@ use Modules\Internal\Http\Controllers\Api\HospitalController;
|
||||
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
||||
use Modules\Internal\Http\Controllers\Api\DoctorRatingController;
|
||||
use Modules\Internal\Http\Controllers\Api\DoctorOnlineController;
|
||||
use Modules\Internal\Http\Controllers\Api\DashboardController;
|
||||
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
||||
use Modules\Internal\Http\Controllers\Api\FormulariumTemplateController;
|
||||
@@ -86,7 +88,7 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('drugs', [AutocompleteController::class, 'drugList']);
|
||||
Route::get('units', [AutocompleteController::class, 'unitList']);
|
||||
|
||||
|
||||
|
||||
Route::get('signa', [AutocompleteController::class, 'signaList']);
|
||||
Route::post('signa-add', [AutocompleteController::class, 'signaAdd']);
|
||||
|
||||
@@ -268,7 +270,15 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('claims/{claim_id}/encounters/{encounter_id}/update', [ClaimEncounterController::class, 'update']);
|
||||
Route::post('claims/{claim_id}/set-final-encounter', [ClaimEncounterController::class, 'setFinalEncounter']);
|
||||
|
||||
Route::post('invoice_payments/create', [InvoicePaymentController::class, 'create']);
|
||||
Route::get('invoice_payments/list', [InvoicePaymentController::class, 'index']);
|
||||
Route::post('invoice-payment/submit-status', [InvoicePaymentController::class, 'submitStatus']);
|
||||
Route::get('invoice-payment/detail/{id}', [InvoicePaymentController::class, 'detail']);
|
||||
Route::get('invoice-payment/claim', [InvoicePaymentController::class, 'claim']);
|
||||
Route::get('invoice-payment/export', [InvoicePaymentController::class, 'export']);
|
||||
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
Route::post('claim-details', [ClaimController::class, 'getClaimDetails']);
|
||||
Route::get('claims-files-provider', [ClaimController::class, 'filesProvider']);
|
||||
Route::post('download-zip', [ClaimController::class, 'downloadZip']);
|
||||
Route::get('claims/download-template', [ClaimController::class, 'downloadTemplate']);
|
||||
@@ -411,6 +421,11 @@ Route::prefix('internal')->group(function () {
|
||||
// Navigation
|
||||
Route::get('navigations', [NavigationController::class, 'index']);
|
||||
|
||||
// Dashboard
|
||||
Route::get('dashboard/transaksi', [DashboardController::class, 'index']);
|
||||
Route::get('dashboard/transaksi-bar-chart', [DashboardController::class, 'listBarChart']);
|
||||
Route::get('dashboard/list-dokter', [DashboardController::class, 'listDokter']);
|
||||
Route::get('dashboard/list-performa-dokter', [DashboardController::class, 'listPerformaDokter']);
|
||||
});
|
||||
|
||||
Route::get('province', [ProvinceController::class, 'index']);
|
||||
|
||||
@@ -53,6 +53,7 @@ class File extends Model
|
||||
'docs' => 'docs/',
|
||||
'additional-files' => 'additional-files/',
|
||||
'chat' => 'chat/',
|
||||
'files-proof-payment' => 'files-proof-payment/',
|
||||
];
|
||||
|
||||
public function fileable()
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('invoice_number');
|
||||
$table->string('payment_number');
|
||||
$table->date('invoice_date');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->decimal('amount_paid', 15, 2);
|
||||
$table->string('status')->comment('submitted = Pengajuan, accepted = Belum Dibayar, partial_paid = Bayar Sebagian, paid = Sudah Dibayar');
|
||||
$table->bigInteger('created_by');
|
||||
$table->bigInteger('updated_by');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('invoice_payments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_payment_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('invoice_payment_id')->constrained('invoice_payments')->onDelete('cascade');
|
||||
$table->foreignId('claim_request_id')->constrained('claim_requests')->onDelete('cascade');
|
||||
$table->bigInteger('created_by');
|
||||
$table->bigInteger('updated_by');
|
||||
$table->bigInteger('deleted_by');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('invoice_payment_details');
|
||||
}
|
||||
};
|
||||
@@ -19,8 +19,14 @@ class NavigationSeeder extends Seeder
|
||||
// DOCTORS & HOSPITALS
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'path' => '/dashboard',
|
||||
'permission' => 'dashboard'
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'path' => '/dashboard',
|
||||
'permission' => 'doctor-list'
|
||||
],
|
||||
],
|
||||
'permission' => 'dashboard',
|
||||
],
|
||||
// DOCTORS & HOSPITALS
|
||||
[
|
||||
@@ -134,6 +140,18 @@ class NavigationSeeder extends Seeder
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// Invoice
|
||||
[
|
||||
'title' => 'INVOICE',
|
||||
'children' => [
|
||||
[
|
||||
'title' => 'Invoice',
|
||||
'path' => '/invoice-payment',
|
||||
'permission' => 'invoice-payment-list'
|
||||
],
|
||||
],
|
||||
'permission' => null
|
||||
],
|
||||
// CUSTOMER SERVICES
|
||||
[
|
||||
'title' => 'CUSTOMER SERVICES',
|
||||
@@ -277,6 +295,11 @@ class NavigationSeeder extends Seeder
|
||||
'path' => '/alarm-center',
|
||||
'permission' => 'alarm-center-list-client-portal'
|
||||
],
|
||||
[
|
||||
'title' => 'Daily Monitoring',
|
||||
'path' => '/daily-monitoring',
|
||||
'permission' => 'daily-monitoring-list-client-portal'
|
||||
],
|
||||
[
|
||||
'title' => 'Formularium',
|
||||
'path' => '/master/formularium-template-v2',
|
||||
|
||||
@@ -41,6 +41,7 @@ class PermissionTableSeeder extends Seeder
|
||||
'formularium-create',
|
||||
'formularium-edit',
|
||||
'formularium-delete',
|
||||
'dashboard',
|
||||
'diagnosis-list',
|
||||
'diagnosis-create',
|
||||
'diagnosis-edit',
|
||||
@@ -72,7 +73,8 @@ class PermissionTableSeeder extends Seeder
|
||||
'report-doctor-online',
|
||||
'user-role-list',
|
||||
'user-access-list',
|
||||
'report-katalog-dokter'
|
||||
'report-katalog-dokter',
|
||||
'invoice-payment-list',
|
||||
]
|
||||
],
|
||||
####################### CLIENT PORTAL #########################
|
||||
@@ -85,6 +87,7 @@ class PermissionTableSeeder extends Seeder
|
||||
'employee-data-list-client-portal',
|
||||
'corporate-client-portal',
|
||||
'alarm-center-list-client-portal',
|
||||
'daily-monitoring-list-client-portal',
|
||||
'formularium-list-client-portal',
|
||||
'case-management-client-portal',
|
||||
'service-monitoring-limit-client-portal',
|
||||
@@ -97,6 +100,7 @@ class PermissionTableSeeder extends Seeder
|
||||
'export-alarm-center-client-portal',
|
||||
'filter-alarm-center-client-portal',
|
||||
'benefit-client-portal',
|
||||
'daily-monitoring-list-client-portal'
|
||||
]
|
||||
],
|
||||
####################### HOSPITAL PORTAL #########################
|
||||
|
||||
@@ -5,5 +5,6 @@ PORT=8083
|
||||
REACT_APP_HOST_API_URL="https://aso-api.linksehat.dev/api/client"
|
||||
|
||||
# VITE_API_URL="https://aso-api.linksehat.dev/api/client"
|
||||
VITE_API_URL="https://aso-api.linksehat.dev/api/client"
|
||||
# VITE_API_URL="https://aso-api.linksehat.dev/api/client"
|
||||
|
||||
VITE_API_URL="http://localhost:8000/api/client"
|
||||
116
frontend/client-portal/src/@types/claims.ts
Executable file
116
frontend/client-portal/src/@types/claims.ts
Executable file
@@ -0,0 +1,116 @@
|
||||
import { Benefit } from "./corporates";
|
||||
import { Member } from "./member";
|
||||
|
||||
export type ClaimRequest = {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
submission_date: string;
|
||||
payment_type: string;
|
||||
service_code: string;
|
||||
claim_method: string;
|
||||
service_type: string;
|
||||
service_name: string;
|
||||
code_provider: string;
|
||||
file_condition: Files;
|
||||
member: Member;
|
||||
claim: {
|
||||
organization: Organizations
|
||||
}
|
||||
provider_code: string,
|
||||
organization: {
|
||||
code: string
|
||||
}
|
||||
};
|
||||
|
||||
export type Claims = {
|
||||
id: number;
|
||||
code: string;
|
||||
plan: Plan;
|
||||
payor_id: string;
|
||||
corporate_id: string;
|
||||
policy_number: string;
|
||||
benefit_desc: string;
|
||||
member: Member;
|
||||
benefit: Benefit | boolean;
|
||||
status: string;
|
||||
claim_request: ClaimRequest;
|
||||
};
|
||||
|
||||
export type ClaimsEdit = {
|
||||
id: number;
|
||||
plan_id: string;
|
||||
payor_id: string;
|
||||
corporate_id: string;
|
||||
policy_number: string;
|
||||
member_id: string;
|
||||
benefit_code: string;
|
||||
benefit_desc: string;
|
||||
amount_incurred: number;
|
||||
amount_approved: number;
|
||||
amount_not_approved: number;
|
||||
excess_paid: number;
|
||||
}
|
||||
|
||||
export type Files = {
|
||||
name: string;
|
||||
url: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export type Plan = {
|
||||
code: string;
|
||||
}
|
||||
|
||||
export type ClaimHistoryCare = {
|
||||
id: number;
|
||||
claim_id: number;
|
||||
service_code: string;
|
||||
admission_date: string;
|
||||
discharge_date: string;
|
||||
main_diagnosis_id: number;
|
||||
main_diagnosis_name: string;
|
||||
medical_record_number: string;
|
||||
organization_id: number;
|
||||
practitioner_id: number;
|
||||
organization_name: string;
|
||||
practitioner_name: string;
|
||||
secondary_diagnosis_id: number[];
|
||||
sign: string;
|
||||
symptoms: string;
|
||||
name: any;
|
||||
}
|
||||
|
||||
export type Organizations = {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
address: string;
|
||||
type: string;
|
||||
lat: string;
|
||||
lng: string;
|
||||
phone: string;
|
||||
timezone: string;
|
||||
active: boolean | number;
|
||||
province_id: number;
|
||||
city_id: number;
|
||||
district_id: number;
|
||||
village_id: number;
|
||||
postal_code: string;
|
||||
description: string;
|
||||
technology: string;
|
||||
support_services: string;
|
||||
merchant_code: string;
|
||||
merchant_key: string;
|
||||
image_url: string;
|
||||
region_groups: string;
|
||||
};
|
||||
|
||||
export type Import = {
|
||||
result_file: {
|
||||
url: string,
|
||||
name: string,
|
||||
total_success_row: number,
|
||||
total_failed_row: number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import React, { ChangeEvent, useEffect, useRef, useState } from "react";
|
||||
import { Box, Paper, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Stack, TextField, Button, Menu, Typography, ButtonGroup, } from "@mui/material";
|
||||
|
||||
/**
|
||||
* Types & Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { getDailyMonitoringList } from "../Model/Functions";
|
||||
import { DailyMonitoringListType } from "../Model/Types";
|
||||
import DailyMonitoringListRow from "./DailyMonitoringListRow";
|
||||
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from "../../../@types/paginated-data";
|
||||
import { Grid } from "@mui/material";
|
||||
import DataTable from '../../../components/LaravelTable';
|
||||
import DownloadIcon from '@mui/icons-material/Download';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import { MenuItem } from "@mui/material";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import axios from "../../../utils/axios";
|
||||
import { DesktopDatePicker, LocalizationProvider } from "@mui/x-date-pickers";
|
||||
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
||||
import { fDate } from "../../../utils/formatTime";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { Import } from "../../../@types/claims";
|
||||
import { HeadCell, Order } from '../../../@types/table';
|
||||
import { fDateOnly } from "../../../utils/formatTime";
|
||||
|
||||
export default function DailyMonitoringList() {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
// State
|
||||
// --------------------
|
||||
const [dataTableIsLoading, setDataTableLoading] = useState<boolean>(true);
|
||||
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>(
|
||||
LaravelPaginatedDataDefault
|
||||
);
|
||||
|
||||
// Tabel Style
|
||||
// --------------------
|
||||
const TableHeadStyle = {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
|
||||
const [importResult, setImportResult] = useState<Import>(null);
|
||||
// Load Data
|
||||
// -------------------
|
||||
const loadDataTableData = async (appliedFilter: any | null = null) => {
|
||||
setDataTableLoading(true);
|
||||
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||
|
||||
const response = await axios.get('/memberlist', {params: filter})
|
||||
setDataTableLoading(false);
|
||||
setDataTableData(response.data);
|
||||
}
|
||||
|
||||
const applyFilter = async (searchFilter: { search: string }) => {
|
||||
await loadDataTableData(searchFilter);
|
||||
setSearchParams(searchFilter);
|
||||
};
|
||||
|
||||
const handlePageChange = (event: ChangeEvent, value: number): void => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------ handle params ----------------------------- */
|
||||
const [appliedParams, setAppliedParams] = useState({});
|
||||
|
||||
const params = {
|
||||
searchParams: searchParams,
|
||||
setSearchParams: setSearchParams,
|
||||
appliedParams: appliedParams,
|
||||
setAppliedParams: setAppliedParams,
|
||||
};
|
||||
|
||||
/* ------------------------------ handle order ------------------------------ */
|
||||
const [order, setOrder] = useState<Order>('desc');
|
||||
const [orderBy, setOrderBy] = useState('submission_date');
|
||||
|
||||
const orders = {
|
||||
order: order,
|
||||
setOrder: setOrder,
|
||||
orderBy: orderBy,
|
||||
setOrderBy: setOrderBy,
|
||||
};
|
||||
|
||||
/* ------------------------------- handle sort ------------------------------ */
|
||||
const handleRequestSort = async (event: React.MouseEvent<unknown>, property: string) => {
|
||||
const isAsc = orders?.orderBy === property && orders?.order === 'asc';
|
||||
|
||||
orders?.setOrder(isAsc ? 'desc' : 'asc');
|
||||
orders?.setOrderBy(property);
|
||||
const parameters = Object.fromEntries([
|
||||
...(params?.searchParams.entries() as IterableIterator<[string, string]>),
|
||||
['order', isAsc ? 'desc' : 'asc'],
|
||||
['orderBy', property],
|
||||
]);
|
||||
params?.setAppliedParams(parameters);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [appliedParams, searchParams, order, orderBy, setSearchParams])
|
||||
|
||||
function SearchInput(props: any) {
|
||||
// SEARCH
|
||||
const searchInput = useRef<HTMLInputElement>(null);
|
||||
const [searchText, setSearchText] = useState('');
|
||||
// Start Date
|
||||
// con
|
||||
|
||||
const handleSearchChange = (event: any) => {
|
||||
const newSearchText = event.target.value ?? '';
|
||||
setSearchText(newSearchText);
|
||||
};
|
||||
|
||||
|
||||
const today = new Date(); // Default ke hari ini
|
||||
|
||||
const [startDate, setStartDate] = useState<Date | null>(today);
|
||||
const [endDate, setEndDate] = useState<Date | null>(today);
|
||||
|
||||
useEffect(() => {
|
||||
// Set nilai default saat pertama kali load jika searchParams kosong
|
||||
const paramStartDate = searchParams.get('start_date');
|
||||
const paramEndDate = searchParams.get('end_date');
|
||||
|
||||
if (paramStartDate) {
|
||||
setStartDate(new Date(paramStartDate));
|
||||
}
|
||||
if (paramEndDate) {
|
||||
setEndDate(new Date(paramEndDate));
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Trigger First Search
|
||||
setSearchText(searchParams.get('search') ?? '');
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<form style={{ width: '100%' }}>
|
||||
<Grid container spacing={2} >
|
||||
<Grid item md={8}>
|
||||
<TextField
|
||||
id="search-input"
|
||||
ref={searchInput}
|
||||
label="Search"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
onChange={handleSearchChange}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Enter') {
|
||||
// handleSearchSubmit(event);
|
||||
|
||||
const filter = Object.fromEntries([
|
||||
...searchParams.entries(),
|
||||
['search', searchText],
|
||||
]);
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
}}
|
||||
value={searchText}
|
||||
placeholder='Search Code or Name...'
|
||||
/>
|
||||
</Grid>
|
||||
{/* Start Date */}
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="Start Date"
|
||||
inputFormat="dd/MM/yyyy"
|
||||
value={startDate}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
setStartDate(value);
|
||||
const dateStr = fDateOnly(value);
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ['start_date', dateStr]]);
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
|
||||
{/* End Date */}
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="End Date"
|
||||
inputFormat="dd/MM/yyyy"
|
||||
value={endDate}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
setEndDate(value);
|
||||
const dateStr = fDateOnly(value);
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ['end_date', dateStr]]);
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function ImportForm(props: any) {
|
||||
// IMPORT
|
||||
// Create Button Menu
|
||||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||
const createMenu = Boolean(anchorEl);
|
||||
const importForm = useRef<HTMLInputElement>(null);
|
||||
const [currentImportFileName, setCurrentImportFileName] = useState(null);
|
||||
const [importLoading, setImportLoading] = useState(false);
|
||||
|
||||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
const handleImportButton = () => {
|
||||
if (importForm?.current) {
|
||||
handleClose();
|
||||
importForm.current ? importForm.current.click() : console.log('No File selected');
|
||||
} else {
|
||||
alert('No file selected');
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelImportButton = () => {
|
||||
importForm.current.value = '';
|
||||
importForm.current.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
};
|
||||
|
||||
const handleImportChange = (event: any) => {
|
||||
if (event.target.files[0]) {
|
||||
setCurrentImportFileName(event.target.files[0].name);
|
||||
} else {
|
||||
setCurrentImportFileName(null);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpload = () => {
|
||||
if (importForm.current?.files.length) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importForm.current?.files[0]);
|
||||
|
||||
setImportLoading(true);
|
||||
axios
|
||||
.post(`customer-service/request/import`, formData)
|
||||
.then((response) => {
|
||||
handleCancelImportButton();
|
||||
loadDataTableData();
|
||||
setImportResult(response.data);
|
||||
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
||||
setImportLoading(false);
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(
|
||||
'Looks like something went wrong. Please check your data and try again. ' +
|
||||
response.message,
|
||||
{ variant: 'error' }
|
||||
);
|
||||
setImportLoading(false);
|
||||
});
|
||||
} else {
|
||||
enqueueSnackbar('No File Selected', { variant: 'warning' });
|
||||
}
|
||||
};
|
||||
|
||||
const handleGetTemplate = (type :string) => {
|
||||
axios.get('corporates/import-document-example/' + type)
|
||||
.then((response) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = response.data.data.file_url;
|
||||
link.setAttribute('download', response.data.data.file_name);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
handleClose();
|
||||
})
|
||||
}
|
||||
|
||||
const handleGetData = (type :string) => {
|
||||
|
||||
}
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input
|
||||
type="file"
|
||||
id="file"
|
||||
ref={importForm}
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImportChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
||||
/>
|
||||
{!currentImportFileName && (
|
||||
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||
<SearchInput onSearch={applyFilter} />
|
||||
<Menu
|
||||
id="import-button"
|
||||
anchorEl={anchorEl}
|
||||
open={createMenu}
|
||||
onClose={handleClose}
|
||||
MenuListProps={{
|
||||
'aria-labelledby': 'basic-button',
|
||||
}}
|
||||
>
|
||||
<MenuItem onClick={handleImportButton}>
|
||||
<Typography variant='body2'>Import</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleGetTemplate('member');
|
||||
}}
|
||||
>
|
||||
<Typography variant='body2'> Download Template</Typography>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => navigate(`/daily-monitoring/add_monitoring`)}>
|
||||
<Typography variant='body2'>Tambah</Typography>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{currentImportFileName && (
|
||||
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||
<ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth>
|
||||
<Button onClick={handleImportButton} fullWidth>
|
||||
{currentImportFileName ?? 'No File Selected'}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleCancelImportButton}
|
||||
size="small"
|
||||
fullWidth={false}
|
||||
sx={{ p: 1.8 }}
|
||||
>
|
||||
<CancelIcon color="error" />
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
|
||||
<LoadingButton
|
||||
id="upload-button"
|
||||
variant="outlined"
|
||||
startIcon={<UploadIcon />}
|
||||
sx={{ p: 1.8 }}
|
||||
onClick={handleUpload}
|
||||
loading={importLoading}
|
||||
>
|
||||
Upload
|
||||
</LoadingButton>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{importResult && (
|
||||
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
|
||||
<Box sx={{ color: 'text.secondary' }}>
|
||||
Last Import Result :{' '}
|
||||
<Box sx={{ color: 'success.main', display: 'inline' }}>
|
||||
{importResult.total_success_row ?? 0}
|
||||
</Box>{' '}
|
||||
Row Processed,{' '}
|
||||
<Box sx={{ color: 'error.main', display: 'inline' }}>
|
||||
{importResult.total_failed_row}
|
||||
</Box>{' '}
|
||||
Failed, Report :{' '}
|
||||
<a href={importResult.result_file?.url ?? '#'}>
|
||||
{importResult.result_file?.name ?? '-'}
|
||||
</a>
|
||||
</Box>
|
||||
</Stack>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TableContent(){
|
||||
return (
|
||||
<Table sx={{ minWidth: 250 }} size='medium' aria-label="collapsible table">
|
||||
{/* Head Table */}
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell style={TableHeadStyle} align="left" width={50} />
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Code</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Admission Date</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={150}>Member ID</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={'*'}>Name</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Tanggal Lahir</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Member Type</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Medical Plan</TableCell>
|
||||
<TableCell style={TableHeadStyle} align="left" width={160}>Non Medical Plan</TableCell>
|
||||
<TableCell align="left" width={"10"} />
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
|
||||
{/* Body Table */}
|
||||
{dataTableIsLoading ? (
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell colSpan={7} align="center">Loading</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
) : dataTableData.data.length == 0 ? (
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell colSpan={7} align="center">No Data</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
) : dataTableData.data && dataTableData.data.length > 0 ? (
|
||||
<TableBody>
|
||||
{dataTableData.data.map((row: DailyMonitoringListType, index) => (
|
||||
<DailyMonitoringListRow key={index} number={index+1} row={row} />
|
||||
))}
|
||||
</TableBody>
|
||||
) : null}
|
||||
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Grid container>
|
||||
<Grid item sm={12}>
|
||||
<ImportForm />
|
||||
</Grid>
|
||||
|
||||
<Grid item sm={12} marginTop={2}>
|
||||
<DataTable
|
||||
isLoading={dataTableIsLoading}
|
||||
lastRequest={0}
|
||||
data={dataTableData}
|
||||
handlePageChange={handlePageChange}
|
||||
TableContent={<TableContent />}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import React, { useState } from "react";
|
||||
import { useNavigate } from "react-router";
|
||||
import { Box, Collapse, MenuItem, TableCell, TableRow, Stack } from "@mui/material";
|
||||
import Visibility from '@mui/icons-material/Visibility';
|
||||
|
||||
/**
|
||||
* Component
|
||||
* ============================================
|
||||
*/
|
||||
// - Global -
|
||||
import Label from "../../../components/Label";
|
||||
import TableMoreMenu from '../../../components/table/TableMoreMenu';
|
||||
|
||||
/**
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { fDate } from "../../../utils/formatTime";
|
||||
import { DailyMonitoringListType } from "../Model/Types";
|
||||
import { Edit } from "@mui/icons-material";
|
||||
|
||||
type Props = {
|
||||
row: DailyMonitoringListType,
|
||||
number: number
|
||||
}
|
||||
|
||||
export default function DailyMonitoringListRow ({ ...props }: Props) {
|
||||
const navigate = useNavigate()
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
<TableRow hover sx={{ '& > td': { borderBottom: '1' } }}>
|
||||
<TableCell align="left" />
|
||||
<TableCell align="left">{props.row.code}</TableCell>
|
||||
<TableCell align="left">
|
||||
<Label
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{props.row.addmision_date ? fDate(props.row.addmision_date) : '-'}
|
||||
</Label>
|
||||
</TableCell>
|
||||
<TableCell align="left">{props.row.member_id}</TableCell>
|
||||
<TableCell align="left">{props.row.name}</TableCell>
|
||||
<TableCell align="left">
|
||||
<Label
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{props.row.birth_date ? fDate(props.row.birth_date) : '-'}
|
||||
</Label>
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
{props.row.member_type}
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
{props.row.medical_plan}
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
{props.row.non_medical_plan}
|
||||
</TableCell>
|
||||
|
||||
<TableCell align="right" onClick={(e) => e.stopPropagation()}>
|
||||
<Stack direction="row" justifyContent="flex-end" spacing={1}>
|
||||
<TableMoreMenu actions={
|
||||
<>
|
||||
<MenuItem onClick={() => navigate(`/daily-monitoring/${props.row.member_id}/claims/${props.row.code}/list_monitoring`)}>
|
||||
<Visibility />
|
||||
View
|
||||
</MenuItem>
|
||||
</>
|
||||
} />
|
||||
</Stack>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,526 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, IconButton, Typography, Grid, Card, List, ListItem, Stack, Autocomplete, TextField, Button } from '@mui/material';
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
|
||||
/**
|
||||
* Components
|
||||
* ============================================
|
||||
*/
|
||||
// - Global -
|
||||
import Page from '../../../components/Page';
|
||||
import Label from "../../../components/Label";
|
||||
|
||||
/**
|
||||
* Icon
|
||||
* ============================================
|
||||
*/
|
||||
import ArrowBackIosNew from '@mui/icons-material/ArrowBackIosNew';
|
||||
import FiberManualRecord from '@mui/icons-material/FiberManualRecord';
|
||||
|
||||
/**
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { fDate, fDateOnly } from '../../../utils/formatTime';
|
||||
import { getMonitoringDetailList } from '../Model/Functions';
|
||||
import { getOrganizationId } from '../Model/Functions';
|
||||
import { DetailMonitoringListType } from '../Model/Types';
|
||||
import TableMoreMenu from '../../../components/table/TableMoreMenu';
|
||||
import { MenuItem } from '@mui/material';
|
||||
import { Delete, DeleteForever, Edit, LoopOutlined } from '@mui/icons-material';
|
||||
import MuiDialog from '../../../components/MuiDialog';
|
||||
import { DialogActions } from '@mui/material';
|
||||
import axios from '../../../utils/axios';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { escape } from 'lodash';
|
||||
|
||||
|
||||
export default function DetailMonitoringList() {
|
||||
const { member_id, claim_code } = useParams();
|
||||
const navigate = useNavigate()
|
||||
const pageTitle = claim_code??'_ _ _ _';
|
||||
|
||||
// State
|
||||
// --------------------
|
||||
const [detailMonitoringList, setDetailMonitoringList] = useState<DetailMonitoringListType[]>();
|
||||
const [organizationId, setOrganizationId] = useState<number|undefined>();
|
||||
|
||||
const [openDialog, setOpenDialog] = useState<boolean>(false)
|
||||
|
||||
// Use Effect
|
||||
// --------------------
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
|
||||
// Dialog
|
||||
const marginBottom2 = {
|
||||
marginBottom: 2,
|
||||
}
|
||||
const [selectedReason, setSelectedReason] = useState({value:'-', label:''});
|
||||
const reason = [
|
||||
{ value: 'Wrong Setting', label: 'Wrong Setting' },
|
||||
{ value: 'Hospital Request', label: 'Hospital Request' }
|
||||
];
|
||||
const [error, setError] = useState('');
|
||||
const [id, setId] = useState<null|number>(null);
|
||||
const [id_file, setIdFile] = useState<null|number>(null);
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
setOpenDialog(false);
|
||||
}
|
||||
const handleDelete = () => {
|
||||
if(selectedReason.value != '-'){
|
||||
const parameters = {
|
||||
'reason' : selectedReason.value
|
||||
}
|
||||
if (id){
|
||||
const response = axios.get(`case_management/daily-monitoring/detail/${id}/delete`, {
|
||||
params: { ...parameters },
|
||||
});
|
||||
|
||||
if (!response.error){
|
||||
enqueueSnackbar('Claim Request Updated Successfully!', { variant: 'success' });
|
||||
window.location.reload();
|
||||
setOpenDialog(false)
|
||||
} else {
|
||||
enqueueSnackbar('Claim Request Updated Error!', { variant: 'error' });
|
||||
}
|
||||
|
||||
} else {
|
||||
axios.get(`case_management/daily-monitoring/detail/${id_file}/delete-file`, {
|
||||
params: { ...parameters },
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.error) {
|
||||
enqueueSnackbar('File Successfully deleted!', { variant: 'success' });
|
||||
window.location.reload();
|
||||
setOpenDialog(false);
|
||||
} else {
|
||||
enqueueSnackbar('Deleted File Error!', { variant: 'error' });
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setError('Please select a reason')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handleEdit = (id:number|undefined) => {
|
||||
navigate(`/case_management/daily-monitoring/${member_id}/claims/${claim_code}/${id}`)
|
||||
}
|
||||
|
||||
const getContent = () => (
|
||||
<Stack spacing={1} marginTop={2}>
|
||||
<Typography variant="subtitle2">Are you sure to delete this {id_file ? 'File ' : '' } Daily Monitoring ?</Typography>
|
||||
<Grid item xs={12} md={12} marginTop={4}>
|
||||
<Card sx={{padding:2, marginTop:2}} >
|
||||
<Typography variant="subtitle1" marginY={2}>Reason for Delete*</Typography>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Autocomplete
|
||||
options={reason}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedReason}
|
||||
onChange={(event, newValue) => {
|
||||
setSelectedReason(newValue);
|
||||
// Validasi jika newValue adalah null
|
||||
if (!newValue) {
|
||||
setError('Please select a reason');
|
||||
} else {
|
||||
setError('');
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Reason for Delete"
|
||||
variant="outlined"
|
||||
name='reason'
|
||||
error={Boolean(error)} // Menampilkan error jika ada
|
||||
helperText={error} // Menampilkan pesan kesalahan
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
</Card>
|
||||
</Grid>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialog}>Cancel</Button>
|
||||
<Button color="primary" variant="contained" onClick={() => handleDelete()}>Delete</Button>
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
)
|
||||
|
||||
|
||||
// Load Data
|
||||
// -------------------
|
||||
const loadDataTableData = async () => {
|
||||
const response = await getMonitoringDetailList(claim_code??'');
|
||||
const organization_id = await getOrganizationId(claim_code??'');
|
||||
|
||||
setDetailMonitoringList(response);
|
||||
setOrganizationId(organization_id);
|
||||
}
|
||||
|
||||
function renderHTML(data: string) {
|
||||
return (
|
||||
<div style={{ marginLeft: 20 }}
|
||||
dangerouslySetInnerHTML={{ __html: data }} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Page title={pageTitle} sx={{ px: 2 }}>
|
||||
<Grid container gap={6}>
|
||||
{/* back button */}
|
||||
<Grid item xs={12}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<IconButton size='large' color='inherit' onClick={() => navigate(`/daily-monitoring`)} >
|
||||
<ArrowBackIosNew/>
|
||||
</IconButton>
|
||||
|
||||
<Typography variant="h5" sx={{ marginLeft: '24px' }}>
|
||||
{pageTitle}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Grid>
|
||||
|
||||
{/* tabel claims */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={4} sx={{ px: 2 }}>
|
||||
{
|
||||
detailMonitoringList?.map((row, index) => {
|
||||
return (
|
||||
<Grid key={index} item xs={12}>
|
||||
<Card sx={{ border: '1px solid rgba(0,0,0,0.125)', px: '30px', py: '24px'}}>
|
||||
{/* card header */}
|
||||
<Box
|
||||
sx={{
|
||||
pb: '20px',
|
||||
mb: '20px',
|
||||
borderBottom: '1px solid rgba(0,0,0,0.125)',
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
alignItems: 'center'
|
||||
}}
|
||||
>
|
||||
<Label variant="ghost" color="default">
|
||||
{row.submission_date ? fDate(row.submission_date) : '-'}
|
||||
</Label>
|
||||
|
||||
{row.discharge_date ? (
|
||||
<Label
|
||||
variant="ghost"
|
||||
color="success"
|
||||
sx={{ position: 'absolute', top: 0, right: 0 }}
|
||||
>
|
||||
Close Monitoring
|
||||
</Label>
|
||||
) : (
|
||||
<Label
|
||||
variant="ghost"
|
||||
color="warning"
|
||||
sx={{ position: 'absolute', top: 0, right: 0 }}
|
||||
>
|
||||
On Monitoring
|
||||
</Label>
|
||||
)}
|
||||
</Box>
|
||||
{/* card body */}
|
||||
<Grid container gap={4}>
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Subject :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{renderHTML(row.subject)}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Object :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} paddingY={2}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{renderHTML(row.object)}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Body Temperature
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.body_temperature} Cel
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Sistole
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.sistole} mm[Hg]
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Diastole
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.diastole} mm[Hg]
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Respiration Rate
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.respiration_rate} / min
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Analysis :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{renderHTML(row.analysis)}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Medical Plan :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
{
|
||||
row.medical_plan?.map((data, index) => {
|
||||
return (
|
||||
<ListItem key={index}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} /> {renderHTML(data.medical_plan_str)}
|
||||
</ListItem>
|
||||
)
|
||||
})
|
||||
}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Non Medikamentosa Plan :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
{
|
||||
row.non_medikamentosa_plan?.map((data, index) => {
|
||||
return (
|
||||
<ListItem key={index}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} /> {renderHTML(data.non_medikamentosa_plan_str)}
|
||||
</ListItem>
|
||||
)
|
||||
})
|
||||
}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Laboratorium Result :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Date
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{ row.lab_date != null ? fDate(row.lab_date) : '-'}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Location
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{row.provider != null ? row.provider : '-' }
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Examination
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
{row.examination != null ? renderHTML(row.examination) : '-' }
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Confirmation Medical Letter:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
data.type === 'confirmation-medical-letter' ? (
|
||||
<ListItem key={index} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<div sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</div>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Medical Action Letter:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
data.type === 'medical-action-letter' ? (
|
||||
<ListItem key={index} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<div sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</div>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Examination Result:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
data.type === 'laboratorium-result' ? (
|
||||
<ListItem key={index} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<div sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</div>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Card>
|
||||
</Grid>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Dialog Delete */}
|
||||
<MuiDialog
|
||||
title={{name: id_file ? "Delete File Daily Monitoring" : "Delete Daily Monitoring"}}
|
||||
openDialog={openDialog}
|
||||
setOpenDialog={setOpenDialog}
|
||||
content={getContent()}
|
||||
maxWidth="xs"
|
||||
/>
|
||||
</Grid>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
178
frontend/client-portal/src/pages/DailyMonitoring/Model/Functions.ts
Executable file
178
frontend/client-portal/src/pages/DailyMonitoring/Model/Functions.ts
Executable file
@@ -0,0 +1,178 @@
|
||||
import axios from '../../../utils/axios';
|
||||
import { makeFormData } from '../../../utils/jsonToFormData';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { DailyMonitoringListType, DetailMonitoringListType, ResponseListingClaimType } from "./Types";
|
||||
import { fDate, fDateOnly } from '../../../utils/formatTime';
|
||||
|
||||
/**
|
||||
* Listing Daily Monitoring
|
||||
*/
|
||||
export const getDailyMonitoringList = async ( param: any) => {
|
||||
const response = await axios.get('/case_management/memberlist', {params: param})
|
||||
.then((res) =>{
|
||||
return res.data;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Listing Claim
|
||||
*/
|
||||
export const getClaimList = async ( member_id: string ): Promise<ResponseListingClaimType> => {
|
||||
const response = await axios.get(`/case_management/claimlist/${member_id}`)
|
||||
.then((res) =>{
|
||||
return res.data.data;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Monitoring Detail
|
||||
*/
|
||||
export const AddMonitoringDetail = async ( claim_code: string,data: DetailMonitoringListType ): Promise<boolean> => {
|
||||
data.lab_date = data.lab_date != '' && data.lab_date != null ? fDateOnly(data.lab_date) : '';
|
||||
data.submission_date = data.submission_date != '' && data.submission_date != null ? fDateOnly(data.submission_date) : '';
|
||||
|
||||
const formData = makeFormData({...data});
|
||||
|
||||
const response = await axios.post(`/daily_monitoring/add-request`, formData)
|
||||
.then((res) =>{
|
||||
enqueueSnackbar(res.data.message, {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((res) => {
|
||||
if (res.response.status == 400) {
|
||||
let arr_message = res.response.data.message;
|
||||
|
||||
for (const key in arr_message) {
|
||||
enqueueSnackbar(arr_message[key][0], {
|
||||
variant: 'warning',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Monitoring Detail List
|
||||
*/
|
||||
export const getMonitoringDetailList = async ( claim_code: string ): Promise<DetailMonitoringListType[]> => {
|
||||
const response = await axios.get(`/daily_monitoring/detail/${claim_code}/list`)
|
||||
.then((res) =>{
|
||||
return res.data.data.detail_list;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Monitoring Detail List
|
||||
*/
|
||||
export const getOrganizationId = async ( claim_code: string ): Promise<number> => {
|
||||
const response = await axios.get(`/daily_monitoring/detail/${claim_code}/list`)
|
||||
.then((res) =>{
|
||||
return res.data.data.organization_id;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get detail monitoring
|
||||
*/
|
||||
export const getMonitoringDetailById = async ( id: string) => {
|
||||
const response = await axios.get(`/daily_monitoring/detail/${id}/edit`)
|
||||
.then((res) =>{
|
||||
return res.data.data;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update detail monitoring
|
||||
*/
|
||||
export const UpdateMonitoringDetail = async (data: DetailMonitoringListType) => {
|
||||
data.lab_date = data.lab_date != '' && data.lab_date != null ? fDateOnly(data.lab_date) : '';
|
||||
data.submission_date = data.submission_date != '' && data.submission_date != null ? fDateOnly(data.submission_date) : '';
|
||||
|
||||
const formData = makeFormData({...data});
|
||||
|
||||
const response = await axios.post(`/daily_monitoring/detail/update-request`, formData)
|
||||
.then((res) =>{
|
||||
enqueueSnackbar(res.data.message, {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((res) => {
|
||||
if (res.response.status == 400) {
|
||||
let arr_message = res.response.data.message;
|
||||
|
||||
for (const key in arr_message) {
|
||||
enqueueSnackbar(arr_message[key][0], {
|
||||
variant: 'warning',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
120
frontend/client-portal/src/pages/DailyMonitoring/Model/Types.ts
Executable file
120
frontend/client-portal/src/pages/DailyMonitoring/Model/Types.ts
Executable file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* List Daily Monitoring
|
||||
*/
|
||||
export type DailyMonitoringListType = {
|
||||
member_id : string,
|
||||
member_type : string,
|
||||
birth_date : string,
|
||||
name : string,
|
||||
start_date : string,
|
||||
end_date : string,
|
||||
description : string,
|
||||
doctor_1 : string,
|
||||
doctor_2 : string,
|
||||
temp_diagnosis : string,
|
||||
final_diagnosis : string,
|
||||
approval_pendamping : string,
|
||||
note : string,
|
||||
addmision_date : string,
|
||||
provider : string,
|
||||
organization_id : number,
|
||||
medical_plan : string,
|
||||
non_medical_plan : string,
|
||||
}
|
||||
|
||||
/**
|
||||
* Response Listing Claim
|
||||
*/
|
||||
export type ResponseListingClaimType = {
|
||||
member_detail : MemberDetailType,
|
||||
claim_list : ClaimListType[],
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Detail
|
||||
*/
|
||||
export type MemberDetailType = {
|
||||
id : string,
|
||||
member_id : string,
|
||||
name : string,
|
||||
}
|
||||
|
||||
/**
|
||||
* List Claim
|
||||
*/
|
||||
export type ClaimListType = {
|
||||
claim_id : number,
|
||||
admission_date : string,
|
||||
discharge_date : string,
|
||||
claim_code : string,
|
||||
name : string,
|
||||
code : string,
|
||||
service_name : string,
|
||||
claim_status : string,
|
||||
service_type : string,
|
||||
member_id : string
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail Monitoring List
|
||||
*/
|
||||
export type DetailMonitoringListType = {
|
||||
id : number|null,
|
||||
claim_id : string|null,
|
||||
log_code : string|null,
|
||||
request_log_id : string|null,
|
||||
claim_code : string|undefined,
|
||||
doctor_1 : string|undefined,
|
||||
doctor_2 : string|undefined,
|
||||
temp_diagnosis : string|undefined,
|
||||
final_diagnosis : string|undefined,
|
||||
approval_pendamping : string|undefined,
|
||||
keterangan : string|undefined,
|
||||
catatan : string|undefined,
|
||||
description : string|undefined,
|
||||
note : string|undefined,
|
||||
subject : string|undefined,
|
||||
object : string|undefined,
|
||||
objective : string|undefined,
|
||||
body_temperature: string|undefined,
|
||||
respiration_rate: string|undefined,
|
||||
sistole : string|undefined,
|
||||
diastole : string|undefined
|
||||
analysis : string|undefined,
|
||||
complaints : string|undefined,
|
||||
submission_date : string|undefined,
|
||||
discharge_date : string|undefined,
|
||||
lab_date : string|undefined,
|
||||
provider : string|undefined,
|
||||
examination : string|undefined,
|
||||
reason : string|undefined,
|
||||
medical_plan : MedicalPlanStrType[],
|
||||
non_medikamentosa_plan : NonMedikamentosaPlanType[],
|
||||
confirmation_medical_leter : files[],
|
||||
medical_action_letter : files[],
|
||||
result : files[],
|
||||
document : document[],
|
||||
created_at : string|null
|
||||
data : {
|
||||
organization_id : number
|
||||
}
|
||||
}
|
||||
|
||||
export type MedicalPlanStrType = {
|
||||
medical_plan_str: string
|
||||
}
|
||||
|
||||
export type NonMedikamentosaPlanType = {
|
||||
non_medikamentosa_plan_str: string
|
||||
}
|
||||
|
||||
export type files = {
|
||||
file: string
|
||||
}
|
||||
|
||||
export type document = {
|
||||
id: number
|
||||
file_name: string,
|
||||
path: string,
|
||||
type: string
|
||||
}
|
||||
48
frontend/client-portal/src/pages/DailyMonitoring/index.tsx
Executable file
48
frontend/client-portal/src/pages/DailyMonitoring/index.tsx
Executable file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import { Box, Grid } from '@mui/material';
|
||||
|
||||
/**
|
||||
* Components
|
||||
* ============================================
|
||||
*/
|
||||
// - Global -
|
||||
import Page from '../../components/Page';
|
||||
import HeaderBreadcrumbs from "../../components/HeaderBreadcrumbs";
|
||||
// - Local -
|
||||
import DailyMonitoringList from './Components/DailyMonitoringList';
|
||||
|
||||
export default function DailyMonitoring() {
|
||||
const pageTitle = "Daily Monitoring";
|
||||
|
||||
return (
|
||||
<Page title={ pageTitle } sx={{ px: 2 }}>
|
||||
<Grid container>
|
||||
{/* page header */}
|
||||
<Grid item xs={12}>
|
||||
<HeaderBreadcrumbs
|
||||
heading={ pageTitle }
|
||||
sx={{ px: 1 }}
|
||||
links={[
|
||||
{
|
||||
name: 'Dashboard',
|
||||
href: '/dashboard',
|
||||
},
|
||||
{
|
||||
name: pageTitle,
|
||||
href: '/daily_monitoring',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
{/* tabel daily monitoring */}
|
||||
<Grid item xs={12}>
|
||||
<DailyMonitoringList />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -117,7 +117,26 @@ export default function Router() {
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: '/daily-monitoring',
|
||||
element: (
|
||||
<AuthProvider>
|
||||
<AuthGuard>
|
||||
<DashboardLayout />
|
||||
</AuthGuard>
|
||||
</AuthProvider>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
element: <DailyMonitoring />,
|
||||
index: true,
|
||||
},
|
||||
{
|
||||
path: ':member_id/claims/:claim_code/list_monitoring',
|
||||
element: <DetailMonitoringList />
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/claim-submit',
|
||||
element: (
|
||||
@@ -463,3 +482,7 @@ const UserRole = Loadable(lazy(() => import('../pages/UserManagement/UserRole/In
|
||||
const UserRoleCreate = Loadable(lazy(() => import('../pages/UserManagement/UserRole/CreateUpdate')));
|
||||
const UserAccess = Loadable(lazy(() => import('../pages/UserManagement/UserAccess/Index')));
|
||||
const UserAccessCreate = Loadable(lazy(() => import('../pages/UserManagement/UserAccess/CreateUpdate')));
|
||||
|
||||
// Daily Monitoring
|
||||
const DailyMonitoring = Loadable(lazy(() => import('../pages/DailyMonitoring/index')))
|
||||
const DetailMonitoringList = Loadable(lazy(() => import('../pages/DailyMonitoring/Components/DetailMonitoringList')))
|
||||
@@ -37,6 +37,10 @@ export function fPostFormat(date: Date | string | number, dateFormat = 'yyyy-MM-
|
||||
return format(new Date(date), dateFormat);
|
||||
}
|
||||
|
||||
export function fDateOnly(date: Date | string | number) {
|
||||
return format(new Date(date), 'yyyy-MM-dd');
|
||||
}
|
||||
|
||||
// export function fDateString(date) {
|
||||
// const dateObj = parseISO(date);
|
||||
// const formattedDate = format(dateObj, 'dd MMMM yyyy');
|
||||
|
||||
@@ -1,66 +1,557 @@
|
||||
// @mui
|
||||
import { Button, Container, Grid, styled, Typography, Card, Stack } from '@mui/material';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Container,
|
||||
Grid,
|
||||
styled,
|
||||
Typography,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
Paper,
|
||||
Card,
|
||||
TextField,
|
||||
FormControl,
|
||||
InputLabel,
|
||||
Select,
|
||||
MenuItem,
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
DialogContent,
|
||||
DialogActions,
|
||||
Checkbox,
|
||||
|
||||
} from '@mui/material';
|
||||
// hooks
|
||||
import useSettings from '../hooks/useSettings';
|
||||
// components
|
||||
import { PieChart, Pie, Cell, Tooltip, BarChart, Bar, XAxis, YAxis, Legend, ResponsiveContainer } from 'recharts';
|
||||
import Page from '../components/Page';
|
||||
import axios from '../utils/axios';
|
||||
import useAuth from '../hooks/useAuth';
|
||||
import SomethingUsage from '../sections/dashboard/SomethingUsage';
|
||||
import { fCurrency } from '../utils/formatNumber';
|
||||
import dayjs from "dayjs";
|
||||
import {DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
||||
import { green, red } from "@mui/material/colors";
|
||||
import MuiDialog from '@/components/MuiDialog';
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
const COLORS = ['#229A16', '#919EAB', '#FF4842'];
|
||||
|
||||
// const performaDokterData = [
|
||||
// { name: 'Dr. John', Berhasil: 70, Gagal: 8, Abandon: 4 },
|
||||
// { name: 'Dr. Richard', Berhasil: 68, Gagal: 10, Abandon: 2 },
|
||||
// { name: 'Dr. Harman', Berhasil: 75, Gagal: 5, Abandon: 3 },
|
||||
// { name: 'Dr. Emma', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// { name: 'Dr. tb', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// { name: 'Dr. test', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// { name: 'Dr. yayan', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// { name: 'Dr. intan', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// { name: 'Dr. fajri', Berhasil: 80, Gagal: 7, Abandon: 1 },
|
||||
// ];
|
||||
|
||||
// Custom Tooltip
|
||||
const CustomTooltip = ({ active, payload, label }) => {
|
||||
if (active && payload && payload.length) {
|
||||
const totalPasien =
|
||||
payload[0].value + payload[1].value + payload[2].value;
|
||||
return (
|
||||
<div style={{ background: "#000", color: "#fff", padding: "10px", borderRadius: "5px" }}>
|
||||
<p>{label}</p>
|
||||
<p>Total Pasien: {totalPasien}</p>
|
||||
<p>Berhasil: {payload[0].value}</p>
|
||||
<p>Gagal: {payload[1].value}</p>
|
||||
<p>Abandon: {payload[2].value}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// Custom Tooltip
|
||||
const CustomTooltipPie = ({ active, payload, startDate, endDate }) => {
|
||||
if (!active || !payload || payload.length === 0) return null;
|
||||
// Fungsi format tanggal ke "2 Jan 2025"
|
||||
const formatDate = (date) => {
|
||||
if (!date) return "N/A";
|
||||
return new Date(date).toLocaleDateString("id-ID", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div style={{ background: "#000", color: "#fff", padding: "10px", borderRadius: "5px" }}>
|
||||
<p>{formatDate(startDate)} - {formatDate(endDate)}</p>
|
||||
<p>Status: {payload[0]?.name || "Tidak ada data"}</p>
|
||||
<p>Jumlah Pasien: {payload[0]?.value || 0}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
export default function Dashboard() {
|
||||
const { themeStretch } = useSettings();
|
||||
|
||||
const { logout } = useAuth();
|
||||
|
||||
const loadSomething = () => {
|
||||
axios.get('/user')
|
||||
const transaksiDataDefault = [
|
||||
{ name: "Berhasil", value: 0, color: "#4CAF50" },
|
||||
{ name: "Gagal", value: 0, color: "#F44336" },
|
||||
{ name: "Abandon", value: 0, color: "#9E9E9E" },
|
||||
];
|
||||
const { themeStretch } = useSettings();
|
||||
const [startDate, setStartDate] = useState(dayjs().startOf('month').format('YYYY-MM-DD'));
|
||||
const [endDate, setEndDate] = useState(dayjs().format('YYYY-MM-DD'));
|
||||
const [startDateDokter, setStartDateDokter] = useState(dayjs().startOf('month').format('YYYY-MM-DD'));
|
||||
const [endDateDokter, setEndDateDokter] = useState(dayjs().format('YYYY-MM-DD'));
|
||||
const [transaksiData, setTransaksiData] = useState(transaksiDataDefault);
|
||||
const [transaksiDataBar, setTransaksiDataBar] = useState([]);
|
||||
const [type, setType] = useState(0);
|
||||
const [status, setStatus] = useState(0);
|
||||
const [statusDokter, setStatusDokter] = useState(0);
|
||||
const [view, setView] = useState(["day", "month", "year"]);
|
||||
const [performaDokterData, setListPerformaDoctors] = useState([]);
|
||||
const [doctors, setListDoctors] = useState([]);
|
||||
const [selectedDoctors, setSelectedDoctors] = useState(doctors.map((doctor) => doctor.id)); // State untuk dokter yang dipilih
|
||||
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await axios.get(`dashboard/transaksi`, {
|
||||
params: {
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
type,
|
||||
status
|
||||
}
|
||||
});
|
||||
if (response.data) {
|
||||
setTransaksiData(response.data);
|
||||
}
|
||||
if (type === 0) {
|
||||
setView(["day", "month", "year"]); // Urutan yang benar: day, month, year
|
||||
} else {
|
||||
setView(["month"]); // Hanya menampilkan bulan & tahun
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching transaksi data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const DangerCard = styled(Card)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
padding: theme.spacing(3),
|
||||
color: theme.palette.error.main,
|
||||
backgroundColor: theme.palette.error.lighter,
|
||||
}));
|
||||
const fetchDataBar = async () => {
|
||||
try {
|
||||
const response = await axios.get(`dashboard/transaksi-bar-chart`, {
|
||||
params: {
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
type,
|
||||
status
|
||||
}
|
||||
});
|
||||
if (response.data) {
|
||||
setTransaksiDataBar(response.data);
|
||||
}
|
||||
if (type === 0) {
|
||||
setView(["day", "month", "year"]); // Urutan yang benar: day, month, year
|
||||
} else {
|
||||
setView(["month"]); // Hanya menampilkan bulan & tahun
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching transaksi data:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const SuccessCard = styled(Card)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
padding: theme.spacing(3),
|
||||
color: theme.palette.success.darker,
|
||||
backgroundColor: theme.palette.success.lighter,
|
||||
}));
|
||||
const fetchListPerfomaDokter = async () => {
|
||||
try {
|
||||
const response = await axios.get(`dashboard/list-performa-dokter`, {
|
||||
params: {
|
||||
start_date: startDateDokter,
|
||||
end_date: endDateDokter,
|
||||
type,
|
||||
statusDokter,
|
||||
nIDDokter: selectedDoctors
|
||||
}
|
||||
} );
|
||||
if (response.data) {
|
||||
setListPerformaDoctors(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching transaksi data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const fetchListDokter = async () => {
|
||||
try {
|
||||
const response = await axios.get(`dashboard/list-dokter`);
|
||||
if (response.data) {
|
||||
setListDoctors(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching transaksi data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Fetch data saat pertama kali halaman dimuat dan ketika filter berubah
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
fetchDataBar();
|
||||
// fetchListPerfomaDokter();
|
||||
}, [startDate, endDate, type, status]);
|
||||
|
||||
// Fetch
|
||||
useEffect(() => {
|
||||
fetchListPerfomaDokter();
|
||||
}, [selectedDoctors, startDateDokter, endDateDokter])
|
||||
|
||||
useEffect(() => {
|
||||
fetchListDokter();
|
||||
}, []);
|
||||
|
||||
|
||||
// Performa dokter
|
||||
const [openDialog, setOpenDialog] = useState(false);
|
||||
const handleOpen = () => setOpenDialog(true);
|
||||
|
||||
|
||||
const getContent = () => {
|
||||
const [search, setSearch] = useState(""); // State untuk pencarian dokter
|
||||
|
||||
// Filter dokter berdasarkan pencarian
|
||||
const filteredDoctors = doctors.filter((doctor) =>
|
||||
doctor.name.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
// Handle pilih satu dokter
|
||||
const handleSelectDoctor = (id) => {
|
||||
setSelectedDoctors((prev) =>
|
||||
prev.includes(id) ? prev.filter((docId) => docId !== id) : [...prev, id]
|
||||
);
|
||||
};
|
||||
|
||||
// Handle pilih semua dokter
|
||||
const handleSelectAll = () => {
|
||||
if (selectedDoctors.length === doctors.length) {
|
||||
setSelectedDoctors([]);
|
||||
} else {
|
||||
setSelectedDoctors(doctors.map((doctor) => doctor.id));
|
||||
}
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
setOpenDialog(false);
|
||||
setSelectedDoctors([]);
|
||||
}
|
||||
|
||||
const handlePilihDokter = () => {
|
||||
setOpenDialog(false);
|
||||
console.log(selectedDoctors);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{/* Search Bar */}
|
||||
<TextField
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
placeholder="Search Doctor"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
InputProps={{
|
||||
endAdornment: <SearchIcon />,
|
||||
}}
|
||||
sx={{ mb: 2, mt:2 }}
|
||||
/>
|
||||
|
||||
{/* Table Dokter */}
|
||||
<TableContainer component={Paper}>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>
|
||||
<Checkbox
|
||||
checked={selectedDoctors.length === doctors.length}
|
||||
onChange={handleSelectAll}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>Kode</TableCell>
|
||||
<TableCell>Nama</TableCell>
|
||||
<TableCell>Status</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{filteredDoctors.map((doctor) => (
|
||||
<TableRow key={doctor.id}>
|
||||
<TableCell>
|
||||
<Checkbox
|
||||
checked={selectedDoctors.includes(doctor.id)}
|
||||
onChange={() => handleSelectDoctor(doctor.id)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>{doctor.code}</TableCell>
|
||||
<TableCell>{doctor.name}</TableCell>
|
||||
<TableCell>
|
||||
<Typography
|
||||
sx={{
|
||||
color: doctor.online === 1 ? green[500] : red[500],
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{doctor.online === 1 ? "🟢 Online" : "🔴 Offline"}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialog}>Cancel</Button>
|
||||
<Button color="primary" variant="contained" onClick={handlePilihDokter}>Pilih</Button>
|
||||
|
||||
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Page title="Dashboard">
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<Container maxWidth="xl">
|
||||
<Typography variant="h3" component="h1" paragraph>
|
||||
Dashboard
|
||||
</Typography>
|
||||
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<SomethingUsage />
|
||||
{/* Jumlah Transaksi */}
|
||||
<Card sx={{ p: 3, mb: 3 }}>
|
||||
<Typography variant="h5" gutterBottom>
|
||||
Jumlah Transaksi
|
||||
</Typography>
|
||||
<Grid container spacing={3}>
|
||||
{/* Pilih */}
|
||||
<Grid item sm={3}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Tipe</InputLabel>
|
||||
<Select
|
||||
value={type}
|
||||
onChange={(e) => setType(e.target.value)}
|
||||
>
|
||||
<MenuItem value="0">Harian</MenuItem>
|
||||
<MenuItem value="1">Mingguan</MenuItem>
|
||||
<MenuItem value="2">Bulanan</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="Start"
|
||||
views={view}
|
||||
value={startDate}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
if (!value) return; // Hindari error jika value null atau undefined
|
||||
if (type == 0) {
|
||||
setStartDate(value);
|
||||
} else {
|
||||
setStartDate(new Date(value.getFullYear(), value.getMonth(), 1));
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="End"
|
||||
views={view}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
value={endDate}
|
||||
onChange={(value) => {
|
||||
if (!value) return; // Hindari error jika value null atau undefined
|
||||
if (type == 0) {
|
||||
setEndDate(value);
|
||||
} else {
|
||||
setEndDate(new Date(value.getFullYear(), value.getMonth(), 1));
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
{/* Pilih Status */}
|
||||
<Grid item sm={3}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Status</InputLabel>
|
||||
<Select
|
||||
value={status}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
>
|
||||
<MenuItem value="0">Semua</MenuItem>
|
||||
<MenuItem value="1">Berhasil</MenuItem>
|
||||
<MenuItem value="2">Abandon</MenuItem>
|
||||
<MenuItem value="3">Gagal</MenuItem>
|
||||
</Select>
|
||||
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<ResponsiveContainer width="100%" height={350}>
|
||||
<PieChart>
|
||||
<Pie
|
||||
data={transaksiData}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
outerRadius={100}
|
||||
fill="#8884d8"
|
||||
dataKey="value"
|
||||
label={({ percent }) => `${(percent * 100).toFixed(0)}%`}
|
||||
>
|
||||
{transaksiData.map((entry, index) => (
|
||||
<Cell key={`cell-${index}`} fill={entry.color} />
|
||||
))}
|
||||
</Pie>
|
||||
<Tooltip content={<CustomTooltipPie startDate={startDate} endDate={endDate} />} />
|
||||
<Legend />
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={8}>
|
||||
<div style={{ width: "100%", overflowX: "auto" }}>
|
||||
<ResponsiveContainer width={1000} height={350}>
|
||||
<BarChart
|
||||
data={transaksiDataBar}
|
||||
margin={{ top: 10, right: 30, left: 10, bottom: 10 }}
|
||||
>
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tickFormatter={(date) => date}
|
||||
/>
|
||||
<YAxis />
|
||||
<Tooltip content={<CustomTooltip />} />
|
||||
<Legend />
|
||||
<Bar dataKey="Berhasil" fill="#4CAF50" barSize={20} />
|
||||
<Bar dataKey="Gagal" fill="#F44336" barSize={20} />
|
||||
<Bar dataKey="Abandon" fill="#9E9E9E" barSize={20} />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<DangerCard>
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ mb: 0.6 }}>
|
||||
<Typography sx={{ typography: 'subtitle2' }}>This Month Usages </Typography>
|
||||
<Typography>{fCurrency(15000000)} (57)</Typography>
|
||||
</Stack>
|
||||
</DangerCard>
|
||||
<br />
|
||||
<SuccessCard>
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ mb: 0.6 }}>
|
||||
<Typography sx={{ typography: 'subtitle2' }}>Remaining Balance Estimation </Typography>
|
||||
<Typography>November 2022</Typography>
|
||||
</Stack>
|
||||
</SuccessCard>
|
||||
</Card>
|
||||
|
||||
{/* Performa Dokter */}
|
||||
<Card sx={{ p: 3 }}>
|
||||
<Typography variant="h5" gutterBottom>
|
||||
Performa Dokter
|
||||
</Typography>
|
||||
<Grid container spacing={3}>
|
||||
{/* Pilih Dokter*/}
|
||||
<Grid item sm={3}>
|
||||
<Button variant="contained" onClick={handleOpen}>
|
||||
Pilih Dokter
|
||||
</Button>
|
||||
</Grid>
|
||||
{/* Pilih */}
|
||||
<Grid item sm={3}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Tipe</InputLabel>
|
||||
<Select
|
||||
value={type}
|
||||
onChange={(e) => setType(e.target.value)}
|
||||
>
|
||||
<MenuItem value="0">Harian</MenuItem>
|
||||
<MenuItem value="1">Mingguan</MenuItem>
|
||||
<MenuItem value="2">Bulanan</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="Start"
|
||||
views={view}
|
||||
value={startDateDokter}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
if (!value) return; // Hindari error jika value null atau undefined
|
||||
if (type == 0) {
|
||||
setStartDateDokter(value);
|
||||
} else {
|
||||
setStartDateDokter(new Date(value.getFullYear(), value.getMonth(), 1));
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
<Grid item md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
label="End"
|
||||
views={view}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
value={endDateDokter}
|
||||
onChange={(value) => {
|
||||
if (!value) return; // Hindari error jika value null atau undefined
|
||||
if (type == 0) {
|
||||
setEndDateDokter(value);
|
||||
} else {
|
||||
setEndDateDokter(new Date(value.getFullYear(), value.getMonth(), 1));
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} variant="outlined" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
{/* Pilih Status */}
|
||||
<Grid item sm={2}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Status</InputLabel>
|
||||
<Select
|
||||
value={statusDokter}
|
||||
onChange={(e) => setStatusDokter(e.target.value)}
|
||||
>
|
||||
<MenuItem value="0">Semua</MenuItem>
|
||||
<MenuItem value="1">Berhasil</MenuItem>
|
||||
<MenuItem value="2">Abandon</MenuItem>
|
||||
<MenuItem value="3">Gagal</MenuItem>
|
||||
</Select>
|
||||
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item sm={12} marginTop={2}>
|
||||
<ResponsiveContainer width="100%" height={300}>
|
||||
<BarChart data={performaDokterData}>
|
||||
<XAxis dataKey="name" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
<Bar dataKey="Berhasil" fill="#4CAF50" />
|
||||
<Bar dataKey="Gagal" fill="#F44336" />
|
||||
<Bar dataKey="Abandon" fill="#9E9E9E" />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Dialog Pilih Dokter */}
|
||||
<MuiDialog
|
||||
title={{name: "Pilih Dokter"}}
|
||||
openDialog={openDialog}
|
||||
setOpenDialog={setOpenDialog}
|
||||
content={getContent()}
|
||||
maxWidth="xl"
|
||||
/>
|
||||
|
||||
</Card>
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
|
||||
1573
frontend/dashboard/src/pages/InvoicePayment/CreateInvoice.tsx
Normal file
1573
frontend/dashboard/src/pages/InvoicePayment/CreateInvoice.tsx
Normal file
File diff suppressed because it is too large
Load Diff
323
frontend/dashboard/src/pages/InvoicePayment/Detail.tsx
Normal file
323
frontend/dashboard/src/pages/InvoicePayment/Detail.tsx
Normal file
@@ -0,0 +1,323 @@
|
||||
import {
|
||||
Container,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
Card,
|
||||
TableRow,
|
||||
Tab,
|
||||
TableCell,
|
||||
Collapse,
|
||||
AccordionSummary,
|
||||
AccordionDetails,
|
||||
IconButton,
|
||||
TextField
|
||||
} from '@mui/material';
|
||||
import { fCurrency } from '../../utils/formatNumber';
|
||||
import { Table, TableBody, TableContainer, TableHead, Paper } from '@mui/material';
|
||||
// components
|
||||
import Page from '@/components/Page';
|
||||
// utils
|
||||
import useSettings from '@/hooks/useSettings';
|
||||
// react
|
||||
import { useNavigate, useParams, useLocation } from 'react-router-dom';
|
||||
import { useEffect, useState, useRef, useMemo } from 'react';
|
||||
import axios from '@/utils/axios';
|
||||
// pages
|
||||
import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
|
||||
import { fDate, fDateTimesecond, fDateTime } from '@/utils/formatTime';
|
||||
import { Button } from '@mui/material';
|
||||
import Label from '@/components/Label';
|
||||
import { Box } from '@mui/system';
|
||||
import { Accordion } from '@mui/material';
|
||||
import { Delete, EditOutlined, ExpandMore } from '@mui/icons-material';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
|
||||
import MoreMenu from '@/components/MoreMenu';
|
||||
import { MenuItem } from '@mui/material';
|
||||
import { fNumber } from '@/utils/formatNumber';
|
||||
import palette from '@/theme/palette';
|
||||
|
||||
import CloseIcon from '@mui/icons-material/Close';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material';
|
||||
import { List, ListItem, Link, Divider } from '@mui/material';
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export default function Detail() {
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { themeStretch } = useSettings();
|
||||
const [invoicePayment, setInvoicePayment] = useState([]);
|
||||
const [invoicePaymentDetail, setInvoicePaymentDetail] = useState([]);
|
||||
const [invoicePaymentFile, setInvoicePaymentFile] = useState([]);
|
||||
const [statusClaim, setStatusClaim] = useState('');
|
||||
const [dataMember, setDataMember] = useState('');
|
||||
|
||||
|
||||
const { id } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get('invoice-payment/detail/'+id)
|
||||
.then((response) => {
|
||||
setInvoicePayment(response.data.invoice_payments);
|
||||
setInvoicePaymentDetail(response.data.invoice_payment_details);
|
||||
setInvoicePaymentFile(response.data.files);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}, [id]);
|
||||
|
||||
console.log(invoicePayment);
|
||||
console.log(invoicePaymentDetail);
|
||||
console.log(invoicePaymentFile);
|
||||
|
||||
const style1 = {
|
||||
color: '#919EAB',
|
||||
width: '30%'
|
||||
}
|
||||
const style3 = {
|
||||
color: '#919EAB',
|
||||
width: '35%'
|
||||
}
|
||||
const style2 = {
|
||||
width: '70%'
|
||||
}
|
||||
const marginBottom1 = {
|
||||
marginBottom: 1,
|
||||
}
|
||||
const marginBottom2 = {
|
||||
marginBottom: 2,
|
||||
}
|
||||
|
||||
const handleCloseDialogSubmit = () => {
|
||||
setOpenDialogSubmit(false);
|
||||
}
|
||||
|
||||
const [decline, setDeclaine] = useState('');
|
||||
|
||||
// const handleSubmitData = () => {
|
||||
// //approve or decline
|
||||
// if(!reasonDecline && approve == 'decline')
|
||||
// {
|
||||
// enqueueSnackbar('Mohon isi alasan', { variant: 'warning' });
|
||||
// return false;
|
||||
// }
|
||||
// axios
|
||||
// .post('claims/'+id_claim+'/'+approve, {reasonDecline:reasonDecline})
|
||||
// .then((response) => {
|
||||
// enqueueSnackbar('Success '+toTitleCase(approve)+' Claim Request', { variant: 'success' });
|
||||
// setOpenDialogSubmit(false);
|
||||
// // window.location.reload();
|
||||
|
||||
// })
|
||||
// .catch(({ response }) => {
|
||||
// enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
// });
|
||||
|
||||
// setTimeout(() =>
|
||||
// {
|
||||
// window.location.reload();
|
||||
// }, 5000);
|
||||
|
||||
// };
|
||||
|
||||
function toTitleCase(str: string | null) {
|
||||
return str.replace(/\w\S*/g, function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
const [reasonDecline, setReasonDecline] = useState('');
|
||||
|
||||
const handleReasonDeclineChange = (event) => {
|
||||
setReasonDecline(event.target.value);
|
||||
// Tambahkan logika yang diperlukan di sini
|
||||
};
|
||||
|
||||
const [openDialogSubmit, setOpenDialogSubmit] = useState(false);
|
||||
const [openDialogEditDetail, setDialogDEditDetail] = useState(false);
|
||||
const [openDialogBenefit, setDialogBenefit] = useState(false);
|
||||
const [openDialogMedicine, setDialogMedicine] = useState(false);
|
||||
|
||||
// Handel Delete Detail Benefit
|
||||
const [idBenefitData, setIdBenefitData] = useState<number>();
|
||||
const [openDialogDeleteBenefit, setDialogDeleteBenefit] = useState(false)
|
||||
|
||||
const [idMedicineData, setIdMedicineData] = useState<number>();
|
||||
const [openDialogDeleteMedicine, setDialogDeleteMedicine] = useState(false)
|
||||
|
||||
const [approve, setApprove] = useState('')
|
||||
|
||||
// Handle Edit Detail Benefit
|
||||
const [openDialogEditBenefit, setDialogEditBenefit] = useState(false)
|
||||
const [BenefitConfigurationData, setBenefitConfigurationData] = useState<BenefitData>();
|
||||
|
||||
// Buat total data
|
||||
|
||||
|
||||
// Handle Delete File LOG
|
||||
const [pathFile, setPathFile] = useState('')
|
||||
const [dialogDeleteFIleLog, setDialogDeleteFileLog] = useState(false)
|
||||
|
||||
// Handle Upload File LOG
|
||||
const [dialogUploadFileLog, setDialogUploadFileLog] = useState(false)
|
||||
|
||||
const totalAmount = invoicePaymentFile.reduce((sum, payment) => {
|
||||
const num = parseFloat(payment.amount_paid) || 0;
|
||||
return parseFloat(sum) + parseFloat(num);
|
||||
}, 0);
|
||||
const grandTotal = invoicePaymentDetail.reduce((sum, item) => sum + parseFloat(item.tot_bill ? item.tot_bill : 0), 0);
|
||||
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<Stack direction="row" alignItems="center" sx={{ marginBottom: 3 }}>
|
||||
<ArrowBackIosIcon onClick={() => navigate(-1)} sx={{cursor:'pointer'}}/>
|
||||
<Typography variant="h5" sx={{ marginLeft: 2 }}>
|
||||
{/* {invoicePayment.length > 0 ? invoicePayment[0].invoice_number : 'Detail'} */}
|
||||
Detail Invoice
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Grid container spacing={2}>
|
||||
{/* Detail */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant='subtitle1' sx={{ color: '#19BBBB', marginBottom: 4 }} gutterBottom>
|
||||
Detail
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Tanggal Invoice</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? fDate(invoicePayment[0].invoice_date) : '-'}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Nomor Invoice </Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? invoicePayment[0].invoice_number : '-'}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Periode Pembayaran</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? fDate(invoicePayment[0].start_date) : '-'}-{invoicePayment.length > 0 ? fDate(invoicePayment[0].end_date) : '-'}</Typography>
|
||||
</Stack>
|
||||
|
||||
</Card>
|
||||
</Grid>
|
||||
|
||||
{/* Benefit */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
|
||||
<Typography variant='subtitle1' sx={{color: '#19BBBB'}} gutterBottom>Claim</Typography>
|
||||
</Stack>
|
||||
<TableContainer component={Paper}>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Code Claim/Code Log</TableCell>
|
||||
<TableCell>Invoice No</TableCell>
|
||||
<TableCell>Name</TableCell>
|
||||
<TableCell>Member ID</TableCell>
|
||||
<TableCell>Policy Number</TableCell>
|
||||
<TableCell>Provider</TableCell>
|
||||
<TableCell>Total Bill</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{invoicePaymentDetail.map((detail) => (
|
||||
<TableRow key={detail.id}>
|
||||
<TableCell>{detail.code} / {detail.code_log}</TableCell>
|
||||
<TableCell>{detail.invoice_no || '-'}</TableCell>
|
||||
<TableCell>{detail.name}</TableCell>
|
||||
<TableCell>{detail.member_id}</TableCell>
|
||||
<TableCell>{detail.corporate_policies}</TableCell>
|
||||
<TableCell>{detail.provider}</TableCell>
|
||||
<TableCell>{fCurrency(detail.tot_bill)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Card>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
{/* Catatan Pembayaran */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
|
||||
<Typography variant='subtitle1' sx={{color: '#19BBBB'}} gutterBottom>Catatan Pembayaran</Typography>
|
||||
|
||||
</Stack>
|
||||
{invoicePaymentFile.map((file, index) => (
|
||||
<Stack key={index.id} spacing={2} width="100%" sx={{ border: "1px solid #ddd", p: 2, borderRadius: 2, mt: 2, pt: 2 }}>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||
<Typography variant="subtitle1">Pembayaran {file.payment_number}</Typography>
|
||||
</Stack>
|
||||
|
||||
{/* Input Jumlah Bayar */}
|
||||
<Stack direction="row" spacing={2} width="100%">
|
||||
<Stack spacing={2} sx={{ width: "50%" }}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Nominal Pembayaran</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{fCurrency(parseFloat(file.amount_paid))}</Typography>
|
||||
</Stack>
|
||||
|
||||
{/* Input File Bukti */}
|
||||
<Stack spacing={2} sx={{ width: "50%" }}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Bukti Pembayaran</Typography>
|
||||
<Stack>
|
||||
<Stack divider={<Divider orientation="horizontal" flexItem />} spacing={1}>
|
||||
{file.files.map((file1, fileIndex) => (
|
||||
<Stack direction="row" justifyContent="space-between" key={fileIndex}>
|
||||
<a
|
||||
href={file1.path}
|
||||
style={{ cursor: 'pointer', textDecoration: 'none', color: '#19BBBB' }}
|
||||
target="_blank"
|
||||
>
|
||||
<Typography variant="body2" gutterBottom>{file1.original_name ? file1.original_name : '-'}</Typography>
|
||||
</a>
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
))}
|
||||
<Stack direction="row" justifyContent="space-between" alignContent="center" sx={{ mt: 2, pt: 2}}>
|
||||
<Typography variant='subtitle1' fontWeight="bold">Jumlah Tagihan</Typography>
|
||||
<Typography variant='subtitle1' fontWeight="bold">
|
||||
{fCurrency(grandTotal)}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{/* Total Jumlah Bayar */}
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mt: 2, borderTop: "2px solid #ddd", pt: 2 }}>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#19BBBB" }}>Total Dibayar</Typography>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#19BBBB" }}>
|
||||
{fCurrency(totalAmount.toString())}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mt: 1, pt: 1 }}>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#FF4842" }}>Sisa Pembayaran</Typography>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#FF4842" }}>
|
||||
{fCurrency((grandTotal - totalAmount))}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
30
frontend/dashboard/src/pages/InvoicePayment/Index.tsx
Normal file
30
frontend/dashboard/src/pages/InvoicePayment/Index.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Card, Stack } from "@mui/material";
|
||||
import HeaderBreadcrumbs from "../../components/HeaderBreadcrumbs";
|
||||
import Page from "../../components/Page";
|
||||
import List from "./List";
|
||||
|
||||
|
||||
|
||||
export default function Invoice() {
|
||||
|
||||
const pageTitle = 'Invoice Management';
|
||||
return (
|
||||
<Page title={ pageTitle } sx={{ mx: 2}}>
|
||||
|
||||
<HeaderBreadcrumbs
|
||||
heading={ pageTitle }
|
||||
links={[
|
||||
{ name: 'Dashboard', href: '/dashboard' },
|
||||
{
|
||||
name: 'Invoice Payment',
|
||||
href: '/invoice-payment',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* <Stack> */}
|
||||
<List />
|
||||
{/* </Stack> */}
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
1063
frontend/dashboard/src/pages/InvoicePayment/List.tsx
Normal file
1063
frontend/dashboard/src/pages/InvoicePayment/List.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,8 @@ import {
|
||||
Autocomplete,
|
||||
InputAdornment,
|
||||
IconButton,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
} from '@mui/material';
|
||||
|
||||
import {
|
||||
@@ -61,6 +63,7 @@ import { RHFDatepicker } from '@/components/hook-form';
|
||||
import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
||||
import { fDateOnly } from '@/utils/formatTime';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -73,7 +76,9 @@ export default function List() {
|
||||
const [searchParamsOrganizations, setSearchParamsOrganizations] = useSearchParams();
|
||||
const [searchParamsSpecialities, setSearchParamsSpecialities] = useSearchParams();
|
||||
const [searchParamsFilter, setSearchParamsFilter] = useSearchParams();
|
||||
|
||||
const [type, setType] = useState(0);
|
||||
const [view, setView] = useState(["day", "month", "year"]);
|
||||
|
||||
function Filter(props: any) {
|
||||
// SEARCH
|
||||
const searchInput = useRef<HTMLInputElement>(null);
|
||||
@@ -91,9 +96,27 @@ export default function List() {
|
||||
props.onSearch(searchText);
|
||||
};
|
||||
|
||||
const handleTypeChange = (value: string) => { // Perbaikan di parameter
|
||||
setType(value); // Mengatur state type dengan nilai baru
|
||||
if (value === "0") {
|
||||
setView(["day", "month", "year"]); // Urutan benar
|
||||
} else {
|
||||
setView(["month"]); // Hanya menampilkan bulan & tahun
|
||||
}
|
||||
|
||||
let entries = [...searchParams.entries(), ['type', value ?? '']];
|
||||
if (!searchParams.get('type')) {
|
||||
entries = [...entries, ['type', value ?? '']];
|
||||
}
|
||||
const filter = Object.fromEntries(entries);
|
||||
|
||||
setSearchParams(filter);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Trigger First Search
|
||||
setSearchText(searchParams.get('search') ?? '');
|
||||
|
||||
}, []);
|
||||
|
||||
const item = [
|
||||
@@ -107,7 +130,7 @@ export default function List() {
|
||||
return (
|
||||
<form style={{ width: '100%' }}>
|
||||
<Grid container spacing={2} sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Grid item xs={12} md={4}>
|
||||
<TextField
|
||||
id="search-input"
|
||||
ref={searchInput}
|
||||
@@ -130,21 +153,42 @@ export default function List() {
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Tipe</InputLabel>
|
||||
<Select
|
||||
value={type}
|
||||
onChange={(event) => handleTypeChange(event.target.value)} // Perbaikan disini
|
||||
>
|
||||
<MenuItem value="0">Daily</MenuItem>
|
||||
<MenuItem value="1">Monthly</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
views={view}
|
||||
value={searchParams.get('startDate')}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
try {
|
||||
if (value && !!Date.parse(value)) {
|
||||
const date = value ? fDateOnly(value) : '';
|
||||
var entries = [...searchParams.entries(), ['startDate', date ?? '']];
|
||||
let date = fDateOnly(value);
|
||||
|
||||
// Jika view adalah "month", set tanggal ke 1
|
||||
if (view.length === 1 && view.includes("month")) {
|
||||
const dateObj = new Date(value);
|
||||
dateObj.setDate(1);
|
||||
date = fDateOnly(dateObj);
|
||||
}
|
||||
|
||||
let entries = [...searchParams.entries(), ['startDate', date ?? '']];
|
||||
if (!searchParams.get('endDate')) {
|
||||
entries = [...entries, ['endDate', date ?? '']];
|
||||
}
|
||||
const filter = Object.fromEntries(entries);
|
||||
|
||||
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
@@ -157,18 +201,28 @@ export default function List() {
|
||||
<Grid item xs={12} md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
views={view}
|
||||
value={searchParams.get('endDate')}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
try {
|
||||
if (value && !!Date.parse(value)) {
|
||||
const date = fDateOnly(value);
|
||||
var entries = [...searchParams.entries(), ['endDate', date ?? '']];
|
||||
let date = fDateOnly(value);
|
||||
|
||||
// Jika mode monthly, set endDate ke akhir bulan dari startDate
|
||||
if (view.length === 1 && view.includes("month")) {
|
||||
const dateObj = new Date(value);
|
||||
dateObj.setMonth(dateObj.getMonth() + 1); // Pindah ke bulan berikutnya
|
||||
dateObj.setDate(0); // Set ke tanggal terakhir bulan sebelumnya (akhir bulan)
|
||||
date = fDateOnly(dateObj);
|
||||
}
|
||||
|
||||
let entries = [...searchParams.entries(), ['endDate', date ?? '']];
|
||||
if (!searchParams.get('startDate')) {
|
||||
entries = [...entries, ['startDate', date ?? '']];
|
||||
entries = [...entries, ['startDate', date ?? ''] ];
|
||||
}
|
||||
const filter = Object.fromEntries(entries);
|
||||
|
||||
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
@@ -188,15 +242,25 @@ export default function List() {
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<Button
|
||||
{/* <LoadingButton
|
||||
type="submit"
|
||||
variant="contained"
|
||||
size="small"
|
||||
|
||||
|
||||
>
|
||||
{'Save'}
|
||||
</LoadingButton> */}
|
||||
<LoadingButton
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
startIcon={<Add />}
|
||||
sx={{ p: 1.8 }}
|
||||
loading={isSubmitting}
|
||||
onClick={exportExcel}
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
</LoadingButton>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</form>
|
||||
@@ -383,6 +447,7 @@ export default function List() {
|
||||
const [dataTableIsLoading, setDataTableLoading] = useState(true);
|
||||
const [dataTableLastRequest, setDataTableLastRequest] = useState(0);
|
||||
const [dataTableResponseState, setDataTableResponseState] = useState('idle');
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>({
|
||||
current_page: 1,
|
||||
data: [],
|
||||
@@ -411,10 +476,11 @@ export default function List() {
|
||||
|
||||
const exportExcel = async () => {
|
||||
var filter = Object.fromEntries([...searchParams.entries()]);
|
||||
|
||||
setIsSubmitting(true)
|
||||
await axios
|
||||
.get('live-chat/export', { params: filter })
|
||||
.then((res) => {
|
||||
setIsSubmitting(false)
|
||||
enqueueSnackbar('Data berhasil di Export', {
|
||||
variant: 'success',
|
||||
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
||||
|
||||
@@ -480,6 +480,22 @@ export default function Router() {
|
||||
path: 'report/rujukan',
|
||||
element: <RujukanPasien/>,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment',
|
||||
element: <InvoicePayments />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/create',
|
||||
element: <CreateInvoicePayments />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/detail/:id',
|
||||
element: <InvoicePaymentsDetail />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/edit/:invoiceID',
|
||||
element: <InvoicePaymentsEdit />,
|
||||
},
|
||||
{
|
||||
path: 'claims',
|
||||
element: <Claims />,
|
||||
@@ -780,6 +796,13 @@ const CorporateHistories = Loadable(
|
||||
|
||||
const Profile = Loadable(lazy(() => import('../pages/Profile/Index')));
|
||||
|
||||
//Invoice_Payments
|
||||
const InvoicePayments = Loadable(lazy(() => import('../pages/InvoicePayment/Index')));
|
||||
const CreateInvoicePayments = Loadable(lazy(() => import('../pages/InvoicePayment/CreateInvoice')));
|
||||
const InvoicePaymentsDetail = Loadable(lazy(() => import('../pages/InvoicePayment/Detail')));
|
||||
const InvoicePaymentsEdit = Loadable(lazy(() => import('../pages/InvoicePayment/CreateInvoice')));
|
||||
|
||||
|
||||
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
|
||||
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/CreateUpdate')));
|
||||
const ClaimsDetail = Loadable(lazy(() => import('../pages/Claims/Detail')));
|
||||
|
||||
Reference in New Issue
Block a user