8.0 KiB
8.0 KiB
2026-04-06 — OPD Policy Terms Plan (policy_type_id = 72)
Context
- Policy type:
72 - Policy terms label:
OPD Policy Terms - Requested fields/content:
Mode of ServiceabilityEligibilityTotal Sum Insured limit - INR 15000In Person Doctor ConsultationPrescribed Lab test (Pathology & Radiology)Prescribed PharmacyDentalVisionVaccination for children & adults
- Target view:
app/Views/other_policy_terms.php
Problem Identified
- OPD fields were visible in UI but not saved to DB for
policy_type_id = 72. - Root cause:
app/Controllers/ClientController.phpinotherPolicyTermsFormSubmit()uses a strict field mapping for policy72and did not include the newly added OPD keys. - Impact: Submitted payload contained OPD fields, but controller dropped them before
policy_termsJSON update.
Fix Plan
-
Update
policy_type_id = 72save mapping- Add OPD keys to
$dataconstruction inotherPolicyTermsFormSubmit(). - Include defaults where applicable (
total_sum_insured_limitfallback toINR 15000).
- Add OPD keys to
-
Keep existing family floater/age mapping unchanged
- Preserve current business logic for
family_floater,family_floaters, andage_ratio. - Add OPD terms in additive mode only.
- Preserve current business logic for
-
Validate controller integrity
- Run PHP syntax check for
ClientController.php. - Confirm no changes to unrelated policy type save flow.
- Run PHP syntax check for
New Requirement Plan - _display Checkbox -> enrollment_display_key for other_policy_terms
Reference behavior (from app/Views/policy_gmc_terms.php)
- Each term row includes a checkbox with
nameending in_display. - Only checked display keys are reflected in
enrollment_display_key. - Existing loader flow reads
enrollment_display_keyand restores checkbox states.
Problem to solve in other_policy_terms
- For policy type
72, OPD fields currently do not have*_displaycheckboxes. - In controller,
otherPolicyTermsDisplayKeyConstruct()currently buildsenrollment_display_keyonly from special condition label/input pairs, not from*_displaycheckboxes. - Result: checkbox-driven display selection is not persisted/reloaded for OPD terms.
Implementation plan
-
Add
*_displaycheckboxes to OPD rows inapp/Views/other_policy_terms.php- For each OPD field (
mode_of_serviceability,eligibility,total_sum_insured_limit, etc.), add a checkbox input:name="<field_key>_display"id="<field_key>_display"- class
unchecked - default checked
- Keep checkbox + label + value input row layout aligned with existing non-72 dynamic term rows.
- For each OPD field (
-
Update
otherPolicyTermsDisplayKeyConstruct()inapp/Controllers/ClientController.php- Extend logic to parse all incoming keys ending with
_display. - For each checked display key, map base key to human-readable label and value from the corresponding base field.
- Preserve current special-condition mapping behavior; merge both outputs into one
enrollment_display_key.
- Extend logic to parse all incoming keys ending with
-
Keep save flow backward compatible
- Do not alter existing
policy_type_id == 72family floater and age mapping. - Ensure OPD values and
enrollment_display_keyare both saved inpolicy_terms. - Keep non-72 flow unchanged.
- Do not alter existing
-
Restore checkbox states on load
- Reuse existing
processJsonObject-style behavior inother_policy_terms(if missing, add equivalent) to set*_displaychecked state based onenrollment_display_key. - Verify for both newly created and previously saved records.
- Reuse existing
-
Validate end-to-end
- Save with mixed checked/unchecked OPD display checkboxes.
- Confirm DB JSON includes expected
enrollment_display_keyentries. - Reload and verify display checkbox states are restored.
Implementation Plan
-
Place OPD terms section immediately after
familyFloaterDiv_others_two- Keep
familyFloaterDiv_others_twoas the first visible block for policy72. - Insert OPD terms container directly below it in the DOM order (not before it).
- Ensure the OPD section appears before special conditions.
- Keep
-
Add OPD-specific policy terms UI block
- Add dedicated OPD template/HTML for
policy_type_id = 72. - Render OPD rows as labeled text inputs with stable keys (
mode_of_serviceability,eligibility, etc.). - Keep field names in snake_case so they serialize cleanly into
policy_termsJSON.
- Add dedicated OPD template/HTML for
-
Handle fixed sum insured limit cleanly
- Add a separate OPD field key like
total_sum_insured_limit. - Set default value as
15000(orINR 15000based on UI format) for new entries. - Keep numeric sanitization consistent with existing sum insured input behavior where applicable.
- Add a separate OPD field key like
-
Preserve existing
policy_type_id = 72family floater behavior- Do not remove current family floater section/logic already tied to
policy_type_id == 72. - Ensure OPD terms are additive and do not break
family_floater,family_floaters, andage_ratiohandling.
- Do not remove current family floater section/logic already tied to
-
Populate saved data on edit
- Reuse existing JSON hydration flow (
Object.keys(jsonObject)loop) so OPD fields auto-populate byname. - Confirm keys in UI match keys stored in policy terms JSON exactly.
- Reuse existing JSON hydration flow (
-
Validate display behavior
- Confirm form section opens for
policy_type_id > 5. - Confirm non-72 cleanup (
if(policy_type_id != 72)) does not remove OPD fields when policy type is 72. - Confirm OPD fields are not rendered for unrelated policy types.
- Confirm visual order is
familyFloaterDiv_others_two-> OPD terms -> special conditions.
- Confirm form section opens for
-
QA checklist
- Create a new policy terms record for
policy_type_id = 72with all OPD values. - Reload and verify values repopulate correctly.
- Verify submit and autosave payload include OPD keys in
policy_terms. - Verify no regressions for policy types
6and7.
- Create a new policy terms record for
Suggested Field Keys
mode_of_serviceabilityeligibilitytotal_sum_insured_limitin_person_doctor_consultationprescribed_lab_test_pathology_radiologyprescribed_pharmacydentalvisionvaccination_for_children_and_adults
Tasks
- Place OPD section after
familyFloaterDiv_others_twoin UI order. - Add
policy_type == 72OPD HTML block inappendPolicyTermsHTML(). - Ensure defaults are applied for total sum insured limit.
- Verify bind/populate works from existing JSON loader.
- Fix OPD term persistence in
ClientController::otherPolicyTermsFormSubmit()forpolicy_type_id = 72. - Add temporary debug logging for OPD72 save payload in controller.
- Add
*_displaycheckboxes for OPD term rows inother_policy_terms.php. - Extend
otherPolicyTermsDisplayKeyConstruct()to include checked*_displaykeys. - Ensure
enrollment_display_keyrestores OPD checkbox states inother_policy_terms.php. - Verify DB
policy_terms.enrollment_display_keyfor mixed checked/unchecked OPD fields. - Run manual UI verification for create/edit/submit/autosave.
- Confirm no regressions for other policy types (code-level condition check and syntax validation completed).
- Remove temporary debug logging after verification.
Verification Notes
- PHP syntax check passed for
app/Views/other_policy_terms.php(php -l). - PHP syntax check passed for
app/Controllers/ClientController.php(php -l). - Verified
policy_type_id == 72now renders OPD fields in both create and edit flows. - Verified OPD fields are now rendered in a dedicated container placed after
familyFloaterDiv_others_two. - Verified non-
72cleanup blocks remain scoped (sumInsuredDiv/family floater removals are still excluded for72). - Added temporary controller debug log (
OPD72 save payload) to confirm persisted key/value mapping during manual test. - Added OPD
*_displaycheckboxes and controller mapping so checked fields are now included inenrollment_display_key. - Added
processOtherEnrollmentDisplayKey()inother_policy_terms.phpto restore OPD display checkbox states from savedenrollment_display_key. - Manual browser verification is still required for submit + autosave end-to-end confirmation.