Upgrading to 3.0¶
x12sdk 3.0 makes loops and segments that the implementation guides let repeat
into lists, so a file that repeats them is no longer rejected or silently
merged. If your code reads only the high-level API (the tables, the accessors
such as claims(), matching, generation, the command line or the MCP
server), nothing changes. Code that walks the models directly needs updating
for the attributes below, usually by adding [0].
Transaction |
Attribute |
2.x |
3.0 |
|---|---|---|---|
5010 837P |
|
one loop |
list (up to 2) |
4010 837P |
|
one loop |
list |
4010 837I |
|
one loop |
list |
835 |
|
one segment |
list |
834 |
|
one loop |
list |
834 |
|
one segment |
list; |
270 |
|
one segment |
list (up to 9); |
271 |
|
three attributes |
|
276, 277 |
|
one loop |
list (at least 1) |
For example, the service provider on a 276:
from x12sdk.generate import generate_276
from x12sdk.io import X12ModelReader
with X12ModelReader(generate_276(seed=1, patients=1)) as reader:
(inquiry,) = list(reader.models())
provider_level = inquiry.loop_2000a[0].loop_2000b[0].loop_2000c[0]
# 2.x: provider_level.loop_2100c.nm1_segment
print(provider_level.loop_2100c[0].nm1_segment.name_last_or_organization_name)
and the same pattern elsewhere:
claim.loop_2310a.nm1_segment -> claim.loop_2310a[0].nm1_segment
footer.plb_segment.adjustment_reason_code_1
-> footer.plb_segment[0].adjustment_reason_code_1
loop_2110c.loop_2120c[0].nm1_segment -> loop_2110c.ls_loop_2120c[0].loop_2120c[0].nm1_segment
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, and the X12 that x12sdk writes is the same as before.
Other changes to know about¶
A malformed file that made a parser fail with a bare
KeyError,TypeError,AttributeErrororLookupErrornow raisesX12ParseException, which names the segment, the loop and the HL but not the file’s content, and keeps the original error as__cause__.A 276 service line with no TRN before it raises a
ValueErrornaming SVC and TRN. Code that catches onlyValidationErrorwill not see it.In a 271, a
DTP,REForMSGplaced afterLEbreaks the segment order and is now reported, instead of being moved before theLSsilently.
The changelog has the full list, including the bugs 3.0 fixes.