[WIP] Encounter
This commit is contained in:
117
Modules/Client/Http/Controllers/Api/ClaimController.php
Normal file
117
Modules/Client/Http/Controllers/Api/ClaimController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Claim;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Client\Transformers\ClaimShowResource;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$claims = Claim::query()
|
||||
->when($request->search ?? null, function($query, $search) {
|
||||
$query->where('code', 'LIKE', '%'.$search.'%');
|
||||
})
|
||||
->with([
|
||||
'member',
|
||||
'diagnoses' => function ($diagnosis) {
|
||||
return $diagnosis->where('type', 'primary');
|
||||
},
|
||||
'diagnoses.icd',
|
||||
'plan',
|
||||
'benefit',
|
||||
'claimRequest',
|
||||
'claimRequest.service'
|
||||
])
|
||||
->paginate(10);
|
||||
|
||||
return Helper::responseJson($claims);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('client::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)
|
||||
{
|
||||
$claim = Claim::query()
|
||||
->with([
|
||||
'member',
|
||||
'member.currentPlan',
|
||||
'member.currentPlan.benefits',
|
||||
'member.currentCorporate',
|
||||
'member.currentPolicy',
|
||||
'diagnosis',
|
||||
'diagnoses',
|
||||
'benefit',
|
||||
'files',
|
||||
'claimRequest',
|
||||
'claimRequest.files',
|
||||
'items',
|
||||
'items.claim_itemable'
|
||||
])
|
||||
->findOrFail($id);
|
||||
|
||||
return Helper::responseJson(ClaimShowResource::make($claim));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('client::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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use Modules\Client\Http\Controllers\Api\CorporateManageController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
|
||||
use Modules\Client\Http\Controllers\Api\UserController;
|
||||
use Modules\Client\Http\Controllers\Api\ClaimController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -34,6 +35,10 @@ Route::prefix('client')->group(function () {
|
||||
Route::get('policy', [CorporatePolicyController::class, 'index']);
|
||||
Route::get('division', [CorporateDivisionController::class, 'index']);
|
||||
Route::get('members', [CorporateMemberController::class, 'index']);
|
||||
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
});
|
||||
|
||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||
});
|
||||
});
|
||||
|
||||
41
Modules/Client/Transformers/ClaimShowResource.php
Normal file
41
Modules/Client/Transformers/ClaimShowResource.php
Normal file
@@ -0,0 +1,41 @@
|
||||
c<?php
|
||||
|
||||
namespace Modules\Client\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ClaimShowResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
// $data['']
|
||||
$data['benefit_items'] = $this->items
|
||||
->filter(function ($item) {
|
||||
return $item->claim_itemable_type == Benefit::class;
|
||||
})
|
||||
->map(function ($item) {
|
||||
$itemData = $item->claim_itemable->toArray();
|
||||
$itemData['nominal_dicover'] = $item['nominal_dicover'] ?? 0;
|
||||
$itemData['nominal_ditagihkan'] = $item['nominal_ditagihkan'] ?? 0;
|
||||
$itemData['nominal_total'] = $item['nominal_total'] ?? 0;
|
||||
|
||||
// For React Frotnend
|
||||
$itemData['biaya_diajukan'] = $itemData['nominal_ditagihkan'];
|
||||
$itemData['biaya_disetujui'] = $itemData['nominal_dicover'];
|
||||
|
||||
return $itemData;
|
||||
});
|
||||
|
||||
$data['primary_diagnosis'] = $this->diagnoses->filter(function($diagnosis){ return $diagnosis->type == 'primary';})->values();
|
||||
$data['secondary_diagnosis'] = $this->diagnoses->filter(function($diagnosis){ return $diagnosis->type == 'secondary';})->values();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -99,8 +99,9 @@ class ClaimController extends Controller
|
||||
'member.currentPlan.benefits',
|
||||
'member.currentCorporate',
|
||||
'member.currentPolicy',
|
||||
'diagnosis',
|
||||
// 'diagnosis',
|
||||
'diagnoses',
|
||||
'diagnoses.icd',
|
||||
'benefit',
|
||||
'files',
|
||||
'claimRequest',
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Icd;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Practitioner;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
@@ -30,6 +32,35 @@ class OptionController extends Controller
|
||||
|
||||
return $icds;
|
||||
break;
|
||||
case 'doctors':
|
||||
$doctors = Practitioner::query()
|
||||
->whereHas('person', function ($person) use ($request) {
|
||||
$person->where('name', 'LIKE', '%'.$request->search.'%');
|
||||
})
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
$doctors = $doctors->map(function($doctor) {
|
||||
$doctorDetail = $doctor->person->toArray();
|
||||
unset($doctorDetail['id']);
|
||||
|
||||
return array_merge([
|
||||
'id' => $doctor->id,
|
||||
'code' => $doctor->code
|
||||
], $doctorDetail);
|
||||
});
|
||||
|
||||
return $doctors;
|
||||
break;
|
||||
case 'healthcares':
|
||||
$healthcares = Organization::query()
|
||||
->hospital()
|
||||
->where('name', 'LIKE', '%'.$request->search.'%')
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
return $healthcares;
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
|
||||
@@ -19,6 +19,15 @@ class ClaimDiagnosis extends Model
|
||||
'description',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function icd()
|
||||
{
|
||||
return $this->belongsTo(Icd::class, 'diagnosis_id', 'id');
|
||||
|
||||
31
app/Models/Encounter.php
Normal file
31
app/Models/Encounter.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Encounter extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = [
|
||||
'part_of',
|
||||
'status',
|
||||
'class',
|
||||
'type',
|
||||
'patient_id',
|
||||
'start',
|
||||
'end',
|
||||
];
|
||||
|
||||
public function participants()
|
||||
{
|
||||
return $this->hasMany(EncounterParticipant::class, 'encounter_id');
|
||||
}
|
||||
|
||||
public function diagnoses()
|
||||
{
|
||||
return $this->hasMany(EncounterDiagnosis::class, 'encounter_id');
|
||||
}
|
||||
}
|
||||
29
app/Models/EncounterDiagnosis.php
Normal file
29
app/Models/EncounterDiagnosis.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EncounterDiagnosis extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = [
|
||||
'encounter_id',
|
||||
'diagnosis_id',
|
||||
'use',
|
||||
'source',
|
||||
'description',
|
||||
];
|
||||
|
||||
public static $use_enums = [
|
||||
'working' => 'Working',
|
||||
'final' => 'Final'
|
||||
];
|
||||
|
||||
public function encounter()
|
||||
{
|
||||
return $this->belongsTo(Encounter::class, 'encounter_id');
|
||||
}
|
||||
}
|
||||
27
app/Models/EncounterParticipant.php
Normal file
27
app/Models/EncounterParticipant.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EncounterParticipant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = [
|
||||
'encounter_id',
|
||||
'type',
|
||||
];
|
||||
|
||||
|
||||
public function encounter()
|
||||
{
|
||||
return $this->belongsTo(Encounter::class, 'encounter_id');
|
||||
}
|
||||
|
||||
public function participantable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class Practitioner extends Model
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'meta'
|
||||
'meta',
|
||||
'code'
|
||||
];
|
||||
|
||||
public function getMetaAttribute()
|
||||
@@ -27,6 +28,11 @@ class Practitioner extends Model
|
||||
return (object) $orgMeta;
|
||||
}
|
||||
|
||||
public function getCodeAttribute()
|
||||
{
|
||||
return 'DOC'.str_pad($this->id, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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('encounters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('part_of')->comment('encounter_id');
|
||||
$table->string('status');
|
||||
$table->string('class')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->foreignId('patient_id')->nullable();
|
||||
$table->dateTime('start')->nullable();
|
||||
$table->dateTime('end')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('encounters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('encounter_participants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('encounter_id');
|
||||
$table->string('type');
|
||||
$table->nullableMorphs('participantable', 'participantable');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('encounter_participants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('encounter_diagnoses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('encounter_id');
|
||||
$table->foreignId('diagnosis_id');
|
||||
$table->string('use')->nullable();
|
||||
$table->text('source')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('encounter_diagnoses');
|
||||
}
|
||||
};
|
||||
@@ -19,23 +19,21 @@ import {
|
||||
} from '@mui/material';
|
||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
// hooks
|
||||
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, useContext, useEffect, useRef, useState } from 'react';
|
||||
import { Navigate, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
// components
|
||||
import axios from '../../utils/axios';
|
||||
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
|
||||
import DataTable from '../../components/LaravelTable';
|
||||
import { fCurrency } from '../../utils/formatNumber';
|
||||
import EditRoundedIcon from '@mui/icons-material/EditRounded';
|
||||
import { Chip } from '@mui/material';
|
||||
import Iconify from '@/components/Iconify';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { UserCurrentCorporateContext } from '@/contexts/UserCurrentCorporate';
|
||||
|
||||
export default function List() {
|
||||
const { corporateValue } = useContext(UserCurrentCorporateContext);
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [importResult, setImportResult] = useState(null);
|
||||
const navigate = useNavigate();
|
||||
@@ -108,11 +106,11 @@ export default function List() {
|
||||
const loadDataTableData = async (appliedFilter: any | null = null) => {
|
||||
setDataTableLoading(true);
|
||||
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||
const response = await axios.get('/claims', { params: filter });
|
||||
// console.log(response.data);
|
||||
const response = await axios.get(corporateValue+'/claims', { params: filter });
|
||||
// console.log(response.data.data);
|
||||
setDataTableLoading(false);
|
||||
|
||||
setDataTableData(response.data);
|
||||
setDataTableData(response.data.data);
|
||||
};
|
||||
|
||||
const applyFilter = async (searchFilter: { search: string }) => {
|
||||
|
||||
@@ -122,6 +122,10 @@ export default function Router() {
|
||||
element: <Claims />,
|
||||
index: true,
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
element: <ClaimShow />,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -153,3 +157,4 @@ const AlarmCenterUserProfile = Loadable(lazy(() => import('../pages/AlarmCenter/
|
||||
// Claim Report
|
||||
const ClaimReport = Loadable(lazy(() => import('../pages/ClaimReport/Index')));
|
||||
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
|
||||
const ClaimShow = Loadable(lazy(() => import('../pages/Claims/Show')));
|
||||
|
||||
Reference in New Issue
Block a user