Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -14,6 +14,10 @@ use App\Models\MemberPolicy;
|
||||
use App\Models\MemberPlan;
|
||||
use App\Models\Person;
|
||||
use App\Models\Plan;
|
||||
use App\Models\OLDLMS\User;
|
||||
use App\Models\OLDLMS\UserDetail;
|
||||
use App\Models\OLDLMS\UserInsurance;
|
||||
use App\Models\OLDLMS\UserInsuranceDetail;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
use Carbon\Carbon;
|
||||
@@ -331,7 +335,7 @@ class MemberEnrollmentService
|
||||
|
||||
public function validateDate($dateString, $dateFormat = 'Ymd'){
|
||||
$date = DateTime::createFromFormat($dateFormat, $dateString);
|
||||
if ($date && $date->format($dateFormat) == $dateString) {
|
||||
if ($date && ($date->format($dateFormat) == $dateString)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -433,32 +437,32 @@ class MemberEnrollmentService
|
||||
if (empty($row['member_effective_date'])) {
|
||||
throw new ImportRowException(__('enrollment.MEMBER_EFFECTIVE_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
if(!$this->validateDate($row['member_effective_date'])){
|
||||
throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
'title' => $title['member_effective_date']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
// if(!$this->validateDate($row['member_effective_date'])){
|
||||
// throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
// 'title' => $title['member_effective_date']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
|
||||
if (empty($row['member_expiry_date'])) {
|
||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
if(!$this->validateDate($row['member_expiry_date'])){
|
||||
throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
'title' => $title['member_expiry_date']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
// if(!$this->validateDate($row['member_expiry_date'])){
|
||||
// throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
// 'title' => $title['member_expiry_date']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
|
||||
// TODO EFFECTIVE DATE VALIDATION
|
||||
// if (empty($row['activation_date'])) {
|
||||
// throw new ImportRowException(__('enrollment.ACTIVATION_DATE_REQUIRED'), 0, null, $row);
|
||||
// }
|
||||
if(!empty($row['activation_date'])){
|
||||
if(!$this->validateDate($row['activation_date'])){
|
||||
throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
'title' => $title['activation_date']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
}
|
||||
// if(!empty($row['activation_date'])){
|
||||
// if(!$this->validateDate($row['activation_date'])){
|
||||
// throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
// 'title' => $title['activation_date']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
// }
|
||||
// TODO FKTP VALIDATION
|
||||
// TODO FKRTL VALIDATION
|
||||
|
||||
@@ -491,22 +495,22 @@ class MemberEnrollmentService
|
||||
if (empty($row['date_of_birth'])) {
|
||||
throw new ImportRowException(__('enrollment.DATE_OF_BIRTH_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
if(!$this->validateDate($row['date_of_birth'])){
|
||||
throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
'title' => $title['date_of_birth']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
// if(!$this->validateDate($row['date_of_birth'])){
|
||||
// throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
// 'title' => $title['date_of_birth']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
|
||||
// if (empty($row['date_terminated'])) {
|
||||
// throw new ImportRowException(__('enrollment.DATE_OF_TERMINATED'), 0, null, $row);
|
||||
// }
|
||||
if (!empty($row['date_terminated'])) {
|
||||
if(!$this->validateDate($row['date_terminated'])){
|
||||
throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
'title' => $title['date_terminated']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
}
|
||||
// if (!empty($row['date_terminated'])) {
|
||||
// if(!$this->validateDate($row['date_terminated'])){
|
||||
// throw new ImportRowException(__('enrollment.INVALID_DATE', [
|
||||
// 'title' => $title['date_terminated']
|
||||
// ]), 0, null, $row);
|
||||
// }
|
||||
// }
|
||||
// TODO DOB FORMAT VALIDATION
|
||||
|
||||
if (empty($row['sex'])) {
|
||||
@@ -625,6 +629,7 @@ class MemberEnrollmentService
|
||||
'start' => $corporate->currentPolicy->start
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if ($member_effective_date >= $corporate->currentPolicy->end && ($member_effective_date != $corporate->currentPolicy->end)) {
|
||||
throw new ImportRowException(__('enrollment.LESS_THAN', [
|
||||
'date_param' => 'Member Effective Date',
|
||||
@@ -633,6 +638,7 @@ class MemberEnrollmentService
|
||||
'end' => $corporate->currentPolicy->end
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
if ($member_effective_date >= $corporate->currentPolicy->end && ($member_effective_date != $corporate->currentPolicy->end)) {
|
||||
throw new ImportRowException(__('enrollment.LESS_THAN', [
|
||||
'date_param' => 'Member Effective Date',
|
||||
@@ -649,7 +655,11 @@ class MemberEnrollmentService
|
||||
'start' => $corporate->currentPolicy->start
|
||||
]), 0, null, $row);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> origin/staging
|
||||
if ($members_expire_date >= $corporate->currentPolicy->end && ($members_expire_date != $corporate->currentPolicy->end)) {
|
||||
throw new ImportRowException(__('enrollment.LESS_THAN', [
|
||||
'date_param' => 'Member Expired Date',
|
||||
@@ -699,6 +709,7 @@ class MemberEnrollmentService
|
||||
'gender' => Helper::genderPerson($row['sex']),
|
||||
'language' => $row['language'] ?? null,
|
||||
'race' => $row['race'] ?? null,
|
||||
'phone' => $row['telephone_mobile'] ?? null
|
||||
]
|
||||
);
|
||||
$member->person_id = $person->id;
|
||||
@@ -743,6 +754,7 @@ class MemberEnrollmentService
|
||||
'gender' => Helper::genderPerson($row['sex']),
|
||||
'language' => $row['language'] ?? null,
|
||||
'race' => $row['race'] ?? null,
|
||||
'phone' => $row['telephone_mobile'],
|
||||
]);
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
@@ -793,19 +805,44 @@ class MemberEnrollmentService
|
||||
}
|
||||
break;
|
||||
case "2": // Member Information Update (Without Replacement Card)
|
||||
$this->validateRow($row);
|
||||
|
||||
// $this->validateRow($row);
|
||||
$member = Member::query()
|
||||
->where('member_id', $row['member_id'])
|
||||
->first();
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Validate If Exist Member
|
||||
=======
|
||||
// // Validate If Exist Member
|
||||
>>>>>>> origin/staging
|
||||
if (!$member) {
|
||||
throw new ImportRowException(__('enrollment.MEMBER_NOT_FOUND', [
|
||||
'member_id' => $row['member_id'],
|
||||
'policy_id' => $row['policy_number']
|
||||
]), 0, null, $row);
|
||||
}
|
||||
|
||||
|
||||
$person = Person::updateOrCreate(
|
||||
[
|
||||
'id' => $member->person_id
|
||||
],
|
||||
[
|
||||
'name' => $row['name'] ?? null,
|
||||
// 'birth_date' => $this->dateParser($row['date_of_birth']),
|
||||
'birth_date' => $row['date_of_birth'],
|
||||
'gender' => Helper::genderPerson($row['sex']),
|
||||
'language' => $row['language'] ?? null,
|
||||
'race' => $row['race'] ?? null,
|
||||
'phone' => $row['telephone_mobile']
|
||||
]
|
||||
);
|
||||
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
try {
|
||||
|
||||
$memberPolicy = MemberPolicy::query()
|
||||
->where('policy_id', $row['policy_number'])
|
||||
->where('member_id', $row['member_id'])
|
||||
@@ -823,6 +860,102 @@ 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();
|
||||
}
|
||||
// Update jika ada perubahaan di ASO maka akan teriflek ke LMS juga\
|
||||
$userInsuranceLms = UserInsurance::query()
|
||||
->where('sNoPolis', $row['member_id'])
|
||||
->first();
|
||||
if ($userInsuranceLms){
|
||||
$userInsuranceLms->sNamaPeserta = $row['name'];
|
||||
$userInsuranceLms->dStartDate = $row['member_effective_date'];
|
||||
$userInsuranceLms->dExpireDate = $row['member_expiry_date'];
|
||||
$nIDUser = $userInsuranceLms->nIDUser;
|
||||
|
||||
UserInsurance::updateOrCreate(
|
||||
['nIDUser' => $nIDUser],
|
||||
[
|
||||
'sNamaPeserta' => $row['name'],
|
||||
'dStartDate' => $row['member_effective_date'],
|
||||
'dExpireDate' => $row['member_expiry_date'],
|
||||
'dTanggalLahir' => $row['date_of_birth'],
|
||||
// 'nNoKTP' => $row['nric'] ?? ,
|
||||
]
|
||||
);
|
||||
/* Lihat ID Marital status di table tm_status_pernikahan Linksehat */
|
||||
if ($row['relationship_with_principal'] == 'H'){
|
||||
$sMartialStatus= 6;
|
||||
$nIDHubunganKeluarga = 3;
|
||||
} else if ($row['relationship_with_principal'] == 'W'){
|
||||
$sMartialStatus = 7;
|
||||
$nIDHubunganKeluarga = 4;
|
||||
} else if ($row['relationship_with_principal'] == 'S'){
|
||||
$sMartialStatus = 4;
|
||||
$nIDHubunganKeluarga = 5;
|
||||
} else if ($row['relationship_with_principal'] == 'D'){
|
||||
$sMartialStatus = 5;
|
||||
$nIDHubunganKeluarga = 5;
|
||||
} else {
|
||||
$sMartialStatus = 0;
|
||||
$nIDHubunganKeluarga = 0;
|
||||
}
|
||||
|
||||
|
||||
if($row['sex'] == 'M'){
|
||||
$nIDJenisKelamin = 1;
|
||||
} else {
|
||||
$nIDJenisKelamin = 2;
|
||||
};
|
||||
// $ip_address = $CI->_prepare_ip($CI->input->ip_address());
|
||||
$name = explode(" ", $row['name']);
|
||||
// First name
|
||||
$first_name = isset($name[0]) ? $name[0] : '';
|
||||
// Middle name
|
||||
$middle_name = isset($name[1]) ? $name[1] : '';
|
||||
// Last name
|
||||
$last_name = '';
|
||||
if (count($name) > 2) {
|
||||
$last_name = implode(" ", array_slice($name, 2));
|
||||
}
|
||||
$userLms = User::updateOrCreate(
|
||||
[
|
||||
'nID' => $nIDUser // Kondisi untuk mencari data dengan 'nID' yang sesuai dengan $nIDUser
|
||||
],
|
||||
[
|
||||
'sFirstName' => $first_name,
|
||||
'sLastName' => $middle_name . ' ' .$last_name, // Ubah ini dengan variabel yang sesuai dengan nama belakang (last name)
|
||||
'sPhone' => $row['telephone_mobile'],
|
||||
'sEmail' => str_replace(' ', '', $row['email']),
|
||||
'nIDHubunganKeluarga' => $nIDHubunganKeluarga !== 0 ? $nIDHubunganKeluarga : null,
|
||||
'dUpdateOn' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
);
|
||||
|
||||
$userLmsDetail = UserDetail::updateOrCreate(
|
||||
[
|
||||
'nIDUser' => $nIDUser
|
||||
],
|
||||
[
|
||||
'nIDUser' => $nIDUser,
|
||||
'dTanggalLahir' => $row['date_of_birth'],
|
||||
'dCreateOn' => date('Y-m-d H:i:s'),
|
||||
'sMartialStatus' => $sMartialStatus != 0 ? $sMartialStatus : null,
|
||||
'nIDJenisKelamin' => $nIDJenisKelamin,
|
||||
'sCreateBy' => $nIDUser,
|
||||
'sKTP' => $row['nric'] ?? null,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
if (!$memberPolicy) {
|
||||
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
|
||||
'member_id' => $row['member_id'],
|
||||
|
||||
Reference in New Issue
Block a user