c:edidevexampleshipaa5010csharpcsharp tran837x223a2 ...·...

Download C:EDIdEvExamplesHIPAA5010cSharpcSharp Tran837X223A2 ...· C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\

Post on 07-Nov-2018

222 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • 1C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\frmTran837X223A2.cs

    usingSystem;usingSystem.Configuration;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingEdidev.FrameworkEDIx64;

    namespaceTran837X223A2{////ThetablesintheHipaaDbdatabasewerecreatedusingthescriptsinthefolder"CREATE_SQL_TABLES"publicpartialclassfrmTran837X223A2:Form{publicfrmTran837X223A2(){InitializeComponent();}

    privatestringsConnection=ConfigurationManager.ConnectionStrings["Development"].ConnectionString;

    privateSqlConnectionoConnection=null;privateSqlDataAdapteroDaInterchange=newSqlDataAdapter();privateSqlDataAdapteroDaFuncGroup=newSqlDataAdapter();privateSqlDataAdapteroDaHeader=newSqlDataAdapter();privateSqlDataAdapteroDaInfoSource=newSqlDataAdapter();privateSqlDataAdapteroDaSubscriber=newSqlDataAdapter();privateSqlDataAdapteroDaOtherSubscriberInfo=newSqlDataAdapter();privateSqlDataAdapteroDaDependent=newSqlDataAdapter();privateSqlDataAdapteroDaClaims=newSqlDataAdapter();privateSqlDataAdapteroDaClaimsHi=newSqlDataAdapter();privateSqlDataAdapteroDaServiceLine=newSqlDataAdapter();privateSqlDataAdapteroDaServiceLineAdj=newSqlDataAdapter();

    privateInt32nInterkey;privateInt32nGroupkey;privateInt32nHeaderkey;privateInt32nInfoSourcekey;privateInt32nSubscriberkey;privateInt32nOtherSubscriberInfokey;privateInt32nDependentkey;privateInt32nClaimskey;privateInt32nClaimsHikey;privateInt32nServiceLinekey;privateInt32nServiceLineAdjkey;

    privatevoidbtnTranslate_Click(objectsender,EventArgse){ediDocumentoEdiDoc=null;stringsAppPath=AppDomain.CurrentDomain.BaseDirectory;

    stringsSefFile="837_005010X223A2.SemRef.EVAL0.SEF";//evaluationSEFfile

    Cursor=Cursors.WaitCursor;

    label2.Text="Pleasewait.ValidatingEDIfile...";label2.Refresh();

    //CREATESEDIDOCOBJECToEdiDoc=newediDocument();

    //THISMAKESCERTAINTHATFREDIONLYUSESTHESEFFILEPROVIDED,ANDTHATITDOES

  • 2C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\frmTran837X223A2.cs

    //NOTUSEITSBUILTINSTANDARDREFERENCETABLETOTRANSLATETHEEDIFILE.ediSchemasoSchemas=oEdiDoc.GetSchemas();oSchemas.EnableStandardReference=false;

    //THISOPTIONSSTOPSFREDIFROMKEEPINGALLTHESEGMENTSINMEMORYTHUSSAVESMEMORYANDIMPROVESPERFORMANCE

    oEdiDoc.CursorType=DocumentCursorTypeConstants.Cursor_ForwardOnly;

    //LOADSTHESEFFILEediSchemaoSchema=oEdiDoc.ImportSchema(sAppPath+sSefFile,0);

    //LOADSTHEEDIFILEoEdiDoc.LoadEdi(txtEdiFile.Text);

    //GETSTHEFIRSTDATASEGMENTediDataSegmentoSegment=oEdiDoc.FirstDataSegment;

    //LOOPTHATWILLTRAVERSETHRUEDIFILEFROMTOPTOBOTTOMwhile(oSegment!=null){ediDataSegment.Set(refoSegment,oSegment.Next());}//checkifFREDIfoundanyerrorsediWarningsoWarnings=oEdiDoc.GetWarnings();intnWarningsCount=oWarnings.Count;

    if(nWarningsCount>0){if(MessageBox.Show("ErrorswerefoundintheEDIfile,whichmaycausetheprogramto

    breakornottranslateproperly.Doyouwishtocontinue?","Attention",MessageBoxButtons.YesNo)==System.Windows.Forms.DialogResult.Yes)

    {label2.Text="TranslatingEDIfiletoDatabase...";label2.Refresh();Proc_Translate_837X223_To_Database(refoEdiDoc,refsAppPath);MessageBox.Show("Done");}else{//donotprocessEDIfileMessageBox.Show("Bye");}

    }else{label2.Text="TranslatingEDIfiletoDatabase...";label2.Refresh();Proc_Translate_837X223_To_Database(refoEdiDoc,refsAppPath);MessageBox.Show("Done");}

    label2.Text="";label2.Refresh();

    Cursor=Cursors.Default;

    oWarnings.Dispose();oSchema.Dispose();oSchemas.Dispose();oEdiDoc.Dispose();

    }//privatevoidbtnTranslate_Click

  • 3C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\frmTran837X223A2.cs

    //******************************************************************************************************

    //******************************************************************************************************

    //***********************************Proc_Translate_837X223_To_Database******************************

    //******************************************************************************************************

    //******************************************************************************************************

    privatevoidProc_Translate_837X223_To_Database(refediDocumentoEdiDoc,refstringsAppPath){stringsSegmentID;stringsLoopSection;intnArea;

    stringsValue;stringsHlQlfr="";stringsQlfr="";stringsSql="";stringsNm1Qlfr="";

    oConnection=newSqlConnection(sConnection);oConnection.Open();

    //loadedifileoEdiDoc.LoadEdi(txtEdiFile.Text);

    //GETSTHEFIRSTDATASEGMENTediDataSegmentoSegment=oEdiDoc.FirstDataSegment;

    //LOOPTHATWILLTRAVERSETHRUEDIFILEFROMTOPTOBOTTOMwhile(oSegment!=null){//DATASEGMENTSAREIDENTIFIEDBYTHEIRID,LOOPSECTIONANDAREAsSegmentID=oSegment.ID;sLoopSection=oSegment.LoopSection;nArea=oSegment.Area;

    if(nArea==0){if(sLoopSection==""){if(sSegmentID=="ISA"){//insertarecordintointerchangetablesSql=@"INSERTINTO[Interchange](ISA01_AuthorizationInfoQlfr,

    ISA02_AuthorizationInfo,ISA03_SecurityInfoQlfr,ISA04_SecurityInfo,ISA05_SenderIdQlfr,ISA06_SenderId,

    ISA07_ReceiverIdQlfr,ISA08_ReceiverId,ISA09_Date,ISA10_Time,ISA11_RepetitionSeparator,ISA12_ControlVersionNumber,

    ISA13_ControlNumber,ISA14_AcknowledgmentRequested,ISA15_UsageIndicator,

    ISA16_ComponentElementSeparator)values(@ISA01_AuthorizationInfoQlfr,@ISA02_AuthorizationInfo,@

    ISA03_SecurityInfoQlfr,@ISA04_SecurityInfo,@ISA05_SenderIdQlfr,@ISA06_SenderId,@

    ISA07_ReceiverIdQlfr,@ISA08_ReceiverId,@ISA09_Date,@ISA10_Time,@ISA11_RepetitionSeparator,@ISA12_ControlVersionNumber,@

    ISA13_ControlNumber,@ISA14_AcknowledgmentRequested,@ISA15_UsageIndicator,@

    ISA16_ComponentElementSeparator);

  • 4C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\frmTran837X223A2.cs

    SELECTscope_identity()";

    oDaInterchange.InsertCommand=newSqlCommand(sSql,oConnection);oDaInterchange.InsertCommand.Parameters.AddWithValue("@

    ISA01_AuthorizationInfoQlfr",oSegment.get_DataElementValue(1,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA02_AuthorizationInfo"

    ,oSegment.get_DataElementValue(2,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA03_SecurityInfoQlfr",

    oSegment.get_DataElementValue(3,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA04_SecurityInfo",

    oSegment.get_DataElementValue(4,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA05_SenderIdQlfr",

    oSegment.get_DataElementValue(5,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA06_SenderId",

    oSegment.get_DataElementValue(6,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA07_ReceiverIdQlfr",

    oSegment.get_DataElementValue(7,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA08_ReceiverId",

    oSegment.get_DataElementValue(8,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA09_Date",oSegment.

    get_DataElementValue(9,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA10_Time",oSegment.

    get_DataElementValue(10,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@

    ISA11_RepetitionSeparator",oSegment.get_DataElementValue(11,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@

    ISA12_ControlVersionNumber",oSegment.get_DataElementValue(12,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA13_ControlNumber",

    oSegment.get_DataElementValue(13,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@

    ISA14_AcknowledgmentRequested",oSegment.get_DataElementValue(14,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@ISA15_UsageIndicator",

    oSegment.get_DataElementValue(15,0));oDaInterchange.InsertCommand.Parameters.AddWithValue("@

    ISA16_ComponentElementSeparator",oSegment.get_DataElementValue(16,0));nInterkey=(Int32)(decimal)oDaInterchange.InsertCommand.ExecuteScalar();}elseif(sSegmentID=="GS"){//insertarecordintoFunctionGroptablesSql=@"INSERTINTO[FuncGroup](Interkey,GS01_FunctionalIdfrCode,

    GS02_SendersCode,GS03_ReceiversCode,GS04_Date,GS05_Time,GS06_GroupControlNumber,

    GS07_ResponsibleAgencyCode,GS08_VersionReleaseCode)values(@Interkey,@GS01_FunctionalIdfrCode,@GS02_SendersCode,@

    GS03_ReceiversCode,@GS04_Date,@GS05_Time,@GS06_GroupControlNumber,@

    GS07_ResponsibleAgencyCode,@GS08_VersionReleaseCode);SELECTscope_identity()";

    oDaFuncGroup.InsertCommand=newSqlCommand(sSql,oConnection);oDaFuncGroup.InsertCommand.Parameters.AddWithValue("@Interkey",nInterkey);oDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS01_FunctionalIdfrCode",

    oSegment.get_DataElementValue(1,0));//FunctionalIdentifierCodeoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS02_SendersCode",

    oSegment.get_DataElementValue(2,0));//ApplicationSender'sCodeoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS03_ReceiversCode",

    oSegment.get_DataElementValue(3,0));//ApplicationReceiver'sCodeoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS04_Date",oSegment.

    get_DataElementValue(4,0));//DateoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS05_Time",oSegment.

    get_DataElementValue(5,0));//TimeoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS06_GroupControlNumber",

    oSegment.get_DataElementValue(6,0));//GroupControlNumberoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS07_ResponsibleAgencyCode

  • 5C:\EDIdEv\Examples\HIPAA\5010\cSharp\cSharp_Tran837X223A2_SqlClient\frmTran837X223A2.cs

    ",oSegment.get_DataElementValue(7,0));//ResponsibleAgencyCodeoDaFuncGroup.InsertCommand.Parameters.AddWithValue("@GS08_VersionReleaseCode",

    oSegment.get_DataElementValue(8,0));//Version/Release/IndustryIdentifierCodenGroupkey=(Int32)(decimal)oDaFuncGroup.InsertCommand.Execu