c:edidevexampleshipaa5010csharpcsharp gen834x220a1 ...€¦ ·...

26
1 C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs using System ; using System . Configuration ; using System . Collections . Generic ; using System . ComponentModel ; using System . Data ; using System . Data . SqlClient ; using System . Drawing ; using System . Text ; using System . Windows . Forms ; using Edidev . FrameworkEDIx 64 ; namespace cSharp _ Gen 834 X 220 A 1 { public partial class frmGen 834 : Form { public frmGen 834 () { InitializeComponent () ; } private string sConnection = ConfigurationManager . ConnectionStrings [" Development "]. ConnectionString ; private void btnGenerate _ Click ( object sender , EventArgs e ) { SqlConnection oConnection = new SqlConnection ( sConnection ) ; ediDocument oEdiDoc = null ; ediSchema oSchema = null ; ediSchemas oSchemas = null ; ediInterchange oInterchange = null ; ediGroup oGroup = null ; ediTransactionSet oTransactionSet = null ; ediDataSegment oSegment = null ; string sSql = "" ; string sPath = AppDomain . CurrentDomain . BaseDirectory ; string sEdiFile =" 834 _ 5010 X 220 A 1 . X 12 " ; string sSefFile =" 834 _ 005010 X 220 A 1 . SemRef . EVAL 0 . SEF " ; // EVALUATION SEF FILE // CREATES OEDIDOC OBJECT ediDocument . Set ( ref oEdiDoc , new ediDocument ()) ; // THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED , AND THAT IT DOES // NOT USE ITS BUILT IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE . ediSchemas . Set ( ref oSchemas , ( ediSchemas ) oEdiDoc . GetSchemas ()) ; oSchemas . EnableStandardReference = false ; // ENABLES FORWARD WRITE , AND INCREASES BUFFER I / O TO IMPROVE PERFORMANCE oEdiDoc . CursorType = DocumentCursorTypeConstants . Cursor _ ForwardWrite ; oEdiDoc . set _ Property ( DocumentPropertyIDConstants . Property _ DocumentBufferIO , 2000 ) ; // SET TERMINATORS oEdiDoc . SegmentTerminator =" ~ " ; oEdiDoc . ElementTerminator = "*" ; oEdiDoc . CompositeTerminator = ":" ; // LOADS THE SEF FILE ediSchema . Set ( ref oSchema , ( ediSchema ) oEdiDoc . LoadSchema ( sPath + sSefFile , 0 )) ; sSql =" select * from [ Interchange ]" ; SqlDataAdapter oInterchangeAdapter = new SqlDataAdapter ( sSql , oConnection ) ; DataSet oInterchangeDs = new DataSet (" dsInterchange ") ; oInterchangeAdapter . Fill ( oInterchangeDs , " dsInterchange ") ; foreach ( DataRow oInterchangeRow in oInterchangeDs . Tables [" dsInterchange "]. Rows )

Upload: others

Post on 13-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

1C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

using System;using System.Configuration;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Text;using System.Windows.Forms;using Edidev.FrameworkEDIx64;

namespace cSharp_Gen834X220A1{    public partial class frmGen834 : Form    {        public frmGen834()        {            InitializeComponent();        }

        private string sConnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString;

        private void btnGenerate_Click(object sender, EventArgs e)        {            SqlConnection oConnection = new SqlConnection(sConnection);

            ediDocument oEdiDoc = null;            ediSchema oSchema = null;            ediSchemas oSchemas = null;            ediInterchange oInterchange = null;            ediGroup oGroup = null;            ediTransactionSet oTransactionSet = null;            ediDataSegment oSegment = null;

            string sSql = "";            string sPath = AppDomain.CurrentDomain.BaseDirectory;            string sEdiFile = "834_5010X220A1.X12";            string sSefFile = "834_005010X220A1.SemRef.EVAL0.SEF";  //EVALUATION SEF FILE

            //CREATES OEDIDOC OBJECT            ediDocument.Set(ref oEdiDoc, new ediDocument());

            //THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES             //NOT USE ITS BUILT‐IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE.            ediSchemas.Set(ref oSchemas, (ediSchemas)oEdiDoc.GetSchemas());            oSchemas.EnableStandardReference = false;

            //ENABLES FORWARD WRITE, AND INCREASES BUFFER I/O TO IMPROVE PERFORMANCE            oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardWrite;            oEdiDoc.set_Property(DocumentPropertyIDConstants.Property_DocumentBufferIO, 2000);

            //SET TERMINATORS            oEdiDoc.SegmentTerminator = "~";            oEdiDoc.ElementTerminator = "*";            oEdiDoc.CompositeTerminator = ":";

            //LOADS THE SEF FILE            ediSchema.Set(ref oSchema, (ediSchema)oEdiDoc.LoadSchema(sPath + sSefFile , 0));

            sSql = "select * from [Interchange]";            SqlDataAdapter oInterchangeAdapter = new SqlDataAdapter(sSql, oConnection);            DataSet oInterchangeDs = new DataSet("dsInterchange");            oInterchangeAdapter.Fill(oInterchangeDs, "dsInterchange");

            foreach (DataRow oInterchangeRow in oInterchangeDs.Tables["dsInterchange"].Rows)

Page 2: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

2C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

            {                //CREATES THE ISA SEGMENT                oInterchange = (ediInterchange)oEdiDoc.CreateInterchange("X", "005010");                oSegment = (ediDataSegment)oInterchange.GetDataSegmentHeader();                oSegment.set_DataElementValue(1, 0, oInterchangeRow["ISA01_AuthorizationInfoQlfr"].ToString

());     //Authorization Information Qualifier                oSegment.set_DataElementValue(2, 0, oInterchangeRow["ISA02_AuthorizationInfo"].ToString());

     //Authorization Information                oSegment.set_DataElementValue(3, 0, oInterchangeRow["ISA03_SecurityInfoQlfr"].ToString()); 

    //Security Information Qualifier                oSegment.set_DataElementValue(4, 0, oInterchangeRow["ISA04_SecurityInfo"].ToString());     

//Security Information                oSegment.set_DataElementValue(5, 0, oInterchangeRow["ISA05_SenderIdQlfr"].ToString());     

//Interchange ID Qualifier                oSegment.set_DataElementValue(6, 0, oInterchangeRow["ISA06_SenderId"].ToString());     //

Interchange Sender ID                oSegment.set_DataElementValue(7, 0, oInterchangeRow["ISA07_ReceiverIdQlfr"].ToString());   

  //Interchange ID Qualifier                oSegment.set_DataElementValue(8, 0, oInterchangeRow["ISA08_ReceiverId"].ToString());     //

Interchange Receiver ID                oSegment.set_DataElementValue(9, 0, oInterchangeRow["ISA09_Date"].ToString());     //

Interchange Date                oSegment.set_DataElementValue(10, 0, oInterchangeRow["ISA10_Time"].ToString());     //

Interchange Time                oSegment.set_DataElementValue(11, 0, oInterchangeRow["ISA11_RepetitionSeparator"].ToString

());     //Repetition Separator                oSegment.set_DataElementValue(12, 0, oInterchangeRow["ISA12_ControlVersionNumber"].ToString

());     //Interchange Control Version Number                oSegment.set_DataElementValue(13, 0, oInterchangeRow["ISA13_ControlNumber"].ToString());   

  //Interchange Control Number                oSegment.set_DataElementValue(14, 0, oInterchangeRow["ISA14_AcknowledgmentRequested"].

ToString());     //Acknowledgment Requested                oSegment.set_DataElementValue(15, 0, oInterchangeRow["ISA15_UsageIndicator"].ToString());  

   //Usage Indicator                oSegment.set_DataElementValue(16, 0, oInterchangeRow["ISA16_ComponentElementSeparator"].

ToString());     //Component Element Separator

                sSql = "select * from [FuncGroup] where Interkey = " + oInterchangeRow["Interkey"].ToString();

                SqlDataAdapter oGroupAdapter = new SqlDataAdapter(sSql, oConnection);                DataSet oGroupDs = new DataSet("dsGroup");                oGroupAdapter.Fill(oGroupDs, "dsGroup");

                foreach (DataRow oGroupRow in oGroupDs.Tables["dsGroup"].Rows)                {                    //CREATES THE GS SEGMENT                    oGroup = (ediGroup)oInterchange.CreateGroup("005010X223A2");                    ediDataSegment.Set(ref oSegment, oGroup.GetDataSegmentHeader());                    oSegment.set_DataElementValue(1, 0, oGroupRow["GS01_FunctionalIdfrCode"].ToString());  

   //Functional Identifier Code                    oSegment.set_DataElementValue(2, 0, oGroupRow["GS02_SendersCode"].ToString());     //

Application Sender//s Code                    oSegment.set_DataElementValue(3, 0, oGroupRow["GS03_ReceiversCode"].ToString());     //

Application Receiver//s Code                    oSegment.set_DataElementValue(4, 0, oGroupRow["GS04_Date"].ToString());     //Date                    oSegment.set_DataElementValue(5, 0, oGroupRow["GS05_Time"].ToString());     //Time                    oSegment.set_DataElementValue(6, 0, oGroupRow["GS06_GroupControlNumber"].ToString());  

   //Group Control Number                    oSegment.set_DataElementValue(7, 0, oGroupRow["GS07_ResponsibleAgencyCode"].ToString())

;     //Responsible Agency Code                    oSegment.set_DataElementValue(8, 0, oGroupRow["GS08_VersionReleaseCode"].ToString());  

   //Version / Release / Industry Identifier Code

                    sSql = "select * from [834X220_Header] where Groupkey = " + oGroupRow["Groupkey"].ToString();

                    SqlDataAdapter oDaHeader = new SqlDataAdapter(sSql, oConnection);

Page 3: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

3C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                    DataSet oHeaderDs = new DataSet("dsHeader");                    oDaHeader.Fill(oHeaderDs, "dsHeader");

                    foreach (DataRow oHeaderRow in oHeaderDs.Tables["dsHeader"].Rows)                    {                        //CREATES THE ST SEGMENT                        ediTransactionSet.Set(ref oTransactionSet, (ediTransactionSet)oGroup.

CreateTransactionSet("834"));                        ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

GetDataSegmentHeader());                        oSegment.set_DataElementValue(1, 0, oHeaderRow["ST01_TransactionSetIdentifierCode"]

.ToString());     //Transaction Set Identifier Code                        oSegment.set_DataElementValue(2, 0, oHeaderRow["ST02_TransactionSetControlNumber"].

ToString());     //Transaction Set Control Number                        oSegment.set_DataElementValue(3, 0, oHeaderRow[

"ST03_ImplementationConventionReference"].ToString());     //Implementation Convention Reference

                        //BGN ‐ BEGINNING SEGMENT                        ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.CreateDataSegment

("BGN"));                        oSegment.set_DataElementValue(1, 0, oHeaderRow["BGN01_TransactionSetPurposeCode"].

ToString());     //Transaction Set Purpose Code                        oSegment.set_DataElementValue(2, 0, oHeaderRow["BGN02_TransactionSetReferenceNumber

"].ToString());     //Reference Identification                        oSegment.set_DataElementValue(3, 0, oHeaderRow["BGN03_TransactionSetCreationDate"].

ToString());     //Date                        oSegment.set_DataElementValue(4, 0, oHeaderRow["BGN04_TransactionSetCreationTime"].

ToString());     //Time                        oSegment.set_DataElementValue(5, 0, oHeaderRow["BGN05_TimeZoneCode"].ToString()); 

    // Time Code (623)                         oSegment.set_DataElementValue(6, 0, oHeaderRow[

"BGN06_OriginalTransactionSetReferenceNo"].ToString());     // Reference Identification (127)                         oSegment.set_DataElementValue(8, 0, oHeaderRow["BGN08_ActionCode"].ToString());    

 //Action Code

                        // Transaction Set Policy Number (REF)                         ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("REF"));                        oSegment.set_DataElementValue(1, 0,"38");     // Reference Identification 

Qualifier (128)                         oSegment.set_DataElementValue(2, 0, oHeaderRow["REF02_MasterPolicyNumber"].ToString

());     // Reference Identification (127) 

                        // File Effective Dates                        sSql = "select * from [834X220_FileEffectiveDates] where Headerkey = " + oHeaderRow

["Headerkey"].ToString();                        SqlDataAdapter oDaFileEffectiveDates = new SqlDataAdapter(sSql, oConnection);                        DataSet oFileEffectiveDatesDs = new DataSet("dsFileEffectiveDates");                        oDaFileEffectiveDates.Fill(oFileEffectiveDatesDs, "dsFileEffectiveDates");

                        foreach (DataRow oFileEffectiveDatesRow in oFileEffectiveDatesDs.Tables["dsFileEffectiveDates"].Rows)

                        {                            // File Effective Date (DTP)                             ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("DTP"));                            oSegment.set_DataElementValue(1, 0, oFileEffectiveDatesRow["DTP01_DateTimeQlfr"

].ToString());    // Date/Time Qualifier (374)                             oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period Format 

Qualifier (1250)                             oSegment.set_DataElementValue(3, 0, oFileEffectiveDatesRow["DTP03_DateTime"].

ToString());     // Date Time Period (1251) 

                        }// foreach oFileEffectiveDatesRow

                        // Dependent Total (QTY)                         if (oHeaderRow["QTY02_TransactionSetDependentTotal"].ToString().Trim() != "")                        {

Page 4: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

4C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                            ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("QTY"));                            oSegment.set_DataElementValue(1, 0, "DT");    // Quantity Qualifier (673)                             oSegment.set_DataElementValue(2, 0, oHeaderRow[

"QTY02_TransactionSetDependentTotal"].ToString());    // Quantity (380) 

                        }

                        // Employee Total (QTY)                         if (oHeaderRow["QTY02_TransactionSetEmployeeTotal"].ToString().Trim() != "")                        {                            ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("QTY"));                            oSegment.set_DataElementValue(1, 0, "ET");    // Quantity Qualifier (673)                             oSegment.set_DataElementValue(2, 0, oHeaderRow[

"QTY02_TransactionSetEmployeeTotal"].ToString());     // Quantity (380) 

                        }

                        // Employee Total (QTY)                         if (oHeaderRow["QTY02_TransactionSetTotal"].ToString().Trim() != "")                        {                            ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("QTY"));                            oSegment.set_DataElementValue(1, 0, "TO");    // Quantity Qualifier (673)                             oSegment.set_DataElementValue(2, 0, oHeaderRow["QTY02_TransactionSetTotal"].

ToString());     // Quantity (380) 

                        }                                                //1000A SPONSOR NAME                        ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.CreateDataSegment

(@"N1\N1"));                        oSegment.set_DataElementValue(1, 0, "P5");    // Entity Identifier Code (98)                         oSegment.set_DataElementValue(2, 0, oHeaderRow["N102_PlanSponsorName"].ToString());

     /// Name (93)                         oSegment.set_DataElementValue(3, 0, oHeaderRow["N103_PlanSponsorIdCodeQlfr"].

ToString());     // Identification Code Qualifier (66)                         oSegment.set_DataElementValue(4, 0, oHeaderRow["N104_PlanSponsorIdCode"].ToString

());     //Identification Code

                        //1000B PAYER                        ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.CreateDataSegment

(@"N1\N1"));                        oSegment.set_DataElementValue(1, 0, "IN");    // Entity Identifier Code (98)                         oSegment.set_DataElementValue(2, 0, oHeaderRow["N102_PayerInsurerName"].ToString())

;     /// Name (93)                         oSegment.set_DataElementValue(3, 0, oHeaderRow["N103_PayerInsurerIdCodeQlfr"].

ToString());     // Identification Code Qualifier (66)                         oSegment.set_DataElementValue(4, 0, oHeaderRow["N104_PayerInsurerIdCode"].ToString

());     //Identification Code

                        //1000C BROKER NAME                        if (oHeaderRow["N102_BrokerSalesName"].ToString().Trim() != "")                        {                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"N1\N1"));                            oSegment.set_DataElementValue(1, 0, "BO");    // Entity Identifier Code (98)                             oSegment.set_DataElementValue(2, 0, oHeaderRow["N102_BrokerSalesName"].ToString

());     /// Name (93)                             oSegment.set_DataElementValue(3, 0, oHeaderRow["N103_BrokerSalesIdCodeQlfr"].

ToString());     // Identification Code Qualifier (66)                             oSegment.set_DataElementValue(4, 0, oHeaderRow["N104_BrokerSalesIdCode"].

ToString());     //Identification Code

                            //1100C BROKER ACCOUNT INFORMATION                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment("N1\\ACT\\ACT"));                            oSegment.set_DataElementValue(1, 0, oHeaderRow["ACT01_BrokerSalesAccountNumber"

Page 5: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

5C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

].ToString());    // Account Number (508)                             oSegment.set_DataElementValue(6, 0, oHeaderRow["ACT06_BrokerSalesAccountNumber2

"].ToString());     // Account Number (508) 

                        }

                        //1000C THIRD PARTY ADMIINISTRATOR (TPA) NAME                        if (oHeaderRow["N102_BrokerSalesName"].ToString().Trim() != "")                        {                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"N1\N1"));                            oSegment.set_DataElementValue(1, 0, "TV");    // Entity Identifier Code (98)                             oSegment.set_DataElementValue(2, 0, oHeaderRow["N102_TPA_Name"].ToString());   

  /// Name (93)                             oSegment.set_DataElementValue(3, 0, oHeaderRow["N103_TPA_IdCodeQlfr"].ToString

());     // Identification Code Qualifier (66)                             oSegment.set_DataElementValue(4, 0, oHeaderRow["N104_TPA_IdCode"].ToString()); 

    //Identification Code

                            //1100C TPA ACCOUNT INFORMATION                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment("N1\\ACT\\ACT"));                            oSegment.set_DataElementValue(1, 0, oHeaderRow["ACT01_TPA_AccountNumber"].

ToString());     // Account Number (508)                             oSegment.set_DataElementValue(6, 0, oHeaderRow["ACT06_TPA_AccountNumber2"].

ToString());     // Account Number (508) 

                        }

                        //2000 MEMBER LEVEL DETAIL                        sSql = "select * from [834X220_MemberDetail] where Headerkey = " + oHeaderRow[

"Headerkey"].ToString();                        SqlDataAdapter oDaMemberDetail = new SqlDataAdapter(sSql, oConnection);                        DataSet oDaMemberDetailDs = new DataSet("dsDaMemberDetail");                        oDaMemberDetail.Fill(oDaMemberDetailDs, "dsDaMemberDetail");

                        foreach (DataRow oMemberDetailRow in oDaMemberDetailDs.Tables["dsDaMemberDetail"].Rows)

                        {                                                        //INS ‐ INSURED BENEFIT                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\INS"));                            oSegment.set_DataElementValue(1, 0, oMemberDetailRow["INS01_MemberIndicator"].

ToString());     //Yes/No Condition or Response Code                            oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"INS02_IndividualRelationshipCode"].ToString());     //Individual Relationship Code                            oSegment.set_DataElementValue(3, 0, oMemberDetailRow["INS03_MaintenanceTypeCode

"].ToString());     //Maintenance Type Code                            oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"INS04_MaintenanceReasonCode"].ToString());     //Maintenance Reason Code                            oSegment.set_DataElementValue(5, 0, oMemberDetailRow["INS05_BenefitStatusCode"]

.ToString());     //Benefit Status Code                            oSegment.set_DataElementValue(6, 1, oMemberDetailRow["INS06_01_MedicarePlanCode

"].ToString());     // Medicare Plan Code (1218)                             oSegment.set_DataElementValue(6, 2, oMemberDetailRow[

"INS06_02_MedicareEligibilityReasonCode"].ToString());    // Eligibility Reason Code (1701)                             oSegment.set_DataElementValue(7, 0, oMemberDetailRow["INS07_COBRA_Qualify"].

ToString());     // Consolidated Omnibus Budget Reconciliation Act (COBRA) Qualify (1219)                             oSegment.set_DataElementValue(8, 0, oMemberDetailRow[

"INS08_EmploymentStatusCode"].ToString());     //Employment Status Code                            oSegment.set_DataElementValue(9, 0, oMemberDetailRow["INS09_StudentStatusCode"]

.ToString());     // Student Status Code (1220)                             oSegment.set_DataElementValue(10, 0, oMemberDetailRow["INS10_HandicapIndicator"

].ToString());    // Yes/No Condition or Response Code (1073) 

Page 6: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

6C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                            if (oMemberDetailRow["INS12_MemberIndividualDeathDate"].ToString().Trim() != "")

                            {                                oSegment.set_DataElementValue(11, 0, "D8");     // Date Time Period 

Format Qualifier (1250)                                 oSegment.set_DataElementValue(12, 0, oMemberDetailRow[

"INS12_MemberIndividualDeathDate"].ToString());     // Date Time Period (1251)                             }                            oSegment.set_DataElementValue(13, 0, oMemberDetailRow[

"INS13_ConfidentialityCode"].ToString());     // Confidentiality Code (1165)                             oSegment.set_DataElementValue(17, 0, oMemberDetailRow[

"INS17_BirthSequenceNumber"].ToString());     // Number (1470) 

                            // Subscriber Identifier (REF)                            ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\REF"));                            oSegment.set_DataElementValue(1, 0, "0F");     //Reference Identification 

Qualifier                            oSegment.set_DataElementValue(2, 0, oMemberDetailRow["REF02_SubscriberNumber"].

ToString());     //Reference Identification

                            // Member Group Policy Number (REF)                             if (oMemberDetailRow["REF02_GroupPolicyNumber"].ToString().Trim() != "")                            {                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\REF"));                                oSegment.set_DataElementValue(1, 0, "1L");     //Reference Identification 

Qualifier                                oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"REF02_GroupPolicyNumber"].ToString());     //Reference Identification

                            }

                            // MEMBER SUPPLEMENT ID                            sSql = "select * from [834X220_MemberSupplementId] where Detailkey = " + 

oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberSupplementId = new SqlDataAdapter(sSql, oConnection);                            DataSet oMemberSupplementIdDs = new DataSet("dsMemberSupplementId");                            oDaMemberSupplementId.Fill(oMemberSupplementIdDs, "dsMemberSupplementId");

                            foreach (DataRow oMemberSupplementIdRow in oMemberSupplementIdDs.Tables["dsMemberSupplementId"].Rows)

                            {                                //REF ‐ Member Supplemental Identifier                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\REF"));                                oSegment.set_DataElementValue(1, 0, oMemberSupplementIdRow[

"REF01_ReferenceIdQlfr"].ToString());     //Reference Identification Qualifier                                oSegment.set_DataElementValue(2, 0, oMemberSupplementIdRow[

"REF02_ReferenceId"].ToString());     //Reference Identification

                            } //foreach oMemberSupplementIdRow

                            // MEMBER LEVEL DATES                            sSql = "select * from [834X220_MemberLevelDates] where Detailkey = " + 

oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberLevelDates = new SqlDataAdapter(sSql, oConnection);                            DataSet oMemberLevelDatesDs = new DataSet("dsMemberLevelDates");                            oDaMemberLevelDates.Fill(oMemberLevelDatesDs, "dsMemberLevelDates");

                            foreach (DataRow oMemberLevelDatesRow in oMemberLevelDatesDs.Tables["dsMemberLevelDates"].Rows)

                            {                                // Member Level Dates (DTP)                                 ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

Page 7: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

7C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

CreateDataSegment(@"INS\DTP"));                                oSegment.set_DataElementValue(1, 0, oMemberLevelDatesRow[

"DTP01_DateTimeQlfr"].ToString());     //Date/Time Qualifier                                oSegment.set_DataElementValue(2, 0, "D8");     //Date Time Period Format 

Qualifier                                oSegment.set_DataElementValue(3, 0, oMemberLevelDatesRow["DTP03_DateTime"].

ToString());     //Date Time Period

                            }// foreach oMemberLevelDatesRow                                                                                    //'2100A MEMBER NAME                            if (true)                            {                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"NM101_MemberEntityIdCode"].ToString());     //Entity Identifier Code                                oSegment.set_DataElementValue(2, 0, "1");     //Entity Type Qualifier                                oSegment.set_DataElementValue(3, 0, oMemberDetailRow["NM103_MemberLastName"

].ToString());     //Name Last or Organization Name                                oSegment.set_DataElementValue(4, 0, oMemberDetailRow["NM104_MemberFirstName

"].ToString());     //Name First                                oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"NM105_MemberMiddleName"].ToString());     //Name Middle                                oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"NM106_MemberPrefixName"].ToString());    // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberDetailRow[

"NM107_MemberSuffixtName"].ToString());     // Name Suffix (1039)                                 oSegment.set_DataElementValue(8, 0, oMemberDetailRow[

"NM108_MemberIdCodeQlfr"].ToString());     //Identification Code Qualifier                                oSegment.set_DataElementValue(9, 0, oMemberDetailRow["NM109_MemberIdCode"].

ToString());     //Identification Code

                                //PER ‐ Member Communications Numbers                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\NM1\PER"));                                oSegment.set_DataElementValue(1, 0, "IP");     //Contact Function Code                                oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"PER03_MemberInsuredNumberQlfr"].ToString());     //Communication Number Qualifier                                oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"PER04_MemberInsuredNumber"].ToString());     //Communication Number                                oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"PER05_MemberInsuredNumberQlfr2"].ToString());     //Communication Number Qualifier                                oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"PER06_MemberInsuredNumber2"].ToString());     //Communication Number                                oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"PER07_MemberInsuredNumberQlfr3"].ToString());     //Communication Number Qualifier                                oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"PER08_MemberInsuredNumber3"].ToString());     //Communication Number

                                //N3 ‐ Member Residence Street Address                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\NM1\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow["N301_MemberAddress"].

ToString());     //Address Information                                oSegment.set_DataElementValue(2, 0, oMemberDetailRow["N302_MemberAddress2"]

.ToString());     //Address Information

                                //N4 ‐ Member City, State, ZIP Code                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\NM1\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow["N401_MemberCity"].

ToString());     //City Name                                oSegment.set_DataElementValue(2, 0, oMemberDetailRow["N402_MemberState"].

ToString());     //State or Province Code

Page 8: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

8C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                oSegment.set_DataElementValue(3, 0, oMemberDetailRow["N403_MemberZip"].ToString());     //Postal Code

                                oSegment.set_DataElementValue(4, 0, oMemberDetailRow["N404_MemberCountryCode"].ToString());    // Country Code (26) 

                                oSegment.set_DataElementValue(5, 0, oMemberDetailRow["N405_MemberLocationQlfr"].ToString());     //Location Qualifier

                                oSegment.set_DataElementValue(6, 0, oMemberDetailRow["N406_MemberLocationId"].ToString());     //Location Identifier

                                oSegment.set_DataElementValue(7, 0, oMemberDetailRow["N407_MemberCountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                                //DMG ‐ Member Demographics                                ediDataSegment.Set(ref oSegment, (ediDataSegment)oTransactionSet.

CreateDataSegment(@"INS\NM1\DMG"));                                oSegment.set_DataElementValue(1, 0, "D8");     //Date Time Period Format 

Qualifier                                oSegment.set_DataElementValue(2, 0, oMemberDetailRow["DMG02_MemberBirthDate

"].ToString());     //Date Time Period                                oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"DMG03_MemberGenderCode"].ToString());     //Gender Code                                oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"DMG04_MemberMaritalStatusCode"].ToString());     // Marital Status Code (1067)                                 oSegment.set_DataElementValue(5, 1, oMemberDetailRow[

"DMG05_01_MemberRaceEthnicityCode"].ToString());     // Race or Ethnicity Code (1109)                                 oSegment.set_DataElementValue(5, 2, "RET");     // Code List Qualifier 

Code (1270)                                 oSegment.set_DataElementValue(5, 3, oMemberDetailRow[

"DMG05_03_MemberRaceEthnicityIndustryCode"].ToString());     // Industry Code (1271)                                 oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"DMG06_MemberCitizenshipStatusCode"].ToString());     // Citizenship Status Code (1066)                                 oSegment.set_DataElementValue(10, 0, "REC");     // Code List Qualifier 

Code (1270)                                 oSegment.set_DataElementValue(11, 0, oMemberDetailRow[

"DMG11_MemberRaceEthnicityCollectionCode"].ToString());     // Industry Code (1271) 

                                // Employment Class (EC)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\EC"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"EC01_EmploymentClassCode"].ToString());     // Employment Class Code (1176)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"EC02_EmploymentClassCode2"].ToString());     // Employment Class Code (1176)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"EC03_EmploymentClassCode3"].ToString());     // Employment Class Code (1176)                                                                // Member Income (ICM)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\ICM"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"ICM01_MemberFrequencyCode"].ToString());     // Frequency Code (594)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"ICM02_MemberWageAmount"].ToString());    // Monetary Amount (782)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"ICM03_MemberWorkHoursCount"].ToString());    // Quantity (380)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"ICM04_MemberLocationIdCode"].ToString());    // Location Identifier (310)                                 oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"ICM05_MemberSalaryGrade"].ToString());     // Salary Grade (1214)                                                                 // Member Policy Amounts (AMT)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\AMT"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"AMT01_MemberPolicyQlfr"].ToString());    // Amount Qualifier Code (522)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

Page 9: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

9C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

"AMT02_MemberPolicyContractAmount"].ToString());     // Monetary Amount (782)                                                                 // Member Health Information (HLH)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\HLH"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"HLH01_MemberHealthRelatedCode"].ToString());     // Health‐Related Code (1212)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow["HLH02_MemberHeight"].

ToString());     // Height (65)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow["HLH03_MemberWeight"].

ToString());     // Weight (81)                                                                 // Member Language (LUI)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\LUI"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"LUI01_MemberLanguageQlfr"].ToString());     // Identification Code Qualifier (66)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"LUI02_MemberLanguageCode"].ToString());     // Identification Code (67)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"LUI03_MemberLanguageDescription"].ToString());     // Description (352)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"LUI04_MemberUseLanguageIndicator"].ToString());     // Use of Language Indicator (1303)                                                             }// if Member Name                                                                                  

                            //2100B INCORRECT MEMBER NAME                            if (true)                            {                                // Incorrect Member Name (NM1)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, "70");    // Entity Identifier Code 

(98)                                 oSegment.set_DataElementValue(2, 0, "1");     // Entity Type Qualifier 

(1065)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"NM103_IncorrectMemberLastName"].ToString());     // Name Last or Organization Name (1035)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"NM104_IncorrectMemberFirstName"].ToString());    // Name First (1036)                                 oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"NM105_IncorrectMemberMiddleName"].ToString());     // Name Middle (1037)                                 oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"NM106_IncorrectMemberPrefixName"].ToString());     // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberDetailRow[

"NM107_IncorrectMemberSuffixtName"].ToString());     // Name Suffix (1039)                                 oSegment.set_DataElementValue(8, 0, oMemberDetailRow[

"NM108_IncorrectMemberIdCodeQlfr"].ToString());     // Identification Code Qualifier (66)                                 oSegment.set_DataElementValue(9, 0, oMemberDetailRow[

"NM109_IncorrectMemberIdCode"].ToString());     // Identification Code (67) 

                                // Incorrect Member Demographics (DMG)                                ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\DMG"));                                oSegment.set_DataElementValue(1, 0, "D8");    // Date Time Period Format 

Qualifier (1250)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"DMG02_IncorrectMemberBirthDate"].ToString());    // Date Time Period (1251)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"DMG03_IncorrectMemberGenderCode"].ToString());     // Gender Code (1068)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"DMG04_IncorrectMemberMaritalStatusCode"].ToString());    // Marital Status Code (1067)                                 oSegment.set_DataElementValue(5, 1, oMemberDetailRow[

"DMG05_01_IncorrectMemberRaceEthnicityCode"].ToString());     // Race or Ethnicity Code (1109) 

Page 10: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

10C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                oSegment.set_DataElementValue(5, 2, "RET");     // Code List Qualifier Code (1270) 

                                oSegment.set_DataElementValue(5, 3, oMemberDetailRow["DMG05_03_IncorrectMemberRaceEthnicityIndustryCode"].ToString());     // Industry Code (1271) 

                                oSegment.set_DataElementValue(6, 0, oMemberDetailRow["DMG06_IncorrectMemberCitizenshipStatusCode"].ToString());    // Citizenship Status Code (1066) 

                                oSegment.set_DataElementValue(10, 0, "REC");     // Code List Qualifier Code (1270) 

                                oSegment.set_DataElementValue(11, 0, oMemberDetailRow["DMG11_IncorrectMemberRaceEthnicityCollectionCode"].ToString());     // Industry Code (1271) 

                            }// if Incorrect Member Name

                            // 2100C MEMBER MAILING ADDRESS                            if (true)                            {                                // Member Mailing Address (NM1)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                          oSegment.set_DataElementValue(1, 0, "31");    // Entity Identifier Code 

(98)                           oSegment.set_DataElementValue(2, 0, "1");     // Entity Type Qualifier 

(1065)                                                     // Member Mail Street Address (N3)                           ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"N301_MemberMailAddress"].ToString());    // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"N302_MemberMailAddress2"].ToString());     // Address Information (166) 

                          // Member Mail City, State, ZIP Code (N4)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow["N401_MemberMailCity"]

.ToString());     // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow["N402_MemberMailState"

].ToString());    // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow["N403_MemberMailZip"].

ToString());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"N404_MemberMailCountryCode"].ToString());    // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberDetailRow[

"N407_MemberMailCountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                            }// if Mailing Address

                                                        // 2100D MEMBER EMPLOYER                            sSql = "select * from [834X220_MemberEmployerSchool] where 

NM101_EntityIdentifierCode = '36' and Detailkey = " + oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberEmployer = new SqlDataAdapter(sSql, oConnection);                            DataSet oMemberEmployerDs = new DataSet("dsMemberEmployer");                            oDaMemberEmployer.Fill(oMemberEmployerDs, "dsMemberEmployer");

                            foreach (DataRow oMemberEmployerRow in oMemberEmployerDs.Tables["dsMemberEmployer"].Rows)

                            {                                ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, oMemberEmployerRow[

"NM101_EntityIdentifierCode"].ToString());    // Entity Identifier Code (98)                                 oSegment.set_DataElementValue(2, 0, oMemberEmployerRow[

"NM102_EntityType_Qualifier"].ToString());    // Entity Type Qualifier (1065) 

Page 11: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

11C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                oSegment.set_DataElementValue(3, 0, oMemberEmployerRow["NM103_NameLastOrganizationName"].ToString());    // Name Last or Organization Name (1035) 

                                oSegment.set_DataElementValue(4, 0, oMemberEmployerRow["NM104_NameFirst"].ToString());     // Name First (1036) 

                                oSegment.set_DataElementValue(5, 0, oMemberEmployerRow["NM105_NameMiddle"].ToString());     // Name Middle (1037) 

                                oSegment.set_DataElementValue(6, 0, oMemberEmployerRow["NM106_NamePrefix"].ToString());     // Name Prefix (1038) 

                                oSegment.set_DataElementValue(7, 0, oMemberEmployerRow["NM107_NameSuffix"].ToString());     // Name Suffix (1039) 

                                oSegment.set_DataElementValue(8, 0, oMemberEmployerRow["NM108_IdentificationCodeQlfr"].ToString());     // Identification Code Qualifier (66) 

                                oSegment.set_DataElementValue(9, 0, oMemberEmployerRow["NM109_IdentificationCode"].ToString());     // Identification Code (67) 

                                //Member Employer Communications Numbers (PER)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\PER"));                                oSegment.set_DataElementValue(1, 0, oMemberEmployerRow[

"PER01_Contact_Function_Code"].ToString());     // Contact Function Code (366)                                 oSegment.set_DataElementValue(2, 0, oMemberEmployerRow["PER02_Name"].

ToString());     // Name (93)                                 oSegment.set_DataElementValue(3, 0, oMemberEmployerRow[

"PER03_CommunicationNumberQlfr"].ToString());     // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(4, 0, oMemberEmployerRow[

"PER04_CommunicationNumber"].ToString());     // Communication Number (364)                                 oSegment.set_DataElementValue(5, 0, oMemberEmployerRow[

"PER05_CommunicationNumberQlfr2"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(6, 0, oMemberEmployerRow[

"PER06_CommunicationNumber2"].ToString());    // Communication Number (364)                                 oSegment.set_DataElementValue(7, 0, oMemberEmployerRow[

"PER07_CommunicationNumberQlfr3"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(8, 0, oMemberEmployerRow[

"PER08_CommunicationNumber3"].ToString());    // Communication Number (364) 

                                //Member Employer Street Address (N3)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberEmployerRow["N301_Address1"].

ToString());     // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberEmployerRow["N302_Address2"].

ToString());     // Address Information (166) 

                                //Member Employer City, State, ZIP Code                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberEmployerRow["N401_City"].

ToString());     // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberEmployerRow["N402_State"].

ToString());     // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberEmployerRow["N403_Zip"].ToString

());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberEmployerRow["N404_CountryCode"].

ToString());     // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberEmployerRow[

"N407_CountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                            }// foreach oMemberEmployerSchoolRow

                                                       // 2100E MEMBER SCHOOL                            sSql = "select * from [834X220_MemberEmployerSchool] where 

NM101_EntityIdentifierCode = '36' and Detailkey = " + oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberSchool = new SqlDataAdapter(sSql, oConnection);                            DataSet oMemberSchoolDs = new DataSet("dsMemberSchool");                            oDaMemberSchool.Fill(oMemberSchoolDs, "dsMemberSchool");

Page 12: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

12C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                            foreach (DataRow oMemberSchoolRow in oMemberSchoolDs.Tables["dsMemberSchool"].Rows)

                            {                                ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, oMemberSchoolRow[

"NM101_EntityIdentifierCode"].ToString());    // Entity Identifier Code (98)                                 oSegment.set_DataElementValue(2, 0, oMemberSchoolRow[

"NM102_EntityType_Qualifier"].ToString());    // Entity Type Qualifier (1065)                                 oSegment.set_DataElementValue(3, 0, oMemberSchoolRow[

"NM103_NameLastOrganizationName"].ToString());    // Name Last or Organization Name (1035)                                 oSegment.set_DataElementValue(4, 0, oMemberSchoolRow["NM104_NameFirst"].

ToString());     // Name First (1036)                                 oSegment.set_DataElementValue(5, 0, oMemberSchoolRow["NM105_NameMiddle"].

ToString());     // Name Middle (1037)                                 oSegment.set_DataElementValue(6, 0, oMemberSchoolRow["NM106_NamePrefix"].

ToString());     // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberSchoolRow["NM107_NameSuffix"].

ToString());     // Name Suffix (1039)                                 oSegment.set_DataElementValue(8, 0, oMemberSchoolRow[

"NM108_IdentificationCodeQlfr"].ToString());     // Identification Code Qualifier (66)                                 oSegment.set_DataElementValue(9, 0, oMemberSchoolRow[

"NM109_IdentificationCode"].ToString());     // Identification Code (67) 

                                //Member Employer Communications Numbers (PER)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\PER"));                                oSegment.set_DataElementValue(1, 0, oMemberSchoolRow[

"PER01_Contact_Function_Code"].ToString());     // Contact Function Code (366)                                 oSegment.set_DataElementValue(2, 0, oMemberSchoolRow["PER02_Name"].ToString

());     // Name (93)                                 oSegment.set_DataElementValue(3, 0, oMemberSchoolRow[

"PER03_CommunicationNumberQlfr"].ToString());     // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(4, 0, oMemberSchoolRow[

"PER04_CommunicationNumber"].ToString());     // Communication Number (364)                                 oSegment.set_DataElementValue(5, 0, oMemberSchoolRow[

"PER05_CommunicationNumberQlfr2"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(6, 0, oMemberSchoolRow[

"PER06_CommunicationNumber2"].ToString());    // Communication Number (364)                                 oSegment.set_DataElementValue(7, 0, oMemberSchoolRow[

"PER07_CommunicationNumberQlfr3"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(8, 0, oMemberSchoolRow[

"PER08_CommunicationNumber3"].ToString());    // Communication Number (364) 

                                //Member Employer Street Address (N3)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberSchoolRow["N301_Address1"].

ToString());     // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberSchoolRow["N302_Address2"].

ToString());     // Address Information (166) 

                                //Member Employer City, State, ZIP Code                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment("INS\\

NM1\\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberSchoolRow["N401_City"].ToString

());     // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberSchoolRow["N402_State"].ToString

());     // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberSchoolRow["N403_Zip"].ToString

());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberSchoolRow["N404_CountryCode"].

ToString());     // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberSchoolRow[

"N407_CountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

Page 13: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

13C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                            }

                            // 2100F CUSTODIAL PARENT / 2100G RESPONSIBLE PERSON                            sSql = "select * from [834X220_MemberCustodialResponsiblePerson] where 

NM101_EntityIdentifierCode = 'S3' AND Detailkey = " + oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberCustodialParent = new SqlDataAdapter(sSql, oConnection)

;                            DataSet oMemberCustodialParentDs = new DataSet("dsMemberCustodialParent");                            oDaMemberCustodialParent.Fill(oMemberCustodialParentDs, 

"dsMemberCustodialParent");

                            foreach (DataRow oMemberCustodialParentRow in oMemberCustodialParentDs.Tables["dsMemberCustodialParent"].Rows)

                            {                                // Custodial Parent (NM1)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, oMemberCustodialParentRow[

"NM101_EntityIdentifierCode"].ToString());    // Entity Identifier Code (98)                                 oSegment.set_DataElementValue(2, 0, oMemberCustodialParentRow[

"NM102_EntityType_Qualifier"].ToString());    // Entity Type Qualifier (1065)                                 oSegment.set_DataElementValue(3, 0, oMemberCustodialParentRow[

"NM103_NameLastOrganizationName"].ToString());    // Name Last or Organization Name (1035)                                 oSegment.set_DataElementValue(4, 0, oMemberCustodialParentRow[

"NM104_NameFirst"].ToString());     // Name First (1036)                                 oSegment.set_DataElementValue(5, 0, oMemberCustodialParentRow[

"NM105_NameMiddle"].ToString());     // Name Middle (1037)                                 oSegment.set_DataElementValue(6, 0, oMemberCustodialParentRow[

"NM106_NamePrefix"].ToString());     // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberCustodialParentRow[

"NM107_NameSuffix"].ToString());     // Name Suffix (1039)                                 oSegment.set_DataElementValue(8, 0, oMemberCustodialParentRow[

"NM108_IdentificationCodeQlfr"].ToString());     // Identification Code Qualifier (66)                                 oSegment.set_DataElementValue(9, 0, oMemberCustodialParentRow[

"NM109_IdentificationCode"].ToString());     // Identification Code (67)                                                                 // Custodial Parent Communications Numbers (PER)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\PER"));                                oSegment.set_DataElementValue(1, 0, oMemberCustodialParentRow[

"PER01_Contact_Function_Code"].ToString());     // Contact Function Code (366)                                 oSegment.set_DataElementValue(2, 0, oMemberCustodialParentRow["PER02_Name"]

.ToString());     // Name (93)                                 oSegment.set_DataElementValue(3, 0, oMemberCustodialParentRow[

"PER03_CommunicationNumberQlfr"].ToString());     // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(4, 0, oMemberCustodialParentRow[

"PER04_CommunicationNumber"].ToString());     // Communication Number (364)                                 oSegment.set_DataElementValue(5, 0, oMemberCustodialParentRow[

"PER05_CommunicationNumberQlfr2"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(6, 0, oMemberCustodialParentRow[

"PER06_CommunicationNumber2"].ToString());    // Communication Number (364)                                 oSegment.set_DataElementValue(7, 0, oMemberCustodialParentRow[

"PER07_CommunicationNumberQlfr3"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(8, 0, oMemberCustodialParentRow[

"PER08_CommunicationNumber3"].ToString());    // Communication Number (364)                                                                 // Custodial Parent Street Address (N3)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberCustodialParentRow[

"N301_Address1"].ToString());     // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberCustodialParentRow[

"N302_Address2"].ToString());     // Address Information (166) 

Page 14: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

14C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                // Custodial Parent City, State, ZIP Code (N4)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberCustodialParentRow["N401_City"].

ToString());     // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberCustodialParentRow["N402_State"]

.ToString());     // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberCustodialParentRow["N403_Zip"].

ToString());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberCustodialParentRow[

"N404_CountryCode"].ToString());     // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberCustodialParentRow[

"N407_CountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                            }

                            // 2100G RESPONSIBLE PERSON                            sSql = "select * from [834X220_MemberCustodialResponsiblePerson] where 

NM101_EntityIdentifierCode <> 'S3' AND Detailkey = " + oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberResponsiblePerson = new SqlDataAdapter(sSql, 

oConnection);                            DataSet oMemberResponsiblePersonDs = new DataSet("dsMemberResponsiblePerson");                            oDaMemberResponsiblePerson.Fill(oMemberResponsiblePersonDs, 

"dsMemberResponsiblePerson");

                            foreach (DataRow oMemberResponsiblePersonRow in oMemberResponsiblePersonDs.Tables["dsMemberResponsiblePerson"].Rows)

                            {                                // Custodial Parent (NM1)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\NM1"));                                oSegment.set_DataElementValue(1, 0, oMemberResponsiblePersonRow[

"NM101_EntityIdentifierCode"].ToString());    // Entity Identifier Code (98)                                 oSegment.set_DataElementValue(2, 0, oMemberResponsiblePersonRow[

"NM102_EntityType_Qualifier"].ToString());    // Entity Type Qualifier (1065)                                 oSegment.set_DataElementValue(3, 0, oMemberResponsiblePersonRow[

"NM103_NameLastOrganizationName"].ToString());    // Name Last or Organization Name (1035)                                 oSegment.set_DataElementValue(4, 0, oMemberResponsiblePersonRow[

"NM104_NameFirst"].ToString());     // Name First (1036)                                 oSegment.set_DataElementValue(5, 0, oMemberResponsiblePersonRow[

"NM105_NameMiddle"].ToString());     // Name Middle (1037)                                 oSegment.set_DataElementValue(6, 0, oMemberResponsiblePersonRow[

"NM106_NamePrefix"].ToString());     // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberResponsiblePersonRow[

"NM107_NameSuffix"].ToString());     // Name Suffix (1039)                                 oSegment.set_DataElementValue(8, 0, oMemberResponsiblePersonRow[

"NM108_IdentificationCodeQlfr"].ToString());     // Identification Code Qualifier (66)                                 oSegment.set_DataElementValue(9, 0, oMemberResponsiblePersonRow[

"NM109_IdentificationCode"].ToString());     // Identification Code (67)                                                                 // Custodial Parent Communications Numbers (PER)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\PER"));                                oSegment.set_DataElementValue(1, 0, oMemberResponsiblePersonRow[

"PER01_Contact_Function_Code"].ToString());     // Contact Function Code (366)                                 oSegment.set_DataElementValue(2, 0, oMemberResponsiblePersonRow["PER02_Name

"].ToString());     // Name (93)                                 oSegment.set_DataElementValue(3, 0, oMemberResponsiblePersonRow[

"PER03_CommunicationNumberQlfr"].ToString());     // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(4, 0, oMemberResponsiblePersonRow[

"PER04_CommunicationNumber"].ToString());     // Communication Number (364)                                 oSegment.set_DataElementValue(5, 0, oMemberResponsiblePersonRow[

"PER05_CommunicationNumberQlfr2"].ToString());    // Communication Number Qualifier (365)                                 oSegment.set_DataElementValue(6, 0, oMemberResponsiblePersonRow[

"PER06_CommunicationNumber2"].ToString());    // Communication Number (364) 

Page 15: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

15C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                oSegment.set_DataElementValue(7, 0, oMemberResponsiblePersonRow["PER07_CommunicationNumberQlfr3"].ToString());    // Communication Number Qualifier (365) 

                                oSegment.set_DataElementValue(8, 0, oMemberResponsiblePersonRow["PER08_CommunicationNumber3"].ToString());    // Communication Number (364) 

                                                                // Custodial Parent Street Address (N3)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberResponsiblePersonRow[

"N301_Address1"].ToString());     // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberResponsiblePersonRow[

"N302_Address2"].ToString());     // Address Information (166) 

                                // Custodial Parent City, State, ZIP Code (N4)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberResponsiblePersonRow["N401_City"

].ToString());    // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberResponsiblePersonRow["N402_State

"].ToString());     // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberResponsiblePersonRow["N403_Zip"]

.ToString());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberResponsiblePersonRow[

"N404_CountryCode"].ToString());     // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberResponsiblePersonRow[

"N407_CountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                            }

                            // 2100H  DROP OFF LOCATION                            if (true)                            {                                // Drop Off Location (NM1)                                 oSegment = oTransactionSet.CreateDataSegment(@"INS\NM1\NM1");                                oSegment.set_DataElementValue(1, 0, "45");    // Entity Identifier Code 

(98)                                 oSegment.set_DataElementValue(2, 0, "1");     // Entity Type Qualifier 

(1065)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

"NM103_MemberDropOffLocationLastName"].ToString());     // Name Last or Organization Name (1035)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"NM104_MemberDropOffLocationFirstName"].ToString());     // Name First (1036)                                 oSegment.set_DataElementValue(5, 0, oMemberDetailRow[

"NM105_MemberDropOffLocationMiddleName"].ToString());     // Name Middle (1037)                                 oSegment.set_DataElementValue(6, 0, oMemberDetailRow[

"NM106_MemberDropOffLocationPrefixName"].ToString());     // Name Prefix (1038)                                 oSegment.set_DataElementValue(7, 0, oMemberDetailRow[

"NM107_MemberDropOffLocationSuffixtName"].ToString());    // Name Suffix (1039)                                                                 // Drop Off Location Street Address (N3)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N3"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"N301_MemberDropOffLocationAddress"].ToString());     // Address Information (166)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"N302_MemberDropOffLocationAddress2"].ToString());    // Address Information (166) 

                                // Drop Off Location City, State, ZIP Code (N4)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

NM1\N4"));                                oSegment.set_DataElementValue(1, 0, oMemberDetailRow[

"N401_MemberDropOffLocationCity"].ToString());    // City Name (19)                                 oSegment.set_DataElementValue(2, 0, oMemberDetailRow[

"N402_MemberDropOffLocationState"].ToString());     // State or Province Code (156)                                 oSegment.set_DataElementValue(3, 0, oMemberDetailRow[

Page 16: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

16C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

"N403_MemberDropOffLocationZip"].ToString());     // Postal Code (116)                                 oSegment.set_DataElementValue(4, 0, oMemberDetailRow[

"N404_MemberDropOffLocationCountryCode"].ToString());     // Country Code (26)                                 oSegment.set_DataElementValue(7, 0, oMemberDetailRow[

"N407_MemberDropOffLocationCountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                            }

                            // 2200 DISABILITY INFORMATION                            sSql = "select * from [834X220_DisabilityInfo] where Detailkey = " + 

oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaDisabilityInfo = new SqlDataAdapter(sSql, oConnection);                            DataSet oDisabilityInfoDs = new DataSet("dsDisabilityInfo");                            oDaDisabilityInfo.Fill(oDisabilityInfoDs, "dsDisabilityInfo");

                            foreach (DataRow oDisabilityInfoRow in oDisabilityInfoDs.Tables["dsDisabilityInfo"].Rows)

                            {                                // Disability Information (DSB)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\

DSB\DSB"));                                oSegment.set_DataElementValue(1, 0, oDisabilityInfoRow[

"DSB01_DisabilityTypeCode"].ToString());     // Disability Type Code (1146)                                 oSegment.set_DataElementValue(7, 0, oDisabilityInfoRow[

"DSB07_ProductServiceIdQlfr"].ToString());    // Product/Service ID Qualifier (235)                                 oSegment.set_DataElementValue(8, 0, oDisabilityInfoRow[

"DSB08_MedicalCodeValue"].ToString());    // Medical Code Value (1137) 

                                // Initial Disability Period Start                                if (oDisabilityInfoRow["DTP03_InitialDisabilityStartDate"].ToString().Trim

() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\DSB\DTP"));                                    oSegment.set_DataElementValue(1, 0, "360");     // Date/Time 

Qualifier (374)                                     oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period 

Format Qualifier (1250)                                     oSegment.set_DataElementValue(3, 0, oDisabilityInfoRow[

"DTP03_InitialDisabilityStartDate"].ToString());     // Date Time Period (1251)                                 }                                                                // Initial Disability Period End                                if (oDisabilityInfoRow["DTP03_InitialDisabilityEndDate"].ToString().Trim() 

!= "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\DSB\DTP"));                                    oSegment.set_DataElementValue(1, 0, "361");     // Date/Time 

Qualifier (374)                                     oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period 

Format Qualifier (1250)                                     oSegment.set_DataElementValue(3, 0, oDisabilityInfoRow[

"DTP03_InitialDisabilityEndDate"].ToString());    // Date Time Period (1251)                                 }                                                            }// foreach oDisabilityInfoRow

                            // 2300 HEALTH COVERAGE                            sSql = "select * from [834X220_HealthCoverage] where Detailkey = " + 

oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaHealthCoverage = new SqlDataAdapter(sSql, oConnection);                            DataSet oHealthCoverageDs = new DataSet("dsHealthCoverage");                            oDaHealthCoverage.Fill(oHealthCoverageDs, "dsHealthCoverage");

Page 17: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

17C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                            foreach (DataRow oHealthCoverageRow in oHealthCoverageDs.Tables["dsHealthCoverage"].Rows)

                            {                                // Health Coverage (HD)                                 ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\HD

\HD"));                                oSegment.set_DataElementValue(1, 0, oHealthCoverageRow[

"HD01_MaintenanceTypeCode"].ToString());     // Maintenance Type Code (875)                                 oSegment.set_DataElementValue(3, 0, oHealthCoverageRow[

"HD03_InsuranceLineCode"].ToString());    // Insurance Line Code (1205)                                 oSegment.set_DataElementValue(4, 0, oHealthCoverageRow[

"HD04_Plan_Coverage_Description"].ToString());    // Plan Coverage Description (1204)                                 oSegment.set_DataElementValue(5, 0, oHealthCoverageRow[

"HD05_CoverageLevelCode"].ToString());    // Coverage Level Code (1207)                                 oSegment.set_DataElementValue(9, 0, oHealthCoverageRow[

"HD09_LateEnrollmentIndicator"].ToString());     // Yes/No Condition or Response Code (1073)                                                                 // Health Coverage Dates (DTP)                                 // Benefit Begin                                if (oHealthCoverageRow["DTP03_BenefitBeginDate"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\DTP"));                                    oSegment.set_DataElementValue(1, 0, "348");     // Date/Time 

Qualifier (374)                                     oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period 

Format Qualifier (1250)                                     oSegment.set_DataElementValue(3, 0, oHealthCoverageRow[

"DTP03_BenefitBeginDate"].ToString());    // Date Time Period (1251)                                 }

                                // Benefit End                                if (oHealthCoverageRow["DTP03_BenefitEndDate"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\DTP"));                                    oSegment.set_DataElementValue(1, 0, "348");     // Date/Time 

Qualifier (374)                                     oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period 

Format Qualifier (1250)                                     oSegment.set_DataElementValue(3, 0, oHealthCoverageRow[

"DTP03_BenefitEndDate"].ToString());     // Date Time Period (1251)                                 }

                                // Enrollment Signature Date                                if (oHealthCoverageRow["DTP03_EnrollmentSignDate"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\DTP"));                                    oSegment.set_DataElementValue(1, 0, "300");     // Date/Time 

Qualifier (374)                                     oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period 

Format Qualifier (1250)                                     oSegment.set_DataElementValue(3, 0, oHealthCoverageRow[

"DTP03_EnrollmentSignDate"].ToString());     // Date Time Period (1251)                                 }

                                // Last Premium Paid Date                                if (oHealthCoverageRow["DTP03_LastPremiumPaidDate"].ToString().Trim() != 

"")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\DTP"));                                    oSegment.set_DataElementValue(1, 0, "543");     // Date/Time 

Qualifier (374) 

Page 18: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

18C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                    oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period Format Qualifier (1250) 

                                    oSegment.set_DataElementValue(3, 0, oHealthCoverageRow["DTP03_LastPremiumPaidDate"].ToString());     // Date Time Period (1251) 

                                }                                

                                // Health Coverage Policy (AMT)                                 // Co‐insurance ‐ Actual                                if (oHealthCoverageRow["AMT02_CoInsuranceAmount"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\AMT"));                                    oSegment.set_DataElementValue(1, 0, "B9");    // Amount Qualifier 

Code (522)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"AMT02_CoInsuranceAmount"].ToString());     // Monetary Amount (782)                                 }

                                // Co‐Payment Amount                                if (oHealthCoverageRow["AMT02_CoPaymentAmount"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\AMT"));                                    oSegment.set_DataElementValue(1, 0, "C1");    // Amount Qualifier 

Code (522)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"AMT02_CoPaymentAmount"].ToString());     // Monetary Amount (782)                                 }

                                // Deductible Amount                                if (oHealthCoverageRow["AMT02_DeductibleAmount"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\AMT"));                                    oSegment.set_DataElementValue(1, 0, "D2");    // Amount Qualifier 

Code (522)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"AMT02_DeductibleAmount"].ToString());    // Monetary Amount (782)                                 }

                                // Premium Amount                                if (oHealthCoverageRow["AMT02_PremiumAmount"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\AMT"));                                    oSegment.set_DataElementValue(1, 0, "P3");    // Amount Qualifier 

Code (522)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"AMT02_PremiumAmount"].ToString());     // Monetary Amount (782)                                 }

                                // Spend Down                                if (oHealthCoverageRow["AMT02_SpenDownAmount"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\AMT"));                                    oSegment.set_DataElementValue(1, 0, "R");     // Amount Qualifier 

Code (522)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"AMT02_SpenDownAmount"].ToString());     // Monetary Amount (782)                                 }

                                                                // Health Coverage Policy Number (REF)                                 // Group or Policy Number

Page 19: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

19C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                if (oHealthCoverageRow["REF02_GroupPolicyNumber"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\REF"));                                    oSegment.set_DataElementValue(1, 0, "1L");    // Reference 

Identification Qualifier (128)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"REF02_GroupPolicyNumber"].ToString());     // Reference Identification (127)                                 }

                                // Internal Control Number                                if (oHealthCoverageRow["REF02_InternalControlNumber"].ToString().Trim() != 

"")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\REF"));                                    oSegment.set_DataElementValue(1, 0, "X9");    // Reference 

Identification Qualifier (128)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"REF02_InternalControlNumber"].ToString());     // Reference Identification (127)                                 }

                                // Issuer Number                                if (oHealthCoverageRow["REF02_IssuerNumber"].ToString().Trim() != "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\REF"));                                    oSegment.set_DataElementValue(1, 0, "XM");    // Reference 

Identification Qualifier (128)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"REF02_IssuerNumber"].ToString());    // Reference Identification (127)                                 }

                                                                // Prior Coverage Months (REF)                                 // Issuer Number                                if (oHealthCoverageRow["REF02_PriorCoverageMonthCount"].ToString().Trim() !

= "")                                {                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\REF"));                                    oSegment.set_DataElementValue(1, 0, "QQ");    // Reference 

Identification Qualifier (128)                                     oSegment.set_DataElementValue(2, 0, oHealthCoverageRow[

"REF02_PriorCoverageMonthCount"].ToString());     // Reference Identification (127)                                 }

                                // Identification Card                                 sSql = "select * from [834X220_IdCard] where HealthCoverageKey = " + 

oHealthCoverageRow["HealthCoverageKey"].ToString();                                SqlDataAdapter oDaIdCard = new SqlDataAdapter(sSql, oConnection);                                DataSet oIdCardDs = new DataSet("dsIdCard");                                oDaIdCard.Fill(oIdCardDs, "dsIdCard");

                                foreach (DataRow oIdCardRow in oIdCardDs.Tables["dsIdCard"].Rows)                                {                                    // Identification Card (IDC)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\IDC"));                                    oSegment.set_DataElementValue(1, 0, oIdCardRow[

"IDC01_PlanCoverageDescription"].ToString());     // Plan Coverage Description (1204)                                     oSegment.set_DataElementValue(2, 0, oIdCardRow[

"IDC02_IdentificationCardTypeCode"].ToString());     // Identification Card Type Code (1215)                                     oSegment.set_DataElementValue(3, 0, oIdCardRow["IDC03_IdCardCount"].

ToString());     // Quantity (380)                                     oSegment.set_DataElementValue(4, 0, oIdCardRow["IDC04_ActionCode"].

Page 20: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

20C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

ToString());     // Action Code (306) 

                                }// foreach oIdCardRow

                                // 2310 PROVIDER INFORMATION                                 sSql = "select * from [834X220_ProviderInfo] where HealthCoverageKey = " + 

oHealthCoverageRow["HealthCoverageKey"].ToString();                                SqlDataAdapter oDaProviderInfo = new SqlDataAdapter(sSql, oConnection);                                DataSet oProviderInfoDs = new DataSet("dsProviderInfo");                                oDaProviderInfo.Fill(oProviderInfoDs, "dsProviderInfo");

                                foreach (DataRow oProviderInfoRow in oProviderInfoDs.Tables["dsProviderInfo"].Rows)

                                {                                    // Provider Information (LX)                                     oSegment = oTransactionSet.CreateDataSegment(@"INS\HD\LX\LX");                                    oSegment.set_DataElementValue(1, 0, oProviderInfoRow[

"LX01_Assigned_Number"].ToString());     // Assigned Number (554) 

                                    // Provider Name (NM1)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\LX\NM1"));                                    oSegment.set_DataElementValue(1, 0, oProviderInfoRow[

"NM101_EntityIdentifierCode"].ToString());    // Entity Identifier Code (98)                                     oSegment.set_DataElementValue(2, 0, oProviderInfoRow[

"NM102_EntityTyp_Qualifier"].ToString());     // Entity Type Qualifier (1065)                                     oSegment.set_DataElementValue(3, 0, oProviderInfoRow[

"NM103_ProvideNameLastOrganization"].ToString());     // Name Last or Organization Name (1035)                                     oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"NM104_ProvideNameFirst"].ToString());    // Name First (1036)                                     oSegment.set_DataElementValue(5, 0, oProviderInfoRow[

"NM105_ProvideNameMiddle"].ToString());     // Name Middle (1037)                                     oSegment.set_DataElementValue(6, 0, oProviderInfoRow[

"NM106_ProvideNamePrefix"].ToString());     // Name Prefix (1038)                                     oSegment.set_DataElementValue(7, 0, oProviderInfoRow[

"NM107_ProvideNameSuffix"].ToString());     // Name Suffix (1039)                                     oSegment.set_DataElementValue(8, 0, oProviderInfoRow[

"NM108_ProvideIdQlfr"].ToString());     // Identification Code Qualifier (66)                                     oSegment.set_DataElementValue(9, 0, oProviderInfoRow["NM109_ProvideId"]

.ToString());     // Identification Code (67)                                     oSegment.set_DataElementValue(10, 0, oProviderInfoRow[

"NM110_EntityRelationshipCode"].ToString());     // Entity Relationship Code (706)                                                                         // Provider Address (N3)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\LX\N3"));                                    oSegment.set_DataElementValue(1, 0, oProviderInfoRow[

"N301_ProvideAddress"].ToString());     // Address Information (166)                                     oSegment.set_DataElementValue(2, 0, oProviderInfoRow[

"N302_ProvideAddress2"].ToString());     // Address Information (166) 

                                    // Provider City, State, ZIP Code (N4)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\LX\N4"));                                    oSegment.set_DataElementValue(1, 0, oProviderInfoRow["N401_ProvideCity"

].ToString());    // City Name (19)                                     oSegment.set_DataElementValue(2, 0, oProviderInfoRow["N402_ProvideState

"].ToString());     // State or Province Code (156)                                     oSegment.set_DataElementValue(3, 0, oProviderInfoRow["N403_ProvideZip"]

.ToString());     // Postal Code (116)                                     oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"N404_ProvideCountryCode"].ToString());     // Country Code (26)                                     oSegment.set_DataElementValue(7, 0, oProviderInfoRow[

"N407_ProvideCountrySubdivisionCode"].ToString());    // Country Subdivision Code (1715) 

                                    // Provider Communications Numbers (PER) 

Page 21: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

21C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                    int nElemPos = 4;                                    ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\LX\PER"));                                    oSegment.set_DataElementValue(1, 0, "IC");    // Contact Function 

Code (366) 

                                    // Cellular Phone                                    if (oProviderInfoRow["PER0X_ProviderCellPhoneNumber"].ToString().Trim()

 != "")                                    {                                        oSegment.set_DataElementValue(3, 0, "CP");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"PER0X_ProviderCellPhoneNumber"].ToString());     // Communication Number (364)                                         nElemPos = nElemPos + 2;                                    }

                                    // Home Phone Number                                    if (oProviderInfoRow["PER0X_ProviderHomeNumber"].ToString().Trim() != 

"")                                    {                                        oSegment.set_DataElementValue(3, 0, "HP");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"PER0X_ProviderHomeNumber"].ToString());     // Communication Number (364)                                         nElemPos = nElemPos + 2;                                    }

                                    // Work Phone Number                                    if (oProviderInfoRow["PER0X_ProviderWorkNumber"].ToString().Trim() != 

"")                                    {                                        oSegment.set_DataElementValue(3, 0, "WP");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"PER0X_ProviderWorkNumber"].ToString());     // Communication Number (364)                                         nElemPos = nElemPos + 2;                                    }

                                    // Facsimile                                    if (oProviderInfoRow["PER0X_ProviderFaxNumber"].ToString().Trim() != 

"")                                    {                                        oSegment.set_DataElementValue(3, 0, "FX");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"PER0X_ProviderFaxNumber"].ToString());     // Communication Number (364)                                         nElemPos = nElemPos + 2;                                    }

                                    // Electronic Mail                                    if (oProviderInfoRow["PER0X_ProviderEmail"].ToString().Trim() != "")                                    {                                        oSegment.set_DataElementValue(3, 0, "EM");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oProviderInfoRow[

"PER0X_ProviderEmail"].ToString());     // Communication Number (364)                                         nElemPos = nElemPos + 2;                                    }

                                    // Provider Change Reason (PLA)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\HD\LX\PLA"));                                    oSegment.set_DataElementValue(1, 0, "2");     // Action Code (306)                                     oSegment.set_DataElementValue(2, 0, "1P");    // Entity Identifier 

Page 22: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

22C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

Code (98)                                     oSegment.set_DataElementValue(3, 0, oProviderInfoRow[

"PLA03_ProviderEffectiveChangeDate"].ToString());     // Date (373)                                     oSegment.set_DataElementValue(5, 0, oProviderInfoRow[

"PLA05_MaintenanceReasonCode"].ToString());     // Maintenance Reason Code (1203) 

                                }//foreach oProviderInfoRow

                                // 2320 COORDINATION OF BENEFITS                                sSql = "select * from [834X220_CoordinationBenefits] where 

HealthCoverageKey = " + oHealthCoverageRow["HealthCoverageKey"].ToString();                                SqlDataAdapter oDaCoordinationBenefits = new SqlDataAdapter(sSql, 

oConnection);                                DataSet oCoordinationBenefitsDs = new DataSet("dsCoordinationBenefits");                                oDaCoordinationBenefits.Fill(oCoordinationBenefitsDs, 

"dsCoordinationBenefits");

                                foreach (DataRow oCoordinationBenefitsRow in oCoordinationBenefitsDs.Tables["dsCoordinationBenefits"].Rows)

                                {                                    // Coordination of Benefits (COB)                                     oSegment = oTransactionSet.CreateDataSegment(@"INS\HD\COB\COB");                                    oSegment.set_DataElementValue(1, 0, oCoordinationBenefitsRow[

"COB01_PayerResponsibility_SequenceNumberCode"].ToString());     // Payer Responsibility Sequence Number Code (1138) 

                                    oSegment.set_DataElementValue(2, 0, oCoordinationBenefitsRow["COB02_MemberGroupPolicyNo"].ToString());     // Reference Identification (127) 

                                    oSegment.set_DataElementValue(3, 0, oCoordinationBenefitsRow["COB03_CoordinationOfBenefitsCode"].ToString());     // Coordination of Benefits Code (1143) 

                                    oSegment.set_DataElementValue(4, 0, oCoordinationBenefitsRow["COB04_ServiceTypeCode"].ToString());     // Service Type Code (1365) 

                                    // Additional Coordination of Benefits Identifiers (REF)                                     // Account Suffix Code                                    if (oCoordinationBenefitsRow["REF02_AccountSuffixCode"].ToString().Trim

() != "")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\REF"));                                        oSegment.set_DataElementValue(1, 0, "60");    // Reference 

Identification Qualifier (128)                                         oSegment.set_DataElementValue(2, 0, oCoordinationBenefitsRow[

"REF02_AccountSuffixCode"].ToString());     // Reference Identification (127)                                     }

                                    // Group Number                                    if (oCoordinationBenefitsRow["REF02_GroupNumber"].ToString().Trim() != 

"")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\REF"));                                        oSegment.set_DataElementValue(1, 0, "6P");    // Reference 

Identification Qualifier (128)                                         oSegment.set_DataElementValue(2, 0, oCoordinationBenefitsRow[

"REF02_GroupNumber"].ToString());     // Reference Identification (127)                                     }

                                    // Social Security Number                                    if (oCoordinationBenefitsRow["REF02_SocialSecurityNo"].ToString().Trim

() != "")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\REF"));                                        oSegment.set_DataElementValue(1, 0, "SY");    // Reference 

Identification Qualifier (128)                                         oSegment.set_DataElementValue(2, 0, oCoordinationBenefitsRow[

Page 23: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

23C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

"REF02_SocialSecurityNo"].ToString());    // Reference Identification (127)                                     }                                    

                                    // Coordination of Benefits Eligibility Dates (DTP)                                     // Coordination of Benefits Begin                                    if (oCoordinationBenefitsRow["DTP03_COB_BeginDate"].ToString().Trim() !

= "")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\DTP"));                                        oSegment.set_DataElementValue(1, 0, "344");     // Date/Time 

Qualifier (374)                                         oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period

 Format Qualifier (1250)                                         oSegment.set_DataElementValue(3, 0, oCoordinationBenefitsRow[

"DTP03_COB_BeginDate"].ToString());     // Date Time Period (1251)                                     }

                                    // Coordination of Benefits End                                    if (oCoordinationBenefitsRow["DTP03_COB_EndDate"].ToString().Trim() != 

"")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\DTP"));                                        oSegment.set_DataElementValue(1, 0, "345");     // Date/Time 

Qualifier (374)                                         oSegment.set_DataElementValue(2, 0, "D8");    // Date Time Period

 Format Qualifier (1250)                                         oSegment.set_DataElementValue(3, 0, oCoordinationBenefitsRow[

"DTP03_COB_EndDate"].ToString());     // Date Time Period (1251)                                     }                                    

                                    // 2330 COORDINATION OF BENEFITS RELATED ENTITY                                    sSql = "select * from [834X220_COB_RelatedEntity] where 

CoordinationBenefitsKey = " + oCoordinationBenefitsRow["CoordinationBenefitsKey"].ToString();                                    SqlDataAdapter oDaCOB_RelatedEntity = new SqlDataAdapter(sSql, 

oConnection);                                    DataSet oCOB_RelatedEntityDs = new DataSet("dsCOB_RelatedEntity");                                    oDaCOB_RelatedEntity.Fill(oCOB_RelatedEntityDs, "dsCOB_RelatedEntity");

                                    foreach (DataRow oCOB_RelatedEntityRow in oCOB_RelatedEntityDs.Tables["dsCOB_RelatedEntity"].Rows)

                                    {                                        // Coordination of Benefits Related Entity (NM1)                                         oSegment = oTransactionSet.CreateDataSegment(@"INS\HD\COB\NM1\NM1")

;                                        oSegment.set_DataElementValue(1, 0, oCOB_RelatedEntityRow[

"NM101_COB_RelatedEntityIdentifierCode"].ToString());     // Entity Identifier Code (98)                                         oSegment.set_DataElementValue(2, 0, "2");     // Entity Type 

Qualifier (1065)                                         oSegment.set_DataElementValue(3, 0, oCOB_RelatedEntityRow[

"NM103_COB_RelatedEntityOrganizationName"].ToString());     // Name Last or Organization Name (1035) 

                                        oSegment.set_DataElementValue(8, 0, oCOB_RelatedEntityRow["NM108_COB_RelatedEntityIdQlfr"].ToString());     // Identification Code Qualifier (66) 

                                        oSegment.set_DataElementValue(9, 0, oCOB_RelatedEntityRow["NM109_COB_RelatedEntityId"].ToString());     // Identification Code (67) 

                                                                                // Coordination of Benefits Related Entity Address (N3)                                         ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\NM1\N3"));                                        oSegment.set_DataElementValue(1, 0, oCOB_RelatedEntityRow[

"N301_COB_RelatedEntityAddress"].ToString());     // Address Information (166)                                         oSegment.set_DataElementValue(2, 0, oCOB_RelatedEntityRow[

Page 24: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

24C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

"N302_COB_RelatedEntityAddress2"].ToString());    // Address Information (166) 

                                        // Coordination of Benefits Other Insurance Company City, State, ZIP Code (N4) 

                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@"INS\HD\COB\NM1\N4"));

                                        oSegment.set_DataElementValue(1, 0, oCOB_RelatedEntityRow["N401_COB_RelatedEntityCity"].ToString());    // City Name (19) 

                                        oSegment.set_DataElementValue(2, 0, oCOB_RelatedEntityRow["N402_COB_RelatedEntityState"].ToString());     // State or Province Code (156) 

                                        oSegment.set_DataElementValue(3, 0, oCOB_RelatedEntityRow["N403_COB_RelatedEntityZip"].ToString());     // Postal Code (116) 

                                        oSegment.set_DataElementValue(4, 0, oCOB_RelatedEntityRow["N404_COB_RelatedEntityCountryCode"].ToString());     // Country Code (26) 

                                        oSegment.set_DataElementValue(7, 0, oCOB_RelatedEntityRow["N407_COB_RelatedEntityCountrySubdivisionCode"].ToString());     // Country Subdivision Code (1715) 

                                        // Administrative Communications Contact (PER)                                         ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\HD\COB\NM1\PER"));                                        oSegment.set_DataElementValue(1, 0, "CN");    // Contact Function

 Code (366)                                         oSegment.set_DataElementValue(3, 0, "TE");    // Communication 

Number Qualifier (365)                                         oSegment.set_DataElementValue(4, 0, oCOB_RelatedEntityRow[

"PER04_TelephoneNumber"].ToString());     // Communication Number (364)                                                                             }// foreach  oCOB_RelatedEntityRow

                                }// foreach oCoordinationBenefitsRow

                            }// foreach oHealthCoverageRow

                            // 2700 MEMBER REPORTING CATEGORIES                            sSql = "select * from [834X220_MemberReportingCategories] where Detailkey = " +

 oMemberDetailRow["Detailkey"].ToString();                            SqlDataAdapter oDaMemberReportingCategories = new SqlDataAdapter(sSql, 

oConnection);                            DataSet oMemberReportingCategoriesDs = new DataSet("dsMemberReportingCategories

");                            oDaMemberReportingCategories.Fill(oMemberReportingCategoriesDs, 

"dsMemberReportingCategories");

                            foreach (DataRow oMemberReportingCategoriesRow in oMemberReportingCategoriesDs.Tables["dsMemberReportingCategories"].Rows)

                            {                                // Member Reporting Categories (LX)                                 oSegment = oTransactionSet.CreateDataSegment(@"INS\LX\LX");                                oSegment.set_DataElementValue(1, 0, oMemberReportingCategoriesRow[

"LX01_Assigned_Number"].ToString());     // Assigned Number (554) 

                                // Reporting Category (N1)                                 if (oMemberReportingCategoriesRow["N102_ParticipantName"].ToString().Trim()

 != "")                                {                                    oSegment = oTransactionSet.CreateDataSegment(@"INS\LX\N1\N1");                                    oSegment.set_DataElementValue(1, 0, "75");    // Entity Identifier 

Code (98)                                     oSegment.set_DataElementValue(2, 0, oMemberReportingCategoriesRow[

"N102_ParticipantName"].ToString());     // Name (93) 

                                    // Reporting Category Reference (REF)                                     ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment(@

"INS\LX\N1\REF"));                                    oSegment.set_DataElementValue(1, 0, oMemberReportingCategoriesRow[

"REF01_ParticipantIdQlfr"].ToString());     // Reference Identification Qualifier (128) 

Page 25: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

25C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

                                    oSegment.set_DataElementValue(2, 0, oMemberReportingCategoriesRow["REF02_ParticipantId"].ToString());     // Reference Identification (127) 

                                    // Reporting Category Date (DTP)                                     if (oMemberReportingCategoriesRow["DTP03_EfectiveDates"].ToString().

Trim() != "")                                    {                                        ediDataSegment.Set(ref oSegment, oTransactionSet.CreateDataSegment

(@"INS\LX\N1\DTP"));                                        oSegment.set_DataElementValue(1, 0, "007");     // Date/Time 

Qualifier (374)                                         oSegment.set_DataElementValue(2, 0, oMemberReportingCategoriesRow[

"DTP02_EfectiveDateFormatQlfr"].ToString());     // Date Time Period Format Qualifier (1250)                                         oSegment.set_DataElementValue(3, 0, oMemberReportingCategoriesRow[

"DTP03_EfectiveDates"].ToString());     // Date Time Period (1251)                                     }                                                                    }                                                            }// foreach oMemberReportingCategoriesRow

                        }// foreach oMemberDetailRow

                    }// foreach oHeaderRow

                }// foreach oGroupRow

            }// foreach oInterchangeRow

            //TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS THE EDIDOC OBJECT INTO AN EDI FILE.

            MessageBox.Show(oEdiDoc.GetEdiString());

            oEdiDoc.Save(sPath + sEdiFile );

            //DESTROYS OBJECTS            if (oSegment != null)                oSegment.Dispose();

            if (oTransactionSet != null)                oTransactionSet.Dispose();

            if (oGroup != null)                oGroup.Dispose();

            if (oInterchange != null)                oInterchange.Dispose();

            if (oSchema != null)                oSchema.Dispose();

            if (oSchemas != null)                oSchemas.Dispose();

            if (oEdiDoc != null)                oEdiDoc.Dispose();

        }

        private void btnAddDelRec_Click(object sender, EventArgs e)        {            frmAddRec oAddRec;

            oAddRec = new frmAddRec();

Page 26: C:EDIdEvExamplesHIPAA5010cSharpcSharp Gen834X220A1 ...€¦ · C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs 2 { //CREATES THE ISA SEGMENT

26C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Gen834X220A1_SqlClient\frmGen834.cs

            oAddRec.Show();        }

        private void btnViewTables_Click(object sender, EventArgs e)        {            frmViewTables ofrmViewTables = new frmViewTables();

            ofrmViewTables.Show();        }    }}