Example #1
0
        public static string RunFour(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[1].ProvNum;       //dentist #2
            Patient pat     = Patients.GetPat(PatientTC.PatNum6);   //patient#6

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan          patplan        = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub           sub            = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan          plan           = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            long             etransNum      = CanadianOutput.SendElegibility(pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans         = Etranss.GetEtrans(etransNum);
            string           message        = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData       = new CCDFieldInputter(message);
            string           responseStatus = formData.GetValue("G05");

            if (responseStatus != "M")
            {
                throw new Exception("Should be M");
            }
            retVal += "Eligibility #4 successful.\r\n";
            return(retVal);
        }
Example #2
0
        public static string RunOne(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[0].ProvNum;       //dentist #1
            Patient pat     = Patients.GetPat(PatientTC.PatNum1);   //patient#1

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan patplan = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub  sub     = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan plan    = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            //the UI would block this due to carrier not supporting this transaction type.
            Clearinghouse    clearinghouseHq   = Clearinghouses.GetDefaultDental();
            Clearinghouse    clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);
            long             etransNum         = CanadianOutput.SendElegibility(clearinghouseClin, pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans            = Etranss.GetEtrans(etransNum);
            string           message           = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData          = new CCDFieldInputter(message);
            string           responseStatus    = formData.GetValue("G05");

            if (responseStatus != "R")
            {
                throw new Exception("Should be R");
            }
            retVal += "Eligibility #1 successful.\r\n";
            return(retVal);
        }
Example #3
0
 private void FormEtrans277Edit_Load(object sender, EventArgs e)
 {
     MessageText = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     x277        = new X277(MessageText);
     FillHeader();
     FillGrid();
 }
Example #4
0
        private void FormEtrans270Edit_Load(object sender, EventArgs e)
        {
            MessageText    = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
            MessageTextAck = "";
            //textMessageText.Text=MessageText;
            textNote.Text = EtransCur.Note;
            EtransAck271  = Etranss.GetEtrans(EtransCur.AckEtransNum);
            x271          = null;
            if (EtransAck271 != null)
            {
                MessageTextAck = EtransMessageTexts.GetMessageText(EtransAck271.EtransMessageTextNum);              //.Replace("~","~\r\n");
                if (EtransAck271.Etype == EtransType.BenefitResponse271)
                {
                    x271 = new X271(MessageTextAck);
                }
            }
            listDTP = new List <DTP271>();
            if (x271 != null)
            {
                listDTP = x271.GetListDtpSubscriber();
            }
            radioBenefitSendsPat.Checked = (!_isConinsuranceInverted);
            radioBenefitSendsIns.Checked = (_isConinsuranceInverted);
            FillGridDates();
            CreateListOfBenefits();
            FillGrid();
            FillGridBen();
            if (IsInitialResponse)
            {
                SelectForImport();
            }
            long patNum = (EtransCur.PatNum == 0?_subPatNum:EtransCur.PatNum);        //Older 270/217s were always for the subscriber and have etrans.PatNum of 0.

            this.Text += ": " + Patients.GetNameLF(patNum);
        }
Example #5
0
 private void FormEtrans270Edit_Load(object sender, EventArgs e)
 {
     MessageText    = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     MessageTextAck = "";
     //textMessageText.Text=MessageText;
     textNote.Text = EtransCur.Note;
     EtransAck271  = Etranss.GetEtrans(EtransCur.AckEtransNum);
     x271          = null;
     if (EtransAck271 != null)
     {
         MessageTextAck = EtransMessageTexts.GetMessageText(EtransAck271.EtransMessageTextNum);              //.Replace("~","~\r\n");
         if (EtransAck271.Etype == EtransType.BenefitResponse271)
         {
             x271 = new X271(MessageTextAck);
         }
     }
     listDTP = new List <DTP271>();
     if (x271 != null)
     {
         listDTP = x271.GetListDtpSubscriber();
     }
     FillGridDates();
     CreateListOfBenefits();
     FillGrid();
     FillGridBen();
     if (IsInitialResponse)
     {
         SelectForImport();
     }
 }
 private void FormEtrans277Edit_Load(object sender, EventArgs e)
 {
     MessageText = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     try {
         x277 = new X277(MessageText);
     }
     catch (Exception ex) {
         MessageBox.Show(Lan.g(this, "Claim Status Response not valid.  An error occurred while loading: ") + "\r\n" + ex.Message);
         DialogResult = DialogResult.Cancel;
         return;
     }
     FillHeader();
     FillGrid();
 }
Example #7
0
        /*
         * private void butShowResponseDeciph_Click(object sender,EventArgs e) {
         *      if(!X12object.IsX12(MessageTextAck)) {
         *              MessageBox.Show("Only works with 997's");
         *              return;
         *      }
         *      X12object x12obj=new X12object(MessageTextAck);
         *      if(!x12obj.Is997()) {
         *              MessageBox.Show("Only works with 997's");
         *              return;
         *      }
         *      X997 x997=new X997(MessageTextAck);
         *      string display=x997.GetHumanReadable();
         *      MsgBoxCopyPaste msgbox=new MsgBoxCopyPaste(display);
         *      msgbox.ShowDialog();
         * }*/

        private void butDelete_Click(object sender, EventArgs e)
        {
            //This button is not visible if IsNew
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete entire request and response?"))
            {
                return;
            }
            if (EtransAck271 != null)
            {
                EtransMessageTexts.Delete(EtransAck271.EtransMessageTextNum);
                Etranss.Delete(EtransAck271.EtransNum);
            }
            EtransMessageTexts.Delete(EtransCur.EtransMessageTextNum);
            Etranss.Delete(EtransCur.EtransNum);
            DialogResult = DialogResult.OK;
        }
Example #8
0
 private void FormEtransEdit_Load(object sender, EventArgs e)
 {
     MessageText            = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     textMessageText.Text   = MessageText;
     textDateTimeTrans.Text = EtransCur.DateTimeTrans.ToString();
     textClaimNum.Text      = EtransCur.ClaimNum.ToString();
     textBatchNumber.Text   = EtransCur.BatchNumber.ToString();
     textTransSetNum.Text   = EtransCur.TransSetNum.ToString();
     textAckCode.Text       = EtransCur.AckCode;
     textNote.Text          = EtransCur.Note;
     if (EtransCur.Etype == EtransType.ClaimSent)
     {
         if (X12object.IsX12(MessageText))
         {
             X12object x12obj = new X12object(MessageText);
             if (x12obj.IsFormat4010())
             {
                 X837_4010 x837 = new X837_4010(MessageText);
                 checkAttachments.Checked = x837.AttachmentsWereSent(EtransCur.ClaimNum);                      //This function does not currently work, so the corresponding checkbox is hidden on the form as well.
             }
             else if (x12obj.IsFormat5010())
             {
                 X837_5010 x837 = new X837_5010(MessageText);
                 checkAttachments.Checked = x837.AttachmentsWereSent(EtransCur.ClaimNum);                      //This function does not currently work, so the corresponding checkbox is hidden on the form as well.
             }
         }
     }
     if (EtransCur.AckEtransNum > 0)
     {
         AckCur = Etranss.GetEtrans(EtransCur.AckEtransNum);
         if (AckCur != null)
         {
             textAckMessage.Text  = EtransMessageTexts.GetMessageText(AckCur.EtransMessageTextNum);
             textAckDateTime.Text = AckCur.DateTimeTrans.ToString();
             textAckNote.Text     = AckCur.Note;
         }
     }
     else
     {
         AckCur           = null;
         groupAck.Visible = false;
     }
     if (!CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Not Canadian.
     {
         butPrintAck.Visible = false;
     }
 }
        private void FormEtrans270Edit_Load(object sender, EventArgs e)
        {
            MessageText    = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
            MessageTextAck = "";
            //textMessageText.Text=MessageText;
            textNote.Text = EtransCur.Note;
            EtransAck271  = Etranss.GetEtrans(EtransCur.AckEtransNum);
            x271          = null;
            if (EtransAck271 != null)
            {
                MessageTextAck = EtransMessageTexts.GetMessageText(EtransAck271.EtransMessageTextNum);              //.Replace("~","~\r\n");
                if (EtransAck271.Etype == EtransType.BenefitResponse271)
                {
                    x271 = new X271(MessageTextAck);
                }
            }
            listDTP = new List <DTP271>();
            if (x271 != null)
            {
                listDTP = x271.GetListDtpSubscriber();
                textResponseGroupNum.Text = x271.GetGroupNum();
            }
            if (textCurrentGroupNum.Text != textResponseGroupNum.Text)
            {
                errorProviderGroupNum.SetError(textCurrentGroupNum, Lan.g(this, "Mismatched group number."));
            }
            radioBenefitSendsPat.Checked = (!_isConinsuranceInverted);
            radioBenefitSendsIns.Checked = (_isConinsuranceInverted);
            FillGridDates();
            CreateListOfBenefits();
            FillGrid();
            FillGridBen();
            if (IsInitialResponse)
            {
                SelectForImport();
            }
            long patNum = (EtransCur.PatNum == 0?_subPatNum:EtransCur.PatNum);        //Older 270/217s were always for the subscriber and have etrans.PatNum of 0.

            this.Text += ": " + Patients.GetNameLF(patNum);
            if (Clearinghouses.GetFirstOrDefault(x => x.ClearinghouseNum == EtransCur.ClearingHouseNum)?.CommBridge == EclaimsCommBridge.EDS &&
                EtransAck271 != null && EtransAck271.AckEtransNum != 0)
            {
                _htmlResponse    = EtransMessageTexts.GetMessageText(Etranss.GetEtrans(EtransAck271.AckEtransNum).EtransMessageTextNum);
                butPrint.Visible = true;
            }
        }
Example #10
0
        public static string Run(int scriptNum, string responseExpected, Claim claim)
        {
            string           retVal         = "";
            InsPlan          insPlan        = InsPlans.GetPlan(claim.PlanNum, null);
            InsSub           insSub         = InsSubs.GetOne(claim.InsSubNum);
            long             etransNum      = CanadianOutput.SendClaimReversal(claim, insPlan, insSub);
            Etrans           etrans         = Etranss.GetEtrans(etransNum);
            string           message        = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData       = new CCDFieldInputter(message);
            string           responseStatus = formData.GetValue("G05");

            if (responseStatus != responseExpected)
            {
                return("G05 should be " + responseExpected + "\r\n");
            }
            retVal += "Reversal #" + scriptNum.ToString() + " successful.\r\n";
            return(retVal);
        }
Example #11
0
        public static string Run(int scriptNum, string responseExpected, string responseTypeExpected, Claim claim, bool showForms, int pageNumber, int lastPageNumber, double firstExamFee, double diagnosticPhaseFee)
        {
            string             retVal            = "";
            ClaimSendQueueItem queueItem         = Claims.GetQueueList(claim.ClaimNum, claim.ClinicNum, 0)[0];
            Clearinghouse      clearinghouseHq   = ClearinghouseL.GetClearinghouseHq(queueItem.ClearinghouseNum);
            Clearinghouse      clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);

            Eclaims.GetMissingData(clearinghouseClin, queueItem);           //,out warnings);
            if (queueItem.MissingData != "")
            {
                return("Cannot send predetermination until missing data is fixed:\r\n" + queueItem.MissingData + "\r\n");
            }
#if DEBUG
            Canadian.testNumber = scriptNum;
            claim.PreAuthString = "" + pageNumber + "," + lastPageNumber + "," + firstExamFee + "," + diagnosticPhaseFee;
#endif
            long             etransNum    = Canadian.SendClaim(clearinghouseClin, queueItem, showForms);
            Etrans           etrans       = Etranss.GetEtrans(etransNum);
            string           message      = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData     = new CCDFieldInputter(message);
            string           responseType = formData.GetValue("A04");
            if (responseType != responseTypeExpected)
            {
                return("Form type is '" + responseType + "' but should be '" + responseTypeExpected + "'\r\n");
            }
            string responseStatus = formData.GetValue("G05");
            if (responseStatus != responseExpected)
            {
                return("G05 is '" + responseStatus + "' but should be '" + responseExpected + "'\r\n");
            }
            if (responseExpected == "R" && responseTypeExpected == "11")
            {
                //so far, only for #6.  We need some other way to test if successful transaction
                string errorMsgCount = formData.GetValue("G06");
                if (errorMsgCount == "00")
                {
                    return("Wrong message count.\r\n");
                }
            }
            retVal += "Predetermination #" + scriptNum + " page " + pageNumber + " of " + lastPageNumber + " successful.\r\n";
            return(retVal);
        }
Example #12
0
        public static string Run(int scriptNum, string responseExpected, string responseTypeExpected, Claim claim, bool showForms)
        {
            string             retVal            = "";
            ClaimSendQueueItem queueItem         = Claims.GetQueueList(claim.ClaimNum, claim.ClinicNum, 0)[0];
            Clearinghouse      clearinghouseHq   = ClearinghouseL.GetClearinghouseHq(queueItem.ClearinghouseNum);
            Clearinghouse      clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);

            Eclaims.GetMissingData(clearinghouseClin, queueItem);           //,out warnings);
            if (queueItem.MissingData != "")
            {
                return("Cannot send claim until missing data is fixed:\r\n" + queueItem.MissingData + "\r\n");
            }
#if DEBUG
            Canadian.testNumber = scriptNum;
#endif
            long             etransNum    = Canadian.SendClaim(clearinghouseClin, queueItem, showForms);
            Etrans           etrans       = Etranss.GetEtrans(etransNum);
            string           message      = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData     = new CCDFieldInputter(message);
            string           responseType = formData.GetValue("A04");
            if (responseType != responseTypeExpected)
            {
                return("Form type should be " + responseTypeExpected + "\r\n");
            }
            string responseStatus = formData.GetValue("G05");
            if (responseStatus != responseExpected)
            {
                return("G05 should be " + responseExpected + "\r\n");
            }
            if (responseExpected == "R" && responseTypeExpected == "11")
            {
                //so far, only for #6.  We need some other way to test if successful transaction
                string errorMsgCount = formData.GetValue("G06");
                if (errorMsgCount == "00")
                {
                    return("Wrong message count.\r\n");
                }
            }
            retVal += "Claim #" + scriptNum.ToString() + " successful.\r\n";
            return(retVal);
        }
Example #13
0
 private void FormEtransEdit_Load(object sender, EventArgs e)
 {
     MessageText            = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     textMessageText.Text   = MessageText;
     textDateTimeTrans.Text = EtransCur.DateTimeTrans.ToString();
     textClaimNum.Text      = EtransCur.ClaimNum.ToString();
     textBatchNumber.Text   = EtransCur.BatchNumber.ToString();
     textTransSetNum.Text   = EtransCur.TransSetNum.ToString();
     textAckCode.Text       = EtransCur.AckCode;
     textNote.Text          = EtransCur.Note;
     if (EtransCur.Etype == EtransType.ClaimSent)
     {
         if (X12object.IsX12(MessageText))
         {
             //TODO: we need to do something different here for 5010s.
             X837_4010 x837 = new X837_4010(MessageText);
             checkAttachments.Checked = x837.AttachmentsWereSent(EtransCur.ClaimNum);
         }
     }
     if (EtransCur.AckEtransNum > 0)
     {
         AckCur = Etranss.GetEtrans(EtransCur.AckEtransNum);
         if (AckCur != null)
         {
             textAckMessage.Text  = EtransMessageTexts.GetMessageText(AckCur.EtransMessageTextNum);
             textAckDateTime.Text = AckCur.DateTimeTrans.ToString();
         }
         groupAck.Text = Lan.g(this, "Acknowledgement");
     }
     else
     {
         AckCur           = null;
         groupAck.Visible = false;
     }
     if (!CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Not Canadian.
     {
         butPrintAck.Visible = false;
     }
 }
Example #14
0
        public static string Run(int scriptNum, string responseExpected, Claim claim)
        {
            string        retVal          = "";
            InsPlan       insPlan         = InsPlans.GetPlan(claim.PlanNum, null);
            InsSub        insSub          = InsSubs.GetOne(claim.InsSubNum);
            Carrier       carrier         = Carriers.GetCarrier(insPlan.CarrierNum);
            Clearinghouse clearinghouseHq =
                Clearinghouses.GetClearinghouse(Clearinghouses.AutomateClearinghouseHqSelection(carrier.ElectID, claim.MedType));
            Clearinghouse    clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);
            long             etransNum         = CanadianOutput.SendClaimReversal(clearinghouseClin, claim, insPlan, insSub);
            Etrans           etrans            = Etranss.GetEtrans(etransNum);
            string           message           = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData          = new CCDFieldInputter(message);
            string           responseStatus    = formData.GetValue("G05");

            if (responseStatus != responseExpected)
            {
                return("G05 should be " + responseExpected + "\r\n");
            }
            retVal += "Reversal #" + scriptNum.ToString() + " successful.\r\n";
            return(retVal);
        }
Example #15
0
        ///<summary>Fills grid based on values in _listEtrans.
        ///Set isRefreshNeeded to true when we need to reinitialize local dictionarys after in memory list is also updated. Required true for first time running.
        ///Also allows you to passed in predetermined filter options.</summary>
        private void FillGrid(bool isRefreshNeeded, List <string> listSelectedStatuses, List <long> listSelectedClinicNums,
                              string carrierName, string checkTraceNum, string amountMin, string amountMax, string controlId)
        {
            Cursor = Cursors.WaitCursor;
            labelControlId.Visible = PrefC.GetBool(PrefName.EraShowControlIdFilter);
            textControlId.Visible  = PrefC.GetBool(PrefName.EraShowControlIdFilter);
            Action actionCloseProgress = null;

            if (isRefreshNeeded)
            {
                actionCloseProgress = ODProgress.Show(ODEventType.Etrans, typeof(EtransEvent), Lan.g(this, "Gathering data") + "...");
                _dictEtrans835s.Clear();
                _dictEtransClaims.Clear();
                List <Etrans835Attach>    listAttached        = Etrans835Attaches.GetForEtrans(_listAllEtrans.Select(x => x.EtransNum).ToArray());
                Dictionary <long, string> dictEtransMessages  = new Dictionary <long, string>();
                List <X12ClaimMatch>      list835ClaimMatches = new List <X12ClaimMatch>();
                Dictionary <long, int>    dictClaimMatchCount = new Dictionary <long, int>(); //1:1 with _listEtranss. Stores how many claim matches each 835 has.
                int batchQueryInterval = 500;                                                 //Every 500 rows we get the next 500 message texts to save memory.
                int rowCur             = 0;
                foreach (Etrans etrans in _listAllEtrans)
                {
                    if (rowCur % batchQueryInterval == 0)
                    {
                        int range = Math.Min(batchQueryInterval, _listAllEtrans.Count - rowCur);                   //Either the full batchQueryInterval amount or the remaining amount of etrans.
                        dictEtransMessages = EtransMessageTexts.GetMessageTexts(_listAllEtrans.GetRange(rowCur, range).Select(x => x.EtransMessageTextNum).ToList(), false);
                    }
                    rowCur++;
                    EtransEvent.Fire(ODEventType.Etrans, Lan.g(this, "Processing 835: ") + ": " + rowCur + " out of " + _listAllEtrans.Count);
                    List <Etrans835Attach> listAttachedTo835 = listAttached.FindAll(x => x.EtransNum == etrans.EtransNum);
                    X835 x835 = new X835(etrans, dictEtransMessages[etrans.EtransMessageTextNum], etrans.TranSetId835, listAttachedTo835, true);
                    _dictEtrans835s.Add(etrans.EtransNum, x835);
                    List <X12ClaimMatch> listClaimMatches = x835.GetClaimMatches();
                    dictClaimMatchCount.Add(etrans.EtransNum, listClaimMatches.Count);
                    list835ClaimMatches.AddRange(listClaimMatches);
                }
                #region Set 835 unattached in batch and build _dictEtransClaims and _dictClaimPayCheckNums.
                EtransEvent.Fire(ODEventType.Etrans, Lan.g(this, "Gathering internal claim matches."));
                List <long> listClaimNums = Claims.GetClaimFromX12(list835ClaimMatches);             //Can return null.
                EtransEvent.Fire(ODEventType.Etrans, Lan.g(this, "Building data sets."));
                int         claimIndexCur        = 0;
                List <long> listMatchedClaimNums = new List <long>();
                foreach (Etrans etrans in _listAllEtrans)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    if (listClaimNums != null)
                    {
                        x835.SetClaimNumsForUnattached(listClaimNums.GetRange(claimIndexCur, dictClaimMatchCount[etrans.EtransNum]));
                    }
                    claimIndexCur += dictClaimMatchCount[etrans.EtransNum];
                    listMatchedClaimNums.AddRange(x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(x => x.ClaimNum).ToList());
                }
                List <Claim> listClaims = Claims.GetClaimsFromClaimNums(listMatchedClaimNums.Distinct().ToList());
                //The following line includes manually detached and split attaches.
                _listAllAttaches   = Etrans835Attaches.GetForEtransNumOrClaimNums(false, _listAllEtrans.Select(x => x.EtransNum).ToList(), listMatchedClaimNums.ToArray());
                _listAllClaimProcs = ClaimProcs.RefreshForClaims(listMatchedClaimNums);
                foreach (Etrans etrans in _listAllEtrans)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    #region _dictEtransClaims, _dictClaimPayCheckNums
                    _dictEtransClaims.Add(etrans.EtransNum, new List <Claim>());
                    List <long>  listSubClaimNums = x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(y => y.ClaimNum).ToList();
                    List <Claim> listClaimsFor835 = listClaims.FindAll(x => listSubClaimNums.Contains(x.ClaimNum));
                    foreach (Hx835_Claim claim in x835.ListClaimsPaid)
                    {
                        Claim claimCur = listClaimsFor835.FirstOrDefault(x => x.ClaimNum == claim.ClaimNum);                    //Can be null.
                        _dictEtransClaims[etrans.EtransNum].Add(claimCur);
                    }
                    #endregion
                }
                EtransEvent.Fire(ODEventType.Etrans, Lan.g(this, "Filling Grid."));
                #endregion
            }
            gridMain.BeginUpdate();
            #region Initilize columns
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Patient Name"), 250));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Carrier Name"), 190));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Status"), 80));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Date"), 80, GridSortingStrategy.DateParse));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Amount"), 80, GridSortingStrategy.AmountParse));
            if (PrefC.HasClinicsEnabled)
            {
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Clinic"), 70));
            }
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Code"), 37, HorizontalAlignment.Center));
            if (PrefC.GetBool(PrefName.EraShowControlIdFilter))
            {
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "ControlID"), -1));
            }
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableEtrans835s", "Note"), -2));
            #endregion
            gridMain.ListGridRows.Clear();
            foreach (Etrans etrans in _listAllEtrans)
            {
                X835 x835 = _dictEtrans835s[etrans.EtransNum];
                #region Filter: Carrier Name
                if (carrierName != "" && !x835.PayerName.ToLower().Contains(carrierName.ToLower().Trim()))
                {
                    continue;
                }
                #endregion
                string status = GetStringStatus(etrans.EtransNum);
                #region Filter: Status
                if (!listSelectedStatuses.Contains(status.Replace("*", "")))                //The filter will ignore finalized with detached claims.
                {
                    continue;
                }
                #endregion
                //List of ClinicNums for the current etrans.ListClaimsPaid from the DB.
                List <long> listClinicNums = _dictEtransClaims[etrans.EtransNum].Select(x => x == null? 0 :x.ClinicNum).Distinct().ToList();
                #region Filter: Clinics
                if (PrefC.HasClinicsEnabled && !listClinicNums.Exists(x => listSelectedClinicNums.Contains(x)))
                {
                    continue;                    //The ClinicNums associated to the 835 do not match any of the selected ClinicNums, so nothing to show in this 835.
                }
                #endregion
                #region Filter: Check and Trace Value
                if (checkTraceNum != "" && !x835.TransRefNum.ToLower().Contains(checkTraceNum.ToLower().Trim()))               //Trace Number does not match
                {
                    continue;
                }
                #endregion
                #region Filter: Insurance Check Range Min and Max
                if (amountMin != "" && x835.InsPaid < PIn.Decimal(amountMin) || amountMax != "" && x835.InsPaid > PIn.Decimal(amountMax))
                {
                    continue;                    //Either the InsPaid is below or above our range.
                }
                #endregion
                #region Filter: ControlID
                if (controlId != "" && !x835.ControlId.ToLower().Contains(controlId.ToLower()))
                {
                    continue;
                }
                #endregion
                GridRow row = new GridRow();
                #region Column: Patient Name
                List <string> listPatNames = x835.ListClaimsPaid.Select(x => x.PatientName.ToString()).Distinct().ToList();
                string        patName      = (listPatNames.Count > 0 ? listPatNames[0] : "");
                if (listPatNames.Count > 1)
                {
                    patName = "(" + POut.Long(listPatNames.Count) + ")";
                }
                row.Cells.Add(patName);
                #endregion
                row.Cells.Add(x835.PayerName);
                row.Cells.Add(status);                //See GetStringStatus(...) for possible values.
                row.Cells.Add(POut.Date(etrans.DateTimeTrans));
                row.Cells.Add(POut.Decimal(x835.InsPaid));
                #region Column: Clinic
                if (PrefC.HasClinicsEnabled)
                {
                    string clinicAbbr = "";
                    if (listClinicNums.Count == 1)
                    {
                        if (listClinicNums[0] == 0)
                        {
                            clinicAbbr = Lan.g(this, "Unassigned");
                        }
                        else
                        {
                            clinicAbbr = Clinics.GetAbbr(listClinicNums[0]);
                        }
                    }
                    else if (listClinicNums.Count > 1)
                    {
                        clinicAbbr = "(" + Lan.g(this, "Multiple") + ")";
                    }
                    row.Cells.Add(clinicAbbr);
                }
                #endregion
                row.Cells.Add(x835._paymentMethodCode);
                if (PrefC.GetBool(PrefName.EraShowControlIdFilter))
                {
                    row.Cells.Add(x835.ControlId);
                }
                row.Cells.Add(etrans.Note);
                row.Tag = etrans;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            actionCloseProgress?.Invoke();            //When this function executes quickly this can fail rarely, fail silently because of WaitCursor.
            Cursor = Cursors.Default;
        }
Example #16
0
        ///<summary>Called from Eclaims and includes multiple claims.</summary>
        public static string SendBatch(Clearinghouse clearinghouseClin, List <ClaimSendQueueItem> queueItems, int batchNum)
        {
            //STEP 1 - Build XML output.
            List <DP_RACINDP>    listDps       = new List <DP_RACINDP>();
            List <ProcedureCode> listProcCodes = ProcedureCodes.GetAllCodes();
            List <Etrans>        listEtrans    = new List <Etrans>();

            foreach (ClaimSendQueueItem queueItem in queueItems)
            {
                Etrans etrans = Etranss.SetClaimSentOrPrinted(queueItem.ClaimNum, queueItem.PatNum, clearinghouseClin.HqClearinghouseNum, EtransType.Claim_Ramq, batchNum, Security.CurUser.UserNum);
                listEtrans.Add(etrans);
                //Now we need to update our cache of claims to reflect the change that took place in the database above in Etranss.SetClaimSentOrPrinted()
                queueItem.ClaimStatus = "S";
                Claim      claim          = Claims.GetClaim(queueItem.ClaimNum);
                Provider   provClaimTreat = Providers.GetProv(claim.ProvTreat);
                DP_RACINDP dp             = new DP_RACINDP();
                #region Header
                dp.CHN           = DP_RACINDPCHN.Item06;
                dp.CHNSpecified  = true;
                dp.ENRG          = DP_RACINDPENRG.Item1;
                dp.ENRGSpecified = true;
                //We hijack the TaxID number for the TRNSM field.  The TRNSM is a office identifying number.  Test range for developers is 18000 to 18999.
                dp.TRNSM = clearinghouseClin.SenderTIN;
                dp.DISP  = provClaimTreat.NationalProvID;
                //dp.CPTE_ADMN=;//Administrative account number.  Not currently used.
                JulianCalendar calendar = new JulianCalendar();
                dp.ATTES = (DateTime.Now.Year % 10).ToString()                               //One digit for year
                           + calendar.GetDayOfYear(DateTime.Now).ToString().PadLeft(3, '0')  //3 digits for Julian day of year.
                           + (etrans.CarrierTransCounter % 1000).ToString().PadLeft(3, '0'); //3 digits for sequence number.
                dp.NCE        = (etrans.CarrierTransCounter % 10000).ToString().PadLeft(4, '0');
                dp.DISP_REFNT = claim.CanadianReferralProviderNum.Trim();
                //dp.DIAGN=;//Diagnostic code.  Not currently used.
                dp.ETAB = provClaimTreat.CanadianOfficeNum;              //Usually empty.
                //dp.ADMIS=;//Date of patient admission.  Not currently used.  This would be the same as the date of service for dental claims anyway.
                //dp.SORTI=;//Date patient discharged.  Not currently used.  This would be the same as the date of service for dental claims anyway.
                dp.TOT_DEM = claim.ClaimFee.ToString().Replace(".", "").PadLeft(6, '0');
                dp.COMPL   = TidyStr(claim.ClaimNote, 200);
                //dp.CS=;//Not sure what this is.  Not currently used.
                //dp.AUTOR=claim.PreAuthString;//Authorization number when invoicing acrylic prostheses. Required if DAT_AUTOR is present. Not currently used.
                //dp.DAT_AUTOR=claim.CanadianDateInitialLower;//Date of authorization when invoicing acrylic prostheses. Format YYMMDD. Not currently used.
                dp.SERV = claim.DateService.ToString("yyMMdd");
                #endregion Header
                #region Insurance
                //Most fields in the insuranace section are optional.
                InsSub insSub = InsSubs.GetOne(claim.InsSubNum);
                dp.PERS_ASSU     = new DP_RACINDPPERS_ASSU();
                dp.PERS_ASSU.NAM = insSub.SubscriberID;
                Patient pat = Patients.GetPat(claim.PatNum);
                dp.PERS_ASSU.PRE = TidyStr(pat.FName, 20);
                dp.PERS_ASSU.NOM = TidyStr(pat.LName, 30);
                if (pat.Birthdate.Year > 1880)
                {
                    dp.PERS_ASSU.NAISS = pat.Birthdate.ToString("yyyyMMdd");
                }
                if (pat.Gender == PatientGender.Male)
                {
                    dp.PERS_ASSU.SEXE = DP_RACINDPPERS_ASSUSEXE.M;
                }
                else if (pat.Gender == PatientGender.Female)
                {
                    dp.PERS_ASSU.SEXE = DP_RACINDPPERS_ASSUSEXE.F;
                }
                else
                {
                    //There is no value for UNKNOWN.  This field is optional if the subscriber ID is present anyway.
                }
                List <PatPlan> listPatPlans = PatPlans.Refresh(claim.PatNum);
                PatPlan        patPlan      = PatPlans.GetByInsSubNum(listPatPlans, insSub.InsSubNum);
                dp.PERS_ASSU.CAM = patPlan.PatID;
                if (insSub.DateTerm.Year > 1880)
                {
                    dp.PERS_ASSU.EXPIR_CAM = insSub.DateTerm.ToString("yyMM");
                }
                InsPlan insPlan  = InsPlans.RefreshOne(claim.PlanNum);
                InsPlan insPlan2 = InsPlans.RefreshOne(claim.PlanNum2);
                Carrier carrier  = null;
                if (claim.ClaimType == "S")
                {
                    carrier = Carriers.GetCarrier(insPlan2.CarrierNum);
                }
                else
                {
                    carrier = Carriers.GetCarrier(insPlan.CarrierNum);
                }
                if (carrier.Address.Trim() != "")
                {
                    dp.PERS_ASSU.ADR_1 = carrier.Address;
                    dp.PERS_ASSU.ADR_2 = carrier.Address2;
                    dp.PERS_ASSU.CP    = carrier.Zip;
                }
                #endregion Insurance
                #region Procedures
                List <ClaimProc>      listClaimProcsForPat   = ClaimProcs.Refresh(claim.PatNum);
                List <ClaimProc>      listClaimProcsForClaim = ClaimProcs.GetForSendClaim(listClaimProcsForPat, claim.ClaimNum);        //Excludes labs.
                List <Procedure>      listProcsForPat        = Procedures.Refresh(claim.PatNum);
                List <DP_RACINDPACTE> listProcs = new List <DP_RACINDPACTE>();
                foreach (ClaimProc claimProc in listClaimProcsForClaim)
                {
                    Procedure proc = Procedures.GetProcFromList(listProcsForPat, claimProc.ProcNum);
                    if (proc.ProcFee == 0)
                    {
                        continue;
                    }
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum, listProcCodes);
                    if (procCode.NoBillIns)
                    {
                        continue;
                    }
                    DP_RACINDPACTE acteProc = new DP_RACINDPACTE();
                    acteProc.ACTE = procCode.ProcCode;
                    if (procCode.ProcCode.Length > 5)
                    {
                        acteProc.ACTE = procCode.ProcCode.Substring(0, 5);
                    }
                    acteProc.ROLE = "1";                  //1 for principal role and 2 for assistant role.
                    //acte.MODIF=;//Optional.  Not sure what to put here, so leaving blank for now.
                    acteProc.UNIT = proc.UnitQty.ToString().PadLeft(3, '0');
                    acteProc.MNT  = proc.ProcFee.ToString("F").Replace(".", "").PadLeft(6, '0');
                    acteProc.DENT = proc.ToothNum.ToString().PadLeft(2, '0');
                    acteProc.SURF = proc.Surf.ToString().PadLeft(2, '0');
                    listProcs.Add(acteProc);
                    List <Procedure> listLabProcs = Procedures.GetCanadianLabFees(proc.ProcNum, listProcsForPat);
                    foreach (Procedure labProc in listLabProcs)
                    {
                        if (labProc.ProcFee == 0)
                        {
                            continue;
                        }
                        ProcedureCode  labProcCode = ProcedureCodes.GetProcCode(labProc.CodeNum, listProcCodes);
                        DP_RACINDPACTE acteLab     = new DP_RACINDPACTE();
                        acteLab.ACTE = labProcCode.ProcCode;
                        if (labProcCode.ProcCode.Length > 5)
                        {
                            acteLab.ACTE = labProcCode.ProcCode.Substring(0, 5);
                        }
                        acteLab.ROLE = "1";                      //1 for principal role and 2 for assistant role.
                        acteLab.MNT  = labProc.ProcFee.ToString("F").Replace(".", "").PadLeft(6, '0');
                        listProcs.Add(acteLab);
                    }
                }
                dp.ACTE = listProcs.ToArray();
                #endregion Procedures
                listDps.Add(dp);
            }
            DP_RACIN batch = new DP_RACIN();
            batch.DP = listDps.ToArray();
            StringWriter  sw         = new StringWriter();
            XmlSerializer serializer = new XmlSerializer(typeof(DP_RACIN));
            serializer.Serialize(sw, batch);
            string xml = sw.ToString();
            //Save a copy of the batch xml to each etrans entry (one per claim).
            EtransMessageText etransMsgText = new EtransMessageText();
            etransMsgText.MessageText = xml;
            EtransMessageTexts.Insert(etransMsgText);
            foreach (Etrans etrans in listEtrans)
            {
                etrans.EtransMessageTextNum = etransMsgText.EtransMessageTextNum;
                Etranss.Update(etrans);
            }
            //Step 2 - ZIP XML and save to report path.  The zip file name and file name within the zip file do not matter.
            string  zipFilePath = CodeBase.ODFileUtils.CreateRandomFile(clearinghouseClin.ExportPath, ".zip", "claims");
            ZipFile zip         = null;
            try {
                zip = new ZipFile();
                zip.UseZip64WhenSaving = Zip64Option.Always;
                zip.AddEntry("claims" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xml", xml);
                zip.Save(zipFilePath);
                zip.Dispose();
            }
            catch (Exception ex) {
                ex.ToString();
                if (zip != null)
                {
                    zip.Dispose();
                }
                if (File.Exists(zipFilePath))
                {
                    try {
                        File.Delete(zipFilePath);
                    }
                    catch (Exception ex2) {
                        ex2.ToString();
                    }
                }
            }
            return(xml);
        }
Example #17
0
        ///<summary>Fills grid based on values in _listEtrans.
        ///Set isRefreshNeeded to true when we need to reinitialize local dictionarys after in memory list is also updated. Required true for first time running.
        ///Also allows you to passed in predetermined filter options.</summary>
        private void FillGrid(bool isRefreshNeeded, List <string> listSelectedStatuses, List <long> listSelectedClinicNums,
                              string carrierName, string checkTraceNum, string amountMin, string amountMax)
        {
            Action actionCloseProgress = null;

            if (isRefreshNeeded)
            {
                actionCloseProgress = ODProgressOld.ShowProgressStatus("Etrans835", this, Lan.g(this, "Gathering data") + "...", false);
                _dictEtrans835s.Clear();
                _dictEtransClaims.Clear();
                _dictClaimPayExists.Clear();
                List <Etrans835Attach>    listAttached        = Etrans835Attaches.GetForEtrans(_listEtranss.Select(x => x.EtransNum).ToArray());
                Dictionary <long, string> dictEtransMessages  = new Dictionary <long, string>();
                List <X12ClaimMatch>      list835ClaimMatches = new List <X12ClaimMatch>();
                Dictionary <long, int>    dictClaimMatchCount = new Dictionary <long, int>(); //1:1 with _listEtranss. Stores how many claim matches each 835 has.
                int batchQueryInterval = 500;                                                 //Every 500 rows we get the next 500 message texts to save memory.
                int rowCur             = 0;
                foreach (Etrans etrans in _listEtranss)
                {
                    if (rowCur % batchQueryInterval == 0)
                    {
                        int range = Math.Min(batchQueryInterval, _listEtranss.Count - rowCur);                   //Either the full batchQueryInterval amount or the remaining amount of etrans.
                        dictEtransMessages = EtransMessageTexts.GetMessageTexts(_listEtranss.GetRange(rowCur, range).Select(x => x.EtransMessageTextNum).ToList(), false);
                    }
                    rowCur++;
                    ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Processing 835: ") + ": " + rowCur + " out of " + _listEtranss.Count));
                    List <Etrans835Attach> listAttachedTo835 = listAttached.FindAll(x => x.EtransNum == etrans.EtransNum);
                    X835 x835 = new X835(etrans, dictEtransMessages[etrans.EtransMessageTextNum], etrans.TranSetId835, listAttachedTo835, true);
                    _dictEtrans835s.Add(etrans.EtransNum, x835);
                    List <X12ClaimMatch> listClaimMatches = x835.GetClaimMatches();
                    dictClaimMatchCount.Add(etrans.EtransNum, listClaimMatches.Count);
                    list835ClaimMatches.AddRange(listClaimMatches);
                }
                #region Set 835 unattached in batch and build _dictEtransClaims and _dictClaimPayCheckNums.
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Gathering internal claim matches.")));
                List <long> listClaimNums = Claims.GetClaimFromX12(list835ClaimMatches);             //Can return null.
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Building data sets.")));
                int         claimIndexCur        = 0;
                List <long> listMatchedClaimNums = new List <long>();
                foreach (Etrans etrans in _listEtranss)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    if (listClaimNums != null)
                    {
                        x835.SetClaimNumsForUnattached(listClaimNums.GetRange(claimIndexCur, dictClaimMatchCount[etrans.EtransNum]));
                    }
                    claimIndexCur += dictClaimMatchCount[etrans.EtransNum];
                    listMatchedClaimNums.AddRange(x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(x => x.ClaimNum).ToList());
                }
                List <Claim> listClaims = Claims.GetClaimsFromClaimNums(listMatchedClaimNums.Distinct().ToList());
                _dictClaimPayExists = ClaimPayments.HasClaimPayment(listMatchedClaimNums);              //Every claim num is associated to a bool. True when there is an existing claimPayment.
                foreach (Etrans etrans in _listEtranss)
                {
                    X835 x835 = _dictEtrans835s[etrans.EtransNum];
                    #region _dictEtransClaims, _dictClaimPayCheckNums
                    _dictEtransClaims.Add(etrans.EtransNum, new List <Claim>());
                    List <long>  listSubClaimNums = x835.ListClaimsPaid.FindAll(x => x.ClaimNum != 0).Select(y => y.ClaimNum).ToList();
                    List <Claim> listClaimsFor835 = listClaims.FindAll(x => listSubClaimNums.Contains(x.ClaimNum));
                    foreach (Hx835_Claim claim in x835.ListClaimsPaid)
                    {
                        Claim claimCur = listClaimsFor835.FirstOrDefault(x => x.ClaimNum == claim.ClaimNum);                    //Can be null.
                        if (claimCur == null && claim.IsAttachedToClaim && claim.ClaimNum == 0)
                        {
                            claimCur = new Claim();                          //Create empty claim since user detached claim manually, will not be considered in GetStringStatus(...).
                        }
                        if (claimCur != null && claim.IsPreauth)             //User attached preauth to internal claim, no payment needed to be considered 'Finalized' in GetStringStatus(...).
                        {
                            _dictClaimPayExists[claim.ClaimNum] = true;
                        }
                        _dictEtransClaims[etrans.EtransNum].Add(claimCur);
                    }
                    #endregion
                }
                ODEvent.Fire(new ODEventArgs("Etrans835", Lan.g(this, "Filling Grid.")));
                #endregion
            }
            gridMain.BeginUpdate();
            #region Initilize columns only once
            if (gridMain.Columns.Count == 0)
            {
                ODGridColumn col;
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Patient Name"), 250);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Carrier Name"), 190);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Status"), 80);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Date"), 80);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Amount"), 80);
                gridMain.Columns.Add(col);
                if (PrefC.HasClinicsEnabled)
                {
                    col = new ODGridColumn(Lan.g("TableEtrans835s", "Clinic"), 70);
                    gridMain.Columns.Add(col);
                }
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Code"), 37, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableEtrans835s", "Note"), 0);
                gridMain.Columns.Add(col);
            }
            #endregion
            gridMain.Rows.Clear();
            foreach (Etrans etrans in _listEtranss)
            {
                X835 x835 = _dictEtrans835s[etrans.EtransNum];
                #region Filter: Carrier Name
                if (carrierName != "" && !x835.PayerName.ToLower().Contains(carrierName.ToLower()))
                {
                    continue;
                }
                #endregion
                string status = GetStringStatus(etrans.EtransNum);
                #region Filter: Status
                if (!listSelectedStatuses.Contains(status.Replace("*", "")))                //The filter will ignore finalized with detached claims.
                {
                    continue;
                }
                #endregion
                //List of ClinicNums for the current etrans.ListClaimsPaid from the DB.
                List <long> listClinicNums = _dictEtransClaims[etrans.EtransNum].Select(x => x == null? 0 :x.ClinicNum).Distinct().ToList();
                #region Filter: Clinics
                if (PrefC.HasClinicsEnabled && !listClinicNums.Exists(x => listSelectedClinicNums.Contains(x)))
                {
                    continue;                    //The ClinicNums associated to the 835 do not match any of the selected ClinicNums, so nothing to show in this 835.
                }
                #endregion
                #region Filter: Check and Trace Value
                if (checkTraceNum != "" && !x835.TransRefNum.Contains(checkTraceNum))               //Trace Number does not match
                {
                    continue;
                }
                #endregion
                #region Filter: Insurance Check Range Min and Max
                if (amountMin != "" && x835.InsPaid < PIn.Decimal(amountMin) || amountMax != "" && x835.InsPaid > PIn.Decimal(amountMax))
                {
                    continue;                    //Either the InsPaid is below or above our range.
                }
                #endregion
                ODGridRow row = new ODGridRow();
                #region Column: Patient Name
                List <string> listPatNames = x835.ListClaimsPaid.Select(x => x.PatientName.ToString()).Distinct().ToList();
                string        patName      = (listPatNames.Count > 0 ? listPatNames[0] : "");
                if (listPatNames.Count > 1)
                {
                    patName = "(" + POut.Long(listPatNames.Count) + ")";
                }
                row.Cells.Add(patName);
                #endregion
                row.Cells.Add(x835.PayerName);
                row.Cells.Add(status);                //See GetStringStatus(...) for possible values.
                row.Cells.Add(POut.Date(etrans.DateTimeTrans));
                row.Cells.Add(POut.Decimal(x835.InsPaid));
                #region Column: Clinic
                if (PrefC.HasClinicsEnabled)
                {
                    string clinicAbbr = "";
                    if (listClinicNums.Count == 1)
                    {
                        if (listClinicNums[0] == 0)
                        {
                            clinicAbbr = Lan.g(this, "Unassigned");
                        }
                        else
                        {
                            clinicAbbr = Clinics.GetAbbr(listClinicNums[0]);
                        }
                    }
                    else if (listClinicNums.Count > 1)
                    {
                        clinicAbbr = "(" + Lan.g(this, "Multiple") + ")";
                    }
                    row.Cells.Add(clinicAbbr);
                }
                #endregion
                row.Cells.Add(x835._paymentMethodCode);
                row.Cells.Add(etrans.Note);
                row.Tag = etrans;
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            actionCloseProgress?.Invoke();
        }
Example #18
0
        ///<summary>The insplan that's passed in need not be properly updated to the database first.</summary>
        public static void RequestBenefits(Clearinghouse clearhouse, InsPlan plan, long patNum, Carrier carrier, List <Benefit> benList, long patPlanNum, InsSub insSub)
        {
            Patient  pat      = Patients.GetPat(patNum);
            Patient  subsc    = Patients.GetPat(insSub.Subscriber);
            Clinic   clinic   = Clinics.GetClinic(pat.ClinicNum);
            Provider billProv = Providers.GetProv(Providers.GetBillingProvNum(pat.PriProv, pat.ClinicNum));
            //validation.  Throw exception if missing info----------------------------------------
            string validationResult = X270.Validate(clearhouse, carrier, billProv, clinic, plan, subsc, insSub);

            if (validationResult != "")
            {
                throw new Exception(Lan.g("FormInsPlan", "Please fix the following errors first:") + "\r\n" + validationResult);
            }
            //create a 270 message---------------------------------------------------------------
            string            x12message        = X270.GenerateMessageText(clearhouse, carrier, billProv, clinic, plan, subsc, insSub);
            EtransMessageText etransMessageText = new EtransMessageText();

            etransMessageText.MessageText = x12message;
            EtransMessageTexts.Insert(etransMessageText);
            //attach it to an etrans-------------------------------------------------------------
            Etrans etrans = new Etrans();

            etrans.DateTimeTrans        = DateTime.Now;
            etrans.ClearingHouseNum     = clearhouse.ClearinghouseNum;
            etrans.Etype                = EtransType.BenefitInquiry270;
            etrans.PlanNum              = plan.PlanNum;
            etrans.InsSubNum            = insSub.InsSubNum;
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans);
            //send the 270----------------------------------------------------------------------
            string x12response = "";

            //a connection error here needs to bubble up
            try {
                if (clearhouse.CommBridge == EclaimsCommBridge.ClaimConnect)
                {
                    x12response = ClaimConnect.Benefits270(clearhouse, x12message);
                }
            }
            catch (Exception ex) {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lan.g("FormInsPlan", "Connection Error:") + "\r\n" + ex.GetType().Name + "\r\n" + ex.Message);
            }
            //start to process the 271----------------------------------------------------------
            X271 x271 = null;

            if (X12object.IsX12(x12response))
            {
                X12object x12obj = new X12object(x12response);
                if (x12obj.Is271())
                {
                    x271 = new X271(x12response);
                }
            }
            else              //neither a 997 nor a 271
            {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lan.g("FormInsPlan", "Error:") + "\r\n" + x12response);
            }

            /*
             * //In realtime mode, X12 limits the request to one patient.
             * //We will always use the subscriber.
             * //So all EB segments are for the subscriber.
             * List<EB271> listEB=new List<EB271>();
             * EB271 eb;
             * if(x271 != null) {
             *      for(int i=0;i<x271.Segments.Count;i++) {
             *              if(x271.Segments[i].SegmentID != "EB") {
             *                      continue;
             *              }
             *              eb=new EB271(x271.Segments[i]);
             *              listEB.Add(eb);
             *      }
             * }*/
            //create an etrans for the 271------------------------------------------------------
            etransMessageText             = new EtransMessageText();
            etransMessageText.MessageText = x12response;
            EtransMessageTexts.Insert(etransMessageText);
            Etrans etrans271 = new Etrans();

            etrans271.DateTimeTrans    = DateTime.Now;
            etrans271.ClearingHouseNum = clearhouse.ClearinghouseNum;
            etrans271.Etype            = EtransType.TextReport;
            if (X12object.IsX12(x12response))             //this shouldn't need to be tested because it was tested above.
            {
                if (x271 == null)
                {
                    etrans271.Etype = EtransType.Acknowledge_997;
                }
                else
                {
                    etrans271.Etype = EtransType.BenefitResponse271;
                }
            }
            etrans271.PlanNum              = plan.PlanNum;
            etrans271.InsSubNum            = insSub.InsSubNum;
            etrans271.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans271);
            etrans.AckEtransNum = etrans271.EtransNum;
            if (etrans271.Etype == EtransType.Acknowledge_997)
            {
                X997   x997     = new X997(x12response);
                string error997 = x997.GetHumanReadable();
                etrans.Note = "Error: " + error997;            //"Malformed document sent.  997 error returned.";
                Etranss.Update(etrans);
                MessageBox.Show(etrans.Note);
                //CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
                //msgbox.ShowDialog();
                //don't show the 270 interface.
                return;
            }
            else
            {
                string processingerror = x271.GetProcessingError();
                if (processingerror != "")
                {
                    etrans.Note = processingerror;
                    Etranss.Update(etrans);
                    MessageBox.Show(etrans.Note);
                    //CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
                    //msgbox.ShowDialog();
                    //don't show the 270 interface.
                    return;
                }
                else
                {
                    etrans.Note = "Normal 271 response.";                  //change this later to be explanatory of content.
                }
            }
            Etranss.Update(etrans);
            //show the user a list of benefits to pick from for import--------------------------
            FormEtrans270Edit formE = new FormEtrans270Edit(patPlanNum, plan.PlanNum, insSub.InsSubNum);

            formE.EtransCur         = etrans;
            formE.IsInitialResponse = true;
            formE.benList           = benList;
            formE.ShowDialog();
        }
Example #19
0
 private void FormEtrans835Edit_Load(object sender, EventArgs e)
 {
     MessageText = EtransMessageTexts.GetMessageText(EtransCur.EtransMessageTextNum);
     x835        = new X835(MessageText);
     FillAll();
 }
Example #20
0
        ///<summary>Supply a list of ClaimSendQueueItems.  Called from FormClaimSend.  Can only send to one clearinghouse at a time.
        ///The queueItems must contain at least one item.  Each item in queueItems must have the same ClinicNum.  Cannot include Canadian.</summary>
        public static void SendBatch(Clearinghouse clearinghouseClin, List <ClaimSendQueueItem> queueItems, EnumClaimMedType medType,
                                     IFormClaimFormItemEdit formClaimFormItemEdit, Renaissance.FillRenaissanceDelegate fillRenaissance, ITerminalConnector terminalConnector)
        {
            string messageText = "";

            if (clearinghouseClin.Eformat == ElectronicClaimFormat.Canadian)
            {
                MessageBox.Show(Lans.g("Eclaims", "Cannot send Canadian claims as part of Eclaims.SendBatch."));
                return;
            }
            //get next batch number for this clearinghouse
            int batchNum = Clearinghouses.GetNextBatchNumber(clearinghouseClin);

            //---------------------------------------------------------------------------------------
            //Create the claim file for this clearinghouse
            if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_4010 ||
                clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
                clearinghouseClin.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
            {
                messageText = x837Controller.SendBatch(clearinghouseClin, queueItems, batchNum, medType, false);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
            {
                messageText = Renaissance.SendBatch(clearinghouseClin, queueItems, batchNum, formClaimFormItemEdit, fillRenaissance);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Dutch)
            {
                messageText = Dutch.SendBatch(clearinghouseClin, queueItems, batchNum);
            }
            else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Ramq)
            {
                messageText = Ramq.SendBatch(clearinghouseClin, queueItems, batchNum);
            }
            else
            {
                messageText = "";      //(ElectronicClaimFormat.None does not get sent)
            }
            if (messageText == "")     //if failed to create claim file properly,
            {
                return;                //don't launch program or change claim status
            }
            //----------------------------------------------------------------------------------------
            //Launch Client Program for this clearinghouse if applicable
            if (clearinghouseClin.CommBridge == EclaimsCommBridge.None)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.WebMD)
            {
                if (!WebMD.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + WebMD.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.BCBSGA)
            {
                if (!BCBSGA.Launch(clearinghouseClin, batchNum, terminalConnector))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + BCBSGA.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Renaissance)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.ClaimConnect)
            {
                if (ClaimConnect.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show("Upload successful.");
                }
                else
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + ClaimConnect.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.RECS)
            {
                if (!RECS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch RECS client.") + "\r\n" + RECS.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Inmediata)
            {
                if (!Inmediata.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch Inmediata client.") + "\r\n" + Inmediata.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.AOS)           // added by SPK 7/13/05
            {
                if (!AOS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but could not launch AOS Communicator.") + "\r\n" + AOS.ErrorMessage);
                    //continue;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.PostnTrack)
            {
                AttemptLaunch(clearinghouseClin, batchNum);
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.MercuryDE)
            {
                if (!MercuryDE.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + MercuryDE.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.ClaimX)
            {
                if (!ClaimX.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Claim file created, but encountered an error while launching ClaimX Client.") + ":\r\n" + ClaimX.ErrorMessage);
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.EmdeonMedical)
            {
                if (!EmdeonMedical.Launch(clearinghouseClin, batchNum, medType))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + EmdeonMedical.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.DentiCal)
            {
                if (!DentiCal.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + DentiCal.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.NHS)
            {
                if (!NHS.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + NHS.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.EDS)
            {
                if (!EDS.Launch(clearinghouseClin, messageText))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + "\r\n" + EDS.ErrorMessage);
                    return;
                }
            }
            else if (clearinghouseClin.CommBridge == EclaimsCommBridge.Ramq)
            {
                if (!Ramq.Launch(clearinghouseClin, batchNum))
                {
                    MessageBox.Show(Lans.g("Eclaims", "Error sending.") + Ramq.ErrorMessage);
                    return;
                }
            }
            //----------------------------------------------------------------------------------------
            //finally, mark the claims sent. (only if not Canadian)
            EtransType etype = EtransType.ClaimSent;

            if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
            {
                etype = EtransType.Claim_Ren;
            }
            //Canadians cannot send in batches (see above).  RAMQ is performing a similar algorithm but the steps are in a different order in Ramq.cs.
            if (clearinghouseClin.Eformat != ElectronicClaimFormat.Canadian && clearinghouseClin.Eformat != ElectronicClaimFormat.Ramq)
            {
                //Create the etransmessagetext that all claims in the batch will point to.
                EtransMessageText etransMsgText = new EtransMessageText();
                etransMsgText.MessageText = messageText;
                EtransMessageTexts.Insert(etransMsgText);
                for (int j = 0; j < queueItems.Count; j++)
                {
                    Etrans etrans = Etranss.SetClaimSentOrPrinted(queueItems[j].ClaimNum, queueItems[j].PatNum,
                                                                  clearinghouseClin.HqClearinghouseNum, etype, batchNum, Security.CurUser.UserNum);
                    etrans.EtransMessageTextNum = etransMsgText.EtransMessageTextNum;
                    Etranss.Update(etrans);
                    //Now we need to update our cache of claims to reflect the change that took place in the database above in Etranss.SetClaimSentOrPrinted()
                    queueItems[j].ClaimStatus = "S";
                }
            }
        }
Example #21
0
        ///<summary>Throws exceptions. The insplan that's passed in need not be properly updated to the database first.</summary>
        ///<returns>The Etrans created from the request. Will be null if the request failed in any way.</returns>
        public static Etrans RequestBenefits(Clearinghouse clearinghouseClin, InsPlan plan, long patNum, Carrier carrier, InsSub insSub, out string error)
        {
            error = "";
            Patient  pat      = Patients.GetPat(patNum);
            Patient  subsc    = Patients.GetPat(insSub.Subscriber);
            Clinic   clinic   = Clinics.GetClinic(pat.ClinicNum);
            Provider billProv = Providers.GetProv(Providers.GetBillingProvNum(pat.PriProv, pat.ClinicNum));
            //validation.  Throw exception if missing info----------------------------------------
            string validationResult = X270.Validate(clearinghouseClin, carrier, billProv, clinic, plan, subsc, insSub, pat);

            if (validationResult != "")
            {
                throw new Exception(Lans.g("FormInsPlan", "Please fix the following errors first:") + "\r\n" + validationResult);
            }
            //create a 270 message---------------------------------------------------------------
            string            x12message        = X270.GenerateMessageText(clearinghouseClin, carrier, billProv, clinic, plan, subsc, insSub, pat);
            EtransMessageText etransMessageText = new EtransMessageText();

            etransMessageText.MessageText = x12message;
            EtransMessageTexts.Insert(etransMessageText);
            //attach it to an etrans-------------------------------------------------------------
            Etrans etrans = new Etrans();

            etrans.PatNum               = patNum;
            etrans.DateTimeTrans        = DateTime.Now;
            etrans.ClearingHouseNum     = clearinghouseClin.HqClearinghouseNum;
            etrans.Etype                = EtransType.BenefitInquiry270;
            etrans.PlanNum              = plan.PlanNum;
            etrans.InsSubNum            = insSub.InsSubNum;
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans);
            //send the 270----------------------------------------------------------------------
            string x12response = "";
            Etrans etransHtml  = null;

            //a connection error here needs to bubble up
            try {
                if (!String.IsNullOrWhiteSpace(FakeResponseOverride271))
                {
                    x12response = FakeResponseOverride271;
                }
                else if (clearinghouseClin.CommBridge == EclaimsCommBridge.ClaimConnect)
                {
                    x12response = ClaimConnect.Benefits270(clearinghouseClin, x12message);
                }
                else if (clearinghouseClin.CommBridge == EclaimsCommBridge.EDS)
                {
                    x12response = EDS.Benefits270(clearinghouseClin, x12message, out etransHtml);
                }
                else if (clearinghouseClin.CommBridge == EclaimsCommBridge.WebMD)
                {
                    x12response = WebMD.Benefits270(clearinghouseClin, x12message);
                }
            }
            catch (Exception ex) {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lans.g("FormInsPlan", "Connection Error:") + "\r\n" + ex.GetType().Name + "\r\n" + ex.Message);
            }
            //start to process the 271----------------------------------------------------------
            X271 x271 = null;

            if (X12object.IsX12(x12response))
            {
                X12object x12obj = new X12object(x12response);
                if (x12obj.Is271())
                {
                    x271 = new X271(x12response);
                }
            }
            else              //not a 997, 999, 277 or 271
            {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lans.g("FormInsPlan", "Error:") + "\r\n" + x12response);
            }

            /*
             * //In realtime mode, X12 limits the request to one patient.
             * //We will always use the subscriber.
             * //So all EB segments are for the subscriber.
             * List<EB271> listEB=new List<EB271>();
             * EB271 eb;
             * if(x271 != null) {
             *      for(int i=0;i<x271.Segments.Count;i++) {
             *              if(x271.Segments[i].SegmentID != "EB") {
             *                      continue;
             *              }
             *              eb=new EB271(x271.Segments[i]);
             *              listEB.Add(eb);
             *      }
             * }*/
            //create an etrans for the 271------------------------------------------------------
            etransMessageText             = new EtransMessageText();
            etransMessageText.MessageText = x12response;
            EtransMessageTexts.Insert(etransMessageText);
            Etrans etrans271 = new Etrans();

            etrans271.PatNum           = patNum;
            etrans271.DateTimeTrans    = DateTime.Now;
            etrans271.ClearingHouseNum = clearinghouseClin.HqClearinghouseNum;
            etrans271.Etype            = EtransType.TextReport;
            if (X12object.IsX12(x12response))             //this shouldn't need to be tested because it was tested above.
            {
                if (x271 == null)
                {
                    X12object Xobj = new X12object(x12response);
                    if (Xobj.Is997())
                    {
                        etrans271.Etype = EtransType.Acknowledge_997;
                    }
                    else if (Xobj.Is999())
                    {
                        etrans271.Etype = EtransType.Acknowledge_999;
                    }
                    else if (X277.Is277(Xobj))
                    {
                        etrans271.Etype = EtransType.StatusNotify_277;
                    }
                    else if (X835.Is835(Xobj))
                    {
                        etrans271.Etype = EtransType.ERA_835;
                    }
                    else if (Xobj.IsAckInterchange())
                    {
                        etrans271.Etype = EtransType.Ack_Interchange;
                    }
                }
                else
                {
                    etrans271.Etype = EtransType.BenefitResponse271;
                }
            }
            etrans271.PlanNum              = plan.PlanNum;
            etrans271.InsSubNum            = insSub.InsSubNum;
            etrans271.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            etrans271.MessageText          = etransMessageText.MessageText; //Not a DB column, used to save queries for some calling methods (OpenDentalService).
            if (etransHtml != null)
            {
                etrans271.AckEtransNum = etransHtml.EtransNum;
            }
            Etranss.Insert(etrans271);
            etrans.AckEtransNum = etrans271.EtransNum;
            etrans.AckEtrans    = etrans271;       //Not a DB column, used to save queries for some calling methods (OpenDentalService).
            if (etrans271.Etype == EtransType.Acknowledge_997)
            {
                X997   x997     = new X997(x12response);
                string error997 = x997.GetHumanReadable();
                etrans.Note = "Error: " + error997;            //"Malformed document sent.  997 error returned.";
                Etranss.Update(etrans);
                error = etrans.Note;
                return(null);
            }
            else if (etrans271.Etype == EtransType.Acknowledge_999)
            {
                X999   x999     = new X999(x12response);
                string error999 = x999.GetHumanReadable();
                etrans.Note = "Error: " + error999;            //"Malformed document sent.  999 error returned.";
                Etranss.Update(etrans);
                error = etrans.Note;
                return(null);
            }
            else if (etrans271.Etype == EtransType.StatusNotify_277)
            {
                X277   x277     = new X277(x12response);
                string error277 = x277.GetHumanReadable();
                etrans.Note = "Error: " + error277;            //"Malformed document sent.  277 error returned.";
                Etranss.Update(etrans);
                error = etrans.Note;
                return(null);
            }
            else if (etrans271.Etype == EtransType.ERA_835)
            {
                X835   x835     = new X835(etrans271, x12response, "");
                string error835 = x835.GetHumanReadable();
                etrans.Note = "Error: " + error835;            //"Malformed document sent.  835 error returned.";
                Etranss.Update(etrans);
                error = etrans.Note;
                return(null);
            }
            else if (etrans271.Etype == EtransType.BenefitResponse271)            //271
            {
                string processingerror = x271.GetProcessingError();
                if (processingerror != "")
                {
                    etrans.Note = processingerror;
                    Etranss.Update(etrans);
                    error = etrans.Note;
                    return(null);
                }
                else
                {
                    etrans.Note = "Normal 271 response.";                  //change this later to be explanatory of content.
                }
            }
            else if (etrans271.Etype == EtransType.Ack_Interchange)           //See document "X092 Elig 270-271.pdf" pages 388 and 401.
            {
                X12object  xobj   = new X12object(x12response);
                X12Segment segTa1 = xobj.GetNextSegmentById(0, "TA1");
                if (segTa1.Get(4) == "A")
                {
                    etrans.Note = "The request was accepted, but the response is empty.";
                }
                else
                {
                    if (segTa1.Get(4) == "E")
                    {
                        etrans.Note = "The request was accepted with errors: ";
                    }
                    else if (segTa1.Get(4) == "R")
                    {
                        etrans.Note = "The request was rejected with errors: ";
                    }
                    switch (segTa1.Get(5))
                    {
                    case "000": etrans.Note += "No error"; break;

                    case "001": etrans.Note += "The Interchange Control Number in the Header and Trailer Do Not Match. "
                                               + "The Value From the Header is Used in the Acknowledgment."; break;

                    case "002": etrans.Note += "This Standard as Noted in the Control Standards Identifier is Not Supported."; break;

                    case "003": etrans.Note += "This Version of the Controls is Not Supported"; break;

                    case "004": etrans.Note += "The Segment Terminator is Invalid"; break;

                    case "005": etrans.Note += "Invalid Interchange ID Qualifier for Sender"; break;

                    case "006": etrans.Note += "Invalid Interchange Sender ID"; break;

                    case "007": etrans.Note += "Invalid Interchange ID Qualifier for Receiver"; break;

                    case "008": etrans.Note += "Invalid Interchange Receiver ID"; break;

                    case "009": etrans.Note += "Unknown Interchange Receiver ID"; break;

                    case "010": etrans.Note += "Invalid Authorization Information Qualifier Value"; break;

                    case "011": etrans.Note += "Invalid Authorization Information Value"; break;

                    case "012": etrans.Note += "Invalid Security Information Qualifier Value"; break;

                    case "013": etrans.Note += "Invalid Security Information Value"; break;

                    case "014": etrans.Note += "Invalid Interchange Date Value"; break;

                    case "015": etrans.Note += "Invalid Interchange Time Value"; break;

                    case "016": etrans.Note += "Invalid Interchange Standards Identifier Value"; break;

                    case "017": etrans.Note += "Invalid Interchange Version ID Value"; break;

                    case "018": etrans.Note += "Invalid Interchange Control Number Value"; break;

                    case "019": etrans.Note += "Invalid Acknowledgment Requested Value"; break;

                    case "020": etrans.Note += "Invalid Test Indicator Value"; break;

                    case "021": etrans.Note += "Invalid Number of Included Groups Value"; break;

                    case "022": etrans.Note += "Invalid Control Structure"; break;

                    case "023": etrans.Note += "Improper (Premature) End-of-File (Transmission)"; break;

                    case "024": etrans.Note += "Invalid Interchange Content (e.g., Invalid GS Segment)"; break;

                    case "025": etrans.Note += "Duplicate Interchange Control Number"; break;

                    case "026": etrans.Note += "Invalid Data Element Separator"; break;

                    case "027": etrans.Note += "Invalid Component Element Separator"; break;

                    case "028": etrans.Note += "Invalid Delivery Date in Deferred Delivery Request"; break;

                    case "029": etrans.Note += "Invalid Delivery Time in Deferred Delivery Request"; break;

                    case "030": etrans.Note += "Invalid Delivery Time Code in Deferred Delivery Request"; break;

                    case "031": etrans.Note += "Invalid Grade of Service Code"; break;
                    }
                }
            }
            else
            {
                throw new Exception("Unknown response");
            }
            Etranss.Update(etrans);
            return(etrans);
        }