Update Add Input Hospital Portal
This commit is contained in:
@@ -23,6 +23,8 @@ import Page from '../../../components/Page';
|
||||
import Iconify from '@/components/Iconify';
|
||||
import { FormProvider, RHFDatepicker, RHFSelect, RHFTextField } from '@/components/hook-form';
|
||||
import RHFTextFieldMoney from '@/components/hook-form/v2/RHFTextFieldMoney';
|
||||
import { DatePicker, LocalizationProvider, MobileDatePicker } from '@mui/x-date-pickers';
|
||||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
||||
// utils
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { useFieldArray, useForm } from 'react-hook-form';
|
||||
@@ -35,7 +37,7 @@ import { enqueueSnackbar } from 'notistack';
|
||||
import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
|
||||
import { DetailFinalLogType } from './Model/Types';
|
||||
import { fDate, fDateTimesecond } from '@/utils/formatTime';
|
||||
import { Button } from '@mui/material';
|
||||
import { Button, Autocomplete, FormHelperText} from '@mui/material';
|
||||
import DialogConfirmation from '../FinalLog/Components/DialogConfirmation';
|
||||
import Label from '@/components/Label';
|
||||
import { Box } from '@mui/system';
|
||||
@@ -45,6 +47,11 @@ import {BenefitData } from '../FinalLog/Model/Types'
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
import { makeFormData } from '@/utils/jsonToFormData';
|
||||
import TextField from '@mui/material/TextField';
|
||||
import { fPostFormat } from '@/utils/formatTime';
|
||||
|
||||
|
||||
|
||||
|
||||
// Import Card Detail Final LOG
|
||||
import CardDetail from '../Components/CardDetail';
|
||||
@@ -71,11 +78,86 @@ import DialogDeleteFileLog from './Components/DialogDeleteFileLog';
|
||||
import DialogUploadFileFinalLog from './Components/DialogUploadFileFinalLog';
|
||||
import DialogSendWa from './Components/DialogSendWa';
|
||||
import { set } from 'nprogress';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export default function Detail() {
|
||||
//dari hospital portal
|
||||
const [dischargeDate, setDischargeDate] = useState<string>(format(new Date(), "yyyy MMM d HH:mm:ss"));
|
||||
const [serviceOptions, setServiceOptions] = useState([
|
||||
{ value: '-', label: '-' }
|
||||
]);
|
||||
const [specialisOptions, setSpecialisOptions] = useState([
|
||||
{ value: '-', label: '-' }
|
||||
]);
|
||||
useEffect(() => {
|
||||
axios.get('service-member/'+1)
|
||||
.then((response) => {
|
||||
setServiceOptions(response.data);
|
||||
}).catch((error) => {
|
||||
console.error('Error fetching ICD options:', error);
|
||||
});
|
||||
|
||||
axios.get('specialis')
|
||||
.then((response) => {
|
||||
setSpecialisOptions(response.data);
|
||||
}).catch((error) => {
|
||||
console.error('Error fetching ICD options:', error);
|
||||
});
|
||||
|
||||
}, []);
|
||||
const [serviceCode, setServiceCode] = useState<string>("");
|
||||
const [idSpecialities, setIdSpecialities] = useState("");
|
||||
const [inputDppj, setInputDppj] = useState("");
|
||||
function submitRequestFinalLog() {
|
||||
if(dischargeDate == '')
|
||||
{
|
||||
enqueueSnackbar('Tanggal Keluar', { variant: 'warning' });
|
||||
return false;
|
||||
}
|
||||
//cek spesialis
|
||||
if(!idSpecialities)
|
||||
{
|
||||
enqueueSnackbar('Spesialis', { variant: 'warning' });
|
||||
return false;
|
||||
}
|
||||
//cek dpjp
|
||||
if(!inputDppj)
|
||||
{
|
||||
enqueueSnackbar('DPPJ', { variant: 'warning' });
|
||||
return false;
|
||||
}
|
||||
setSubmitLoading(true);
|
||||
const formData = makeFormData({
|
||||
// request_logs_id: member.id,
|
||||
// result_files: fileHasilPenunjangs,
|
||||
// diagnosa_files: fileDiagnosas,
|
||||
// kondisi_files: fileKondisis,
|
||||
discharge_date: fPostFormat(dischargeDate, 'yyyy-MM-dd HH:mm:ss'),
|
||||
service_code: serviceCode,
|
||||
spescialis_id: idSpecialities,
|
||||
dppj: inputDppj,
|
||||
});
|
||||
axios
|
||||
.post('/request-final-log', formData)
|
||||
.then((response) => {
|
||||
enqueueSnackbar(response.data.meta.message ?? 'Berhasil membuat data', { variant: 'success' });
|
||||
// handleSubmitSuccess();
|
||||
// onClose({ someData: 'example data' }, getData);
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
enqueueSnackbar(response.data.meta.message ?? 'Something Went Wrong', { variant: 'error' });
|
||||
})
|
||||
.then(() => {
|
||||
setSubmitLoading(false);
|
||||
});
|
||||
}
|
||||
//end dari hospital portal
|
||||
|
||||
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
|
||||
@@ -106,7 +188,7 @@ export default function Detail() {
|
||||
.post(`/customer-service/request/${id}/approval_files`, formData)
|
||||
.then((response) => {
|
||||
enqueueSnackbar('Berhasil membuat data', { variant: 'success' });
|
||||
|
||||
|
||||
window.location.reload()
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
@@ -231,10 +313,10 @@ export default function Detail() {
|
||||
// Handle Delete File LOG
|
||||
const [pathFile, setPathFile] = useState('')
|
||||
const [dialogDeleteFIleLog, setDialogDeleteFileLog] = useState(false)
|
||||
|
||||
|
||||
// Handle Upload File LOG
|
||||
const [dialogUploadFileLog, setDialogUploadFileLog] = useState(false)
|
||||
|
||||
|
||||
|
||||
const fileDiagnosaInput = useRef<HTMLInputElement>(null);
|
||||
const [fileApprovals, setFileApproval] = useState<any>([]);
|
||||
@@ -425,6 +507,91 @@ export default function Detail() {
|
||||
>
|
||||
</DialogHospitalCare>
|
||||
</Grid> */}
|
||||
<Grid item xs={12}>
|
||||
<Card sx={{p:3}}>
|
||||
<Stack direction="row" spacing={2} sx={{ width: '100%' }}>
|
||||
{/* Kolom Tanggal Discharge */}
|
||||
<Stack spacing={2} sx={{ flex: 1 }}>
|
||||
<Typography variant="subtitle1">Tanggal Keluar </Typography>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DatePicker
|
||||
label="Tanggal Keluar"
|
||||
value={dischargeDate}
|
||||
onChange={(newValue: any) => {
|
||||
setDischargeDate(newValue);
|
||||
}}
|
||||
inputFormat="dd-MM-yyyy HH:mm"
|
||||
renderInput={(params) => <TextField {...params} fullWidth required />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Stack>
|
||||
|
||||
{/* Kolom Service Type */}
|
||||
<Stack spacing={2} sx={{ flex: 1 }}>
|
||||
<Typography variant="subtitle1">Tipe Service </Typography>
|
||||
<Autocomplete
|
||||
id="service_type"
|
||||
options={serviceOptions}
|
||||
getOptionLabel={(option) => option.label || ""}
|
||||
value={serviceOptions.find((opt) => opt.value == serviceCode) || null}
|
||||
onChange={(event, newValue) => {
|
||||
setServiceCode(newValue?.value || "");
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label='Tipe Service' fullWidth />
|
||||
)}
|
||||
/>
|
||||
<FormHelperText style={{ color: "red" }}></FormHelperText>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
{/* Specialist */}
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Stack spacing={2} sx={{ width: '100%' }}>
|
||||
<Typography variant='subtitle1'>Spesialis </Typography>
|
||||
<Autocomplete
|
||||
id='specialities'
|
||||
options={specialisOptions}
|
||||
getOptionLabel={(option) => option.label || ''}
|
||||
value={specialisOptions.find((opt) => opt.value === idSpecialities) || null}
|
||||
onChange={(event, newValue) => {
|
||||
setIdSpecialities(newValue?.value || 0);
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label="Spesialis" fullWidth />
|
||||
)}
|
||||
/>
|
||||
<FormHelperText style={{ color: 'red' }}></FormHelperText>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Stack spacing={2} sx={{ width: '100%' }}>
|
||||
<Typography variant='subtitle1'>DPPJ </Typography>
|
||||
<TextField
|
||||
id='dppj'
|
||||
variant='outlined'
|
||||
value={inputDppj}
|
||||
placeholder="DPPJ"
|
||||
onChange={(event) => {
|
||||
setInputDppj(event.target.value);
|
||||
}}
|
||||
fullWidth
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
sx={{ marginTop: 2, p: 2, backgroundColor: '#19BBBB' }}
|
||||
onClick={() => {
|
||||
submitRequestFinalLog();
|
||||
}}
|
||||
loading={submitLoading}
|
||||
>
|
||||
Simpan
|
||||
</LoadingButton>
|
||||
</Card>
|
||||
</Grid>
|
||||
|
||||
{/* Surat persetujuan Tindakan */}
|
||||
<Grid item xs={12}>
|
||||
@@ -592,7 +759,7 @@ export default function Detail() {
|
||||
|
||||
{/* FILE YANG SUDAH TERUPLOAD */}
|
||||
{requestLog?.files
|
||||
?.filter((document) => document.type === 'approval')
|
||||
?.filter((document) => document.type === 'approval')
|
||||
?.map((documentType, index) => (
|
||||
<Stack
|
||||
key={index}
|
||||
@@ -640,7 +807,7 @@ export default function Detail() {
|
||||
openDialog={dialogUploadFileLog}
|
||||
/>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
{/* Benefit */}
|
||||
@@ -993,7 +1160,7 @@ export default function Detail() {
|
||||
|
||||
</Stack>
|
||||
{requestLog?.files
|
||||
?.filter((document) => document.type !== 'approval')
|
||||
?.filter((document) => document.type !== 'approval')
|
||||
?.map((documentType, index) => (
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{marginBottom: 2}} key={index}>
|
||||
<Stack direction="column" spacing={2} >
|
||||
@@ -1043,7 +1210,7 @@ export default function Detail() {
|
||||
variant="outlined"
|
||||
sx={{ color: '#FF4842', borderColor: '#FF4842' }}
|
||||
onClick={() => {
|
||||
|
||||
|
||||
}}
|
||||
>
|
||||
Decline
|
||||
|
||||
Reference in New Issue
Block a user