示例#1
0
    def testDjangoModel(self):
        dj = DjangoModelVisitor()
        parse_278.visit(dj)
        text = dj.getSource(appname="claims_837")
        # print( "***Manual Inspection" )
        # print( text )
        sample = '''\
from web.claims.models import X12Segment
from django.db import models

class Segment_ISA(models.Model):
    """Properties()"""
    segment = models.ForeignKey( X12Segment )
    def unmarshall( self, segmentToken, cs=':' ):

class Segment_GS(models.Model):
    """Properties()"""
    segment = models.ForeignKey( X12Segment )
    def unmarshall( self, segmentToken, cs=':' ):

class Segment_ST(models.Model):
    """Properties(qual=(1, '278'),req_sit='R',repeat='1',desc='Transaction Set Header')"""
    segment = models.ForeignKey( X12Segment )
    ST01 = models.CharField( max_length=16, null=True, blank=True ) # None None
    def unmarshall( self, segmentToken, cs=':' ):
        self.ST01 = segmentToken.elt(1)
'''
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#2
0
    def testDjangoModel(self):
        dj = DjangoModelVisitor()
        parse_278.visit(dj)
        text = dj.getSource(appname='claims_837')
        sample = '''\
from web.claims.models import X12Segment
from django.db import models

class Segment_ISA(models.Model):
    """Properties()"""
    segment = models.ForeignKey( X12Segment )
    def unmarshall( self, segmentToken, cs=':' ):

class Segment_GS(models.Model):
    """Properties()"""
    segment = models.ForeignKey( X12Segment )
    def unmarshall( self, segmentToken, cs=':' ):

class Segment_ST(models.Model):
    """Properties(qual=(1, '278'),req_sit='R',repeat='1',desc='Transaction Set Header')"""
    segment = models.ForeignKey( X12Segment )
    ST01 = models.CharField( max_length=16, null=True, blank=True ) # None None
    def unmarshall( self, segmentToken, cs=':' ):
        self.ST01 = segmentToken.elt(1)
'''
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#3
0
    def testPythonVisitor(self):
        python = PythonVisitor("parse_278")
        parse_278.visit(python)
        text = python.getSource()
        sample = """from tigershark.X12.parse import Message, Loop, Segment, Composite, Element, Properties
parse_278 = Message( '278', Properties(desc='HIPAA Health Care Services Review: Request X094A1-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'),
          Element( 'ST01', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=1,
            codes=['278'] ) ),
        ),
        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'),
            Element( 'HL03', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=3,
              codes=['20'] ) ),
          ),
          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'),
              Element( 'NM101', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=1,
                codes=['X3'] ) ),
            ),
          ),"""
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#4
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     # print( "***Manual Inspection" )
     # print( text )
     exec text
示例#5
0
    def testPythonVisitor( self ):
        python= PythonVisitor( "parse_278" )
        parse_278.visit( python )
        text= python.getSource()
        sample="""from tigershark.X12.parse import Message, Loop, Segment, Composite, Element, Properties
parse_278 = Message( '278', Properties(desc='HIPAA Health Care Services Review: Request X094A1-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'),
          Element( 'ST01', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=1,
            codes=['278'] ) ),
        ),
        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'),
            Element( 'HL03', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=3,
              codes=['20'] ) ),
          ),
          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'),
              Element( 'NM101', Properties(desc=None, req_sit=None, data_type=(None,None,None), position=1,
                codes=['X3'] ) ),
            ),
          ),"""
        tLines= text.splitlines()
        sLines= sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual( tLines[i].rstrip(), sLines[i].rstrip() )
示例#6
0
 def testPythonVisitorCompile( self ):
     python= FlatPythonVisitor( "parse_278" )
     parse_278.visit( python )
     text= python.getSource()
     #print( "***Manual Inspection" )
     #print( text )
     exec text
示例#7
0
 def testPythonVisitorWorks(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec(text)
     self.assertEqual(type(parse_278), Message)
     msg = parse_278.unmarshall(self.msg1)
     # XXX - check the resulting structure
     self.assertEqual(self.msg1, msg.marshall())
示例#8
0
 def testPythonVisitorWorks(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec text
     self.assertEqual(type(parse_278), Message)
     msg = parse_278.unmarshall(self.msg1)
     # XXX - check the resulting structure
     self.assertEquals(self.msg1, msg.marshall())
示例#9
0
 def test_PythonVisitor(self):
     python = PythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     with open('tests/278-sample.txt') as f:
         sample = f.read()
     tLines = text.splitlines()
     sLines = sample.splitlines()
     for i in range(len(sLines)):
         self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#10
0
 def test_PythonVisitor(self):
     python = PythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     with open('tests/278-sample.txt') as f:
         sample = f.read()
     tLines = text.splitlines()
     sLines = sample.splitlines()
     for i in range(len(sLines)):
         self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#11
0
    def testSQLVisitor(self):
        sql = SQLTableVisitor()
        parse_278.visit(sql)
        text = sql.getSource()
        # print( "***Manual Inspection" )
        # print( text )
        sample = """-- HIPAA Health Care Services Review: Request X094A1-278
CREATE TABLE X278_278(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    -- FK reference from X278_ISA -- ISA
    -- FK reference from X278_IEA -- IEA
    xtra CHAR(8) -- placeholder
) -- 278
;
-- ISA
CREATE TABLE X278_ISA(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    loop INTEGER NOT NULL REFERENCES X278_278(id),
    -- In-line Segment ISA None
    -- FK reference from X278_GS -- GS
    -- FK reference from X278_GE -- GE
    xtra CHAR(8) -- placeholder
) -- ISA
;
-- GS
CREATE TABLE X278_GS(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    loop INTEGER NOT NULL REFERENCES X278_ISA(id),
    -- In-line Segment GS None
    -- FK reference from X278_ST -- ST
    -- FK reference from X278_SE -- SE
    xtra CHAR(8) -- placeholder
) -- GS
;
"""
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#12
0
    def testSQLVisitor( self ):
        sql= SQLTableVisitor( )
        parse_278.visit( sql )
        text= sql.getSource()
        #print( "***Manual Inspection" )
        #print( text )
        sample="""-- HIPAA Health Care Services Review: Request X094A1-278
CREATE TABLE X278_278(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    -- FK reference from X278_ISA -- ISA
    -- FK reference from X278_IEA -- IEA
    xtra CHAR(8) -- placeholder
) -- 278
;
-- ISA
CREATE TABLE X278_ISA(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    loop INTEGER NOT NULL REFERENCES X278_278(id),
    -- In-line Segment ISA None
    -- FK reference from X278_GS -- GS
    -- FK reference from X278_GE -- GE
    xtra CHAR(8) -- placeholder
) -- ISA
;
-- GS
CREATE TABLE X278_GS(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    loop INTEGER NOT NULL REFERENCES X278_ISA(id),
    -- In-line Segment GS None
    -- FK reference from X278_ST -- ST
    -- FK reference from X278_SE -- SE
    xtra CHAR(8) -- placeholder
) -- GS
;
"""
        tLines= text.splitlines()
        sLines= sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual( tLines[i].rstrip(), sLines[i].rstrip() )
示例#13
0
    def testDjangoAdmin(self):
        dj = DjangoAdminVisitor()
        parse_278.visit(dj)
        text = dj.getSource(appname='claims_837')
        sample = '''\
from web.claims_837.models import NM1
admin.site.register( NM1 )
from web.claims_837.models import PER
admin.site.register( PER )
from web.claims_837.models import CRC
admin.site.register( CRC )
from web.claims_837.models import ST
admin.site.register( ST )
from web.claims_837.models import HL
admin.site.register( HL )
from web.claims_837.models import MSG
admin.site.register( MSG )
from web.claims_837.models import ISA
admin.site.register( ISA )
from web.claims_837.models import DTP
admin.site.register( DTP )
from web.claims_837.models import REF
admin.site.register( REF )
from web.claims_837.models import HSD
admin.site.register( HSD )
from web.claims_837.models import DMG
admin.site.register( DMG )
from web.claims_837.models import PRV
admin.site.register( PRV )
from web.claims_837.models import CL1
admin.site.register( CL1 )
from web.claims_837.models import GS
admin.site.register( GS )
from web.claims_837.models import TRN
admin.site.register( TRN )
from web.claims_837.models import GE
admin.site.register( GE )
from web.claims_837.models import IEA
admin.site.register( IEA )
from web.claims_837.models import N3
admin.site.register( N3 )
from web.claims_837.models import N4
admin.site.register( N4 )
from web.claims_837.models import CR2
admin.site.register( CR2 )
from web.claims_837.models import CR1
admin.site.register( CR1 )
from web.claims_837.models import CR6
admin.site.register( CR6 )
from web.claims_837.models import CR5
admin.site.register( CR5 )
from web.claims_837.models import INS
admin.site.register( INS )
from web.claims_837.models import UM
admin.site.register( UM )
from web.claims_837.models import HI
admin.site.register( HI )
from web.claims_837.models import BHT
admin.site.register( BHT )
from web.claims_837.models import SE
admin.site.register( SE )
'''
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#14
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec(text)
示例#15
0
    def testDjangoAdmin(self):
        dj = DjangoAdminVisitor()
        parse_278.visit(dj)
        text = dj.getSource(appname="claims_837")
        # print( "***Manual Inspection" )
        # print( text )
        sample = """\
from web.claims_837.models import NM1
admin.site.register( NM1 )
from web.claims_837.models import PER
admin.site.register( PER )
from web.claims_837.models import CRC
admin.site.register( CRC )
from web.claims_837.models import ST
admin.site.register( ST )
from web.claims_837.models import HL
admin.site.register( HL )
from web.claims_837.models import MSG
admin.site.register( MSG )
from web.claims_837.models import ISA
admin.site.register( ISA )
from web.claims_837.models import DTP
admin.site.register( DTP )
from web.claims_837.models import REF
admin.site.register( REF )
from web.claims_837.models import HSD
admin.site.register( HSD )
from web.claims_837.models import DMG
admin.site.register( DMG )
from web.claims_837.models import PRV
admin.site.register( PRV )
from web.claims_837.models import CL1
admin.site.register( CL1 )
from web.claims_837.models import GS
admin.site.register( GS )
from web.claims_837.models import TRN
admin.site.register( TRN )
from web.claims_837.models import GE
admin.site.register( GE )
from web.claims_837.models import IEA
admin.site.register( IEA )
from web.claims_837.models import N3
admin.site.register( N3 )
from web.claims_837.models import N4
admin.site.register( N4 )
from web.claims_837.models import CR2
admin.site.register( CR2 )
from web.claims_837.models import CR1
admin.site.register( CR1 )
from web.claims_837.models import CR6
admin.site.register( CR6 )
from web.claims_837.models import CR5
admin.site.register( CR5 )
from web.claims_837.models import INS
admin.site.register( INS )
from web.claims_837.models import UM
admin.site.register( UM )
from web.claims_837.models import HI
admin.site.register( HI )
from web.claims_837.models import BHT
admin.site.register( BHT )
from web.claims_837.models import SE
admin.site.register( SE )
"""
        tLines = text.splitlines()
        sLines = sample.splitlines()
        for i in range(len(sLines)):
            self.assertEqual(tLines[i].rstrip(), sLines[i].rstrip())
示例#16
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec text