delete daily monitoring
This commit is contained in:
@@ -395,6 +395,31 @@ class DailyMonitoringController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Status Request LOG
|
* Update Status Request LOG
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::post('detail/{claim_code}/add', [DailyMonitoringController::class, 'AddDetailMonitoringList']);
|
Route::post('detail/{claim_code}/add', [DailyMonitoringController::class, 'AddDetailMonitoringList']);
|
||||||
Route::post('detail/{claim_code}/add-request', [DailyMonitoringController::class, 'AddDetailMonitoringListRequestLog']);
|
Route::post('detail/{claim_code}/add-request', [DailyMonitoringController::class, 'AddDetailMonitoringListRequestLog']);
|
||||||
Route::post('detail/{claim_code}/update-status', [DailyMonitoringController::class, 'UpdateListRequestLog']);
|
Route::post('detail/{claim_code}/update-status', [DailyMonitoringController::class, 'UpdateListRequestLog']);
|
||||||
|
Route::get('detail/{id}/delete', [DailyMonitoringController::class, 'deleteDetailMonitoringListRequestLog']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Laboratorium Result
|
// Laboratorium Result
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
class RequestDailyMonitoring extends Model
|
class RequestDailyMonitoring extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
protected $table = "request_log_daily_monitorings";
|
protected $table = "request_log_daily_monitorings";
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
@@ -28,6 +30,8 @@ class RequestDailyMonitoring extends Model
|
|||||||
'created_by',
|
'created_by',
|
||||||
'updated_by',
|
'updated_by',
|
||||||
'deleted_by',
|
'deleted_by',
|
||||||
|
'reason',
|
||||||
|
'deleted_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date'];
|
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date'];
|
||||||
@@ -52,6 +56,18 @@ class RequestDailyMonitoring extends Model
|
|||||||
// return round($this->attributes['respiration_rate'], 0);
|
// return round($this->attributes['respiration_rate'], 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
// Event handling untuk deleting
|
||||||
|
static::deleting(function ($model) {
|
||||||
|
// Set nilai deleted_by dengan ID pengguna yang melakukan penghapusan (jika ada)
|
||||||
|
$model->deleted_by = Auth::id();
|
||||||
|
$model->save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function getMedicalPlanAttribute()
|
public function getMedicalPlanAttribute()
|
||||||
{
|
{
|
||||||
$arr_medical_plan = [];
|
$arr_medical_plan = [];
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ class RequestLog extends Model
|
|||||||
|
|
||||||
public function requestLogDailyMonitorings()
|
public function requestLogDailyMonitorings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(RequestLogDailyMonitoring::class, 'request_log_id');
|
return $this->hasMany(RequestLogDailyMonitoring::class, 'request_log_id')->whereNull('deleted_at');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPaymentTypeNameAttribute()
|
public function getPaymentTypeNameAttribute()
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?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::table('request_log_daily_monitorings', function (Blueprint $table) {
|
||||||
|
$table->string('reason');
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('request_log_daily_monitorings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('reason');
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
* Core
|
* Core
|
||||||
* ============================================
|
* ============================================
|
||||||
*/
|
*/
|
||||||
import { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import { Box, IconButton, Typography, Grid, Card, List, ListItem } from '@mui/material';
|
import { Box, IconButton, Typography, Grid, Card, List, ListItem, Stack, Autocomplete, TextField, Button } from '@mui/material';
|
||||||
import { LoadingButton } from "@mui/lab";
|
import { LoadingButton } from "@mui/lab";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +31,13 @@ import { fDate, fDateOnly } from '@/utils/formatTime';
|
|||||||
import { getMonitoringDetailList } from '../Model/Functions';
|
import { getMonitoringDetailList } from '../Model/Functions';
|
||||||
import { getOrganizationId } from '../Model/Functions';
|
import { getOrganizationId } from '../Model/Functions';
|
||||||
import { DetailMonitoringListType } from '../Model/Types';
|
import { DetailMonitoringListType } from '../Model/Types';
|
||||||
|
import TableMoreMenu from '@/components/table/TableMoreMenu';
|
||||||
|
import { MenuItem } from '@mui/material';
|
||||||
|
import { Delete } from '@mui/icons-material';
|
||||||
|
import MuiDialog from '@/components/MuiDialog';
|
||||||
|
import { DialogActions } from '@mui/material';
|
||||||
|
import axios from '@/utils/axios';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
|
||||||
|
|
||||||
export default function DetailMonitoringList() {
|
export default function DetailMonitoringList() {
|
||||||
@@ -42,12 +49,91 @@ export default function DetailMonitoringList() {
|
|||||||
// --------------------
|
// --------------------
|
||||||
const [detailMonitoringList, setDetailMonitoringList] = useState<DetailMonitoringListType[]>();
|
const [detailMonitoringList, setDetailMonitoringList] = useState<DetailMonitoringListType[]>();
|
||||||
const [organizationId, setOrganizationId] = useState<number|undefined>();
|
const [organizationId, setOrganizationId] = useState<number|undefined>();
|
||||||
|
|
||||||
|
const [openDialog, setOpenDialog] = useState<boolean>(false)
|
||||||
|
|
||||||
// Use Effect
|
// Use Effect
|
||||||
// --------------------
|
// --------------------
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadDataTableData();
|
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);
|
||||||
|
const handleCloseDialog = () => {
|
||||||
|
setOpenDialog(false);
|
||||||
|
}
|
||||||
|
const handleDelete = () => {
|
||||||
|
if(selectedReason.value != '-'){
|
||||||
|
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' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setError('Please select a reason')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getContent = () => (
|
||||||
|
<Stack spacing={1} marginTop={2}>
|
||||||
|
<Typography variant="subtitle2">Are you sure to delete this 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
|
// Load Data
|
||||||
// -------------------
|
// -------------------
|
||||||
const loadDataTableData = async () => {
|
const loadDataTableData = async () => {
|
||||||
@@ -81,33 +167,49 @@ export default function DetailMonitoringList() {
|
|||||||
detailMonitoringList?.map((row, index) => {
|
detailMonitoringList?.map((row, index) => {
|
||||||
return (
|
return (
|
||||||
<Grid key={index} item xs={12}>
|
<Grid key={index} item xs={12}>
|
||||||
<Card sx={{ border: '1px solid rgba(0,0,0,0.125)', px: '32px', py: '24px'}}>
|
<Card sx={{ border: '1px solid rgba(0,0,0,0.125)', px: '30px', py: '24px'}}>
|
||||||
{/* card header */}
|
{/* card header */}
|
||||||
<Box sx={{ pb: '20px', mb: '20px', borderBottom: '1px solid rgba(0,0,0,0.125)' }}>
|
<Box
|
||||||
<Label
|
sx={{
|
||||||
variant="ghost"
|
pb: '20px',
|
||||||
color="default"
|
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) : '-'}
|
{row.submission_date ? fDate(row.submission_date) : '-'}
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
{row.discharge_date.discharge_date ?
|
{row.discharge_date ? (
|
||||||
(<Label
|
<Label
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="success"
|
color="success"
|
||||||
sx={{marginLeft: '85%'}}
|
sx={{ position: 'absolute', top: 0, right: '120px' }} // Atur posisi label "Close Monitoring"
|
||||||
>
|
>
|
||||||
Close Monitoring
|
Close Monitoring
|
||||||
</Label>) : (<Label
|
</Label>
|
||||||
variant="ghost"
|
) : (
|
||||||
color="warning"
|
<Label
|
||||||
sx={{marginLeft: '77%'}}
|
variant="ghost"
|
||||||
>
|
color="warning"
|
||||||
|
sx={{ position: 'absolute', top: 0, right: '120px' }} // Atur posisi label "On Monitoring"
|
||||||
|
>
|
||||||
On Monitoring
|
On Monitoring
|
||||||
</Label>)}
|
</Label>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Box sx={{ marginLeft: 'auto' }}> {/* Menempatkan TableMoreMenu di sebelah kanan */}
|
||||||
|
<TableMoreMenu actions={
|
||||||
|
<MenuItem onClick={() => {setOpenDialog(true); setId(row.id)}}>
|
||||||
|
<Delete color='error' />
|
||||||
|
Delete
|
||||||
|
</MenuItem>
|
||||||
|
} />
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* card body */}
|
{/* card body */}
|
||||||
<Grid container gap={4}>
|
<Grid container gap={4}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
@@ -387,6 +489,15 @@ export default function DetailMonitoringList() {
|
|||||||
}
|
}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
{/* Dialog Delete */}
|
||||||
|
<MuiDialog
|
||||||
|
title={{name: "Delete Daily Monitoring"}}
|
||||||
|
openDialog={openDialog}
|
||||||
|
setOpenDialog={setOpenDialog}
|
||||||
|
content={getContent()}
|
||||||
|
maxWidth="xs"
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export type ClaimListType = {
|
|||||||
* Detail Monitoring List
|
* Detail Monitoring List
|
||||||
*/
|
*/
|
||||||
export type DetailMonitoringListType = {
|
export type DetailMonitoringListType = {
|
||||||
id : string|null,
|
id : number|null,
|
||||||
claim_id : string|null,
|
claim_id : string|null,
|
||||||
claim_code : string,
|
claim_code : string,
|
||||||
subject : string,
|
subject : string,
|
||||||
@@ -61,6 +61,7 @@ export type DetailMonitoringListType = {
|
|||||||
analysis : string,
|
analysis : string,
|
||||||
complaints : string,
|
complaints : string,
|
||||||
submission_date : string,
|
submission_date : string,
|
||||||
|
discharge_date : string,
|
||||||
lab_date : string,
|
lab_date : string,
|
||||||
provider : string,
|
provider : string,
|
||||||
examination : string,
|
examination : string,
|
||||||
|
|||||||
Reference in New Issue
Block a user