Merge branch 'staging'

This commit is contained in:
2023-05-08 08:59:43 +07:00
5 changed files with 372 additions and 258 deletions

View File

@@ -0,0 +1,90 @@
<?php
namespace Database\Seeders;
use App\Models\OLDLMS\Healthcare;
use App\Models\OLDLMS\JadwalDokter;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TarifDokterRsAwalBros extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
$mapHealthcare = [
'A' => 'PekanBaru',
'B' => 'Batam',
'G' => 'UjungBatu',
'I' => 'Panam',
'K' => 'AhmadYani',
'L' => 'ChevronDuri',
];
$file = fopen(public_path("files/Tarif Konsultasi AwalBros 2023.csv"), "r");
$data = [];
while ($row = fgetcsv($file)) {
for ($i = 0; $i < count($row); $i++) {
$data[$i][] = $row[$i];
}
}
fclose($file);
// foreach ($healthcare_primaya as $healthcare) {
$jadwalDokter = JadwalDokter::get();
foreach ($jadwalDokter as $jadwal) {
$id_healthcare_jadwal = $jadwal->nIDHealthCare;
$healthcare = Healthcare::where('nID', $id_healthcare_jadwal)->first() ?? null;
if ($healthcare == null) {
continue;
}
$mapValue = $mapHealthcare[$healthcare->sKodeRS] ?? null;
if ($mapValue == null) {
continue;
}
foreach ($data as $value) {
if ($value[0] == "") {
continue;
}
$codeValue = $value[0];
$codeValue = $codeValue;
if ($codeValue == $mapValue) {
if ($jadwal->nIDSpesialis == 1) {
//umum
$jadwal->nBiaya =(int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[2]);
$jadwal->nBiayaTC = (int)str_replace(",", "", $value[2]);
$jadwal->nBiayaATC = (int)str_replace(",", "", $value[5]);
$jadwal->save();
} else if ($jadwal->nIDSpesialis !== 1 && $jadwal->sIsSubSpesialis == 1) {
//sub spesialis
$jadwal->nBiaya = (int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[4]);
$jadwal->nBiayaTC = (int)str_replace(",", "", $value[4]);
$jadwal->nBiayaATC = (int)str_replace(",", "", $value[7]);
$jadwal->save();
} else if ($jadwal->nIDSpesialis !== 1) {
//spesialis
$jadwal->nBiaya = (int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[3]);
$jadwal->nBiayaTC = (int)str_replace(",", "", $value[3]);
$jadwal->nBiayaATC = (int)str_replace(",", "", $value[6]);
$jadwal->save();
}
} else {
continue;
}
}
}
}
}

View File

@@ -2,6 +2,6 @@ GENERATE_SOURCEMAP=false
PORT=8083 PORT=8083
REACT_APP_HOST_API_URL="http://lms.test" REACT_APP_HOST_API_URL="http://localhost:8001"
VITE_API_URL="http://lms.test/api/client" VITE_API_URL="http://localhost:8001/api/client"

View File

@@ -15,128 +15,170 @@ import {
} from '@mui/material'; } from '@mui/material';
import { visuallyHidden } from '@mui/utils'; import { visuallyHidden } from '@mui/utils';
/* ---------------------------------- axios --------------------------------- */ /* ---------------------------------- axios --------------------------------- */
import axios from 'axios'; // import axios from 'axios';
import axios from '../../utils/axios';
/* ---------------------------------- react --------------------------------- */ /* ---------------------------------- react --------------------------------- */
import { useEffect, useState } from 'react'; import { useContext, useEffect, useState } from 'react';
/* -------------------------------- component ------------------------------- */ /* -------------------------------- component ------------------------------- */
import Iconify from '../../components/Iconify'; import Iconify from '../../components/Iconify';
import BaseTablePagination from '../../components/BaseTablePagination'; import BaseTablePagination from '../../components/BaseTablePagination';
import TableComponent from '../../components/Table';
/* ---------------------------------- hooks --------------------------------- */ /* ---------------------------------- hooks --------------------------------- */
import useMap from '../../hooks/useMap'; import useMap from '../../hooks/useMap';
/* ---------------------------------- theme --------------------------------- */ /* ---------------------------------- theme --------------------------------- */
import palette from '../../theme/palette'; import palette from '../../theme/palette';
import { UserCurrentCorporateContext } from '../../contexts/UserCurrentCorporate';
import { HeadCell, Order, PaginationTableProps } from '../../@types/table';
import { useSearchParams } from 'react-router-dom';
/* ---------------------------------- types --------------------------------- */ /* ---------------------------------- types --------------------------------- */
type PaginationTableProps = { // type PaginationTableProps = {
current_page: number; // current_page: number;
from: number; // from: number;
last_page: number; // last_page: number;
links: []; // links: [];
path: string; // path: string;
per_page: number; // per_page: number;
to: number; // to: number;
total: number; // total: number;
}; // };
type DataTableProps = { // type DataTableProps = {
name: string; // fullName: string;
member_id: string; // memberId: string;
service: string; // service: string;
start_date: string; // start_date: string;
end_date: string; // end_date: string;
status: string; // status: boolean | number;
}; // };
/* -------------------------------------------------------------------------- */ // /* -------------------------------------------------------------------------- */
/* -------------------------- enchanced table head -------------------------- */ // /* -------------------------- enchanced table head -------------------------- */
type Order = 'asc' | 'desc'; // type Order = 'asc' | 'desc';
interface HeadCell { // interface HeadCell {
id: string; // id: string;
label: string; // label: string;
} // }
const headCells: readonly HeadCell[] = [ // const headCells: readonly HeadCell[] = [
{ // {
id: 'name', // id: 'name',
label: 'Name', // label: 'Name',
}, // },
{ // {
id: 'member_id', // id: 'member_id',
label: 'Member ID', // label: 'Member ID',
}, // },
{ // {
id: 'service', // id: 'service',
label: 'Service', // label: 'Service',
}, // },
{ // {
id: 'start_date', // id: 'start_date',
label: 'Start Date', // label: 'Start Date',
}, // },
{ // {
id: 'end_date', // id: 'end_date',
label: 'End Date', // label: 'End Date',
}, // },
{ // {
id: 'status', // id: 'status',
label: 'Status', // label: 'Status',
}, // },
]; // ];
interface EnhancedTableProps { // interface EnhancedTableProps {
onRequestSort: (event: React.MouseEvent<unknown>, property: string) => void; // onRequestSort: (event: React.MouseEvent<unknown>, property: string) => void;
order: Order; // order: Order;
orderBy: string; // orderBy: string;
} // }
function EnhancedTableHead(props: EnhancedTableProps) { // function EnhancedTableHead(props: EnhancedTableProps) {
const { order, orderBy, onRequestSort } = props; // const { order, orderBy, onRequestSort } = props;
const createSortHandler = (property: string) => (event: React.MouseEvent<unknown>) => { // const createSortHandler = (property: string) => (event: React.MouseEvent<unknown>) => {
onRequestSort(event, property); // onRequestSort(event, property);
}; // };
return ( // return (
<TableHead> // <TableHead>
<TableRow> // <TableRow>
<TableCell align="center">No</TableCell> // <TableCell align="center">No</TableCell>
{headCells.map((headCell) => ( // {headCells.map((headCell) => (
<TableCell // <TableCell
key={headCell.id} // key={headCell.id}
sortDirection={orderBy === headCell.id ? order : false} // sortDirection={orderBy === headCell.id ? order : false}
align="center" // align="center"
> // >
<TableSortLabel // <TableSortLabel
active={orderBy === headCell.id} // active={orderBy === headCell.id}
direction={orderBy === headCell.id ? order : 'asc'} // direction={orderBy === headCell.id ? order : 'asc'}
onClick={createSortHandler(headCell.id)} // onClick={createSortHandler(headCell.id)}
> // >
{headCell.label} // {headCell.label}
{orderBy === headCell.id ? ( // {orderBy === headCell.id ? (
<Box component="span" sx={visuallyHidden}> // <Box component="span" sx={visuallyHidden}>
{order === 'desc' ? 'sorted descending' : 'sorted ascending'} // {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
</Box> // </Box>
) : null} // ) : null}
</TableSortLabel> // </TableSortLabel>
</TableCell> // </TableCell>
))} // ))}
</TableRow> // </TableRow>
</TableHead> // </TableHead>
); // );
} // }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
export default function List() { export default function List() {
const [order, setOrder] = useState<Order>('asc'); const { corporateValue } = useContext(UserCurrentCorporateContext);
const [orderBy, setOrderBy] = useState('name');
const [customSearchParams, setCustomSearchParams] = useMap<string, any>(); const [data, setData] = useState([]);
/* -------------------------------------------------------------------------- */
/* setting up for the table */
/* -------------------------------------------------------------------------- */
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [dataTable, setDataTable] = useState([]);
const loadings = {
isLoading: isLoading,
setIsLoading: setIsLoading,
};
/* ------------------------------ handle params ----------------------------- */
const [searchParams, setSearchParams] = useSearchParams();
const [appliedParams, setAppliedParams] = useState({});
const params = {
searchParams: searchParams,
setSearchParams: setSearchParams,
appliedParams: appliedParams,
setAppliedParams: setAppliedParams,
};
/* -------------------------------------------------------------------------- */
/* ------------------------------ handle order ------------------------------ */
const [order, setOrder] = useState<Order>('asc');
const [orderBy, setOrderBy] = useState('fullName');
const orders = {
order: order,
setOrder: setOrder,
orderBy: orderBy,
setOrderBy: setOrderBy,
};
/* -------------------------------------------------------------------------- */
/* ---------------------------- handle pagination --------------------------- */
const [page, setPage] = useState(0); const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10); const [rowsPerPage, setRowsPerPage] = useState(10);
const [paginationTable, setPaginationTable] = useState<PaginationTableProps>({ const [paginationTable, setPaginationTable] = useState<PaginationTableProps>({
current_page: 0, current_page: 0,
from: 0, from: 0,
@@ -148,182 +190,156 @@ export default function List() {
total: 0, total: 0,
}); });
/* ------------------------------- handle sort ------------------------------ */ const paginations = {
const handleRequestSort = async (event: React.MouseEvent<unknown>, property: string) => { page: page,
const isAsc = orderBy === property && order === 'asc'; setPage: setPage,
setOrder(isAsc ? 'desc' : 'asc'); rowsPerPage: rowsPerPage,
setOrderBy(property); setRowsPerPage: setRowsPerPage,
const params = Object.fromEntries([ paginationTable: paginationTable,
...customSearchParams.entries(), setPaginationTable: setPaginationTable,
['order', isAsc ? 'desc' : 'asc'],
['orderBy', property],
]);
setIsLoading(true);
await new Promise((resolve) => setTimeout(resolve, 500));
loadDataTable(params);
setIsLoading(false);
}; };
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* ------------------------------ Search field ------------------------------ */ /* ------------------------------ handle search ----------------------------- */
const [searchText, setSearchText] = useState(''); const [searchText, setSearchText] = useState('');
const handleSearch = (event: any) => { const handleSearchSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
setSearchText(event.target.value);
};
const handleSearchSubmit = async (event: any) => {
event.preventDefault(); event.preventDefault();
const params = Object.fromEntries([...customSearchParams.entries(), ['search', searchText]]);
setIsLoading(true); if (searchText === '') {
await new Promise((resolve) => setTimeout(resolve, 500)); searchParams.delete('search');
loadDataTable(params); const params = Object.fromEntries([...searchParams.entries()]);
setIsLoading(false); setAppliedParams(params);
} else {
const params = Object.fromEntries([...searchParams.entries(), ['search', searchText]]);
setAppliedParams(params);
}
}; };
/* -------------------------------------------------------------------------- */
/* --------------------------- Load Data Table API -------------------------- */ const searchs = {
const loadDataTable = async (appliedParams: any | null = null) => { searchText: searchText,
setIsLoading(true); setSearchText: setSearchText,
handleSearchSubmit: handleSearchSubmit,
const params = appliedParams
? appliedParams
: Object.fromEntries([
...customSearchParams.entries(),
['order', order],
['orderBy', orderBy],
]);
const response = await axios.get('http://localhost:8001/api/alarm-center', { params: params });
setDataTable(response.data.data);
setPaginationTable(response.data.meta);
setRowsPerPage(response.data.meta.per_page);
setIsLoading(false);
}; };
/* -------------------------------------------------------------------------- */
/* ------------------------ button change pagination ------------------------ */ /* -------------------------------- headCell -------------------------------- */
const onPageChangeHandle = async (event: unknown, newPage: number) => { const headCells: HeadCell<never>[] = [
const params = Object.fromEntries([...customSearchParams.entries(), ['page', newPage + 1]]); {
setPage(newPage); id: 'fullName',
setIsLoading(true); align: 'left',
await new Promise((resolve) => setTimeout(resolve, 500)); label: 'Name',
loadDataTable(params); isSort: true,
setIsLoading(false); },
setCustomSearchParams.set('page', newPage + 1); {
}; id: 'memberId',
/* -------------------------------------------------------------------------- */ align: 'left',
label: 'Member ID',
/* ----------------------- row page per limit on click ---------------------- */ isSort: true,
const onRowsPerPageChangeHandle = async (event: React.ChangeEvent<HTMLInputElement>) => { },
setPage(0); {
const params = Object.fromEntries([ id: 'start_date',
...customSearchParams.entries(), align: 'center',
['page', 0], label: 'Start Date',
['per_page', parseInt(event.target.value, 10)], isSort: true,
]); },
setRowsPerPage(parseInt(event.target.value, 10)); {
setIsLoading(true); id: 'end_date',
await new Promise((resolve) => setTimeout(resolve, 500)); align: 'center',
loadDataTable(params); label: 'End Date',
setIsLoading(false); isSort: false,
setCustomSearchParams.set('per_page', parseInt(event.target.value, 10)); },
}; {
id: 'status',
align: 'center',
label: 'Status',
isSort: true,
},
];
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
useEffect(() => { useEffect(() => {
loadDataTable(); (async () => {
}, []); setIsLoading(true);
await new Promise((resolve) => setTimeout(resolve, 250));
const parameters =
Object.keys(appliedParams).length !== 0
? appliedParams
: Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]);
const response = await axios.get(`/${corporateValue}/members?type=alarm-center`, {
params: parameters,
});
setData(
response.data.data.map((obj: any) => {
return {
...obj,
status:
obj.status === 1 ? (
<Button
startIcon={<Iconify icon="ic:round-check" />}
sx={{
backgroundColor: palette.light.grey[300],
color: palette.light.grey[800],
paddingX: 1.5,
paddingY: 1,
'&:hover': {
backgroundColor: palette.light.grey[400],
color: palette.light.grey[800],
},
}}
>
done
</Button>
) : (
<Button
startIcon={<Iconify icon="fa6-solid:clock" />}
sx={{
backgroundColor: '#CD7B2E',
color: '#FFFF',
paddingX: 1.5,
paddingY: 1,
'&:hover': {
backgroundColor: '#BF6919',
color: '#FFFF',
},
}}
>
Ongoing
</Button>
),
};
})
);
setPaginationTable(response.data);
setRowsPerPage(response.data.per_page);
if (searchParams.get('page')) {
//@ts-ignore
const currentPage = parseInt(searchParams.get('page')) - 1;
paginationTable.current_page = currentPage;
setPage(currentPage);
}
setIsLoading(false);
})();
}, [appliedParams, searchParams, order, orderBy, setSearchParams, corporateValue]);
return ( return (
<Stack> <Stack>
{/* Search */} <TableComponent
<form onSubmit={handleSearchSubmit} style={{ width: '100%', padding: '20px 24px' }}> headCells={headCells}
<TextField rows={data}
id="search-input" orders={orders}
label="Search" paginations={paginations}
variant="outlined" loadings={loadings}
fullWidth params={params}
onChange={handleSearch} searchs={searchs}
value={searchText} // filters={filters}
/>
</form>
{/* The Main Table */}
<TableContainer component={Paper}>
<Table aria-label="collapsible table">
<EnhancedTableHead order={order} orderBy={orderBy} onRequestSort={handleRequestSort} />
<TableBody>
{isLoading ? (
<TableRow>
<TableCell colSpan={8} align="center">
Loading . . .
</TableCell>
</TableRow>
) : dataTable.length >= 1 ? (
dataTable.map((row: DataTableProps, index) => (
<TableRow key={index}>
<TableCell align="center">{paginationTable.from + index++}</TableCell>
<TableCell align="center">{row.name}</TableCell>
<TableCell align="center">{row.member_id}</TableCell>
<TableCell align="center">{row.service}</TableCell>
<TableCell align="center">{row.start_date}</TableCell>
<TableCell align="center">{row.end_date}</TableCell>
<TableCell align="center">
{row.status.toLowerCase() === 'done' ? (
<Button
startIcon={<Iconify icon="ic:round-check" />}
sx={{
backgroundColor: palette.light.grey[300],
color: palette.light.grey[800],
paddingX: 1.5,
paddingY: 1,
'&:hover': {
backgroundColor: palette.light.grey[400],
color: palette.light.grey[800],
},
}}
>
{row.status}
</Button>
) : (
<Button
startIcon={<Iconify icon="fa6-solid:clock" />}
sx={{
backgroundColor: '#CD7B2E',
color: '#FFFF',
paddingX: 1.5,
paddingY: 1,
'&:hover': {
backgroundColor: '#BF6919',
color: '#FFFF',
},
}}
>
{row.status}
</Button>
)}
</TableCell>
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={8} align="center">
No Data Found
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</TableContainer>
{/* Pagination */}
<BaseTablePagination
count={paginationTable.total}
onPageChange={onPageChangeHandle}
page={page}
rowsPerPage={rowsPerPage}
onRowsPerPageChange={onRowsPerPageChangeHandle}
/> />
</Stack> </Stack>
); );

View File

@@ -61,7 +61,7 @@ const DialogLog = ({ title, openDialog, setOpenDialog, data }: MuiDialogProps) =
const [loadingLog, setLoadingLog] = useState(false); const [loadingLog, setLoadingLog] = useState(false);
useEffect(() => { useEffect(() => {
setBenefitIds(data.member.current_plan?.benefits.map((benefit) => benefit.id)) setBenefitIds(data.member.current_plan?.benefits.filter((benefit) => benefit.pivot.active == 1).map((benefit) => benefit.id))
setCheckedBenefitIds(benefitIds) setCheckedBenefitIds(benefitIds)
console.log('Check All', benefitIds, 'X', data.member.current_plan?.benefits.map((benefit) => benefit.id)) console.log('Check All', benefitIds, 'X', data.member.current_plan?.benefits.map((benefit) => benefit.id))
}, []) }, [])

View File

@@ -0,0 +1,8 @@
,,PekanBaru,UjungBatu,Panam,AhmadYani,BaganBatu,Batam,BotaniaBatam
,Administrasi Rawat Jalan," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "
,Konsultasi Dokter Umum," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 150,000 "," 150,000 "
,Konsultasi Dokter Spesialis," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 300,000 "," 300,000 "
,Konsultasi Dokter Sub Spesialis / Konsultan," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 500,000 "," 500,000 "
,Telekonsultasi Dokter Umum," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 150,000 "," 150,000 "
,Telekonsultasi Dokter Spesialis," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 300,000 "," 300,000 "
,Telekonsultasi Dokter Sub Spesialis," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 500,000 "," 500,000 "
1 PekanBaru UjungBatu Panam AhmadYani BaganBatu Batam BotaniaBatam
2 Administrasi Rawat Jalan 50,000 50,000 50,000 50,000 50,000 50,000 50,000
3 Konsultasi Dokter Umum 75,000 75,000 75,000 75,000 75,000 150,000 150,000
4 Konsultasi Dokter Spesialis 175,000 175,000 175,000 175,000 175,000 300,000 300,000
5 Konsultasi Dokter Sub Spesialis / Konsultan 265,000 265,000 265,000 265,000 265,000 500,000 500,000
6 Telekonsultasi Dokter Umum 75,000 75,000 75,000 75,000 75,000 150,000 150,000
7 Telekonsultasi Dokter Spesialis 175,000 175,000 175,000 175,000 175,000 300,000 300,000
8 Telekonsultasi Dokter Sub Spesialis 265,000 265,000 265,000 265,000 265,000 500,000 500,000