π₯ Health & Medical Insurance: The Four Healthcare Automation Pillars
Automating medical health insurance systems requires specialized domain logic: handling Family Floater vs. Individual coverage, calculating dynamic copayments, loading actuarial risk for Pre-Existing Diseases (PED) such as diabetes and hypertension, running Third-Party Administrator (TPA) document verification, billing recurring premium installments, and adjudicating both Cashless Hospital Network approvals and Post-Hospitalization Reimbursement claims. This enterprise case study provides a complete, production-grade Playwright Python framework implementation covering: 1. Medical Policy Creation & Underwriting Risk Assessment, 2. Medical Scrutiny, TPA Document Verification & Waiting Period Assignment, 3. Multi-Channel Premium Payment & Digital Health Card Issuance, and 4. In-Patient Hospitalization Cashless Settlement & NEFT Reimbursement Adjudication, all audited with strongly-typed Pydantic v2 schemas and Allure BDD telemetry.
HEALTHCARE INSURANCE POLICY & SETTLEMENT TOPOGRAPHY:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PILLAR 1: MEDICAL POLICY ENROLLMENT (Customer / Broker Portal) β
β * Insured Members: Primary Member (34) + Spouse (32) + 1 Child (5) β
β * Plan Choice: Family Floater (βΉ 10 Lakhs SI + βΉ 50 Lakhs Restoration) β
β * Medical Disclosure: Pre-Existing Disease (PED) & Room Rent Capping Matrix β
β * Status: "PROPOSAL_INGESTED" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PILLAR 2: TPA MEDICAL SCRUTINY & VERIFICATION (Underwriter Portal) β
β * Identity & Age Proof scrutiny (Aadhaar / Passport validation) β
β * Tele-Medical Consultation check; 3-Year PED Waiting Period applied β
β * State Transition: "PROPOSAL_INGESTED" βββΊ "TPA_UNDERWRITING_APPROVED" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PILLAR 3: PREMIUM PAYMENT & DIGITAL HEALTH CARD GENERATION β
β * Payment: Annual Premium (βΉ 18,500 + 18% GST = βΉ 21,830.00) via NetBanking β
β * Member Policy Inception: 10-digit Policy ID + Member TPA Health ID Cards β
β * State Transition: "TPA_UNDERWRITING_APPROVED" βββΊ "POLICY_ACTIVE_IN_FORCEβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββ΄ββββββββββββββββββββββ
βΌ (Cashless Hospital Desk) βΌ (Reimbursement Claim)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PILLAR 4A: CASHLESS TPA PRE-AUTH APPROVALββ PILLAR 4B: REIMBURSEMENT ADJUDICATION β
β * Hospital Desk submits cashless request ββ * Member uploads final discharge summary,β
β * Real-time eligibility check ββ pharmacy bills, & diagnostic scans β
β * Initial Pre-Auth: βΉ 85,000 sanctioned ββ * Copay & Deductible assessment β
β * Final Discharge: Hospital bill cleared ββ * Payout Disbursed: NEFT to Member Bank β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
βΌ
Terminal State: "CLAIM_SETTLED_CLOSED" (IRDAI Compliant)
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Field, EmailStr
class CoverType(str, Enum):
INDIVIDUAL = "INDIVIDUAL"
FAMILY_FLOATER = "FAMILY_FLOATER"
class InsuredMemberDTO(BaseModel):
full_name: str = Field(min_length=3)
relationship: str
age: int = Field(ge=0, le=75)
has_ped: bool = Field(default=False, description="Pre-Existing Disease present")
ped_details: Optional[str] = None
class MedicalProposalDTO(BaseModel):
"""Proposal payload schema for Health/Medical Insurance policy issuance."""
proposer_name: str
proposer_email: EmailStr
cover_type: CoverType
sum_insured_inr: float = Field(ge=500000.0, le=10000000.0)
members: List[InsuredMemberDTO] = Field(min_length=1)
hospital_room_category: str = Field(default="SINGLE_PRIVATE_AC")
critical_illness_rider: bool = True
class CashlessClaimRequestDTO(BaseModel):
"""Payload schema for hospital cashless admission pre-authorization."""
policy_number: str = Field(pattern=r"^MED-\d{8}$")
tpa_member_id: str = Field(pattern=r"^TPA-[A-Z0-9]{8}$")
hospital_rohini_code: str = Field(pattern=r"^ROHINI-\d{6}$")
estimated_procedure_cost: float = Field(gt=1000.0)
diagnosis_icd_code: str = Field(pattern=r"^[A-Z][0-9]{2}(\.[0-9]+)?$")
treating_doctor_name: str
# Sample DTO validation
proposal_payload = MedicalProposalDTO(
proposer_name="Pooja Patil",
proposer_email="pooja.patil@nikita-infotech.com",
cover_type=CoverType.FAMILY_FLOATER,
sum_insured_inr=1000000.0, # βΉ 10 Lakhs Family Floater
members=[
InsuredMemberDTO(full_name="Pooja Patil", relationship="Self", age=34, has_ped=False),
InsuredMemberDTO(full_name="Aarav Patil", relationship="Spouse", age=36, has_ped=True, ped_details="Hypertension"),
InsuredMemberDTO(full_name="Rohan Patil", relationship="Son", age=6, has_ped=False)
]
)
print("Validated Medical Insurance DTO:")
print(f" Proposer : {proposal_payload.proposer_name}")
print(f" Plan Format : {proposal_payload.cover_type.value}")
print(f" Sum Insured : βΉ {proposal_payload.sum_insured_inr:,.2f}")
print(f" Members (3) : {[m.full_name for m in proposal_payload.members]}")
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.set_content("""
Arogya Sanjeevani Family Floater Policy
""")
# 1. Verify default premium with βΉ 10 Lakhs floater and critical rider
expect(page.locator("#premium-box")).to_contain_text("Total: βΉ 19470.00")
# 2. Check Hypertension pre-existing condition and assert 15% actuarial risk loading
page.locator("#ped-hypertension").check()
# Base: 14000 * 1.15 = 16100 + 2500 rider = 18600 * 1.18 GST = βΉ 21,948.00
expect(page.locator("#premium-box")).to_contain_text("Total: βΉ 21948.00")
# 3. Submit proposal to trigger unique proposal tracking reference
page.locator("#btn-submit-proposal").click()
proposal_tag = page.locator("#proposal-ref-tag")
expect(proposal_tag).to_have_text("PROPOSAL-MED-2026-90412")
print(f"Medical Proposal Created: Ref = '{proposal_tag.inner_text()}'")
browser.close()
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.set_content("""
TPA Underwriting Workbench: PROPOSAL-MED-2026-90412
Cover: Family Floater (2 Adults + 1 Child) | Sum Insured: βΉ 10,00,000
Declared Condition: Aarav Patil - Hypertension (Stage 1)
STATUS: PENDING_TPA_VERIFICATION
""")
approve_btn = page.locator("#btn-approve-tpa")
expect(approve_btn).to_be_disabled()
# Complete TPA scrutiny requirements
page.locator("#check-identity").check()
page.locator("#check-telemed").check()
expect(approve_btn).to_be_enabled()
# Sign off underwriting approval
approve_btn.click()
status_label = page.locator("#tpa-status")
expect(status_label).to_have_text("STATUS: TPA_UNDERWRITING_APPROVED | WAITING_PERIOD: 36_MONTHS")
print(f"TPA Scrutiny Phase Finalized: '{status_label.inner_text()}'")
browser.close()
import os
import tempfile
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.set_content("""
Health Premium Authorization Gateway
Proposal: PROPOSAL-MED-2026-90412
Total Payable: βΉ 21,948.00 (Annual)
""")
# Authorize payment
page.locator("#btn-pay-health").click()
# Verify generated policy number and TPA Member ID
policy_locator = page.locator("#master-policy-tag")
tpa_locator = page.locator("#tpa-id-tag")
expect(policy_locator).to_have_text("MED-88410295")
expect(tpa_locator).to_have_text("TPA-MED88419")
# Intercept asynchronous download of Digital Health ID Card PDF
with page.expect_download() as download_info:
page.locator("#download-health-card").click()
card_download = download_info.value
target_card_path = os.path.join(tempfile.gettempdir(), card_download.suggested_filename)
card_download.save_as(target_card_path)
print("Medical Policy Payment & Health Card Issuance Verified:")
print(f" Master Policy ID : {policy_locator.inner_text()}")
print(f" TPA Health ID : {tpa_locator.inner_text()}")
print(f" Downloaded Card : {card_download.suggested_filename} ({os.path.getsize(target_card_path)} bytes)")
assert os.path.exists(target_card_path)
if os.path.exists(target_card_path):
os.remove(target_card_path)
browser.close()
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.set_content("""
Network Hospital Cashless Pre-Auth Portal
Hospital: Ruby Hall Clinic (ROHINI Code: ROHINI-411001)
Policy: MED-88410295 | TPA ID: TPA-MED88419
Patient: Pooja Patil | Diagnosis: Acute Appendicitis (ICD-10: K35.8)
""")
# 1. Assert patient details
expect(page.locator("#pol-check")).to_have_text("MED-88410295")
expect(page.locator("#tpa-check")).to_have_text("TPA-MED88419")
# 2. Submit cashless admission request
page.locator("#btn-request-preauth").click()
# 3. Assert real-time cashless approval
preauth_ref = page.locator("#preauth-ref")
sanctioned = page.locator("#sanctioned-amt")
auth_state = page.locator("#auth-state")
expect(preauth_ref).to_have_text("CASHLESS-AUTH-2026-99214")
expect(sanctioned).to_have_text("βΉ 1,15,000.00")
expect(auth_state).to_have_text("STATUS: PRE_AUTH_APPROVED")
print(f"Hospital Cashless Sanctioned: Ref = '{preauth_ref.inner_text()}' for {sanctioned.inner_text()}")
browser.close()
import os
import tempfile
from playwright.sync_api import sync_playwright, expect
# Create mock hospital bill and discharge summary attachment
temp_dir = tempfile.gettempdir()
mock_discharge_pdf = os.path.join(temp_dir, "discharge_summary_case902.pdf")
with open(mock_discharge_pdf, "wb") as f:
f.write(b"%PDF-1.4 Mock Discharge Summary & Bills")
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.set_content("""
Post-Hospitalization Reimbursement Adjudication
Policy: MED-88410295 | Claimant: Pooja Patil
Claim Type: Post-Hospitalization Diagnostic Scans & Pharmacy
""")
# 1. Attach verified discharge summary PDF
page.locator("#bill-upload").set_input_files(mock_discharge_pdf)
# 2. Authorize claim settlement
page.locator("#btn-settle-reimbursement").click()
# 3. Assert claim ledger updates
settled_locator = page.locator("#settled-amt")
utr_locator = page.locator("#utr-ref-tag")
final_status = page.locator("#reimburse-status")
expect(settled_locator).to_have_text("βΉ 35,000.00")
expect(utr_locator).to_have_text("NEFT-HDFC-2026-8841902")
expect(final_status).to_have_text("STATUS: CLAIM_SETTLED_CLOSED")
print(f"Reimbursement Claim Settled: Amount = {settled_locator.inner_text()} | UTR = '{utr_locator.inner_text()}'")
if os.path.exists(mock_discharge_pdf):
os.remove(mock_discharge_pdf)
browser.close()
import json
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
context = browser.new_context()
# 1. API PRECONDITION: Seed active policy and TPA card in 38ms
seeded_health_policy = {
"policy_number": "MED-99418204",
"tpa_member_id": "TPA-PUNE994",
"primary_member": "Pooja Patil",
"sum_insured_inr": 1000000.0,
"balance_sum_insured_inr": 1000000.0,
"status": "POLICY_ACTIVE_IN_FORCE"
}
seed_res = context.request.post("https://httpbin.org/post", data=seeded_health_policy)
expect(seed_res).to_be_ok()
print(f"[Core API Setup] Active Medical Policy {seeded_health_policy['policy_number']} seeded in 38ms.")
# 2. UI NAVIGATION: Open hospital desk directly with seeded TPA credentials
page = context.new_page()
page.set_content(f"""
Hospital Cashless Admission Check
{seeded_health_policy['policy_number']}
{seeded_health_policy['tpa_member_id']}
{seeded_health_policy['status']}
""")
expect(page.locator("#card-policy")).to_have_text("MED-99418204")
expect(page.locator("#card-status")).to_have_text("POLICY_ACTIVE_IN_FORCE")
page.locator("#btn-admit").click()
expect(page.locator("#card-status")).to_have_text("HOSPITAL_ADMISSION_VERIFIED")
print("Fast-track hybrid execution verified: API policy initialization with targeted UI hospitalization verification!")
context.close()
browser.close()
import allure
import pytest
from playwright.sync_api import Page, expect
@allure.epic("Healthcare & Health Insurance Operations")
@allure.feature("End-to-End Medical Policy Lifecycle")
class TestMedicalInsuranceE2E:
@allure.story("Medical Underwriting, Digital Health Card, Cashless Pre-Auth & Reimbursement")
@allure.severity(allure.severity_level.BLOCKER)
@allure.title("Complete Medical Insurance Cycle: Floater Proposal to Claim Settlement")
def test_full_medical_policy_lifecycle(self, page: Page):
# ββ PILLAR 1: PROPOSAL ENROLLMENT βββββββββββββββββββββββββββ
with allure.step("Pillar 1: Enroll Family Floater (βΉ 10L Sum Insured + PED Declaration)"):
page.set_content("""
STAGE_PROPOSAL_SUBMITTED
""")
page.locator("#btn-step").click()
expect(page.locator("#stage")).to_have_text("STAGE_TPA_APPROVED")
allure.attach("Proposal Ref: PROPOSAL-MED-2026-90412", name="Proposal_Details", attachment_type=allure.attachment_type.TEXT)
# ββ PILLAR 2: TPA MEDICAL SCRUTINY ββββββββββββββββββββββββββ
with allure.step("Pillar 2: TPA Scrutiny & 36-Month PED Waiting Period Endorsement"):
page.evaluate("""() => {
document.getElementById('stage').innerText = 'STAGE_PAYMENT_READY: 36M_WAITING_PERIOD';
}""")
expect(page.locator("#stage")).to_contain_text("STAGE_PAYMENT_READY")
# ββ PILLAR 3: PREMIUM PAYMENT & HEALTH CARD βββββββββββββββββ
with allure.step("Pillar 3: Process Annual Premium of βΉ 21,948 & Issue Digital Health Card"):
page.evaluate("""() => {
document.getElementById('stage').innerText = 'POLICY_ACTIVE_IN_FORCE: MED-88410295';
}""")
expect(page.locator("#stage")).to_contain_text("MED-88410295")
allure.attach("Master Health Policy ID: MED-88410295 | TPA ID: TPA-MED88419", name="Policy_And_Health_Cards", attachment_type=allure.attachment_type.TEXT)
# ββ PILLAR 4: CASHLESS PRE-AUTH & REIMBURSEMENT βββββββββββββ
with allure.step("Pillar 4: Sanction Hospital Cashless Pre-Auth & Settle Claim via NEFT"):
page.evaluate("""() => {
document.getElementById('stage').innerText = 'CLAIM_SETTLED_CLOSED: NEFT-HDFC-8841902';
}""")
expect(page.locator("#stage")).to_contain_text("CLAIM_SETTLED_CLOSED")
allure.attach("Cashless Pre-Auth Ref: CASHLESS-AUTH-2026-99214\nReimbursement UTR: NEFT-HDFC-8841902\nDisbursed: βΉ 35,000.00",
name="Final_Settlement_Audit_Voucher",
attachment_type=allure.attachment_type.TEXT)
print("All 4 medical insurance pillars verified and reported in Allure executive suite!")
MEDICAL INSURANCE AUTOMATION ARCHITECTURAL MATRIX:
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β Medical Domain Pillar β Automation Challenge β Recommended Playwright Python Solution β
ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ€
β 1. Proposal Enrollment β Complex family floater arrays & dynamic β Pydantic InsuredMemberDTO model + β
β β actuarial risk loading on declared PED β expect().to_contain_text() auto-waiting β
β 2. TPA Scrutiny β Checklists for tele-medical consultation β Scoped checkbox locators + asserting β
β β and assigning 36-month waiting period β state update to TPA_UNDERWRITING_APPROVEDβ
β 3. Premium Payment β Multi-channel payment verification and β Mock billing route + page.expect_ β
β β issuing digital member TPA Health Cards β download() for member ID card PDF captureβ
β 4A. Hospital Cashless Desk β Real-time in-patient pre-auth approval β Bounding box assertion on sanitized TPA β
β β at network hospitals with co-pay checks β authorization reference voucher β
β 4B. Claim Reimbursement β Uploading multipart hospital bills and β Native set_input_files() + asserting β
β β deducting non-medical consumable costs β NEFT UTR settlement ledger update β
β Hybrid Fast-Track Seeding β Avoiding 20-minute form fills to test β Seed active health policies in 40ms via β
β β hospital cashless admission desks β context.request.post() direct API calls β
β Executive & Audit Compliance β Providing IRDAI-compliant audit trails β allure-pytest steps with attached health β
β β for insurance claim settlements β IDs, cashless vouchers, and trace ZIPs β
ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββ