Example SQL Script

Top  Previous  Next

When you use the Schema Engine to create your schema engine it generates ANSI SQL Scripts internally and executes them.  You can also generate these SQL scripts yourself (see Creating Tables).

 

Important Note: The SQL Scripts are provided for your reference only.  You should not attempt to manually create a schema yourself by generating the SQL scripts and then executing them in Access or by manually creating the table in Access following the SQL Script.  The Schema Engine, in addition to creating the tables will also populate some of the master tables with information needed for the schema processors to run correctly.

 

Click here to see an example of the SQL generated for the Master Tables of a schema with a prefix of V23

 

These are the master tables used by the schema engine

 

 DROP TABLE V23_HL7Data

 

GO

 

CREATE TABLE V23_HL7Data ( 

        MessageID Varchar(50) Not Null PRIMARY KEY

        VendorName Varchar(50) Not Null

        VendorVersion Varchar(25) Not Null

        MsgControl Varchar(50) Not Null

        PartnerAPP Varchar(60) Not Null

        DateLoaded DateTime, 

        LastLoaded DateTime, 

        LoadCount Int Default 1, 

        MsgType Varchar(20) Not Null

        MsgEvent Varchar(20) Null

        Outbound Int Not Null Default 0, 

        Inbound Int Not Null Default 0, 

        Processed Int Not Null Default 0, 

        Warnings Int Null Default 0, 

        Loaded Int Not Null Default 0, 

        SchemaLoaded Int Not Null Default 0, 

        StatusMessage Text Null

        ArchiveID Varchar(50) Null

        HL7Format Int Default 0, 

        SegmentCount Int Default 1, 

        MessageSize Int Default 0, 

        HL7Message Text Null )

 

GO

 

CREATE INDEX V23_HL7_AppControl ON V23_HL7Data (MsgControl,PartnerApp)

 

GO

 

DROP TABLE V23_MessageErrors

 

GO

 

CREATE TABLE V23_MessageErrors ( 

        MessageID Varchar(50) Not Null

        DateLoaded DateTime, 

        ErrorMessage Text Null )

 

GO

 

CREATE INDEX V23_MsgID ON V23_MessageErrors (MessageID)

 

GO

 

DROP TABLE V23_SchemaMaster

 

GO

 

CREATE TABLE V23_SchemaMaster ( 

        Schema_ID Varchar(50) Not Null PRIMARY KEY

        Schema_VendorID Varchar(50) Not Null,

        Maint_LastRun DateTime, 

        Created DateTime, 

        VendorDefinition Text Null )

 

GO

 

DROP TABLE V23_MessageManifest

 

GO

 

CREATE TABLE V23_MessageManifest (

        MessageID Varchar(50) Not Null,

        SegmentName Varchar(10) Not Null

        SegmentIDX int Not Null ) 

 

GO

 

CREATE UNIQUE INDEX V23_Manifest ON V23_MessageManifest (MessageID,SegmentIDX)

 

GO

 

DROP TABLE V23_SegmentTables

 

GO

 

CREATE TABLE V23_SegmentTables (

SegmentName Varchar(250) Not Null

TableName Varchar(250) Not Null

StartingField int Not Null, EndingField int Not Null, Description Text Null  ) 

 

GO

 

CREATE UNIQUE INDEX V23_SegmentTablesIDX ON V23_SegmentTables (SegmentName,TableName,StartingField)

 

GO

 

DROP TABLE V23_InterfaceTables

 

GO

 

CREATE TABLE V23_InterfaceTables (

SegmentName Varchar(10) Not Null PRIMARY KEY

TableNames Varchar(200) Not Null

Hl7FieldCount int Not Null, Description Text Null  ) 

 

GO

 

DROP TABLE V23_InterfaceFields

 

GO

 

CREATE TABLE V23_InterfaceFields (

Record_GUID Varchar(50) Not Null PRIMARY KEY,

SegmentName Varchar(10) Not Null

TableName   Varchar(50) Not Null

FieldNumber int Not Null, Components  int Not Null, Repeats     int Not Null, Description Text Null  ) 

 

GO

 

DROP TABLE V23_InterfaceComponents

 

GO

 

CREATE TABLE V23_InterfaceComponents (

Record_GUID Varchar(50) Not Null PRIMARY KEY,

SegmentName Varchar(10) Not Null

FieldNumber int Not Null, FieldName Char (30) Not Null

Component int Not Null, SubComponents int Not Null, Description Text Null  ) 

 

GO