Skip to content

x12sdk 3.0.0

Choose a tag to compare

@owgreen-dev owgreen-dev released this 28 Nov 23:23
· 10 commits to main since this release
bb8e60b

Loops and segments that the implementation guides let repeat are now lists in
the models, so files that repeat them are no longer rejected or silently
merged. Code that reads these attributes needs updating (usually adding
[0]); the table below lists every one. Written X12 output is unchanged, and
the high-level API (x12sdk.tables, x12sdk.access, matching, generation,
the CLI and the MCP server) is unchanged. Every change in this release was
contributed by jcc004 (#32 to #38, #40).

Changed — breaking

Transaction Attribute Before After
5010 837P Loop2300.loop_2310a Optional[Loop2310A] Optional[List[Loop2310A]] (max 2)
4010 837P Loop2300.loop_2305, loop_2310a Optional[Loop] Optional[List[Loop]]
4010 837P Loop2320.loop_2330d Optional[Loop2330D] Optional[List[Loop2330D]]
4010 837P Loop2400.loop_2420f, loop_2420g Optional[Loop] Optional[List[Loop]]
4010 837I Loop2300.loop_2305 Optional[Loop2305] Optional[List[Loop2305]]
835 Footer.plb_segment Optional[PlbSegment] Optional[List[PlbSegment]]
834 Loop2000.loop_2100e, loop_2100g Optional[Loop] Optional[List[Loop]]
834 Loop2310.n3_segment Optional[N3Segment] Optional[List[N3Segment]]; absent is [], not None
270 Loop2100C.dtp_segment, Loop2100D.dtp_segment Optional[Loop2100DtpSegment] Optional[List[Loop2100DtpSegment]] (max 9); absent is [], not None
271 Loop2110C, Loop2110D: ls_segment, loop_2120c/loop_2120d, le_segment three attributes ls_loop_2120c/ls_loop_2120d: Optional[List[Loop2120CBlock]]/Optional[List[Loop2120DBlock]], each block holding one LS, its 2120 loops and its LE
276, 277 Loop2000C.loop_2100c Loop2100C List[Loop2100C] (min_length=1)
# 837P referring provider
claim.loop_2310a.nm1_segment            # 2.x
claim.loop_2310a[0].nm1_segment         # 3.0

# 835 provider-level adjustment
footer.plb_segment.adjustment_reason_code_1      # 2.x
footer.plb_segment[0].adjustment_reason_code_1   # 3.0

# 271 benefit-related entity
loop_2110c.loop_2120c[0].nm1_segment                      # 2.x
loop_2110c.ls_loop_2120c[0].loop_2120c[0].nm1_segment     # 3.0

# 276/277 service provider
loop_2000c.loop_2100c.nm1_segment       # 2.x
loop_2000c.loop_2100c[0].nm1_segment    # 3.0

Code that builds these models in Python passes lists; a single instance is not
wrapped for you. A parsed single occurrence is a one-item list.

Other behaviour changes:

  • A malformed file that made a parser fail with a bare KeyError,
    TypeError, AttributeError or LookupError now raises
    X12ParseException. The message names the segment, the loop and the
    current HL (not the file's content) and keeps the original exception as
    __cause__. A repeated BPR in an 835 is a validation error saying so.
  • A 276 service line with no TRN before it raises a ValueError naming SVC and
    TRN (a ValidationError or raw AttributeError before). Code that catches
    only ValidationError will not see it.
  • A DTP, REF or MSG placed after LE in a 271 (an order violation) used
    to be moved before the LS silently; it is now reported, as an SE
    segment-count mismatch.
  • Model dumps of the 271 2100A loop include per_segment: [] when there is no
    PER.

Fixed

  • Repeated loops are kept. A claim with two referring providers (837P
    2310A), a repeated home health care plan (4010 2305), a repeated 2330D,
    2420F or 2420G; an 835 with more than one PLB; an 834 with several 2700
    reporting categories (the second used to overwrite the first), several 2100E
    or 2100G loops, or two address lines in 2310; a 271 with two
    benefit-related entities in one 2120 loop or two LS to LE envelopes in one
    2110; a 270 with two DTPs in 2100C or 2100D; and a 276 or 277 with a second
    service-provider name loop (two NM1*1P, as sent during a provider
    identifier transition) no longer fail or lose data.
  • An 835 with no claims (a payment-only or provider-adjustment-only file)
    validates: loop_2000 defaults to an empty list.
  • 837I and 4010 837I accept up to 999 service lines, the institutional
    guide's limit (it was 50).
  • 837P: a REF in loop 2310D (supervising provider) no longer fails.
    Loop2310DRefSegment was built on the name segment instead of the
    reference segment.
  • Segments of valid loops were dropped, or opened the wrong loop, without an
    error.
    Each case now parses and writes back unchanged:
    • 4010 837P: loops 2010BC (NM1*QD), 2010BD (NM1*AO) and 2330H
      (NM1*DQ) were never routed, because their handlers were not named like
      the other loop handlers.
    • 4010 837I: loop 2010BD (NM1*QD), the 2310E qualifiers 77, LI and
      TL, and loop 2330H (NM1*FA, whose handler named a constant that did
      not exist) were not routed. An NM1*QC inside an other subscriber loop
      replaced the dependent's own patient name loop 2010CA.
    • 5010 837P and 837D: the pay-to plan loop 2010AC used the billing
      provider's REF class, which rejected 2U, FY and NF. It has its own
      class now, which also keeps the earlier EI, SY, 0B and 1G, so
      nothing that parsed before is rejected. 5010 837I 2010AC also accepts
      REF*EI.
    • 271: a PER after the information source name (2100A) was dropped;
      Loop2100A gains per_segment, up to three.
    • 834: an NM1*36 inside a coordination of benefits loop 2320 also opened a
      member employer loop 2100D.
  • 276: service lines after the first are no longer lost, and a subscriber
    with HL04 = 1 that carries its own claims no longer crashes or attaches them
    to an earlier subscriber. The 277 gets the same subscriber handling, so a
    277 whose HL04 = 1 subscriber carries its own TRN or STC is accepted.