Overview
 Top Next

Our goal is to make HIPAA and X12 EDI development easy for everyone

A comprehensive .Net Library that fully supports all HIPAA 5010 and 4010 transaction sets

Features

· EDI Document Creation
· EDI File Parsing
· EDI Validation
· EDI File Scrubbing
· EDI File Joining
· EDI File Splitting
· EDI File and Data Loading
· EDI Rules Creation
· EDI Transmission
· EDI Data Correction
· EDI Data Viewer

We offer a very comprehensive EDI solution package that caters to the needs of each company.

There is a solution available from just creating general EDI files to parsing, validating, loading, joining, splitting, sending and receiving EDI files.


System Requirements
 Previous Top Next
RDPCrystal EDI Library has the following minimum system requirements:

· Microsoft Visual Studio .NET 2010
· Net 4.0 or higher
· At least 2 GB of RAM recommended


Purchase
Please visit us at www.rdpcrystal.com or contact us at sales@rdpcrystal.com for purchasing information.

Prices

Please do not distribute your application using the RDPCrystal EDI Library 30 day evaluation version. The component will inform you that the 30-day evaluation period has expired and contains a disabling component.


License
RDPCRYSTAL EDI LIBRARY
© Copyright 2017 Crystal Universe Software Inc.
All Rights Reserved.

SOFTWARE LICENSE AGREEMENT IMPORTANT—READ CAREFULLY BEFORE USING THIS PRODUCT. THIS IS A LEGALLY BINDING CONTRACT BETWEEN YOU, THE LICENSEE (“YOU” OR “LICENSEE”), AND CRYSTAL UNIVERSE SOFTWARE INC. THAT STATES THE TERMS AND CONDITIONS GOVERNING YOUR USE OF THIS SOFTWARE, INCLUDING SOFTWARE DOCUMENTATION, SUPPORTING UTILITY PROGRAMS, FILES, AS WELL AS BUG FIXES, MODIFICATIONS AND UPDATES PROVIDED BY CRYSTAL UNIVERSE SOFTWARE INC. TO LICENSEE (HEREINAFTER COLLECTIVELY “SOFTWARE”). CRYSTAL UNIVERSE SOFTWARE INC. IS WILLING TO LICENSE THE SOFTWARE ONLY IF YOU ACCEPT ALL OF THE TERMS AND CONDITIONS OF THIS SOFTWARE LICENSE AGREEMENT (“AGREEMENT”). BY CLICKING YOUR ACCEPTANCE BELOW, YOU AGREE TO BE BOUND LEGALLY BY THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE WITH THIS AGREEMENT, YOU MUST INDICATE BELOW THAT YOU DECLINE AND CONTACT CRYSTAL UNIVERSE SOFTWARE INC. WITHIN SEVEN (7) DAYS OF YOUR PURCHASE FOR A FULL REFUND OF LICENSE FEES YOU PAID FOR THE SOFTWARE. IF YOU DECLINE, YOU MAY NOT USE THE SOFTWARE UNDER ANY CONDITIONS. ANY USE OF THE SOFTWARE BY LICENSEE SHALL CONSTITUTE ACCEPTANCE OF THIS AGREEMENT.

1. Grant of License. Depending on the fees paid, CRYSTAL UNIVERSE SOFTWARE INC. grants Licensee one or more of the following licenses. All rights not expressly granted to you in this Agreement are reserved by CRYSTAL UNIVERSE SOFTWARE INC.

a. Evaluation License. If you have licensed the Software for evaluation purposes, CRYSTAL UNIVERSE SOFTWARE INC. grants a license to install and use the Software in executable form for a period of thirty (30) days solely for the purpose of evaluating the Software. Licensee understands and acknowledges that the Software licensed for evaluation purposes contains a disabling device that will automatically disable the Software thirty (30) days after installation.

b. Single User License. If you have licensed the Software under a single user license, CRYSTAL UNIVERSE SOFTWARE INC. grants to Licensee a personal, nonexclusive license to install and use the Software (i) in executable form only on a single computer at a time, which computer can be substituted at any time, provided that Licensee is the only one using the Software, (ii) for the sole purpose of designing, developing and testing application programs created by Licensee for Licensee’s own business, and (iii) as a component of any applications created by Licensee using the Software, provided such applications are used solely by Licensee, and not provided or licensed to any third parties. If Licensee is an entity, CRYSTAL UNIVERSE SOFTWARE INC. grants you the right to designate one individual within your entity (“Named User”), which Named User will have the rights to use the Software as described in this subsection.

c. Multi-User Site License. If you have licensed the Software under a multi-user site license, CRYSTAL UNIVERSE SOFTWARE INC. grants to Licensee, as an entity, a nonexclusive license to install and use the Software (i) in executable form on an unlimited number of computers at a single geographic location or site, (ii) for the sole purpose of designing, developing and testing application programs created by Licensee for Licensee’s own business, and (iii) as a component of any applications created by Licensee using the Software, provided such applications are used solely by Licensee, and not provided or licensed to any third parties.

d. Multi-User Enterprise License. If you have licensed the Software under a multi- user site license, CRYSTAL UNIVERSE SOFTWARE INC. grants to Licensee, as an entity, a nonexclusive license to install and use the Software (i) in executable form on an unlimited number of computers at multiple geographic locations or sites throughout Licensee’s enterprise, (ii) for the sole purpose of designing, developing and testing application programs created by Licensee for Licensee’s own business or for distribution to third parties, and (iii) as a component of any applications created by Licensee using the Software for distribution to third parties. License must restrict third party licensees of Licensee’s applications from further redistribution of any component of the Software in Licensee’s applications. Furthermore, Licensee may not distribute any application, program or file which includes, is created from, or otherwise incorporates portions of the Software, if such application, program or file is a general purpose development tool, library or component, or is otherwise generally competitive with or a substitute for the Software.

2. License Restrictions. The license provided by CRYSTAL UNIVERSE SOFTWARE INC. is a non-exclusive, non-transferable license, subject to the following restrictions. You may not, nor permit any party to: (i) use the Software for the benefit of any third party, including without limitation, in an outsourcing or timesharing arrangement, or in the operation of a service bureau; (ii) sell, lease, sublicense, distribute or otherwise transfer the Software to any person, firm, or entity; (iii) modify or prepare derivative works of the Software; or (iv) translate, decompile, disassemble or reverse engineer the Software. The Software includes significant elements, including its algorithms and logic, which CRYSTAL UNIVERSE SOFTWARE INC. has maintained as confidential and constitute trade secrets and confidential information of CRYSTAL UNIVERSE SOFTWARE INC. You agree to keep confidential and use your best efforts to prevent and protect the contents of the Software from unauthorized disclosure or use.

3. Proprietary Rights. This is a license agreement and NOT an agreement for sale. You acknowledge and agree that, as between you and CRYSTAL UNIVERSE SOFTWARE INC., the Software and all worldwide Intellectual Property Rights that are embodied in, related to, or represented by the Software, are the sole and exclusive property of Crystal. The term “Intellectual Property Rights” means the rights under patent, trademark, copyright and trade secret laws, and any other intellectual property or proprietary rights recognized in any jurisdiction worldwide, including moral and similar rights. You shall not delete, alter, cover or distort any copyright, trademark or other proprietary rights notices or identifying logos, icons or other markings placed by CRYSTAL UNIVERSE SOFTWARE INC. on or in the Software, web page, template or other output of the Software, and shall ensure that all such notices, logos, icons or other markings are reproduced on all copies of the Software or any web page, template or other output of the Software.

4. Disclaimer of Warranty. THE SOFTWARE IS FURNISHED TO LICENSEE “AS IS” WITHOUT ANY WARRANTY WHATSOEVER, INCLUDING WARRANTY OF TITLE OR PERFORMANCE. CRYSTAL UNIVERSE SOFTWARE INC. makes no representations or warranties that the operation of the Software will be uninterrupted or error free or that it will produce the results desired by Licensee. CRYSTAL UNIVERSE SOFTWARE INC. does not agree to provide any modifications, enhancements, improvements, corrections or bug fixes to the Software, even if errors in the Software are reported to Crystal. CRYSTAL UNIVERSE SOFTWARE INC. HEREBY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, TITLE, PERFORMANCE AND THE PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES.

5. Limitation of Liability. IN NO EVENT WILL CRYSTAL UNIVERSE SOFTWARE INC. BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS AND LOSS OF PRIVACY), UNDER CONTRACT, TORT OR ANY OTHER LEGAL THEORY OR CAUSE OF ACTION, EVEN IF CRYSTAL UNIVERSE SOFTWARE INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. CRYSTAL UNIVERSE SOFTWARE INC.’S ENTIRE LIABILITY TO YOU AND YOUR EXCLUSIVE REMEDY UNDER THIS AGREEMENT SHALL BE LIMITED TO THE LICENSE FEE PAID FOR THE SOFTWARE. NO ACTION OR CLAIM RELATING TO THIS AGREEMENT OR THE SOFTWARE MAY BE INSTITUTED MORE THAN ONE (1) YEAR AFTER THE EVENT GIVING RISE TO SUCH ACTION OR CLAIM.

6. Support and Maintenance. Technical support as well as software updates, upgrades and any new added components are provided free of charge for a period of (1) year beginning from the initial date of purchase of the Software. After this period has expired you can purchase a new subscription.

7. Term and Termination. The term of the license grant shall be perpetual. Notwithstanding the foregoing, CRYSTAL UNIVERSE SOFTWARE INC. may terminate this Agreement if you fail to comply with any terms and conditions. In such event, you must cease using the Software and destroy all copies, including components, of the Software. This Agreement shall automatically terminate upon your failure to comply with any of its terms or if you voluntarily terminate the Agreement, provided you notify CRYSTAL UNIVERSE SOFTWARE INC. and destroy all copies, including components, of the Software.

8. General

a. Export Restrictions. Licensee agrees that Licensee will not export or re-export the Software outside of the United States to any individual, business, third party, or other entity, or to any country subject to United States export restrictions. Furthermore, any Licensee who receives the Software outside the United States agrees not to re-export the Software except as permitted by laws of the United States. If you intend to export (or re-export), directly or indirectly, the Software or related technical data, it is your responsibility to assure compliance with U.S. and other applicable governmental export control laws and, if appropriate, to secure any required export licenses or approvals in your own name. You are also responsible for the accuracy and completeness of any information or certification you provide for purposes of export control compliance.

b. U.S. Government Rights. If you are obtaining Software on behalf of any part of the United States Government, the Software shall be deemed “commercial Software” and “commercial computer Software documentation,” respectively, pursuant to DFAR Section 227.7202 and FAR Section 12.212, as applicable. Any use, modification, reproduction, release, performance, display or disclosure of the Software shall be governed solely by the terms of this Agreement and shall be prohibited except to the extent expressly permitted by this Agreement.

c. Entire Agreement. This Agreement constitutes the entire agreement between you and CRYSTAL UNIVERSE SOFTWARE INC. relating to the Software and supersedes any prior purchase order, communications, advertising or representations concerning the Software.

d. Governing Law and Jurisdiction. This Agreement will be governed by the laws of the State of New York. Any legal action under this Agreement shall be brought in the state or federal courts in New York and Licensee consents to exclusive jurisdiction in New York. This Agreement will not be governed by the United Nations Convention on Contracts for the International Sale of Goods, the application of which is expressly excluded. If any part of this Agreement is found void or unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms.

e. Amendment. This Agreement may only be modified or amended in a writing referencing this Agreement and signed by an authorized agent of CRYSTAL UNIVERSE SOFTWARE INC. and of Licensee.

f. Agreement Read and Understood. You acknowledge that you have read and understand this Agreement and that by noting your acceptance below, you agree to be bound by its terms and conditions.


Installing License Key
Enter the license key for RDPCrystal EDI Library. This should be done before using any components of RDPCrystal EDI Library

Example

using RDPCrystalEDILibrary;

// Add the license key
RDPCrystalEDILibrary.PackageLicense.Key = "xxxxxxxx-xxxx-xx-xx-xxxx";


Technical Support
We strive to provide useful and timely technical support. If you have any technical support issues regarding RDPCrystal EDI Library please e-mail your support questions to support@rdpcrystal.com.

When requesting e-mail support please be sure to include any source code which may help us in answering your question. We will make every effort to answer your technical support questions in a timely manner.

Please contact our support team at support@rdpcrystal.com. We would also appreciate it if you also send us the following:

· A brief description of the issue
· The scrubbed EDI file you were working on if that’s possible.
· The exact version of RDPCrystal EDI Library
· The component name in the library
· Any relevant source code or files
· Please make sure that you remove any .exe files in your email attachments as they will not be accepted by our email system


Overview

EDIFileLoader provides a fast and easy way to parse and load any X12 or EDIFACT EDI file. It exhibits fast parsing speeds and offers the ability to load data from files or from in-memory strings. EDIFileLoader enables loaded EDI data to be accessed in an API-like fashion after loading. It does not require any rules files to parse and load EDI data. Unlike the EDIValidator component the resulting structure is flat with only one main loop that contains all segments in the file. EDIFileLoader loads EDI files quickly and efficiently giving developers the power to interpret the segment data however they desire.

Main Features

· EDI Parser
· Loads any EDI file (X12 and EDIFACT)
· Handles composite elements
· Fast parsing and loading speeds
· Creates an EDILightWeightDocument object after loading is completed for easy access to EDI data
· Option to load EDI data from the file system or in-memory strings
· Auto detection of segment, element and composite delimiters
· Loads EDI files without any rules files whatsoever
· Exposes an array containing all lines of the loaded EDI file
· Ability to convert EDI data to XML
· Extremely easy to use API


Auto Detection of Delimiters
EDIFileLoader has a Delimiter property that can be set if these delimiters are known beforehand. It also has a property called AutoDetectDelimiters. By enabling this property EDIFileLoader detects the special delimiter characters while loading is being performed. Parsing is then performed from this point as usual.

Example

// Create an instance of the EDIFileScrubber object
EDIFileLoader loader = new EDIFileLoader

loader.AutoDetectDelimiters  = true;


Load EDI Data From File

Load EDI data from a file
EDIFileLoader allows developers to load EDI files from the file system using the EDIFile property. EDIFileLoader will also find the necessary delimiters if set.

Example

// Create a new instance of EDIFileLoader
EDIFileLoader loader = new EDIFileLoader();

loader.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the load
loader.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are loading from an in-memory string or a file
loader.EDISource = EDISource.File; // Or EDISource.DataString

// Set the EDI file path to load
loader.EDIFile = "C:\\EDIFile.txt;

// load the data
EDILightWeightDocument loadedDocument = loader.Load();

Since there are no rules required EDIFileLoader only parses and loads all the segments in one loop. It does not group the segments into a loop hierarchy structure. In order to retrieve the segments just access the Loops property with index 0. The segments are of type LightWeightSegment. They contain their corresponding elements and composite elements.


Load EDI Data From String

Load EDI data from a string
EDIFileLoader allows developers to load EDI files from the file system using the EDIFile property as well as from a string of EDI data using the EDIDataString property. You can create an entire EDI string containing EDI data from your applications and pass it into the EDIFileLoader's EDIDataString property. Loading will continue as normal after calling the Load() method.

Example

// Create a new instance of EDIFileLoader
EDIFileLoader loader = new EDIFileLoader();

loader.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the load
loader.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are validating from an in- memory string or a file
loader = EDISource.DataString; // Or EDISource.File

// Set the EDI data to load
loader.EDIDataString = "SEG*12*122*~SEG2*7*2~";

// Load the data
EDILightWeightDocument loadedDocument = loader.Load();


Combining Transactions
EDIFileLoader allows developers to combine different ISA messages into folders. By default the EDI file structure is flat. However by setting the FlatStructure property to false ISA segments will be converted to top level folders

Example

// Create a new instance of EDIFileLoader
EDIFileLoader loader = new EDIFileLoader();

loader.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the load
loader.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are validating from an in- memory string or a file
loader = EDISource.DataString; // Or EDISource.File

// Set the EDI data to load
loader.EDIDataString = "......";

loader.FlatStructure = false;

// Load the data
EDILightWeightDocument loadedDocument = loader.Load();


Setting Delimiters
Example

loader.Delimiters.SegmentTerminatorCharacter = '^';
loader.Delimiters.ElementTerminatorCharacter = '*';
loader.Delimiters.CompositeTerminatorCharacter = ':';

For EDIFACT files the segment terminator character is usually the apostrophe character.

loader.Delimiters.SegmentTerminatorCharacter = '\'';
loader.Delimiters.ElementTerminatorCharacter = '^';


Accessing loaded EDI data
Developers can access all data from an EDI file that has been loaded with the EDIFileLoader using the EDILightWeightDocument returned after calling the Load() method. The EDILightWeightDocumentreturned enables access the EDI file. Because EDIFileLoader does not use any rules file, there is no validation on the EDI data. More importantly there is no proper hierarchy data conforming to the EDI implementation guides as you would find in the EDIValidator component. There is only one main loop containing all the parsed segments and elements that exist in the EDI file. This gives developers the flexibility to group this data however they please.

Example

// Create a new instance of EDIFileLoader
EDIFileLoader loader = new EDIFileLoader();

// Set the type of EDI file that you are about the load
loader.EDIFileType = FileType.X12;

// Set the source of EDI data, whether you are validating from an in- memory string or a file
validator.EDISource = EDISource.File; // Or EDISource.DataString

// Set the EDI file to load
loader.EDIFile = "C:\\EDIFile.txt";

// Load the file
EDILightWeightDocument doc = loader.Load();

// Get the main loop. This loop contains the entire EDI document
LightWeightLoop mainLoop = doc.Loop[0]; //the main loop

// Get all segments
Collection<LightWeightSegment> allSegments = mainLoop.Segments;


Ignoring Extra Formatting Characters
EDIFileLoader offers the ability to ignore certain strings that trail segments (X12). These extra characters are sometimes used for formatting an EDI file. For example, some companies may place a return character so that an EDI file may look a little better. While processing an EDI file these characters may cause a parser to fail. By setting the TrimString property of the EDIFileLoader these extra characters will be ignored

Example 1

// Ignore all return characters at the end of a segment
loader.TrimString = "\n";

Example 2

// Ignore all carriage returns characters at the end of a segment
loader.TrimString = "\r\n";


Getting Time Elapsed
Developers can check how long it takes to load an EDI file using the TimeElapsed property of the EDIFileLoader component. The TimeElapsed property will give the number of milliseconds it took to load the file.
There are two ways to get the elapsed time. One way is through the TimeElapsed property. The other way is to subscribe to the FileLoadingComplete event. It contains the Milliseconds property in its eventargs object.

Example 1

// Use the TimeElapsed property after loading
loader.TimeElapsed;

Example 2

loader. FileLoadingCompleted += new
EDIFileLoader.EDIFileLoadingCompletedEvent(loader_loadingCompleted);

private void loader_loadingCompleted (object sender,
FileLoadingEventArgs e)
{
MessageBox.Show(e.Milliseconds);
}


Overview

The EDIDocument component provides a fast and easy way to create EDI files. It follows an object oriented hierarchy schema that makes it easy to use and understand.

It enables developers to create any X12 EDI file quickly and easily. It’s as simple as creating a new EDIDocument and adding loops, segments and elements. There are many powerful built-in smart features that prevents malformed EDI files without compromising speed. From the simplest to the most complex file, let EDIDocument help you create well-formed EDI files the first time.

Main Features

· Create any X12 EDI file
· Pads or trims element data to meet minimum and maximum length requirements
· Automatically removes empty trailing data from elements and composite elements
· Generate files on the file system or in memory EDI strings
· Convert EDI data to XML
· Automatically keeps track of the number of data segments created for the SE segments in X12
· Automatically adds the numbers of ST transactions to the GE segments
· Automatically adds the numbers of GS functional headers to the IEA segments
· Fast EDI file generation
· Easy-to-use API
· Plus much more!


Creating an X12 EDI file
Creating an EDI document is easy with the EDIDocument component. Simply create an instance of the EDIDocument, set its loops, and call its GenerateFile() procedure. EDIDocument is based on a loop hierarchy. Loops contain segments and other loops. Segments contain elements. Elements contains data and composite elements. For EDIFACT documents loops are the same as segment groups.

Example

This example creates an EDIDocument instance, set its formation and call its GenerateFile() method. We will create a simple X12 EDI file with the following loop structure:

Implementation

// Instantiate an instance of EDIDocument and set the name of the file to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Place the correct counts of segment, headers and functional groups
sampleEDIFile.AutoPlaceCorrectNumOfSegments = true;
sampleEDIFile.AutoPlaceCorrectNumOfST = true;
sampleEDIFile.AutoPlaceCorrectNumOfGT = true;

// Create an interchange loop. This loop will contain all other loops in the EDI structure
Loop interchangeHeaderLoop = new Loop("Interchange Header");
// Create an ISA segment in the interchange loop
DataSegment isa = interchangeHeaderLoop.CreateSegment("ISA");

// Add elements with data to the ISA segment
isa.Elements.Add("00");
isa.Elements.Add("");
isa.Elements.Add("00");
isa.Elements.Add("");
isa.Elements.Add("ZZ");
isa.Elements.Add("InterchangeSenderID");
isa.Elements.Add("ZZ");
isa.Elements.Add("InterchangeReceiverID");
isa.Elements.Add("070303");
isa.Elements.Add("18:04");
isa.Elements.Add("U");
isa.Elements.Add("00401");
isa.Elements.Add("1");
isa.Elements.Add("1");
isa.Elements.Add("T");
isa.Elements.Add(":");

// Now create the function header loop
Loop functionalHeaderLoop = interchangeHeaderLoop.CreateLoop("Functional
Header Loop");

// Add a GS segment to it
DataSegment gs = functionalHeaderLoop.CreateSegment("GS");

// Set its elements and their values
gs.Elements.Add("HC");
gs.Elements.Add("ApplicationSenderCode");
gs.Elements.Add("ApplicationReceiverCode");
gs.Elements.Add("2005");
gs.Elements.Add("132334");
gs.Elements.Add("1");
gs.Elements.Add("X");
gs.Elements.Add("004010X098A1");

// Create a transaction header loop
Loop transactionLoop = functionalHeaderLoop.CreateLoop("Transaction
Header");

// Add an ST segment to the transaction header loop
DataSegment st =transactionLoop.CreateSegment("ST");

// Set its elements and their values
st.Elements.Add("837");
st.Elements.Add("1");

// Add an ST segment to the transaction header loop
DataSegment bht = transactionLoop.CreateSegment("BHT");
bht.Elements.Add("0019");
bht.Elements.Add("00");
bht.Elements.Add("1");
bht.Elements.Add("20070515");
bht.Elements.Add("094553");
bht.Elements.Add("CH");

// Create the end of the transaction (SE segment). This must be done in
a loop.
Loop endOfTransactionLoop = transactionLoop.CreateLoop("End Of
Transaction");
DataSegment se = endOfTransactionLoop.CreateSegment("SE");
se.Elements.Add(DataSegment.NumberCreated.ToString(), "Segment Count");
se.Elements.Add("1");

// Create the end of the functional group (GE segment). This must be
done in a loop.
Loop endOfFunctionalGroupLoop = functionalHeaderLoop.CreateLoop("End
Functional Group");
DataSegment ge = endOfFunctionalGroupLoop.CreateSegment("GE");
ge.Elements.Add("1");
ge.Elements.Add("1");

// Finally create the end of the interchange loop (IEA segment). This
must be done in a loop.
Loop endInterchangeLoop = interchangeHeaderLoop.CreateLoop("End
Interchange");
DataSegment iea = endInterchangeLoop.CreateSegment("IEA");
iea.Elements.Add("1");
iea.Elements.Add("1");

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();

Output File

ISA*00* *00* *ZZ*InterchangeSenderID*ZZ*InterchangeReceiverID*070303*18:04*U*00401*1*1*T*:~
GS*HC*ApplicationSenderCode*ApplicationReceiverCode*2005*132334*1*X*004010X098A1~
ST*837*1~
BHT*0019*00*1*20070515*094553*CH~
SE*3*1~
GE*1*1~
IEA*1*1~


Adding Loops
Creating an EDI document is easy with the EDIDocument component. Simply create an instance of the EDIDocument, set its loops, and call its GenerateFile() procedure. EDIDocument is based on a loop hierarchy. Loops contain segments and other loops. Segments contain elements. Elements contain data and composite elements.

Example

// Instantiate an instance of EDIDocument and set the name of the file
to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop(“Interchange Header”);

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();


Adding Fast Loops
Creating loops is necessary for creating any EDI file. RDP Crystal EDI Library enables you to create a loop very quickly and save a lot of type in the long run

Example

// Instantiate an instance of EDIDocument and set the name of the file
to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = "Interchange Header";  //NOTICE: The
"Interchange Header" loop is automatically constructed

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();


Adding Data Segments

Adding a Data Segment
Creating an EDI document is easy with the EDIDocument component. Simply create an instance of the EDIDocument, set its loops, and call its GenerateFile() procedure. EDIDocument is based on a loop hierarchy. Loops contain segments and other loops. Segments contain elements. Element contains data and composite elements.
Creating a data segment is very simple!

Example

// Instantiate an instance of EDIDocument and set the name of the file
to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop(“Interchange Header”);

// Create an ISA segment in the interchange loop
DataSegment isa = interchangeHeaderLoop.CreateSegment(“ISA”);

Now add elements with data to the ISA segment


Adding Fast Data Segments
Creating an EDI document is easy with the EDIDocument component. Simply create an instance of the EDIDocument, set its loops, and call its GenerateFile() procedure. EDIDocument is based on a loop hierarchy. Loops contain segments and other loops. Segments contain elements. Element contains data and composite elements.
Creating a data segment is very simple!

Example

// Instantiate an instance of EDIDocument and set the name of the file
to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop("Interchange Header");

// Create an ISA segment in the interchange loop
DataSegment isa = "ISA";   //Notice: The "ISA" string is automatically
converted to a loop

Now add elements with data to the ISA segment


Adding Data Elements
Creating data elements and adding them to a DataSegment is simple.

Example

// Instantiate an instance of EDIDocument and set the name of the file
to be created
EDIDocument sampleEDIFile = new EDIDocument("C:\\My837EDIFile.txt");

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop(“Interchange Header”);

// Create a Data Segment
DataSegment gs = interchangeHeaderLoop.CreateSegment(“GS”);

//Set its elements and their values
gs.Elements.Add("HC","ApplicationSenderCode","ApplicationReceiverCode","2005","132334","1","X","004010X098A1");

// Set its elements individually
gs.Elements.Add("HC");
gs.Elements.Add("ApplicationSenderCode");
gs.Elements.Add("ApplicationReceiverCode");
gs.Elements.Add("2005");
gs.Elements.Add("132334");
gs.Elements.Add("1");
gs.Elements.Add("X");
gs.Elements.Add(“004010X098A1”);


Adding Composite Elements
Composite data elements are data elements that can contain other data elements. A DataSegment contains DataElements. DataElements contains data values and well as other DataElements. A DataElement that contains other DataElements is a composite data element. Creating a composite data element is very simple.

Creating a regular element and adding it to a segment

Example

// Create a new Data Segment that will hold the data element
DataSegment segSegment = new DataSegment("SEG");
segSegment.Elements.Add("A Value");

or

DataElement regularElement = new DataElement("A Value");
segSegment.Elements.Add(regularElement);

Creating a composite element and adding it to a segment

Example

DataSegment segSegment = new DataSegment("SEG");

// Create a Data Element and set its composite property to true
DataElement compositeElement = new DataElement();
compositeElement.Composite = true;

// Add elements to the composite element
compositeElement.Elements.Add("Composite Value 1");
compositeElement.Elements.Add("Composite Value 2");
compositeElement.Elements.Add("Composite Value 3");
compositeElement.Elements.Add("Composite Value 4");
compositeElement.Elements.Add("Composite Value 5");
compositeElement.Elements.Add("Composite Value 6");
compositeElement.Elements.Add("Composite Value 7");
segSegment.Elements.Add(compositeElement);


Viewing EDI Tree
EDIDocumentViewer allows you to either display data from an EDILightWeightDocument or an EDIDocument. Nodes in the visual tree are only created when they are needed to reduced the memory footprint and increase the overall performance of your application. Conversely nodes are removed from memory when they are expanded.
The example below assumes that you have already created an instance of the EDIDocumentViewer and added it to your form.

Example

EDIDocument sampleEDIFile = new EDIDocument(“C:\\EDIDoc.txt”);

//..Create your EDI documents loops, segments an elements here

// Load the data into the EDIDocumentViewer.
ediDocumentViewer1.LoadDocument(sampleEDIFile);

Your EDIDocument will now be displayed in a visual tree. You can now expand and collapse loops, segments and composite elements and see the data in your EDI document.


Setting Delimiters
Example

document.Delimiters.SegmentTerminatorCharacter = '^';
document.Delimiters.ElementTerminatorCharacter = '*';
document.Delimiters.CompositeTerminatorCharacter = ':';

For EDIFACT files the segment terminator character is usually the apostrophe character.

document.Delimiters.SegmentTerminatorCharacter = '\'';
document.Delimiters.ElementTerminatorCharacter = '^';


Setting Segment Count In The SE Segment

Setting the correct number of segment in the SE segment
In X12 EDI specifications the SE segment requires that you enter the correct number of segments in the transaction. This can be very tedious since at runtime it is hard to find out exactly how many segments they are in a given transaction. EDIDocument enables you to correctly enter this value in the SE, GE and IEA segments

Example

EDIDocument doc = new EDIDocument();

doc.AutoPlaceCorrectNumOfSegments = true;
doc.AutoPlaceCorrectNumOfST = true;
doc.AutoPlaceCorrectNumOfGT = true;


Converting to XML
After creating an EDI document using EDIDocument and settings its loop, segments and elements you can convert it to XML by calling the ToXML() method. Additionally if you want to get a string respresentation of the XML data you can use the EDIXMLFileString property of EDIDocument. The length of the string is restricted by the size of the string data type. Under most circumstances the string will hold the entire EDI file.

Example

EDIDocument ediFile = New EDIDocument();

// Create loops, segment and elements here

ediFile.ToXML(" C:\\EDI_XML_File.xml ");

MessageBox.Show(ediFile.EDIXMLFileString);
.


Getting String Version Of EDI file

Getting a String Version of the EDI file
After calling the GenerateFile() method to create an EDI file you can get a string containing the EDI file. This feature should not be used when generating very large EDI files. The length of the string is restricted by the size of the string data type. Under most circumstances the string will hold the entire EDI file.

Example

EDIDocument ediDocument = new EDIDocument();

// Generate the EDI file
ediDocument.GenerateFile();

// Display the EDI file just created using the EDIFileString
MessageBox.Show(ediDocument.EDIFileString);
You don’t need to actually generate an EDI file on the file system to actually get EDI data. Instead you can call the GenerateEDIData() method of the EDIDocument. This method returns a string containing the newly created EDI file data as a string.


Setting File Buffer Size For Performance

Setting the File Buffer Size for performance
Generating EDI files can consume a lot of memory and effect performance. One way to improve the speed when generating EDI files is to specify an approximate length (in terms of the amount of characters). The internal buffers will not need to recreate itself with more space. By default the FileBufferSize is set to 2000 characters. This number should be changed if you plan to generate an EDI file larger than 2000 characters (which is most likely the case).

Example

// Instantiate an instance of EDIDocument and set filepath
EDIDocument sampleEDIFile = new EDIDocument(“C:\\edi.txt”);

// Set the file buffer size
sampleEDIFile.FileBufferSize = 2000000;
// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop("Interchange Header");

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();


Setting the output file
Creating an EDI document is easy with the EDIDocument component. The EDIDocument component contains a constructor that accepts a path to a file to create. EDIDocument will create the file when generating EDI content.

Example

// Instantiate an instance of EDIDocument and set the filestream parameter
EDIDocument sampleEDIFile = new EDIDocument("C:\\edi.txt");
// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop("Interchange Header");

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();

You can also set the EDIFilePath property of EDIDocument before calling the GenerateEDIFile() method.


Setting the output file stream
Creating an EDI document is easy with the EDIDocument component. The EDIDocument component contains a constructor that accepts a FileStream object Initializing a FileStream object and passing it to the EDIDocument constructor will cause any EDI document generated to be written to that specific stream.

Example

// Create a filestream object
FileStream myStream = new StreamWriter("C:\\edi.txt");

// Instantiate an instance of EDIDocument and set the filestream
parameter
EDIDocument sampleEDIFile = new EDIDocument(myStream);

// Create an interchange loop. This loop will contain all other loops in
the EDI structure
Loop interchangeHeaderLoop = new Loop("Interchange Header");

// Add the interchange loop to the EDI document
sampleEDIFile.Loops.Add(interchangeHeaderLoop);

// Generate the EDI file
sampleEDIFile.GenerateEDIFile();

You can also explicitly set the FileStream property of EDIDocument.


EDIDocumentFinished Event
After creating an EDI document using EDIDocument it is sometimes useful to check when exactly the document creation process is finished. EDIDocument has the EDIDocumentFinished event that is fired when a file has been created.

Example

// Subscribe to the EDIDocumentFinished Event
ediDocument.EDIDocumentFinished += new
EDIDocument.GeneralEvent(ediDocument_EDIDocumentFinished);

// Handle event
void ediDocument_EDIDocumentFinished(object sender)
{
MessageBox.Show("EDI file creation complete!");
}


Auto Trimming Data Elements
Set the AutoTrimElements property of the EDIDocument

Example

EDIDocument doc = new EDIDocument();
doc.AutoTrimElements = true;


Removing Empty Data Elements And Composite Data Elements

Removing Empty Elements and Empty Composite Elements
It is good practice when creating EDI files not to leave trailing empty data elements and composite data elements. EDI Documents does this for you automatically.

For example, a segment like the following is incorrect:

SEG*1*2*5****~

EDI document removes trailing empty data elements and composite data elements. The above segment would be converted to the following:

SEG*1*2*5~

You can turn this off/on if desired. We recommend that you leave these settings to their default values

Example

ediDocument.TruncateEmptyElements = true;
ediDocument.TruncateEmptyCompositeElements = true;


Setting Minimum and Maximum Lengths
Creating well-formed EDI documents can mean the difference in an EDI file being accepted or rejected by EDI receivers. EDIDocument helps to make sure that you create well-formed EDI documents.

It is always good to keep the value in an elements between its minimum and maximum allowable lengths. EDIDocument will do this for you.

To enable this create a DataElement object using the DataElement(string elementValue, int min, int max) constructor

Example

DataElement element = new DataElement("A Value",1,3);
segment.Elements.Add(element);

or when you add an element to a segment use its overloaded Add method

segment.Elements.Add("A Value",1,3);

Now when creating an EDI file EDIDocument will make sure that the element value conforms to it minimum and maximum requirements by trimming or padding it.


Overview

EDILightWeightDocument is a component that provides a fast and easy way to create EDI files. EDILightWeightDocument follows an object oriented hierarchy schema that makes it easy to use and understand.

EDILightWeightDocument enables developers to create any EDI file (X12 and EDIFACT) fast and easily. It’s as simple as creating a new EDILightWeightDocument object and adding loops, segments and data elements to it. Developers will experience how powerful EDILightWeightDocument is with their first use. EDI file creation is very fast, just call the GenerateFile() method and you’re all done.

Main Features

· Create X12 and EDIFACT EDI files
· Easy to use API
· View entire EDI document in a tree
· Fast EDI file generation
· Extremely memory efficient

Difference between EDIDocument and EDILightWeightDocument

· EDILightWeightDocument is much more memory efficient. It only creates objects when it needs to, resulting in less memory usage. This is useful when loading large EDI files.
· EDILightWeightDocument does not have smart features like auto trim of elements, element padding and removal of empty trailing elements.
· EDILightWeightDocument is a bit faster at generating EDI files since it does not contain any smart features.
· Other than the above differences EDILightWeightDocument can be used in the same manner as EDIDocument


Setting the Repeating Character
You can set the repeating character for the EDI File. The repeating character was introduced by the X12 EDI format and used in version 5010 of the implementation guides. By default this value is '^'

Example

ediDocument.Delimiters.RepetitionCharacter = '^';

The repeating character will be used for both repeating elements and repeating composite elements. For example,

DMG*D8*19780302*M*M*:RET:2135-2^:RET:2079-2~
DMG*D8^D8^D8*19780302*M~

EDIDocument does not support repeating elements


Adding Repeating Elements
A LightWeightElement can have repeating elements

Example

LightWeightElement element = new LightWeightElement("Val1");
element.RepeatingElementsValues.Add("Repeating Val1");
element.RepeatingElementsValues.Add("Repeating Val2");

In order for the repeating values to be delimited correctly please set RepetitionCharacter to the desired character.


Adding Composite Repeating Elements
A composite LightWeightElement can have repeating composite elements.

Example

// Create a composite element
LightWeightElement compositeElement = new LightWeightElement(true);
compositeElement.Elements.Add(new LightWeightElement("Composite Element"));
compositeElement.Elements.Add(new LightWeightElement("Composite Element"));
compositeElement.Elements.Add(new LightWeightElement("Composite Element"));

// Add the first repeating composite element
compositeElement.RepeatingCompositeElements.Add(new LightWeightElements());

compositeElement.RepeatingCompositeElements[0].Add(new LightWeightElement("Composite Element 1"));
compositeElement.RepeatingCompositeElements[0].Add(new LightWeightElement("Composite Element 1"));
compositeElement.RepeatingCompositeElements[0].Add(new LightWeightElement("Composite Element 1"));
compositeElement.RepeatingCompositeElements[0].Add(new LightWeightElement("Composite Element 1"));

// Add the second repeating composite element
compositeElement.RepeatingCompositeElements.Add(new LightWeightElements());

compositeElement.RepeatingCompositeElements[1].Add(new LightWeightElement("Composite Element 2"));
compositeElement.RepeatingCompositeElements[1].Add(new LightWeightElement("Composite Element 2"));
compositeElement.RepeatingCompositeElements[1].Add(new LightWeightElement("Composite Element 2"));
compositeElement.RepeatingCompositeElements[1].Add(new LightWeightElement("Composite Element 2"));

In order for the repeating values to be delimited correctly please set RepetitionCharacter to the desired character.


Overview

The EDIValidator component provides a fast and easy way to both validate and load EDI files. It exhibits both fast parsing and fast validation speeds.

EDIValidator validates and loads data into a convenient object

· Display validated EDI data to clients, save it to a database, use it to create custom applications.
· Modify existing EDI documents in memory and then output them to a file
· Works hand-in-hand with EDI Rules File for superior validation

Main Features

· Validates all 7 SNIP levels
· Ability to add custom rules
· Displays the exact line of errors and warnings
· Validates loop, segment and element usage
· Supports both internal and external code lists like CPT, ICD, NDC, CAS, zip codes, states, countries, etc. for superior validation
· Validates element lengths constraints
· Validates element relationship constraints
· Advanced pattern matching with Regular Expressions for superior validation
· Validates Out-Of-Order segments
· Handles Repeating Elements and Repeating Composite Elements
· Validate EDI data from files or strings
· Support custom validation rules
· Access loaded EDI data like an API after validation
· Creates an EDI Document after validation
· Auto Detection of delimiters
· Highly Configurable!
· Easy to use API
· Plus much more


Setting Delimiters
Example

validator.loader.Delimiters.SegmentTerminatorCharacter = '^';
validator.Delimiters.ElementTerminatorCharacter = '*';
validator.Delimiters.CompositeTerminatorCharacter = ':';

For EDIFACT files the segment terminator character is usually the apostrophe character.

validator.Delimiters.SegmentTerminatorCharacter = '\'';
validator.Delimiters.ElementTerminatorCharacter = '^';


Validating EDI Files
Validating EDI files is extremely simple. Just set a few properties and you're ready to go.

Example

// Create an instance of the EDIValidator object
EDIValidator validator = new EDIValidator();

validator.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the validate
validator.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are validating from an in- memory string or a file
validator.EDISource = EDISource.File; // Or EDISource.DataString

// Set the EDI rules file
validator.EDIRulesFile = "C: \\EDIFile.Rules ";

// Set the EDI file to validate
validator.EDIFile = " C:\\EDIFile.txt ";

// Validate
validator.Validate();

// Check if the EDI file passed
if (validator.Passed)
{
Console.WriteLine("Passed");

//Get the EDI file just parsed
EDILightWeightDocument file = validator.EDILightWeightDocument;
}
else
{
// Display all errors
foreach (EDIError error in ediValidator.Errors)
{
Console.WriteLine(error.LineNumber.ToString() + " " + error.Loop +
" " + error.Segment + " " + error.Message.ToString());
}

}

If you just want to validate the EDI file and not load it just set the LoadValidatedData property to false. In this case EDILightWeightDocument will be null after validation.

Prior to RDPCrystal EDI Library 4.0 a ValidationException could have been thrown if an unexpected exception occurred. Currently if an unexpected error occurs an Error object is created and returned in the Errors collection. In this case an EDIValidationMessage type of UnexpectedError or MalformedEDIFile is returned in the Error object. An exception will be thrown if the file to validate is not found or the rules file to use is not found.

Segment must also appear in the same order as they are mentioned in the implementation guide.


Validating EDI Files 2
Validating EDI documents is extremely simple. Just set a few properties and you're ready to go.

Example

// Create an instance of the EDIDocument object
EDIDocument ediDocument = new EDIDocument();
…
// Create your EDI Document here, adding loops segments, data elements etc.
…
// Create an instance of the EDIValidator object
EDIValidator validator = new EDIValidator();

// Set the type of EDI file that you are about the validate
validator.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the EDI rules file
validator.EDIRulesFile = "C:\\EDIFile.Rules";

// Validate the EDI Document
validator.Validate(ediDocument);

// Check if the EDI file passed
if (validator.Passed)
{
Console.WriteLine("Passed");

// Get the EDI file just parsed
EDILightWeightDocument file = validator.EDILightWeightDocument;
}
else
{
// Display all errors
foreach (EDIError error in ediValidator.Errors)
{
Console.WriteLine(error.LineNumber.ToString() + " " + error.Loop +
" " + error.Segment + " " + error.Message.ToString());
}
}

You can also validate an EDILightWeightDocument using this method. If you just want to validate the EDI file and not load it just set the LoadValidatedData property to false. In this case EDIDocument property of EDIValidator will be null after validation.

Prior to RDPCrystal EDI Library 4.0 a ValidationException could have been thrown if an unexpected exception occurred. Currently if an unexpected error occurs an Error object is created and returned in the Errors collection. In this case an EDIValidationMessage type of UnexpectedError or MalformedEDIFile is returned in the Error object. An exception will be thrown if the file to validate is not found or the rules file to use is not found.


Validating Strings
EDIValidator allows you to validate EDI files from your file system using the EDIFile property as well as from a string of EDI text using the EDIDataString property. You can create an entire EDI string containing EDI data from your applications and pass it into the EDIValidator's EDIDataString property. Validation will continue as normal after calling the Validate() method.

Example

// Create a new instance of EDIValidator
EDIValidator validator = new EDIValidator();

// Set the type of EDI file that you are about the validate
validator.EDIFileType = FileType.X12;  //Or FileType.EDIFACT
// Set the source of EDI data, whether you are validating from an in- memory string or a file
validator.EDISource = EDISource.DataString; // Or EDISource.File

// Set the EDI rules file
validator.EDIRulesFile = "C:\\EDIFile.Rules";

// Set the EDI file to validate
validator.EDIDataString= "SEG*12*122*~SEG2*7*2~";

// Validate
validator.Validate();


Accessing Validated EDI Data
You can access ALL data from an EDI file that has been validated. The LoadValidatedData property must be set to true first.

Example

// Create a new instance of EDIValidator
EDIValidator validator = new EDIValidator();

// Set the type of EDI file that you are about the validate
validator.EDIFileType = FileType.X12;

// Set the EDI rules file
validator.EDIRulesFile = "C:\\EDIRulesFile.Rules";

// Set the EDI file to validate
validator.EDIFile = "C:\\EDIFile.txt";

// Validate
ediValidator.Validate();

// The EDI Document will contain all the data of the file
EDILightWeightDocument doc = ediValidator.EDILightWeightDocument;

LightWeightLoop interchangeHeaderLoop = doc.Loops[0].GetLoop("INTERCHANGE HEADER");


Auto Detection of Delimiters
EDIValidator has a Delimiter property that can be set if these delimiters are known beforehand. It also has a property called AutoDetectDelimiters. By enabling this property EDIValidator detects the special delimiter characters while validation is being performed. Validation and parsing is then performed from this point as usual.

Example

// Create an instance of the EDIValidator object
EDIValidator validator = new EDIValidator();

// Set the AutoDetectDelimiters property
validator.AutoDetectDelimiters = true;


Checking If EDI File Passed Validation

Checking if an EDI file has passed validation
You can check whether an EDI file passed validation by the EDIValidator through the Passed property

Example

// Create a new instance of EDIValidator
EDIValidator validator = new EDIValidator();

// Set the type of EDI file that you are about the validate
validator.EDIFileType = FileType.X12;

// Set the source of EDI data, whether you are validating from an in- memory string or a file
validator.EDISource = EDISource.File // Or EDISource.DataString

// Set the EDI rules file
validator.EDIRulesFile= "C:\\EDIFile.Rules";

// Set the EDI file to validate
validator.EDIFile = "C:\\EDIFile.txt";

// Validate
validator.Validate();

if (validator.Passed)
{
   // passed
}


Validation Complete Event
EDIValidator exposes the ValidationCompleted event. This event will fire when the validation of an EDI file has completed.

Example

// Subscribe to the ValidationCompleted event
validator.ValidationCompleted += new
EDIValidator.ValidationCompletedEvent(ValidationCompleted);

void ValidationCompleted(object sender, ValidationEventsArgs e)
{
Console.WriteLine("Validation Complete");
}


Setting Type Of EDI File To Validate

Setting the type of EDI file to be validated
EDIValidator can validate both the X12 and EDIFACT EDI files. It is important to tell EDIValidator what type of EDI file you want to validate. By default EDIValidator is set to validate X12 EDI files. You can change this using the FileType property of EDIValidator.

Example

ediValidator.EDIFileType = FileType.EDIFACT;


Getting Validation Warnings

Getting the validation warnings
You can get validation warnings from an EDI file using the Warnings property of EDIValidator. Access the Warnings property of the EDIValidator after calling the Validate method.

Example

Collection<EDIWarning>warnings = validator.Warnings;

foreach (EDIWarning warning in warnings)
{
 //Process or display warning here
 //error.LineNumber;
 //error.Loop;
 //error.Segment;
 //error.ElementOrdinal;
 //error.CompositeElementOrdinal;
 //error.Message;
//error.Description;
}

In addition the EDIWarning object also contains the corresponding SNIP level for the warning. This level can be accessed through the SnipLevel enum property.

The possible SNIP levels are:

· Integrity-Testing for valid EDI syntax for each type of transaction
· Requirement- Testing for HIPAA specific syntax. This tests that the transaction sets adhere to the HIPAA implementation guides
· Balance - Testing of the transaction for balanced field totals, financial balancing of claims or remittance advice and balancing of summary fields.
· Situational - Testing of specific inter-segment situations as defined in the implementation guide, where if A occurs, then B must be populated
· CodeSet - Testing correct use of external code sets. Tests that only valid values of external data elements are used
· DoesNotApply – The warning does not have a corresponding SNIP level.


Getting Validation Errors

Getting the validation errors
You can get validation errors from an EDI file using the Errors property of EDIValidator. Access the Errors property of the EDIValidator after calling the Validate method.

Example

Collection<EDIError>errors = validator.Errors;

foreach (EDIError error in errors)
{
   //Process or display errors here
 //error.LineNumber;
 //error.Loop;
 //error.Segment;
 //error.ElementOrdinal;
 //error.CompositeElementOrdinal;
 //error.Message;
//error.Description;
}

In addition the EDIWarning object also contains the corresponding SNIP level for the warning. This level can be accessed through the SnipLevel enum property.

The possible SNIP levels are:

· Integrity-Testing for valid EDI syntax for each type of transaction
· Requirement- Testing for HIPAA specific syntax. This tests that the transaction sets adhere to the HIPAA implementation guides
· Balance - Testing of the transaction for balanced field totals, financial balancing of claims or remittance advice and balancing of summary fields.
· Situational - Testing of specific inter-segment situations as defined in the implementation guide, where if A occurs, then B must be populated
· CodeSet - Testing correct use of external code sets. Tests that only valid values of external data elements are used
· DoesNotApply - The warning does not have a corresponding SNIP level


Ignoring Extra Formatting Characters
RDPCrystal EDI Library offers the ability to ignore certain strings that trail segments (X12). These extra characters are sometimes used for formatting an EDI file. For example, some companies may place a return character so that an EDI file may look a little better. While processing an EDI file these characters may cause a parser to fail.
By setting the TrimString property of the EDIValidator these extra characters will be ignored

Example 1

// Ignore all return characters at the end of a segment
ediValidator.TrimString = "\n";

Example 2
// Ignore all carriage returns characters at the end of a segment
ediValidator.TrimString = "\r\n";


Getting Raw EDI Data After Validation

Getting the raw EDI data after validation
EDIValidator allows you to retrieve the raw EDI file data after validation. The raw EDI data is placed in an array. Each index represents one line from the EDI file. EDIValidator has this data available through the EDIFileLines property. This value will only be populated when the EDISource is EDISource.DataString.

Example

EDIValidator ediValidator = new EDIValidator();

...
...

// Validate an EDI file
ediValidator.Validate();

// Retrieve the raw EDI data
foreach(string ediLine in ediValidator.EDIFileLines)
{
   MessageBox.Show(ediLine);
}


Setting the Release Character
The release character is only used while validating EDIFACT documents. Setting the release character enables correct segment parsing for EDIFACT files. If the release character is not set properly then validation errors will occur. You can set the release character for the EDI file by setting the ReleaseCharacter property of the EDIValidator. By default this value is '?'.

Example

ediValidator.Delimiters.ReleaseCharacter = '?';

Release characters are only used in EDIFACT file validation.


Getting Time Elapsed
You can check how long it takes to validate an EDI file using the TimeElapsed property of the EDIValidator. The TimeElapsed property will give the number of milliseconds it took to validate the file. The first time the EDIValidator is used it will take a few more milliseconds because aside from validating the EDI file, the EDIValidator has to load the EDI rules. After the EDI rules are loaded it will take significantly less time to validate an EDI file.
There are two ways to get the elapsed time. One way is through the TimeElapsed property. The other way is to subscribe to the ValidationComplete event args. It contains the Milliseconds property in its event args object.

Example 1

// Use the TimeElapsed property after validating the EDI file
ediValidator.TimeElapsed;

Example 2

ediValidator.ValidationCompleted += new EDIValidator.ValidationCompletedEvent(ediValidator_ValidationCompleted);
void ediValidator_ValidationCompleted(object sender,
ValidationEventsArgs e)
{
MessageBox.Show(e.Milliseconds);
}


Getting Validation Progress
EDIValidator exposes the ProgressChanged event. This represents the progress while validating X12 EDI files. The ProgressChanged event will not fire for EDIFACT EDI files.

Example

validator.ProgressChanged += new EDIValidator.GeneralEvent(validator_ProgressChanged);

void validator_ProgressChanged(int progress)
{
   Console.WriteLine(progress.ToString());
}


Checking for trailing empty elements
Some EDI files are considered incorrect if they contain trailing empty data elements or trailing empty composite data elements. EDIValidator automatically checks for this occurrence and a validation error is generated if empty trailing data elements are found.

An example of a trailing empty data element is:

SEG*1*2**~

This segment should have been written as:

SEG*1*2~

The EDIDocument component automatically removes trailing empty data elements when creating EDI documents

Example

ediValidator.CheckForEmptyTrailingElements = true;


Checking Element Lengths
EDIValidator automatically checks every data element to see if it conforms to its minimum and maximum length requirements. If a data element's data value does not fit these requirements a validation error will be logged. You have the option of turning this checking off for debugging purposes.

Example

// Create a new instance of EDIValidator
EDIValidator validator = new EDIValidator();

// Turn off element length checking
ediValidator.CheckMinMaxRequirements = false;


Malformed EDI Files
EDIValidator possesses a very complex validation engine that enables it to load and validate EDI files. During the validation process EDIValidator may encounter many warnings and errors. It stores these messages in its Errors and Warnings collections. When validating large EDI files these collections can grow considerably. EDI files with a considerably large amount of errors or warnings may lead to an OutOfMemoryException being thrown. To prevent this situation from occurring developers can set the MaxErrorsBeforeThrowingException property to the maximum number of errors or warnings that EDIValidator encounters before throwing an exception. This will prevent the memory issues.

Example

validator.MaxErrorsBeforeThrowingException = 50000;


Overview

EDIFileSplitter provides a fast and easy way to split large EDI files into smaller ones quickly and efficiently. It exhibits fast reading and writing speeds and offers the ability to split EDI files at the Envelope Level (ISA), the Functional Group Level (GS) or the Header Level (ST).

Main Features

· Ability to split multiple X12 EDI files into many EDI files
· Ability to split X12 files at the envelope level (ISA), functional group level (GS) or the header level (ST)
· Ability to specify how many headers or functional groups to place in each split file
· Keeps track and inserts the correct number of ST and GS segments in respective loops
· Fast reading and writing speeds
· Asynchronous file read and write operations
· Buffered write operations to decrease IO calls
· Memory efficient
· Ability to specify the size of read and write buffers for less IO operations
· Easy to use API


Splitting Files
EDIFileSplitter is capable of splitting an X12 EDI files into many smaller files. The splitting operation is asynchronous by nature allowing program flow to continue. The resulting files will be placed in the directory specified.
Developers can split file at the envelope level (ISA), the functional group level (GS) , or the header level (ST) by setting the FileSplitLevel property of EDIFileSplitter. After splitting the file the OnFileOperationCompletedEvent will be fired. Note that the event will be fired from a different thread.

Example

EDIFileSplitter ediFileSplitter = new EDIFileSplitter();

// Split the file at the header level (ST segment)
ediFileSplitter.FileSplitLevel = FileSplitLevel.HEADER;

// Place 2 ST headers per file
ediFileSplitter.NumberOfItemsPerFile = 2;
ediFileSplitter.OnFileOperationCompleted += new EventHandler(splitter_OnFileOperationCompleted);

try
{
   string currentDirectory = Directory.GetCurrentDirectory();
   ediFileSplitter.Split("837P_2ST_SE_Loops.txt", currentDirectory);
}
catch (Exception ex)
{
   MessageBox.Show(ex.Message);
}

private void splitter_OnFileOperationCompleted(object sender, FileOperationCompletedEventArgs e)
{
    if (e.Status != FileOperationStatus.Success)
    {
       MessageBox.Show("Error splitting file", "Error");
    }
    else if (e.Status == FileOperationStatus.Success)
    {
       MessageBox.Show("File Split Success", "Success");
    }
}

EDIFileSplitter will add the correct number of items in element 1 of the SE, GE, and IEA segments.


Setting Read/Write Buffers
EDIFileSplitter is a high-speed multi-threaded X12 EDI File splitter. It reads and writes data concurrently. This means that strings only stay in memory for a short time reducing overall memory load in applications. This also has the added benefit of being able to split larger EDI files. EDIFileSplitter does not read the entire source EDI file at once. By default EDIFileSplitter reads data 4096 bytes at a time. This reduces total IO operations and increase the speed of the overall splitting process. EDIFileSplitter also does not write to the output EDI files one line at a time. By default it uses a buffer of 4096 bytes. When the buffer is full it then writes the data to the output EDI files. This again reduces the total IO operations. These default settings can be changed to suit specific scenarios.

Example

EDIFileSplitter splitter = new EDIFileSplitter();
splitter.ReadBlockSize = 5012;
splitter.WriteBlockBuffer = 5012;


Setting Output File Name
By default the output file name created used the following format: <OriginalFileName><file number><extension>. For example, if two files are generated as the result of the splitting a file named “EDIData”, the following two files will be created in the output directory:

· EDIData1.txt
· EDIData2.txt

The format of the output file name can be changed by setting the OutputFilenameFormat and the OutputFilename property.

Example

EDIFileSplitter ediFileSplitter = new EDIFileSplitter();

// Split the file at the header level (ST segment)
ediFileSplitter.FileSplitLevel = FileSplitLevel.HEADER;

// Place 2 ST headers per file
ediFileSplitter.NumberOfHeadersPerFile = 2;
ediFileSplitter.OutputFilename = "Test";
ediFileSplitter.OutputFilenameFormat = "{0}_{1}{2}";
ediFileSplitter.Split("EDIData", Directory.GetCurrentDirectory());

The output file name will now be Test_1.txt.

The GeneratePseudoRandomNumberInFilename property will generate a unique number for each split file. The unique number is total milliseconds since the last epoch, January 1, 1970.


Overview

EDIFileJoiner provides a fast and easy way to combine multiple X12 EDI files. It exhibits fast reading and writing speeds and offers the ability to combine EDI files at the Interchange (ISA), Functional Group (GS) or the Header Level (ST).

Main Features

· Ability to combine multiple X12 EDI files into one EDI file
· Ability to combine X12 files at the Interchange (ISA), Functional Group (GS) or the Transaction Header Level (ST)
· Fast reading and writing speeds
· Keeps track of and inserts correct number of ST and GS segments in the GE and IEA segments
· Asynchronous file read and write operations
· Auto detection of file delimiters to properly combine files
· Memory efficient
· Ability to specify the size of read and write buffers for less IO operations
· Easy to use API


Joining Files
EDIFileJoiner is capable of joining any number of X12 EDI files into one. The joining operation is asynchronous by nature allowing program flow to continue.

Example

EDIFileJoiner joiner = new EDIFileJoiner();
joiner.AutoDetectDelimiters = true;

// Join the files at the ST header level
joiner.FileJoinLevel = FileJoinLevel.HEADER;

// Subscribe to be notified when the joining operation is complete
joiner.OnFileOperationCompleted += new EventHandler(joiner_OnFileOperationCompleted);

// Specify the list of files to join
List files = new List();
files.Add("834_1.txt");
files.Add("834_2.txt");
files.Add("834_2ST.txt");
files.Add("834_5010.txt");

// Join the EDI files
joiner.Join(files, "CombinedAll.txt");

private void joiner_OnFileOperationCompleted(object sender, FileOperationCompletedEventArgs e)
{
   if (e.Status != FileOperationStatus.Success)
   {
     // Success
   }
}

Files can also be joined asynchronously using the async join methods. Use the EachSegmentInNewLine property to make every segment appear in a new line


Joining files at different levels
EDIFileJoiner is capable of combining any number of X12 EDI files into one. The combining operation is asynchronous by nature allowing program flow to continue. You can combine EDI files at either the Interchange (ISA segment), Functional Group Level (GS segment) or at the Header Level (ST segment) by setting the FileJoinLevel property correctly.

It is important to note that the ISA and IEA segments of the first EDI file in the group will be used in the resulting EDI output file whether joining is specified at the functional group or header level.
It is also important to note that the EDIFileJoiner component is powerful enough to join X12 EDI files of different standards (i.e. 837, 834, 820) with completely different delimiter sets. It is recommended that only EDI files of the same standard and having the same delimiter set be combined however

Example

EDIFileJoiner joiner = new EDIFileJoiner();

// Join the files at the Functional Group Level (GS)
joiner.FileJoinLevel = FileJoinLevel.FUNCTIONALGROUP;

// Subscribe to be notified when the joining operation is complete
joiner.OnFileOperationCompleted += new EventHandler(joiner_OnFileOperationCompleted);

// Specify the list of files to join
List files = new List();
files.Add("834_1.txt");
files.Add("834_2.txt");
files.Add("834_2ST.txt");
files.Add("834_5010.txt");

// Join the EDI files
joiner.Join(files, "CombinedAll.txt");

private void joiner_OnFileOperationCompleted(object sender, FileOperationCompletedEventArgs e)
{
   if (e.Status != FileOperationStatus.Success)
   {
      // Success
   }
}

Files can also be joined asynchronously using the async join methods. Use the EachSegmentInNewLine property to make every segment appear in a new line


Joining strings
EDIFileJoiner is capable of joining any number of X12 EDI strings into one.

Example

EDIFileJoiner joiner = new EDIFileJoiner();
joiner.AutoDetectDelimiters = true;

// Join the strings at the ST header level
joiner.FileJoinLevel = FileJoinLevel.HEADER;

// Specify the list of files to join
List<string> dataList = new List<string>();
dataList.Add("ISA*....");
dataList.Add("ISA*....");
dataList.Add("ISA*....");
dataList.Add("ISA*....");

// Join the strings
string combinedEDIStrings = joiner.JoinStrings(dataList);


Transaction Control Numbers

Totals
By default EDIFileJoiner will automatically add the ST Control Numbers at element 2 of the ST and SE segment. This feature can be turned off using the AutoGenerateSTControlNumber property.

Example

EDIFileJoiner joiner = new EDIFileJoiner();
AutoGenerateSTControlNumber = false;


Setting Read/Write Buffers
EDIFileJoiner is a high-speed multithreaded X12 EDI File combiner. It reads and writes data at the concurrently. This means that strings only stay in memory for a short time reducing overall memory load in applications. This also has the added benefit of being able to combine larger EDI files.
EDIFileJoiner does not read EDI files one line at a time. By default EDIFileJoiner reads data 4096 bytes at a time. This reduces total IO operations and increase the speed of the overall joining process.
EDIFileJoiner also does not write to the output EDI files one line at a time. By default it uses a buffer of 4096 bytes. When the buffer is full it then writes the data to the output EDI files. This again reduces the total IO operations.
These default settings can be changed to suit specific scenarios.
Example

EDIFileJoiner joiner = new EDIFileJoiner();
joiner.ReadBlockSize = 5012;
joiner.NewFileBufferSize = 5012;


Overview

EDIFileScrubber provides a fast and easy way to hide sensitive data in EDI files. It exhibits fast parsing speeds and offers the ability to scrub data from EDI files or from in-memory strings. EDIFileScrubber enables scrubbed EDI data to be accessed in an API-like fashion after loading.

Main Features

· Scrubs any EDI file (X12 and EDIFACT)
· Handles composite elements
· Fast parsing and scrubbing speeds
· Creates an EDI Document object after scrubbing is completed for easy access to EDI data
· Option to scrub EDI data from the file system or in-memory strings
· Auto detection of segment, element and composite delimiters
· Extremely easy to use API


Setting Delimiters
Example

scrubber.Delimiters.SegmentTerminatorCharacter = '^';
scrubber.Delimiters.ElementTerminatorCharacter = '*';
scrubber.Delimiters.CompositeTerminatorCharacter = ':';

For EDIFACT files the segment terminator character is usually the apostrophe character.

scrubber.Delimiters.SegmentTerminatorCharacter = '\'';
scrubber.Delimiters.ElementTerminatorCharacter = '^';


Auto Detection of Delimiters
EDIFileScrubber has a Delimiter property that can be set if delimiters are known beforehand. It also has a property called AutoDetectDelimiters. By enabling this property EDIFileScrubber detects the special delimiter characters while scrubbing is being performed. Scrubbing is then performed from this point as usual.

Example

// Create an instance of the EDIFileScrubber object
EDIFileScrubber scrubber = new EDIFileScrubber

scrubber.AutoDetectDelimiters = true;


Scrub EDI Data In File

Scrub EDI data from a file
EDIFileScrubber allows developers to scrub EDI files from the file system using the EDIFile property. EDIFileScrubber will also find the necessary delimiters if set.

Example

// Create a new instance of EDIFileScrubber
EDIFileScrubber scrubber = new EDIFileScrubber

scrubber.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the scrub
scrubber.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are scrubbing from an in- memory string or a file.  If you are scrubbing from a string then set the EDIDataString property to the EDI data
scrubber.EDISource = EDISource.File // Or EDISource.DataString

// Set the EDI file path to scrub
scrubber.EDIFile = "C:\\EDIFile.txt

// Set the scrubbing rule (s)

// Set element 0,1,2,3 of the ISA segment to be replaced by the character 'Q'
ScrubRule rule = new ScrubRule();
rule.SegmentName = "ISA";
rule.ReplaceCharacter = 'Q';
rule.ScrubPositions.Add(new ScrubPosition(0));
rule.ScrubPositions.Add(new ScrubPosition(1));
rule.ScrubPositions.Add(new ScrubPosition(2));
rule.ScrubPositions.Add(new ScrubPosition(3));

// Set composite element 0 element 0 of the SVC segment to be replaced by the character 'W'
ScrubRule rule2 = new ScrubRule();
rule2.SegmentName = "SVC";
rule2.ReplaceCharacter = 'W';
rule2.ScrubPositions.Add(new ScrubPosition(0,0));

scrubber.ScrubRules.Add(rule);
scrubber.ScrubRules.Add(rule2);

// scrub the data
EDILightWeightDocument doc = scrubber.Scrub();

.


Accessing Scrubbed EDI Data
Developers can access all data from an EDI file that has been scrubbed with the EDIFileScrubber using the EDILightWeightDocument returned after calling the Scrub() method. The EDILightWeightDocumentreturned enables access the EDI file. There is only one main loop containing all the scrubbed segments and elements that exist in the EDI file.

Example

// Create a new instance of EDIFileScrubber
EDIFileScrubber scrubber = new EDIFileScrubber

scrubber.AutoDetectDelimiters = true;

// Set the type of EDI file that you are about the scrub
scrubber.EDIFileType = FileType.X12; //Or FileType.EDIFACT

// Set the source of EDI data, whether you are scrubbing from an in- memory string or a file
scrubber.EDISource = EDISource.File // Or EDISource.DataString

// Set the EDI file path to scrub
scrubber.EDIFile = "C:\\EDIFile.txt

// Set the scrubbing rule (s)

// Set element 0,1,2,3 of the ISA segment to be replaced by the character 'Q'
ScrubRule rule = new ScrubRule();
rule.SegmentName = "ISA";
rule.ReplaceCharacter = 'Q';
rule.ScrubPositions.Add(new ScrubPosition(0));
rule.ScrubPositions.Add(new ScrubPosition(1));
rule.ScrubPositions.Add(new ScrubPosition(2));
rule.ScrubPositions.Add(new ScrubPosition(3));

// Set composite element 0 element 0 of the SVC segment to be replaced by the character 'W'
ScrubRule rule2 = new ScrubRule();
rule2.SegmentName = "SVC";
rule2.ReplaceCharacter = 'W';
rule2.ScrubPositions.Add(new ScrubPosition(0,0));

scrubber.ScrubRules.Add(rule);
scrubber.ScrubRules.Add(rule2);

// scrub the data
EDILightWeightDocument scrubbedDocument = scrubber.Scrub();
// Get the main loop. This loop contains the entire scrubbed EDI
document
LightWeightLoop mainLoop = scrubbedDocument.Loop[0]; //the main loop

// Get all segments
Collection<LightWeightSegment> allSegments = mainLoop.Segments;


Ignoring Formatting Characters
EDIFileScrubber offers the ability to ignore certain strings that trail segments (X12). These extra characters are sometimes used for formatting an EDI file. For example, some companies may place a return character so that an EDI file may look a little better. While processing an EDI file these characters may cause a parser to fail. By setting the TrimString property of the EDIFileScrubber these extra characters will be ignored

Example 1

// Ignore all return characters at the end of a segment
scrubber.TrimString = "\n";

Example 2

// Ignore all carriage returns characters at the end of a segment
scrubber.TrimString = "\r\n";


Getting Time Elapsed
Developers can check how long it takes to scrub an EDI file using the TimeElapsed property of the EDIFileScrubber component. The TimeElapsed property will give the number of milliseconds it took to scrub the file.
There are two ways to get the elapsed time. One way is through the TimeElapsed property. The other way is to subscribe to the FileScrubbingCompleted
event. It contains the Milliseconds property in its eventargs object.

Example 1

// Use the TimeElapsed property after loading
scrubber.TimeElapsed;

Example 2

scrubber.FileScrubbingCompleted += new
EDIFileScrubber.EDIFileScrubbingCompletedEvent(scrubbingCompleted);

private void scrubbingCompleted(object sender, FileLoadingEventArgs e)
{
MessageBox.Show(e.Milliseconds);
}


Overview

EDIDocumentViewer is a high performance, low memory UI component that displays EDI data in a hierarchical fashion. It supports both large and small EDI files while not sacrificing performance, speed or memory. Data is loaded and unloaded on demand so memory footprint remains low.

Main Features

· View entire EDI data in a hierarchical tree
· Low memory footprint, only nodes that are in view are loaded
· On demand loading, unloading of loops and segments
· Loops, segments and elements are color coded for easy viewing
· Raises a NodeSelected event for custom coding
· Supports repeating elements as well as repeating composite elements
· Support EDIDocument and EDILightweightDocument object types
· Supports both large and small EDI files


Displaying an EDI Document
EDIDocumentViewer allows you to either display data from an EDILightWeightDocument or an EDIDocument. Nodes in the visual tree are only created when they are needed to reduced the memory footprint and increase the overall performance of your application. Conversely nodes are removed from memory when they are expanded.
The example below assumes that you have already created an instance of the EDIDocumentViewer and added it to your form.

Example

EDIDocument sampleEDIFile = new EDIDocument("C:\\EDIDoc.txt");

// Create your EDI documents loops, segments an elements here

// Load the data into the EDIDocumentViewer.
ediDocumentViewer1.LoadDocument(sampleEDIFile);

Your EDIDocument will now be displayed in a visual tree. You can now expand and collapse loops, segments and composite elements and see the data in your EDI document.


Displaying Validated EDI File

Displaying a validated EDI File
One very important use of the EDIDocumentViewer is to display a validated EDI document. This allows both developers and users alike to see their EDI documents in a visual tree. They can now expand and collapse and drill down into their EDI documents.

Example

// Setup up your edivalidator object and configurations here
ediValidator.LoadValidatedData = true;
ediValidator.Validate();

// Load the data into the EDIDocumentViewer.
ediDocumentViewer1.LoadDocument(ediValidator.EDILightWeightDocument);

Your EDILightWeightDocument will now be displayed in a visual tree. You can now expand and collapse loops, segments and composite elements and see the data in your EDI document.


Node Events
EDIDocumentViewer a exposes an event called NodeSelected. This will allow developers to know when a node is selected. A node can be either a loop, segment, element or composite element.

Example

ediDocumentViewer1.NodeSelected += new System.EventHandler<RDPCrystalEDILibrary.UI.Winforms.EDINodeSelectedEventArgs>(NodeSelected);

private void NodeSelected(object sender, EDINodeSelectedEventArgs e)
{
   if (e.SelectedObject is DataElement)
   {
   }
   else if (e.SelectedObject is LightWeightElement)
   {
   }
   else if (e.SelectedObject is Loop)
   {
   }
   else if (e.SelectedObject is LightWeightLoop)
   {
   }
}

Depending on if you were displaying an EDIDocument or a EDILightWeightDocument the SelectedObject will be of that category type.


Overview

EDI Rules Reader is a very fast parser that reads the EDI rules from a .Rules formatted rule file. EDI Rules Reader is used primarily by the EDIValidator component to read, parse, validate and load EDI files, in that order. EDIValidator then uses the information in EDIRulesReader to do all of its validation.

In most cased the actions of the EDIRulesReader will be transparent to EDI developers using the RDPCrystal EDI Library. They will just use the EDIValidator component.
EDI Rules Reader reads in all the EDI rules and puts them in a tree like structure.

The EDI rules format gives you the flexibility to create basically any type of EDI rule. It can load ANY EDI specs and any rules. For example EDI Rules Reader can be used to load 837s, 835s, 997, 270, 271 .Rules file formats.

The EDI Rules Reader is configured to read in any valid .Rules EDI rules file. This is what makes the component so valuable, it’s not tied into just one rule or format. You can also create your own rules file graphically with the EDI Rules Creator application

It contains the following meta data for each standard

· Element Definitions – ID, Type, Minimum, Maximum, Description
· Segment Definitions – Names, Usage
· Composite Elements Definitions– Names, Usage
· EDI File Structure – Loop Hierarchy
· Elements Formats -Regular Expressions used to validate data like dates, times, ids etc.
· Validation Rules – Required, Optional, Not Used loops, segments and elements
· Summary Rules
· Segment Constraints
· Element Constraints
· Code List and Accepted Values
· Plus much more


Parsing EDI Rules File

Parsing an EDI Rules File
EDI Rules Reader is a very fast parser that reads the EDI rules from a .Rules formatted rule file. EDI Rules Reader is used primarily by the EDIValidator component to read, parse, validate and load EDI files, in that order. EDIValidator then uses the information in EDI Rules Reader to do all of its validation. The EDI Rules Creator Application uses the EDI Rules Reader component to load .Rules files and EDI Rules Creator component to save .Rules file.
In most cases the actions of the EDI Rules Reader will be transparent to EDI developers using the RDPCrystal EDI Library. They will just use the EDIValidator component. However some developers will want to see rules displayed in another editor or for their own editing applications. You can use the EDI Rules Reader to complete this task.

Example

// Create an instance of the EDI Rules Reader
EDIRulesReader reader = new EDIRulesReader("C:\\EDIRules.Rules");
// Load EDI Rules
reader.Parse();

// After parsing the following dictionary lists are available for custom
programming and application development
// All the elements in the rules file
this.elements = reader.Elements;

// All the segments in the rules file
this.segments = reader.Segments;

// All the composite segments in the rules file
this.compositeSegments = reader.CompositesSegments;

// All the segment schemas in the rules file
this.segmentSchemas = reader.SegmentSchemas;

// All code list in the rules files (internal and external)
this.codeLists = reader.CodeLists;

// All element formats
this.elementFormats = reader.ElementFormats;

// The complete rules of the .Rules format included loops, usages,
segments, elements, element values
this.loopSchema = reader.Schema;


View Rules Tree
You can use the TreeGenerator class from RDPCrystalEDILibrary.UI.Winforms to generate a complete tree of your rules.

public static TreeNode BuildRulesTree(EDIRulesReader reader)

public static TreeNode BuildEDIDocumentTree(EDIDocument document, bool expandLoopNode = false)

Example


Overview

EDIValidationUnit is a pre-built Windows user control that can be dropped into applications. NO PROGRAMMING REQUIRED!!

Integrate EDI validation into applications faster than ever!

· No programming required!
· Displays errors and warnings in convenient grids
· Loads EDI data in a high-performance hierarchy tree
· Go directly to the line that contains an error or warning
· Saves tons of time

Main Features

· View all errors in EDI files
· View all warnings in EDI files
· View all EDI data in a tree
· Navigate to errors and warnings in EDI files with one click
· Set component colors to the match look and feel of applications
· Export errors and warnings into CSV files
· Displays SNIP Levels
· Show/Hide different parts of the view


Validating An EDI file

Validating an EDI file using the Validation Unit
After placing the ValidationUnit on your form you can virtually validate an EDI file with no code at all.

How to use the validation component

After running your program you will see the ValidationUnit on your form:

Steps

1. Select the EDI Rules file from the EDI Rule File text field. This rule file must be a valid EDI rules file.
2. Select the EDI file you want to validate in the EDI File text field.
3. Click on the Validate button to validate the file.
4. The ValidationUnit will first read in the EDI rules file. Progress will be displayed in the Reading EDI Rules progress bar.
5. The ValidationUnit will then validate the EDI file. Progress will be displayed in the Validating & Loading progress bar.
6. After validation a list of errors or warnings will be in the Errors and Warnings tab. You can right click on the error or warning tables to go directly to the error or warning.

After validation example


Setting Delimiters
You can set the delimiters of the ValidationUnit

Example

validationUnit.Delimiters.SegmentTerminatorCharacter = '~';
validationUnit.Delimiters.ElementTerminatorCharacter = '*';
validationUnit.Delimiters.CompositeTerminatorCharacter = ':';

or

validationUnit.AutoDetectDelimiters =  true;


Hide Load Data Section

Hiding Load Data Section
By default all sections of the ValidationUnit are visible. You can hide the loaded data section using the HideLoadDataSection property of the ValidationUnit.

Example

validationUnit.HideLoadDataSection = false;
Before

After


Hide EDI File Section

Hiding EDI File Section
By default all sections of the ValidationUnit are visible. You can hide the EDI File Section using the HideEDIFileSection property of the Validation Unit.

Example

validationUnit.HideEDIFileSection = false;

Before

After


Hide File Input Section
By default all sections of the ValidationUnit are visible. You can hide the File Input Section using the ShowFileInputSection property of the Validation Unit. This will also hide the validate button. You can still validate files using the ValidateFile() method of the ValidationUnit.

Example

validationUnit.ShowFileInputSection = false;


Hiding Progress Section

Hiding the Progress Section
By default all sections of the ValidationUnit are visible. You can hide the Progress Section using the ShowProgressSection property of the Validation Unit.

Example

validationUnit.ShowProgressSection = false;


Setting Colors
You can customize the appearance of the ValidationUnit

Example

validationUnit.EDIFileBackColor = Color.Blue;
validationUnit.EDIFileForeColor = Color.Black;

validationUnit.ErrorTableBackColor = Color.Yellow;
validationUnit.ErrorTableForeColor = Color.Black;

validationUnit.WarningTableBackColor = Color.Yellow;
validationUnit.WarningTableForeColor = Color.Black;

validationUnit.LoadDataBackColor = Color.Orange;

validationUnit.ShowFileGridLines = false;
validationUnit.ShowErrorGridLines = false;
validationUnit.ShowWarningGridLines = false;


Overview

RDPCrystal EDI Library allows you to send and receive files using HTTP

Transmission Protocol: (HTTP)

· Send files over HTTP
· Receive files over HTTP
· Supports username and password authentication
· Upload and download files asynchronously
· Delegate event model – Delegate event model allowing developers to easily capture events fired from the HTTP component


Uploading File

Uploading a File
You can upload a file using the HTTP class

Example

HTTP http = new HTTP();
http.Hostname = "HostnameAddress";
http.UploadFile("C:\\filetoupload.txt");


Uploading File Asynchronously

Uploading a File Asynchronously
You can upload a file asynchronously using the HTTP class

Example

HTTP http = new HTTP();

http.Hostname = "HostnameAddress";

http.FileUploadCompleted += new
HTTP.UploadFileCompletedDelegate(http_FileUploadCompleted);

http.FileUploadProgressChanged += new
HTTP.UploadFileProgressChangedDelegate(http_FileUploadProgressChanged);
http.UploadFileAsync("C:\\FileToUpload.txt");

private void http_FileUploadProgressChanged(object sender,
System.Net.UploadProgressChangedEventArgs e)
{
MessageBox.Show(e.BytesReceived.ToString());
}

private void http_FileUploadCompleted(object sender,
System.Net.UploadFileCompletedEventArgs e)
{
MessageBox.Show("File Uploaded Completed");
}


Downloading File

Downloading a File
You can download a file using the HTTP class. The downloaded file will be saved in the file system as in the file specified in the parameters of the DownloadFile() procedure.

Example

HTTP http =  new HTTP();
http.Hostname = "HostnameAddress/fileToDownload";
http.DownloadFile("C:\\SaveFiled.txt");


Downloading File Asychronously

Downloading a File Asynchronously
You can download a file asynchronously using the HTTP class.

Example

// Create an instance of the HTTP instance
HTTP http = new HTTP();
http.Hostname = "HostnameAddress";

// Subscribe to the DownloafFileProgressChanged event
http.DownloadFileProgressChanged += new
HTTP.DownloadFileProgressChangedDelegate(http_DownloadFileProgressChanged);

// Subscribe to the DownloafFileCompleted event
http.DownloadFileCompleted += new
HTTP.DownloadFileCompletedDelegate(http_DownloadFileCompleted);
http.DownloadFile(" C:\\SaveFiled.txt ");
private void http_DownloadFileCompleted(object sender,
AsyncCompletedEventArgs e)
{
Console.WriteLine("Download completed");
}

private void http_DownloadFileProgressChanged(object sender,
System.Net.DownloadProgressChangedEventArgs e)
{
Console.WriteLine(e.BytesReceived.ToString();
}


Supplying Username and Password

Supplying a Username and Password
You can specify a username and password for either uploading or downloading a file.

Example

HTTP http = new HTTP();
http.Hostname = "HostnameAddressAndFileToDownload";
http.Username = "Username";
http.Password = "Password";
http.DownloadFile("C:\\SaveFiled.txt");


Overview

RDPCrystal EDI Library allows you to send and receive files using HTTPS

Transmission Protocol: (HTTPS)

· Send files over HTTPS
· Receive files over HTTP S
· Supports username and password authentication
· Add custom headers
· Validate server certificates before sending files
· Send your certificates to a server
· Delegate event model – Delegate event model allowing developers to easily capture events fired from the HTTPS component


Uploading File

Uploading a File
You can upload a file using the HTTPS class

Example

HTTPS http = new HTTPS();
http.Hostname = "HostnameAddress";
http.UploadFile("C:\\filetoupload.txt");


Downloading File

Download a File
You can download a file using the HTTPS class. The downloaded file will be saved in the file system as the filename specified in the parameters of the DownloadFile() procedure.

Example

HTTPS https = new HTTPS();
https.Hostname = "HostnameAddress/fileToDownload.txt";
https.DownloadFile("C:\\SaveFiled.txt");


Supplying Username and Password

Supplying a Username and Password
You can specify a username and password for either uploading or downloading a file.

Example

HTTPS https = new HTTPS();
https.Hostname = "HostnameAddress";
https.Username = "Username";
https.Password = "Password";
https.DownloadFile("C:\\SaveFiled.txt");


Sending Certificates
You can set client certificates to be validated by your hosts

Example

HTTPS https = new HTTPS();

https.X509CertificateFile = "certifcate.cer";


Validates Certificates
You can validate a host's certificate before creating a secure connection in order to make sure that the host's certificate is valid or a trusted party. You can also check if the certificate has expired.

Example

HTTPS https = new HTTPS();
https.CertificateValidation += new
HTTPS.CertificateValidationDelegate(https_CertificateValidation);
private void https_CertificateValidation(object sender,
CertificationEventArgs e)
{
if (e.SslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
{
//Valid certificate. You can go on further and check the following
fields
//to make sure that the certificate is valid
string expDate = e.Certificate.GetExpirationDateString();
string effDate = e.Certificate.GetEffectiveDateString();
string issName = e.Certificate.GetIssuerName();
}
else
{
//Invalid Certificate
e.Cancel = true;
}
}


Overview

Typed Documents removes all complexities from creating HIPAA EDI documents. It allows the creation of HIPAA EDI documents without worrying about elements, delimiters and many other EDI nuances

Main Features

· Use feature-rich HIPAA objects like X125010Document to quickly create EDI documents
· Use high level objects like ISA, GS, ST, CLM, IEA etc
· Just set properties instead of worrying about elements, positions, segments and delimiters
· Seamlessly use composite elements
· Cut HIPAA EDI development time in half
· Generate actual EDI data with one procedure call
· Extensible model that allows custom documents and segments creation


Supported HIPAA Guides
Typed Documents support the loading of the following HIPAA 5010 Implementation Guides

· 5010 837 Dental
· 5010 837 Professional
· 5010 837 Institutional
· 5010 270 Health Care Eligibility Benefit Inquiry
· 5010 271 Health Care Eligibility Benefit Response
· 5010 834 Health Benefit Enrollment and Maintenance
· 5010 835 Health Care Claim Payment/Advice
· 5010 276 Health Care Claim Status Request
· 5010 277 Health Care Information Status Notification
· 5010 277CA Health Care Claim Acknowledgment
· 5010 999 Implementation Acknowledgment for Health Care Insurance

Typed Documents can also be customized to support any X12 guide. Please see our examples.


Creating a TypedDocument EDI File

Creating an EDI File
Typed Documents are simple to create and follow the same name and terminology as the HIPAA 5010 implementation guides.

The entire document could be created in one loop as opposed to mirroring the loop structures for a specific implementation guide

Example

X125010Document sampleEDIFile = new X125010Document();

// Puts the correct number of segments/headers/transaction in X12 SE, GE, and IEA segments
sampleEDIFile.AutoPlaceCorrectNumOfSegments = true;
sampleEDIFile.AutoPlaceNumOfTransactions = true;
sampleEDIFile.AutoPlaceNumOfFunctionalGroups = true;
sampleEDIFile.PadISAElementValues = true;

// Create an interchance loop. This loop will contain all other loops in the EDI structure
DocumentLoop interchangeHeader = sampleEDIFile.MainSection.CreateLoop("Interchange Header");

// Create an ISA segment in the interchange loop
ISA isa = interchangeHeader.CreateSegment<ISA>();
isa.AuthorizationInformationQualifier = "00";
isa.AuthorizationInformation = "";
isa.SecurityInformationQualifier = "00";
isa.SecurityInformation = "";
isa.InterchangeIDQualifier1 = "ZZ";
isa.InterchangeSenderID = "InterchangeSenderID";
isa.InterchangeIDQualifier2 = "ZZ";
isa.InterchangeReceiverID = "InterchangeReceiverID";
isa.InterchangeDate = "150303";
isa.InterchangeTime = "1804";
isa.RepetitionSeparator = "^";
isa.InterchangeControlVersionNumber = "00501";
isa.InterchangeControlNumber = "1";
isa.AcknowledgmentRequested = "1";
isa.InterchangeUsageIndicator = "P";
isa.ComponentElementSeparator = ":";

// Now create the function header section
DocumentLoop functionalHeader = interchangeHeader.CreateLoop("Functional Header");

GS gs = functionalHeader.CreateSegment<GS>();
gs.FunctionalIdentifierCode = "HC";
gs.ApplicationSenderCode = "ApplicationSenderCode";
gs.ApplicationReceiverCode = "ApplicationReceiverCode";
gs.Date = "20150303";
gs.Time = "1424";
gs.GroupControlNumber = "1234";
gs.ResponsibleAgencyCode = "X";
gs.VersionReleaseIndustryIdentifierCode = "005010X222";

// Create a transaction header loop
DocumentLoop transactionHeader = functionalHeader.CreateLoop("Transaction Header");
ST st = transactionHeader.CreateSegment<ST>();
st.TransactionSetIdentifierCode = "837";
st.TransactionSetControlNumber = "1";
st.ImplementationConventionReference = "005010X222";

// Add an BHT segment to the transaction header loop
BHT bht = transactionHeader.CreateSegment<BHT>();
bht.HierarchicalStructureCode = "0019";
bht.TransactionSetPurposeCode = "00";
bht.ReferenceIdentification = "44445";
bht.Date = "20040213";
bht.Time = "0345";

// Create the end of the transaction (SE segment). This must be done in a loop.
DocumentLoop endOfTransactionLoop = transactionHeader.CreateLoop("End Of Transaction");
SE se = endOfTransactionLoop.CreateSegment<SE>();
se.TransactionSetControlNumber = "1";
se.NumberOfIncludedSegments = "3";

// Create the end of the functional group (GE segment). This must be done in a loop.
DocumentLoop endOfFunctionalGroupLoop = functionalHeader.CreateLoop("End Functional Group");
GE ge = endOfFunctionalGroupLoop.CreateSegment<GE>();
ge.GroupControlNumber = "11234";
ge.NumberOfTransactionSetsIncluded = "1";

// Finally create the end of the interchange loop (IEA segment). This must be done in a loop.
DocumentLoop endInterchangeSection = interchangeHeader.CreateLoop("End Interchange");
IEA iea = endInterchangeSection.CreateSegment<IEA>();
iea.InterchangeControlNumber = "123";
iea.NumberOfIncludedFunctionalGroups = "1";

// Generate the EDI file
string ediData = sampleEDIFile.ToEDIString(new Delimiters());

// There is also a GenerateEDIFile() method to write directly to a file


Loading a Typed Document
If validating HIPAA 5010 EDI files you can load the entire file into a Typed Document after validation.

Example

ediValidator.Validate();

// The EDI Document will contain all the data of the 837 file
if (ediValidator.EDILightWeightDocument != null)
{
  // Creates and loads a TypedDocuments
   X125010Document doc = new X125010Document(ediValidator.EDILightWeightDocument);

   // From here on you can access objects rather than indexes
   // from arrays to get data
   DisplayInterchangeHeader(doc.MainSection);
   DisplayFunctionalHeader(doc.MainSection.GetLoop("FUNCTIONAL GROUP"));

   ISA header = doc.MainSection.GetSegment<ISA>();

   DocumentLoop functionalHeaderLoop = doc.MainSection.GetLoop("FUNCTIONAL GROUP");

   DocumentLoop stHeaderLoop = functionalHeaderLoop.GetLoop("ST HEADER");

   // Get the submitter loop. In an 837 file the submitter loop is 1000A
   DocumentLoop submitterSection = stHeaderLoop.GetLoop("1000A");
   DisplaySubmitterInformation(submitterSection);

   // Get the receiver loop. In an 837 file the receiver loop is 1000B
   DocumentLoop receiverSection = stHeaderLoop.GetLoop("1000B");
   DisplayReceiverInformation(receiverSection);

   // Get the 2000A BILLING/PAY-TO PROVIDER HIERARCHICAL LEVEL
   // In an 837 file this loop is 2000A
   DocumentLoop bpHierLevel = stHeaderLoop.GetLoop("2000A");
   DocumentLoop billingProviderLoop = bpHierLevel.GetLoop("2010AA");

   DisplayBillingProviderInformation(billingProviderLoop);

   // Get all the subscribers and claims information
   List<DocumentLoop> subscriberAndClaimsSections = bpHierLevel.GetLoops("2000B");
   DisplayAllClaims(subscriberAndClaimsSections);
}

A potential display procedure can be

private void DisplayBillingProviderInformation(DocumentLoop billingProviderNameSection)
{
  // Get the Billing Provider's name
  NM1 nm1 = billingProviderNameSection.GetSegment<NM1>();
  txtBillingProviderName.Text = nm1.NameLastOrOrganizationName + nm1.FirstName;

  // Get the street address
  N3 n3 = billingProviderNameSection.GetSegment<N3>();
  txtProviderStreet.Text = n3.AddressInformation1;

  // Get the city state and zip code
  N4 n4 = billingProviderNameSection.GetSegment<N4>();
  txtProviderAddress.Text = n4.CityName + "," + n4.StateOrProvinceCode + "," + n4.PostalCode;
}


Extending Typed Documents
Typed Documents support the loading of the HIPAA 5010 Implementation Guides. However the situation may arise where more guides or custom documents may need to be supported. Typed Documents allows full customization to support any standard.

Step 1 - Create your custom segments class

public class CustomSegment1 : DocumentSegment
{
    public CustomSegment1()
    {
        Name = "CS1";
    }

    // Add properties you need
    public string ID { get; set; }
    public string RefID { get; set; }

    // Override this method and add your custom properties to the Values list
    public override void Write(WriteArguments wargs)
    {
        base.Write(wargs);

        wargs.Values.Add(Name);
        wargs.Values.Add(ID);
        wargs.Values.Add(RefID);

        WriteToBuffer(wargs);
    }

    // Override this method if you also want to load your document from EDILightWeightDocument
    public override void Load(LightWeightSegment segment)
    {
        for (int i = 0; i < segment.Elements.Count; i++)
        {
            LightWeightElement element = segment.Elements[i];

            switch (i)
            {
                case 0:
                    {
                        ID = GetValue(element);
                        break;
                    }
                case 1:
                    {
                        RefID = GetValue(element);
                        break;
                    }
            }
        }
    }
}

Step 2: Derive from TypedEDIDocument

public class MyTypedDocument : TypedEDIDocument
{
    public MyTypedDocument()
    {
    }

    protected override DocumentSegment GetDocumentSegment(string segmentName)
    {
          switch (segmentName)
            {
                case "CS1":
                    {
                        return new CustomSegment1();
                    }
             }

            return null;    }
}

Step 3: Use your TypedEDIDocument

MyTypedDocument customDocument = new MyTypedDocument();

DocumentLoop mainLoop = customDocument.MainSection.CreateLoop("Header");

CustomSegment1 cs1 = mainLoop.CreateSegment<CustomSegment1>();
cs1.ID = "ID123";
cs1.RefID = "RefID 12345";

string ediData = customDocument.ToEDIString(new Delimiters());


Extending X125010Document
X125010Document supports the loading of the HIPAA 5010 EDI documents. By default any HIPAA 5010 file is supported. However the situation may arise where a custom segment needs to be added or subclassed for custom behavior.

For example, let's say that you need to add custom properties to the SVC segment. The SVC class can be subclassed

Step 1 - Derive from SVC

    using RDPCrystalEDILibrary.Documents;

    public class MySVC: X12.IG5010.Segments.SVC
    {
        public MySVC()
        {
        }

         // new property added
        public string LineItemChargeAmount
        {
            get { return MonetaryAmount1; }
        }

        // new property added
        public string LineItemProviderPaymentAmount
        {
            get { return MonetaryAmount2; }
        }
    }

Step 2 - Derive from X125010Document

public class My5010Document : X12.X125010Document
    {
        public My5010Document()
        {
        }

        // add support for your custom segment here
        protected override DocumentSegment GetDocumentSegment(string segmentName)
        {
            if (segmentName == "SVC")
            {
                return new MySVC();
             }

            return base.GetDocumentSegment(segmentName);
        }
    }

That's it. Now when X125010Document is loaded and the SVC segment is encountered your custom SVC segment will be used instead of the default SVC.


Finding EDI Specifications

Parsing EDI Specifications
 Previous Top
The EDISpecification class is used to obtain the specification for an EDI file whether X12 or EDIFACT.

Example

EDISpecification spec = EDISpecification.FindSpecificationFromFile("SampleEDIFACT.txt");

// For EDIFACT
Console.WriteLine(spec.EDIFileType);
Console.WriteLine(spec.EDIFACTReleaseVersion);
Console.WriteLine(spec.EDIFACTMessageType);
Console.WriteLine(spec.EDIFACTMessageVersion);
Console.WriteLine(spec.EDIFACTControllingAgency);

// For X12
Console.WriteLine(spec.X12TransactionSetCode);
Console.WriteLine(spec.X12Version);
Console.WriteLine(spec.X12VersionCode);

Console.WriteLine(spec.InterchangeSenderIDQualifier);
Console.WriteLine(spec.InterchangeSenderID);
Console.WriteLine(spec.InterchangeReceiverIDQualifier);
Console.WriteLine(spec.InterchangeReceiverID);

EDI specification could also be retrieved from EDI data in memory using the FindSpecificationFromString() method.


The EDISpecification class is used to obtain the specification for an EDI file whether X12 or EDIFACT.

Example

EDISpecification spec = EDISpecification.FindSpecificationFromFile("SampleEDIFACT.txt");

// For EDIFACT
Console.WriteLine(spec.EDIFileType);
Console.WriteLine(spec.EDIFACTReleaseVersion);
Console.WriteLine(spec.EDIFACTMessageType);
Console.WriteLine(spec.EDIFACTMessageVersion);
Console.WriteLine(spec.EDIFACTControllingAgency);

// For X12
Console.WriteLine(spec.X12TransactionSetCode);
Console.WriteLine(spec.X12Version);
Console.WriteLine(spec.X12VersionCode);

Console.WriteLine(spec.InterchangeSenderIDQualifier);
Console.WriteLine(spec.InterchangeSenderID);
Console.WriteLine(spec.InterchangeReceiverIDQualifier);
Console.WriteLine(spec.InterchangeReceiverID);

EDI specification could also be retrieved from EDI data in memory using the FindSpecificationFromString() method.