add export report

This commit is contained in:
2023-06-09 12:00:51 +07:00
parent 20c2bea127
commit 01727bd02b
2 changed files with 53 additions and 38 deletions

View File

@@ -310,58 +310,68 @@ class ClaimController extends Controller
$claims = Claim::with([ $claims = Claim::with([
'member', 'member',
'member.currentPolicy',
'member.currentPlan',
'member.currentCorporate',
'diagnoses' => function ($diagnosis) { 'diagnoses' => function ($diagnosis) {
return $diagnosis->where('type', 'primary'); return $diagnosis->where('type', 'primary');
}, },
'diagnoses.icd', 'diagnoses.icd',
'plan', 'plan',
'benefit', 'benefit',
'claimRequest', 'claimRequest',
'claimRequest.service' 'claimRequest.service'
]) ])
// ->latest() // ->latest()
->get()->toArray(); ->get()->toArray();
foreach ($claims as $index => $row){ foreach ($claims as $index => $row){
$rowData = [ $rowData = [
'', // Count of Usage '', // Count of Usage
$row['code'], $row['code'], // Claim Number
$row['code'], '', // Insurar Code
$row['code'], $row['member']['current_policy']? $row['member']['current_policy']['code'] : '', // Policy no
$row['code'], $row['member']['current_corporate']? $row['member']['current_corporate']['name'] : '', // Corporate Name
$row['code'], $row['member']['current_plan']? $row['member']['current_plan']['code'] : '', // Plan Code
$row['code'], $row['member']['name'], // Member Name
$row['code'], $row['member']['record_type'], // Member Status
$row['code'], $row['member']['birth_date'], // Date of brith
$row['code'], $row['member']['member_id'], // Member Number
$row['code'], $row['member']['current_corporate']? $row['member']['current_corporate']['code'] : '', // Institution Code
$row['code'], '', // Invoice Line Number
$row['code'], $row['status'], // Claim Status
$row['code'], '', // Admission Date
$row['code'], '', // Discharge Date
$row['code'], '', // Date Of Service
$row['code'], '', // Place Of Service
$row['code'], '', // Los
$row['code'], '', // Provider code
$row['code'], '', // Treating Doctor Code
$row['code'], '', // Treating Doctor Name
$row['code'], '', // Doctor Title
$row['code'], $row['diagnoses']?$row['diagnoses'][0]['icd']['name']: '-', // Diagnosis
$row['code'], $row['plan']['service_code'], // Service Code
$row['code'], $row['plan']['type'], // ServiceType
$row['code'], $row['claim_request'] ? $row['claim_request']['service']['description'] : '', // ServiceDescription
$row['code'], '', // UnitPrice
$row['code'], '', // Quantity
$row['code'], '', // Tarif
$row['code'], '', // Claimable amount
$row['code'], '', // Paid by customer
$row['code'], '', // HD Disc
$row['code'], '', // Doctor Notes
$row['code'], '', // ConsultationID Date
$row['code'], '', // Pharmacy Code
$row['code'], '', // Pharmacy Name
$row['code'], '', // Pharmacy Permit Number
'', // Pharmacy Address
'', // Pharmacy Phone number
'', // Delivery Address
'', // Claimable Status
$row['claim_request'] ? $row['claim_request']['service']['description'] : '', // ServiceDescription, // Benefit Code
]; ];
$row = WriterEntityFactory::createRowFromArray($rowData);
$writer->addRow($row);
} }
// $dataClaim = Claim::query // $dataClaim = Claim::query

View File

@@ -224,6 +224,11 @@ class Claim extends Model
{ {
return $this->belongsTo(Plan::class, 'plan_id'); return $this->belongsTo(Plan::class, 'plan_id');
} }
public function curentCorporate()
{
return $this->hashOne(Corporate::class, 'corporate_id', 'id');
}
public function benefit() public function benefit()
{ {