update validasi benefit & plan
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Exceptions\ImportRowException;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\CorporatePolicy;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
@@ -13,16 +14,105 @@ class CorporateService
|
||||
{
|
||||
protected function validatePlanRow($row)
|
||||
{
|
||||
// $corporate_policy = CorporatePolicy::where('corporate_id', $corporateId)->get();
|
||||
/*
|
||||
Refer to Coverage code :
|
||||
MEDIVAC = Medical evacuation
|
||||
MSO = Medical second opinion
|
||||
PAC = Personal Assistant Concierge
|
||||
OPDE = Outpatient Dental
|
||||
IP=Inpatient
|
||||
OP=Outpatient
|
||||
MA=Maternity
|
||||
ANC = Ante/Post Natal Care
|
||||
DE=Dental
|
||||
GL=Glasses
|
||||
SP=Special Treatment
|
||||
PF=Pooled Fund
|
||||
MCU=Medical Check Up
|
||||
KB-VACC = Family Planning/Vaccination
|
||||
LAB = Test Diagnostic
|
||||
PHAR = Pharmacy
|
||||
**/
|
||||
|
||||
$service_code = ['MEDIVAC', 'MSO', 'PAC', 'OPDE', 'IP', 'OP', 'MA', 'ANC', 'DE', 'GL', 'SP', 'PF', 'MCU', 'KB-VACC', 'LAB', 'PHAR'];
|
||||
$plan_code = [1, 2, 3, 4];
|
||||
$prorate_type = [0, 1, 2];
|
||||
$family_plan = ['F', 'S', 'N'];
|
||||
|
||||
if (empty($row['service_code'])) {
|
||||
throw new ImportRowException(__('plan.RECORD_TYPE_REQUIRED'), 0, null, $row);
|
||||
throw new ImportRowException(__('plan.REQUIRED', [
|
||||
'attribute' => 'Service Code'
|
||||
] ), 0, null, $row);
|
||||
} else if (!in_array($row['service_code'], $service_code)){
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Service Code',
|
||||
'code' => $row['service_code']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (empty($row['corporate_plan_id'])) {
|
||||
throw new ImportRowException(__('plan.REQUIRED', [
|
||||
'attribute' => 'Plan'
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (empty($row['code'])) {
|
||||
throw new ImportRowException(__('plan.CODE_REQUIRED'), 0, null, $row);
|
||||
throw new ImportRowException(__('plan.REQUIRED', [
|
||||
'attribute' => 'Customer Plan'
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (!in_array($row['type'], $plan_code)){
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Plan Type',
|
||||
'code' => $row['type']
|
||||
]), 0, null, $row);
|
||||
} else if ($row['type'] == 2 && $row['limit_rules'] != 999999999){
|
||||
throw new ImportRowException(__('plan.LIMIT_PLAN'), 0, null, $row);
|
||||
}
|
||||
|
||||
if (empty($row['type'])) {
|
||||
throw new ImportRowException(__('plan.TYPE_REQUIRED'), 0, null, $row);
|
||||
// if (!empty($row['start'])) {
|
||||
// throw new ImportRowException(__('plan.REQUIRED', [
|
||||
// 'attribute' => 'Start Date of Plan'
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
|
||||
// if (empty($row['type'])) {
|
||||
// throw new ImportRowException(__('plan.TYPE_REQUIRED'), 0, null, $row);
|
||||
// } else if (!in_array($row['type'],$plan_code)){
|
||||
// throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
// 'attribute' => 'Plan Type',
|
||||
// 'code' => $row['code']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
|
||||
if (!empty($row['family_plan']) && !in_array($family_plan)) {
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Family Plan',
|
||||
'code' => $row['family_plan']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (!empty($row['family_plan']) && !in_array($family_plan)) {
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Family Plan',
|
||||
'code' => $row['family_plan']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (!empty($row['prorate_type']) && !in_array($prorate_type)) {
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Prorate Type',
|
||||
'code' => $row['prorate_type']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (!empty($row['prorate_lookup']) && !in_array($prorate_type)) {
|
||||
throw new ImportRowException(__('plan.NOT_MATCH', [
|
||||
'attribute' => 'Prorate Lookup',
|
||||
'code' => $row['prorate_lookup']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if (empty($row['limit_rules'])) {
|
||||
@@ -38,8 +128,8 @@ class CorporateService
|
||||
{
|
||||
try {
|
||||
$plan_data = $row;
|
||||
$plan_data["corporate_id"] = $corporate->id;
|
||||
$this->validatePlanRow($plan_data);
|
||||
$plan_data["corporate_id"] = $corporate->id;
|
||||
$plan = $corporate->plans()->updateOrCreate([
|
||||
'corporate_plan_id' => $plan_data['corporate_plan_id'],
|
||||
// 'active' => 0,
|
||||
@@ -53,6 +143,8 @@ class CorporateService
|
||||
|
||||
protected function validateBenefitRow($row)
|
||||
{
|
||||
$max_frequence = 7;
|
||||
$budget_aso = [1,2];
|
||||
if (empty($row['service_code'])) {
|
||||
throw new ImportRowException(__('benefit.SERVICE_CODE_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
@@ -77,6 +169,13 @@ class CorporateService
|
||||
if (empty($row['genders'])) {
|
||||
throw new ImportRowException(__('benefit.GENDER_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
if (!empty($row['max_frequency_period']) && $row['max_frequency_period'] >= $max_frequence){ // jenis frequence
|
||||
throw new ImportRowException(__('benefit.MAX_FREQUENCY'), 0, null, $row);
|
||||
}
|
||||
|
||||
if (!empty($row['budget']) && !in_array($budget_aso)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function handleBenefitRow(Corporate $corporate, $row)
|
||||
|
||||
Reference in New Issue
Block a user