<?php

namespace Modules\Internal\Transformers;

use App\Models\Benefit;
use App\Models\CorporateEmployee;
use App\Models\ClaimRequest;
use App\Models\Icd;
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)
    {
        $claim = parent::toArray($request);

        $member_data = CorporateEmployee::where('member_id', $claim['member_id'])->first();
        $claim_request = ClaimRequest::where('id', $claim['claim_request_id'])->first();

        $data = [
            'id' => $claim['id'],
            'uuid' => $claim['uuid'],
            'code' => $claim['code'],
            'claim_request_id' => $claim['claim_request_id'],
            'member_id' => $claim['member_id'],
            'currency' => $claim['currency'],
            'total_claim' => $claim['total_claim'],
            'plan_id' => $claim['plan_id'],
            'benefit_id' => $claim['benefit_id'],
            'organization_id' => $claim['organization_id'],
            'benefit_code' => $claim['benefit_code'],
            'benefit_desc' => $claim['benefit_desc'],
            'amount_incurred' => $claim['amount_incurred'],
            'amount_approved' => $claim['amount_approved'],
            'amount_not_approved' => $claim['amount_not_approved'],
            'excess_paid' => $claim['excess_paid'],
            'final_encounter_id' => $claim['final_encounter_id'],
            'status' => $claim['status'],
            'created_at' => $claim['created_at'],
            'corporate_id' => $member_data->corporate_id,
            'service_code' => $claim_request->service_code
            // "uuid" => "9a59bff7-857f-4e48-8c6b-242ad1286395"
            // "" => "CLM-00035"
            // "" => 66
            // "member_id" => 3
            // "" => "IDR"
            // "" => null
            // "" => 1
            // "" => null
            // "" => 0
            // "benefit_code" => ""
            // "benefit_desc" => "erwraf"
            // "" => 10000
            // "" => 123000
            // "amount_not_approved" => 122000
            // "excess_paid" => 230000
            // "final_encounter_id" => null
            // "status" => "received"
            // "created_at" => "2023-10-12T09:23:54.000000Z"
        ];
        // $data['benefit_items'] = $this->items
        $data['history_hospital_care'] = $claim['history_hospital_care'];
        // $data['main_diagnosis']

        return $data;
    }
}
