finishing feature/dashboard-create-claim-request
This commit is contained in:
@@ -113,48 +113,83 @@ class ClaimRequestController extends Controller
|
||||
'updated_at'=> date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
if ($request->hasFile('laboratorium')) {
|
||||
foreach ($request->laboratorium[$key] as $file) {
|
||||
$pathFile = File::storeFile('claim-result', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-result',
|
||||
'name' => File::getFileName('claim-result', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
$storage_path = storage_path() . "/app/public";
|
||||
|
||||
if (isset($_FILES['file_penunjang'])) {
|
||||
foreach ($_FILES['file_penunjang']['error']["member_" .$member_id] as $key => $value) {
|
||||
if ($value == 0) {
|
||||
$folder = "claim/";
|
||||
$new_file_name = "claim-result-" . time() . "-" . uniqid();
|
||||
$ekstension = "." . explode("/", $_FILES['file_penunjang']['type']["member_" .$member_id][$key])[1];
|
||||
$pathFile = $folder . $new_file_name . $ekstension;
|
||||
|
||||
$tmp_name = $_FILES['file_penunjang']['tmp_name']["member_" .$member_id][$key];
|
||||
$full_path = $_FILES['file_penunjang']['full_path']["member_" .$member_id][$key];
|
||||
|
||||
if (move_uploaded_file($tmp_name, $storage_path . "/" . $pathFile)) {
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-result',
|
||||
'name' => $new_file_name,
|
||||
'original_name' => $full_path,
|
||||
'extension' => $ekstension,
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('prescription')) {
|
||||
foreach ($request->prescription[$key] as $file) {
|
||||
$pathFile = File::storeFile('claim-diagnosis', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-diagnosis',
|
||||
'name' => File::getFileName('claim-diagnosis', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
if (isset($_FILES['file_diagnosa'])) {
|
||||
foreach ($_FILES['file_diagnosa']['error']["member_" .$member_id] as $key => $value) {
|
||||
if ($value == 0) {
|
||||
$folder = "claim/";
|
||||
$new_file_name = "claim-diagnosis-" . time() . "-" . uniqid();
|
||||
$ekstension = "." . explode("/", $_FILES['file_diagnosa']['type']["member_" .$member_id][$key])[1];
|
||||
$pathFile = $folder . $new_file_name . $ekstension;
|
||||
|
||||
$tmp_name = $_FILES['file_diagnosa']['tmp_name']["member_" .$member_id][$key];
|
||||
$full_path = $_FILES['file_diagnosa']['full_path']["member_" .$member_id][$key];
|
||||
|
||||
if (move_uploaded_file($tmp_name, $storage_path . "/" . $pathFile)) {
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-diagnosis',
|
||||
'name' => $new_file_name,
|
||||
'original_name' => $full_path,
|
||||
'extension' => $ekstension,
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('invoice')) {
|
||||
foreach ($request->invoice[$key] as $file) {
|
||||
$pathFile = File::storeFile('claim-kondisi', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-kondisi',
|
||||
'name' => File::getFileName('claim-kondisi', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
if (isset($_FILES['file_kondisi'])) {
|
||||
foreach ($_FILES['file_kondisi']['error']["member_" .$member_id] as $key => $value) {
|
||||
if ($value == 0) {
|
||||
$folder = "claim/";
|
||||
$new_file_name = "claim-kondisi-" . time() . "-" . uniqid();
|
||||
$ekstension = "." . explode("/", $_FILES['file_kondisi']['type']["member_" .$member_id][$key])[1];
|
||||
$pathFile = $folder . $new_file_name . $ekstension;
|
||||
|
||||
$tmp_name = $_FILES['file_kondisi']['tmp_name']["member_" .$member_id][$key];
|
||||
$full_path = $_FILES['file_kondisi']['full_path']["member_" .$member_id][$key];
|
||||
|
||||
if (move_uploaded_file($tmp_name, $storage_path . "/" . $pathFile)) {
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-kondisi',
|
||||
'name' => $new_file_name,
|
||||
'original_name' => $full_path,
|
||||
'extension' => $ekstension,
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,10 @@ class DailyMonitoringController extends Controller
|
||||
|
||||
$claimList = DB::table('claims')
|
||||
->leftJoin('claim_requests', 'claims.claim_request_id', '=', 'claim_requests.id')
|
||||
->leftJoin('claim_history_cares', 'claims.id', '=', 'claim_history_cares.claim_id')
|
||||
->leftJoin('services', 'claim_requests.service_code', '=', 'services.code')
|
||||
->leftJoin('members', 'claims.member_id', '=', 'members.id')
|
||||
->select('claims.id AS claim_id','claim_requests.code AS claim_code','services.name AS service_type','claims.status AS claim_status','members.member_id',)
|
||||
->select('claims.id AS claim_id','claim_history_cares.admission_date','claim_history_cares.discharge_date','claim_requests.code AS claim_code','services.name AS service_type','claims.status AS claim_status','members.member_id',)
|
||||
->where("claims.member_id", "=", $memberDetail->id)
|
||||
->orderBy("claims.created_at", "desc")
|
||||
->get();
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function Claim() {
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [loadDataTableData])
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Page title={ `claims | ${memberDetail?.name??'_ _ _'}` } sx={{ px: 2 }}>
|
||||
|
||||
@@ -37,7 +37,7 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
<TableRow hover sx={{ '& > td': { borderBottom: '1' } }}>
|
||||
<TableCell align="left" />
|
||||
<TableCell align="left">
|
||||
{props.row.admission_dates == "0000-00-00 00:00:00" ?
|
||||
{props.row.admission_date == "0000-00-00 00:00:00" ?
|
||||
('-')
|
||||
:
|
||||
(
|
||||
@@ -45,12 +45,12 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{fDate(props.row.admission_dates)}
|
||||
{fDate(props.row.admission_date)}
|
||||
</Label>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
{props.row.discharge_dates == "0000-00-00 00:00:00" ?
|
||||
{props.row.discharge_date == "0000-00-00 00:00:00" ?
|
||||
('-')
|
||||
:
|
||||
(
|
||||
@@ -58,7 +58,7 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{fDate(props.row.discharge_dates)}
|
||||
{fDate(props.row.discharge_date)}
|
||||
</Label>
|
||||
)}
|
||||
</TableCell>
|
||||
|
||||
@@ -30,8 +30,8 @@ export type MemberDetailType = {
|
||||
*/
|
||||
export type ClaimListType = {
|
||||
claim_id : number,
|
||||
admission_dates : string,
|
||||
discharge_dates : string,
|
||||
admission_date : string,
|
||||
discharge_date : string,
|
||||
claim_code : string,
|
||||
claim_status : string,
|
||||
service_type : string,
|
||||
|
||||
@@ -37,7 +37,7 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
<TableRow hover sx={{ '& > td': { borderBottom: '1' } }}>
|
||||
<TableCell align="left" />
|
||||
<TableCell align="left">
|
||||
{props.row.admission_dates == "0000-00-00 00:00:00" ?
|
||||
{props.row.admission_date == "0000-00-00 00:00:00" ?
|
||||
('-')
|
||||
:
|
||||
(
|
||||
@@ -45,12 +45,12 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{fDate(props.row.admission_dates)}
|
||||
{fDate(props.row.admission_date)}
|
||||
</Label>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
{props.row.discharge_dates == "0000-00-00 00:00:00" ?
|
||||
{props.row.discharge_date == "0000-00-00 00:00:00" ?
|
||||
('-')
|
||||
:
|
||||
(
|
||||
@@ -58,7 +58,7 @@ export default function ClaimListRow ({ ...props }: Props) {
|
||||
variant="ghost"
|
||||
color="default"
|
||||
>
|
||||
{fDate(props.row.discharge_dates)}
|
||||
{fDate(props.row.discharge_date)}
|
||||
</Label>
|
||||
)}
|
||||
</TableCell>
|
||||
|
||||
@@ -30,8 +30,8 @@ export type MemberDetailType = {
|
||||
*/
|
||||
export type ClaimListType = {
|
||||
claim_id : number,
|
||||
admission_dates : string,
|
||||
discharge_dates : string,
|
||||
admission_date : string,
|
||||
discharge_date : string,
|
||||
claim_code : string,
|
||||
claim_status : string,
|
||||
service_type : string,
|
||||
|
||||
@@ -81,33 +81,33 @@ export default function FormCreate() {
|
||||
|
||||
// Function - Handle Btn Upload
|
||||
// -----------------------------
|
||||
const handleChangeInput = (data: MemberListType, type_file: 'invoice'|'prescription'|'laboratorium', file: any) => {
|
||||
const handleChangeInput = (data: MemberListType, type_file: 'kondisi'|'diagnosa'|'penunjang', file: any) => {
|
||||
let newListChoosed = listChoosed.map((list) => {
|
||||
if (data.id == list.id) {
|
||||
if (type_file == 'invoice') {
|
||||
if (list.invoice_files == undefined) {
|
||||
list.invoice_files = [file];
|
||||
if (type_file == 'kondisi') {
|
||||
if (list.file_kondisi == undefined) {
|
||||
list.file_kondisi = [file];
|
||||
}
|
||||
else {
|
||||
list.invoice_files.push(file);
|
||||
list.file_kondisi.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (type_file == 'prescription') {
|
||||
if (list.prescription_files == undefined) {
|
||||
list.prescription_files = [file];
|
||||
if (type_file == 'diagnosa') {
|
||||
if (list.file_diagnosa == undefined) {
|
||||
list.file_diagnosa = [file];
|
||||
}
|
||||
else {
|
||||
list.prescription_files.push(file);
|
||||
list.file_diagnosa.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (type_file == 'laboratorium') {
|
||||
if (list.laboratorium_files == undefined) {
|
||||
list.laboratorium_files = [file];
|
||||
if (type_file == 'penunjang') {
|
||||
if (list.file_penunjang == undefined) {
|
||||
list.file_penunjang = [file];
|
||||
}
|
||||
else {
|
||||
list.laboratorium_files.push(file);
|
||||
list.file_penunjang.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,27 +120,27 @@ export default function FormCreate() {
|
||||
|
||||
// Function - Handle Remove Fle
|
||||
// -----------------------------
|
||||
const handleRemoveFile = (data: MemberListType, type_file: 'invoice'|'prescription'|'laboratorium', target_index: number) => {
|
||||
const handleRemoveFile = (data: MemberListType, type_file: 'kondisi'|'diagnosa'|'penunjang', target_index: number) => {
|
||||
let newListChoosed = listChoosed.map((list) => {
|
||||
if (data.id == list.id) {
|
||||
if (type_file == 'invoice') {
|
||||
list.invoice_files = list.invoice_files?.filter((file: any, index: number) =>{
|
||||
if (type_file == 'kondisi') {
|
||||
list.file_kondisi = list.file_kondisi?.filter((file: any, index: number) =>{
|
||||
if (target_index !== index) {
|
||||
return file;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (type_file == 'prescription') {
|
||||
list.prescription_files = list.prescription_files?.filter((file: any, index: number) =>{
|
||||
if (type_file == 'diagnosa') {
|
||||
list.file_diagnosa = list.file_diagnosa?.filter((file: any, index: number) =>{
|
||||
if (target_index !== index) {
|
||||
return file;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (type_file == 'laboratorium') {
|
||||
list.laboratorium_files = list.laboratorium_files?.filter((file: any, index: number) =>{
|
||||
if (type_file == 'penunjang') {
|
||||
list.file_penunjang = list.file_penunjang?.filter((file: any, index: number) =>{
|
||||
if (target_index !== index) {
|
||||
return file;
|
||||
}
|
||||
@@ -282,59 +282,59 @@ export default function FormCreate() {
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Invoice */}
|
||||
{/* File Kondisi */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="h6">Real Invoice</Typography>
|
||||
<Typography variant="h6">Condition Document</Typography>
|
||||
</Grid>
|
||||
|
||||
{row.invoice_files && row.invoice_files.map((file, index) => (
|
||||
{row.file_kondisi && row.file_kondisi.map((file, index) => (
|
||||
<Grid item xs={12} key={index}>
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'invoice', index)} />
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'kondisi', index)} />
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'invoice', file)} />
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'kondisi', file)} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Prescription */}
|
||||
{/* File Diagnosa */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="h6">Doctor's Prescription and Another Documents</Typography>
|
||||
<Typography variant="h6">Diagnosis Document</Typography>
|
||||
</Grid>
|
||||
|
||||
{row.prescription_files && row.prescription_files.map((file, index) => (
|
||||
{row.file_diagnosa && row.file_diagnosa.map((file, index) => (
|
||||
<Grid item xs={12} key={index}>
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'prescription', index)} />
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'diagnosa', index)} />
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'prescription', file)} />
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'diagnosa', file)} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
{/* Laboratorium */}
|
||||
{/* File Penunjang */}
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="h6">Laboratory Results</Typography>
|
||||
<Typography variant="h6">Supporting Result Document</Typography>
|
||||
</Grid>
|
||||
|
||||
{row.laboratorium_files && row.laboratorium_files.map((file, index) => (
|
||||
{row.file_penunjang && row.file_penunjang.map((file, index) => (
|
||||
<Grid item xs={12} key={index}>
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'laboratorium', index)} />
|
||||
<FormCreateFilesUpload file={file} handleRemoveFileProp={() => handleRemoveFile(row, 'penunjang', index)} />
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<Grid item xs={12} sx={{display: 'flex', gap: 1}}>
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'laboratorium', file)} />
|
||||
<FormCreateBtnUpload handleChangeInputProp={(file) => handleChangeInput(row, 'penunjang', file)} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -33,21 +33,27 @@ export const addClaimRequest = async ( data: MemberListType[] ): Promise<boolean
|
||||
formData.append(`member_id[${index}]`, row.id.toString());
|
||||
formData.append(`service_code[${index}]`, row.patien_type??'');
|
||||
|
||||
if (row.invoice_files != undefined) {
|
||||
row.invoice_files.forEach((file, file_index) => {
|
||||
formData.append(`invoice[${index}][${file_index}]`, file);
|
||||
if (row.file_kondisi != undefined) {
|
||||
row.file_kondisi.forEach((file, file_index) => {
|
||||
console.log(file);
|
||||
|
||||
formData.append(`file_kondisi[member_${row.id}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
|
||||
if (row.prescription_files != undefined) {
|
||||
row.prescription_files.forEach((file, file_index) => {
|
||||
formData.append(`prescription[${index}][${file_index}]`, file);
|
||||
if (row.file_diagnosa != undefined) {
|
||||
row.file_diagnosa.forEach((file, file_index) => {
|
||||
console.log(file);
|
||||
|
||||
formData.append(`file_diagnosa[member_${row.id}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
|
||||
if (row.laboratorium_files != undefined) {
|
||||
row.laboratorium_files.forEach((file, file_index) => {
|
||||
formData.append(`laboratorium[${index}][${file_index}]`, file);
|
||||
if (row.file_penunjang != undefined) {
|
||||
row.file_penunjang.forEach((file, file_index) => {
|
||||
console.log(file);
|
||||
|
||||
formData.append(`file_penunjang[member_${row.id}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -12,8 +12,8 @@ export type MemberListType = {
|
||||
id : string,
|
||||
member_id : string,
|
||||
name : string,
|
||||
patien_type? : string,
|
||||
invoice_files? : any[],
|
||||
laboratorium_files? : any[],
|
||||
prescription_files? : any[]
|
||||
patien_type? : string,
|
||||
file_kondisi? : any[],
|
||||
file_diagnosa? : any[],
|
||||
file_penunjang? : any[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user