add fitur delete file dan update daily monitoring
This commit is contained in:
@@ -175,8 +175,12 @@ class DataServiceMonitoring extends JsonResource
|
||||
->groupBy(function ($requestLogDailyMonitoring) {
|
||||
return Carbon::parse($requestLogDailyMonitoring->lab_date)->format('d M Y');
|
||||
})
|
||||
->filter(function ($groupedItems) {
|
||||
return !is_null($groupedItems->first()->lab_date);
|
||||
})
|
||||
->map(function ($groupedItems) {
|
||||
return collect($groupedItems)
|
||||
|
||||
->map(function ($test) {
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')
|
||||
@@ -197,6 +201,7 @@ class DataServiceMonitoring extends JsonResource
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => $test->code,
|
||||
'date' => Carbon::parse($test->lab_date)->format('d M Y') ?? null,
|
||||
|
||||
@@ -10,6 +10,7 @@ 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;
|
||||
|
||||
@@ -120,6 +121,230 @@ class DailyMonitoringController extends Controller
|
||||
],200);
|
||||
}
|
||||
|
||||
public function GetDetailMonitoringListbyID(Request $request, $id)
|
||||
{
|
||||
|
||||
$detail = RequestDailyMonitoring::where('id', $id)
|
||||
->orderBy("created_at", "desc")
|
||||
->first();
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => $detail,
|
||||
],200);
|
||||
}
|
||||
|
||||
public function UpdateDetailMonitoringbyID(Request $request)
|
||||
{
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'subject' => 'required',
|
||||
'submission_date' => 'required',
|
||||
'body_temperature' => 'required',
|
||||
'sistole' => 'required',
|
||||
'diastole' => 'required',
|
||||
'respiration_rate' => 'required',
|
||||
'analysis' => 'required',
|
||||
'medical_plan' => 'required',
|
||||
'reason' => 'required',
|
||||
'non_medikamentosa_plan' => '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([
|
||||
'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,
|
||||
'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
|
||||
*/
|
||||
@@ -420,6 +645,35 @@ class DailyMonitoringController extends Controller
|
||||
], 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
|
||||
*/
|
||||
|
||||
@@ -175,10 +175,13 @@ Route::prefix('internal')->group(function () {
|
||||
// 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::post('detail/update-request', [DailyMonitoringController::class, 'UpdateDetailMonitoringbyID']);
|
||||
Route::post('detail/{claim_code}/add', [DailyMonitoringController::class, 'AddDetailMonitoringList']);
|
||||
Route::post('detail/{claim_code}/add-request', [DailyMonitoringController::class, 'AddDetailMonitoringListRequestLog']);
|
||||
Route::post('detail/{claim_code}/update-status', [DailyMonitoringController::class, 'UpdateListRequestLog']);
|
||||
Route::get('detail/{id}/delete', [DailyMonitoringController::class, 'deleteDetailMonitoringListRequestLog']);
|
||||
Route::get('detail/{id}/delete-file', [DailyMonitoringController::class, 'deleteFileDetailMonitoringListRequestLog']);
|
||||
});
|
||||
|
||||
// Laboratorium Result
|
||||
|
||||
@@ -34,7 +34,7 @@ class RequestDailyMonitoring extends Model
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date'];
|
||||
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date', 'confirmation_medical_leter', 'medical_action_letter', 'laboratorium_result'];
|
||||
|
||||
// public function getBodyTemperatureAttribute()
|
||||
// {
|
||||
@@ -99,10 +99,15 @@ class RequestDailyMonitoring extends Model
|
||||
public function getDocumentAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where(['fileable_type' => 'App\Models\LaboratoriumResult', 'fileable_id' => $this->attributes['id']])->get();
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
'deleted_at' => null,
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'id' => $row->id,
|
||||
'file_name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
@@ -117,4 +122,62 @@ class RequestDailyMonitoring extends Model
|
||||
return $discharge_date = DB::table('request_logs')->where('id', $this->attributes['request_log_id'])->select('discharge_date')->first();
|
||||
}
|
||||
|
||||
public function getConfirmationMedicalLeterAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'confirmation-medical-letter',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
public function getMedicalActionLetterAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'medical-action-letter',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
public function getLaboratoriumResultAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'laboratorium-result',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, IconButton, Typography, Grid, Card, Button, ButtonBase, Stack } from '@mui/material';
|
||||
import { Box, IconButton, Typography, Grid, Card, Button, ButtonBase, Stack, Autocomplete } from '@mui/material';
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
|
||||
/**
|
||||
@@ -28,16 +28,23 @@ import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { AddMonitoringDetail, getOrganizationId } from '../Model/Functions';
|
||||
import { AddMonitoringDetail, UpdateMonitoringDetail, getMonitoringDetailById, getMonitoringDetailList, getMonitorungDetailById, getOrganizationId } from '../Model/Functions';
|
||||
import { DetailMonitoringListType} from '../Model/Types';
|
||||
import FormCreateFilesUpload from '@/pages/CustomerService/FinalLog/Components/FormCreateFilesUpload';
|
||||
import MultiFilePreview from '@/components/upload/MultiFilePreview';
|
||||
import Iconify from '@/components/Iconify';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { TextField } from '@mui/material';
|
||||
|
||||
type Detail = {
|
||||
row : DetailMonitoringListType|undefined
|
||||
}
|
||||
|
||||
export default function DetailMonitoringList() {
|
||||
const { member_id, claim_code } = useParams();
|
||||
const { member_id, claim_code, id} = useParams();
|
||||
const [organizationId, setOrganizationId] = useState<number|undefined>();
|
||||
const [isEdit, setIsEdit] = useState<boolean|undefined>(false);
|
||||
const [data, setData] = useState<DetailMonitoringListType>();
|
||||
|
||||
const navigate = useNavigate()
|
||||
const pageTitle = claim_code??'_ _ _ _';
|
||||
@@ -49,39 +56,94 @@ export default function DetailMonitoringList() {
|
||||
const organization_id = await getOrganizationId(claim_code??'');
|
||||
setOrganizationId(organization_id);
|
||||
}
|
||||
const loadDetailDailyMonitoring = async () => {
|
||||
const monitoring = await getMonitoringDetailById(id??'')
|
||||
setData(monitoring)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadOrganizationID();
|
||||
if (id){
|
||||
loadDetailDailyMonitoring();
|
||||
setIsEdit(true)
|
||||
console.log(data)
|
||||
}
|
||||
}, [])
|
||||
|
||||
// setup form
|
||||
// ====================================
|
||||
const defaultValues: DetailMonitoringListType = {
|
||||
id : '',
|
||||
claim_code : '',
|
||||
claim_id : '',
|
||||
subject : '',
|
||||
objective : '',
|
||||
submission_date : '',
|
||||
body_temperature: '',
|
||||
sistole : '',
|
||||
diastole : '',
|
||||
respiration_rate: '',
|
||||
complaints : '',
|
||||
analysis : '',
|
||||
medical_plan : [{
|
||||
medical_plan_str: ''
|
||||
}],
|
||||
non_medikamentosa_plan : [{
|
||||
non_medikamentosa_plan_str: ''
|
||||
}],
|
||||
confirmation_medical_leter : [],
|
||||
medical_action_letter : [],
|
||||
result : [],
|
||||
created_at : '',
|
||||
lab_date : '',
|
||||
provider : '',
|
||||
examination : '',
|
||||
};
|
||||
const defaultValues = useMemo(
|
||||
() => ({
|
||||
id : data?.id ??'',
|
||||
claim_code : data?.claim_code ?? '',
|
||||
claim_id : data?.claim_id ?? '',
|
||||
subject : data?.subject ?? '',
|
||||
objective : data?.object ?? '',
|
||||
submission_date : data?.submission_date ?? '',
|
||||
body_temperature: data?.body_temperature ?? '',
|
||||
sistole : data?.sistole ?? '',
|
||||
diastole : data?.diastole ??'',
|
||||
respiration_rate: data?.respiration_rate ??'',
|
||||
complaints : data?.complaints ?? '',
|
||||
analysis : data?.analysis ?? '',
|
||||
medical_plan : data?.medical_plan ?? [{
|
||||
medical_plan_str: ''
|
||||
}],
|
||||
non_medikamentosa_plan : data?.non_medikamentosa_plan ?? [{
|
||||
non_medikamentosa_plan_str: ''
|
||||
}],
|
||||
confirmation_medical_leter : [],
|
||||
medical_action_letter : [],
|
||||
// result : data?.laboratorium_result ?? [],
|
||||
result : [],
|
||||
created_at : data?.created_at ?? '',
|
||||
lab_date : data?.lab_date ?? '',
|
||||
provider : data?.provider ?? '',
|
||||
examination : data?.examination ?? '',
|
||||
reason : '',
|
||||
}),
|
||||
[data]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isEdit && data) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
if (!isEdit) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
// setFileKondisis(currentClaim?.files_by_type?.claim_diagnosis);
|
||||
// setFileDiagnosas(currentClaim?.files_by_type?.claim_diagnosis);
|
||||
}, [isEdit, data]);
|
||||
|
||||
// const defaultValues: DetailMonitoringListType = {
|
||||
// id : '',
|
||||
// claim_code : '',
|
||||
// claim_id : '',
|
||||
// subject : '',
|
||||
// objective : '',
|
||||
// submission_date : '',
|
||||
// body_temperature: '',
|
||||
// sistole : '',
|
||||
// diastole : '',
|
||||
// respiration_rate: '',
|
||||
// complaints : '',
|
||||
// analysis : data?.analysis ?? '',
|
||||
// medical_plan : [{
|
||||
// medical_plan_str: ''
|
||||
// }],
|
||||
// non_medikamentosa_plan : [{
|
||||
// non_medikamentosa_plan_str: ''
|
||||
// }],
|
||||
// confirmation_medical_leter : [],
|
||||
// medical_action_letter : [],
|
||||
// result : [],
|
||||
// created_at : '',
|
||||
// lab_date : '',
|
||||
// provider : '',
|
||||
// examination : '',
|
||||
// };
|
||||
|
||||
|
||||
const methods = useForm<any>({
|
||||
defaultValues
|
||||
@@ -113,7 +175,6 @@ export default function DetailMonitoringList() {
|
||||
arr_medical_action_letter.push(event.target.files[0]);
|
||||
|
||||
setValue('medical_action_letter', arr_medical_action_letter)
|
||||
console.log('test2')
|
||||
}
|
||||
else {
|
||||
console.log('NO FILE');
|
||||
@@ -168,15 +229,27 @@ export default function DetailMonitoringList() {
|
||||
// Submit Form
|
||||
// =====================================
|
||||
const submitHandler = async (data: DetailMonitoringListType) => {
|
||||
const response = await AddMonitoringDetail(claim_code??'', data);
|
||||
|
||||
const response = isEdit ? await UpdateMonitoringDetail(data) : await AddMonitoringDetail(claim_code??'', data);
|
||||
|
||||
if (response == true) {
|
||||
reset();
|
||||
navigate('/case_management/daily_monitoring/'+member_id+'/'+organizationId+'/claims', { replace: true });
|
||||
if (isEdit) {
|
||||
navigate('/case_management/daily_monitoring/'+member_id+'/claims/'+claim_code+'/list_monitoring', { replace: true });
|
||||
} else {
|
||||
navigate('/case_management/daily_monitoring/'+member_id+'/'+organizationId+'/claims', { replace: true });
|
||||
}
|
||||
// window.location.reload()
|
||||
}
|
||||
}
|
||||
|
||||
const [selectedReason, setSelectedReason] = useState({value:'-', label:''});
|
||||
const reasons = [
|
||||
{ value: 'Wrong Setting', label: 'Wrong Setting' },
|
||||
{ value: 'Hospital Request', label: 'Hospital Request' }
|
||||
];
|
||||
const [error, setError] = useState(true);
|
||||
|
||||
return (
|
||||
<Page title={pageTitle}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', pl: '22px', mb: '40px' }}>
|
||||
@@ -211,6 +284,7 @@ export default function DetailMonitoringList() {
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Subject */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={3}>
|
||||
@@ -586,7 +660,6 @@ export default function DetailMonitoringList() {
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
{/* Laboratorium */}
|
||||
<Grid item xs={12}>
|
||||
@@ -689,6 +762,49 @@ export default function DetailMonitoringList() {
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Reason Update */}
|
||||
{
|
||||
isEdit ? (
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="subtitle1" marginY={2}>Reason for Update*</Typography>
|
||||
<Stack direction='row' spacing={2} sx={{marginBottom: 2}}>
|
||||
<Autocomplete
|
||||
options={reasons}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedReason}
|
||||
onChange={(event, newValue) => {
|
||||
setSelectedReason(newValue);
|
||||
setValue('reason',newValue?.value)
|
||||
// Validasi jika newValue adalah null
|
||||
if (!newValue) {
|
||||
setError('Please select a reason');
|
||||
} else {
|
||||
setError('');
|
||||
}
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<RHFTextField
|
||||
{...params}
|
||||
label="Reason for Delete"
|
||||
variant="outlined"
|
||||
id="reason"
|
||||
name='reason'
|
||||
error={Boolean(error)} // Menampilkan error jika ada
|
||||
helperText={error} // Menampilkan pesan kesalahan
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
) : null
|
||||
}
|
||||
|
||||
|
||||
|
||||
{/* Button Cancel & Save */}
|
||||
<Grid item xs={12} md={12}>
|
||||
@@ -697,8 +813,8 @@ export default function DetailMonitoringList() {
|
||||
<Button variant="outlined" color="inherit" onClick={() => navigate(`/case_management/daily_monitoring/${member_id}/claims`)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<LoadingButton disabled={!isDirty} type="submit" variant="contained" loading={isSubmitting}>
|
||||
Add
|
||||
<LoadingButton disabled={ isEdit ? error : !isDirty} type="submit" variant="contained" loading={isSubmitting}>
|
||||
{isEdit ? 'Update' : 'Add'}
|
||||
</LoadingButton>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -33,7 +33,7 @@ import { getOrganizationId } from '../Model/Functions';
|
||||
import { DetailMonitoringListType } from '../Model/Types';
|
||||
import TableMoreMenu from '@/components/table/TableMoreMenu';
|
||||
import { MenuItem } from '@mui/material';
|
||||
import { Delete } from '@mui/icons-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';
|
||||
@@ -68,7 +68,9 @@ export default function DetailMonitoringList() {
|
||||
{ value: 'Hospital Request', label: 'Hospital Request' }
|
||||
];
|
||||
const [error, setError] = useState('');
|
||||
const [id, setId] = useState(null);
|
||||
const [id, setId] = useState<null|number>(null);
|
||||
const [id_file, setIdFile] = useState<null|number>(null);
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
setOpenDialog(false);
|
||||
}
|
||||
@@ -77,27 +79,52 @@ export default function DetailMonitoringList() {
|
||||
const parameters = {
|
||||
'reason' : selectedReason.value
|
||||
}
|
||||
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' });
|
||||
}
|
||||
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 Daily Monitoring ?</Typography>
|
||||
<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>
|
||||
<Typography variant="subtitle1" marginY={2}>Reason for Delete*</Typography>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Autocomplete
|
||||
options={reason}
|
||||
@@ -131,9 +158,10 @@ export default function DetailMonitoringList() {
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialog}>Cancel</Button>
|
||||
<Button color="primary" variant="contained" onClick={() => handleDelete()}>Delete</Button>
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
)
|
||||
</Stack>
|
||||
)
|
||||
|
||||
|
||||
// Load Data
|
||||
// -------------------
|
||||
const loadDataTableData = async () => {
|
||||
@@ -203,10 +231,16 @@ export default function DetailMonitoringList() {
|
||||
|
||||
<Box sx={{ marginLeft: 'auto' }}> {/* Menempatkan TableMoreMenu di sebelah kanan */}
|
||||
<TableMoreMenu actions={
|
||||
<MenuItem onClick={() => {setOpenDialog(true); setId(row.id)}}>
|
||||
<Delete color='error' />
|
||||
Delete
|
||||
</MenuItem>
|
||||
<>
|
||||
<MenuItem onClick={() => {handleEdit(row.id);}}>
|
||||
<Edit />
|
||||
Edit
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => {setOpenDialog(true); setId(row.id); setIdFile(null)}}>
|
||||
<Delete color='error' />
|
||||
Delete
|
||||
</MenuItem>
|
||||
</>
|
||||
} />
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -394,93 +428,106 @@ export default function DetailMonitoringList() {
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid container>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Confirmation Medical Letter:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
<ListItem key={index}>
|
||||
{data.type === 'confirmation-medical-letter' ? (
|
||||
<>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path} // Replace 'data.download_link' with the actual download link
|
||||
target="_blank" // Optional: Open the link in a new tab
|
||||
rel="noopener noreferrer" // Recommended when using target="_blank"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</ListItem>
|
||||
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>
|
||||
<a
|
||||
onClick={() => { setOpenDialog(true); setIdFile(data.id); setId(null); }}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<DeleteForever color='error'/>
|
||||
</a>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Medical Action Letter:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
<ListItem key={index}>
|
||||
{data.type === 'medical-action-letter' ? (
|
||||
<>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path} // Replace 'data.download_link' with the actual download link
|
||||
target="_blank" // Optional: Open the link in a new tab
|
||||
rel="noopener noreferrer" // Recommended when using target="_blank"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</ListItem>
|
||||
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>
|
||||
<a
|
||||
onClick={() => { setOpenDialog(true); setIdFile(data.id); setId(null); }}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<DeleteForever color='error'/>
|
||||
</a>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document Laboratorium Result:
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
<List>
|
||||
{row.document?.map((data, index) => (
|
||||
<ListItem key={index}>
|
||||
{data.type === 'laboratorium-result' ? (
|
||||
<>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} />
|
||||
<a
|
||||
href={data.path} // Replace 'data.download_link' with the actual download link
|
||||
target="_blank" // Optional: Open the link in a new tab
|
||||
rel="noopener noreferrer" // Recommended when using target="_blank"
|
||||
>
|
||||
{data.file_name}
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</ListItem>
|
||||
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>
|
||||
<a
|
||||
onClick={() => { setOpenDialog(true); setIdFile(data.id); setId(null); }}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<DeleteForever color='error'/>
|
||||
</a>
|
||||
</ListItem>
|
||||
) : null
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Card>
|
||||
</Grid>
|
||||
@@ -492,7 +539,7 @@ export default function DetailMonitoringList() {
|
||||
|
||||
{/* Dialog Delete */}
|
||||
<MuiDialog
|
||||
title={{name: "Delete Daily Monitoring"}}
|
||||
title={{name: id_file ? "Delete File Daily Monitoring" : "Delete Daily Monitoring"}}
|
||||
openDialog={openDialog}
|
||||
setOpenDialog={setOpenDialog}
|
||||
content={getContent()}
|
||||
|
||||
@@ -99,6 +99,7 @@ export const getMonitoringDetailList = async ( claim_code: string ): Promise<Det
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Monitoring Detail List
|
||||
*/
|
||||
@@ -117,3 +118,61 @@ export const getOrganizationId = async ( claim_code: string ): Promise<number> =
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get detail monitoring
|
||||
*/
|
||||
export const getMonitoringDetailById = async ( id: string) => {
|
||||
const response = await axios.get(`/case_management/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(`/case_management/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;
|
||||
}
|
||||
|
||||
@@ -50,21 +50,22 @@ export type ClaimListType = {
|
||||
export type DetailMonitoringListType = {
|
||||
id : number|null,
|
||||
claim_id : string|null,
|
||||
claim_code : string,
|
||||
subject : string,
|
||||
object : string,
|
||||
objective : string,
|
||||
body_temperature: string,
|
||||
respiration_rate: string,
|
||||
sistole : string,
|
||||
diastole : string
|
||||
analysis : string,
|
||||
complaints : string,
|
||||
submission_date : string,
|
||||
discharge_date : string,
|
||||
lab_date : string,
|
||||
provider : string,
|
||||
examination : string,
|
||||
claim_code : 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[],
|
||||
@@ -90,6 +91,7 @@ export type files = {
|
||||
}
|
||||
|
||||
export type document = {
|
||||
id: number
|
||||
file_name: string,
|
||||
path: string,
|
||||
type: string
|
||||
|
||||
@@ -232,6 +232,10 @@ export default function Router() {
|
||||
path: 'daily_monitoring/:member_id/claims/:claim_code/add_monitoring',
|
||||
element: <DetailMonitoringForm />
|
||||
},
|
||||
{
|
||||
path: 'daily_monitoring/:member_id/claims/:claim_code/:id',
|
||||
element: <DetailMonitoringForm />
|
||||
},
|
||||
{
|
||||
path: 'daily_monitoring/:member_id/claims/:claim_code/list_monitoring',
|
||||
element: <DetailMonitoringList />
|
||||
|
||||
Reference in New Issue
Block a user