Пример #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" ) )
Пример #2
0
class TestSegmentMatch(unittest.TestCase):
    """Test Segment match."""
    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" ) )
    def testQual( self ):
        self.assertTrue( self.parserQual.match( self.segments1[0] ) )
        self.assertFalse( self.parserQual.match( self.segments2[0] ) )
    def testNonQual( self ):
        self.assertTrue( self.parserNonQual.match( self.segments1[0] ))
        self.assertTrue( self.parserNonQual.match( self.segments2[0] ))
Пример #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
    """
    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
Пример #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
Пример #5
0
#!/usr/bin/env python
from X12.parse import Message, Loop, Segment, Composite, Element, 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'),
          Segment( 'DTP', Properties(req_sit='S',repeat=1,desc='Last Menstrual Period Date'),
Пример #6
0
#!/usr/bin/env python
# EXAMPLE IMPLEMENTATION - 278 Request Parser
from X12.parse import Message, Loop, Segment, Composite, Element, 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",
                       repeat="1"),