Exemplo n.º 1
0
 def setUp( self ):
     self.segments1= [ ['ST', '278', '242835'] ]
     self.segments2= [ ['ST', '279', '242835'] ]
     self.parserQual= Segment( "ST", Properties( qual=(1,"278"), desc="ST", req_sit="R" ),
         Element( "ST01", Properties(position=1,codes=["278"]) ),
         )
     self.parserNonQual= Segment( "ST", Properties( desc="ST", req_sit="R" ) )
Exemplo n.º 2
0
    def buildSegment(self, segmentNode, context, nesting=0):
        """Segment contains Elements and Composites.
        
        :param segmentNode: a :mod:`xml.dom` Element with a name of :samp:`segment`
        :param context: The Loop which contains this Segment.
        :param nesting: The current nesting level used to indent the log messages.
        """
        assert segmentNode.nodeType == DOM.Node.ELEMENT_NODE and segmentNode.nodeName == "segment"
        segXid = segmentNode.getAttribute('xid')
        name = self.getChildTextValue(segmentNode, "name")
        usage = self.getChildTextValue(segmentNode, "usage")
        pos = self.getChildTextValue(segmentNode, "pos")
        max_use = self.getChildTextValue(segmentNode, "max_use")
        syntax = self.getChildTextValue(segmentNode, "syntax")
        self.log.debug(
            "%*sSegment xid %r: name %r usage %r pos %r max_use %r syntax %r",
            nesting * 2, '', segXid, name, usage, pos, max_use, syntax)
        theSegment = Segment(
            segXid,
            Properties(desc=name,
                       req_sit=usage,
                       position=pos,
                       repeat=max_use,
                       syntax=syntax),
        )

        for c in segmentNode.childNodes:
            # Want to preserve the original XML order of <element> and <composite>
            if c.nodeType != DOM.Node.ELEMENT_NODE: continue
            if c.nodeName == "element":
                self.buildElement(c, theSegment, nesting + 1)
            elif c.nodeName == "composite":
                self.buildComposite(c, theSegment, nesting + 1)
            elif c.nodeName in (
                    "name",
                    "usage",
                    "pos",
                    "max_use",
                    "syntax",
            ):
                pass  # already consumed
            else:
                warnings.warn(XMLWarning("Unexpected %r" % (c, )))
                self.log.warning("*** Unexpected %r", c)
        context.append(theSegment)
Exemplo n.º 3
0
def buildSegment(name, desc, fieldText):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.

    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name
        and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    segment = Segment(name, Properties(desc=desc))
    for line in filter(None, fieldText.splitlines()):
        name, description = line.strip().split(None, 1)
        element = Element(name, Properties(desc=description, codes=[]))
        segment.append(element)
    return segment
Exemplo n.º 4
0
def buildSegment(name, desc, fieldText):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.
    
    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    theSeg = Segment(name, Properties(desc=desc))
    for line in fieldText.splitlines():
        clean = line.strip()
        eltName, space, eltDesc = clean.partition(" ")
        theElt = Element(eltName, Properties(desc=eltDesc))
        theSeg.append(theElt)
    return theSeg
Exemplo n.º 5
0
#
# Generated by TigerShark.tools.convertPyX12 on 2012-10-03 14:38:27.454816
#
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'), 
Segment( u'BHT', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'020',desc=u'Beginning of Hierarchical Transaction'),
  Element( u'BHT01', Properties(desc=u'Hierarchical Structure Code', req_sit=u'R', data_type=(u'ID',u'4',u'4'), position=1,
    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'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=[] ) ),
  Element( u'BHT05', Properties(desc=u'Time', req_sit=u'R', data_type=(u'TM',u'4',u'8'), position=5,
    codes=[] ) ),
  Element( u'BHT06', Properties(desc=u'Transaction Type Code', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=6,
    codes=[u'RT', u'RU'] ) ),
),
)
parsed_270_2100A = Loop( u'2100A', Properties(looptype='',repeat=u'1',pos=u'030',req_sit=u'R',desc=u'Information Source Name'), 
Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Information Source Name'),
  Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
    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'60'), position=3,
    codes=[] ) ),
  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,
Exemplo n.º 6
0
from tigershark.X12.parse import Segment
from tigershark.X12.parse import Composite
from tigershark.X12.parse import Element
from tigershark.X12.parse import Properties

loop2000A = Loop(
    "2000A",
    Properties(
        desc="2000A",
        req_sit="R",
        repeat="1",
    ),
    Segment(
        "HL",
        Properties(qual=(3, "20"),
                   desc="Utilization Management Organization (UMO) Level",
                   req_sit="R",
                   repeat="1"),
        Element("HL03", Properties(position=3, codes=["20"]))),
    Loop(
        "2010A",
        Properties(
            desc="2010A",
            req_sit="R",
            repeat=">1",
        ),
        Segment(
            "NM1",
            Properties(qual=(1, "X3"),
                       desc="Utilization Management Organization (UMO) Name",
                       req_sit="R",
Exemplo n.º 7
0
#
# Generated by TigerShark.tools.convertPyX12 on 2012-07-10 16:29:58.460993
#
from tigershark.X12.parse import Message, Loop, Segment, Composite, Element, Properties
parsed_277_HEADER = Loop( u'HEADER', Properties(looptype=u'wrapper',repeat=u'1',pos=u'015',req_sit=u'R',desc=u'Table 1 - Header'),
Segment( u'BHT', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'020',desc=u'Beginning of Hierarchical Transaction'),
  Element( u'BHT01', Properties(desc=u'Hierarchical Structure Code', req_sit=u'R', data_type=(u'ID',u'4',u'4'), position=1,
    codes=[u'0010'] ) ),
  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'08'] ) ),
  Element( u'BHT03', Properties(desc=u'Reference Identification', req_sit=u'R', 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=[] ) ),
  Element( u'BHT05', Properties(desc=u'Time', req_sit=u'N', data_type=(u'TM',u'4',u'8'), position=5,
    codes=[] ) ),
  Element( u'BHT06', Properties(desc=u'Transaction Type Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=6,
    codes=[u'DG'] ) ),
),
)
parsed_277_2100A = Loop( u'2100A', Properties(looptype='',repeat=u'>1',pos=u'050',req_sit=u'R',desc=u'Payer Name'),
Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'050',desc=u'Payer Name'),
  Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1,
    codes=[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'2'] ) ),
  Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'R', data_type=(u'AN',u'1',u'60'), position=3,
    codes=[] ) ),
  Element( u'NM104', Properties(desc=u'Name First', req_sit=u'N', data_type=(u'AN',u'1',u'35'), position=4,
    codes=[] ) ),
  Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'N', data_type=(u'AN',u'1',u'25'), position=5,
Exemplo n.º 8
0
from tigershark.X12.parse import Composite
from tigershark.X12.parse import Element
from tigershark.X12.parse import Properties

parse_278 = Message( '278', Properties(desc='278'),
  Loop( 'ISA', Properties(req_sit='R',repeat='1',desc='ISA'),
    Segment( 'ISA', Properties(),
    Loop( 'GS', Properties(req_sit='R',repeat='1',desc='GS'),
      Segment( 'GS', Properties(),
      Loop( 'ST', Properties(req_sit='R',repeat='1',desc='ST'),
        Segment( 'ST', Properties(qual=(1, '278'),req_sit='R',repeat=1,desc='Transaction Set Header'),
        Segment( 'BHT', Properties(req_sit='R',repeat=1,desc='Beginning of Hierarchical Transaction'),
        Loop( '2000A', Properties(req_sit='R',repeat='1',desc='2000A'),
          Segment( 'HL', Properties(qual=(3, '20'),req_sit='R',repeat='1',desc='Utilization Management Organization (UMO) Level'),
          Loop( '2010A', Properties(req_sit='R',repeat='>1',desc='2010A'),
            Segment( 'NM1', Properties(qual=(1, 'X3'),req_sit='R',repeat='1',desc='Utilization Management Organization (UMO) Name'),
          ),
        ),
        Loop( '2000B', Properties(req_sit='R',repeat='1',desc='2000B'),
          Segment( 'HL', Properties(qual=(3, '21'),req_sit='R',repeat='1',desc='Requester Level'),
          Loop( '2010B', Properties(req_sit='R',repeat='>1',desc='2010B'),
            Segment( 'NM1', Properties(qual=(1, ('1P', 'FA')),req_sit='R',repeat='1',desc='Requester Name'),
            Segment( 'REF', Properties(req_sit='S',repeat='8',desc='Requester Supplemental Identification'),
            Segment( 'N3', Properties(req_sit='S',repeat='1',desc='Requester Address'),
            Segment( 'N4', Properties(req_sit='S',repeat='1',desc='Requester City/State/ZIP Code'),
            Segment( 'PER', Properties(req_sit='S',repeat='1',desc='Requester Contact Information'),
            Segment( 'PRV', Properties(req_sit='S',repeat='1',desc='Requester Provider Information'),
          ),
        ),
        Loop( '2000C', Properties(req_sit='R',repeat='1',desc='2000C'),
          Segment( 'HL', Properties(qual=(3, '22'),req_sit='R',repeat='1',desc='Subscriber Level'),
          Segment( 'DTP', Properties(req_sit='S',repeat=1,desc='Accident Date'),
Exemplo n.º 9
0
 Segment(
     u'N1',
     Properties(syntax=u'R0203 P0304',
                req_sit=u'S',
                repeat=u'1',
                pos=u'120',
                desc=u'Code List Source'),
     Element(
         u'N101',
         Properties(desc=u'Entity Identifier Code',
                    req_sit=u'R',
                    data_type=(u'ID', u'2', u'3'),
                    position=1,
                    codes=[u'0F'])),
     Element(
         u'N102',
         Properties(desc=u'Name',
                    req_sit=u'R',
                    data_type=(u'AN', u'1', u'60'),
                    position=2,
                    codes=[])),
     Element(
         u'N103',
         Properties(desc=u'Identification Code Qualifier',
                    req_sit=u'N',
                    data_type=(u'ID', u'1', u'2'),
                    position=3,
                    codes=[])),
     Element(
         u'N104',
         Properties(desc=u'Identification Code',
                    req_sit=u'N',
                    data_type=(u'AN', u'2', u'80'),
                    position=4,
                    codes=[])),
     Element(
         u'N105',
         Properties(desc=u'Entity Relationship Code',
                    req_sit=u'N',
                    data_type=(u'ID', u'2', u'2'),
                    position=5,
                    codes=[])),
     Element(
         u'N106',
         Properties(desc=u'Entity Identifier Code',
                    req_sit=u'N',
                    data_type=(u'ID', u'2', u'3'),
                    position=6,
                    codes=[])),
 ),