From a2911696c79b841da93f3890a659e8039c5efbdd Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 6 Apr 2026 14:41:13 +0530 Subject: [PATCH] FEAT_OPD_POLICY_AND_FIX_MAST_VALIDATION --- app/Controllers/ClientController.php | 47 +++++++- app/Controllers/MasterController.php | 10 +- app/Views/other_policy_terms.php | 171 ++++++++++++++++++++++++++- 3 files changed, 220 insertions(+), 8 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index cf931aa6..b5d1706c 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5307,6 +5307,18 @@ class ClientController extends AdminController } $data['family_floaters']['elders_count'] = $this->request->getPost("elder_member_count") ? $this->request->getPost("elder_member_count") : 0; + + // OPD policy terms fields for policy_type_id = 72 + $data['mode_of_serviceability'] = $policy_terms['mode_of_serviceability'] ?? ''; + $data['eligibility'] = $policy_terms['eligibility'] ?? ''; + $data['total_sum_insured_limit'] = $policy_terms['total_sum_insured_limit'] ?? 'INR 15000'; + $data['in_person_doctor_consultation'] = $policy_terms['in_person_doctor_consultation'] ?? ''; + $data['prescribed_lab_test_pathology_radiology'] = $policy_terms['prescribed_lab_test_pathology_radiology'] ?? ''; + $data['prescribed_pharmacy'] = $policy_terms['prescribed_pharmacy'] ?? ''; + $data['dental'] = $policy_terms['dental'] ?? ''; + $data['vision'] = $policy_terms['vision'] ?? ''; + $data['vaccination_for_children_and_adults'] = $policy_terms['vaccination_for_children_and_adults'] ?? ''; + $data['special_condition_label'] = $policy_terms['special_condition_label'] ?? []; $data['special_condition_input'] = $policy_terms["special_condition_input"] ?? []; @@ -5364,6 +5376,7 @@ class ClientController extends AdminController $values = $data['special_condition_input'] ?? []; $special_conditions = []; + $display_fields = []; foreach ($labels as $i => $label) { $value = $values[$i] ?? ''; @@ -5376,7 +5389,39 @@ class ClientController extends AdminController $special_conditions[$label] = $value; } - return $special_conditions; + $labelMap = [ + 'mode_of_serviceability' => 'Mode Of Serviceability', + 'eligibility' => 'Eligibility', + 'total_sum_insured_limit' => 'Total Sum Insured Limit', + 'in_person_doctor_consultation' => 'In Person Doctor Consultation', + 'prescribed_lab_test_pathology_radiology' => 'Prescribed Lab Test Pathology Radiology', + 'prescribed_pharmacy' => 'Prescribed Pharmacy', + 'dental' => 'Dental', + 'vision' => 'Vision', + 'vaccination_for_children_and_adults' => 'Vaccination For Children And Adults', + ]; + + foreach ($data as $key => $value) { + if (!str_ends_with($key, '_display')) { + continue; + } + + if (empty($value)) { + continue; + } + + $baseKey = substr($key, 0, -8); + $baseValue = $data[$baseKey] ?? ''; + + if (trim((string)$baseValue) === '') { + continue; + } + + $label = $labelMap[$baseKey] ?? ucwords(str_replace('_', ' ', $baseKey)); + $display_fields[$label] = $baseValue; + } + + return array_merge($display_fields, $special_conditions); } public function checkPolicyType($policy_type_id, $client_branch_id, $client_id) diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 4087b301..75fd9800 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -420,7 +420,7 @@ class MasterController extends AdminController 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', 'errors' => [ 'required' => 'State is required.', 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' @@ -661,7 +661,7 @@ class MasterController extends AdminController 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', 'errors' => [ 'required' => 'State is required.', 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' @@ -1057,7 +1057,7 @@ class MasterController extends AdminController 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', 'errors' => [ 'required' => 'State is required.', 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' @@ -1370,7 +1370,7 @@ class MasterController extends AdminController 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', 'errors' => [ 'required' => 'State is required.', 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' @@ -3590,7 +3590,7 @@ class MasterController extends AdminController ], 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', 'errors' => [ 'required' => 'State is required.', 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' diff --git a/app/Views/other_policy_terms.php b/app/Views/other_policy_terms.php index 8e0b4360..9074f760 100755 --- a/app/Views/other_policy_terms.php +++ b/app/Views/other_policy_terms.php @@ -395,6 +395,8 @@ +
+
@@ -521,6 +523,7 @@ $('body').on('click', '.btnPolicyMaster', function() { $("#append_html_for_other_policy_terms").empty(); + $("#append_html_for_other_policy_terms_72_after_family").empty(); var client_policy_id = $(this).data('id'); policy_type_id = $(this).data('typeid'); @@ -575,6 +578,10 @@ if (res.data) { + if (policy_type_id == 72) { + appendPolicyTermsHTML(policy_type_id); + } + //special conditions fields let otherTermsJsonObjectSpecialCondition = JSON.parse(res.data); Object.keys(otherTermsJsonObjectSpecialCondition).forEach(function(key) { @@ -757,6 +764,10 @@ $('#other_member_max_age_others').val(jsonObject[key].elders.max); } + if (key.includes("enrollment_display_key") && jsonObject[key]) { + processOtherEnrollmentDisplayKey(jsonObject[key]); + } + } }); @@ -929,7 +940,12 @@ function appendPolicyTermsHTML(policy_type) { var termsHTML = "" - $('#append_html_for_other_policy_terms').empty(); + var targetContainer = '#append_html_for_other_policy_terms'; + if (policy_type == 72) { + targetContainer = '#append_html_for_other_policy_terms_72_after_family'; + } + + $(targetContainer).empty(); if (policy_type == 7) { @@ -1132,10 +1148,126 @@
+ ` + } else if (policy_type == 72) { + termsHTML = ` + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ ` } - $('#append_html_for_other_policy_terms').append(termsHTML); + $(targetContainer).append(termsHTML); } function appendOtherSIAddMore(data = null) { @@ -1177,6 +1309,41 @@ .join(' '); // Join with spaces instead of underscores } + function processOtherEnrollmentDisplayKey(displayObject) { + if (!displayObject || typeof displayObject !== 'object' || Array.isArray(displayObject)) { + return; + } + + const displayMap = { + 'Mode Of Serviceability': 'mode_of_serviceability_display', + 'Eligibility': 'eligibility_display', + 'Total Sum Insured Limit': 'total_sum_insured_limit_display', + 'In Person Doctor Consultation': 'in_person_doctor_consultation_display', + 'Prescribed Lab Test Pathology Radiology': 'prescribed_lab_test_pathology_radiology_display', + 'Prescribed Pharmacy': 'prescribed_pharmacy_display', + 'Dental': 'dental_display', + 'Vision': 'vision_display', + 'Vaccination For Children And Adults': 'vaccination_for_children_and_adults_display' + }; + + $('#append_html_for_other_policy_terms_72_after_family .unchecked').prop('checked', false); + + Object.keys(displayObject).forEach(function(label) { + let checkboxId = displayMap[label]; + if (!checkboxId) { + checkboxId = label + .toLowerCase() + .replace(/[\s\-\/,&]+/g, '_') + .replace(/_+/g, '_') + .replace(/^_+|_+$/g, '') + '_display'; + } + + if (displayObject[label] !== '' && displayObject[label] !== null && displayObject[label] !== undefined) { + $('#' + checkboxId).prop('checked', true); + } + }); + } + function autoSaveOtherTerms() { console.log('autoSaveOtherTerms function called');