fix cleint portal employee-data, dashboard, hide notification

This commit is contained in:
Muhammad Fajar
2023-12-31 23:44:43 +07:00
parent ae884f8cd0
commit 96034d069a
26 changed files with 684 additions and 804 deletions

View File

@@ -179,7 +179,7 @@ class MemberEnrollmentService
"ingestion_code" => "Ingestion Code",
"ingestion_status" => "Ingestion Status",
];
public $result_doc_headers = [
"Record Mode",
"Record Type",
@@ -357,7 +357,7 @@ class MemberEnrollmentService
'activation_date' => 'Activation Date',
'date_of_birth' => 'Date of Birth',
'date_terminated' => 'Date Terminated',
];
if (empty($row['record_type'])) {
@@ -372,6 +372,10 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.MEMBER_ID_REQUIRED'), 0, null, $row);
}
if (empty($row['plan_id'])) {
throw new ImportRowException(__('Plan ID Required'), 0, null, $row);
}
if ($row['record_type'] == 'P') {
if (!empty($row['principal_id'])) {
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_NOT_REQUIRED'), 0, null, $row);
@@ -391,22 +395,22 @@ class MemberEnrollmentService
->first();
if(empty($member)){
throw new ImportRowException(__('enrollment.PRINCIPAL_NOT_IN_MEMBER_ID'), 0, null, $row);
// throw new ImportRowException(__('enrollment.PRINCIPAL_NOT_IN_MEMBER_ID'), 0, null, $row);
} else {
if ($member['record_type'] != 'P'){
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_NOT_SAME_MEMBER_ID'), 0, null, $row);
}
// if ($member['record_type'] != 'P'){
// throw new ImportRowException(__('enrollment.PRINCIPAL_ID_NOT_SAME_MEMBER_ID'), 0, null, $row);
// }
}
if (empty($row['principal_id'])) {
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_REQUIRED'), 0, null, $row);
}
if (empty($row['relationship_with_principal'])){
throw new ImportRowException(__('enrollment.RELATIONSHIP_WITH_PRICIPAL_REQUIRED'), 0, null, $row);
}
if (!empty($row['relationship_with_principal']) && !in_array($row['relationship_with_principal'], ['H', 'W', 'D', 'S'])){
throw new ImportRowException(__('enrollment.RELATIONSHIP_WITH_PRICIPAL_NOT_VALID'), 0, null, $row);
}
// if (empty($row['relationship_with_principal'])){
// throw new ImportRowException(__('enrollment.RELATIONSHIP_WITH_PRICIPAL_REQUIRED'), 0, null, $row);
// }
// if (!empty($row['relationship_with_principal']) && !in_array($row['relationship_with_principal'], ['H', 'W', 'D', 'S'])){
// throw new ImportRowException(__('enrollment.RELATIONSHIP_WITH_PRICIPAL_NOT_VALID'), 0, null, $row);
// }
}
@@ -420,26 +424,26 @@ class MemberEnrollmentService
// throw new ImportRowException(__('enrollment.BRANCH_CODE_NOT_REQUIRED'), 0, null, $row);
// }
if (!empty($row['language']) && !in_array($row['language'], ['M', 'E', 'C', 'I', 'O'])) {
throw new ImportRowException(__('enrollment.INVALID_LANGUAGE'), 0, null, $row);
}
// if (!empty($row['language']) && !in_array($row['language'], ['M', 'E', 'C', 'I', 'O'])) {
// throw new ImportRowException(__('enrollment.INVALID_LANGUAGE'), 0, null, $row);
// }
if (!empty($row['type_of_work']) && !in_array($row['type_of_work'], ['0', '1', '2', '3'])) {
throw new ImportRowException(__('enrollment.INVALID_TYPE_OF_WORK'), 0, null, $row);
}
// if (!empty($row['type_of_work']) && !in_array($row['type_of_work'], ['0', '1', '2', '3'])) {
// throw new ImportRowException(__('enrollment.INVALID_TYPE_OF_WORK'), 0, null, $row);
// }
if (!empty($row['race']) && !in_array($row['race'], ['M', 'C', 'I', 'O'])) {
throw new ImportRowException(__('enrollment.INVALID_RACE'), 0, null, $row);
}
// if (!empty($row['race']) && !in_array($row['race'], ['M', 'C', 'I', 'O'])) {
// throw new ImportRowException(__('enrollment.INVALID_RACE'), 0, null, $row);
// }
if (empty($row['policy_number'])) {
throw new ImportRowException(__('enrollment.POLICY_NUMBER_REQUIRED'), 0, null, $row);
}
if (!empty($row['marital_status']) && !in_array($row['marital_status'], ['S', 'M', 'D'])) {
throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
}
// if (!empty($row['marital_status']) && !in_array($row['marital_status'], ['S', 'M', 'D'])) {
// throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
// }
// TODO EFFECTIVE DATE VALIDATION
if (empty($row['member_effective_date'])) {
throw new ImportRowException(__('enrollment.MEMBER_EFFECTIVE_REQUIRED'), 0, null, $row);
@@ -458,7 +462,7 @@ class MemberEnrollmentService
// '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);
@@ -473,35 +477,35 @@ class MemberEnrollmentService
// TODO FKTP VALIDATION
// TODO FKRTL VALIDATION
if (!empty($row['marital_status']) && !in_array($row['marital_status'], ['S', 'M', 'D'])) {
throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
}
// if (!empty($row['marital_status']) && !in_array($row['marital_status'], ['S', 'M', 'D'])) {
// throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
// }
if (empty($row['name'])) {
throw new ImportRowException(__('enrollment.NAME_REQUIRED'), 0, null, $row);
}
if (!Helper::validatePhoneNumber($row['telephone_mobile'])){
throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
}
// if (!Helper::validatePhoneNumber($row['telephone_mobile'])){
// throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
// }
if (
!empty($row['telephone_mobile'])
&& !(substr($row['telephone_mobile'], 0, 4) == '+628' || substr($row['telephone_mobile'], 0, 3) == '628')
) {
throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
}
// if (
// !empty($row['telephone_mobile'])
// && !(substr($row['telephone_mobile'], 0, 4) == '+628' || substr($row['telephone_mobile'], 0, 3) == '628')
// ) {
// throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
// }
if (
!empty($row['email'])
&& !filter_var($row['email'], FILTER_VALIDATE_EMAIL)
) {
throw new ImportRowException(__('enrollment.EMAIL_INVALID'), 0, null, $row);
}
// if (
// !empty($row['email'])
// && !filter_var($row['email'], FILTER_VALIDATE_EMAIL)
// ) {
// throw new ImportRowException(__('enrollment.EMAIL_INVALID'), 0, null, $row);
// }
if (empty($row['date_of_birth'])) {
throw new ImportRowException(__('enrollment.DATE_OF_BIRTH_REQUIRED'), 0, null, $row);
}
// 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']
@@ -520,16 +524,16 @@ class MemberEnrollmentService
// }
// TODO DOB FORMAT VALIDATION
if (empty($row['sex'])) {
throw new ImportRowException(__('enrollment.SEX_REQUIRED'), 0, null, $row);
}
if (!in_array($row['sex'], ['F', 'M'])){
throw new ImportRowException(__('enrollment.SEX_CODE_NOT_VALID'), 0, null, $row);
}
// if (empty($row['sex'])) {
// throw new ImportRowException(__('enrollment.SEX_REQUIRED'), 0, null, $row);
// }
// if (!in_array($row['sex'], ['F', 'M'])){
// throw new ImportRowException(__('enrollment.SEX_CODE_NOT_VALID'), 0, null, $row);
// }
}
public function handleImportRow(Corporate $corporate, $row)
{
try {
@@ -546,7 +550,7 @@ class MemberEnrollmentService
"member_id" => $row['member_id'] ?? null,
"payor_id" => $row['payor_id'] ?? null,
"nik" => $row['nik'] ?? null,
"birth_date" => $row['date_of_birth'],
"birth_date" => $row['date_of_birth'] ? date("Y-m-d",$row['date_of_birth']) : null,
"gender" => Helper::genderNormalization($row['sex']),
"language" => $row['language'] ?? null,
"race" => $row['race'] ?? null,
@@ -588,6 +592,8 @@ class MemberEnrollmentService
"telephone_res" => $row['telephone_res'] ?? null,
"telephone_office" => $row['telephone_office'] ?? null,
"suspended" => $row['member_suspended'] ?? null,
"active" => $row['employment_status'] == 'INACTIVE' ? 0 : 1
];
// $this->validateRow($row);
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->code != $row['policy_number']) {
@@ -595,101 +601,101 @@ class MemberEnrollmentService
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
// validasi member efektif date range date in periode date coroporate
// validasi member efektif date range date in periode date coroporate
$member_effective_date = date("Y-m-d", strtotime($row['member_effective_date']));
$date_terminated = date("Y-m-d", strtotime($row['date_terminated']));
if(!empty($row['activation_date'])){
$activation_date = date("Y-m-d", strtotime($row['activation_date']));
if (($activation_date == $date_terminated) && ($activation_date == $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Activation Date',
'date' => $activation_date,
'date_param2' => 'Member Effective Date',
'start' => $activation_date
]), 0, null, $row);
}
// $activation_date = date("Y-m-d", strtotime($row['activation_date']));
// if (($activation_date == $date_terminated) && ($activation_date == $member_effective_date)) {
// throw new ImportRowException(__('enrollment.MORE_THAN', [
// 'date_param' => 'Activation Date',
// 'date' => $activation_date,
// 'date_param2' => 'Member Effective Date',
// 'start' => $activation_date
// ]), 0, null, $row);
// }
}
if (!empty($row['date_terminated'])){
$date_terminated = date("Y-m-d", strtotime($row['date_terminated']));
if($date_terminated){
if ($date_terminated <= $member_effective_date && ($date_terminated != $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Date Terminated Date',
'date' => $date_terminated,
'date_param2' => 'Member Effective Date',
'start' => $member_effective_date
]), 0, null, $row);
}
}
// $date_terminated = date("Y-m-d", strtotime($row['date_terminated']));
// if($date_terminated){
// if ($date_terminated <= $member_effective_date && ($date_terminated != $member_effective_date)) {
// throw new ImportRowException(__('enrollment.MORE_THAN', [
// 'date_param' => 'Date Terminated Date',
// 'date' => $date_terminated,
// 'date_param2' => 'Member Effective Date',
// 'start' => $member_effective_date
// ]), 0, null, $row);
// }
// }
}
// validasi member expried date range date in periode date coroporate
// validasi member expried date range date in periode date coroporate
$members_expire_date = date("Y-m-d", strtotime($row['member_expiry_date']));
// validasi member expried date must less date member effective
$members_expire_date = date("Y-m-d", strtotime($row['member_expiry_date']));
$members_expire_date = date("Y-m-d", strtotime($row['member_expiry_date']));
if ($member_effective_date <= $corporate->currentPolicy->start && ($member_effective_date != $corporate->currentPolicy->start)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Member Effective Date',
'date' => $member_effective_date,
'date_param2' => 'Start Period Date',
'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',
'date' => $member_effective_date,
'date_param2' => 'End Period Date',
'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',
'date' => $member_effective_date,
'date_param2' => 'End Period Date',
'end' => $corporate->currentPolicy->end
]), 0, null, $row);
}
if ($members_expire_date <= $corporate->currentPolicy->start && ($members_expire_date != $corporate->currentPolicy->start) ) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Member Expired Date',
'date' => $members_expire_date,
'date_param2' => 'Start Period Date',
'start' => $corporate->currentPolicy->start
]), 0, null, $row);
}
if ($members_expire_date >= $corporate->currentPolicy->end && ($members_expire_date != $corporate->currentPolicy->end)) {
throw new ImportRowException(__('enrollment.LESS_THAN', [
'date_param' => 'Member Expired Date',
'date' => $members_expire_date,
'date_param2' => 'END Period Date',
'end' => $corporate->currentPolicy->end
]), 0, null, $row);
}
if ($members_expire_date <= $member_effective_date && ($members_expire_date != $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Member Expired Date',
'date' => $members_expire_date,
'date_param2' => 'Member Effective Date',
'start' => $member_effective_date
]), 0, null, $row);
}
// if ($member_effective_date <= $corporate->currentPolicy->start && ($member_effective_date != $corporate->currentPolicy->start)) {
// throw new ImportRowException(__('enrollment.MORE_THAN', [
// 'date_param' => 'Member Effective Date',
// 'date' => $member_effective_date,
// 'date_param2' => 'Start Period Date',
// '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',
// 'date' => $member_effective_date,
// 'date_param2' => 'End Period Date',
// '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',
// 'date' => $member_effective_date,
// 'date_param2' => 'End Period Date',
// 'end' => $corporate->currentPolicy->end
// ]), 0, null, $row);
// }
// if ($members_expire_date <= $corporate->currentPolicy->start && ($members_expire_date != $corporate->currentPolicy->start) ) {
// throw new ImportRowException(__('enrollment.MORE_THAN', [
// 'date_param' => 'Member Expired Date',
// 'date' => $members_expire_date,
// 'date_param2' => 'Start Period Date',
// 'start' => $corporate->currentPolicy->start
// ]), 0, null, $row);
// }
// if ($members_expire_date >= $corporate->currentPolicy->end && ($members_expire_date != $corporate->currentPolicy->end)) {
// throw new ImportRowException(__('enrollment.LESS_THAN', [
// 'date_param' => 'Member Expired Date',
// 'date' => $members_expire_date,
// 'date_param2' => 'END Period Date',
// 'end' => $corporate->currentPolicy->end
// ]), 0, null, $row);
// }
// if ($members_expire_date <= $member_effective_date && ($members_expire_date != $member_effective_date)) {
// throw new ImportRowException(__('enrollment.MORE_THAN', [
// 'date_param' => 'Member Expired Date',
// 'date' => $members_expire_date,
// 'date_param2' => 'Member Effective Date',
// 'start' => $member_effective_date
// ]), 0, null, $row);
// }
if($corporate->code != $row['corporate_id']){
throw new ImportRowException(__('enrollment.CORPORATE_CODE_NOT_MATCH', [
'corporate_id' => $row['corporate_id']
]), 0, null, $row);
}
switch ($row['record_mode']) {
case "1": // New Member
$this->validateRow($row);
@@ -707,8 +713,8 @@ class MemberEnrollmentService
],
[
'name' => $row['name'] ?? null,
// 'birth_date' => $this->dateParser($row['date_of_birth']),
'birth_date' => $row['date_of_birth'],
'birth_date' => $this->dateParser($row['date_of_birth']),
// 'birth_date' => $row['date_of_birth'],
'gender' => Helper::genderNormalization($row['sex']),
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
@@ -758,22 +764,23 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
}
}
try {
DB::beginTransaction();
$member->fill($member_data);
if ($member->save()) {
$person = Person::create([
'name' => $row['name'],
'birth_date' => $row['date_of_birth'],
'gender' => Helper::genderNormalization($row['sex']),
'birth_date' => $this->dateParser($row['date_of_birth']) ?? null,
'gender' => Helper::genderNormalization($row['sex']) ?? '-',
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
'phone' => $row['telephone_mobile'],
]);
$member->person_id = $person->id;
$member->save();
$memberPolicy = new MemberPolicy();
$memberPolicy->fill([
'member_id' => $member->member_id,
@@ -782,7 +789,7 @@ class MemberEnrollmentService
'end' => $this->dateParser($row['member_expiry_date']),
'status' => 'active'
]);
$memberPolicy->save();
if (!empty($row['division_name'])) {
@@ -807,7 +814,7 @@ class MemberEnrollmentService
'status' => $row['employment_status']
]);
// Bisa disini penyebab data dobel
$plans = explode(",",$row['plan_id']);
if (count($plans) > 0) {
foreach($plans as $d){
@@ -840,7 +847,7 @@ class MemberEnrollmentService
'end' => $this->dateParser($row['member_expiry_date']),
]);
}
}
DB::commit();
} catch (\Exception $e) {
@@ -849,12 +856,12 @@ class MemberEnrollmentService
}
break;
case "2": // Member Information Update (Without Replacement Card)
// $this->validateRow($row);
$member = Member::query()
->where('member_id', $row['member_id'])
->first();
// // Validate If Exist Member
if (!$member) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_FOUND', [
@@ -862,7 +869,7 @@ class MemberEnrollmentService
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
$person = Person::updateOrCreate(
[
@@ -870,15 +877,14 @@ class MemberEnrollmentService
],
[
'name' => $row['name'] ?? null,
// 'birth_date' => $this->dateParser($row['date_of_birth']),
'birth_date' => $row['date_of_birth'],
'birth_date' => $this->dateParser($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 {
@@ -952,7 +958,7 @@ class MemberEnrollmentService
// 'end' => $this->dateParser($row['member_expiry_date']),
// ]);
// }
// end update plan
@@ -1024,14 +1030,15 @@ class MemberEnrollmentService
'dUpdateOn' => date('Y-m-d H:i:s'),
]
);
$userLmsDetail = UserDetail::updateOrCreate(
[
'nIDUser' => $nIDUser
],
[
'nIDUser' => $nIDUser,
'dTanggalLahir' => $row['date_of_birth'],
// 'dTanggalLahir' => $row['date_of_birth'],
'dTanggalLahir' => $this->dateParser($row['date_of_birth']),
'dCreateOn' => date('Y-m-d H:i:s'),
'sMartialStatus' => $sMartialStatus != 0 ? $sMartialStatus : null,
'nIDJenisKelamin' => $nIDJenisKelamin,
@@ -1059,7 +1066,7 @@ class MemberEnrollmentService
if (!$memberPolicy->member->isDirty()) {
throw new ImportRowException(__('enrollment.MEMBER_NO_CHANGE'), 0, null, $row);
}
$memberPolicy->member->save();
$member->save();
// update informasi person
@@ -1205,7 +1212,7 @@ class MemberEnrollmentService
// if (empty($row["option_mode"])) {
// throw new ImportRowException(__('enrollment.OPTION_MODE_INVALID_FORMAT', [
// 'member_id' => $row['member_id'],
// 'member_id' => $row['member_id'],
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
@@ -1218,7 +1225,7 @@ class MemberEnrollmentService
// // Validate
// if ( !in_array($option_mode[0], ['P', 'D']) || empty($corp_code) || empty($policy_number) || empty($member_id) ) {
// throw new ImportRowException(__('enrollment.OPTION_MODE_INVALID_FORMAT', [
// 'member_id' => $row['member_id'],
// 'member_id' => $row['member_id'],
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
@@ -1280,7 +1287,7 @@ class MemberEnrollmentService
// $memberPolicy->member->record_type == $row['record_type']
// ) {
// throw new ImportRowException(__('enrollment.UNIQUE_CHANGE_PRINCIPAL_INVALID', [
// 'member_id' => $row['member_id'],
// 'member_id' => $row['member_id'],
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
@@ -1293,7 +1300,7 @@ class MemberEnrollmentService
// $memberPolicy->member->payor_id == $row['payor_id']
// ) {
// throw new ImportRowException(__('enrollment.UNIQUE_CHANGE_DEPENDANT_INVALID', [
// 'member_id' => $row['member_id'],
// 'member_id' => $row['member_id'],
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
@@ -1533,10 +1540,10 @@ class MemberEnrollmentService
$value = $row_data[$this->doc_headers_to_field_map[$header]] ?? null;
if (is_string($value)) {
$cells[] = WriterEntityFactory::createCell($value);
}
}
else if ($value instanceof DateTime) {
$cells[] = WriterEntityFactory::createCell(Carbon::parse($value)->format('Ymd'));
}
}
else {
$cells[] = WriterEntityFactory::createCell($value);
}
@@ -1549,7 +1556,7 @@ class MemberEnrollmentService
public function validateRangePeriode($dates){
$date = date("Y-m-d", strtotime($dates));
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->start <= $date) {
}
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->end >= $date) {
dd($corporate->currentPolicy->end, $dates);