Skip to content

Insurance claims

Explanation of Benefits tables: each claim line with service dates, description, status and every amount in its own field, the totals line as a type of its own, and the remark codes explained below.

input.txtHover a value to see its type · click it to find it in the treeRun in Studio
EXPLANATION OF BENEFITS

Line No.  Date of Service  Service Description  Claim Status  Provider Charges  Allowed Charges  Copay   Deductible  Coinsurance  Paid by Insurer  What You Owe  Remark Code
1         3/20/22-3/20/22  Medical care         Paid          $31.60            $2.15            $0.00   $0.00       $0.00        $2.15            $0.00         PDC
2         3/20/22-3/20/22  Medical care         Paid          $375.00           $118.12          $35.00  $0.00       $0.00        $83.12           $35.00        PDC
                                                Total         $406.60           $120.27          $35.00  $0.00       $0.00        $85.27           $35.00        PDC

Remark Code: PDC - Billed amount is higher than the maximum payment insurance allows. The payment is for the allowed amount.
insurance-healthcare.ymlspec
Date:
  $local:
    Digit: '[1-9]'
    TwoDigits: '\d{2}'
    Month:
      Single: { $fields: { digit: Digit }, $patterns: '#{digit}', $value: '0#{digit}' }
      Double: '0[1-9]|1[0-2]'
    Day:
      Single: { $fields: { digit: Digit }, $patterns: '#{digit}', $value: '0#{digit}' }
      Double: '0[1-9]|[12]\d|3[01]'
    Year:
      Short: { $fields: { digits: TwoDigits }, $patterns: '#{digits}', $value: '20#{digits}' }
      Long: '(19|20)\d{2}'
  $fields: { month: Month, day: Day, year: Year }
  $patterns: '#{month}/#{day}/#{year}'
  $value: '#{year}-#{month}-#{day}'

Money:
  $local:
    Amount:
      $local: { Group: '\d{1,3}', Whole: '\d{4,}', Cents: '\d{1,2}' }
      $fields:
        groups: { $type: 'Group[]', $separator: ',' }
        whole: Whole
        cents: Cents
      $patterns: [ '#{groups}(\.#{cents})?', '#{whole}(\.#{cents})?' ]
      $value: '[#{groups}][#{whole}][.#{cents}]'
  $fields: { amount: Amount }
  Positive:
    $patterns: '\$ ?#{amount}'
    $value: '#{amount}'
  Negative:
    $patterns: [ '-\$ ?#{amount}', '\$ ?-#{amount}', '\(\$ ?#{amount}\)' ]
    $value: '-#{amount}'

RemarkCode: {}

StatementLine:
  $flags: [ CASE_INSENSITIVE ]
  $local:
    LineHeader: 'Line( No\.?| Number| #)?'
    DatesHeader: [ 'Dates? of Service', 'Service Dates?', 'Service Period', '^Dates?$', '^DOS$' ]
    DescriptionHeader: [ 'Service Description', 'Description( of Services?)?', '^Services?( Provided)?$', 'Procedure' ]
    StatusHeader: '(Claim )?Status'
    ChargesHeader: [ 'Provider Charges?', 'Billed( Amount| Charges?)?', 'Amount Billed', 'Total Charges?', '^Charges?$' ]
    AllowedHeader: [ 'Allowed( Amount| Charges?)?', 'Approved( Amount)?', 'Plan Allowance' ]
    CopayHeader: 'Co-?pay(ment)?s?'
    DeductibleHeader: 'Deductible'
    CoinsuranceHeader: 'Co-?insurance'
    PaidHeader: [ 'Paid by (Insurer|Plan|Insurance)', '(Plan|Insurer|Insurance) Paid', 'Amount Paid', 'Paid Amount' ]
    OwedHeader: [ 'You Owe', '(Patient|Member|Your) Responsibility', 'Patient Owes' ]
    RemarkHeader: [ 'Remarks?( Codes?)?', 'Reason Codes?' ]
    TotalLabel: [ 'Totals?', '(Claim|Grand|Statement) totals?' ]
    LineNumber:
      $patterns: '\d{1,3}'
    ServiceDates:
      Range:
        $fields: { start: Date, end: Date }
        $patterns: '#{start} ?(-|–|to|thru|through) ?#{end}'
        $value: { start: '#{start}', end: '#{end}' }
      Single:
        $fields: { date: Date }
        $patterns: '#{date}'
        $value: { start: '#{date}', end: '#{date}' }
    Description:
      $patterns: '[\p{L}\p{N}][^\n]*'
    Status:
      Paid: { $patterns: [ 'Paid', 'Processed', 'Approved' ], $value: 'paid' }
      PartiallyPaid: { $patterns: [ 'Partially paid', 'Partially approved', 'Paid in part' ], $value: 'partially paid' }
      Denied: { $patterns: [ 'Denied', 'Rejected', 'Not covered', 'Not paid', 'Declined' ], $value: 'denied' }
      Pending: { $patterns: [ 'Pending', 'In process', 'Processing', 'Under review' ], $value: 'pending' }
      Adjusted: { $patterns: [ 'Adjusted', 'Reprocessed' ], $value: 'adjusted' }
  $fields:
    line: LineNumber
    dates: ServiceDates
    description: Description
    status: Status
    provider_charges: Money
    allowed_charges: Money
    copay: Money
    deductible: Money
    coinsurance: Money
    paid_by_insurer: Money
    patient_owes: Money
    remark_codes: { $type: 'RemarkCode[]', $match: '[A-Z][A-Z0-9]{1,5}', $separator: ',? ' }
  $tables:
    $columns:
      line: LineHeader
      dates: DatesHeader
      description: DescriptionHeader
      status: StatusHeader
      provider_charges: ChargesHeader
      allowed_charges: AllowedHeader
      copay: CopayHeader
      deductible: DeductibleHeader
      coinsurance: CoinsuranceHeader
      paid_by_insurer: PaidHeader
      patient_owes: OwedHeader
      remark_codes: RemarkHeader

  Total:
    $fields: { line: TotalLabel, dates: TotalLabel, description: TotalLabel, status: TotalLabel }

RemarkNote:
  $flags: [ MULTILINE ]
  $local:
    Label: '(?i:remark|reason)( (?i:codes?))?'
    Explanation: '[^\n]*[^\s]'
  $fields:
    code: { $type: RemarkCode, $match: '[A-Z][A-Z0-9]{1,5}' }
    explanation: Explanation
  $patterns:
    - '^${Label}:? #{code} ?(-|–|:) ?#{explanation}$'
    - '^#{code}( (-|–)|:) #{explanation}$'
$ texomy parse input.txt -m insurance-healthcare
insurance-healthcare.json
[
  {
    "type": "StatementLine",
    "start": 198,
    "end": 362,
    "fields": {
      "line": {
        "type": "LineNumber",
        "start": 198,
        "end": 199,
        "text": "1"
      },
      "dates": {
        "type": "ServiceDates::Range",
        "start": 208,
        "end": 223,
        "fields": {
          "start": {
            "type": "Date",
            "start": 208,
            "end": 215,
            "fields": {
              "month": {
                "type": "Month::Single",
                "start": 208,
                "end": 209,
                "fields": {
                  "digit": {
                    "type": "Digit",
                    "start": 208,
                    "end": 209,
                    "text": "3"
                  }
                },
                "value": "03"
              },
              "day": {
                "type": "Day::Double",
                "start": 210,
                "end": 212,
                "text": "20"
              },
              "year": {
                "type": "Year::Short",
                "start": 213,
                "end": 215,
                "fields": {
                  "digits": {
                    "type": "TwoDigits",
                    "start": 213,
                    "end": 215,
                    "text": "22"
                  }
                },
                "value": "2022"
              }
            },
            "value": "2022-03-20"
          },
          "end": {
            "type": "Date",
            "start": 216,
            "end": 223,
            "fields": {
              "month": {
                "type": "Month::Single",
                "start": 216,
                "end": 217,
                "fields": {
                  "digit": {
                    "type": "Digit",
                    "start": 216,
                    "end": 217,
                    "text": "3"
                  }
                },
                "value": "03"
              },
              "day": {
                "type": "Day::Double",
                "start": 218,
                "end": 220,
                "text": "20"
              },
              "year": {
                "type": "Year::Short",
                "start": 221,
                "end": 223,
                "fields": {
                  "digits": {
                    "type": "TwoDigits",
                    "start": 221,
                    "end": 223,
                    "text": "22"
                  }
                },
                "value": "2022"
              }
            },
            "value": "2022-03-20"
          }
        },
        "value": {
          "start": "2022-03-20",
          "end": "2022-03-20"
        }
      },
      "description": {
        "type": "Description",
        "start": 225,
        "end": 237,
        "text": "Medical care"
      },
      "status": {
        "type": "Status::Paid",
        "start": 246,
        "end": 250,
        "text": "Paid",
        "value": "paid"
      },
      "provider_charges": {
        "type": "Money::Positive",
        "start": 260,
        "end": 266,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 261,
            "end": 266,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 261,
                  "end": 263,
                  "text": "31"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 264,
                "end": 266,
                "text": "60"
              }
            },
            "value": "31.60"
          }
        },
        "value": "31.60"
      },
      "allowed_charges": {
        "type": "Money::Positive",
        "start": 278,
        "end": 283,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 279,
            "end": 283,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 279,
                  "end": 280,
                  "text": "2"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 281,
                "end": 283,
                "text": "15"
              }
            },
            "value": "2.15"
          }
        },
        "value": "2.15"
      },
      "copay": {
        "type": "Money::Positive",
        "start": 295,
        "end": 300,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 296,
            "end": 300,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 296,
                  "end": 297,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 298,
                "end": 300,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "deductible": {
        "type": "Money::Positive",
        "start": 303,
        "end": 308,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 304,
            "end": 308,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 304,
                  "end": 305,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 306,
                "end": 308,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "coinsurance": {
        "type": "Money::Positive",
        "start": 315,
        "end": 320,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 316,
            "end": 320,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 316,
                  "end": 317,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 318,
                "end": 320,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "paid_by_insurer": {
        "type": "Money::Positive",
        "start": 328,
        "end": 333,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 329,
            "end": 333,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 329,
                  "end": 330,
                  "text": "2"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 331,
                "end": 333,
                "text": "15"
              }
            },
            "value": "2.15"
          }
        },
        "value": "2.15"
      },
      "patient_owes": {
        "type": "Money::Positive",
        "start": 345,
        "end": 350,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 346,
            "end": 350,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 346,
                  "end": 347,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 348,
                "end": 350,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "remark_codes": [
        {
          "type": "RemarkCode",
          "start": 359,
          "end": 362,
          "text": "PDC"
        }
      ]
    }
  },
  {
    "type": "StatementLine",
    "start": 363,
    "end": 527,
    "fields": {
      "line": {
        "type": "LineNumber",
        "start": 363,
        "end": 364,
        "text": "2"
      },
      "dates": {
        "type": "ServiceDates::Range",
        "start": 373,
        "end": 388,
        "fields": {
          "start": {
            "type": "Date",
            "start": 373,
            "end": 380,
            "fields": {
              "month": {
                "type": "Month::Single",
                "start": 373,
                "end": 374,
                "fields": {
                  "digit": {
                    "type": "Digit",
                    "start": 373,
                    "end": 374,
                    "text": "3"
                  }
                },
                "value": "03"
              },
              "day": {
                "type": "Day::Double",
                "start": 375,
                "end": 377,
                "text": "20"
              },
              "year": {
                "type": "Year::Short",
                "start": 378,
                "end": 380,
                "fields": {
                  "digits": {
                    "type": "TwoDigits",
                    "start": 378,
                    "end": 380,
                    "text": "22"
                  }
                },
                "value": "2022"
              }
            },
            "value": "2022-03-20"
          },
          "end": {
            "type": "Date",
            "start": 381,
            "end": 388,
            "fields": {
              "month": {
                "type": "Month::Single",
                "start": 381,
                "end": 382,
                "fields": {
                  "digit": {
                    "type": "Digit",
                    "start": 381,
                    "end": 382,
                    "text": "3"
                  }
                },
                "value": "03"
              },
              "day": {
                "type": "Day::Double",
                "start": 383,
                "end": 385,
                "text": "20"
              },
              "year": {
                "type": "Year::Short",
                "start": 386,
                "end": 388,
                "fields": {
                  "digits": {
                    "type": "TwoDigits",
                    "start": 386,
                    "end": 388,
                    "text": "22"
                  }
                },
                "value": "2022"
              }
            },
            "value": "2022-03-20"
          }
        },
        "value": {
          "start": "2022-03-20",
          "end": "2022-03-20"
        }
      },
      "description": {
        "type": "Description",
        "start": 390,
        "end": 402,
        "text": "Medical care"
      },
      "status": {
        "type": "Status::Paid",
        "start": 411,
        "end": 415,
        "text": "Paid",
        "value": "paid"
      },
      "provider_charges": {
        "type": "Money::Positive",
        "start": 425,
        "end": 432,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 426,
            "end": 432,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 426,
                  "end": 429,
                  "text": "375"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 430,
                "end": 432,
                "text": "00"
              }
            },
            "value": "375.00"
          }
        },
        "value": "375.00"
      },
      "allowed_charges": {
        "type": "Money::Positive",
        "start": 443,
        "end": 450,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 444,
            "end": 450,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 444,
                  "end": 447,
                  "text": "118"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 448,
                "end": 450,
                "text": "12"
              }
            },
            "value": "118.12"
          }
        },
        "value": "118.12"
      },
      "copay": {
        "type": "Money::Positive",
        "start": 460,
        "end": 466,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 461,
            "end": 466,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 461,
                  "end": 463,
                  "text": "35"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 464,
                "end": 466,
                "text": "00"
              }
            },
            "value": "35.00"
          }
        },
        "value": "35.00"
      },
      "deductible": {
        "type": "Money::Positive",
        "start": 468,
        "end": 473,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 469,
            "end": 473,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 469,
                  "end": 470,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 471,
                "end": 473,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "coinsurance": {
        "type": "Money::Positive",
        "start": 480,
        "end": 485,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 481,
            "end": 485,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 481,
                  "end": 482,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 483,
                "end": 485,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "paid_by_insurer": {
        "type": "Money::Positive",
        "start": 493,
        "end": 499,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 494,
            "end": 499,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 494,
                  "end": 496,
                  "text": "83"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 497,
                "end": 499,
                "text": "12"
              }
            },
            "value": "83.12"
          }
        },
        "value": "83.12"
      },
      "patient_owes": {
        "type": "Money::Positive",
        "start": 510,
        "end": 516,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 511,
            "end": 516,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 511,
                  "end": 513,
                  "text": "35"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 514,
                "end": 516,
                "text": "00"
              }
            },
            "value": "35.00"
          }
        },
        "value": "35.00"
      },
      "remark_codes": [
        {
          "type": "RemarkCode",
          "start": 524,
          "end": 527,
          "text": "PDC"
        }
      ]
    }
  },
  {
    "type": "StatementLine::Total",
    "start": 576,
    "end": 692,
    "fields": {
      "status": {
        "type": "TotalLabel",
        "start": 576,
        "end": 581,
        "text": "Total"
      },
      "provider_charges": {
        "type": "Money::Positive",
        "start": 590,
        "end": 597,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 591,
            "end": 597,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 591,
                  "end": 594,
                  "text": "406"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 595,
                "end": 597,
                "text": "60"
              }
            },
            "value": "406.60"
          }
        },
        "value": "406.60"
      },
      "allowed_charges": {
        "type": "Money::Positive",
        "start": 608,
        "end": 615,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 609,
            "end": 615,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 609,
                  "end": 612,
                  "text": "120"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 613,
                "end": 615,
                "text": "27"
              }
            },
            "value": "120.27"
          }
        },
        "value": "120.27"
      },
      "copay": {
        "type": "Money::Positive",
        "start": 625,
        "end": 631,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 626,
            "end": 631,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 626,
                  "end": 628,
                  "text": "35"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 629,
                "end": 631,
                "text": "00"
              }
            },
            "value": "35.00"
          }
        },
        "value": "35.00"
      },
      "deductible": {
        "type": "Money::Positive",
        "start": 633,
        "end": 638,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 634,
            "end": 638,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 634,
                  "end": 635,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 636,
                "end": 638,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "coinsurance": {
        "type": "Money::Positive",
        "start": 645,
        "end": 650,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 646,
            "end": 650,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 646,
                  "end": 647,
                  "text": "0"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 648,
                "end": 650,
                "text": "00"
              }
            },
            "value": "0.00"
          }
        },
        "value": "0.00"
      },
      "paid_by_insurer": {
        "type": "Money::Positive",
        "start": 658,
        "end": 664,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 659,
            "end": 664,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 659,
                  "end": 661,
                  "text": "85"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 662,
                "end": 664,
                "text": "27"
              }
            },
            "value": "85.27"
          }
        },
        "value": "85.27"
      },
      "patient_owes": {
        "type": "Money::Positive",
        "start": 675,
        "end": 681,
        "fields": {
          "amount": {
            "type": "Amount",
            "start": 676,
            "end": 681,
            "fields": {
              "groups": [
                {
                  "type": "Group",
                  "start": 676,
                  "end": 678,
                  "text": "35"
                }
              ],
              "cents": {
                "type": "Cents",
                "start": 679,
                "end": 681,
                "text": "00"
              }
            },
            "value": "35.00"
          }
        },
        "value": "35.00"
      },
      "remark_codes": [
        {
          "type": "RemarkCode",
          "start": 689,
          "end": 692,
          "text": "PDC"
        }
      ]
    }
  },
  {
    "type": "RemarkNote",
    "start": 694,
    "end": 818,
    "fields": {
      "code": {
        "type": "RemarkCode",
        "start": 707,
        "end": 710,
        "text": "PDC"
      },
      "explanation": {
        "type": "Explanation",
        "start": 713,
        "end": 818,
        "text": "Billed amount is higher than the maximum payment insurance allows. The payment is for the allowed amount."
      }
    }
  }
]

About this spec

Claim lines, statement totals and remark code explanations in Explanation of Benefits statements: service dates, description, claim status, provider charges, allowed charges, copay, deductible, coinsurance, insurer payment, what the patient owes and remark codes.

Package files

  • insurance-healthcare.yml
  • samples/letter.txt
  • samples/variant.txt
  • tests/expected/letter.yaml
  • tests/expected/sample.yaml
  • tests/expected/variant.yaml
  • tests/insurance-healthcare.test.yml
  • tests/values.test.yml
  • texomy.json

126 nodes from 4 top-level matches.

Run it yourself

Save the example from Studio to a folder, then in that folder:

texomy parse input.txt -m insurance-healthcare
texomy test

Write the spec once. Run it on everything.

Install the CLI, connect your agent, and turn your first sample into typed data in minutes.

brew install texomy/tap/texomy