diff --git a/Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php b/Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php index 9fca0540..db11aab5 100644 --- a/Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php +++ b/Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php @@ -400,7 +400,8 @@ class DiagnosisExclusionController extends Controller } Exclusion::where('id', $request->id)->update([ - 'active' => $request->active + 'active' => $request->active == 1 ? 0 : 1, + 'reason' => $request->reason ]); return response()->json([ diff --git a/Modules/Internal/Services/MemberEnrollmentService.php b/Modules/Internal/Services/MemberEnrollmentService.php index 257842ba..2a57f484 100644 --- a/Modules/Internal/Services/MemberEnrollmentService.php +++ b/Modules/Internal/Services/MemberEnrollmentService.php @@ -326,6 +326,7 @@ class MemberEnrollmentService public function __construct(Member $member) { + app()->setLocale('en'); $this->member = $member; } diff --git a/app/Models/Exclusion.php b/app/Models/Exclusion.php index 93090f9b..7cfd5f74 100644 --- a/app/Models/Exclusion.php +++ b/app/Models/Exclusion.php @@ -19,6 +19,7 @@ class Exclusion extends Model 'exclusionable_id', 'exclusionable_type', 'active', + 'reason' ]; protected $hidden = [ diff --git a/database/migrations/2023_10_21_115939_add_column_reason_to_exclusion.php b/database/migrations/2023_10_21_115939_add_column_reason_to_exclusion.php new file mode 100644 index 00000000..eb08cb27 --- /dev/null +++ b/database/migrations/2023_10_21_115939_add_column_reason_to_exclusion.php @@ -0,0 +1,32 @@ +string('reason')->after('active'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('exclusions', function (Blueprint $table) { + $table->dropColumn('reason'); + }); + } +}; diff --git a/frontend/dashboard/src/@types/diagnosis.ts b/frontend/dashboard/src/@types/diagnosis.ts index 2d2d65db..8bd53e58 100644 --- a/frontend/dashboard/src/@types/diagnosis.ts +++ b/frontend/dashboard/src/@types/diagnosis.ts @@ -5,9 +5,12 @@ export type Icd = { version?: string; code: string; name: string; + service_code: string; + active: number; description?: any; childs?: Icd[]; status: string; + rules:any }; diff --git a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx index 7b9e77c3..806dff2c 100644 --- a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx @@ -75,6 +75,7 @@ import TableMoreMenu from '@/components/table/TableMoreMenu'; import { Edit } from '@mui/icons-material'; import { fData, fNumber } from '@/utils/formatNumber'; import DialogUpdateStatus from '@/components/DialogUpdateStatus'; + import { ro } from 'date-fns/locale'; export default function PlanList() { diff --git a/frontend/dashboard/src/pages/Corporates/CorporateTabNavigations.tsx b/frontend/dashboard/src/pages/Corporates/CorporateTabNavigations.tsx index 6e3835c1..e2c98329 100644 --- a/frontend/dashboard/src/pages/Corporates/CorporateTabNavigations.tsx +++ b/frontend/dashboard/src/pages/Corporates/CorporateTabNavigations.tsx @@ -64,10 +64,10 @@ export default function CorporateTabNavigations({ position }: Props) { path: 'formularium', label: 'Formularium', }, - { - path: 'claim-history', - label: 'Claim History', - }, + // { + // path: 'claim-history', + // label: 'Claim History', + // }, ]; useEffect(() => { let currentIndex = mainTabItems.findIndex((item) => item.path === position); diff --git a/frontend/dashboard/src/pages/Corporates/DiagnosisExclusion/List.tsx b/frontend/dashboard/src/pages/Corporates/DiagnosisExclusion/List.tsx index 99332313..71540108 100644 --- a/frontend/dashboard/src/pages/Corporates/DiagnosisExclusion/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/DiagnosisExclusion/List.tsx @@ -1,4 +1,5 @@ // @mui +import * as Yup from 'yup'; import { Autocomplete, Box, @@ -46,6 +47,9 @@ import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'reac import useSettings from '../../../hooks/useSettings'; import { Link, useParams, useSearchParams, useNavigate } from 'react-router-dom'; // components +import { yupResolver } from '@hookform/resolvers/yup'; +import { useForm } from 'react-hook-form'; + import axios from '../../../utils/axios'; import { LaravelPaginatedData } from '../../../@types/paginated-data'; import { Icd } from '../../../@types/diagnosis'; @@ -59,6 +63,8 @@ import TableMoreMenu from '@/components/table/TableMoreMenu'; import { EditOutlined, FindInPageOutlined } from '@mui/icons-material'; import Label from '@/components/Label'; import { display } from '@mui/system'; +import DialogUpdateStatus from '@/components/DialogUpdateStatus' +import { FormProvider, RHFSelect } from '@/components/hook-form'; export default function List(props: any) { const { themeStretch } = useSettings(); @@ -272,6 +278,14 @@ export default function List(props: any) { ...icd, }; } + type DataContent = { + service: string; + id: number; + status: number; + code: string, + name: string, + rules: string, + }; const plans = props?.data.map((plan: any) => { return { value: plan.code, @@ -305,6 +319,16 @@ export default function List(props: any) { const { row, index, data } = props; } + const [isDialogOpen, setDialogOpen] = useState(false) + let titles = { + name: 'Update Status', + icon: '-' + } + const [dataValue, setDataValue] = useState(''); + const [dataDescription, setDescriptionValue] = useState(''); + const [url, setUrl] = useState(''); + + function Row(props: { row: ReturnType; data: any; @@ -337,9 +361,6 @@ export default function List(props: any) { const [openEdit, setOpenEdit] = React.useState(false); - console.log('open', open); - console.log('openEdit', openEdit); - // const [plans, setPlans] = useState([]); const plans = data; @@ -469,44 +490,53 @@ export default function List(props: any) { console.log('exclusions', exclusions); - const handleActivate = (row: any) => { - axios - .put(`/corporates/diagnosis-exclusions/update_activation`, { - id: row.id, - active: row.active == 1 ? 0 : 1, - }) - .then((res) => { - setDataTableData({ - ...dataTableData, - data: dataTableData.data.map((model) => { - let updatedModel = model; + // const handleActivate = (row: any) => { - if (model.id == row.id) { - updatedModel.active = row.active == 1 ? 0 : 1; - } + // axios + // .put(`/corporates/diagnosis-exclusions/update_activation`, { + // id: row.id, + // active: row.active == 1 ? 0 : 1, + // }) + // .then((res) => { + // setDataTableData({ + // ...dataTableData, + // data: dataTableData.data.map((model) => { + // let updatedModel = model; - return updatedModel; - }), - }); - }) - .catch((error) => { - if (error.response.status == 400) { - let data = error.response.data.messages; + // if (model.id == row.id) { + // updatedModel.active = row.active == 1 ? 0 : 1; + // } - for (const key in data) { - enqueueSnackbar( - data[key][0], - { variant: 'error' } - ); - } - } - else { - enqueueSnackbar( - error.response.data.message ?? error.message ?? 'Failed Processing Request', - { variant: 'error' } - ); - } - }); + // return updatedModel; + // }), + // }); + // }) + // .catch((error) => { + // if (error.response.status == 400) { + // let data = error.response.data.messages; + + // for (const key in data) { + // enqueueSnackbar( + // data[key][0], + // { variant: 'error' } + // ); + // } + // } + // else { + // enqueueSnackbar( + // error.response.data.message ?? error.message ?? 'Failed Processing Request', + // { variant: 'error' } + // ); + // } + // }); + // }; + + const handleActivate = (isOpen: boolean, dataValue: DataContent) => { + console.log(dataValue) + setDialogOpen(isOpen) + setDataValue(dataValue) + setDescriptionValue('Are you sure to inactive this service ?') + setUrl(url) }; return ( @@ -557,7 +587,15 @@ export default function List(props: any) { Edit - handleActivate(row)}> + handleActivate(true, { + code: row.code, + name: row.name, + rules: Object.keys(row.rules).length ? 'With Rules' : 'All', + id:row.id, + status: row.active, + service: row.service_code + }) + } > Update Status @@ -585,16 +623,30 @@ export default function List(props: any) { MSC : - - {row?.rules?.msc && row?.rules?.msc[0] ? ( - row?.rules?.msc[0].split(',').map((text,i) => { - return ( - - - - ) - }) - ) : '-'} + + {row?.rules?.msc && row?.rules?.msc[0] ? ( + row?.rules?.msc[0].split(',').map((text, i) => { + let labelMSC: string = text; + switch (labelMSC) { + case 'm': + labelMSC = 'Member'; + break; + case 'c': + labelMSC = 'Child'; + break; + case 's': + labelMSC = 'Spouse'; + break; + default: + labelMSC = 'Member'; + } + return ( + + + + ); + }) + ) : '-'} @@ -603,9 +655,14 @@ export default function List(props: any) { {row?.rules?.gender && row?.rules?.gender[0] ? ( - - - + row?.rules?.gender[0].split(',').map((text,i) => { + const capitalizedText = text.charAt(0).toUpperCase() + text.slice(1); + return ( + + + + ) + }) ) : '-'} @@ -742,6 +799,18 @@ export default function List(props: any) { fontWeight: 'bold', }; + const onSubmit = async (row : any) => { + try { + handleUpdate(dataValue.status, dataValue.id, row.reason) + } catch (error: any) { + console.log('data gagal'); + } + + const ascent = document?.querySelector('ascent'); + if (ascent != null) { + ascent.innerHTML = ''; + } + }; const applyFilter = async (searchFilter: any) => { await loadDataTableData({ search: searchFilter }); setSearchParams({ search: searchFilter }); @@ -759,6 +828,136 @@ export default function List(props: any) { const navigate = useNavigate() + const NewCorporateSchema = Yup.object().shape({ + reason: Yup.string().required('Reason Edit is required'), + }); + + const methods = useForm({ + resolver: yupResolver(NewCorporateSchema), + }); + + + const { + reset, + handleSubmit, + formState: { isSubmitting }, + } = methods; + + const handleUpdate = (active: number, id: number, reason:string) => { + console.log(active) + axios + .put(`/corporates/diagnosis-exclusions/update_activation`, { + id: id, + active: active, + reason: reason + }) + .then((res) => { + window.location.reload(); + }); + } + + const getContent = () => ( + <> + + Are you sure to {dataValue?.status == 1 ? 'inactive' : 'active'} this benefit ? + + + + + Service + + + {dataValue?.service} + + + Code + + + {dataValue?.code} + + + Name + + + {dataValue?.name} + + + Rules + + + {dataValue?.rules} + + + + + + Reason for update* + + + + + + + + + + + + + + {dataValue?.status == 1? + + Inactive + + : + + Active + + + + } + + + + + + ); + return ( @@ -831,6 +1030,16 @@ export default function List(props: any) { + + ); }