Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlClientDataOperations oSalient = new SqlClientDataOperations();
            DataSet oData = new DataSet();

            try
            {
                if (!IsPostBack)
                {
                    oSalient.ConnectionString = ConfigurationManager.ConnectionStrings["HIPAAComponents"].ConnectionString;
                    oSalient.LoadDataSetFromStoredProc("usp_ListXChanges").Fill(oData);
                    this.dgInterchanges.DataSource = oData.Tables[0];
                    dgInterchanges.DataBind();
                }
                else
                {
                    intInterchangeID       = int.Parse(ViewState["intInterchangeID"].ToString());
                    strSenderIDQual        = ViewState["strSenderIDQual"].ToString();
                    strSenderID            = ViewState["strSenderID"].ToString();
                    strReceiverID          = ViewState["strReceiverID"].ToString();
                    strReceiverIDQual      = ViewState["strReceiverIDQaul"].ToString();
                    blnAcknowledgement     = bool.Parse(ViewState["blnAcknowledgement"].ToString());
                    strRepetitionSeparator = ViewState["strRepetitionSeparator"].ToString();
                    strElementSeparator    = ViewState["strElementSeparator"].ToString();
                    strUsage = ViewState["strUsage"].ToString();
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
        /// <summary>
        /// Build Well-Formed 837P
        /// </summary>
        protected void build837Batches()
        {
            HIPAAComponents.MNBilling               oBills = new MNBilling();
            MNBilling.GE_FunctionalGroupTrailer     oGE    = new MNBilling.GE_FunctionalGroupTrailer();
            MNBilling.IEA_InterchangeControlTrailer oIEA   = new MNBilling.IEA_InterchangeControlTrailer();
            SqlClientDataOperations oSalient = new SqlClientDataOperations();
            DataSet oBatchDS  = new DataSet();
            DataSet oClaimsDS = new DataSet();
            DataSet oLinesDS  = new DataSet();
            //string[] o837P;
            ArrayList o837P = new ArrayList();
            int       intSegmentCount;
            int       intSVCLineCount;
            int       intParent;
            int       intHLLevel;

            try
            {
                oSalient.ConnectionString = ConfigurationManager.ConnectionStrings["HIPAAComponents"].ConnectionString;
                oSalient.LoadDataSetFromStoredProc("usp_GetBatches2Process").Fill(oBatchDS);
                oBills.DefaultSep   = "*";
                oBills.EndOfSegment = "~";
                oBills.AckRequested = blnAcknowledgement;

                foreach (DataRow x in oBatchDS.Tables[0].Rows)
                {
                    intSegmentCount = 10;
                    intSVCLineCount = 1;
                    intParent       = 1;
                    intHLLevel      = 2;
                    o837P.Add(SetISA(x["BatchNumber"].ToString(), oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetGS(x["BatchNumber"].ToString(), oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetST(x["BatchNumber"].ToString(), oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetBHT(x["BatchNumber"].ToString(), oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetSubmitterName(x, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetEDIContact(oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetReceiverName(x, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetBillingProviderLevel(1, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetBillingProviderName(x, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetBillingProviderAddress(x, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetCityStateZip(x, oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetTaxID(x, oBills.DefaultSep, oBills.EndOfSegment));

                    ArrayList oParams = new ArrayList();
                    oParams.Add(new System.Data.SqlClient.SqlParameter("@BatchNumber", x["BatchNumber"].ToString()));

                    oSalient.LoadDataSet(oParams, "usp_GetClaimsByBatchNumber").Fill(oClaimsDS);
                    foreach (DataRow y in oClaimsDS.Tables[0].Rows)
                    {
                        o837P.Add(SetSubscriberLevel(intHLLevel, intParent, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetSBRSegment(x, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetSubscriberName(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetBillingSubscriberAddress(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetSubscriberCityStateZip(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetSubscriberDemographics(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetPayerName(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetClaimSegment(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetPriorAuthorization(y, oBills.DefaultSep, oBills.EndOfSegment));
                        o837P.Add(SetHISegment(y, oBills.DefaultSep, oBills.EndOfSegment));

                        ArrayList oSVCParams = new ArrayList();
                        oSVCParams.Add(new System.Data.SqlClient.SqlParameter("@BatchNumber", x["BatchNumber"].ToString()));
                        oSVCParams.Add(new System.Data.SqlClient.SqlParameter("@SubscriberID", y["ClaimsBatchID"].ToString()));

                        oSalient.LoadDataSet(oSVCParams, "usp_GetSVCLinesByBatchAndClaim").Fill(oLinesDS);
                        foreach (DataRow q in oLinesDS.Tables[0].Rows)
                        {
                            o837P.Add(SetLXSegment(intSVCLineCount, oBills.DefaultSep, oBills.EndOfSegment));
                            intSVCLineCount += 1;
                            o837P.Add(SetSV1Segment(q, oBills.DefaultSep, oBills.EndOfSegment));
                            o837P.Add(SetServiceDate(q, oBills.DefaultSep, oBills.EndOfSegment));
                            intSegmentCount = intSegmentCount + 3;
                        }
                        intSegmentCount = intSegmentCount + 10;
                        intHLLevel     += 1;
                        oLinesDS.Clear();
                        intSVCLineCount = 1;
                    }
                    intSegmentCount = intSegmentCount + 1;
                    o837P.Add(SetSESegment(intSegmentCount, x["BatchNumber"].ToString(), oBills.DefaultSep, oBills.EndOfSegment));
                    o837P.Add(SetGESegment(oBills.DefaultSep, oBills.EndOfSegment, x["BatchNumber"].ToString()));
                    o837P.Add(SetIEASegment(oBills.DefaultSep, oBills.EndOfSegment, x["BatchNumber"].ToString()));

                    int intBuffer = o837P[0].ToString().Length *(intSegmentCount + 6);

                    StreamWriter oFS = new StreamWriter(ConfigurationManager.AppSettings["ResultsPath"].ToString() + x["NPI"].ToString() + "_837P_" + System.DateTime.Now.ToString("yyyyMMdd") + ".dat");

                    foreach (string z in o837P)
                    {
                        oFS.Write(z);
                        oFS.Flush();
                        ArrayList oInsertParam = new ArrayList();
                        oInsertParam.Add(new System.Data.SqlClient.SqlParameter("@ControlNumber", x["BatchNumber"].ToString()));
                        oInsertParam.Add(new System.Data.SqlClient.SqlParameter("@LineSegment", z.ToString()));
                        //oSalient.ExecuteNonQuery(oInsertParam, "usp_InsertClaimLine");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }