From c94285693326bb2c09a361f8bad200ce5f38397f Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 4 Jul 2023 09:35:33 +0700 Subject: [PATCH] Prescription --- .../Api/PrescriptionController.php | 96 ++++ Modules/Internal/Routes/api.php | 3 + app/Models/OLDLMS/Prescription.php | 38 ++ app/Models/Plan.php | 2 +- .../layouts/dashboard/navbar/NavConfig.tsx | 1 + .../src/pages/Report/Prescription/Index.tsx | 37 ++ .../src/pages/Report/Prescription/List.tsx | 440 ++++++++++++++++++ frontend/dashboard/src/routes/index.tsx | 5 + 8 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 Modules/Internal/Http/Controllers/Api/PrescriptionController.php create mode 100644 app/Models/OLDLMS/Prescription.php create mode 100644 frontend/dashboard/src/pages/Report/Prescription/Index.tsx create mode 100644 frontend/dashboard/src/pages/Report/Prescription/List.tsx diff --git a/Modules/Internal/Http/Controllers/Api/PrescriptionController.php b/Modules/Internal/Http/Controllers/Api/PrescriptionController.php new file mode 100644 index 00000000..a7127855 --- /dev/null +++ b/Modules/Internal/Http/Controllers/Api/PrescriptionController.php @@ -0,0 +1,96 @@ +where('nID', $id); + } + + $prescriptions = $query->select('nID','nIDLiveChat', 'nIDLiveChatSummary', 'nIDDokter', 'sDokterName', 'dTanggalResep', 'sSource', 'nIDUser', 'sKodeResep', 'sDiagnose', 'sStatus') + ->get(); + + // $prescriptions->toArray(); + // dd($prescriptions); + + return response()->json($prescriptions); + // return response()->json(Helper::paginateResources(LivechatResource::collection($livechat))); + } + + + + + /** + * Show the form for creating a new resource. + * @return Renderable + */ + public function create() + { + return view('internal::create'); + } + + /** + * Store a newly created resource in storage. + * @param Request $request + * @return Renderable + */ + public function store(Request $request) + { + } + + /** + * Show the specified resource. + * @param int $id + * @return Renderable + */ + public function show($id) + { + + } + + /** + * Show the form for editing the specified resource. + * @param int $id + * @return Renderable + */ + public function edit($id) + { + return view('internal::edit'); + } + + /** + * Update the specified resource in storage. + * @param Request $request + * @param int $id + * @return Renderable + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * @param int $id + * @return Renderable + */ + public function destroy($id) + { + // + } +} diff --git a/Modules/Internal/Routes/api.php b/Modules/Internal/Routes/api.php index f2839eec..d13e0f47 100755 --- a/Modules/Internal/Routes/api.php +++ b/Modules/Internal/Routes/api.php @@ -28,6 +28,7 @@ use Modules\Internal\Http\Controllers\Api\OptionController; use Modules\Internal\Http\Controllers\Api\OrganizationController; use Modules\Internal\Http\Controllers\Api\PlanController; use Modules\Internal\Http\Controllers\Api\ProvinceController; +use Modules\Internal\Http\Controllers\Api\PrescriptionController; use Modules\Internal\Http\Controllers\Api\SpecialityController; use Modules\Internal\Http\Controllers\Api\VillageController; use Modules\Internal\Http\Controllers\Api\AuditTrailController; @@ -151,6 +152,8 @@ Route::prefix('internal')->group(function () { Route::resource('organizations', OrganizationController::class); Route::resource('appointments', AppointmentController::class); Route::resource('live-chat', LivechatController::class); + Route::get('prescription', [PrescriptionController::class, 'index']); + Route::get('prescription/{id}', [PrescriptionController::class, 'index']); Route::resource('doctors', DoctorController::class); diff --git a/app/Models/OLDLMS/Prescription.php b/app/Models/OLDLMS/Prescription.php new file mode 100644 index 00000000..8f75f528 --- /dev/null +++ b/app/Models/OLDLMS/Prescription.php @@ -0,0 +1,38 @@ + 'Menunggu Konfirmasi', + // 1 => 'Diterima', + // 2 => 'Ditolak', + // 3 => 'Selesai', + // 4 => 'Expired', + // ]; + + const CREATED_AT = 'dCreateOn'; + const UPDATED_AT = 'dUpdateOn'; + const DELETED_AT = 'dDeleteOn'; + + protected $connection = 'oldlms'; + + protected $table = 'tx_prescriptions'; + + // protected $appends = [ + // 'status_name', + // ]; + + protected $casts = [ + 'dTanggalResep' => 'datetime', + ]; + +} diff --git a/app/Models/Plan.php b/app/Models/Plan.php index 8950724a..9ffc4759 100755 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -186,7 +186,7 @@ class Plan extends Model { $this->attributes['start'] = empty($value) ? null : $value; } - + public function setEndAttribute($value) { $this->attributes['end'] = empty($value) ? null : $value; diff --git a/frontend/dashboard/src/layouts/dashboard/navbar/NavConfig.tsx b/frontend/dashboard/src/layouts/dashboard/navbar/NavConfig.tsx index 8be86e5c..afcda80a 100755 --- a/frontend/dashboard/src/layouts/dashboard/navbar/NavConfig.tsx +++ b/frontend/dashboard/src/layouts/dashboard/navbar/NavConfig.tsx @@ -82,6 +82,7 @@ const navConfig = [ { title: 'Appointment', path: '/report/appointments' }, { title: 'Live Chat', path: '/report/live-chat' }, { title: 'Linksehat Payment', path: '/report/linksehat-payments' }, + { title: 'Prescription', path: '/report/prescription' }, ], }, { diff --git a/frontend/dashboard/src/pages/Report/Prescription/Index.tsx b/frontend/dashboard/src/pages/Report/Prescription/Index.tsx new file mode 100644 index 00000000..ff5c923e --- /dev/null +++ b/frontend/dashboard/src/pages/Report/Prescription/Index.tsx @@ -0,0 +1,37 @@ +import { Card, Grid, Container } from '@mui/material'; +import { useParams } from 'react-router-dom'; +import HeaderBreadcrumbs from '@/components/HeaderBreadcrumbs'; +import Page from '@/components/Page'; +import useSettings from '@/hooks/useSettings'; +import List from '../Prescription/List'; + +export default function Prescription(){ + const { themeStretch } = useSettings(); + + const { id } = useParams(); + + const pageTitle = 'Prescription'; + + return( + + + + + + + + + ); +} \ No newline at end of file diff --git a/frontend/dashboard/src/pages/Report/Prescription/List.tsx b/frontend/dashboard/src/pages/Report/Prescription/List.tsx new file mode 100644 index 00000000..8ed4712c --- /dev/null +++ b/frontend/dashboard/src/pages/Report/Prescription/List.tsx @@ -0,0 +1,440 @@ +import { + Box, + Button, + Card, + Collapse, + Paper, + Select, + SelectChangeEvent, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + TextField, + Typography, + Stack, + ButtonGroup, + Grid, + Chip, + Dialog, + DialogContent, + DialogContentText, + DialogActions, + FormControl, + Autocomplete, + InputAdornment, + IconButton, + } from '@mui/material'; + + import { + Link, + NavLink as RouterLink, + useSearchParams, + useNavigate, + useParams, + } from 'react-router-dom'; + // hooks + import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react'; + import useSettings from '../../../hooks/useSettings'; + // components + import axios from '../../../utils/axios'; + import { LaravelPaginatedData } from '../../../@types/paginated-data'; + import { Icd } from '../../../@types/diagnosis'; + import BasePagination from '../../../components/BasePagination'; + import { Practitioner } from '../../../@types/doctor'; + import CreateIcon from '@mui/icons-material/Create'; + import { Props } from '../../../components/editor/index'; + import { red } from '@mui/material/colors'; + import { margin, padding } from '@mui/system'; + import { enqueueSnackbar } from 'notistack'; + import { Controller } from 'react-hook-form'; + + import SvgIconStyle from '../../../components/SvgIconStyle'; + import { GridSearchIcon } from '@mui/x-data-grid'; + import { Search } from '@mui/icons-material'; + import { Icon } from '@iconify/react'; + import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; + import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; + + export default function List(){ + + const navigate = useNavigate(); + const { organization_id } = useParams(); + const [searchParams, setSearchParams] = useSearchParams(); + const [searchParamsOrganizations, setSearchParamsOrganizations] = useSearchParams(); + const [searchParamsSpecialities, setSearchParamsSpecialities] = useSearchParams(); + const [searchParamsFilter, setSearchParamsFilter] = useSearchParams(); + + function Filter(props: any) { + // SEARCH + const searchInput = useRef(null); + const [searchText, setSearchText] = useState(''); + + //handle search + const handleSearchChange = (event: any) => { + const newSearchText = event.target.value ?? ''; + setSearchText(newSearchText); + }; + + const handleSearchSubmit = (event: any) => { + event.preventDefault(); + + props.onSearch(searchText); + }; + + useEffect(() => { + // Trigger First Search + setSearchText(searchParams.get('search') ?? ''); + }, []); + + const item = [ + { + id: '', + value: '', + name: 'Semua', + }, + ]; + + return ( +
+ + + { + if (event.key === 'Enter') { + handleSearchSubmit(event); + } + }} + value={searchText} + InputProps={{ + startAdornment: ( + + + + ), + placeholder: 'Search', + }} + /> + + +
+ ); + } + function FilterForm(props: any) { + return( + + + + + + ); + } + + function createData(doctor: Practitioner): Practitioner { + return { + ...doctor, + }; + } + + function Row(props: { row: ReturnType }) { + const { row } = props; + const [open, setOpen] = React.useState(false); + const [openDialog, setOpenDialog] = React.useState(false); + + + + return ( + + + + setOpen(!open)}> + {open ? : } + + + {row.nID ? row.nID : '-'} + + {row.nIDUser ? row.nIDUser : '-'} + + {row.nIDDokter ? row.nIDDokter : '-'} + {row.sDokterName ? row.sDokterName : '-'} + {row.dTanggalResep ? row.dTanggalResep : '-'} + {row.sSource ? row.sSource : '-'} + {row.sKodeResep ? row.sKodeResep : '-'} + {row.sDiagnose ? row.sDiagnose : '-'} + {row.sStatus ? row.sStatus : '-'} + {/* + + + + + + */} + + {/* COLLAPSIBLE ROW */} + + +{/* + + + + + + Metode Pembayaran + + + : {row.payment_method ? row.payment_method : '-'} + + + + Jenis Benefit + + + : - + + + Durasi + + + : {row.duration ? row.duration : '-'} + + + + + + */} + + + + {/* END COLLAPSIBLE ROW */} + { + setOpenDialog(false); + }} + aria-labelledby="alert-dialog-title" + aria-describedby="alert-dialog-description" + > + + + + Apakah anda yakin ingin menghapus + + + {row.name}? + + + + + {/* */} + + + + ); + } + + const headStyle = { + fontWeight: 'bold', + }; + // Dummy Default Data + const [dataTableIsLoading, setDataTableLoading] = useState(true); + const [dataTableLastRequest, setDataTableLastRequest] = useState(0); + const [dataTableResponseState, setDataTableResponseState] = useState('idle'); + const [dataTableData, setDataTableData] = useState({ + current_page: 1, + data: [], + path: '', + first_page_url: '', + last_page: 1, + last_page_url: '', + next_page_url: '', + prev_page_url: '', + per_page: 10, + from: 0, + to: 0, + total: 0, + }); + const [dataTablePage, setDataTablePage] = useState(5); + + const loadDataTableData = async (appliedFilter: any | null = null) => { + setDataTableLoading(true); + const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); + const response = await axios.get('/prescription', { + params: filter, + }); + setDataTableLoading(false); + setDataTableData(response.data); + }; + + // const applyFilter = async (searchFilter: string) => { + // await loadDataTableData({ search: searchFilter }); + // setSearchParams({ search: searchFilter }); + // }; + + const applyItems = async ( + searchFilter: string, + searchFilterOrganization: string, + searchFilterSpecialities: string + ) => { + await loadDataTableData({ + search: searchFilter, + organization_id: searchFilterOrganization, + speciality_id: searchFilterSpecialities, + }); + setSearchParamsFilter({ + search: searchFilter, + organization_id: searchFilterOrganization, + speciality_id: searchFilterSpecialities, + }); + }; + + const handlePageChange = (event: ChangeEvent, value: number) => { + const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]); + loadDataTableData(filter); + setSearchParams(filter); + }; + + useEffect(() => { + loadDataTableData(); + }, []); + + return ( + + {/* */} + + + + + {/* The Main Table */} + + + + + {/* */} + + + ID Booking + + + ID User + + + ID Dokter + + + Nama Dokter + + + Tanggal Resep + + + Source + + + Kode Resep + + + Diagnosa + + + Status + + +{/* + + + Tanggal Booking + + + Tanggal Appointment + + + Faskes + + + Nama Dokter + + + Spesialisasi + + + Pasien + + + Dokter + + */} + + {dataTableIsLoading ? ( + + + + Loading + + + + ) : (dataTableData.data && dataTableData.data.length === 0) ? ( + + + + + No Data + + + + ) : ( + + {dataTableData && dataTableData.map((row) => ( + + ))} + + )} +
+
+ + +
+
+ ); +} \ No newline at end of file diff --git a/frontend/dashboard/src/routes/index.tsx b/frontend/dashboard/src/routes/index.tsx index 3c0a4ec1..389fda74 100755 --- a/frontend/dashboard/src/routes/index.tsx +++ b/frontend/dashboard/src/routes/index.tsx @@ -12,6 +12,7 @@ import VerifyCode from '../pages/auth/VerifyCode'; import { AuthProvider } from '../contexts/LaravelAuthContext'; import AuthGuard from '../guards/AuthGuard'; import { Link, useParams, useSearchParams } from 'react-router-dom'; +import Prescription from '@/pages/Report/Prescription/Index'; // ---------------------------------------------------------------------- @@ -285,6 +286,10 @@ export default function Router() { path: 'report/live-chat/:id/edit', element: , }, + { + path: 'report/prescription', + element: , + }, { path: 'report/linksehat-payments', element: ,