Merge branch 'master' into pajri
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\MemberBenefit;
|
use App\Models\MemberBenefit;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -18,9 +19,10 @@ class BenefitController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$benefits = Benefit::query()
|
$benefits = CorporateBenefit::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
|
->with('benefit')
|
||||||
->paginate()
|
->paginate()
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
@@ -89,59 +91,59 @@ class BenefitController extends Controller
|
|||||||
|
|
||||||
public function memberBenefitImport(Request $request, $corporate_id)
|
public function memberBenefitImport(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$request->validate([
|
// $request->validate([
|
||||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
// 'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
]);
|
// ]);
|
||||||
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
// $file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
// $file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
|
|
||||||
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
// $reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
||||||
$reader->open(Storage::path('temp/'.$file_name));
|
// $reader->open(Storage::path('temp/'.$file_name));
|
||||||
|
|
||||||
$headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
|
// $headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
|
||||||
|
|
||||||
$imported_benefit_data = 0;
|
// $imported_benefit_data = 0;
|
||||||
$failed_benefit_data = [];
|
// $failed_benefit_data = [];
|
||||||
foreach ($reader->getSheetIterator() as $sheet) {
|
// foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
$doc_headers_indexes = [];
|
// $doc_headers_indexes = [];
|
||||||
foreach ($sheet->getRowIterator() as $index => $row) {
|
// foreach ($sheet->getRowIterator() as $index => $row) {
|
||||||
if ($index == 1) { // First Row Must be Header
|
// if ($index == 1) { // First Row Must be Header
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
// foreach ($row->getCells() as $index => $cell) {
|
||||||
$doc_headers_indexes[$index] = rtrim($cell->getValue());
|
// $doc_headers_indexes[$index] = rtrim($cell->getValue());
|
||||||
}
|
// }
|
||||||
} else { // Next Row Should be Data
|
// } else { // Next Row Should be Data
|
||||||
$new_benefit_data = [];
|
// $new_benefit_data = [];
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
// foreach ($row->getCells() as $index => $cell) {
|
||||||
$new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
// $new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $imported_plan_data[] = $new_row; // Insert to Array
|
// // $imported_plan_data[] = $new_row; // Insert to Array
|
||||||
// Create Directly
|
// // Create Directly
|
||||||
$new_benefit_data['corporate_id'] = $corporate_id;
|
// $new_benefit_data['corporate_id'] = $corporate_id;
|
||||||
try {
|
// try {
|
||||||
Benefit::updateOrCreate([
|
// Benefit::updateOrCreate([
|
||||||
'corporate_id' => $corporate_id,
|
// 'corporate_id' => $corporate_id,
|
||||||
'code' => $new_benefit_data['code']
|
// 'code' => $new_benefit_data['code']
|
||||||
], $new_benefit_data);
|
// ], $new_benefit_data);
|
||||||
|
|
||||||
$imported_benefit_data++;
|
// $imported_benefit_data++;
|
||||||
} catch(\Exception $e) {
|
// } catch(\Exception $e) {
|
||||||
$new_benefit_data['error'] = $e->getMessage();
|
// $new_benefit_data['error'] = $e->getMessage();
|
||||||
$failed_benefit_data[] = $new_benefit_data;
|
// $failed_benefit_data[] = $new_benefit_data;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
break; //only read first sheet
|
// break; //only read first sheet
|
||||||
}
|
// }
|
||||||
$reader->close();
|
// $reader->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
// Storage::delete('temp/'.$file_name);
|
||||||
// throw(404);
|
// // throw(404);
|
||||||
|
|
||||||
return [
|
// return [
|
||||||
'total_successed_row' => $imported_benefit_data,
|
// 'total_successed_row' => $imported_benefit_data,
|
||||||
'total_failed_row' => count($failed_benefit_data),
|
// 'total_failed_row' => count($failed_benefit_data),
|
||||||
'failed_row' => $failed_benefit_data
|
// 'failed_row' => $failed_benefit_data
|
||||||
];
|
// ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Imports\PlansImport;
|
|||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
use App\Models\Claim;
|
use App\Models\Claim;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -347,7 +348,7 @@ class CorporateController extends Controller
|
|||||||
// dd($request->toArray());
|
// dd($request->toArray());
|
||||||
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
||||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
$corporate = Corporate::findOrFail($corporate_id);
|
$corporate = Corporate::with(['plans'])->findOrFail($corporate_id);
|
||||||
|
|
||||||
$import = new ImportService();
|
$import = new ImportService();
|
||||||
$import->read(Storage::path('temp/' . $file_name));
|
$import->read(Storage::path('temp/' . $file_name));
|
||||||
@@ -368,7 +369,7 @@ class CorporateController extends Controller
|
|||||||
if ($sheet->getName() == 'Plan') {
|
if ($sheet->getName() == 'Plan') {
|
||||||
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
||||||
} else if ($sheet->getName() == 'Benefit') {
|
} else if ($sheet->getName() == 'Benefit') {
|
||||||
$headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
|
$headers_map_to_table_fields = CorporateBenefit::$doc_headers_to_field_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write Header to File
|
// Write Header to File
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Modules\Internal\Services;
|
|||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
|
||||||
@@ -61,10 +62,10 @@ class CorporateService
|
|||||||
if (empty($row['plan_code'])) {
|
if (empty($row['plan_code'])) {
|
||||||
throw new ImportRowException(__('benefit.PLAN_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.PLAN_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['benefit_code'])) {
|
if (empty($row['code'])) {
|
||||||
throw new ImportRowException(__('benefit.BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['code'])) {
|
if (empty($row['corporate_benefit_code'])) {
|
||||||
throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['description'])) {
|
if (empty($row['description'])) {
|
||||||
@@ -86,20 +87,28 @@ class CorporateService
|
|||||||
try {
|
try {
|
||||||
$benefit_data = $row;
|
$benefit_data = $row;
|
||||||
$benefit_data["corporate_id"] = $corporate->id;
|
$benefit_data["corporate_id"] = $corporate->id;
|
||||||
|
|
||||||
$this->validateBenefitRow($benefit_data);
|
$this->validateBenefitRow($benefit_data);
|
||||||
$plan = Plan::where('corporate_id', $corporate->id)->where('corporate_plan_id', $benefit_data['plan_code'])->first();
|
|
||||||
|
$plan = $corporate->plans->where('corporate_plan_id', $benefit_data['plan_code'])->first();
|
||||||
$benefit_data['plan_code'] = $plan->id;
|
$benefit_data['plan_code'] = $plan->id;
|
||||||
|
|
||||||
$benefit = Benefit::updateOrCreate([
|
$benefit = Benefit::updateOrCreate([
|
||||||
'service_code' => $benefit_data['service_code'],
|
|
||||||
'plan_code' => $benefit_data['plan_code'],
|
|
||||||
'corporate_id' => $corporate->id,
|
|
||||||
'code' => $benefit_data['code'],
|
'code' => $benefit_data['code'],
|
||||||
], $benefit_data);
|
'service_code' => $plan->service_code,
|
||||||
|
], [
|
||||||
|
'code' => $benefit_data['code'],
|
||||||
|
'service_code' => $plan->service_code,
|
||||||
|
'active' => true
|
||||||
|
]);
|
||||||
|
|
||||||
return $benefit;
|
$corporateBenefit = $corporate->corporateBenefits()->updateOrCreate([
|
||||||
|
'benefit_id' => $benefit->id,
|
||||||
|
'plan_id' => $plan->id
|
||||||
|
], $benefit_data );
|
||||||
|
|
||||||
|
return $corporateBenefit;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
dd($e->getMessage());
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,156 +12,12 @@ class Benefit extends Model
|
|||||||
use HasFactory, SoftDeletes, Blameable;
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
|
||||||
'service_code',
|
'service_code',
|
||||||
'plan_code',
|
|
||||||
'benefit_code',
|
|
||||||
'code',
|
'code',
|
||||||
'description',
|
'description',
|
||||||
'budget',
|
'active'
|
||||||
'budget_conditions',
|
|
||||||
'budget_code',
|
|
||||||
'primary_benefit_code',
|
|
||||||
'benefit_mode',
|
|
||||||
'room_class_coverage',
|
|
||||||
'max_bed_coverage',
|
|
||||||
'tolerance_parameter',
|
|
||||||
'max_room_class',
|
|
||||||
'limit_amount',
|
|
||||||
'area_limit',
|
|
||||||
'shared_benefit',
|
|
||||||
'shared_benefit_type',
|
|
||||||
'msc',
|
|
||||||
'genders',
|
|
||||||
'min_age',
|
|
||||||
'max_age',
|
|
||||||
'max_frequency_period',
|
|
||||||
'daily_frequency',
|
|
||||||
'weekly_frequency',
|
|
||||||
'monthly_frequency',
|
|
||||||
'yearly_frequency',
|
|
||||||
'custom_frequency_days',
|
|
||||||
'custom_duration_value',
|
|
||||||
'allowed_transaction_types',
|
|
||||||
'high_plan_factor',
|
|
||||||
'pre_post_treatment',
|
|
||||||
'pre_treatment_days',
|
|
||||||
'post_treatment_days',
|
|
||||||
'layer_type_1',
|
|
||||||
'layer_value_1',
|
|
||||||
'layer_type_2',
|
|
||||||
'layer_value_2',
|
|
||||||
'cashless_percentage',
|
|
||||||
'reimbursement_percentage',
|
|
||||||
'digital_percentage',
|
|
||||||
'co_share_m_percentage',
|
|
||||||
'co_share_s_percentage',
|
|
||||||
'co_share_c_percentage',
|
|
||||||
'cashless_deductible',
|
|
||||||
'reimbursement_deductible',
|
|
||||||
'digital_deductible',
|
|
||||||
'co_share_m_deductible',
|
|
||||||
'co_share_s_deductible',
|
|
||||||
'co_share_c_deductible',
|
|
||||||
'prorate_type',
|
|
||||||
'prorate_lookup',
|
|
||||||
'max_days_for_disability',
|
|
||||||
'max_period_for_disability',
|
|
||||||
'currency',
|
|
||||||
'show_benefit_item',
|
|
||||||
'show_benefit_value',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $doc_headers_to_field_map = [
|
|
||||||
"Service" => 'service_code',
|
|
||||||
"Plan" => 'plan_code',
|
|
||||||
"Benefit Code" => 'benefit_code',
|
|
||||||
"Customer Benefit Code" => 'code',
|
|
||||||
"Detail Benefit" => 'description',
|
|
||||||
"ASO/Budget" => 'budget',
|
|
||||||
"Budget Condition" => 'budget_conditions',
|
|
||||||
"Budget Code" => 'budget_code',
|
|
||||||
"Primary benefit" => 'primary_benefit_code',
|
|
||||||
"Benefit Mode" => 'benefit_mode',
|
|
||||||
"Room Class" => 'room_class_coverage',
|
|
||||||
"Max Bed" => 'max_bed_coverage',
|
|
||||||
"Tolerance Paramater" => 'tolerance_parameter',
|
|
||||||
"Max. Room Class" => 'max_room_class',
|
|
||||||
"Limit Value" => 'limit_amount',
|
|
||||||
"Area" => 'area_limit',
|
|
||||||
"Shared Benefit With" => 'shared_benefit',
|
|
||||||
"Shared Benefit Type" => 'shared_benefit_type',
|
|
||||||
"MSC" => 'msc',
|
|
||||||
"Gender" => 'genders',
|
|
||||||
"Min Age" => 'min_age',
|
|
||||||
"Max Age" => 'max_age',
|
|
||||||
"Freq. Period" => 'max_frequency_period',
|
|
||||||
"Daily Frequency" => 'daily_frequency',
|
|
||||||
"Weekly Frequency" => 'weekly_frequency',
|
|
||||||
"Monthly Frequency" => 'monthly_frequency',
|
|
||||||
"Yearly Frequency" => 'yearly_frequency',
|
|
||||||
"Custom Duration" => 'custom_frequency_days',
|
|
||||||
"Custom Duration Value" => 'custom_duration_value',
|
|
||||||
"Cashless, Reimbursement" => 'allowed_transaction_types',
|
|
||||||
"High Plan Factor" => 'high_plan_factor',
|
|
||||||
"Pre Post Treatment" => 'pre_post_treatment',
|
|
||||||
"Pre Treatment" => 'pre_treatment_days',
|
|
||||||
"Post Treatment" => 'post_treatment_days',
|
|
||||||
"Layer Type 1" => 'layer_type_1',
|
|
||||||
"Layer Value 1" => 'layer_value_1',
|
|
||||||
"Layer Type 2" => 'layer_type_2',
|
|
||||||
"Layer Value 2" => 'layer_value_2',
|
|
||||||
"Cashless (%)" => 'cashless_percentage',
|
|
||||||
"Reimburse (%)" => 'reimbursement_percentage',
|
|
||||||
"Digital (%)" => 'digital_percentage',
|
|
||||||
"CoShareM (%)" => 'co_share_m_percentage',
|
|
||||||
"CoShareS (%)" => 'co_share_s_percentage',
|
|
||||||
"CoShareC (%)" => 'co_share_c_percentage',
|
|
||||||
"Cashless Deductible" => 'cashless_deductible',
|
|
||||||
"Reimbursement Deductible" => 'reimbursement_deductible',
|
|
||||||
"Digital Deductible" => 'digital_deductible',
|
|
||||||
"DeductibleM" => 'co_share_m_deductible',
|
|
||||||
"DeductibleS" => 'co_share_s_deductible',
|
|
||||||
"DeductibleC" => 'co_share_c_deductible',
|
|
||||||
"Prorate Type" => 'prorate_type',
|
|
||||||
"Prorate Lookup" => 'prorate_lookup',
|
|
||||||
"Max Days for Disability" => 'max_days_for_disability',
|
|
||||||
"Max Periode of Disability" => 'max_period_for_disability',
|
|
||||||
"Currency" => 'currency',
|
|
||||||
"Show Benefit Item" => 'show_benefit_item',
|
|
||||||
"Show Benefit Value" => 'show_benefit_value',
|
|
||||||
];
|
|
||||||
|
|
||||||
public static $max_frequency_periods = [
|
|
||||||
0 => 'Policy Period',
|
|
||||||
1 => 'Daily Visit',
|
|
||||||
2 => 'Weekly',
|
|
||||||
3 => 'Monthly',
|
|
||||||
4 => 'Yearly',
|
|
||||||
5 => 'Disability',
|
|
||||||
6 => 'Visit',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $appends = [
|
|
||||||
'max_frequency_period_name',
|
|
||||||
'max_frequency'
|
|
||||||
];
|
|
||||||
|
|
||||||
public function setAreaLimitAttribute($value)
|
|
||||||
{
|
|
||||||
$this->attributes['area_limit'] = empty($value) ? null : $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPrePostTreatmentAttribute($value)
|
|
||||||
{
|
|
||||||
$this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrePostTreatmentAttribute($value)
|
|
||||||
{
|
|
||||||
return empty($value) ? null : ($value ? 'Y' : 'N');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
@@ -174,51 +30,17 @@ class Benefit extends Model
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function benefit()
|
// public function benefit()
|
||||||
{
|
// {
|
||||||
return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
|
// return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function plan()
|
public function plans()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Plan::class, 'plan_code', 'code');
|
return $this->belongsToMany(Plan::class, 'corporate_benefits', 'benefit_id', 'id')
|
||||||
}
|
->withTimestamps()
|
||||||
|
->withPivot([
|
||||||
public function getMaxFrequencyPeriodNameAttribute()
|
// TODO corporate_benefits pivot
|
||||||
{
|
]);
|
||||||
return self::$max_frequency_periods[$this->max_frequency_period] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMaxFrequencyAttribute()
|
|
||||||
{
|
|
||||||
switch ($this->max_frequency_period) {
|
|
||||||
// case(0) :
|
|
||||||
// // TODO Fix This
|
|
||||||
// return null;
|
|
||||||
// break;
|
|
||||||
case(1) :
|
|
||||||
return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
|
|
||||||
break;
|
|
||||||
case(2) :
|
|
||||||
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
|
|
||||||
break;
|
|
||||||
case(3) :
|
|
||||||
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
|
|
||||||
break;
|
|
||||||
case(4) :
|
|
||||||
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
|
|
||||||
break;
|
|
||||||
case(5) :
|
|
||||||
// TODO Fix This
|
|
||||||
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
|
|
||||||
break;
|
|
||||||
case(6) :
|
|
||||||
// TODO Fix This
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
return null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ class Corporate extends Model
|
|||||||
return $this->morphMany(File::class, 'fileable');
|
return $this->morphMany(File::class, 'fileable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function plans()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Plan::class, 'corporate_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function policies()
|
public function policies()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CorporatePolicy::class);
|
return $this->hasMany(CorporatePolicy::class);
|
||||||
|
|||||||
@@ -13,17 +13,208 @@ class CorporateBenefit extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
'corporate_id',
|
||||||
'code',
|
'plan_id',
|
||||||
'name',
|
'benefit_id',
|
||||||
'description',
|
'corporate_benefit_code',
|
||||||
|
'budget',
|
||||||
|
'budget_conditions',
|
||||||
|
'budget_code',
|
||||||
|
'primary_benefit_code',
|
||||||
|
'benefit_mode',
|
||||||
|
'room_class_coverage',
|
||||||
|
'max_bed_coverage',
|
||||||
|
'tolerance_parameter',
|
||||||
|
'max_room_class',
|
||||||
|
'limit_amount',
|
||||||
|
'area_limit',
|
||||||
|
'shared_benefit',
|
||||||
|
'shared_benefit_type',
|
||||||
|
'msc',
|
||||||
|
'genders',
|
||||||
|
'min_age',
|
||||||
|
'max_age',
|
||||||
|
'max_frequency_period',
|
||||||
|
'daily_frequency',
|
||||||
|
'weekly_frequency',
|
||||||
|
'monthly_frequency',
|
||||||
|
'yearly_frequency',
|
||||||
|
'custom_frequency_days',
|
||||||
|
'custom_duration_value',
|
||||||
|
'allowed_transaction_types',
|
||||||
|
'high_plan_factor',
|
||||||
|
'pre_post_treatment',
|
||||||
|
'pre_treatment_days',
|
||||||
|
'post_treatment_days',
|
||||||
|
'layer_type_1',
|
||||||
|
'layer_value_1',
|
||||||
|
'layer_type_2',
|
||||||
|
'layer_value_2',
|
||||||
|
'cashless_percentage',
|
||||||
|
'reimbursement_percentage',
|
||||||
|
'digital_percentage',
|
||||||
|
'co_share_m_percentage',
|
||||||
|
'co_share_s_percentage',
|
||||||
|
'co_share_c_percentage',
|
||||||
|
'cashless_deductible',
|
||||||
|
'reimbursement_deductible',
|
||||||
|
'digital_deductible',
|
||||||
|
'co_share_m_deductible',
|
||||||
|
'co_share_s_deductible',
|
||||||
|
'co_share_c_deductible',
|
||||||
|
'prorate_type',
|
||||||
|
'prorate_lookup',
|
||||||
|
'max_days_for_disability',
|
||||||
|
'max_period_for_disability',
|
||||||
|
'currency',
|
||||||
|
'show_benefit_item',
|
||||||
|
'show_benefit_value',
|
||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static $doc_headers_to_field_map = [
|
||||||
|
"Service" => 'service_code',
|
||||||
|
"Plan" => 'plan_code',
|
||||||
|
"Benefit Code" => 'code',
|
||||||
|
"Customer Benefit Code" => 'corporate_benefit_code',
|
||||||
|
"Detail Benefit" => 'description',
|
||||||
|
"ASO/Budget" => 'budget',
|
||||||
|
"Budget Condition" => 'budget_conditions',
|
||||||
|
"Budget Code" => 'budget_code',
|
||||||
|
"Primary benefit" => 'primary_benefit_code',
|
||||||
|
"Benefit Mode" => 'benefit_mode',
|
||||||
|
"Room Class" => 'room_class_coverage',
|
||||||
|
"Max Bed" => 'max_bed_coverage',
|
||||||
|
"Tolerance Paramater" => 'tolerance_parameter',
|
||||||
|
"Max. Room Class" => 'max_room_class',
|
||||||
|
"Limit Value" => 'limit_amount',
|
||||||
|
"Area" => 'area_limit',
|
||||||
|
"Shared Benefit With" => 'shared_benefit',
|
||||||
|
"Shared Benefit Type" => 'shared_benefit_type',
|
||||||
|
"MSC" => 'msc',
|
||||||
|
"Gender" => 'genders',
|
||||||
|
"Min Age" => 'min_age',
|
||||||
|
"Max Age" => 'max_age',
|
||||||
|
"Freq. Period" => 'max_frequency_period',
|
||||||
|
"Daily Frequency" => 'daily_frequency',
|
||||||
|
"Weekly Frequency" => 'weekly_frequency',
|
||||||
|
"Monthly Frequency" => 'monthly_frequency',
|
||||||
|
"Yearly Frequency" => 'yearly_frequency',
|
||||||
|
"Custom Duration" => 'custom_frequency_days',
|
||||||
|
"Custom Duration Value" => 'custom_duration_value',
|
||||||
|
"Cashless, Reimbursement" => 'allowed_transaction_types',
|
||||||
|
"High Plan Factor" => 'high_plan_factor',
|
||||||
|
"Pre Post Treatment" => 'pre_post_treatment',
|
||||||
|
"Pre Treatment" => 'pre_treatment_days',
|
||||||
|
"Post Treatment" => 'post_treatment_days',
|
||||||
|
"Layer Type 1" => 'layer_type_1',
|
||||||
|
"Layer Value 1" => 'layer_value_1',
|
||||||
|
"Layer Type 2" => 'layer_type_2',
|
||||||
|
"Layer Value 2" => 'layer_value_2',
|
||||||
|
"Cashless (%)" => 'cashless_percentage',
|
||||||
|
"Reimburse (%)" => 'reimbursement_percentage',
|
||||||
|
"Digital (%)" => 'digital_percentage',
|
||||||
|
"CoShareM (%)" => 'co_share_m_percentage',
|
||||||
|
"CoShareS (%)" => 'co_share_s_percentage',
|
||||||
|
"CoShareC (%)" => 'co_share_c_percentage',
|
||||||
|
"Cashless Deductible" => 'cashless_deductible',
|
||||||
|
"Reimbursement Deductible" => 'reimbursement_deductible',
|
||||||
|
"Digital Deductible" => 'digital_deductible',
|
||||||
|
"DeductibleM" => 'co_share_m_deductible',
|
||||||
|
"DeductibleS" => 'co_share_s_deductible',
|
||||||
|
"DeductibleC" => 'co_share_c_deductible',
|
||||||
|
"Prorate Type" => 'prorate_type',
|
||||||
|
"Prorate Lookup" => 'prorate_lookup',
|
||||||
|
"Max Days for Disability" => 'max_days_for_disability',
|
||||||
|
"Max Periode of Disability" => 'max_period_for_disability',
|
||||||
|
"Currency" => 'currency',
|
||||||
|
"Show Benefit Item" => 'show_benefit_item',
|
||||||
|
"Show Benefit Value" => 'show_benefit_value',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static $max_frequency_periods = [
|
||||||
|
0 => 'Policy Period',
|
||||||
|
1 => 'Daily Visit',
|
||||||
|
2 => 'Weekly',
|
||||||
|
3 => 'Monthly',
|
||||||
|
4 => 'Yearly',
|
||||||
|
5 => 'Disability',
|
||||||
|
6 => 'Visit',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'max_frequency_period_name',
|
||||||
|
'max_frequency'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
public function setAreaLimitAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['area_limit'] = empty($value) ? null : $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrePostTreatmentAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrePostTreatmentAttribute($value)
|
||||||
|
{
|
||||||
|
return empty($value) ? null : ($value ? 'Y' : 'N');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxFrequencyPeriodNameAttribute()
|
||||||
|
{
|
||||||
|
return self::$max_frequency_periods[$this->max_frequency_period] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxFrequencyAttribute()
|
||||||
|
{
|
||||||
|
switch ($this->max_frequency_period) {
|
||||||
|
// case(0) :
|
||||||
|
// // TODO Fix This
|
||||||
|
// return null;
|
||||||
|
// break;
|
||||||
|
case(1) :
|
||||||
|
return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
|
||||||
|
break;
|
||||||
|
case(2) :
|
||||||
|
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
|
||||||
|
break;
|
||||||
|
case(3) :
|
||||||
|
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
|
||||||
|
break;
|
||||||
|
case(4) :
|
||||||
|
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
|
||||||
|
break;
|
||||||
|
case(5) :
|
||||||
|
// TODO Fix This
|
||||||
|
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
|
||||||
|
break;
|
||||||
|
case(6) :
|
||||||
|
// TODO Fix This
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
return null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function benefit()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Benefit::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function corporate()
|
public function corporate()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Corporate::class);
|
return $this->belongsTo(Corporate::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function plan()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plan::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
|
|||||||
@@ -168,6 +168,15 @@ class Plan extends Model
|
|||||||
|
|
||||||
public function benefits()
|
public function benefits()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Benefit::class, 'plan_code', 'id');
|
return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'benefit_id', 'id')
|
||||||
|
->withTimestamps()
|
||||||
|
->withPivot([
|
||||||
|
// TODO corporate_benefits pivot
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function corporateBeneftis()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CorporateBenefit::class, 'benefit_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,64 +15,66 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('benefits', function (Blueprint $table) {
|
Schema::create('benefits', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('corporate_id')->index()->nullable();
|
// $table->foreignId('corporate_id')->index()->nullable();
|
||||||
$table->string('service_code')->index()->nullable();
|
$table->string('service_code')->index()->nullable();
|
||||||
$table->string('plan_code')->index()->nullable();
|
// $table->string('plan_code')->index()->nullable();
|
||||||
$table->string('benefit_code')->index()->nullable();
|
// $table->string('benefit_code')->index()->nullable();
|
||||||
$table->string('code')->index()->nullable();
|
$table->string('code')->index();
|
||||||
$table->text('description')->nullable();
|
$table->text('description')->nullable();
|
||||||
$table->string('budget')->nullable();
|
// $table->string('budget')->nullable();
|
||||||
$table->string('budget_conditions')->nullable();
|
// $table->string('budget_conditions')->nullable();
|
||||||
$table->string('budget_code')->nullable();
|
// $table->string('budget_code')->nullable();
|
||||||
$table->string('primary_benefit_code')->index()->nullable();
|
// $table->string('primary_benefit_code')->index()->nullable();
|
||||||
$table->string('benefit_mode')->nullable();
|
// $table->string('benefit_mode')->nullable();
|
||||||
$table->string('room_class_coverage')->nullable();
|
// $table->string('room_class_coverage')->nullable();
|
||||||
$table->string('max_bed_coverage')->nullable();
|
// $table->string('max_bed_coverage')->nullable();
|
||||||
$table->string('tolerance_parameter')->nullable();
|
// $table->string('tolerance_parameter')->nullable();
|
||||||
$table->string('max_room_class')->nullable();
|
// $table->string('max_room_class')->nullable();
|
||||||
$table->string('limit_amount', 30)->nullable();
|
// $table->string('limit_amount', 30)->nullable();
|
||||||
$table->boolean('area_limit')->default(false)->nullable();
|
// $table->boolean('area_limit')->default(false)->nullable();
|
||||||
$table->string('shared_benefit')->nullable();
|
// $table->string('shared_benefit')->nullable();
|
||||||
$table->string('shared_benefit_type')->nullable();
|
// $table->string('shared_benefit_type')->nullable();
|
||||||
$table->string('msc')->nullable();
|
// $table->string('msc')->nullable();
|
||||||
$table->string('genders')->nullable();
|
// $table->string('genders')->nullable();
|
||||||
$table->string('min_age')->nullable();
|
// $table->string('min_age')->nullable();
|
||||||
$table->string('max_age')->nullable();
|
// $table->string('max_age')->nullable();
|
||||||
$table->string('max_frequency_period')->nullable();
|
// $table->string('max_frequency_period')->nullable();
|
||||||
$table->string('daily_frequency')->nullable();
|
// $table->string('daily_frequency')->nullable();
|
||||||
$table->string('weekly_frequency')->nullable();
|
// $table->string('weekly_frequency')->nullable();
|
||||||
$table->string('monthly_frequency')->nullable();
|
// $table->string('monthly_frequency')->nullable();
|
||||||
$table->string('yearly_frequency')->nullable();
|
// $table->string('yearly_frequency')->nullable();
|
||||||
$table->string('custom_frequency_days')->nullable();
|
// $table->string('custom_frequency_days')->nullable();
|
||||||
$table->string('custom_duration_value')->nullable();
|
// $table->string('custom_duration_value')->nullable();
|
||||||
$table->string('allowed_transaction_types')->nullable();
|
// $table->string('allowed_transaction_types')->nullable();
|
||||||
$table->string('high_plan_factor')->nullable();
|
// $table->string('high_plan_factor')->nullable();
|
||||||
$table->boolean('pre_post_treatment')->nullable();
|
// $table->boolean('pre_post_treatment')->nullable();
|
||||||
$table->string('pre_treatment_days')->nullable();
|
// $table->string('pre_treatment_days')->nullable();
|
||||||
$table->string('post_treatment_days')->nullable();
|
// $table->string('post_treatment_days')->nullable();
|
||||||
$table->string('layer_type_1')->nullable();
|
// $table->string('layer_type_1')->nullable();
|
||||||
$table->string('layer_value_1')->nullable();
|
// $table->string('layer_value_1')->nullable();
|
||||||
$table->string('layer_type_2')->nullable();
|
// $table->string('layer_type_2')->nullable();
|
||||||
$table->string('layer_value_2')->nullable();
|
// $table->string('layer_value_2')->nullable();
|
||||||
$table->string('cashless_percentage')->default(100)->nullable();
|
// $table->string('cashless_percentage')->default(100)->nullable();
|
||||||
$table->string('reimbursement_percentage')->default(100)->nullable();
|
// $table->string('reimbursement_percentage')->default(100)->nullable();
|
||||||
$table->string('digital_percentage')->default(100)->nullable();
|
// $table->string('digital_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_m_percentage')->default(100)->nullable();
|
// $table->string('co_share_m_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_s_percentage')->default(100)->nullable();
|
// $table->string('co_share_s_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_c_percentage')->default(100)->nullable();
|
// $table->string('co_share_c_percentage')->default(100)->nullable();
|
||||||
$table->string('cashless_deductible', 30)->nullable();
|
// $table->string('cashless_deductible', 30)->nullable();
|
||||||
$table->string('reimbursement_deductible', 30)->nullable();
|
// $table->string('reimbursement_deductible', 30)->nullable();
|
||||||
$table->string('digital_deductible', 30)->nullable();
|
// $table->string('digital_deductible', 30)->nullable();
|
||||||
$table->string('co_share_m_deductible', 30)->nullable();
|
// $table->string('co_share_m_deductible', 30)->nullable();
|
||||||
$table->string('co_share_s_deductible', 30)->nullable();
|
// $table->string('co_share_s_deductible', 30)->nullable();
|
||||||
$table->string('co_share_c_deductible', 30)->nullable();
|
// $table->string('co_share_c_deductible', 30)->nullable();
|
||||||
$table->string('prorate_type')->nullable();
|
// $table->string('prorate_type')->nullable();
|
||||||
$table->string('prorate_lookup')->nullable();
|
// $table->string('prorate_lookup')->nullable();
|
||||||
$table->string('max_days_for_disability')->nullable();
|
// $table->string('max_days_for_disability')->nullable();
|
||||||
$table->string('max_period_for_disability')->nullable();
|
// $table->string('max_period_for_disability')->nullable();
|
||||||
$table->string('currency')->nullable();
|
// $table->string('currency')->nullable();
|
||||||
$table->string('show_benefit_item')->nullable();
|
// $table->string('show_benefit_item')->nullable();
|
||||||
$table->string('show_benefit_value')->nullable();
|
// $table->string('show_benefit_value')->nullable();
|
||||||
|
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|||||||
@@ -16,9 +16,63 @@ return new class extends Migration
|
|||||||
Schema::create('corporate_benefits', function (Blueprint $table) {
|
Schema::create('corporate_benefits', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('corporate_id')->index();
|
$table->foreignId('corporate_id')->index();
|
||||||
$table->string('code')->index();
|
$table->foreignId('plan_id')->index();
|
||||||
$table->string('name')->nullable();
|
$table->foreignId('benefit_id')->index();
|
||||||
$table->text('description')->nullable();
|
|
||||||
|
$table->string('corporate_benefit_code')->nullable();
|
||||||
|
$table->string('budget')->nullable();
|
||||||
|
$table->string('budget_conditions')->nullable();
|
||||||
|
$table->string('budget_code')->nullable();
|
||||||
|
$table->string('primary_benefit_code')->index()->nullable();
|
||||||
|
$table->string('benefit_mode')->nullable();
|
||||||
|
$table->string('room_class_coverage')->nullable();
|
||||||
|
$table->string('max_bed_coverage')->nullable();
|
||||||
|
$table->string('tolerance_parameter')->nullable();
|
||||||
|
$table->string('max_room_class')->nullable();
|
||||||
|
$table->string('limit_amount', 30)->nullable();
|
||||||
|
$table->boolean('area_limit')->default(false)->nullable();
|
||||||
|
$table->string('shared_benefit')->nullable();
|
||||||
|
$table->string('shared_benefit_type')->nullable();
|
||||||
|
$table->string('msc')->nullable();
|
||||||
|
$table->string('genders')->nullable();
|
||||||
|
$table->string('min_age')->nullable();
|
||||||
|
$table->string('max_age')->nullable();
|
||||||
|
$table->string('max_frequency_period')->nullable();
|
||||||
|
$table->string('daily_frequency')->nullable();
|
||||||
|
$table->string('weekly_frequency')->nullable();
|
||||||
|
$table->string('monthly_frequency')->nullable();
|
||||||
|
$table->string('yearly_frequency')->nullable();
|
||||||
|
$table->string('custom_frequency_days')->nullable();
|
||||||
|
$table->string('custom_duration_value')->nullable();
|
||||||
|
$table->string('allowed_transaction_types')->nullable();
|
||||||
|
$table->string('high_plan_factor')->nullable();
|
||||||
|
$table->boolean('pre_post_treatment')->nullable();
|
||||||
|
$table->string('pre_treatment_days')->nullable();
|
||||||
|
$table->string('post_treatment_days')->nullable();
|
||||||
|
$table->string('layer_type_1')->nullable();
|
||||||
|
$table->string('layer_value_1')->nullable();
|
||||||
|
$table->string('layer_type_2')->nullable();
|
||||||
|
$table->string('layer_value_2')->nullable();
|
||||||
|
$table->string('cashless_percentage')->default(100)->nullable();
|
||||||
|
$table->string('reimbursement_percentage')->default(100)->nullable();
|
||||||
|
$table->string('digital_percentage')->default(100)->nullable();
|
||||||
|
$table->string('co_share_m_percentage')->default(100)->nullable();
|
||||||
|
$table->string('co_share_s_percentage')->default(100)->nullable();
|
||||||
|
$table->string('co_share_c_percentage')->default(100)->nullable();
|
||||||
|
$table->string('cashless_deductible', 30)->nullable();
|
||||||
|
$table->string('reimbursement_deductible', 30)->nullable();
|
||||||
|
$table->string('digital_deductible', 30)->nullable();
|
||||||
|
$table->string('co_share_m_deductible', 30)->nullable();
|
||||||
|
$table->string('co_share_s_deductible', 30)->nullable();
|
||||||
|
$table->string('co_share_c_deductible', 30)->nullable();
|
||||||
|
$table->string('prorate_type')->nullable();
|
||||||
|
$table->string('prorate_lookup')->nullable();
|
||||||
|
$table->string('max_days_for_disability')->nullable();
|
||||||
|
$table->string('max_period_for_disability')->nullable();
|
||||||
|
$table->string('currency')->nullable();
|
||||||
|
$table->string('show_benefit_item')->nullable();
|
||||||
|
$table->string('show_benefit_value')->nullable();
|
||||||
|
|
||||||
$table->boolean('active')->default(true);
|
$table->boolean('active')->default(true);
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
@@ -28,7 +82,7 @@ return new class extends Migration
|
|||||||
$table->foreignId('updated_by')->nullable()->index();
|
$table->foreignId('updated_by')->nullable()->index();
|
||||||
$table->foreignId('deleted_by')->nullable()->index();
|
$table->foreignId('deleted_by')->nullable()->index();
|
||||||
|
|
||||||
$table->unique(['corporate_id', 'code']);
|
$table->unique(['corporate_id', 'plan_id', 'benefit_id']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user