'This is an example C# source code for translating an EDI X12 275X210 using the Framework EDI component. 'The complete sample program can be downloaded from our HIPAA EDI Support webpage at http://www.edidev.com/example_hipaa.html private void btnStart_Click(object sender, EventArgs e) { // Translates 275 Patient Information - Additional Information to Support a Health Care Claim or Encounter ediDocument oEdiDoc; ediSchema oSchema; ediSchemas oSchemas; ediDataSegment oSegment; string sSegmentID = ""; string sValue = ""; string sLoopDesc = ""; string sEdiFileName = ""; string sSefFileName = ""; int nArea = 0; string sNm1Code = ""; string sLxDtpCode = ""; string sQlfr = ""; string sLxAssignedNo = ""; string sPath = AppDomain.CurrentDomain.BaseDirectory; // Create the top-level application object "ediDocument". oEdiDoc = new ediDocument(); // This makes certain that Framework EDI only uses the SEF file provided, // and that it does not use its built-in Standard Reference table to translate // the EDI document oSchemas = (ediSchemas) oEdiDoc.GetSchemas(); oSchemas.EnableStandardReference = false; // The FORWARD-ONLY cursor increases the performance of processing the EDI // document (see Technical Note 3 below). oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly; sEdiFileName = "275_5010X210.X12"; sSefFileName = "275_005010X210.SemRef.SEF"; // Specify SEF file to load. oSchema = (ediSchema) oEdiDoc.LoadSchema(sSefFileName, SchemaTypeIDConstants.Schema_Standard_Exchange_Format); // Specify EDI document to read. oEdiDoc.LoadEdi(sEdiFileName); // Gets the first data segment in the EDI document. oSegment = (ediDataSegment) oEdiDoc.FirstDataSegment; // Loop that will traverse through the EDI document from top to bottom. This // is required for FORWARD-ONLY cursor. while (oSegment != null) { // Data segments are uniquely identified by their segment Identifier (ID). // The loop section and the area (or table) properties of the data segment // are read for each iteration of the loop. sSegmentID = oSegment.ID; sLoopDesc = oSegment.LoopSection; nArea = oSegment.Area; if (nArea == 0) { // Data segments that are not designated an area (i.e. area = 0) // are control segments that are part of the Interchange or // Functional Group envelopes, and are not part of the Transaction Set. if (sSegmentID == "ISA") { sValue = oSegment.get_DataElementValue(1, 0); // Authorization Information Qualifier (I01) sValue = oSegment.get_DataElementValue(2, 0); // Authorization Information (I02) sValue = oSegment.get_DataElementValue(3, 0); // Security Information Qualifier (I03) sValue = oSegment.get_DataElementValue(4, 0); // Security Information (I04) sValue = oSegment.get_DataElementValue(5, 0); // Interchange ID Qualifier (I05) sValue = oSegment.get_DataElementValue(6, 0); // Interchange Sender ID (I06) sValue = oSegment.get_DataElementValue(7, 0); // Interchange ID Qualifier (I05) sValue = oSegment.get_DataElementValue(8, 0); // Interchange Receiver ID (I07) sValue = oSegment.get_DataElementValue(9, 0); // Interchange Date (I08) sValue = oSegment.get_DataElementValue(10, 0); // Interchange Time (I09) sValue = oSegment.get_DataElementValue(11, 0); // Repetition Separator (I65) sValue = oSegment.get_DataElementValue(12, 0); // Interchange Control Version Number (I11) sValue = oSegment.get_DataElementValue(13, 0); // Interchange Control Number (I12) sValue = oSegment.get_DataElementValue(14, 0); // Acknowledgment Requested (I13) sValue = oSegment.get_DataElementValue(15, 0); // Usage Indicator (I14) sValue = oSegment.get_DataElementValue(16, 0); // Component Element Separator (I15) } else if (sSegmentID == "IEA") { sValue = oSegment.get_DataElementValue(1, 0); // Number of Included Functional Groups (I16) sValue = oSegment.get_DataElementValue(2, 0); // Interchange Control Number (I12) } else if (sSegmentID == "GS") { sValue = oSegment.get_DataElementValue(1, 0); // Functional Identifier Code (479) sValue = oSegment.get_DataElementValue(2, 0); // Application Sender's Code (142) sValue = oSegment.get_DataElementValue(3, 0); // Application Receiver's Code (124) sValue = oSegment.get_DataElementValue(4, 0); // Date (373) sValue = oSegment.get_DataElementValue(5, 0); // Time (337) sValue = oSegment.get_DataElementValue(6, 0); // Group Control Number (28) sValue = oSegment.get_DataElementValue(7, 0); // Responsible Agency Code (455) sValue = oSegment.get_DataElementValue(8, 0); // Version / Release / Industry Identifier Code (480) } else if (sSegmentID == "GE") { sValue = oSegment.get_DataElementValue(1, 0); // Number of Transaction Sets Included (97) sValue = oSegment.get_DataElementValue(2, 0); // Group Control Number (28) } // sSegmentID == "GE" } else if (nArea == 1) { if (sLoopDesc == "") { if (sSegmentID == "ST") // Transaction Set Header { sValue = oSegment.get_DataElementValue(1, 0); // Transaction Set Identifier Code (143) sValue = oSegment.get_DataElementValue(2, 0); // Transaction Set Control Number (329) sValue = oSegment.get_DataElementValue(3, 0); // Implementation Convention Reference (1705) } else if (sSegmentID == "BGN") // Beginning Segment { sValue = oSegment.get_DataElementValue(1, 0); // Transaction Set Purpose Code (353) sValue = oSegment.get_DataElementValue(2, 0); // Reference Identification (127) sValue = oSegment.get_DataElementValue(3, 0); // Date (373) sValue = oSegment.get_DataElementValue(4, 0); // Time (337) sValue = oSegment.get_DataElementValue(5, 0); // Time Code (623) sValue = oSegment.get_DataElementValue(6, 0); // Reference Identification (127) sValue = oSegment.get_DataElementValue(7, 0); // Transaction Type Code (640) sValue = oSegment.get_DataElementValue(8, 0); // Action Code (306) sValue = oSegment.get_DataElementValue(9, 0); // Security Level Code (786) } } else { // // The semantic meaning of the loop "NM1" is dependent on the value of the // code qualifier in data element "98" of the data segment "NM1". The value // of the qualifier has the following semantic meaning for the loop: // "PR" - PAYER // "41" - SUBMITTER // "1P" - PROVIDER // "QC" - PATIENT // if (sLoopDesc == "NM1" && sSegmentID == "NM1") { sNm1Code = oSegment.get_DataElementValue(1, 0); } // sLoopDesc == "NM1" && sSegmentID == "NM1" if (sNm1Code == "PR") { if (sLoopDesc == "NM1") { if (sSegmentID == "NM1") // Individual or Organizational Name { sValue = oSegment.get_DataElementValue(1, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(2, 0); // Entity Type Qualifier (1065) sValue = oSegment.get_DataElementValue(3, 0); // Name Last or Organization Name (1035) sValue = oSegment.get_DataElementValue(4, 0); // Name First (1036) sValue = oSegment.get_DataElementValue(5, 0); // Name Middle (1037) sValue = oSegment.get_DataElementValue(6, 0); // Name Prefix (1038) sValue = oSegment.get_DataElementValue(7, 0); // Name Suffix (1039) sValue = oSegment.get_DataElementValue(8, 0); // Identification Code Qualifier (66) sValue = oSegment.get_DataElementValue(9, 0); // Identification Code (67) sValue = oSegment.get_DataElementValue(10, 0); // Entity Relationship Code (706) sValue = oSegment.get_DataElementValue(11, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(12, 0); // Name Last or Organization Name (1035) } else if (sSegmentID == "PER") // Administrative Communications Contact { sValue = oSegment.get_DataElementValue(1, 0); // Contact Function Code (366) sValue = oSegment.get_DataElementValue(2, 0); // Name (93) sValue = oSegment.get_DataElementValue(3, 0); // Communication Number Qualifier (365) sValue = oSegment.get_DataElementValue(4, 0); // Communication Number (364) sValue = oSegment.get_DataElementValue(5, 0); // Communication Number Qualifier (365) sValue = oSegment.get_DataElementValue(6, 0); // Communication Number (364) sValue = oSegment.get_DataElementValue(7, 0); // Communication Number Qualifier (365) sValue = oSegment.get_DataElementValue(8, 0); // Communication Number (364) sValue = oSegment.get_DataElementValue(9, 0); // Contact Inquiry Reference (443) } } // sLoopDesc == "NM1" } else if (sNm1Code == "41") { if (sLoopDesc == "NM1") { if (sSegmentID == "NM1") // Individual or Organizational Name { sValue = oSegment.get_DataElementValue(1, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(2, 0); // Entity Type Qualifier (1065) sValue = oSegment.get_DataElementValue(3, 0); // Name Last or Organization Name (1035) sValue = oSegment.get_DataElementValue(4, 0); // Name First (1036) sValue = oSegment.get_DataElementValue(5, 0); // Name Middle (1037) sValue = oSegment.get_DataElementValue(6, 0); // Name Prefix (1038) sValue = oSegment.get_DataElementValue(7, 0); // Name Suffix (1039) sValue = oSegment.get_DataElementValue(8, 0); // Identification Code Qualifier (66) sValue = oSegment.get_DataElementValue(9, 0); // Identification Code (67) sValue = oSegment.get_DataElementValue(10, 0); // Entity Relationship Code (706) sValue = oSegment.get_DataElementValue(11, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(12, 0); // Name Last or Organization Name (1035) } } // sLoopDesc == "NM1" } else if (sNm1Code == "1P") { if (sLoopDesc == "NM1") { if (sSegmentID == "NM1") // Individual or Organizational Name { sValue = oSegment.get_DataElementValue(1, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(2, 0); // Entity Type Qualifier (1065) sValue = oSegment.get_DataElementValue(3, 0); // Name Last or Organization Name (1035) sValue = oSegment.get_DataElementValue(4, 0); // Name First (1036) sValue = oSegment.get_DataElementValue(5, 0); // Name Middle (1037) sValue = oSegment.get_DataElementValue(6, 0); // Name Prefix (1038) sValue = oSegment.get_DataElementValue(7, 0); // Name Suffix (1039) sValue = oSegment.get_DataElementValue(8, 0); // Identification Code Qualifier (66) sValue = oSegment.get_DataElementValue(9, 0); // Identification Code (67) sValue = oSegment.get_DataElementValue(10, 0); // Entity Relationship Code (706) sValue = oSegment.get_DataElementValue(11, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(12, 0); // Name Last or Organization Name (1035) } } else if (sLoopDesc == "NM1;NX1") { if (sSegmentID == "NX1") // Property or Entity Identification { sValue = oSegment.get_DataElementValue(1, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(2, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(3, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(4, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(5, 0); // Entity Identifier Code (98) } else if (sSegmentID == "N3") // Address Information { sValue = oSegment.get_DataElementValue(1, 0); // Address Information (166) sValue = oSegment.get_DataElementValue(2, 0); // Address Information (166) } else if (sSegmentID == "N4") // Geographic Location { sValue = oSegment.get_DataElementValue(1, 0); // City Name (19) sValue = oSegment.get_DataElementValue(2, 0); // State or Province Code (156) sValue = oSegment.get_DataElementValue(3, 0); // Postal Code (116) sValue = oSegment.get_DataElementValue(4, 0); // Country Code (26) sValue = oSegment.get_DataElementValue(5, 0); // Location Qualifier (309) sValue = oSegment.get_DataElementValue(6, 0); // Location Identifier (310) sValue = oSegment.get_DataElementValue(7, 0); // Country Subdivision Code (1715) } } // sLoopDesc == "NM1;NX1" } else if (sNm1Code == "QC") { if (sLoopDesc == "NM1") { if (sSegmentID == "NM1") // Individual or Organizational Name { sValue = oSegment.get_DataElementValue(1, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(2, 0); // Entity Type Qualifier (1065) sValue = oSegment.get_DataElementValue(3, 0); // Name Last or Organization Name (1035) sValue = oSegment.get_DataElementValue(4, 0); // Name First (1036) sValue = oSegment.get_DataElementValue(5, 0); // Name Middle (1037) sValue = oSegment.get_DataElementValue(6, 0); // Name Prefix (1038) sValue = oSegment.get_DataElementValue(7, 0); // Name Suffix (1039) sValue = oSegment.get_DataElementValue(8, 0); // Identification Code Qualifier (66) sValue = oSegment.get_DataElementValue(9, 0); // Identification Code (67) sValue = oSegment.get_DataElementValue(10, 0); // Entity Relationship Code (706) sValue = oSegment.get_DataElementValue(11, 0); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(12, 0); // Name Last or Organization Name (1035) } else if (sSegmentID == "REF") // Reference Identification { sQlfr = oSegment.get_DataElementValue(1, 0); // Reference Identification Qualifier (128) if (sQlfr == "EJ") { sValue = oSegment.get_DataElementValue(2, 0); // Reference Identification (127) sValue = oSegment.get_DataElementValue(3, 0); // Description (352) sValue = oSegment.get_DataElementValue(4, 1); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 2); // Reference Identification (127) sValue = oSegment.get_DataElementValue(4, 3); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 4); // Reference Identification (127) sValue = oSegment.get_DataElementValue(4, 5); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 6); // Reference Identification (127) } else if (sQlfr == "EA") { sValue = oSegment.get_DataElementValue(2, 0); // Reference Identification (127) sValue = oSegment.get_DataElementValue(3, 0); // Description (352) sValue = oSegment.get_DataElementValue(4, 1); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 2); // Reference Identification (127) sValue = oSegment.get_DataElementValue(4, 3); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 4); // Reference Identification (127) sValue = oSegment.get_DataElementValue(4, 5); // Reference Identification Qualifier (128) sValue = oSegment.get_DataElementValue(4, 6); // Reference Identification (127) } } else if (sSegmentID == "DTP") // Date or Time or Period { sValue = oSegment.get_DataElementValue(1, 0); // Date/Time Qualifier (374) sValue = oSegment.get_DataElementValue(2, 0); // Date Time Period Format Qualifier (1250) sValue = oSegment.get_DataElementValue(3, 0); // Date Time Period (1251) } } // sLoopDesc == "NM1" } // sNm1Code == "QC" } // } else if (nArea == 2) { // Data segments in area 2 are processed here. if (sLoopDesc == "LX") { if (sSegmentID == "LX") // Assigned Number { sLxAssignedNo = oSegment.get_DataElementValue(1, 0); // Assigned Number (554) } else if (sSegmentID == "TRN") // Trace { sValue = oSegment.get_DataElementValue(1, 0); // Trace Type Code (481) sValue = oSegment.get_DataElementValue(2, 0); // Reference Identification (127) sValue = oSegment.get_DataElementValue(3, 0); // Originating Company Identifier (509) sValue = oSegment.get_DataElementValue(4, 0); // Reference Identification (127) } else if (sSegmentID == "STC") // Status Information { sValue = oSegment.get_DataElementValue(1, 1); // Industry Code (1271) sValue = oSegment.get_DataElementValue(1, 2); // Industry Code (1271) sValue = oSegment.get_DataElementValue(1, 3); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(1, 4); // Code List Qualifier Code (1270) sValue = oSegment.get_DataElementValue(2, 0); // Date (373) sValue = oSegment.get_DataElementValue(3, 0); // Action Code (306) sValue = oSegment.get_DataElementValue(4, 0); // Monetary Amount (782) sValue = oSegment.get_DataElementValue(5, 0); // Monetary Amount (782) sValue = oSegment.get_DataElementValue(6, 0); // Date (373) sValue = oSegment.get_DataElementValue(7, 0); // Payment Method Code (591) sValue = oSegment.get_DataElementValue(8, 0); // Date (373) sValue = oSegment.get_DataElementValue(9, 0); // Check Number (429) sValue = oSegment.get_DataElementValue(10, 1); // Industry Code (1271) sValue = oSegment.get_DataElementValue(10, 2); // Industry Code (1271) sValue = oSegment.get_DataElementValue(10, 3); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(10, 4); // Code List Qualifier Code (1270) sValue = oSegment.get_DataElementValue(11, 1); // Industry Code (1271) sValue = oSegment.get_DataElementValue(11, 2); // Industry Code (1271) sValue = oSegment.get_DataElementValue(11, 3); // Entity Identifier Code (98) sValue = oSegment.get_DataElementValue(11, 4); // Code List Qualifier Code (1270) sValue = oSegment.get_DataElementValue(12, 0); // Free-Form Message Text (933) } } else { // // The semantic meaning of the loop "LX;DTP" is dependent on the value of // the code qualifier in data element "374" of the data segment "DTP". The // value of the qualifier has the following semantic meaning for the loop: // // "472" - SERVICE // "368" - SUBMITTAL // if (sLoopDesc == "LX;DTP" && sSegmentID == "DTP") { sLxDtpCode = oSegment.get_DataElementValue(1, 0); } // sLoopDesc == "LX;DTP" && sSegmentID == "DTP" if (sLxDtpCode == "472") { if (sLoopDesc == "LX;DTP") { if (sSegmentID == "DTP") // Date or Time or Period { sValue = oSegment.get_DataElementValue(1, 0); // Date/Time Qualifier (374) sValue = oSegment.get_DataElementValue(2, 0); // Date Time Period Format Qualifier (1250) sValue = oSegment.get_DataElementValue(3, 0); // Date Time Period (1251) } } // sLoopDesc == "LX;DTP" } else if (sLxDtpCode == "368") { if (sLoopDesc == "LX;DTP") { if (sSegmentID == "DTP") // Date or Time or Period { sValue = oSegment.get_DataElementValue(1, 0); // Date/Time Qualifier (374) sValue = oSegment.get_DataElementValue(2, 0); // Date Time Period Format Qualifier (1250) sValue = oSegment.get_DataElementValue(3, 0); // Date Time Period (1251) } else if (sSegmentID == "CAT") // Category of Patient Information Service { sValue = oSegment.get_DataElementValue(1, 0); // Report Type Code (755) sValue = oSegment.get_DataElementValue(2, 0); // Report Transmission Code (756) sValue = oSegment.get_DataElementValue(3, 0); // Version Identifier (799) sValue = oSegment.get_DataElementValue(4, 0); // Code List Qualifier Code (1270) sValue = oSegment.get_DataElementValue(5, 0); // Industry Code (1271) sValue = oSegment.get_DataElementValue(6, 0); // Industry Code (1271) sValue = oSegment.get_DataElementValue(7, 0); // Version Identifier (799) } } else if (sLoopDesc == "LX;DTP;EFI") { if (sSegmentID == "EFI") // Electronic Format Identification { sValue = oSegment.get_DataElementValue(1, 0); // Security Level Code (786) sValue = oSegment.get_DataElementValue(2, 0); // Free-Form Message Text (933) sValue = oSegment.get_DataElementValue(3, 0); // Security Technique Code (797) sValue = oSegment.get_DataElementValue(4, 0); // Version Identifier (799) sValue = oSegment.get_DataElementValue(5, 0); // Program Identifier (802) sValue = oSegment.get_DataElementValue(6, 0); // Version Identifier (799) sValue = oSegment.get_DataElementValue(7, 0); // Interchange Format (801) sValue = oSegment.get_DataElementValue(8, 0); // Version Identifier (799) sValue = oSegment.get_DataElementValue(9, 0); // Compression Technique (800) sValue = oSegment.get_DataElementValue(10, 0); // Drawing Sheet Size Code (789) sValue = oSegment.get_DataElementValue(11, 0); // File Name (803) sValue = oSegment.get_DataElementValue(12, 0); // Block Type (804) sValue = oSegment.get_DataElementValue(13, 0); // Record Length (787) sValue = oSegment.get_DataElementValue(14, 0); // Block Length (788) sValue = oSegment.get_DataElementValue(15, 0); // Version Identifier (799) sValue = oSegment.get_DataElementValue(16, 0); // Filter ID Code (1570) } else if (sSegmentID == "BIN") // Binary Data { if (sLxAssignedNo == "1") { sValue = oSegment.get_DataElementValue(1, 0); // Length of Binary Data (784) oSegment.get_DataElement(2).ExportValue(sPath + @"\export\OutputText.gif"); pictureBox1.Image = oSegment.get_DataElementImageValue(2); pictureBox1.Refresh(); } else if (sLxAssignedNo == "2") { sValue = oSegment.get_DataElementValue(1, 0); // Length of Binary Data (784) oSegment.get_DataElement(2).ExportValue(sPath + @"\export\Output.txt"); textBox1.Text = oSegment.get_DataElementValue(2); textBox1.Refresh(); pictureBox2.Image = oSegment.get_DataElementImageValue(2); pictureBox2.Refresh(); } } } // sLoopDesc == "LX;DTP;EFI" } // sLxDtpCode == "368" } // else } // nArea == 2 // Get the next data segment in the document. ediDataSegment.Set(ref oSegment, oSegment.Next()); } // oSegment != null MessageBox.Show("Done"); // Destroy objects. Not required because objects are automatically destroyed // when the procedure goes off scope. oSchema.Dispose(); oSchemas.Dispose(); oEdiDoc.Dispose(); }