update final log
This commit is contained in:
80
Modules/Internal/Transformers/RequestLogShowResource.php
Normal file
80
Modules/Internal/Transformers/RequestLogShowResource.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use App\Models\Benefit;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\ClaimRequest;
|
||||
use App\Models\CorporateService;
|
||||
use App\Models\RequestLogBenefit;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\Icd;
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RequestLogShowResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$requestLog = parent::toArray($request);
|
||||
$corporateId = $requestLog['member']['current_plan']['corporate_id'] ?? 0;
|
||||
$benefit = CorporateBenefit::with('benefit')->where('plan_id', $corporateId)->get()->toArray();
|
||||
$benefitDetailLog = RequestLogBenefit::with('benefit')->where('request_log_id', $requestLog['id'])->get()->toArray();
|
||||
$benefitData = [];
|
||||
if (count($benefit)){
|
||||
foreach($benefit as $data){
|
||||
array_push($benefitData, $data['benefit']);
|
||||
}
|
||||
}
|
||||
|
||||
// Service Rule
|
||||
$corporateService = CorporateService::query()
|
||||
->where('corporate_id', $corporateId)
|
||||
->where('service_code', $requestLog['service_code'])
|
||||
->with(['configs'])
|
||||
->first();
|
||||
$config = $corporateService->configs->pluck('value', 'name')->toArray();
|
||||
|
||||
// Exclusion Service or diagnosis
|
||||
$exclusions = Exclusion::query()
|
||||
->where('corporate_id', $corporateId)
|
||||
->where('type', 'diagnosis')
|
||||
->with(['exclusionable', 'rules'])
|
||||
->get()->toArray();
|
||||
|
||||
$data = [
|
||||
'id' => $requestLog['id'],
|
||||
'code' => $requestLog['code'],
|
||||
'member_id' => $requestLog['member']['member_id'],
|
||||
'policy_number' => $requestLog['member']['current_policy']['code'],
|
||||
'name' => $requestLog['member']['name'],
|
||||
'date_of_birth' => $requestLog['member']['birth_date'],
|
||||
'gender' => $requestLog['member']['gender'],
|
||||
'marital_status' => Helper::maritalNormalization($requestLog['member']['marital_status']),
|
||||
'member_type' => Helper::memberType($requestLog['member']['record_type']),
|
||||
'principal_id' => $requestLog['member']['principal_id'] ? $requestLog['member']['principal_id'] : '-',
|
||||
'principal_name' => $requestLog['member']['principal_id'] ? Helper::principalName($requestLog['member']['principal_id']) : '-',
|
||||
'relation_with_principal' => Helper::relationWithPrincipal($requestLog['member']['relation_with_principal']),
|
||||
'submission_date' => $requestLog['submission_date'],
|
||||
'service_type' => Helper::serviceName($requestLog['service_code']),
|
||||
'claim_method' => $requestLog['payment_type'],
|
||||
'status' => $requestLog['status'],
|
||||
'status_final_log' => $requestLog['status_final_log'],
|
||||
'benefit' => $benefitData,
|
||||
'benefit_data' => $benefitDetailLog,
|
||||
'config_service' => $config,
|
||||
'exclusion' => $exclusions,
|
||||
'files' => $requestLog['files'],
|
||||
|
||||
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user