Skip to content

CasSegment

CasSegment models the X12 CAS claim-adjustment segment used in 835 remittance advice transactions to report why a claim or service line's payment differs from the billed amount. It carries a group code plus a repeating series of reason-code/amount/quantity triplets, one triplet per distinct adjustment reason applied to the claim or line.

Purpose

  • Represents the CAS segment identity via SegmentId returning the literal "CAS" (BR-020).
  • Carries GroupCode classifying the category of adjustment (e.g. contractual, patient responsibility) applied to the claim/line.
  • Carries repeating reason-code/amount triplets in the parallel Reasoncode/Amount lists, one triplet per adjustment reason, starting at element 2 and advancing by three elements per triplet; the triplet count is floor((elementCount + 1) / 3) on Fill().
  • Adjustment amounts are exchanged unscaled (not multiplied/divided by 100), unlike the equivalent triplets on CtxSegment (BR-050).
  • Omits a reason-code triplet from Build() output entirely when its reason code is empty (BR-059).
  • The quantity position of each triplet is not implemented — quantities are neither read nor written (BR-061).

Context

  • Namespace: SAIF.Common.Files.Edi.Segments
  • Assembly/package: SAIF.Framework.Common.Files

Public members

Member Signature Purpose
SegmentId string SegmentId { get; } Returns the literal X12 segment identifier "CAS".
GroupCode string GroupCode { get; set; } The adjustment group/category code (CAS01), element 1.
Reasoncode List<string> Reasoncode { get; set; } The parallel list of adjustment reason codes, one per triplet, at elements 2, 5, 8, 11, 14, 17 (up to six triplets) (BR-061).
Amount List<decimal> Amount { get; set; } The parallel list of adjustment amounts corresponding to each Reasoncode entry, at elements 3, 6, 9, 12, 15, 18, exchanged unscaled (BR-050).
Build IEdiSegment Build() Creates a SegmentBuilder("CAS"), adds GroupCode at element 1, then for each populated Reasoncode entry adds the reason code and matching Amount at the triplet's two positions, skipping triplets whose reason code is empty (BR-059).
Fill void Fill(IEdiSegment segment) Computes the triplet count as floor((elementCount + 1) / 3) and, for each triplet index, assigns Reasoncode[i] and Amount[i] from the segment's elements (BR-061).
Parse static CasSegment Parse(IEdiSegment segment) Instantiates a new CasSegment, calls Fill(segment) on it, and returns it.

Behavioral notes

  • Fill() assigns into Reasoncode[i] and Amount[i] by list index without first allocating those lists to the required size; because List<T> indexer assignment requires an existing element at that index, calling Fill() on any segment that actually carries adjustment triplets throws an IndexOutOfRangeException/ArgumentOutOfRangeException unless the caller has pre-sized both lists — this appears to make Fill() unreachable for any segment carrying adjustments as currently written**.
  • Similarly, Build() requires the caller to have already populated Reasoncode and Amount with matching-length entries before calling it, since it does not allocate or validate them itself**.

Constraints and usage notes

  • Callers must manually pre-populate Reasoncode and Amount with the correct number of entries before invoking either Build() or Fill(), an usage requirement not enforced or documented by the class itself**.

Note: Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Common\SAIF.Common.Files\Edi\Segments\CasSegment.cs