{
  "nodes": [
    {
      "type": "inputNode",
      "id": "input",
      "name": "request",
      "position": { "x": 100, "y": 220 }
    },
    {
      "type": "decisionTableNode",
      "id": "driverRisk",
      "name": "DriverRisk",
      "position": { "x": 400, "y": 80 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Age", "field": "applicant.age" },
          { "id": "i2", "name": "Years Licensed", "field": "applicant.yearsLicensed" }
        ],
        "outputs": [
          { "id": "o1", "name": "Age Factor", "field": "ageFactor" },
          { "id": "o2", "name": "Experience Factor", "field": "expFactor" }
        ],
        "rules": [
          { "_id": "r1", "i1": "< 21", "i2": "", "o1": "1.8", "o2": "1.0" },
          { "_id": "r2", "i1": "[21..25]", "i2": "", "o1": "1.4", "o2": "1.0" },
          { "_id": "r3", "i1": "[26..65]", "i2": "", "o1": "1.0", "o2": "1.0" },
          { "_id": "r4", "i1": "> 65", "i2": "", "o1": "1.2", "o2": "1.0" },
          { "_id": "r5", "i1": "", "i2": "< 2", "o1": "1.0", "o2": "1.5" },
          { "_id": "r6", "i1": "", "i2": "[2..5]", "o1": "1.0", "o2": "1.2" },
          { "_id": "r7", "i1": "", "i2": "> 5", "o1": "1.0", "o2": "1.0" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "drivingHistory",
      "name": "DrivingHistory",
      "position": { "x": 400, "y": 220 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Accidents (5yr)", "field": "applicant.accidentsLast5Years" },
          { "id": "i2", "name": "Violations (3yr)", "field": "applicant.violationsLast3Years" }
        ],
        "outputs": [
          { "id": "o1", "name": "History Factor", "field": "historyFactor" },
          { "id": "o2", "name": "Surcharge", "field": "surcharge" }
        ],
        "rules": [
          { "_id": "r1", "i1": "0", "i2": "0", "o1": "0.9", "o2": "0" },
          { "_id": "r2", "i1": "0", "i2": "1", "o1": "1.0", "o2": "0" },
          { "_id": "r3", "i1": "0", "i2": "[2..3]", "o1": "1.2", "o2": "50" },
          { "_id": "r4", "i1": "1", "i2": "[0..1]", "o1": "1.3", "o2": "100" },
          { "_id": "r5", "i1": "1", "i2": ">= 2", "o1": "1.5", "o2": "200" },
          { "_id": "r6", "i1": "2", "i2": "", "o1": "1.8", "o2": "350" },
          { "_id": "r7", "i1": ">= 3", "i2": "", "o1": "2.5", "o2": "500" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "vehicleRisk",
      "name": "VehicleRisk",
      "position": { "x": 400, "y": 360 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Vehicle Age", "field": "vehicleAge" },
          { "id": "i2", "name": "Safety Rating", "field": "vehicle.safetyRating" },
          { "id": "i3", "name": "Anti-Theft", "field": "vehicle.antiTheft" }
        ],
        "outputs": [
          { "id": "o1", "name": "Vehicle Factor", "field": "vehicleFactor" }
        ],
        "rules": [
          { "_id": "r1", "i1": "< 3", "i2": ">= 4", "i3": "true", "o1": "0.9" },
          { "_id": "r2", "i1": "< 3", "i2": ">= 4", "i3": "false", "o1": "1.0" },
          { "_id": "r3", "i1": "[3..10]", "i2": ">= 3", "i3": "", "o1": "1.0" },
          { "_id": "r4", "i1": "[3..10]", "i2": "< 3", "i3": "", "o1": "1.1" },
          { "_id": "r5", "i1": "", "i2": "", "i3": "", "o1": "1.15" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "expressionNode",
      "id": "basePremium",
      "name": "BasePremium",
      "position": { "x": 750, "y": 220 },
      "content": {
        "expressions": [
          { "id": "e1", "key": "vehicleAge", "value": "d().year() - vehicle.year" },
          { "id": "e2", "key": "baseRate", "value": "vehicle.value * 0.03" },
          { "id": "e3", "key": "driverRisk", "value": "$nodes.DriverRisk.ageFactor * $nodes.DriverRisk.expFactor" },
          { "id": "e4", "key": "historyRisk", "value": "$nodes.DrivingHistory.historyFactor" },
          { "id": "e5", "key": "vehicleRisk", "value": "$nodes.VehicleRisk.vehicleFactor" },
          { "id": "e6", "key": "combinedFactor", "value": "$.driverRisk * $.historyRisk * $.vehicleRisk" },
          { "id": "e7", "key": "adjustedPremium", "value": "$.baseRate * $.combinedFactor + $nodes.DrivingHistory.surcharge" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "coverageAdj",
      "name": "CoverageAdj",
      "position": { "x": 1100, "y": 140 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Coverage Type", "field": "coverage.type" },
          { "id": "i2", "name": "Deductible", "field": "coverage.deductible" }
        ],
        "outputs": [
          { "id": "o1", "name": "Coverage Multiplier", "field": "coverageMult" },
          { "id": "o2", "name": "Deductible Discount", "field": "deductDiscount" }
        ],
        "rules": [
          { "_id": "r1", "i1": "\"full\"", "i2": "", "o1": "1.4", "o2": "0" },
          { "_id": "r2", "i1": "\"standard\"", "i2": "", "o1": "1.0", "o2": "0" },
          { "_id": "r3", "i1": "\"liability_only\"", "i2": "", "o1": "0.6", "o2": "0" },
          { "_id": "r4", "i1": "", "i2": ">= 1000", "o1": "1.0", "o2": "0.15" },
          { "_id": "r5", "i1": "", "i2": "[500..999]", "o1": "1.0", "o2": "0.10" },
          { "_id": "r6", "i1": "", "i2": "< 500", "o1": "1.0", "o2": "0" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "creditAdj",
      "name": "CreditAdj",
      "position": { "x": 1100, "y": 300 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Credit Tier", "field": "applicant.creditTier" }
        ],
        "outputs": [
          { "id": "o1", "name": "Credit Factor", "field": "creditFactor" }
        ],
        "rules": [
          { "_id": "r1", "i1": "\"excellent\"", "o1": "0.85" },
          { "_id": "r2", "i1": "\"good\"", "o1": "1.0" },
          { "_id": "r3", "i1": "\"fair\"", "o1": "1.15" },
          { "_id": "r4", "i1": "\"poor\"", "o1": "1.35" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "expressionNode",
      "id": "finalPremium",
      "name": "FinalPremium",
      "position": { "x": 1450, "y": 220 },
      "content": {
        "expressions": [
          { "id": "e1", "key": "premiumBeforeCredit", "value": "adjustedPremium * $nodes.CoverageAdj.coverageMult * (1 - $nodes.CoverageAdj.deductDiscount)" },
          { "id": "e2", "key": "annualPremium", "value": "round($.premiumBeforeCredit * $nodes.CreditAdj.creditFactor, 2)" },
          { "id": "e3", "key": "monthlyPremium", "value": "round($.annualPremium / 12, 2)" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "eligibility",
      "name": "Eligibility",
      "position": { "x": 1800, "y": 220 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Accidents", "field": "applicant.accidentsLast5Years" },
          { "id": "i2", "name": "Violations", "field": "applicant.violationsLast3Years" },
          { "id": "i3", "name": "Combined Factor", "field": "combinedFactor" }
        ],
        "outputs": [
          { "id": "o1", "name": "Decision", "field": "decision" },
          { "id": "o2", "name": "Reason", "field": "reason" }
        ],
        "rules": [
          { "_id": "r1", "i1": ">= 4", "i2": "", "i3": "", "o1": "\"decline\"", "o2": "\"Excessive accidents\"" },
          { "_id": "r2", "i1": "", "i2": ">= 5", "i3": "", "o1": "\"decline\"", "o2": "\"Excessive violations\"" },
          { "_id": "r3", "i1": "", "i2": "", "i3": "> 3.0", "o1": "\"refer\"", "o2": "\"High risk - manual review\"" },
          { "_id": "r4", "i1": "", "i2": "", "i3": "", "o1": "\"approve\"", "o2": "\"Meets guidelines\"" }
        ],
        "passThrough": false
      }
    }
  ],
  "edges": [
    { "id": "e1", "sourceId": "input", "targetId": "driverRisk", "type": "edge" },
    { "id": "e2", "sourceId": "input", "targetId": "drivingHistory", "type": "edge" },
    { "id": "e3", "sourceId": "input", "targetId": "vehicleRisk", "type": "edge" },
    { "id": "e4", "sourceId": "driverRisk", "targetId": "basePremium", "type": "edge" },
    { "id": "e5", "sourceId": "drivingHistory", "targetId": "basePremium", "type": "edge" },
    { "id": "e6", "sourceId": "vehicleRisk", "targetId": "basePremium", "type": "edge" },
    { "id": "e7", "sourceId": "basePremium", "targetId": "coverageAdj", "type": "edge" },
    { "id": "e8", "sourceId": "coverageAdj", "targetId": "creditAdj", "type": "edge" },
    { "id": "e9", "sourceId": "creditAdj", "targetId": "finalPremium", "type": "edge" },
    { "id": "e10", "sourceId": "finalPremium", "targetId": "eligibility", "type": "edge" }
  ]
}
