update eprescription

This commit is contained in:
2024-05-06 10:46:26 +07:00
parent 7516e475d6
commit 15df89e703
6 changed files with 88 additions and 222 deletions

View File

@@ -71,7 +71,7 @@ export type Medicine = {
}
export type Appointment = {
id:number;
id:number|undefined;
name:string;
address:string;
birth_date:string;

View File

@@ -44,6 +44,7 @@ export default function Create() {
<View
// isSubmitting={isSubmitting}
isEdit={isEdit}
id={id}
currentAppointment={currentAppointment}
/>
</Container>

View File

@@ -84,6 +84,7 @@ interface FormValuesProps extends Partial<Appointment> {
type Props = {
isEdit: boolean;
id: number;
currentAppointment?: Appointment;
};
@@ -97,7 +98,7 @@ const Text = styled(Typography)(({ theme }) => ({
paddingBottom: theme.spacing(3),
}));
export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
export default function AppointmentForm({ isEdit, id, currentAppointment }: Props) {
const navigate = useNavigate();
// const [ errors, setErrors ] = useState<{ [key: string]: string }>({});
@@ -139,7 +140,8 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
[currentAppointment]
);
console.log()
const methods = useForm<FormValuesProps>({
// resolver: yupResolver(NewCorporateSchema),
defaultValues,
@@ -159,7 +161,7 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
});
setSelectedIcdOptions(selectedCodes);
setValue('diagnosis', selectedCodes);
}, [icdOptions, defaultValues]);
}, [defaultValues.diagnosis]);
@@ -327,6 +329,20 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
ascent.innerHTML = '';
}
};
const handleDownloadEPrescription = (id: number) => {
axios
.get(`prescription-download/${id}`, {
responseType: 'blob',
})
.then((response) => {
window.open(URL.createObjectURL(response.data));
})
.catch((response) => {
enqueueSnackbar(response.message, { variant: 'error' });
});
}
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}>
@@ -510,7 +526,7 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
/>
</Grid>
<Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{marginBottom: 4}}>
{/* <Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{marginBottom: 4}}>
<Span style={{ fontWeight: 'bold' }}>Rumah Sakit</Span>
<Autocomplete
options={hospitalOptions}
@@ -531,7 +547,7 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
)}
/>
</Grid>
</Grid> */}
<Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
@@ -634,6 +650,14 @@ export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
))}
</Grid>
<Grid item xs={12} md={12} sx={{ display: 'flex', justifyContent: 'flex-end' }}>
<Button
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)', marginRight: '10px' }}
onClick={handleDownloadEPrescription(id)}
variant="contained"
size="large"
>
Download
</Button>
<LoadingButton
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)' }}
type="submit"