Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -237,7 +237,6 @@ class CorporateService
|
||||
->where('corporate_plan_id', $benefit_data['plan_code'])
|
||||
->first();
|
||||
$benefit_data['plan_code'] = $plan->id;
|
||||
|
||||
$benefit = Benefit::updateOrCreate([
|
||||
'code' => $benefit_data['code'],
|
||||
'service_code' => $plan->service_code,
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Exceptions\ImportRowException;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
@@ -21,15 +22,13 @@ class ExclusionService
|
||||
public function handleDiagnosisExclusionRow(Corporate $corporate, $row)
|
||||
{
|
||||
try {
|
||||
$this->validateDiagnosisExclusionRow($row);
|
||||
|
||||
if (!empty($row['ip_exclusion'])) {
|
||||
$excl_array = explode('|', $row['ip_exclusion']);
|
||||
if ($excl_array[0] == '3') {
|
||||
$icd = Icd::where('code', $row['code'])->first();
|
||||
$exclusion = $icd->exclusions()->create([
|
||||
'corporate_id' => $corporate->id,
|
||||
'service_code' => 'OP',
|
||||
'service_code' => 'IP',
|
||||
'type' => 'diagnosis'
|
||||
]);
|
||||
|
||||
@@ -89,7 +88,8 @@ class ExclusionService
|
||||
$exclusion = $icd->exclusions()->create([
|
||||
'corporate_id' => $corporate->id,
|
||||
'service_code' => 'OP',
|
||||
'type' => 'diagnosis'
|
||||
'type' => 'diagnosis',
|
||||
'active' => 1
|
||||
]);
|
||||
|
||||
if (!empty($excl_array[1])) { //msc
|
||||
@@ -130,11 +130,35 @@ class ExclusionService
|
||||
]);
|
||||
}
|
||||
if (!empty($excl_array[5])) { //plans
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'plan',
|
||||
'values' => $excl_array[5]
|
||||
]);
|
||||
$codePlan = explode(',', $excl_array[5]);
|
||||
collect($codePlan)->each(function ($codePlan) use ($corporate, $exclusion) {
|
||||
$isCodeplan = Plan::where(['code' => $codePlan, 'corporate_id' => $corporate->id])->first();
|
||||
if (!$isCodeplan) {
|
||||
throw new ImportRowException(__('codePlan.NOT_FOUND'), 0, NULL, $codePlan);
|
||||
}
|
||||
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'plan',
|
||||
'values' => $codePlan
|
||||
]);
|
||||
});
|
||||
}
|
||||
} else if (!$excl_array[0]){
|
||||
$icd = Icd::where(['code' => $row['code']])->first();
|
||||
if (!$icd) {
|
||||
throw new ImportRowException(__('icd.NOT_FOUND'), 0, NULL, $row);
|
||||
}
|
||||
// Cari entitas Exclusion yang sesuai dengan kriteria tertentu
|
||||
$exclusion = Exclusion::where([
|
||||
'corporate_id' => $corporate->id,
|
||||
'exclusionable_id' => $icd->id,
|
||||
])->first();
|
||||
|
||||
// Jika entitas ditemukan, perbarui nilai 'active' menjadi 0
|
||||
if ($exclusion) {
|
||||
$exclusion->update(['active' => 0]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +168,7 @@ class ExclusionService
|
||||
$icd = Icd::where('code', $row['code'])->first();
|
||||
$exclusion = $icd->exclusions()->create([
|
||||
'corporate_id' => $corporate->id,
|
||||
'service_code' => 'OP',
|
||||
'service_code' => 'DE',
|
||||
'type' => 'diagnosis'
|
||||
]);
|
||||
|
||||
@@ -196,7 +220,6 @@ class ExclusionService
|
||||
|
||||
if (!empty($row['ma_exclusion'])) {
|
||||
$excl_array = explode('|', $row['ma_exclusion']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ use App\Models\Benefit;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Drug;
|
||||
use App\Models\Formularium;
|
||||
use App\Models\CorporateFormularium;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class CorporateService
|
||||
class FormulariumService
|
||||
{
|
||||
protected function validateFormulariumRow($row)
|
||||
{
|
||||
@@ -45,4 +46,75 @@ class CorporateService
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleFormuariumTemplateRow($row, $id)
|
||||
{
|
||||
try {
|
||||
$formularium = Formularium::updateOrCreate(
|
||||
[
|
||||
'code' => $row['code'],
|
||||
'formularium_template_id' => $id
|
||||
],
|
||||
[
|
||||
'code' => $row['code'],
|
||||
'name' => $row['name'],
|
||||
'description' => $row['description'],
|
||||
'manufacturer' => $row['manufacturer'],
|
||||
'category_name' => $row['category_name'],
|
||||
'kategori_obat' => $row['kategori_obat'],
|
||||
'uom' => $row['uom'],
|
||||
'composition' => $row['composition'],
|
||||
'general_indication' => $row['general_indication'],
|
||||
'atc_code' => $row['atc_code'],
|
||||
'class' => $row['class'],
|
||||
'bpom_registration' => $row['bpom_registration'],
|
||||
'classifications' => $row['classifications'],
|
||||
'cat_for' => $row['cat_for'],
|
||||
'formularium_template_id' => $id,
|
||||
]);
|
||||
|
||||
return $formularium;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleFormuariumCorporateRow($row, $id)
|
||||
{
|
||||
try {
|
||||
$formularium = CorporateFormularium::updateOrCreate(
|
||||
[
|
||||
'formularium_id' => $row['formularium_id'],
|
||||
'corporate_id' => $id
|
||||
],
|
||||
[
|
||||
'formularium_id' => $row['formularium_id'],
|
||||
'corporate_id' => $id,
|
||||
'active' => $row['active']
|
||||
]);
|
||||
|
||||
return $formularium;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public $listing_doc_headers = [
|
||||
"Internal Code",
|
||||
"Name",
|
||||
"Description",
|
||||
"Manufacturer",
|
||||
"Category Name",
|
||||
"Kategori Obat",
|
||||
"UOM",
|
||||
"Composition",
|
||||
"General Indication",
|
||||
"ATC Code",
|
||||
"Class",
|
||||
"BPOM Registration",
|
||||
"Classifications",
|
||||
"Cat For (O = obat, VS = Vitamin Suplemen, H=herbal, M=makanan, etc) ",
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
53
Modules/Internal/Services/IcdService.php
Normal file
53
Modules/Internal/Services/IcdService.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Services;
|
||||
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class IcdService
|
||||
{
|
||||
protected function validateDiagnosisExclusionRow($row)
|
||||
{
|
||||
if (empty($row['ICD_Code'])) {
|
||||
throw new ImportRowException(__('ICD_Code is REQUIRED'), 0, null, $row);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleIcdRow($row, $id)
|
||||
{
|
||||
try {
|
||||
$this->validateDiagnosisExclusionRow($row);
|
||||
$icd = Icd::updateOrCreate([
|
||||
'code' => $row['ICD_Code']
|
||||
], [
|
||||
"code" => $row['ICD_Code'],
|
||||
"parent_code" => null,
|
||||
"rev" => '',
|
||||
"name" => $row['Description'] ?? null,
|
||||
"version" => null,
|
||||
"active" => 1,
|
||||
"icd_template_id" => $id,
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public $listing_doc_headers = [
|
||||
// "Rev",
|
||||
// "Version",
|
||||
"Code",
|
||||
// "Parent Code",
|
||||
// "Name",
|
||||
"Description",
|
||||
// "Status",
|
||||
// "Type"
|
||||
];
|
||||
}
|
||||
@@ -326,6 +326,7 @@ class MemberEnrollmentService
|
||||
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
app()->setLocale('en');
|
||||
$this->member = $member;
|
||||
}
|
||||
|
||||
@@ -580,6 +581,7 @@ class MemberEnrollmentService
|
||||
"telephone_mobile" => $row['telephone_mobile'] ?? null,
|
||||
"telephone_res" => $row['telephone_res'] ?? null,
|
||||
"telephone_office" => $row['telephone_office'] ?? null,
|
||||
"suspended" => $row['member_suspended'] ?? null,
|
||||
];
|
||||
// $this->validateRow($row);
|
||||
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->code != $row['policy_number']) {
|
||||
@@ -731,12 +733,25 @@ class MemberEnrollmentService
|
||||
|
||||
// Validate If Plan Exist
|
||||
// TODO validate corporate plan
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
$plans = explode(",",$row['plan_id']);
|
||||
if (count($plans) > 0) {
|
||||
foreach($plans as $d){
|
||||
$plan = Plan::query()
|
||||
->where('code', $d)
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -787,12 +802,40 @@ class MemberEnrollmentService
|
||||
'status' => $row['employment_status']
|
||||
]);
|
||||
// Bisa disini penyebab data dobel
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
|
||||
$plans = explode(",",$row['plan_id']);
|
||||
if (count($plans) > 0) {
|
||||
foreach($plans as $d){
|
||||
$plan = Plan::query()
|
||||
->where('code', $d)
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
@@ -834,7 +877,6 @@ class MemberEnrollmentService
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
try {
|
||||
|
||||
$memberPolicy = MemberPolicy::query()
|
||||
->where('policy_id', $row['policy_number'])
|
||||
->where('member_id', $row['member_id'])
|
||||
@@ -852,17 +894,63 @@ class MemberEnrollmentService
|
||||
$memberPlan->save();
|
||||
}
|
||||
|
||||
// Pengecekan jika ada perubahan di plan
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->first();
|
||||
if ($plan){
|
||||
$memberPlan = MemberPlan::query()
|
||||
->where('member_id', $member->id)
|
||||
->first();
|
||||
$memberPlan->plan_id = $plan->id;
|
||||
$memberPlan->save();
|
||||
}
|
||||
// // Pengecekan jika ada perubahan di plan
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $row['plan_id'])
|
||||
// ->first();
|
||||
// if ($plan){
|
||||
// $memberPlan = MemberPlan::query()
|
||||
// ->where('member_id', $member->id)
|
||||
// ->first();
|
||||
// $memberPlan->plan_id = $plan->id;
|
||||
// $memberPlan->save();
|
||||
// }
|
||||
|
||||
// Update plan
|
||||
// $plans = explode(",",$row['plan_id']);
|
||||
// if (count($plans) > 0) {
|
||||
// foreach($plans as $d){
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $d)
|
||||
// ->where('corporate_id', $corporate->id)
|
||||
// ->first();
|
||||
// if (!$plan) {
|
||||
// throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
// }
|
||||
// $member->memberPlans()->updateOrCreate([
|
||||
// 'member_id' => $member->id,
|
||||
// 'plan_id' => $plan->id,
|
||||
// ],
|
||||
// [
|
||||
// 'plan_id' => $plan->id,
|
||||
// 'status' => 'active',
|
||||
// 'start' => $this->dateParser($row['member_effective_date']),
|
||||
// 'end' => $this->dateParser($row['member_expiry_date']),
|
||||
// ]);
|
||||
// }
|
||||
// } else {
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $row['plan_id'])
|
||||
// ->where('corporate_id', $corporate->id)
|
||||
// ->first();
|
||||
// if (!$plan) {
|
||||
// throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
// }
|
||||
// $member->memberPlans()->updateOrCreate([
|
||||
// 'member_id' => $member->id,
|
||||
// 'plan_id' => $plan->id,
|
||||
// ],
|
||||
// [
|
||||
// 'plan_id' => $plan->id,
|
||||
// 'status' => 'active',
|
||||
// 'start' => $this->dateParser($row['member_effective_date']),
|
||||
// 'end' => $this->dateParser($row['member_expiry_date']),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// end update plan
|
||||
|
||||
// Update jika ada perubahaan di ASO maka akan teriflek ke LMS juga\
|
||||
$userInsuranceLms = UserInsurance::query()
|
||||
->where('sNoPolis', $row['member_id'])
|
||||
|
||||
Reference in New Issue
Block a user