Merge branch 'staging' of https://dev.sismedika.online/febio/aso into staging
This commit is contained in:
@@ -0,0 +1,240 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api\Linksehat;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\OLDLMS\Prescription;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\ReportPrescriptionResource;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
|
||||||
|
class PrescriptionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
// return $request->toArray();
|
||||||
|
$prescription = Prescription::query()
|
||||||
|
->with(['livechat', 'user', 'items']);
|
||||||
|
if ($request->has('search')) {
|
||||||
|
$search = $request->search;
|
||||||
|
$prescription->where(function ($query) use ($search) {
|
||||||
|
$query->where('sDokterName', 'LIKE', '%' . $search . "%")
|
||||||
|
->orWhere('sKodeResep', 'LIKE', '%' . $search . "%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($request->has('prescription_start') || $request->has('prescription_end'))
|
||||||
|
&& !empty($request->prescription_start)
|
||||||
|
&& !empty($request->prescription_end)
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
$prescription = $prescription->where(function($q) use ($request) {
|
||||||
|
$q->where('dTanggalResep', '>=', $request->prescription_start)
|
||||||
|
->where('dTanggalResep', '<=', $request->prescription_end);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$prescriptions = $prescription->orderBy('dUpdateOn', 'DESC')
|
||||||
|
->paginate();
|
||||||
|
|
||||||
|
return Helper::responseJson(Helper::paginateResources(ReportPrescriptionResource::collection($prescriptions)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to determine if a string is serialized
|
||||||
|
private function is_serialized($string) {
|
||||||
|
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to determine if a string is JSON
|
||||||
|
private function is_json($string) {
|
||||||
|
json_decode($string);
|
||||||
|
return (json_last_error() == JSON_ERROR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to safely process the plan
|
||||||
|
private function processPlan($sPlan) {
|
||||||
|
if ($this->is_serialized($sPlan)) {
|
||||||
|
$unserializedPlan = @unserialize($sPlan);
|
||||||
|
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||||
|
return $unserializedPlan;
|
||||||
|
}
|
||||||
|
} elseif ($this->is_json($sPlan)) {
|
||||||
|
$jsonPlan = json_decode($sPlan, true);
|
||||||
|
if (json_last_error() == JSON_ERROR_NONE) {
|
||||||
|
return $jsonPlan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sPlan; // Treat as plain text if not serialized or JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateExcel(Request $request)
|
||||||
|
{
|
||||||
|
Helper::setCustomPHPIniSettings();
|
||||||
|
|
||||||
|
$file_name = 'Data Report Resep Online';
|
||||||
|
// Membuat penulis entitas Spout
|
||||||
|
$writer = WriterEntityFactory::createXLSXWriter();
|
||||||
|
// Membuka penulis untuk menulis ke file
|
||||||
|
$writer->openToFile(public_path('files/Report-Resep-Online.xlsx'));
|
||||||
|
|
||||||
|
$headerArray = [
|
||||||
|
'No',
|
||||||
|
'Prescription Code',
|
||||||
|
'Date Consultation',
|
||||||
|
'Patient',
|
||||||
|
'Doctor',
|
||||||
|
'Jenis Obat (Drugs)',
|
||||||
|
'Jumlah Obat (QTY)',
|
||||||
|
'Cara Minum Obat',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Sheet 1
|
||||||
|
$writer->getCurrentSheet()->setName('Data');
|
||||||
|
$headerRow = WriterEntityFactory::createRowFromArray($headerArray);
|
||||||
|
$writer->addRow($headerRow);
|
||||||
|
|
||||||
|
// Query prescription data
|
||||||
|
$prescriptionQuery = Prescription::query()
|
||||||
|
->with(['livechat', 'user', 'items']);
|
||||||
|
|
||||||
|
if ($request->has('search')) {
|
||||||
|
$search = $request->search;
|
||||||
|
$prescriptionQuery->where(function ($query) use ($search) {
|
||||||
|
$query->where('sDokterName', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhere('sKodeResep', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('prescription_start') && $request->has('prescription_end') &&
|
||||||
|
!empty($request->prescription_start) && !empty($request->prescription_end)) {
|
||||||
|
$prescriptionQuery->whereBetween('dTanggalResep', [$request->prescription_start, $request->prescription_end]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prescriptions = $prescriptionQuery->get();
|
||||||
|
|
||||||
|
if ($prescriptions->isNotEmpty()) {
|
||||||
|
$no = 1;
|
||||||
|
foreach ($prescriptions as $index => $row) {
|
||||||
|
if ($row->items->isNotEmpty()) {
|
||||||
|
$rowData = [
|
||||||
|
$no++,
|
||||||
|
$row->sKodeResep ?? '-',
|
||||||
|
$row->dTanggalResep ? Carbon::parse($row->dTanggalResep)->format('Y-m-d') : '-',
|
||||||
|
$row->user->name ?? '-',
|
||||||
|
$row->sDokterName ?? '-',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Create a row from the array and add it to the writer
|
||||||
|
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||||
|
$writer->addRow($rowEntity);
|
||||||
|
foreach ($row->items as $item) {
|
||||||
|
$rowSubData = [
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$item->sItemName ?? '-',
|
||||||
|
$item->nQty ?? '-',
|
||||||
|
$item->sSigna ?? '-'
|
||||||
|
];
|
||||||
|
$subData = WriterEntityFactory::createRowFromArray($rowSubData);
|
||||||
|
$writer->addRow($subData);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$rowData = [
|
||||||
|
$no++,
|
||||||
|
$row->sKodeResep ?? '-',
|
||||||
|
$row->dTanggalResep ? Carbon::parse($row->dTanggalResep)->format('Y-m-d') : '-',
|
||||||
|
$row->user->name ?? '-',
|
||||||
|
$row->sDokterName ?? '-',
|
||||||
|
];
|
||||||
|
// Create a row from the array and add it to the writer
|
||||||
|
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||||
|
$writer->addRow($rowEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$writer->close();
|
||||||
|
|
||||||
|
return Helper::responseJson([
|
||||||
|
'file_name' => "Data Resep Online " . date('Y-m-d h:i:s'),
|
||||||
|
'file_url' => url('files/Report-Resep-Online.xlsx')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,6 +31,8 @@ use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\FormulariumTemplateController;
|
use Modules\Internal\Http\Controllers\Api\FormulariumTemplateController;
|
||||||
use Modules\Internal\Http\Controllers\Api\Linksehat\PaymentController;
|
use Modules\Internal\Http\Controllers\Api\Linksehat\PaymentController;
|
||||||
use Modules\Internal\Http\Controllers\Api\Linksehat\HealthRecordController;
|
use Modules\Internal\Http\Controllers\Api\Linksehat\HealthRecordController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\Linksehat\RujukanController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\Linksehat\PrescriptionController as PrescriptionControllerReport;
|
||||||
use Modules\Internal\Http\Controllers\Api\LivechatController;
|
use Modules\Internal\Http\Controllers\Api\LivechatController;
|
||||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||||
use Modules\Internal\Http\Controllers\Api\OptionController;
|
use Modules\Internal\Http\Controllers\Api\OptionController;
|
||||||
@@ -88,6 +90,10 @@ Route::prefix('internal')->group(function () {
|
|||||||
// Report LMS
|
// Report LMS
|
||||||
Route::get('linksehat/phr', [HealthRecordController::class, 'index']);
|
Route::get('linksehat/phr', [HealthRecordController::class, 'index']);
|
||||||
Route::get('linksehat/phr/generate-excel', [HealthRecordController::class, 'generateExcel']);
|
Route::get('linksehat/phr/generate-excel', [HealthRecordController::class, 'generateExcel']);
|
||||||
|
Route::get('linksehat/prescription', [PrescriptionControllerReport::class, 'index']);
|
||||||
|
Route::get('linksehat/prescription/generate-excel', [PrescriptionControllerReport::class, 'generateExcel']);
|
||||||
|
Route::get('linksehat/rujukan', [RujukanController::class, 'index']);
|
||||||
|
Route::get('linksehat/rujukan/generate-excel', [RujukanController::class, 'generateExcel']);
|
||||||
|
|
||||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||||
Route::get('/user', function (Request $request) {
|
Route::get('/user', function (Request $request) {
|
||||||
|
|||||||
32
Modules/Internal/Transformers/ReportPrescriptionResource.php
Normal file
32
Modules/Internal/Transformers/ReportPrescriptionResource.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class ReportPrescriptionResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$patientName = $this->user ? $this->user->sFirstName .' '. $this->user->sLastName : '-';
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'id' => $this->nID,
|
||||||
|
'patient_name' => $patientName,
|
||||||
|
'livechat' => $this->livechat,
|
||||||
|
'prescription_code' => $this->sKodeResep,
|
||||||
|
'date_consultation' => $this->dTanggalResep ? Carbon::parse($this->dTanggalResep)->format('Y-m-d H:i:s') : null,
|
||||||
|
'doctor_name' => $this->sDokterName ? $this->sDokterName : '-',
|
||||||
|
'items' => $this->items ? $this->items : [],
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,4 +52,18 @@ class Prescription extends Model
|
|||||||
'dTanggalResep' => 'datetime',
|
'dTanggalResep' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function items()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PrescriptionItem::class, 'nIDPrescription', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function livechat(){
|
||||||
|
return $this->belongsTo(Livechat::class, 'nIDLivechat', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,10 @@ class PrescriptionItem extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $primaryKey = 'nID';
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function prescription()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Prescription::class, 'nIDPrescription', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,35 @@
|
|||||||
import { Card, Grid, Container } from '@mui/material';
|
import { Card, Grid, Container } from '@mui/material';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import HeaderBreadcrumbs from '@/components/HeaderBreadcrumbs';
|
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
||||||
import Page from '@/components/Page';
|
import Page from '../../../components/Page';
|
||||||
import useSettings from '@/hooks/useSettings';
|
import useSettings from '../../../hooks/useSettings';
|
||||||
import List from '../Prescription/List';
|
import List from './List';
|
||||||
|
|
||||||
export default function Prescription(){
|
export default function LinksehatPayments() {
|
||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const pageTitle = 'Prescription';
|
const pageTitle = 'Resep Online';
|
||||||
|
return (
|
||||||
|
<Page title={pageTitle}>
|
||||||
|
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={pageTitle}
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
name: 'Report',
|
||||||
|
href: '/report',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Resep Online',
|
||||||
|
href: '/report/prescription',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
return(
|
<List />
|
||||||
<Page title = {pageTitle}>
|
</Container>
|
||||||
<Container maxWidth = {themeStretch ? false : 'xl'}>
|
</Page>
|
||||||
<HeaderBreadcrumbs heading= {pageTitle}
|
);
|
||||||
links={[
|
|
||||||
{
|
|
||||||
name: 'Report',
|
|
||||||
href: '/report',
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Prescription',
|
|
||||||
href: '/prescription',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<List/>
|
|
||||||
|
|
||||||
</Container>
|
|
||||||
</Page>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,8 @@ import {
|
|||||||
Autocomplete,
|
Autocomplete,
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
InputLabel,
|
||||||
|
Menu,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -39,6 +41,7 @@ import {
|
|||||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||||
import useSettings from '../../../hooks/useSettings';
|
import useSettings from '../../../hooks/useSettings';
|
||||||
// components
|
// components
|
||||||
|
import AutocompleteHealthcare from '@/components/autocomplete/AutocompleteHealthcare';
|
||||||
import axios from '../../../utils/axios';
|
import axios from '../../../utils/axios';
|
||||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||||
import { Icd } from '../../../@types/diagnosis';
|
import { Icd } from '../../../@types/diagnosis';
|
||||||
@@ -49,9 +52,8 @@ import { Props } from '../../../components/editor/index';
|
|||||||
import { red } from '@mui/material/colors';
|
import { red } from '@mui/material/colors';
|
||||||
import { margin, padding } from '@mui/system';
|
import { margin, padding } from '@mui/system';
|
||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
import { fNumber } from '@/utils/formatNumber';
|
||||||
import { Controller } from 'react-hook-form';
|
import { Controller } from 'react-hook-form';
|
||||||
import { User } from '../../../Models/User';
|
|
||||||
|
|
||||||
|
|
||||||
import SvgIconStyle from '../../../components/SvgIconStyle';
|
import SvgIconStyle from '../../../components/SvgIconStyle';
|
||||||
import { GridSearchIcon } from '@mui/x-data-grid';
|
import { GridSearchIcon } from '@mui/x-data-grid';
|
||||||
@@ -59,370 +61,520 @@ import { Search } from '@mui/icons-material';
|
|||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
|
import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||||
|
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
||||||
|
import { MenuItem } from '@mui/material';
|
||||||
|
import { fDateOnly, fDateTime } from '@/utils/formatTime';
|
||||||
|
import AutocompleteLinksehatHealthcare from '@/components/autocomplete/AutocompleteLinksehatHealthcare';
|
||||||
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
import UploadIcon from '@mui/icons-material/Upload';
|
||||||
|
|
||||||
export default function List(){
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
export default function List() {
|
||||||
|
// Generate the every row of the table
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { organization_id } = useParams();
|
const { organization_id } = useParams();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [organizationOptions, setOrganizationOptions] = useState([]);
|
||||||
|
const [searchParamsPaymentStatus, setSearchParamsPaymentStatus] = useSearchParams();
|
||||||
const [searchParamsOrganizations, setSearchParamsOrganizations] = useSearchParams();
|
const [searchParamsOrganizations, setSearchParamsOrganizations] = useSearchParams();
|
||||||
const [searchParamsSpecialities, setSearchParamsSpecialities] = useSearchParams();
|
const [searchParamsSpecialities, setSearchParamsSpecialities] = useSearchParams();
|
||||||
const [searchParamsFilter, setSearchParamsFilter] = useSearchParams();
|
const [searchParamsFilter, setSearchParamsFilter] = useSearchParams();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// axios.get(`/search-organizations`).then((response) => {
|
||||||
|
// setOrganizationOptions(response.data);
|
||||||
|
// });
|
||||||
|
}, []);
|
||||||
|
|
||||||
function Filter(props: any) {
|
function Filter(props: any) {
|
||||||
// SEARCH
|
// SEARCH
|
||||||
const searchInput = useRef<HTMLInputElement>(null);
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
const [searchText, setSearchText] = useState('');
|
const [searchText, setSearchText] = useState('');
|
||||||
|
const [importLoading, setImportLoading] = useState(false);
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||||
|
const createMenu = Boolean(anchorEl);
|
||||||
|
|
||||||
//handle search
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
const handleSearchChange = (event: any) => {
|
setAnchorEl(event.currentTarget);
|
||||||
const newSearchText = event.target.value ?? '';
|
};
|
||||||
setSearchText(newSearchText);
|
const handleClose = () => {
|
||||||
};
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSearchSubmit = (event: any) => {
|
/* ------------------------------ handle params ----------------------------- */
|
||||||
event.preventDefault();
|
const [appliedParams, setAppliedParams] = useState({});
|
||||||
|
const params = {
|
||||||
|
searchParams: searchParams,
|
||||||
|
setSearchParams: setSearchParams,
|
||||||
|
appliedParams: appliedParams,
|
||||||
|
setAppliedParams: setAppliedParams,
|
||||||
|
};
|
||||||
|
|
||||||
props.onSearch(searchText);
|
const handleGetData = (type :string) => {
|
||||||
};
|
const parameters =
|
||||||
|
Object.keys(appliedParams).length !== 0
|
||||||
|
? appliedParams
|
||||||
|
: Object.fromEntries([...searchParams.entries()]);
|
||||||
|
setImportLoading(true);
|
||||||
|
axios.get('/linksehat/prescription/generate-excel', {
|
||||||
|
params: { ...parameters },
|
||||||
|
}).then((response) => {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = response.data.data.file_url;
|
||||||
|
link.setAttribute('download', response.data.data.file_name);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
handleClose();
|
||||||
|
setImportLoading(false);
|
||||||
|
});
|
||||||
|
// axios.get(`report/logs/export`)
|
||||||
|
// .then((response) => {
|
||||||
|
// const link = document.createElement('a');
|
||||||
|
// link.href = response.data.data.file_url;
|
||||||
|
// link.setAttribute('download', response.data.data.file_name);
|
||||||
|
// document.body.appendChild(link);
|
||||||
|
// link.click();
|
||||||
|
// handleClose();
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
//handle search
|
||||||
// Trigger First Search
|
const handleSearchChange = (event: any) => {
|
||||||
setSearchText(searchParams.get('search') ?? '');
|
const newSearchText = event.target.value ?? '';
|
||||||
}, []);
|
setSearchText(newSearchText);
|
||||||
|
};
|
||||||
|
|
||||||
const item = [
|
const handleSearchSubmit = (event: any) => {
|
||||||
{
|
event.preventDefault();
|
||||||
id: '',
|
|
||||||
value: '',
|
|
||||||
name: 'Semua',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
props.onSearch(searchText);
|
||||||
<form style={{ width: '100%' }}>
|
};
|
||||||
<Grid container spacing={2} sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
|
||||||
<Grid item xs={12} sm={12} md={12} lg={12}>
|
useEffect(() => {
|
||||||
<TextField
|
// Trigger First Search
|
||||||
id="search-input"
|
setSearchText(searchParams.get('search') ?? '');
|
||||||
ref={searchInput}
|
}, []);
|
||||||
variant="outlined"
|
|
||||||
fullWidth
|
|
||||||
onChange={handleSearchChange}
|
|
||||||
onKeyDown={(event) => {
|
return (
|
||||||
if (event.key === 'Enter') {
|
<form style={{ width: '100%' }}>
|
||||||
handleSearchSubmit(event);
|
<Grid container spacing={2} sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
|
<Grid item md={7}>
|
||||||
|
<TextField
|
||||||
|
id="search-input"
|
||||||
|
ref={searchInput}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
onChange={handleSearchChange}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
// handleSearchSubmit(event);
|
||||||
|
|
||||||
|
const filter = Object.fromEntries([
|
||||||
|
...searchParams.entries(),
|
||||||
|
['search', searchText],
|
||||||
|
]);
|
||||||
|
setSearchParams(filter);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
label="Search"
|
||||||
|
value={searchText}
|
||||||
|
InputProps={{
|
||||||
|
// startAdornment: (
|
||||||
|
// <InputAdornment position="start">
|
||||||
|
// <Search />
|
||||||
|
// </InputAdornment>
|
||||||
|
// ),
|
||||||
|
placeholder: 'Nama Pasien',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
<Grid item md={2}>
|
||||||
|
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||||
|
<DesktopDatePicker
|
||||||
|
value={searchParams.get('prescription_start')}
|
||||||
|
inputFormat="dd/MM/yyyy"
|
||||||
|
onChange={(value) => {
|
||||||
|
try {
|
||||||
|
if (value && !!Date.parse(value)) {
|
||||||
|
const date = value ? fDateOnly(value) : '';
|
||||||
|
var entries = [...searchParams.entries(), ['prescription_start', date ?? '']];
|
||||||
|
if (!searchParams.get('prescription_end')) {
|
||||||
|
entries = [...entries, ['prescription_end', date ?? '']];
|
||||||
}
|
}
|
||||||
}}
|
const filter = Object.fromEntries(entries);
|
||||||
value={searchText}
|
|
||||||
InputProps={{
|
setSearchParams(filter);
|
||||||
startAdornment: (
|
loadDataTableData(filter);
|
||||||
<InputAdornment position="start">
|
}
|
||||||
<Search />
|
} catch (e) {}
|
||||||
</InputAdornment>
|
}}
|
||||||
),
|
renderInput={(params) => <TextField {...params} fullWidth label="Start" />}
|
||||||
placeholder: 'Search',
|
/>
|
||||||
}}
|
</LocalizationProvider>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid item md={2}>
|
||||||
|
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||||
|
<DesktopDatePicker
|
||||||
|
value={searchParams.get('prescription_end')}
|
||||||
|
inputFormat="dd/MM/yyyy"
|
||||||
|
onChange={(value) => {
|
||||||
|
try {
|
||||||
|
if (value && !!Date.parse(value)) {
|
||||||
|
const date = fDateOnly(value);
|
||||||
|
var entries = [...searchParams.entries(), ['prescription_end', date ?? '']];
|
||||||
|
if (!searchParams.get('prescription_start')) {
|
||||||
|
entries = [...entries, ['prescription_start', date ?? '']];
|
||||||
|
}
|
||||||
|
const filter = Object.fromEntries(entries);
|
||||||
|
|
||||||
|
setSearchParams(filter);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField
|
||||||
|
{...params}
|
||||||
|
fullWidth
|
||||||
|
label="End"
|
||||||
|
// error={!!error}
|
||||||
|
// helperText={error?.message}
|
||||||
|
// {...other}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
)}
|
||||||
</Grid>
|
/>
|
||||||
</form>
|
</LocalizationProvider>
|
||||||
);
|
</Grid>
|
||||||
}
|
|
||||||
function FilterForm(props: any) {
|
<Grid item md={1}>
|
||||||
return(
|
<LoadingButton
|
||||||
|
variant="outlined"
|
||||||
|
startIcon={<UploadIcon />}
|
||||||
|
sx={{ p: 1.8 }}
|
||||||
|
onClick={handleClick}
|
||||||
|
loading={importLoading}
|
||||||
|
>
|
||||||
|
Export
|
||||||
|
</LoadingButton>
|
||||||
|
<Menu
|
||||||
|
id="import-button"
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={createMenu}
|
||||||
|
onClose={handleClose}
|
||||||
|
MenuListProps={{
|
||||||
|
'aria-labelledby': 'basic-button',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem onClick={() => {handleGetData('')}}>Download Excel</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function FilterForm(props: any) {
|
||||||
|
// IMPORT
|
||||||
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
|
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
|
||||||
>
|
>
|
||||||
<Grid item xs={12} md={12} lg={12}>
|
<Grid item xs={12} md={12} lg={12}>
|
||||||
<Filter onSearch={applyItems} />
|
<Filter onSearch={applyItems} />
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function createData(doctor: Practitioner): Practitioner {
|
//TODO Create PaymentType
|
||||||
return {
|
function createData(payments: any): any {
|
||||||
...doctor,
|
return {
|
||||||
/* user: doctor.user ? new User(doctor.user) : null; */
|
...payments,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function Row(props: { row: ReturnType<typeof createData> }) {
|
function Row(props: { row: ReturnType<typeof createData> }) {
|
||||||
const { row } = props;
|
const { row } = props;
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(true);
|
||||||
const [openDialog, setOpenDialog] = React.useState(false);
|
const [openDialog, setOpenDialog] = React.useState(false);
|
||||||
|
|
||||||
|
const handleDelete = (model: any) => {
|
||||||
|
axios
|
||||||
|
.delete(`/doctors/${row.id}`)
|
||||||
|
.then((res) => {
|
||||||
|
setDataTableData({
|
||||||
|
...dataTableData,
|
||||||
|
data: dataTableData.data.filter((model) => model.id != row.id),
|
||||||
|
});
|
||||||
|
enqueueSnackbar('Data berhasil dihapus', { variant: 'success' });
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
enqueueSnackbar(
|
||||||
|
error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||||
|
{ variant: 'error' }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
|
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
|
||||||
|
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
||||||
|
</IconButton>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="left">{row.prescription_code ?? '-'}</TableCell>
|
||||||
|
<TableCell align="left">{row.date_consultation ? fDateTime(row.date_consultation) : '-'}</TableCell>
|
||||||
|
<TableCell align="left">{row.patient_name ?? '-'}</TableCell>
|
||||||
|
<TableCell align="left">{row.doctor_name ?? '-'}</TableCell>
|
||||||
|
{/* <TableCell align="center">
|
||||||
|
<ButtonGroup variant="text" aria-label="text button group">
|
||||||
|
<Link to={'/report/appointments/' + row.id + '/show'}>
|
||||||
|
<Button>
|
||||||
|
<Icon icon="ph:eye-bold" style={{ width: '24px', height: '24px' }} />
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</ButtonGroup>
|
||||||
|
</TableCell> */}
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
return (
|
{/* COLLAPSIBLE ROW */}
|
||||||
<React.Fragment>
|
<TableRow>
|
||||||
<TableRow>
|
<TableCell
|
||||||
<TableCell>
|
style={{ paddingBottom: 0, paddingTop: 0, backgroundColor: 'rgba(244, 246, 248, 0.5)' }}
|
||||||
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
|
colSpan={12}
|
||||||
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
>
|
||||||
</IconButton>
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||||
</TableCell>
|
<Box sx={{ margin: 1, pb: 2, pl: 4 }}>
|
||||||
|
<Grid container>
|
||||||
|
<Grid item xs={12} sx={{ padding: 2 }}>
|
||||||
|
<Grid container>
|
||||||
|
<Grid item style={headStyle} xs={4}>
|
||||||
|
Jenis Obat (Drugs)
|
||||||
|
</Grid>
|
||||||
|
<Grid item style={headStyle} xs={4}>
|
||||||
|
Jumlah Obat (QTY)
|
||||||
|
</Grid>
|
||||||
|
<Grid item style={headStyle} xs={4}>
|
||||||
|
Cara Minum Obat
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<TableCell align="left">{row.user ? row.user.sFirstName : '-'}</TableCell>
|
{row.items?.map((item) => (
|
||||||
<TableCell align="left">{row.nIDDokter ? row.nIDDokter : '-'}</TableCell>
|
<React.Fragment key={item.nID}>
|
||||||
<TableCell align="left">{row.nRating ? row.nRating : '-'}</TableCell>
|
<Grid item xs={4}>
|
||||||
<TableCell align="left">{row.sNotes ? row.sNotes : '-'}</TableCell>
|
<Typography>{item.sItemName}</Typography>
|
||||||
<TableCell align="left">{row.dCreateOn ? row.dCreateOn : '-'}</TableCell>
|
</Grid>
|
||||||
|
<Grid item xs={4}>
|
||||||
|
<Typography>{item.nQty}</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={4}>
|
||||||
|
<Typography>{item.sSigna}</Typography>
|
||||||
|
</Grid>
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
|
||||||
{/* <TableCell align="center">
|
|
||||||
<ButtonGroup variant="text" aria-label="text button group">
|
|
||||||
<Link to={'/report/prescription/' + row.id + '/show'}>
|
|
||||||
<Button>
|
|
||||||
<Icon icon="ph:eye-bold" style={{ width: '24px', height: '24px' }} />
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</ButtonGroup>
|
|
||||||
</TableCell> */}
|
|
||||||
</TableRow>
|
|
||||||
{/* COLLAPSIBLE ROW */}
|
|
||||||
<TableRow>
|
|
||||||
<TableCell
|
|
||||||
style={{ paddingBottom: 0, paddingTop: 0, backgroundColor: 'rgba(244, 246, 248, 0.5)' }}
|
|
||||||
colSpan={6}
|
|
||||||
>
|
|
||||||
{/* <Collapse in={open} timeout="auto" unmountOnExit>
|
|
||||||
<Box sx={{ margin: 1, pb: 2, pl: 4 }}>
|
|
||||||
<Grid container>
|
|
||||||
<Grid item xs={12} sx={{ padding: 2 }}>
|
|
||||||
<Grid container>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
Metode Pembayaran
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
: {row.payment_method ? row.payment_method : '-'}
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Grid item xs={6}>
|
|
||||||
Jenis Benefit
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
: -
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
Durasi
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
: {row.duration ? row.duration : '-'}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Box>
|
||||||
</Box>
|
</Collapse>
|
||||||
</Collapse> */}
|
</TableCell>
|
||||||
</TableCell>
|
</TableRow>
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
{/* END COLLAPSIBLE ROW */}
|
{/* END COLLAPSIBLE ROW */}
|
||||||
<Dialog
|
|
||||||
open={openDialog}
|
<Dialog
|
||||||
onClose={() => {
|
open={openDialog}
|
||||||
setOpenDialog(false);
|
onClose={() => {
|
||||||
}}
|
setOpenDialog(false);
|
||||||
aria-labelledby="alert-dialog-title"
|
}}
|
||||||
aria-describedby="alert-dialog-description"
|
aria-labelledby="alert-dialog-title"
|
||||||
>
|
aria-describedby="alert-dialog-description"
|
||||||
<DialogContent sx={{ p: 5 }}>
|
>
|
||||||
<Icon
|
<DialogContent sx={{ p: 5 }}>
|
||||||
icon="eva:trash-2-outline"
|
<Icon
|
||||||
style={{
|
icon="eva:trash-2-outline"
|
||||||
width: '100px',
|
style={{
|
||||||
height: '100px',
|
width: '100px',
|
||||||
color: '#FF0000',
|
height: '100px',
|
||||||
margin: 'auto',
|
color: '#FF0000',
|
||||||
display: 'block',
|
margin: 'auto',
|
||||||
marginBottom: '20px',
|
display: 'block',
|
||||||
alignContent: 'center',
|
marginBottom: '20px',
|
||||||
}}
|
alignContent: 'center',
|
||||||
/>
|
}}
|
||||||
<DialogContentText sx={{ fontWeight: 'bold', pb: 1 }} id="alert-dialog-title">
|
/>
|
||||||
Apakah anda yakin ingin menghapus
|
<DialogContentText sx={{ fontWeight: 'bold', pb: 1 }} id="alert-dialog-title">
|
||||||
</DialogContentText>
|
Apakah anda yakin ingin menghapus
|
||||||
<Typography sx={{ fontWeight: 'bold' }} id="alert-dialog-title">
|
</DialogContentText>
|
||||||
{row.name}?
|
<Typography sx={{ fontWeight: 'bold' }} id="alert-dialog-title">
|
||||||
</Typography>
|
{row.name}?
|
||||||
</DialogContent>
|
</Typography>
|
||||||
<DialogActions>
|
</DialogContent>
|
||||||
<Button
|
<DialogActions>
|
||||||
onClick={() => {
|
<Button
|
||||||
setOpenDialog(false);
|
onClick={() => {
|
||||||
}}
|
setOpenDialog(false);
|
||||||
color="primary"
|
}}
|
||||||
>
|
color="primary"
|
||||||
Batal
|
>
|
||||||
</Button>
|
Batal
|
||||||
{/* <Button
|
</Button>
|
||||||
onClick={() => {
|
<Button
|
||||||
handleDelete(row.id);
|
onClick={() => {
|
||||||
}}
|
handleDelete(row.id);
|
||||||
color="primary"
|
}}
|
||||||
autoFocus
|
color="primary"
|
||||||
>
|
autoFocus
|
||||||
Hapus
|
>
|
||||||
</Button> */}
|
Hapus
|
||||||
</DialogActions>
|
</Button>
|
||||||
</Dialog>
|
</DialogActions>
|
||||||
</React.Fragment>
|
</Dialog>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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<LaravelPaginatedData>({
|
||||||
|
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('/linksehat/prescription', {
|
||||||
|
params: filter,
|
||||||
|
});
|
||||||
|
setDataTableLoading(false);
|
||||||
|
setDataTableData(response.data.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
// const applyFilter = async (searchFilter: string) => {
|
||||||
|
// await loadDataTableData({ search: searchFilter });
|
||||||
|
// setSearchParams({ search: searchFilter });
|
||||||
|
// };
|
||||||
|
|
||||||
|
const applyItems = async (
|
||||||
|
searchFilter: string,
|
||||||
|
searchFilterOrganization: string,
|
||||||
|
searchFilterPaymentStatus: string,
|
||||||
|
searchFilterAppointmentStart: string,
|
||||||
|
searchFilterAppointmentEnd: string
|
||||||
|
) => {
|
||||||
|
await loadDataTableData({
|
||||||
|
search: searchFilter,
|
||||||
|
organization_id: searchFilterOrganization,
|
||||||
|
payment_status: searchFilterPaymentStatus,
|
||||||
|
prescription_start: searchFilterAppointmentStart,
|
||||||
|
prescription_end: searchFilterAppointmentEnd,
|
||||||
|
});
|
||||||
|
setSearchParamsFilter({
|
||||||
|
search: searchFilter,
|
||||||
|
organization_id: searchFilterOrganization,
|
||||||
|
payment_status: searchFilterPaymentStatus,
|
||||||
|
prescription_start: searchFilterAppointmentStart,
|
||||||
|
prescription_end: searchFilterAppointmentEnd,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePageChange = (event: ChangeEvent, value: number) => {
|
||||||
|
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
setSearchParams(filter);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadDataTableData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
{/* <Ambulace /> */}
|
||||||
|
|
||||||
|
<Card sx={{ marginTop: '30px' }}>
|
||||||
|
<FilterForm sx={{ marginTop: '100px' }} />
|
||||||
|
|
||||||
|
{/* The Main Table */}
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">
|
||||||
|
Prescription Code
|
||||||
|
</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">
|
||||||
|
Date
|
||||||
|
</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">
|
||||||
|
Patient
|
||||||
|
</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">
|
||||||
|
Doctor
|
||||||
|
</TableCell>
|
||||||
|
{/* <TableCell style={headStyle} align="center">
|
||||||
|
Aksi
|
||||||
|
</TableCell> */}
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
{dataTableIsLoading ? (
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">
|
||||||
|
Loading
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : dataTableData.data.length == 0 ? (
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">
|
||||||
|
No Data
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
<TableBody>
|
||||||
|
{dataTableData.data.map((row) => (
|
||||||
|
<Row key={row.nID} row={row} />
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
)}
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
|
||||||
|
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
|
||||||
|
</Card>
|
||||||
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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<LaravelPaginatedData>({
|
|
||||||
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('/doctorrating ', {
|
|
||||||
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 (
|
|
||||||
<Stack>
|
|
||||||
{/* <Ambulace /> */}
|
|
||||||
|
|
||||||
<Card sx={{ marginTop: '30px' }}>
|
|
||||||
<FilterForm sx={{ marginTop: '100px' }} />
|
|
||||||
|
|
||||||
{/* The Main Table */}
|
|
||||||
<TableContainer component={Paper}>
|
|
||||||
<Table>
|
|
||||||
<TableBody>
|
|
||||||
<TableRow>
|
|
||||||
{/* <TableCell colSpan={8} rowSpan={1} align="center" /> */}
|
|
||||||
<TableCell style={headStyle} align="left" />
|
|
||||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
|
||||||
Nama User
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
|
||||||
ID Dokter
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
|
||||||
Rating
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
|
||||||
Notes
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
|
||||||
Created On
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
{/* <TableRow>
|
|
||||||
<TableCell style={headStyle} align="left" />
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Tanggal Booking
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Tanggal Appointment
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Faskes
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Nama Dokter
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Spesialisasi
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Pasien
|
|
||||||
</TableCell>
|
|
||||||
<TableCell style={headStyle} align="left">
|
|
||||||
Dokter
|
|
||||||
</TableCell>
|
|
||||||
</TableRow> */}
|
|
||||||
</TableBody>
|
|
||||||
{dataTableIsLoading ? (
|
|
||||||
<TableBody>
|
|
||||||
<TableRow>
|
|
||||||
<TableCell colSpan={8} align="center">
|
|
||||||
Loading
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableBody>
|
|
||||||
) : (dataTableData.data && dataTableData.data.length === 0) ? (
|
|
||||||
|
|
||||||
<TableBody>
|
|
||||||
<TableRow>
|
|
||||||
<TableCell colSpan={8} align="center">
|
|
||||||
No Data
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableBody>
|
|
||||||
) : (
|
|
||||||
<TableBody>
|
|
||||||
{dataTableData && dataTableData.map((row) => (
|
|
||||||
<Row key={row.id} row={row} />
|
|
||||||
))}
|
|
||||||
</TableBody>
|
|
||||||
)}
|
|
||||||
</Table>
|
|
||||||
</TableContainer>
|
|
||||||
|
|
||||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
|
|
||||||
</Card>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { paramCase } from 'change-case';
|
|
||||||
import { useParams, useLocation } from 'react-router-dom';
|
|
||||||
// @mui
|
|
||||||
import { Container, Stack } from '@mui/material';
|
|
||||||
import useSettings from '../../../hooks/useSettings';
|
|
||||||
import Page from '../../../components/Page';
|
|
||||||
import Form from './Form';
|
|
||||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
|
||||||
import axios from '../../../utils/axios';
|
|
||||||
import { Practitioner } from '../../../@types/doctor';
|
|
||||||
import ButtonBack from '../../../components/ButtonBack';
|
|
||||||
|
|
||||||
export default function Create() {
|
|
||||||
const { themeStretch } = useSettings();
|
|
||||||
const { id } = useParams();
|
|
||||||
|
|
||||||
const isEdit = id ? true : false;
|
|
||||||
|
|
||||||
const [currentPractitioner, setCurrentPractitioner] = useState<Practitioner>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isEdit) {
|
|
||||||
axios.get('/doctors/' + id).then((res) => {
|
|
||||||
setCurrentPractitioner(res.data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [id]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Page title="Membership: Create a new Dokter">
|
|
||||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
|
||||||
<Stack direction="row" alignItems="center">
|
|
||||||
{/* <ButtonBack /> */}
|
|
||||||
<HeaderBreadcrumbs
|
|
||||||
heading={!isEdit ? 'Manage a new Dokter' : 'Manage Dokter'}
|
|
||||||
links={[
|
|
||||||
{ name: 'Master', href: '/master' },
|
|
||||||
{
|
|
||||||
name: 'Doctors',
|
|
||||||
href: '/master/doctors',
|
|
||||||
},
|
|
||||||
{ name: !isEdit ? 'Create' : currentPractitioner?.name ?? '' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Form
|
|
||||||
// isSubmitting={isSubmitting}
|
|
||||||
isEdit={isEdit}
|
|
||||||
currentPractitioner={currentPractitioner}
|
|
||||||
/>
|
|
||||||
</Container>
|
|
||||||
</Page>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// const pageTitle = 'Create Data Dokter';
|
|
||||||
// return (
|
|
||||||
// <Page title={pageTitle}>
|
|
||||||
// <Container maxWidth={themeStretch ? false : 'xl'}>
|
|
||||||
// <HeaderBreadcrumbs
|
|
||||||
// heading={pageTitle}
|
|
||||||
// links={[
|
|
||||||
// {
|
|
||||||
// name: 'Master',
|
|
||||||
// href: '/master',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'Dokter',
|
|
||||||
// href: '/master/organizations/',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'Create',
|
|
||||||
// href: '/master/organizations/create/',
|
|
||||||
// },
|
|
||||||
// ]}
|
|
||||||
// />
|
|
||||||
|
|
||||||
// <Grid container spacing={2}>
|
|
||||||
// <Grid item xs={12}>
|
|
||||||
// <Card sx={{ p: 2 }}>
|
|
||||||
// <Form
|
|
||||||
// isSubmitting={isSubmitting}
|
|
||||||
// isEdit={isEdit}
|
|
||||||
// currentOrganizations={currentOrganizations}
|
|
||||||
// />
|
|
||||||
// </Card>
|
|
||||||
// </Grid>
|
|
||||||
// </Grid>
|
|
||||||
// </Container>
|
|
||||||
// </Page>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
@@ -1,260 +0,0 @@
|
|||||||
import * as Yup from 'yup';
|
|
||||||
import { useSnackbar } from 'notistack';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
|
||||||
|
|
||||||
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
// form
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
|
||||||
// @mui
|
|
||||||
import { styled } from '@mui/material/styles';
|
|
||||||
import { LoadingButton } from '@mui/lab';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Avatar,
|
|
||||||
Button,
|
|
||||||
ButtonGroup,
|
|
||||||
Card,
|
|
||||||
FormHelperText,
|
|
||||||
Grid,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
TextField,
|
|
||||||
Chip,
|
|
||||||
} from '@mui/material';
|
|
||||||
|
|
||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
|
||||||
|
|
||||||
// components
|
|
||||||
import {
|
|
||||||
FormProvider,
|
|
||||||
RHFTextField,
|
|
||||||
RHFRadioGroup,
|
|
||||||
RHFUploadAvatar,
|
|
||||||
RHFSwitch,
|
|
||||||
RHFEditor,
|
|
||||||
RHFDatepicker,
|
|
||||||
RHFMultiCheckbox,
|
|
||||||
RHFCheckbox,
|
|
||||||
RHFCustomMultiCheckbox,
|
|
||||||
} from '../../../components/hook-form';
|
|
||||||
import axios from '../../../utils/axios';
|
|
||||||
import { fCurrency } from '../../../utils/formatNumber';
|
|
||||||
import { Practitioner } from '../../../@types/doctor';
|
|
||||||
|
|
||||||
import { Label, Rowing } from '@mui/icons-material';
|
|
||||||
|
|
||||||
const LabelStyle = styled(Typography)(({ theme }) => ({
|
|
||||||
...theme.typography.subtitle2,
|
|
||||||
color: theme.palette.text.secondary,
|
|
||||||
marginBottom: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
|
||||||
paddingBottom: theme.spacing(5),
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Title = styled(Typography)(({ theme }) => ({
|
|
||||||
...theme.typography.h4,
|
|
||||||
boxShadow: 'none',
|
|
||||||
// paddingBottom: theme.spacing(3),
|
|
||||||
fontWeight: 700,
|
|
||||||
color: '#005B7F',
|
|
||||||
}));
|
|
||||||
|
|
||||||
interface FormValuesProps extends Partial<Practitioner> {
|
|
||||||
taxes: boolean;
|
|
||||||
inStock: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
isEdit: boolean;
|
|
||||||
currentPractitioner?: Practitioner;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Span = styled(Typography)(({ theme }) => ({
|
|
||||||
boxShadow: 'none',
|
|
||||||
paddingBottom: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Text = styled(Typography)(({ theme }) => ({
|
|
||||||
boxShadow: 'none',
|
|
||||||
paddingBottom: theme.spacing(3),
|
|
||||||
}));
|
|
||||||
|
|
||||||
export default function PractitionerForm({ isEdit, currentPractitioner }: Props) {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const [practitioner_group, setPractitionerGroups] = useState([]);
|
|
||||||
|
|
||||||
// const [ errors, setErrors ] = useState<{ [key: string]: string }>({});
|
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
|
|
||||||
const NewCorporateSchema = Yup.object().shape({
|
|
||||||
name: Yup.string().required('Name is required'),
|
|
||||||
// file: Yup.boolean().required('Corporate Status is required'),
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultValues = useMemo(
|
|
||||||
() => ({
|
|
||||||
id: currentPractitioner?.id,
|
|
||||||
name: currentPractitioner?.name || '',
|
|
||||||
address: currentPractitioner?.address || '',
|
|
||||||
birth_date: currentPractitioner?.birth_date || '',
|
|
||||||
gender: currentPractitioner?.gender || '',
|
|
||||||
description: currentPractitioner?.description || '',
|
|
||||||
birth_place: currentPractitioner?.birth_place || '',
|
|
||||||
active: currentPractitioner?.active === 1 ? true : false,
|
|
||||||
avatar_url: currentPractitioner?.avatar_url || '',
|
|
||||||
doctor_id: currentPractitioner?.doctor_id || '',
|
|
||||||
organizations: currentPractitioner?.organizations || [],
|
|
||||||
specialities: currentPractitioner?.specialities || [],
|
|
||||||
}),
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
[currentPractitioner]
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('defaultValues', defaultValues);
|
|
||||||
|
|
||||||
function StatusLabel({ value }: { value: boolean }) {
|
|
||||||
return (
|
|
||||||
<Chip
|
|
||||||
label={value ? 'Aktif' : 'Tidak Aktif'}
|
|
||||||
size="medium"
|
|
||||||
sx={{
|
|
||||||
backgroundColor: value ? 'rgba(84, 214, 44, 0.16)' : 'rgba(255, 72, 66, 0.16)',
|
|
||||||
color: value ? '#229A16' : '#B72136',
|
|
||||||
padding: '1 8 1 8 px',
|
|
||||||
borderRadius: '4px',
|
|
||||||
fontSize: '12px',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const methods = useForm<FormValuesProps>({
|
|
||||||
resolver: yupResolver(NewCorporateSchema),
|
|
||||||
defaultValues,
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
reset,
|
|
||||||
watch,
|
|
||||||
control,
|
|
||||||
setValue,
|
|
||||||
getValues,
|
|
||||||
setError,
|
|
||||||
handleSubmit,
|
|
||||||
formState: { isSubmitting },
|
|
||||||
} = methods;
|
|
||||||
|
|
||||||
const values = watch();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isEdit && currentPractitioner) {
|
|
||||||
reset(defaultValues);
|
|
||||||
}
|
|
||||||
if (!isEdit) {
|
|
||||||
reset(defaultValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [isEdit, currentPractitioner]);
|
|
||||||
|
|
||||||
const handleActivate = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
setValue('active', event.target.checked);
|
|
||||||
|
|
||||||
console.log('event.target.checked', event.target.checked);
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('active', event.target.checked ? '1' : '0');
|
|
||||||
formData.append('_method', 'PUT');
|
|
||||||
axios.post('/doctors/' + currentPractitioner?.id ?? '', formData);
|
|
||||||
|
|
||||||
enqueueSnackbar('active Updated Successfully!', { variant: 'success' });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormProvider methods={methods}>
|
|
||||||
<Stack spacing={3}>
|
|
||||||
<Box sx={{ width: '100%' }}>
|
|
||||||
{/* <Stack spacing={3}> */}
|
|
||||||
<Card sx={{ p: 5 }}>
|
|
||||||
<HeaderStyle>
|
|
||||||
<Grid item xs={6} md={6}>
|
|
||||||
<Title>Data Dokter</Title>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6} md={6}>
|
|
||||||
{/* <Typography>Status Rumah Sakit</Typography> */}
|
|
||||||
<RHFSwitch name="active" label="" onClick={handleActivate} />
|
|
||||||
<StatusLabel value={values.active} />
|
|
||||||
</Grid>
|
|
||||||
</HeaderStyle>
|
|
||||||
<Title variant="h5">Informasi Umum</Title>
|
|
||||||
<Avatar
|
|
||||||
alt="Remy Sharp"
|
|
||||||
src={currentPractitioner?.avatar_url}
|
|
||||||
sx={{ width: 120, height: 120, marginBottom: 2 }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Grid item xs={7}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Nama Dokter</Span>
|
|
||||||
<Text>{currentPractitioner?.name ? currentPractitioner?.name : '-'}</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>No Telp</Span>
|
|
||||||
<Text>{currentPractitioner?.phone ? currentPractitioner?.phone : '-'}</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tempat Lahir</Span>
|
|
||||||
<Text>
|
|
||||||
{currentPractitioner?.birth_place ? currentPractitioner?.birth_place : '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Alamat</Span>
|
|
||||||
<Text>{currentPractitioner?.address ? currentPractitioner?.address : '-'}</Text>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={5} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Jenis Kelamin</Span>
|
|
||||||
<Text>{currentPractitioner?.gender ? currentPractitioner?.gender : '-'}</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Email</Span>
|
|
||||||
<Text>{currentPractitioner?.email ? currentPractitioner?.email : '-'}</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Lahir</Span>
|
|
||||||
<Text>
|
|
||||||
{currentPractitioner?.birth_date ? currentPractitioner?.birth_date : '-'}
|
|
||||||
</Text>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Card>
|
|
||||||
<Card sx={{ p: 5, marginTop: 2 }}>
|
|
||||||
<Title variant="h5">Tempat Praktik</Title>
|
|
||||||
{currentPractitioner?.organizations?.map((item, index) => (
|
|
||||||
<Box key={index} sx={{ mt: 3 }}>
|
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Grid item xs={7}>
|
|
||||||
<Text>{item.name}</Text>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
<Card sx={{ p: 5, marginTop: 2 }}>
|
|
||||||
<Title variant="h5">Spesialisasi</Title>
|
|
||||||
{currentPractitioner?.specialities?.map((item, index) => (
|
|
||||||
<Box key={index} sx={{ mt: 3 }}>
|
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Grid item xs={7}>
|
|
||||||
<Text>{item.name}</Text>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
</FormProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { paramCase } from 'change-case';
|
|
||||||
import { useParams, useLocation } from 'react-router-dom';
|
|
||||||
// @mui
|
|
||||||
import { Container, Stack } from '@mui/material';
|
|
||||||
import useSettings from '../../../hooks/useSettings';
|
|
||||||
import Page from '../../../components/Page';
|
|
||||||
import View from './View';
|
|
||||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
|
||||||
import axios from '../../../utils/axios';
|
|
||||||
import { Appointment } from '../../../@types/doctor';
|
|
||||||
|
|
||||||
export default function Create() {
|
|
||||||
const { themeStretch } = useSettings();
|
|
||||||
const { id } = useParams();
|
|
||||||
|
|
||||||
const isEdit = id ? true : false;
|
|
||||||
|
|
||||||
const [currentAppointment, setCurrentAppointment] = useState<Appointment>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isEdit) {
|
|
||||||
axios.get('/appointments/' + id).then((res) => {
|
|
||||||
setCurrentAppointment(res.data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [id]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Page title="Appointment">
|
|
||||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
|
||||||
<Stack direction="row" alignItems="center">
|
|
||||||
<HeaderBreadcrumbs
|
|
||||||
heading={!isEdit ? 'Appointment' : 'Appointment'}
|
|
||||||
links={[
|
|
||||||
{ name: 'Report', href: '/report' },
|
|
||||||
{
|
|
||||||
name: 'Appointments',
|
|
||||||
href: '/report/appointments',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<View
|
|
||||||
// isSubmitting={isSubmitting}
|
|
||||||
isEdit={isEdit}
|
|
||||||
currentAppointment={currentAppointment}
|
|
||||||
/>
|
|
||||||
</Container>
|
|
||||||
</Page>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
import * as Yup from 'yup';
|
|
||||||
import { useSnackbar } from 'notistack';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
|
||||||
|
|
||||||
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
// form
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
|
||||||
// @mui
|
|
||||||
import { styled } from '@mui/material/styles';
|
|
||||||
import { LoadingButton } from '@mui/lab';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Avatar,
|
|
||||||
Button,
|
|
||||||
ButtonGroup,
|
|
||||||
Card,
|
|
||||||
FormHelperText,
|
|
||||||
Grid,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
TextField,
|
|
||||||
Chip,
|
|
||||||
Badge,
|
|
||||||
Divider,
|
|
||||||
} from '@mui/material';
|
|
||||||
|
|
||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
|
||||||
|
|
||||||
// components
|
|
||||||
import {
|
|
||||||
FormProvider,
|
|
||||||
RHFTextField,
|
|
||||||
RHFRadioGroup,
|
|
||||||
RHFUploadAvatar,
|
|
||||||
RHFSwitch,
|
|
||||||
RHFEditor,
|
|
||||||
RHFDatepicker,
|
|
||||||
RHFMultiCheckbox,
|
|
||||||
RHFCheckbox,
|
|
||||||
RHFCustomMultiCheckbox,
|
|
||||||
} from '../../../components/hook-form';
|
|
||||||
import axios from '../../../utils/axios';
|
|
||||||
import { fCurrency } from '../../../utils/formatNumber';
|
|
||||||
import { Appointment } from '../../../@types/doctor';
|
|
||||||
|
|
||||||
import { Label, Rowing, Spa } from '@mui/icons-material';
|
|
||||||
import { border } from '@mui/system';
|
|
||||||
|
|
||||||
const LabelStyle = styled(Typography)(({ theme }) => ({
|
|
||||||
...theme.typography.subtitle2,
|
|
||||||
color: theme.palette.text.secondary,
|
|
||||||
marginBottom: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
|
||||||
paddingBottom: theme.spacing(5),
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Title = styled(Typography)(({ theme }) => ({
|
|
||||||
...theme.typography.h4,
|
|
||||||
boxShadow: 'none',
|
|
||||||
// paddingBottom: theme.spacing(3),
|
|
||||||
fontWeight: 700,
|
|
||||||
color: '#005B7F',
|
|
||||||
}));
|
|
||||||
|
|
||||||
interface FormValuesProps extends Partial<Appointment> {
|
|
||||||
taxes: boolean;
|
|
||||||
inStock: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
isEdit: boolean;
|
|
||||||
currentAppointment?: Appointment;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Span = styled(Typography)(({ theme }) => ({
|
|
||||||
boxShadow: 'none',
|
|
||||||
paddingBottom: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Text = styled(Typography)(({ theme }) => ({
|
|
||||||
boxShadow: 'none',
|
|
||||||
paddingBottom: theme.spacing(3),
|
|
||||||
}));
|
|
||||||
|
|
||||||
export default function AppointmentForm({ isEdit, currentAppointment }: Props) {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
// const [ errors, setErrors ] = useState<{ [key: string]: string }>({});
|
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
|
|
||||||
const NewCorporateSchema = Yup.object().shape({
|
|
||||||
name: Yup.string().required('Name is required'),
|
|
||||||
// file: Yup.boolean().required('Corporate Status is required'),
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultValues = useMemo(
|
|
||||||
() => ({
|
|
||||||
id: currentAppointment?.id,
|
|
||||||
name: currentAppointment?.name || '',
|
|
||||||
address: currentAppointment?.address || '',
|
|
||||||
birth_date: currentAppointment?.birth_date || '',
|
|
||||||
gender: currentAppointment?.gender || '',
|
|
||||||
description: currentAppointment?.description || '',
|
|
||||||
birth_place: currentAppointment?.birth_place || '',
|
|
||||||
active: currentAppointment?.active === 1 ? true : false,
|
|
||||||
avatar_url: currentAppointment?.avatar_url || '',
|
|
||||||
doctor_id: currentAppointment?.doctor_id || '',
|
|
||||||
organizations: currentAppointment?.organizations || [],
|
|
||||||
specialities: currentAppointment?.specialities || [],
|
|
||||||
}),
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
[currentAppointment]
|
|
||||||
);
|
|
||||||
|
|
||||||
const methods = useForm<FormValuesProps>({
|
|
||||||
resolver: yupResolver(NewCorporateSchema),
|
|
||||||
defaultValues,
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
reset,
|
|
||||||
watch,
|
|
||||||
control,
|
|
||||||
setValue,
|
|
||||||
getValues,
|
|
||||||
setError,
|
|
||||||
handleSubmit,
|
|
||||||
formState: { isSubmitting },
|
|
||||||
} = methods;
|
|
||||||
|
|
||||||
const values = watch();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isEdit && currentAppointment) {
|
|
||||||
reset(defaultValues);
|
|
||||||
}
|
|
||||||
if (!isEdit) {
|
|
||||||
reset(defaultValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [isEdit, currentAppointment]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormProvider methods={methods}>
|
|
||||||
<Stack spacing={3}>
|
|
||||||
<Box sx={{ width: '100%' }}>
|
|
||||||
{/* <Stack spacing={3}> */}
|
|
||||||
<Card sx={{ p: 5 }}>
|
|
||||||
<HeaderStyle>
|
|
||||||
<Grid item xs={6} md={6}>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
divider={<Divider orientation="vertical" flexItem />}
|
|
||||||
spacing={2}
|
|
||||||
>
|
|
||||||
<Title>Data Appointment</Title>
|
|
||||||
<Chip label={currentAppointment?.status} variant="outlined" />
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
</HeaderStyle>
|
|
||||||
|
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Grid item xs={12}>
|
|
||||||
<Stack direction="row" spacing={2}>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
<Stack direction="row" spacing={2}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Booking :</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.date_created ? currentAppointment?.date_created : '-'}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
<Stack direction="row" spacing={2}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Appointment :</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.date_appointment
|
|
||||||
? currentAppointment?.date_appointment
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Nama Dokter</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.doctor_name ? currentAppointment?.doctor_name : '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Faskes</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.health_care ? currentAppointment?.health_care : '-'}
|
|
||||||
</Text>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Spesialis</Span>
|
|
||||||
<Text>{currentAppointment?.speciality ? currentAppointment?.speciality : '-'}</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Appointment Via Web/App</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.appointment_media
|
|
||||||
? currentAppointment?.appointment_media
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Card>
|
|
||||||
<Card sx={{ mt: 5, p: 5 }}>
|
|
||||||
<HeaderStyle>
|
|
||||||
<Grid item xs={6} md={6}>
|
|
||||||
<Title>Data Pembayaran</Title>
|
|
||||||
</Grid>
|
|
||||||
</HeaderStyle>
|
|
||||||
|
|
||||||
{currentAppointment?.payment_detail !== null ? (
|
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Grid item xs={6}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Metode Pembayaran</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_method ? currentAppointment?.payment_method : '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Harga</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_detail?.gross_amount
|
|
||||||
? currentAppointment?.payment_detail?.gross_amount
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Mata Uang</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_detail?.currency
|
|
||||||
? currentAppointment?.payment_detail?.currency
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={6} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tipe Pembayaran</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_detail?.payment_type
|
|
||||||
? currentAppointment?.payment_detail?.payment_type
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Waktu Transaksi</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_detail?.transaction_time
|
|
||||||
? currentAppointment?.payment_detail?.transaction_time
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Status</Span>
|
|
||||||
<Text>
|
|
||||||
{currentAppointment?.payment_detail?.status_message
|
|
||||||
? currentAppointment?.payment_detail?.status_message
|
|
||||||
: '-'}
|
|
||||||
</Text>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
) : (
|
|
||||||
<Span>Belum ada pembayaran</Span>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
</FormProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ import VerifyCode from '../pages/auth/VerifyCode';
|
|||||||
import { AuthProvider } from '../contexts/LaravelAuthContext';
|
import { AuthProvider } from '../contexts/LaravelAuthContext';
|
||||||
import AuthGuard from '../guards/AuthGuard';
|
import AuthGuard from '../guards/AuthGuard';
|
||||||
import { Link, useParams, useSearchParams } from 'react-router-dom';
|
import { Link, useParams, useSearchParams } from 'react-router-dom';
|
||||||
import Prescription from '@/pages/Report/Prescription/Index';
|
|
||||||
import DoctorRating from '@/pages/Report/DoctorRating_v2/Index';
|
import DoctorRating from '@/pages/Report/DoctorRating_v2/Index';
|
||||||
import KatalogDokter from '@/pages/Report/KatalogDokter/Index';
|
import KatalogDokter from '@/pages/Report/KatalogDokter/Index';
|
||||||
|
|
||||||
@@ -460,7 +459,14 @@ export default function Router() {
|
|||||||
path: 'report/phr',
|
path: 'report/phr',
|
||||||
element: <RiwayatMedisPeserta />,
|
element: <RiwayatMedisPeserta />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'report/prescription',
|
||||||
|
element: <Prescription/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'report/rujukan',
|
||||||
|
element: <RujukanPasien/>,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'claims',
|
path: 'claims',
|
||||||
element: <Claims />,
|
element: <Claims />,
|
||||||
@@ -727,6 +733,8 @@ const EPrescriptionShow = Loadable(lazy(() => import('../pages/EPrescription/Liv
|
|||||||
const LinksehatPayment = Loadable(lazy(() => import('../pages/Report/LinksehatPayments/Index')));
|
const LinksehatPayment = Loadable(lazy(() => import('../pages/Report/LinksehatPayments/Index')));
|
||||||
|
|
||||||
const RiwayatMedisPeserta = Loadable(lazy(() => import('../pages/Report/RiwayatMedisPeserta/Index')));
|
const RiwayatMedisPeserta = Loadable(lazy(() => import('../pages/Report/RiwayatMedisPeserta/Index')));
|
||||||
|
const RujukanPasien = Loadable(lazy(() => import('../pages/Report/Rujukan/Index')));
|
||||||
|
const Prescription = Loadable(lazy(() => import('../pages/Report/Prescription/Index')));
|
||||||
|
|
||||||
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
||||||
|
|
||||||
|
|||||||
BIN
public/files/Report-Resep-Online.xlsx
Normal file
BIN
public/files/Report-Resep-Online.xlsx
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user