Skip to content

Commit

Permalink
Regenerate all parsers from pyx12 2.0, and update instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Buss committed Jul 10, 2012
1 parent a80168b commit aef13f8
Show file tree
Hide file tree
Showing 18 changed files with 1,757 additions and 1,129 deletions.
Binary file removed Downloads/pyx12-1.4.0.win32.exe
Binary file not shown.
Binary file removed Downloads/pyx12-1.5.0.zip
Binary file not shown.
54 changes: 34 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ for providing the xml files in his package [pyX12](https://github.com/azoner/pyx
Installation
============

python setup.py install
```sh
python setup.py install
```

Manually Generating the Parsers
-------------------------------
Expand All @@ -129,19 +131,25 @@ or convert a file individually (which gives you more control over the result).
If you just want to generate all of the parsers, you can use the
`generate_all_parsers` script:

python tools/generate_all_parsers.py ../Downloads/pyx12-1.5.0.zip -p parsers
```sh
git clone https://github.com/azoner/pyx12.git
cd pyx12
python setup.py sdist --formats=gztar,zip
cd ../
python tools/generate_all_parsers.py pyx12/dist/pyx12-2.0.a1.zip -d parsers
```

This will generate all parsers in a directory called `parsers`.

### Generating A Single Parser ###

After extracting the xml files, you can create the related parser objects
using the tools:
You can also just create a single parser from an unzipped pyx12 source:

cd Downloads/
unzip pyx12-1.5.0.zip
cd ../tigershark/parsers
python ../tools/convertPyX12.py 835.4010.X091.A1.xml M835_4010_X091_A1.py -b ../../Downloads/pyx12-1.5.0/map/ -n parsed_835
```sh
git clone https://github.com/azoner/pyx12.git
cd parsers
python ../tools/convertPyX12.py 835.4010.X091.A1.xml M835_4010_X091_A1.py -b ../pyx12/map/ -n parsed_835
```

This will generate a `M835_4010_X091_A1.py` parser in your current directory.

Expand All @@ -151,24 +159,30 @@ Usage
Using a Parser
--------------

from tigershark.parsers import M835_4010_X091_A1
m = M835_4010_X091_A1.parsed_835
with open('/Users/sbuss/remits/95567.63695.20120314.150150528.ERA.835.edi', 'r') as f:
parsed = m.unmarshall(f.read().strip())
```python
from tigershark.parsers import M835_4010_X091_A1
m = M835_4010_X091_A1.parsed_835
with open('/Users/sbuss/remits/95567.63695.20120314.150150528.ERA.835.edi', 'r') as f:
parsed = m.unmarshall(f.read().strip())
```

Using a Facade
-----------------

Once you have parsed an X12 file, you can build a Facade around it:

from tigershark.facade.f835 import f835_4010
f = F835_4010(parsed)
```python
from tigershark.facade.f835 import f835_4010
f = F835_4010(parsed)
```

Now you can access the segments of the X12 file in an easy and pythonic way

>>> print(f.payee.zip)
94066
>>> print(f.payer.name)
United Healthcare
>>> print(len(f.claims))
150
```python
>>> print(f.payee.zip)
94066
>>> print(f.payer.name)
United Healthcare
>>> print(len(f.claims))
150
```
54 changes: 27 additions & 27 deletions tigershark/parsers/M270_4010_X092_A1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Generated by TigerShark.tools.convertPyX12 on 2012-04-05 18:33:51.227928
# Generated by TigerShark.tools.convertPyX12 on 2012-07-10 16:29:57.852895
#
from tigershark.X12.parse import Message, Loop, Segment, Composite, Element, Properties
parsed_270_HEADER = Loop( u'HEADER', Properties(looptype=u'wrapper',repeat=u'1',pos=u'015',req_sit=u'R',desc=u'Table 1 - Header'),
Expand All @@ -8,7 +8,7 @@
codes=[u'0022'] ) ),
Element( u'BHT02', Properties(desc=u'Transaction Set Purpose Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=2,
codes=[u'01', u'13', u'36'] ) ),
Element( u'BHT03', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'30'), position=3,
Element( u'BHT03', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=3,
codes=[] ) ),
Element( u'BHT04', Properties(desc=u'Date', req_sit=u'R', data_type=(u'DT',u'8',u'8'), position=4,
codes=[] ) ),
Expand All @@ -24,9 +24,9 @@
codes=[u'2B', u'36', u'GP', u'P5', u'PR'] ) ),
Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2,
codes=[u'1', u'2'] ) ),
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=3,
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3,
codes=[] ) ),
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=4,
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4,
codes=[] ) ),
Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5,
codes=[] ) ),
Expand All @@ -50,9 +50,9 @@
codes=[u'1P', u'2B', u'36', u'80', u'FA', u'GP', u'P5', u'PR'] ) ),
Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2,
codes=[u'1', u'2'] ) ),
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=3,
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3,
codes=[] ) ),
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=4,
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4,
codes=[] ) ),
Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5,
codes=[] ) ),
Expand All @@ -72,7 +72,7 @@
Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Information Receiver Additional Identification'),
Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
codes=[u'0B', u'1C', u'1D', u'1J', u'4A', u'CT', u'EL', u'EO', u'JD', u'N5', u'N7', u'Q4', u'SY', u'TJ', u'HPI'] ) ),
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'REF03', Properties(desc=u'Description', req_sit=u'S', data_type=(u'AN',u'1',u'80'), position=3,
codes=[] ) ),
Expand Down Expand Up @@ -106,15 +106,15 @@
codes=[] ) ),
Element( u'PER03', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=3,
codes=[u'ED', u'EM', u'FX', u'TE'] ) ),
Element( u'PER04', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'80'), position=4,
Element( u'PER04', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=4,
codes=[] ) ),
Element( u'PER05', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=5,
codes=[u'ED', u'EM', u'EX', u'FX', u'TE'] ) ),
Element( u'PER06', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'80'), position=6,
Element( u'PER06', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=6,
codes=[] ) ),
Element( u'PER07', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=7,
codes=[u'ED', u'EM', u'EX', u'FX', u'TE'] ) ),
Element( u'PER08', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'80'), position=8,
Element( u'PER08', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=8,
codes=[] ) ),
Element( u'PER09', Properties(desc=u'Contact Inquiry Reference', req_sit=u'N', data_type=(u'AN',u'1',u'20'), position=9,
codes=[] ) ),
Expand All @@ -124,7 +124,7 @@
codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ),
Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2,
codes=[u'ZZ'] ) ),
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=3,
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3,
codes=[] ) ),
Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4,
codes=[] ) ),
Expand Down Expand Up @@ -174,7 +174,7 @@
codes=[u'03', u'04', u'05', u'06', u'07', u'08', u'11', u'12', u'15', u'20', u'21', u'22', u'23', u'24', u'25', u'26', u'31', u'32', u'33', u'34', u'41', u'42', u'50', u'51', u'52', u'53', u'54', u'55', u'56', u'60', u'61', u'62', u'65', u'71', u'72', u'81', u'99'] ) ),
Element( u'III03', Properties(desc=u'Code Category', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=3,
codes=[] ) ),
Element( u'III04', Properties(desc=u'Free-Form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4,
Element( u'III04', Properties(desc=u'Free-form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4,
codes=[] ) ),
Element( u'III05', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=5,
codes=[] ) ),
Expand All @@ -190,7 +190,7 @@
Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'190',desc=u'Subscriber Additional Information'),
Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
codes=[u'9F', u'G1'] ) ),
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3,
codes=[] ) ),
Expand All @@ -212,9 +212,9 @@
codes=[u'IL'] ) ),
Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2,
codes=[u'1'] ) ),
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=3,
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3,
codes=[] ) ),
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=4,
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4,
codes=[] ) ),
Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5,
codes=[] ) ),
Expand All @@ -234,7 +234,7 @@
Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Subscriber Additional Identification'),
Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
codes=[u'18', u'1L', u'1W', u'49', u'6P', u'A6', u'CT', u'EA', u'EJ', u'F6', u'GH', u'HJ', u'IG', u'N6', u'NQ', u'SY'] ) ),
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3,
codes=[] ) ),
Expand Down Expand Up @@ -266,7 +266,7 @@
codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ),
Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2,
codes=[u'9K', u'D3', u'EI', u'HPI', u'SY', u'TJ', u'ZZ'] ) ),
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=3,
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3,
codes=[] ) ),
Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4,
codes=[] ) ),
Expand Down Expand Up @@ -373,7 +373,7 @@
codes=[u'03', u'04', u'05', u'06', u'07', u'08', u'11', u'12', u'15', u'20', u'21', u'22', u'23', u'24', u'25', u'26', u'31', u'32', u'33', u'34', u'41', u'42', u'50', u'51', u'52', u'53', u'54', u'55', u'56', u'60', u'61', u'62', u'65', u'71', u'72', u'81', u'99'] ) ),
Element( u'III03', Properties(desc=u'Code Category', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=3,
codes=[] ) ),
Element( u'III04', Properties(desc=u'Free-Form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4,
Element( u'III04', Properties(desc=u'Free-form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4,
codes=[] ) ),
Element( u'III05', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=5,
codes=[] ) ),
Expand All @@ -389,7 +389,7 @@
Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'190',desc=u'Dependent Additional Information'),
Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
codes=[u'9F', u'G1'] ) ),
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3,
codes=[] ) ),
Expand All @@ -411,9 +411,9 @@
codes=[u'03'] ) ),
Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2,
codes=[u'1'] ) ),
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=3,
Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3,
codes=[] ) ),
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=4,
Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4,
codes=[] ) ),
Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5,
codes=[] ) ),
Expand All @@ -433,7 +433,7 @@
Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Dependent Additional Identification'),
Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
codes=[u'18', u'1L', u'6P', u'A6', u'CT', u'EA', u'EJ', u'F6', u'GH', u'HJ', u'IF', u'IG', u'N6', u'SY'] ) ),
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3,
codes=[] ) ),
Expand Down Expand Up @@ -465,7 +465,7 @@
codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ),
Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2,
codes=[u'9K', u'D3', u'EI', u'HPI', u'SY', u'TJ', u'ZZ'] ) ),
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=3,
Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3,
codes=[] ) ),
Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4,
codes=[] ) ),
Expand Down Expand Up @@ -554,11 +554,11 @@
Segment( u'TRN', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'020',desc=u'Dependent Trace Number'),
Element( u'TRN01', Properties(desc=u'Trace Type Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=1,
codes=[u'1'] ) ),
Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'TRN03', Properties(desc=u'Originating Company Identifier', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=3,
codes=[] ) ),
Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'30'), position=4,
Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=4,
codes=[] ) ),
),
parsed_270_2100D,
Expand All @@ -577,11 +577,11 @@
Segment( u'TRN', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'020',desc=u'Subscriber Trace Number'),
Element( u'TRN01', Properties(desc=u'Trace Type Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=1,
codes=[u'1'] ) ),
Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2,
Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2,
codes=[] ) ),
Element( u'TRN03', Properties(desc=u'Originating Company Identifier', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=3,
codes=[] ) ),
Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'30'), position=4,
Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=4,
codes=[] ) ),
),
parsed_270_2100C,
Expand Down
Loading

0 comments on commit aef13f8

Please sign in to comment.