finishing part 1
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\ClaimDailyMonitoring;
|
||||
use App\Models\DailyMonitoring;
|
||||
use App\Models\MedicalPlan;
|
||||
use DB;
|
||||
use Exception;
|
||||
@@ -98,7 +98,7 @@ class DailyMonitoringController extends Controller
|
||||
->where('claim_request_id', empty($claim_request)==false ? $claim_request->id : '')
|
||||
->first();
|
||||
|
||||
$detail_list = ClaimDailyMonitoring::where('claim_id', empty($claim) == false ? $claim->id : '')->orderBy("created_at", "desc")->get()->makeHidden(['updated_at']);
|
||||
$detail_list = DailyMonitoring::where('claim_id', empty($claim) == false ? $claim->id : '')->orderBy("created_at", "desc")->get()->makeHidden(['updated_at']);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
@@ -153,7 +153,7 @@ class DailyMonitoringController extends Controller
|
||||
|
||||
try {
|
||||
// insert claim daily monitoring
|
||||
$db_response = ClaimDailyMonitoring::create([
|
||||
$db_response = DailyMonitoring::create([
|
||||
'claim_id' => $claim->id,
|
||||
'subject' => $request->subject,
|
||||
'sistole' => $request->sistole,
|
||||
@@ -164,6 +164,27 @@ class DailyMonitoringController extends Controller
|
||||
'complaints' => $request->complaints,
|
||||
]);
|
||||
|
||||
// cek medical plan
|
||||
$num_medical_plan = 0;
|
||||
|
||||
foreach ($request->medical_plan as $row) {
|
||||
if ($row['medical_plan_str']) {
|
||||
$num_medical_plan++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_medical_plan == 0) {
|
||||
DB::rollBack();
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => [
|
||||
'medical_plan' => ['medical plan harus diisi']
|
||||
],
|
||||
'data' => []
|
||||
],400);
|
||||
}
|
||||
|
||||
// insert medical plan
|
||||
foreach ($request->medical_plan as $row) {
|
||||
MedicalPlan::create([
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\LaboratoriumResult;
|
||||
use App\Models\MedicalPlan;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
/**
|
||||
* Bagaskoro BSD 28-10-2023
|
||||
*
|
||||
* Controller untuk laboratorium result
|
||||
*/
|
||||
class LaboratoriumResultController extends Controller
|
||||
{
|
||||
protected $path_for_store = 'public/lab_result';
|
||||
|
||||
protected function messages()
|
||||
{
|
||||
return [
|
||||
'required' => ':attribute harus diisi',
|
||||
'integer' => ':attribute harus angka',
|
||||
'unique' => ':attribute (:input) sudah ada',
|
||||
'max' => ':attribute maximal :max karakter',
|
||||
'exists' => ':attribute (:input) tidak ditemukan',
|
||||
'numeric' => ':attribute harus angka',
|
||||
'digits_between'=> ':attribute maximal :max digit minimal :min digit'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail Lab Result List - by claim_code
|
||||
*/
|
||||
public function GetDetailLabResultList(Request $request, $claim_code)
|
||||
{
|
||||
// get claim request
|
||||
$claim_request = DB::table('claim_requests')
|
||||
->select('id')
|
||||
->where('code', $claim_code)
|
||||
->first();
|
||||
|
||||
// get claim
|
||||
$claim = DB::table('claims')
|
||||
->select('id')
|
||||
->where('claim_request_id', empty($claim_request)==false ? $claim_request->id : '')
|
||||
->first();
|
||||
|
||||
$detail_list = LaboratoriumResult::where('claim_id', empty($claim) == false ? $claim->id : '')->orderBy("created_at", "desc")->get()->makeHidden(['updated_at']);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => [
|
||||
'lab_result_list'=> $detail_list,
|
||||
]
|
||||
],200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Detail Lab Result List
|
||||
*/
|
||||
public function AddDetailLabResultList(Request $request, $claim_code)
|
||||
{
|
||||
$request->merge(['claim_code' => $claim_code]);
|
||||
|
||||
// validation rule
|
||||
$validator = Validator::make($request->all(),[
|
||||
'claim_code' => 'required|exists:claim_requests,code',
|
||||
'date' => 'required',
|
||||
'location' => 'required',
|
||||
'examination' => 'required',
|
||||
'lab_result_file' => 'required',
|
||||
],$this->messages());
|
||||
|
||||
// validation error
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $validator->getMessageBag()
|
||||
],400);
|
||||
}
|
||||
|
||||
// get claim request
|
||||
$claim_request = DB::table('claim_requests')
|
||||
->select('id')
|
||||
->where('code', $claim_code)
|
||||
->first();
|
||||
|
||||
// get claim
|
||||
$claim = DB::table('claims')
|
||||
->select('id')
|
||||
->where('claim_request_id', $claim_request->id)
|
||||
->first();
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
// insert lab result
|
||||
$db_response = LaboratoriumResult::create([
|
||||
'claim_id' => $claim->id,
|
||||
'date' => $request->date,
|
||||
'location' => $request->location,
|
||||
'examination' => $request->examination,
|
||||
]);
|
||||
|
||||
// insert file result
|
||||
foreach ($request->lab_result_file as $file) {
|
||||
$name = 'labresult-' . uniqid();
|
||||
$extension= $file->getClientOriginalExtension();
|
||||
$fileName = $name . '.' . $extension;
|
||||
|
||||
File::create([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $db_response->id,
|
||||
'type' => 'laboratorium-result',
|
||||
'name' => $name,
|
||||
'original_name' => $fileName,
|
||||
'extension' => $extension,
|
||||
'path' => '',
|
||||
]);
|
||||
|
||||
$file->storeAs($this->path_for_store, $fileName);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => "success",
|
||||
'data' => []
|
||||
],200);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage(),
|
||||
'data' => []
|
||||
],500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ use Modules\Internal\Http\Controllers\Api\SpecialityController;
|
||||
use Modules\Internal\Http\Controllers\Api\VillageController;
|
||||
use Modules\Internal\Http\Controllers\Api\AuditTrailController;
|
||||
use Modules\Internal\Http\Controllers\Api\DailyMonitoringController;
|
||||
use Modules\Internal\Http\Controllers\Api\LaboratoriumResultController;
|
||||
use Modules\Internal\Http\Controllers\ClaimEncounterController;
|
||||
|
||||
/*
|
||||
@@ -149,12 +150,20 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('audittrail/{corporate_id}', [AuditTrailController::class, 'index']);
|
||||
|
||||
Route::prefix('case_management')->group(function () {
|
||||
Route::get('memberlist', [DailyMonitoringController::class, 'GetMemberList']);
|
||||
Route::get('claimlist/{member_id}', [DailyMonitoringController::class, 'GetClaimList']);
|
||||
|
||||
// Daily Monitoring
|
||||
Route::prefix('daily_monitoring')->group(function () {
|
||||
Route::get('memberlist', [DailyMonitoringController::class, 'GetMemberList']);
|
||||
Route::get('claimlist/{member_id}', [DailyMonitoringController::class, 'GetClaimList']);
|
||||
Route::get('detail/{claim_code}/list', [DailyMonitoringController::class, 'GetDetailMonitoringList']);
|
||||
Route::post('detail/{claim_code}/add', [DailyMonitoringController::class, 'AddDetailMonitoringList']);
|
||||
});
|
||||
|
||||
// Laboratorium Result
|
||||
Route::prefix('laboratorium_result')->group(function () {
|
||||
Route::get('detail/{claim_code}/list', [LaboratoriumResultController::class, 'GetDetailLabResultList']);
|
||||
Route::post('detail/{claim_code}/add', [LaboratoriumResultController::class, 'AddDetailLabResultList']);
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('master/diagnosis-template', [DiagnosisTemplateController::class, 'index']);
|
||||
|
||||
@@ -6,7 +6,7 @@ use DB;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClaimDailyMonitoring extends Model
|
||||
class DailyMonitoring extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -51,7 +51,9 @@ class ClaimDailyMonitoring extends Model
|
||||
$medical_plan = DB::table('medical_plan')->where('claim_daily_monitoring_id','=',$this->attributes['id'])->get();
|
||||
|
||||
foreach ($medical_plan as $row) {
|
||||
$arr_medical_plan[] = $row->plan;
|
||||
$arr_medical_plan[] = [
|
||||
'medical_plan_str' => $row->plan
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_medical_plan;
|
||||
39
app/Models/LaboratoriumResult.php
Normal file
39
app/Models/LaboratoriumResult.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LaboratoriumResult extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "laboratorium_result";
|
||||
protected $fillable = [
|
||||
'claim_id',
|
||||
'date',
|
||||
'location',
|
||||
'examination',
|
||||
];
|
||||
|
||||
protected $appends = ['lab_result_file'];
|
||||
protected $path_for_public = 'storage/lab_result';
|
||||
|
||||
public function getLabResultFileAttribute()
|
||||
{
|
||||
$arr_files = [];
|
||||
$files = DB::table('files')->select('name','original_name','path','extension')->where("type","=","laboratorium-result")->where('fileable_id','=',$this->attributes['id'])->get();
|
||||
|
||||
foreach ($files as $row) {
|
||||
$row->path = url($this->path_for_public . "/" . $row->original_name);
|
||||
|
||||
$arr_files[] = [
|
||||
'lab_result_file_obj' => $row
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_files;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('laboratorium_result', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->integer('claim_id');
|
||||
$table->string('date');
|
||||
$table->text('location');
|
||||
$table->text('examination');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('laboratorium_result');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
// form
|
||||
import { useFormContext, Controller } from 'react-hook-form';
|
||||
// @mui
|
||||
import { FormHelperText, TextField } from '@mui/material';
|
||||
import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
|
||||
import AdapterDateFns from '@mui/lab/AdapterDateFns';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
interface IProps {
|
||||
name: string;
|
||||
label: string;
|
||||
dateFormat: string;
|
||||
fullWidth?: boolean;
|
||||
minDate?: any;
|
||||
maxDate?: any;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export default function RHFDatePickerV2({ name, label, dateFormat, minDate, maxDate, disabled, ...other }: IProps) {
|
||||
const { control } = useFormContext();
|
||||
|
||||
const { fullWidth } = other;
|
||||
|
||||
return (
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<Controller
|
||||
name={name}
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<>
|
||||
<DesktopDatePicker
|
||||
disabled={disabled}
|
||||
label={label}
|
||||
onChange={(date) => field.onChange(date)}
|
||||
inputFormat={dateFormat}
|
||||
value={field.value}
|
||||
mask={''}
|
||||
minDate={(minDate) ? new Date(minDate) : null}
|
||||
maxDate={(maxDate) ? new Date(maxDate) : null}
|
||||
renderInput={(params) => <TextField fullWidth={fullWidth} {...params} />}
|
||||
/>
|
||||
{!!error && (
|
||||
<FormHelperText error sx={{ px: 2 }}>
|
||||
{error.message}
|
||||
</FormHelperText>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import RemoveIcon from '@mui/icons-material/Remove';
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { AddClaimDetail } from '../Model/Functions';
|
||||
import { AddMonitoringDetail } from '../Model/Functions';
|
||||
import { DetailMonitoringListType} from '../Model/Types';
|
||||
|
||||
export default function DetailMonitoringList() {
|
||||
@@ -36,7 +36,10 @@ export default function DetailMonitoringList() {
|
||||
|
||||
// setup form
|
||||
// ====================================
|
||||
const defaultValues: any = {
|
||||
const defaultValues: DetailMonitoringListType = {
|
||||
id : '',
|
||||
claim_code : '',
|
||||
claim_id : '',
|
||||
subject : '',
|
||||
body_temperature: '',
|
||||
sistole : '',
|
||||
@@ -46,7 +49,8 @@ export default function DetailMonitoringList() {
|
||||
analysis : '',
|
||||
medical_plan : [{
|
||||
medical_plan_str: ''
|
||||
}]
|
||||
}],
|
||||
created_at : ''
|
||||
};
|
||||
|
||||
const methods = useForm<any>({
|
||||
@@ -62,7 +66,7 @@ export default function DetailMonitoringList() {
|
||||
const submitHandler = async (data: DetailMonitoringListType) => {
|
||||
console.log(claim_code);
|
||||
|
||||
const response = await AddClaimDetail(claim_code??'', data);
|
||||
const response = await AddMonitoringDetail(claim_code??'', data);
|
||||
|
||||
if (response == true) {
|
||||
reset();
|
||||
@@ -71,7 +75,7 @@ export default function DetailMonitoringList() {
|
||||
|
||||
return (
|
||||
<Page title={pageTitle}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', pl: '12px', mb: '40px' }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', pl: '22px', mb: '40px' }}>
|
||||
<IconButton size='large' color='inherit' onClick={() => navigate(`/case_management/daily_monitoring/${member_id}/claims`)} >
|
||||
<ArrowBackIosNew/>
|
||||
</IconButton>
|
||||
|
||||
@@ -28,7 +28,7 @@ import FiberManualRecord from '@mui/icons-material/FiberManualRecord';
|
||||
* ============================================
|
||||
*/
|
||||
import { fDate } from "@/utils/formatTime";
|
||||
import { AddClaimDetail, getClaimDetailList } from '../Model/Functions';
|
||||
import { getMonitoringDetailList } from '../Model/Functions';
|
||||
import { DetailMonitoringListType } from '../Model/Types';
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function DetailMonitoringList() {
|
||||
// Load Data
|
||||
// -------------------
|
||||
const loadDataTableData = async () => {
|
||||
const response = await getClaimDetailList(claim_code??'');
|
||||
const response = await getMonitoringDetailList(claim_code??'');
|
||||
|
||||
setDetailMonitoringList(response);
|
||||
}
|
||||
@@ -215,10 +215,10 @@ export default function DetailMonitoringList() {
|
||||
<Grid item xs={12}>
|
||||
<List sx={{ color: 'GrayText' }}>
|
||||
{
|
||||
row.medical_plan.map((str, index) => {
|
||||
row.medical_plan.map((data, index) => {
|
||||
return (
|
||||
<ListItem key={index}>
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} /> {str}
|
||||
<FiberManualRecord sx={{ fontSize: '8px', mr: '10px' }} /> {data.medical_plan_str}
|
||||
</ListItem>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ import { DailyMonitoringListType, DetailMonitoringListType, ResponseListingClaim
|
||||
* Listing Daily Monitoring
|
||||
*/
|
||||
export const getDailyMonitoringList = async ( ): Promise<DailyMonitoringListType[]> => {
|
||||
const response = await axios.get('/case_management/daily_monitoring/memberlist')
|
||||
const response = await axios.get('/case_management/memberlist')
|
||||
.then((res) =>{
|
||||
return res.data.data.member_list;
|
||||
})
|
||||
@@ -25,7 +25,7 @@ export const getDailyMonitoringList = async ( ): Promise<DailyMonitoringListTyp
|
||||
* Listing Claim
|
||||
*/
|
||||
export const getClaimList = async ( member_id: string ): Promise<ResponseListingClaimType> => {
|
||||
const response = await axios.get(`/case_management/daily_monitoring/claimlist/${member_id}`)
|
||||
const response = await axios.get(`/case_management/claimlist/${member_id}`)
|
||||
.then((res) =>{
|
||||
return res.data.data;
|
||||
})
|
||||
@@ -41,9 +41,9 @@ export const getClaimList = async ( member_id: string ): Promise<ResponseListing
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Claim Detail
|
||||
* Add Monitoring Detail
|
||||
*/
|
||||
export const AddClaimDetail = async ( claim_code: string,data: DetailMonitoringListType ): Promise<boolean> => {
|
||||
export const AddMonitoringDetail = async ( claim_code: string,data: DetailMonitoringListType ): Promise<boolean> => {
|
||||
const response = await axios.post(`/case_management/daily_monitoring/detail/${claim_code}/add`, {
|
||||
...data
|
||||
})
|
||||
@@ -77,9 +77,9 @@ export const AddClaimDetail = async ( claim_code: string,data: DetailMonitoringL
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Claim Detail List
|
||||
* Get Monitoring Detail List
|
||||
*/
|
||||
export const getClaimDetailList = async ( claim_code: string ): Promise<DetailMonitoringListType[]> => {
|
||||
export const getMonitoringDetailList = async ( claim_code: string ): Promise<DetailMonitoringListType[]> => {
|
||||
const response = await axios.get(`/case_management/daily_monitoring/detail/${claim_code}/list`)
|
||||
.then((res) =>{
|
||||
return res.data.data.detail_list;
|
||||
|
||||
@@ -39,7 +39,7 @@ export type ClaimListType = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail Claim
|
||||
* Detail Monitoring List
|
||||
*/
|
||||
export type DetailMonitoringListType = {
|
||||
id : string|null,
|
||||
@@ -52,6 +52,10 @@ export type DetailMonitoringListType = {
|
||||
diastole : string
|
||||
analysis : string,
|
||||
complaints : string,
|
||||
medical_plan : string[],
|
||||
medical_plan : MedicalPlanStrType[],
|
||||
created_at : string|null
|
||||
}
|
||||
|
||||
export type MedicalPlanStrType = {
|
||||
medical_plan_str: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import { useRef } from 'react';
|
||||
import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, IconButton, Typography, Grid, Card, Button, ButtonBase, Stack } from '@mui/material';
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
|
||||
/**
|
||||
* Components
|
||||
* ============================================
|
||||
*/
|
||||
import Page from '@/components/Page';
|
||||
import { FormProvider, RHFDatepicker, RHFTextField } from '@/components/hook-form';
|
||||
import RHFDatePickerV2 from '@/components/hook-form/RHFDatePickerV2';
|
||||
|
||||
/**
|
||||
* Icon
|
||||
* ============================================
|
||||
*/
|
||||
import ArrowBackIosNew from '@mui/icons-material/ArrowBackIosNew';
|
||||
import Iconify from '@/components/Iconify';
|
||||
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
||||
|
||||
/**
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { AddLabResultDetail } from '../Model/Functions';
|
||||
import { DetailLabResultListType} from '../Model/Types';
|
||||
|
||||
export default function DetailMonitoringList() {
|
||||
const { member_id, claim_code } = useParams();
|
||||
const navigate = useNavigate()
|
||||
const pageTitle = claim_code??'_ _ _ _';
|
||||
const fileInput = useRef<HTMLInputElement>(null);
|
||||
|
||||
// setup form
|
||||
// ====================================
|
||||
const defaultValues: DetailLabResultListType = {
|
||||
id : '',
|
||||
claim_id : '',
|
||||
claim_code : '',
|
||||
date : '',
|
||||
location : '',
|
||||
examination : '',
|
||||
lab_result_file : [],
|
||||
created_at : ''
|
||||
};
|
||||
|
||||
const methods = useForm<any>({
|
||||
defaultValues
|
||||
});
|
||||
|
||||
const { handleSubmit, reset, watch, setValue, formState: { isDirty, isSubmitting } } = methods;
|
||||
const formValues = watch();
|
||||
|
||||
// Handle File Input
|
||||
// =====================================
|
||||
const handleInputChange = (event: any) => {
|
||||
if (event.target.files[0]) {
|
||||
|
||||
let arr_lab_result_file = formValues.lab_result_file;
|
||||
arr_lab_result_file.push(event.target.files[0]);
|
||||
|
||||
setValue('lab_result_file', arr_lab_result_file)
|
||||
}
|
||||
else {
|
||||
console.log('NO FILE');
|
||||
}
|
||||
};
|
||||
|
||||
// Handle Remove File
|
||||
// =====================================
|
||||
const handleRemoveFile = (target_index: number) => {
|
||||
let arr_lab_result_file = formValues.lab_result_file.filter((file: any, index: number) =>{
|
||||
if (target_index !== index) {
|
||||
return file;
|
||||
}
|
||||
});
|
||||
|
||||
setValue('lab_result_file', arr_lab_result_file)
|
||||
};
|
||||
|
||||
// Submit Form
|
||||
// =====================================
|
||||
const submitHandler = async (data: DetailLabResultListType) => {
|
||||
const response = await AddLabResultDetail(claim_code??'', data);
|
||||
|
||||
if (response == true) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Page title={pageTitle}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', pl: '22px', mb: '40px' }}>
|
||||
<IconButton size='large' color='inherit' onClick={() => navigate(`/case_management/laboratorium_result/${member_id}/claims`)} >
|
||||
<ArrowBackIosNew/>
|
||||
</IconButton>
|
||||
|
||||
<Typography variant="h5" sx={{ marginLeft: '24px' }}>
|
||||
{pageTitle}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<Box sx={{ px: '28px' }}>
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(submitHandler)}>
|
||||
<Card sx={{ padding: '24px' }}>
|
||||
<Grid container spacing={6}>
|
||||
{/* Date */}
|
||||
<Grid item xs={6}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" component="div">
|
||||
Date* :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<RHFDatepicker
|
||||
// label=''
|
||||
name="date"
|
||||
// dateFormat='dd-mm-yyyy'
|
||||
// fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Location */}
|
||||
<Grid item xs={6}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" component="div">
|
||||
Location* :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<RHFTextField
|
||||
id="location"
|
||||
name='location'
|
||||
placeholder='Location'
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Examination */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" component="div">
|
||||
Examination* :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<RHFTextField
|
||||
id="examination"
|
||||
name='examination'
|
||||
placeholder='Examination'
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* list file & button upload */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
{
|
||||
formValues.lab_result_file.map((file: any, index: number) => (
|
||||
<Stack direction="row" justifyContent={'space-between'} key={index} sx={{ mb: '16px' }}>
|
||||
<Stack direction="row" spacing={1} sx={{color: '#19BBBB'}}>
|
||||
<InsertDriveFileIcon />
|
||||
<Typography variant="body2" gutterBottom>{file.name ? file.name : '-'}</Typography>
|
||||
</Stack>
|
||||
<Iconify
|
||||
icon="eva:trash-2-outline"
|
||||
color={'darkred'}
|
||||
onClick={() => handleRemoveFile(index)}
|
||||
sx={{cursor: 'pointer'}}
|
||||
></Iconify>
|
||||
</Stack>
|
||||
))
|
||||
}
|
||||
</Grid>
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<ButtonBase sx={{ p: 4, border: '2px dashed #F9FAFB',bgcolor: '#919EAB52',borderRadius: '8px',width: '100%', height: '60px'}} onClick={() => fileInput.current?.click()}>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
placeItems: 'center',
|
||||
gap: 1,
|
||||
placeContent: 'center',
|
||||
}}
|
||||
>
|
||||
<Iconify icon="icon-park-outline:upload-one" fontSize="3em" />
|
||||
<Typography variant="body1" fontWeight="bold">
|
||||
Upload Result
|
||||
</Typography>
|
||||
</Box>
|
||||
<input
|
||||
type="file"
|
||||
id="file"
|
||||
ref={fileInput}
|
||||
style={{ display: 'none' }}
|
||||
multiple
|
||||
onChange={handleInputChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain, application/pdf"
|
||||
/>
|
||||
</ButtonBase>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Button Cancle & Save */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Box display="flex" justifyContent={'flex-end'}>
|
||||
<Box display="flex" gap={1}>
|
||||
<Button variant="outlined" color="inherit" onClick={() => navigate(`/case_management/daily_monitoring/${member_id}/claims`)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<LoadingButton disabled={!isDirty} type="submit" variant="contained" loading={isSubmitting}>
|
||||
Save Changes
|
||||
</LoadingButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Card>
|
||||
</FormProvider>
|
||||
</Box>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Core
|
||||
* ============================================
|
||||
*/
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useFieldArray, useForm } from 'react-hook-form';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, IconButton, Typography, Grid, Card, List, ListItem, Stack, Link } from '@mui/material';
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
|
||||
/**
|
||||
* Components
|
||||
* ============================================
|
||||
*/
|
||||
// - Global -
|
||||
import Page from '@/components/Page';
|
||||
import Label from "@/components/Label";
|
||||
|
||||
/**
|
||||
* Icon
|
||||
* ============================================
|
||||
*/
|
||||
import ArrowBackIosNew from '@mui/icons-material/ArrowBackIosNew';
|
||||
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
||||
|
||||
/**
|
||||
* Utils, Types, Functions
|
||||
* ============================================
|
||||
*/
|
||||
import { fDate } from "@/utils/formatTime";
|
||||
import { getLabResultDetailList } from '../Model/Functions';
|
||||
import { DetailLabResultListType } from '../Model/Types';
|
||||
|
||||
|
||||
export default function DetailLabResultList() {
|
||||
const { member_id, claim_code } = useParams();
|
||||
const navigate = useNavigate()
|
||||
const pageTitle = claim_code??'_ _ _ _';
|
||||
|
||||
// State
|
||||
// --------------------
|
||||
const [LabResultList, setLabResultList] = useState<DetailLabResultListType[]>();
|
||||
|
||||
// Use Effect
|
||||
// --------------------
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
|
||||
// Load Data
|
||||
// -------------------
|
||||
const loadDataTableData = async () => {
|
||||
const response = await getLabResultDetailList(claim_code??'');
|
||||
|
||||
setLabResultList(response);
|
||||
}
|
||||
|
||||
return (
|
||||
<Page title={pageTitle} sx={{ px: 2 }}>
|
||||
<Grid container gap={6}>
|
||||
{/* back button */}
|
||||
<Grid item xs={12}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<IconButton size='large' color='inherit' onClick={() => navigate(`/case_management/daily_monitoring/${member_id}/claims`)} >
|
||||
<ArrowBackIosNew/>
|
||||
</IconButton>
|
||||
|
||||
<Typography variant="h5" sx={{ marginLeft: '24px' }}>
|
||||
{pageTitle}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Grid>
|
||||
|
||||
{/* tabel claims */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={4} sx={{ px: 2 }}>
|
||||
{
|
||||
LabResultList?.map((row, index) => {
|
||||
return (
|
||||
<Grid key={index} item xs={12}>
|
||||
<Card sx={{ border: '1px solid rgba(0,0,0,0.125)', px: '32px', py: '24px'}}>
|
||||
{/* card header */}
|
||||
<Box sx={{ pb: '20px', mb: '20px', borderBottom: '1px solid rgba(0,0,0,0.125)' }}>
|
||||
<Label
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{row.created_at ? fDate(row.created_at) : '-'}
|
||||
</Label>
|
||||
</Box>
|
||||
|
||||
{/* card body */}
|
||||
<Grid container gap={3}>
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Date
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.date}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Location
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.location}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2" color={"GrayText"}>
|
||||
Examination
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body2">
|
||||
{row.examination}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<Grid container gap={1}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="body1" sx={{ fontWeight: 'bold' }}>
|
||||
Document :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
{
|
||||
row.lab_result_file.map((data, index) => {
|
||||
return (
|
||||
<Stack direction="row" justifyContent={'space-between'} key={index} sx={{ mt: '16px' }}>
|
||||
<Link href={data.lab_result_file_obj.path} underline='hover'>
|
||||
<Stack direction="row" spacing={1} sx={{color: '#19BBBB'}}>
|
||||
<InsertDriveFileIcon />
|
||||
<Typography variant="body2" gutterBottom>{data.lab_result_file_obj.original_name??'-'}</Typography>
|
||||
</Stack>
|
||||
</Link>
|
||||
</Stack>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Card>
|
||||
</Grid>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import axios from '@/utils/axios';
|
||||
import { makeFormData } from '@/utils/jsonToFormData';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { LaboratoriumResultListType, ResponseListingClaimType } from "./Types";
|
||||
import { DetailLabResultListType, LaboratoriumResultListType, ResponseListingClaimType } from "./Types";
|
||||
import { fDate } from '@/utils/formatTime';
|
||||
|
||||
/**
|
||||
* Listing Daily Monitoring
|
||||
*/
|
||||
export const getDailyMonitoringList = async ( ): Promise<LaboratoriumResultListType[]> => {
|
||||
const response = await axios.get('/case_management/daily_monitoring/memberlist')
|
||||
const response = await axios.get('/case_management/memberlist')
|
||||
.then((res) =>{
|
||||
return res.data.data.member_list;
|
||||
})
|
||||
@@ -25,7 +27,7 @@ export const getDailyMonitoringList = async ( ): Promise<LaboratoriumResultList
|
||||
* Listing Claim
|
||||
*/
|
||||
export const getClaimList = async ( member_id: string ): Promise<ResponseListingClaimType> => {
|
||||
const response = await axios.get(`/case_management/daily_monitoring/claimlist/${member_id}`)
|
||||
const response = await axios.get(`/case_management/claimlist/${member_id}`)
|
||||
.then((res) =>{
|
||||
return res.data.data;
|
||||
})
|
||||
@@ -39,3 +41,60 @@ export const getClaimList = async ( member_id: string ): Promise<ResponseListing
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Lab Result Detail
|
||||
*/
|
||||
export const AddLabResultDetail = async ( claim_code: string,data: DetailLabResultListType ): Promise<boolean> => {
|
||||
data.date = data.date != '' ? fDate(data.date) : '';
|
||||
|
||||
const formData = makeFormData({...data});
|
||||
|
||||
const response = await axios.post(`/case_management/laboratorium_result/detail/${claim_code}/add`, formData)
|
||||
.then((res) =>{
|
||||
enqueueSnackbar(res.data.message, {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((res) => {
|
||||
if (res.response.status == 400) {
|
||||
let arr_message = res.response.data.message;
|
||||
|
||||
for (const key in arr_message) {
|
||||
enqueueSnackbar(arr_message[key][0], {
|
||||
variant: 'warning',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Lab Result Detail List
|
||||
*/
|
||||
export const getLabResultDetailList = async ( claim_code: string ): Promise<DetailLabResultListType[]> => {
|
||||
const response = await axios.get(`/case_management/laboratorium_result/detail/${claim_code}/list`)
|
||||
.then((res) =>{
|
||||
return res.data.data.lab_result_list;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
@@ -37,3 +37,21 @@ export type ClaimListType = {
|
||||
service_type : string,
|
||||
member_id : string
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail Lab Result List
|
||||
*/
|
||||
export type DetailLabResultListType = {
|
||||
id : string|null,
|
||||
claim_id : string|null,
|
||||
claim_code : string,
|
||||
date : string,
|
||||
location : string,
|
||||
examination : string,
|
||||
lab_result_file : LabResultFileStrType[],
|
||||
created_at : string|null
|
||||
}
|
||||
|
||||
export type LabResultFileStrType = {
|
||||
lab_result_file_obj: any
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function Detail() {
|
||||
.then((response) => {
|
||||
setData(response.data);
|
||||
setDataDialog(response.data.data.dialog_submits);
|
||||
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
@@ -71,6 +71,8 @@ export default function Detail() {
|
||||
|
||||
const handleInvoiceInputChange = (event) => {
|
||||
if (event.target.files[0]) {
|
||||
console.log('ok');
|
||||
|
||||
setFileInvoices([...fileInvoices, ...event.target.files]);
|
||||
} else {
|
||||
console.log('NO FILE');
|
||||
@@ -84,7 +86,7 @@ export default function Detail() {
|
||||
);
|
||||
};
|
||||
const date = dateInvoice ? fPostFormat(dateInvoice, 'yyyy-MM-dd') : null;
|
||||
|
||||
|
||||
const [openDialogSubmit, setOpenDialogSubmit] = useState(false);
|
||||
const handleCloseDialogSubmit = () => {
|
||||
setOpenDialogSubmit(false);
|
||||
@@ -121,13 +123,13 @@ export default function Detail() {
|
||||
enqueueSnackbar('Please upload file invoice, before submit', { variant: 'warning' });
|
||||
}
|
||||
|
||||
setTimeout(() =>
|
||||
setTimeout(() =>
|
||||
{
|
||||
window.location.reload();
|
||||
}, 5000);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
@@ -209,7 +211,7 @@ export default function Detail() {
|
||||
placeItems: 'center',
|
||||
gap: 1,
|
||||
placeContent: 'center',
|
||||
|
||||
|
||||
|
||||
}}
|
||||
>
|
||||
@@ -297,4 +299,4 @@ export default function Detail() {
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,6 +244,14 @@ export default function Router() {
|
||||
path: 'laboratorium_result/:member_id/claims',
|
||||
element: <LaboratoriumResultClaims />
|
||||
},
|
||||
{
|
||||
path: 'laboratorium_result/:member_id/claims/:claim_code/add_lab_result',
|
||||
element: <DetailLabResultForm />
|
||||
},
|
||||
{
|
||||
path: 'laboratorium_result/:member_id/claims/:claim_code/list_lab_result',
|
||||
element: <DetailLabResultList />
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -572,6 +580,8 @@ const DetailMonitoringList = Loadable(lazy(() => import('../pages/CaseManagemen
|
||||
// Laboratorium Result
|
||||
const LaboratoriumResult = Loadable(lazy(() => import('../pages/CaseManagement/LaboratoriumResult/index')))
|
||||
const LaboratoriumResultClaims = Loadable(lazy(() => import('../pages/CaseManagement/LaboratoriumResult/Claim')))
|
||||
const DetailLabResultForm = Loadable(lazy(() => import('../pages/CaseManagement/LaboratoriumResult/Components/DetailLabResultForm')))
|
||||
const DetailLabResultList = Loadable(lazy(() => import('../pages/CaseManagement/LaboratoriumResult/Components/DetailLabResultList')))
|
||||
|
||||
const MasterDiagnosisTemplate = Loadable(lazy(() => import('../pages/Master/Diagnosis/Master/Index')));
|
||||
const MasterDiagnosisTemplateCreate = Loadable(lazy(() => import('../pages/Master/Diagnosis/Master/CreateUpdate')));
|
||||
|
||||
Reference in New Issue
Block a user