update validasi benefit & plan
This commit is contained in:
@@ -19,6 +19,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Facades\File as FacadesFile;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
@@ -455,7 +456,6 @@ class CorporateController extends Controller
|
||||
} else if ($sheet->getName() == 'Benefit') {
|
||||
$corporateService->handleBenefitRow($corporate, $row_data);
|
||||
}
|
||||
|
||||
// Write Success Result to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
'Ingest Code' => 200,
|
||||
@@ -519,5 +519,170 @@ class CorporateController extends Controller
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function dataPlanBenefit(Request $request, $corporate_id){
|
||||
|
||||
$file_name = 'Corporate Plan and Benefit';
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/CorporatePlan&BenefitImportData.xlsx'));
|
||||
|
||||
// Sheet 1
|
||||
$writer->getCurrentSheet()->setName('Plans');
|
||||
$headers_map_to_table_fields = Plan::$listing_doc_headers;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
$writer->addRow($headerRow);
|
||||
|
||||
$dataPlans = Plan::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
|
||||
// $corporatePlan->where('corporate_id', $corporate_id);
|
||||
// })
|
||||
// ->with('corporatePlan')
|
||||
->orderBy('corporate_plan_id', 'asc')
|
||||
->get()->toArray();
|
||||
foreach ($dataPlans as $index => $row){
|
||||
$rowData = [
|
||||
$row['service_code'], // Service
|
||||
$row['corporate_plan_id'], // Plan
|
||||
$row['code'], // Customer plans
|
||||
$row['type'], // Plan Type
|
||||
$row['start'], // Start Date of Plan
|
||||
$row['end'], // End Date of Plan
|
||||
$row['require_referral'], // Referral
|
||||
$row['referral_source'], // Referral Source
|
||||
$row['referral_duration'], // Referral Duration
|
||||
$row['family_plan'], // Family Plan
|
||||
$row['family_plan_share_rules'], // Family Sharing Overflow
|
||||
$row['limit_rules'], // Plan Limit
|
||||
$row['layer'], // Layer ID
|
||||
$row['layer_conditions'], // Layer Condition
|
||||
$row['budget_type'], // Budget Type
|
||||
$row['budget_code'], // Budget Code
|
||||
$row['budget_conditions'], // Budget Condition
|
||||
$row['surgery_limit'], // Surgery
|
||||
$row['non_surgery_limit'], // Non Surgery
|
||||
$row['max_claim_limit'], // Max/Claim
|
||||
$row['max_claim_count'], // Max Count of Claim
|
||||
$row['area_limit'], // Area
|
||||
$row['limit_shared_plans'], // Shared Plan
|
||||
$row['limit_shared_plan_type'], // Shared Plan Type
|
||||
$row['cashless_percentage'], // Cashless(%)
|
||||
$row['reimbursement_percentage'], // Reimbursement(%)
|
||||
$row['digital_percentage'], // Digital(%)
|
||||
$row['co_share_m_percentage'], // CoShareM(%)
|
||||
$row['co_share_s_percentage'], // CoShareS(%)
|
||||
$row['co_share_c_percentage'], // CoShareC(%)
|
||||
$row['cashless_deductible'], // Cashless Deductible
|
||||
$row['cashless_deductible'], // Reimbursement Deductible
|
||||
$row['digital_deductible'], // Digital Deductible
|
||||
$row['co_share_m_deductible'], // DeductibleM
|
||||
$row['co_share_s_deductible'], // DeductibleS
|
||||
$row['co_share_c_deductible'], // DeductibleC
|
||||
$row['co_share_deductible_condition'], // Co-share & Deductible Condition
|
||||
$row['msc'], // MSC
|
||||
$row['genders'], // Gender
|
||||
$row['min_age'], // Min Age
|
||||
$row['max_age'], // Max Age
|
||||
$row['rule_of_excess'], // Rule of Excess
|
||||
$row['max_excess_covered'], // Max Excess Covered
|
||||
$row['prorate_type'], // Prorate Type
|
||||
$row['prorate_lookup'], // Prorate Lookup
|
||||
$row['currency'], // Currency
|
||||
$row['max_surgery_reinstatement_days'], // Reinstatement days for Surgery NonSurgery
|
||||
$row['max_surgery_periode_days'], // Max Periode of Surgery Non Surgery
|
||||
];
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
|
||||
// Menutup penulis
|
||||
|
||||
// Sheet 2
|
||||
$writer->addNewSheetAndMakeItCurrent();
|
||||
$writer->getCurrentSheet()->setName('Benefit');
|
||||
$headers_map_to_table_fields = CorporateBenefit::$listing_doc_headers;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
$writer->addRow($headerRow);
|
||||
|
||||
$dataBenfit = CorporateBenefit::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->with('benefit', 'plan')
|
||||
->orderBy('plan_id', 'asc')
|
||||
->get()->toArray();
|
||||
// dd($dataBenfit);
|
||||
foreach($dataBenfit as $index => $row){
|
||||
$rowData = [
|
||||
$row['benefit']['service_code'] ?? NULL, // "Service",
|
||||
$row['plan']['type'] ?? NULL, // "Plan",
|
||||
$row['benefit']['code'] ?? NULL, // "Benefit Code",
|
||||
$row['benefit']['code'] ?? NULL, // "Customer Benefit Code",
|
||||
$row['benefit']['description'] ?? NULL, // "Detail Benefit",
|
||||
$row['budget'], // "ASO/Budget",
|
||||
$row['budget_conditions'], // "Budget Condition",
|
||||
$row['budget_code'], // "Budget Code",
|
||||
$row['primary_benefit_code'], // "Primary benefit",
|
||||
$row['benefit_mode'], // "Benefit Mode",
|
||||
$row['room_class_coverage'], // "Room Class",
|
||||
$row['max_bed_coverage'], // "Max Bed",
|
||||
$row['tolerance_parameter'], // "Tolerance Paramater",
|
||||
$row['max_room_class'], // "Max. Room Class",
|
||||
$row['limit_amount'], // "Limit Value",
|
||||
$row['area_limit'], // "Area",
|
||||
$row['shared_benefit'], // "Shared Benefit With",
|
||||
$row['shared_benefit_type'], // "Shared Benefit Type",
|
||||
$row['msc'], // "MSC",
|
||||
$row['genders'], // "Gender",
|
||||
$row['min_age'], // "Min Age",
|
||||
$row['max_age'], // "Max Age",
|
||||
$row['max_frequency_period'], // "Freq. Period",
|
||||
$row['daily_frequency'], // "Daily Frequency",
|
||||
$row['weekly_frequency'], // "Weekly Frequency",
|
||||
$row['monthly_frequency'], // "Monthly Frequency",
|
||||
$row['yearly_frequency'], // "Yearly Frequency",
|
||||
$row['custom_frequency_days'], // "Custom Duration",
|
||||
$row['custom_duration_value'], // "Custom Duration Value",
|
||||
NULL, // "Cashless, Reimbursement",
|
||||
$row['high_plan_factor'], // "High Plan Factor",
|
||||
$row['pre_post_treatment'], // "Pre Post Treatment",
|
||||
$row['pre_treatment_days'], // "Pre Treatment",
|
||||
$row['post_treatment_days'], // "Post Treatment",
|
||||
$row['layer_type_1'], // "Layer Type 1",
|
||||
$row['layer_value_1'], // "Layer Value 1",
|
||||
$row['layer_type_2'], // "Layer Type 2",
|
||||
$row['layer_value_2'], // "Layer Value 2",
|
||||
$row['cashless_percentage'], // "Cashless (%)",
|
||||
$row['reimbursement_percentage'], // "Reimburse (%)",
|
||||
$row['digital_percentage'], // "Digital (%)",
|
||||
$row['co_share_m_percentage'], // "CoShareM (%)",
|
||||
$row['co_share_s_percentage'], // "CoShareS (%)",
|
||||
$row['co_share_c_deductible'], // "CoShareC (%)",
|
||||
$row['cashless_deductible'], // "Cashless Deductible",
|
||||
$row['reimbursement_deductible'], // "Reimbursement Deductible",
|
||||
$row['digital_deductible'], // "Digital Deductible",
|
||||
$row['co_share_m_deductible'], // "DeductibleM",
|
||||
$row['co_share_s_deductible'], // "DeductibleS",
|
||||
$row['co_share_c_deductible'], // "DeductibleC",
|
||||
$row['prorate_type'], // "Prorate Type",
|
||||
$row['prorate_lookup'], // "Prorate Lookup",
|
||||
$row['max_days_for_disability'], // "Max Days for Disability",
|
||||
$row['max_period_for_disability'], // "Max Periode of Disability",
|
||||
$row['currency'], // "Currency",
|
||||
$row['show_benefit_item'], // "Show Benefit Item",
|
||||
$row['show_benefit_value'], // "Show Benefit Value",
|
||||
];
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Data Corporate Plan & Benefit List " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/CorporatePlan&BenefitImportData.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user