{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Premium",
  "definitions": {
    "Premium": {
      "type": "object",
      "properties": {
        "writtenPremium": {
          "$ref": "#/definitions/Money",
          "description": "The written (booked) premium for this coverage"
        },
        "minimumPremium": {
          "$ref": "#/definitions/Money",
          "description": "Minimum premium — floor below which premium cannot be reduced"
        },
        "depositPremium": {
          "$ref": "#/definitions/Money",
          "description": "Deposit premium — amount due at inception for auditable policies"
        },
        "estimatedPremium": {
          "$ref": "#/definitions/Money",
          "description": "Estimated premium — projected premium based on estimated exposures"
        },
        "auditedPremium": {
          "$ref": "#/definitions/Money",
          "description": "Audited premium — final premium determined by premium audit"
        },
        "basis": {
          "$ref": "#/definitions/PremiumBasis",
          "description": "How the premium was calculated (rate, basis, exposure)"
        },
        "adjustments": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PremiumAdjustment"
          },
          "description": "Premium modifications and adjustments (experience mod, schedule credits, etc.)"
        },
        "isAuditable": {
          "type": "boolean",
          "description": "Whether this coverage is subject to premium audit"
        },
        "installments": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PremiumInstallment"
          },
          "description": "Payment installment schedule"
        },
        "allocationByLocation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PremiumAllocation"
          },
          "description": "Premium allocation by location or classification"
        }
      },
      "required": [
        "writtenPremium"
      ],
      "additionalProperties": false,
      "description": "Comprehensive premium structure for a coverage section. Replaces the inline `Money` premium, `rate`, `rateBasis`, `exposure`, and `experienceModFactor` fields, capturing the full lifecycle of insurance premium from estimate through audit.",
      "examples": [
        {
          "writtenPremium": {
            "value": 42000,
            "currency": "USD"
          },
          "depositPremium": {
            "value": 21000,
            "currency": "USD"
          },
          "basis": {
            "ratePerUnit": 2.45,
            "rateBasis": {
              "text": "per $100 of payroll"
            },
            "exposureAmount": {
              "value": 1500000,
              "unit": "payroll"
            }
          },
          "isAuditable": true
        }
      ]
    },
    "Money": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Numeric amount. Represented as a number; precision should be maintained by the consuming system."
        },
        "currency": {
          "type": "string",
          "description": "ISO 4217 currency code.",
          "default": "USD"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "A monetary amount with currency.",
      "examples": [
        {
          "value": 1000000,
          "currency": "USD"
        }
      ]
    },
    "PremiumBasis": {
      "type": "object",
      "properties": {
        "ratePerUnit": {
          "type": "number",
          "description": "Rate per unit of exposure (e.g., 2.45 per $100 of payroll)"
        },
        "rateBasis": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "Description of the rate basis (e.g., \"per $100 of payroll\", \"per $1,000 of revenue\")."
        },
        "exposureAmount": {
          "$ref": "#/definitions/Quantity",
          "description": "The exposure measure used in the calculation"
        },
        "basePremium": {
          "$ref": "#/definitions/Money",
          "description": "Base premium before adjustments (if flat-rated or minimum applies)"
        }
      },
      "additionalProperties": false,
      "description": "The rating basis used to calculate premium. Captures the rate, what it's applied to, and the exposure measure."
    },
    "CodeableConcept": {
      "type": "object",
      "properties": {
        "coding": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Coding"
          },
          "description": "Code(s) from formal code systems"
        },
        "text": {
          "type": "string",
          "description": "Plain text representation of the concept"
        }
      },
      "additionalProperties": false,
      "description": "A concept with a coding and optional text. Wraps one or more Coding values with a human-readable summary."
    },
    "Coding": {
      "type": "object",
      "properties": {
        "system": {
          "type": "string",
          "description": "The code system URI that defines the code.",
          "format": "uri"
        },
        "code": {
          "type": "string",
          "description": "The code value from the code system"
        },
        "display": {
          "type": "string",
          "description": "Human-readable display text for the code"
        }
      },
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "description": "A coded value from a defined code system. Used throughout BIND for standardized enumerations.",
      "examples": [
        {
          "system": "https://bind.codes/line-of-business",
          "code": "GL",
          "display": "General Liability"
        }
      ]
    },
    "Quantity": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Numeric value"
        },
        "unit": {
          "type": "string",
          "description": "Unit of measure (e.g. \"sqft\", \"vehicles\", \"employees\")"
        },
        "system": {
          "type": "string",
          "description": "Code system URI for the unit.",
          "format": "uri"
        },
        "code": {
          "type": "string",
          "description": "Coded form of the unit"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "A quantity with a value and unit.",
      "examples": [
        {
          "value": 50000,
          "unit": "sqft"
        }
      ]
    },
    "PremiumAdjustment": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "Type of adjustment (experience-mod, schedule-credit, schedule-debit, IRPM, etc.)"
        },
        "factor": {
          "type": "number",
          "description": "Multiplicative factor (e.g., 0.85 = 15% credit, 1.15 = 15% debit)"
        },
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "Fixed dollar adjustment amount"
        },
        "description": {
          "type": "string",
          "description": "Description of the adjustment"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "description": "A premium adjustment or modification factor. Represents experience modifications, schedule credits/debits, IRPMs, and similar adjustments.",
      "examples": [
        {
          "type": {
            "text": "Experience Modification"
          },
          "factor": 0.85,
          "description": "15% credit based on 3-year loss history"
        }
      ]
    },
    "PremiumInstallment": {
      "type": "object",
      "properties": {
        "installmentNumber": {
          "type": "number",
          "description": "Installment sequence number"
        },
        "dueDate": {
          "type": "string",
          "description": "Date the installment is due.",
          "format": "date"
        },
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "Installment amount"
        },
        "status": {
          "type": "string",
          "enum": [
            "due",
            "paid",
            "overdue",
            "waived"
          ],
          "description": "Payment status"
        }
      },
      "required": [
        "installmentNumber",
        "dueDate",
        "amount"
      ],
      "additionalProperties": false,
      "description": "A premium payment installment."
    },
    "PremiumAllocation": {
      "type": "object",
      "properties": {
        "location": {
          "$ref": "#/definitions/Reference",
          "description": "Reference to the location this premium is allocated to"
        },
        "classification": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "Classification or category for this allocation"
        },
        "risk": {
          "$ref": "#/definitions/Reference",
          "description": "Reference to the risk this premium is allocated to (for per-vehicle breakdowns)"
        },
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "Allocated premium amount"
        }
      },
      "required": [
        "amount"
      ],
      "additionalProperties": false,
      "description": "Premium allocation to a specific location or classification. Used for multi-location policies and state-by-state breakdowns."
    },
    "Reference": {
      "type": "object",
      "properties": {
        "reference": {
          "type": "string",
          "description": "Relative or absolute reference to another resource. Format: `{ResourceType}/{id}` for relative references."
        },
        "type": {
          "type": "string",
          "description": "The resource type being referenced"
        },
        "display": {
          "type": "string",
          "description": "Text alternative for the reference (e.g. display name)"
        }
      },
      "additionalProperties": false,
      "description": "A reference from one BIND resource to another.",
      "examples": [
        {
          "reference": "Insured/ins-789",
          "display": "Acme Corp"
        }
      ]
    }
  },
  "$id": "https://bind-standard.org/schema/Premium",
  "title": "Premium"
}
