Example #1
0
    def testPythonVisitor( self ):
        python= X12.map.source.PythonVisitor( "parse_278" )
        parse_278.visit( python )
        text= python.getSource()
        sample="""from 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() )
Example #2
0
    def testDjangoModel( self ):
        dj= X12.map.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() )
Example #3
0
 def testPythonVisitorCompile( self ):
     python= X12.map.source.FlatPythonVisitor( "parse_278" )
     parse_278.visit( python )
     text= python.getSource()
     #print( "***Manual Inspection" )
     #print( text )
     exec text
Example #4
0
 def testPythonVisitorWorks( self ):
     python= X12.map.source.FlatPythonVisitor( "parse_278" )
     parse_278.visit( python )
     text= python.getSource()
     exec text
     self.assertEqual( type(parse_278), X12.parse.Message )
     msg= parse_278.unmarshall( self.msg1 )
     # XXX - check the resulting structure
     self.assertEquals( self.msg1, msg.marshall() )
Example #5
0
    def testSQLVisitor( self ):
        sql= X12.map.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() )
Example #6
0
    def testDjangoAdmin( self ):
        dj= X12.map.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() )