update listing dan edit claim management
This commit is contained in:
@@ -11,7 +11,6 @@ use App\Helpers\Helper;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Member;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Exceptions\ImportRowException;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
@@ -21,9 +20,20 @@ use Str;
|
||||
|
||||
class ClaimRequestService{
|
||||
|
||||
public static function storeClaimRequest($code, $member, $paymentType, $serviceCode, $submissionDate = null, $status = 'requested')
|
||||
public static function storeClaimRequest($row, $code, $member, $paymentType, $serviceCode, $submissionDate = null, $status = 'requested', $organization_code = null)
|
||||
{
|
||||
try {
|
||||
// try {
|
||||
|
||||
if($organization_code){
|
||||
$organization = Organization::where('code', $organization_code)->first();
|
||||
if (!$organization){
|
||||
throw new ImportRowException(__('Code Provider Tidak ditemukan', [
|
||||
'attribute' => 'provider_code',
|
||||
'code' => $row['provider_code']
|
||||
]), 403, null, $row);
|
||||
}
|
||||
};
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$claimRequestData = [
|
||||
@@ -34,6 +44,7 @@ class ClaimRequestService{
|
||||
'payment_type' => $paymentType,
|
||||
'service_code' => $serviceCode,
|
||||
'policy_id' => $member->currentPolicy->id ?? null,
|
||||
'organization_id' => $organization ? $organization->id : 0,
|
||||
];
|
||||
|
||||
$claimRequest = ClaimRequest::create($claimRequestData);
|
||||
@@ -41,11 +52,11 @@ class ClaimRequestService{
|
||||
DB::commit();
|
||||
|
||||
return $claimRequest;
|
||||
} catch (\Exception $error) {
|
||||
DB::rollBack();
|
||||
// } catch (\Exception $error) {
|
||||
// DB::rollBack();
|
||||
|
||||
throw new \Exception($error);
|
||||
}
|
||||
// throw new \Exception($error);
|
||||
// }
|
||||
}
|
||||
|
||||
public static function storeClaimManagement($row, $member, $claim_request_id){
|
||||
@@ -66,6 +77,12 @@ class ClaimRequestService{
|
||||
'currency' => 'IDR',
|
||||
'plan_id' => $member->currentPlan->id,
|
||||
'total_claim' => $row['tot_amt_insurred'],
|
||||
'benefit_code' => $row['benefit_code'],
|
||||
'benefit_desc' => $row['benefit_desc'],
|
||||
'amount_incurred' => $row['tot_amt_insurred'],
|
||||
'amount_approved' => $row['tot_amt_approved'],
|
||||
'amount_not_approved' => $row['tot_amt_not_approved'],
|
||||
'excess_paid' => $row['tot_excess_paid'],
|
||||
'claim_request_id' => $claim_request_id,
|
||||
'organization_id' => $organization ? $organization->id : NULL,
|
||||
'status' => 'requested'
|
||||
@@ -90,17 +107,14 @@ class ClaimRequestService{
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateClaimRequest(){
|
||||
public static function updateClaimRequest($organization_id, $claim_request_id){
|
||||
try {
|
||||
$data = [
|
||||
'member_id' => $member->id,
|
||||
'currency' => 'IDR',
|
||||
'plan_id' => $member->currentPlan->id,
|
||||
'total_claim' => $row['tot_amt_insurred'],
|
||||
'claim_request_id' => $claim_request_id,
|
||||
'organization_id' => $organization ? $organization->id : NULL,
|
||||
'status' => 'requested'
|
||||
'organization_id' => $organization_id
|
||||
];
|
||||
DB::commit();
|
||||
$update = ClaimRequest::where('id', $claim_request_id)->update($data);
|
||||
return ClaimRequest::find($claim_request_id);
|
||||
|
||||
} catch (\Exception $error) {
|
||||
DB::rollBack();
|
||||
@@ -124,12 +138,22 @@ class ClaimRequestService{
|
||||
throw new ImportRowException(__('Member Tidak ditemukan'), 0, null, $row);
|
||||
};
|
||||
$code = $row['client_claim_id'];
|
||||
$organization_id = $row['provider_code'];
|
||||
$submissionDate = Helper::formatDateDB($row['admission_date']);
|
||||
$paymentType = $row['claim_type'];
|
||||
$status = $row['status'];
|
||||
$serviceCode = $row['coverage_type'];
|
||||
|
||||
$newClaimRequest = $this->storeClaimRequest(code: $code, member: $member, paymentType: $paymentType, serviceCode: $serviceCode, submissionDate: $submissionDate, status: $status);
|
||||
$newClaimRequest = $this->storeClaimRequest(
|
||||
row: $row,
|
||||
code: $code,
|
||||
member: $member,
|
||||
paymentType: $paymentType,
|
||||
serviceCode: $serviceCode,
|
||||
submissionDate: $submissionDate,
|
||||
status: $status,
|
||||
organization_code: $organization_id
|
||||
);
|
||||
|
||||
$newlyCreatedID = $newClaimRequest->id;
|
||||
|
||||
@@ -145,6 +169,7 @@ class ClaimRequestService{
|
||||
|
||||
$claim_request_data = $row;
|
||||
|
||||
dd($row);
|
||||
// dd($claim_request_data['admission_date']);
|
||||
|
||||
$this->validatePlanRow($claim_request_data);
|
||||
|
||||
Reference in New Issue
Block a user