Health Insurance Claim Automation

What it does:
Automates the submission, verification, and payout of health insurance claims based on predefined coverage rules and approvals.

Why it matters:
Reduces paperwork, fraud, and long processing times by enforcing transparent, rule-based claim settlement without relying on manual intermediaries.

How it works:

  • Insurance coverage terms and payout limits are set at deployment

  • Patient submits a medical claim with treatment details

  • Healthcare provider confirms the treatment on-chain

  • Insurer verifies claim eligibility and coverage

  • Approved claims trigger automatic payout

  • All claim actions are permanently auditable on-chain

      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * @title HealthInsuranceClaimAutomation
 * @author Nam
 * @notice Automates health insurance claim processing and payouts
 */
contract HealthInsuranceClaimAutomation {

    // -------------------- ROLES --------------------

    address public insurer;
    address public healthcareProvider;
    address public patient;

    // -------------------- INSURANCE TERMS --------------------

    uint256 public coverageLimit;

    // -------------------- CLAIM STATE --------------------

    struct Claim {
        uint256 amount;
        bool submitted;
        bool providerApproved;
        bool insurerApproved;
        bool paid;
    }

    Claim public claim;

    // -------------------- EVENTS --------------------

    event ClaimSubmitted(address indexed patient, uint256 amount);
    event TreatmentConfirmed(address indexed provider);
    event ClaimApproved(address indexed insurer);
    event ClaimPaid(address indexed patient, uint256 amount);

    // -------------------- MODIFIERS --------------------

    modifier onlyPatient() {
        require(msg.sender == patient, "Not patient");
        _;
    }

    modifier onlyProvider() {
        require(msg.sender == healthcareProvider, "Not provider");
        _;
    }

    modifier onlyInsurer() {
        require(msg.sender == insurer, "Not insurer");
        _;
    }

    // -------------------- CONSTRUCTOR --------------------

    constructor(
        address _patient,
        address _healthcareProvider,
        uint256 _coverageLimit
    ) {
        require(_patient != address(0), "Invalid patient");
        require(_healthcareProvider != address(0), "Invalid provider");

        insurer = msg.sender;
        patient = _patient;
        healthcareProvider = _healthcareProvider;
        coverageLimit = _coverageLimit;
    }

    // -------------------- CLAIM LOGIC --------------------

    /**
     * @notice Patient submits a health insurance claim
     */
    function submitClaim(uint256 _amount)
        external
        onlyPatient
    {
        require(!claim.submitted, "Claim already submitted");
        require(_amount > 0, "Invalid claim amount");
        require(_amount = claim.amount, "Insufficient funds");

        claim.paid = true;
        payable(patient).transfer(claim.amount);

        emit ClaimPaid(patient, claim.amount);
    }

    // -------------------- FUNDING --------------------

    /**
     * @notice Fund insurance pool
     */
    function fundPool() external payable onlyInsurer {}
}