Exemplo n.º 1
0
 public static List <Carriers> GetCostByUserId(int userId, Carriers carr, int pageSize, int pageIndex, out int recordCount)
 {
     return(LogisticsManagerDAL.CarriersDAL.GetCostByUserId(userId, carr, pageSize, pageIndex, out recordCount));
 }
Exemplo n.º 2
0
 public static List <Carriers> GetCarriersH(Carriers carr, int pageSize, int pageIndex, out int recordCount)
 {
     return(LogisticsManagerDAL.CarriersDAL.GetCarriersH(carr, pageSize, pageIndex, out recordCount));
 }
Exemplo n.º 3
0
        private bool ValidateFields(out string name, out string trackingNumber, out Carriers carrier, out DateTime date)
        {
            bool isFormValid = true;

            name = NameInputField.Text.Trim();
            if (name == "")
            {
                NameInputField.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                isFormValid = false;
            }

            trackingNumber = TrackingNumberInputField.Text.Trim();
            if (trackingNumber == "")
            {
                TrackingNumberInputField.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                isFormValid = false;
            }

            carrier = Carriers.INVALID;
            if (UPSButton.IsChecked.HasValue || FedExButton.IsChecked.HasValue
                || USPSButton.IsChecked.HasValue || DHLButton.IsChecked.HasValue)
            {
                if ((bool)UPSButton.IsChecked)
                {
                    carrier = Carriers.UPS;
                }
                else if ((bool)FedExButton.IsChecked)
                {
                    carrier = Carriers.FEDEX;
                }
                else if ((bool)USPSButton.IsChecked)
                {
                    carrier = Carriers.USPS;
                }
                else if ((bool)DHLButton.IsChecked)
                {
                    carrier = Carriers.DHL;
                }
            }
            if (carrier == Carriers.INVALID)
            {
                // Notify user
                CarrierFieldWarning.Visibility = Visibility.Visible;
                isFormValid = false;
            }

            DateTime? _date = DeliveryDateInputField.Value;
            date = (DateTime)_date;
            if (_date == null)
            {
                DeliveryDateInputField.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                isFormValid = false;
            }

            return isFormValid;
        }
Exemplo n.º 4
0
 public static List <Carriers> GetCarriersWhere(Carriers carr)
 {
     return(LogisticsManagerDAL.CarriersDAL.GetCarriersWhere(carr));
 }
Exemplo n.º 5
0
        ///<summary>Sends data for Patient.Cur to an export file and then launches an exe to notify PT.  If patient exists, this simply opens the patient.  If patient does not exist, then this triggers creation of the patient in PT Dental.  If isUpdate is true, then the export file and exe will have different names. In PT, update is a separate programlink with a separate button.</summary>
        public static void SendData(Program ProgramCur, Patient pat, bool isUpdate)
        {
            //ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);
            //ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "InfoFile path");
            //string infoFile=PPCur.PropertyValue;
            if (!Directory.Exists(dir))
            {
                MessageBox.Show(dir + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (pat == null)
            {
                MessageBox.Show("No patient is selected.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportAddExe))
            {
                MessageBox.Show(dir + "\\" + exportAddExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportUpdateExe))
            {
                MessageBox.Show(dir + "\\" + exportUpdateExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            string filename = dir + "\\" + exportAddCsv;

            if (isUpdate)
            {
                filename = dir + "\\" + exportUpdateCsv;
            }
            using (StreamWriter sw = new StreamWriter(filename, false)){               //overwrites if it already exists.
                sw.WriteLine("PAT_PK,PAT_LOGFK,PAT_LANFK,PAT_TITLE,PAT_FNAME,PAT_MI,PAT_LNAME,PAT_CALLED,PAT_ADDR1,PAT_ADDR2,PAT_CITY,PAT_ST,PAT_ZIP,PAT_HPHN,PAT_WPHN,PAT_EXT,PAT_FAX,PAT_PAGER,PAT_CELL,PAT_EMAIL,PAT_SEX,PAT_EDOCS,PAT_STATUS,PAT_TYPE,PAT_BIRTH,PAT_SSN,PAT_NOCALL,PAT_NOCORR,PAT_DISRES,PAT_LSTUPD,PAT_INSNM,PAT_INSGPL,PAT_INSAD1,PAT_INSAD2,PAT_INSCIT,PAT_INSST,PAT_INSZIP,PAT_INSPHN,PAT_INSEXT,PAT_INSCON,PAT_INSGNO,PAT_EMPNM,PAT_EMPAD1,PAT_EMPAD2,PAT_EMPCIT,PAT_EMPST,PAT_EMPZIP,PAT_EMPPHN,PAT_REFLNM,PAT_REFFNM,PAT_REFMI,PAT_REFPHN,PAT_REFEML,PAT_REFSPE,PAT_NOTES,PAT_FPSCAN,PAT_PREMED,PAT_MEDS,PAT_FTSTUD,PAT_PTSTUD,PAT_COLLEG,PAT_CHRTNO,PAT_OTHID,PAT_RESPRT,PAT_POLHLD,PAT_CUSCD,PAT_PMPID");
                sw.Write(",");                                                         //PAT_PK  Primary key. Long alphanumeric. We do not use.
                sw.Write(",");                                                         //PAT_LOGFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_LANFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_TITLE We do not have this field yet
                sw.Write(Tidy(pat.FName) + ",");                                       //PAT_FNAME
                sw.Write(Tidy(pat.MiddleI) + ",");                                     //PAT_MI
                sw.Write(Tidy(pat.LName) + ",");                                       //PAT_LNAME
                sw.Write(Tidy(pat.Preferred) + ",");                                   //PAT_CALLED Nickname
                sw.Write(Tidy(pat.Address) + ",");                                     //PAT_ADDR1
                sw.Write(Tidy(pat.Address2) + ",");                                    //PAT_ADDR2
                sw.Write(Tidy(pat.City) + ",");                                        //PAT_CITY
                sw.Write(Tidy(pat.State) + ",");                                       //PAT_ST
                sw.Write(Tidy(pat.Zip) + ",");                                         //PAT_ZIP
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.HmPhone) + ",");       //PAT_HPHN No punct
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WkPhone) + ",");       //PAT_WPHN
                sw.Write(",");                                                         //PAT_EXT
                sw.Write(",");                                                         //PAT_FAX
                sw.Write(",");                                                         //PAT_PAGER
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WirelessPhone) + ","); //PAT_CELL
                sw.Write(Tidy(pat.Email) + ",");                                       //PAT_EMAIL
                if (pat.Gender == PatientGender.Female)
                {
                    sw.Write("Female");
                }
                else if (pat.Gender == PatientGender.Male)
                {
                    sw.Write("Male");
                }
                sw.Write(",");                            //PAT_SEX might be blank if unknown
                sw.Write(",");                            //PAT_EDOCS Internal PT logical, it can be ignored.
                sw.Write(pat.PatStatus.ToString() + ","); //PAT_STATUS Any text allowed
                sw.Write(pat.Position.ToString() + ",");  //PAT_TYPE Any text allowed
                if (pat.Birthdate.Year > 1880)
                {
                    sw.Write(pat.Birthdate.ToString("MM/dd/yyyy"));                    //PAT_BIRTH MM/dd/yyyy
                }
                sw.Write(",");
                sw.Write(Tidy(pat.SSN) + ",");              //PAT_SSN No punct
                if (pat.PreferContactMethod == ContactMethod.DoNotCall ||
                    pat.PreferConfirmMethod == ContactMethod.DoNotCall ||
                    pat.PreferRecallMethod == ContactMethod.DoNotCall)
                {
                    sw.Write("1");
                }
                sw.Write(",");                //PAT_NOCALL T if no call
                sw.Write(",");                //PAT_NOCORR No correspondence HIPAA
                sw.Write(",");                //PAT_DISRES Internal PT logical, it can be ignored.
                sw.Write(",");                //PAT_LSTUPD Internal PT logical, it can be ignored.
                List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum);
                Family         fam         = Patients.GetFamily(pat.PatNum);
                List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
                List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
                PatPlan        patplan     = null;
                InsSub         sub         = null;
                InsPlan        plan        = null;
                Carrier        carrier     = null;
                Employer       emp         = null;
                if (patPlanList.Count > 0)
                {
                    patplan = patPlanList[0];
                    sub     = InsSubs.GetSub(patplan.InsSubNum, subList);
                    plan    = InsPlans.GetPlan(sub.PlanNum, planList);
                    carrier = Carriers.GetCarrier(plan.CarrierNum);
                    if (plan.EmployerNum != 0)
                    {
                        emp = Employers.GetEmployer(plan.EmployerNum);
                    }
                }
                if (plan == null)
                {
                    sw.Write(",");                    //PAT_INSNM
                    sw.Write(",");                    //PAT_INSGPL Ins group plan name
                    sw.Write(",");                    //PAT_INSAD1
                    sw.Write(",");                    //PAT_INSAD2
                    sw.Write(",");                    //PAT_INSCIT
                    sw.Write(",");                    //PAT_INSST
                    sw.Write(",");                    //PAT_INSZIP
                    sw.Write(",");                    //PAT_INSPHN
                }
                else
                {
                    sw.Write(Tidy(carrier.CarrierName) + ",");                         //PAT_INSNM
                    sw.Write(Tidy(plan.GroupName) + ",");                              //PAT_INSGPL Ins group plan name
                    sw.Write(Tidy(carrier.Address) + ",");                             //PAT_INSAD1
                    sw.Write(Tidy(carrier.Address2) + ",");                            //PAT_INSAD2
                    sw.Write(Tidy(carrier.City) + ",");                                //PAT_INSCIT
                    sw.Write(Tidy(carrier.State) + ",");                               //PAT_INSST
                    sw.Write(Tidy(carrier.Zip) + ",");                                 //PAT_INSZIP
                    sw.Write(TelephoneNumbers.FormatNumbersOnly(carrier.Phone) + ","); //PAT_INSPHN
                }
                sw.Write(",");                                                         //PAT_INSEXT
                sw.Write(",");                                                         //PAT_INSCON Ins contact person
                if (plan == null)
                {
                    sw.Write(",");
                }
                else
                {
                    sw.Write(Tidy(plan.GroupNum) + ",");                  //PAT_INSGNO Ins group number
                }
                if (emp == null)
                {
                    sw.Write(",");                    //PAT_EMPNM
                }
                else
                {
                    sw.Write(Tidy(emp.EmpName) + ","); //PAT_EMPNM
                }
                sw.Write(",");                         //PAT_EMPAD1
                sw.Write(",");                         //PAT_EMPAD2
                sw.Write(",");                         //PAT_EMPCIT
                sw.Write(",");                         //PAT_EMPST
                sw.Write(",");                         //PAT_EMPZIP
                sw.Write(",");                         //PAT_EMPPHN

                /*we don't support employer info yet.
                 * sw.Write(Tidy(emp.Address)+",");//PAT_EMPAD1
                 * sw.Write(Tidy(emp.Address2)+",");//PAT_EMPAD2
                 * sw.Write(Tidy(emp.City)+",");//PAT_EMPCIT
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPST
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPZIP
                 * sw.Write(TelephoneNumbers.FormatNumbersOnly(emp.Phone)+",");//PAT_EMPPHN*/
                Referral referral = Referrals.GetReferralForPat(pat.PatNum);              //could be null
                if (referral == null)
                {
                    sw.Write(",");                    //PAT_REFLNM
                    sw.Write(",");                    //PAT_REFFNM
                    sw.Write(",");                    //PAT_REFMI
                    sw.Write(",");                    //PAT_REFPHN
                    sw.Write(",");                    //PAT_REFEML Referral source email
                    sw.Write(",");                    //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                else
                {
                    sw.Write(Tidy(referral.LName) + ",");                //PAT_REFLNM
                    sw.Write(Tidy(referral.FName) + ",");                //PAT_REFFNM
                    sw.Write(Tidy(referral.MName) + ",");                //PAT_REFMI
                    sw.Write(referral.Telephone + ",");                  //PAT_REFPHN
                    sw.Write(Tidy(referral.EMail) + ",");                //PAT_REFEML Referral source email
                    if (referral.PatNum == 0 && !referral.NotPerson)     //not a patient, and is a person
                    {
                        sw.Write(Defs.GetName(DefCat.ProviderSpecialties, referral.Specialty));
                    }
                    sw.Write(",");            //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                sw.Write(",");                //PAT_NOTES No limits.  We won't use this right now for exports.
                //sw.Write(",");//PAT_NOTE1-PAT_NOTE10 skipped
                sw.Write(",");                //PAT_FPSCAN Internal PT logical, it can be ignored.
                if (pat.Premed)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                        //PAT_PREMED F or T
                sw.Write(Tidy(pat.MedUrgNote) + ","); //PAT_MEDS The meds that they must premedicate with.
                if (pat.StudentStatus == "F")         //fulltime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                //PAT_FTSTUD T/F
                if (pat.StudentStatus == "P") //parttime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                         //PAT_PTSTUD
                sw.Write(Tidy(pat.SchoolName) + ",");  //PAT_COLLEG Name of college
                sw.Write(Tidy(pat.ChartNumber) + ","); //PAT_CHRTNO
                sw.Write(pat.PatNum.ToString() + ","); //PAT_OTHID The primary key in Open Dental ************IMPORTANT***************
                if (pat.PatNum == pat.Guarantor)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                                    //PAT_RESPRT Responsible party checkbox T/F
                if (plan != null && pat.PatNum == sub.Subscriber) //if current patient is the subscriber on their primary plan
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");               //PAT_POLHLD Policy holder checkbox T/F
                sw.Write(",");               //PAT_CUSCD Web sync folder, used internally this can be ignored.
                sw.Write("");                //PAT_PMPID Practice Management Program ID. Can be ignored
                sw.WriteLine();
            }
            try{
                if (isUpdate)
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportUpdateExe);                //already validated to exist
                }
                else
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportAddExe);                //already validated to exist
                }
                //MessageBox.Show("done");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        ///<summary>The result is a string which can be dropped into the insplan.BenefitNotes.  Or it might throw an exception if invalid data.  This class is also responsible for saving the returned message to the etrans table and printing out the required form.</summary>
        public static string SendElegibility(string electID, int patNum, string groupNumber, string divisionNo,
                                             string subscriberID, string patID, Relat patRelat, int subscNum, string dentaideCardSequence)
        {
            //Note: This might be the only class of this kind that returns a string.  It's a special situation.
            //We are simply not going to bother with language translation here.
            //determine carrier.
            Carrier carrier = Carriers.GetCanadian(electID);          //this also happens to validate missing or short value

            if (carrier == null)
            {
                throw new ApplicationException("Invalid carrier EDI code.");
            }
            Clearinghouse clearhouse = Canadian.GetClearinghouse();

            if (clearhouse == null)
            {
                throw new ApplicationException("Canadian clearinghouse not found.");
            }
            string saveFolder = clearhouse.ExportPath;

            if (!Directory.Exists(saveFolder))
            {
                throw new ApplicationException(saveFolder + " not found.");
            }
            //Initialize objects-----------------------------------------------------------------------------------------------
            Patient  patient    = Patients.GetPat(patNum);
            Patient  subscriber = Patients.GetPat(subscNum);
            Provider treatProv  = Providers.GetProv(Patients.GetProvNum(patient));
            Provider billProv   = Providers.GetProv(Providers.GetBillingProvNum(treatProv.ProvNum));
            //I had to use a dialog box to get the eligibility code.

            //validate any missing info----------------------------------------------------------------------------------
            string error = "";

            if (carrier.CanadianNetworkNum == 0)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Carrier does not have network specified";
            }
            if (!Regex.IsMatch(carrier.ElectID, @"^[0-9]{6}$"))           //not necessary, but nice
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "CarrierId 6 digits";
            }
            if (treatProv.NationalProvID.Length != 9)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "TreatingProv CDA num 9 digits";
            }
            if (treatProv.CanadianOfficeNum.Length != 4)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "TreatingProv office num 4 char";
            }
            if (billProv.NationalProvID.Length != 9)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "BillingProv CDA num 9 digits";
            }
            if (groupNumber.Length == 0 || groupNumber.Length > 12 || groupNumber.Contains(" "))
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Plan Number";
            }
            if (subscriberID == "")
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "SubscriberID";
            }
            if (patNum != subscNum && patRelat == Relat.Self)           //if patient is not subscriber, and relat is self
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Relationship cannot be self";
            }
            if (patient.Gender == PatientGender.Unknown)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Patient gender";
            }
            if (patient.Birthdate.Year < 1880 || patient.Birthdate > DateTime.Today)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Patient birthdate";
            }
            if (patient.LName == "")
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Patient lastname";
            }
            if (patient.FName == "")
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Patient firstname";
            }
            if (subscriber.Birthdate.Year < 1880 || subscriber.Birthdate > DateTime.Today)
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Subscriber birthdate";
            }
            if (subscriber.LName == "")
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Subscriber lastname";
            }
            if (subscriber.FName == "")
            {
                if (error != "")
                {
                    error += ", ";
                }
                error += "Subscriber firstname";
            }
            if (error != "")
            {
                throw new ApplicationException(error);
            }
            FormCanadianEligibility FormElig = new FormCanadianEligibility();

            FormElig.ShowDialog();
            if (FormElig.DialogResult != DialogResult.OK)
            {
                throw new ApplicationException("Eligibility Code or Date missing.");
            }
            //eligiblity code guaranteed to not be 0 at this point.  Also date will be between 1980 and 10 years from now.
            Etrans etrans = Etranss.CreateCanadianOutput(patNum, carrier.CarrierNum, carrier.CanadianNetworkNum,
                                                         clearhouse.ClearinghouseNum, EtransType.Eligibility_CA);
            string txt = "";

            //create message----------------------------------------------------------------------------------------------
            //A01 transaction prefix 12 AN
//todo
            txt += "123456789012";          //To be later provided by the individual network.
            //A02 office sequence number 6 N
            txt += Canadian.TidyN(etrans.OfficeSequenceNumber, 6);
            //A03 format version number 2 N
            txt += "04";
            //A04 transaction code 2 N
            txt += "08";            //eligibility
            //A05 carrier id number 6 N
            txt += carrier.ElectID; //already validated as 6 digit number.
            //A06 software system id 3 AN  The third character is for version of OD.
//todo
            txt += "OD1";          //To be later supplied by CDAnet staff to uniquely identify OD.
            //A10 encryption method 1 N
//todo
            txt += "1";
            //A07 message length 5 N
            int len = 214;

//todo does not account for C19. Possibly 30 more.
            //if(C19 is used, Plan Record){
            //len+=30;
            //}
            txt += Canadian.TidyN(len, 5);
            //A09 carrier transaction counter 5 N
            txt += Canadian.TidyN(etrans.CarrierTransCounter, 5);
            //B01 CDA provider number 9 AN
            txt += Canadian.TidyAN(treatProv.NationalProvID, 9);         //already validated
            //B02 (treating) provider office number 4 AN
            txt += Canadian.TidyAN(treatProv.CanadianOfficeNum, 4);      //already validated
            //B03 billing provider number 9 AN
//todo, need to account for possible 5 digit prov id assigned by carrier
            txt += Canadian.TidyAN(billProv.NationalProvID, 9);         //already validated
            //C01 primary policy/plan number 12 AN (group number)
            //only validated to ensure that it's not blank and is less than 12. Also that no spaces.
            txt += Canadian.TidyAN(groupNumber, 12);
            //C11 primary division/section number 10 AN
            txt += Canadian.TidyAN(divisionNo, 10);
            //C02 subscriber id number 12 AN
            txt += Canadian.TidyAN(subscriberID.Replace("-", ""), 12);        //validated
            //C17 primary dependant code 2 N. Optional
            txt += Canadian.TidyN(patID, 2);
            //C03 relationship code 1 N
            //User interface does not only show Canadian options, but all options are handled.
            txt += Canadian.GetRelationshipCode(patRelat);
            //C04 patient's sex 1 A
            //validated to not include "unknown"
            if (patient.Gender == PatientGender.Male)
            {
                txt += "M";
            }
            else
            {
                txt += "F";
            }
            //C05 patient birthday 8 N
            txt += patient.Birthdate.ToString("yyyyMMdd");          //validated
            //C06 patient last name 25 AE
            txt += Canadian.TidyAE(patient.LName, 25, true);        //validated
            //C07 patient first name 15 AE
            txt += Canadian.TidyAE(patient.FName, 15, true);        //validated
            //C08 patient middle initial 1 AE
            txt += Canadian.TidyAE(patient.MiddleI, 1);
            //C09 eligibility exception code 1 N
            txt += Canadian.TidyN(FormElig.EligibilityCode, 1);         //validated
            //C12 plan flag 1 A
//todo
            //might not be carrier.IsPMP.  Might have to do with plan, not carrier. See F17.
            txt += " ";
            //C18 plan record count 1 N
//todo
            txt += "0";
            //C16 Eligibility date. 8 N.
            txt += FormElig.AsOfDate.ToString("yyyyMMdd");          //validated
            //D01 subscriber birthday 8 N
            txt += subscriber.Birthdate.ToString("yyyyMMdd");       //validated
            //D02 subscriber last name 25 AE
            txt += Canadian.TidyAE(subscriber.LName, 25, true);     //validated
            //D03 subscriber first name 15 AE
            txt += Canadian.TidyAE(subscriber.FName, 15, true);     //validated
            //D04 subscriber middle initial 1 AE
            txt += Canadian.TidyAE(subscriber.MiddleI, 1);
            //D10 language of insured 1 A
            if (subscriber.Language == "fr")
            {
                txt += "F";
            }
            else
            {
                txt += "E";
            }
            //D11 card sequence/version number 2 N
//todo: Not validated against type of carrier yet.  Need to check if Dentaide.
            txt += Canadian.TidyN(dentaideCardSequence, 2);
//todo If C18=1, then the following field would appear
            //C19 plan record 30 AN
            string result = "";

            try {
                result = Canadian.PassToCCD(txt, carrier.CanadianNetworkNum, clearhouse);
            }
            catch (ApplicationException ex) {
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(ex.Message);
            }
            Etranss.SetMessage(etrans.EtransNum, txt);
            etrans.MessageText = txt;
            FormCCDPrint FormP = new FormCCDPrint(etrans);          //Print the form.

            FormP.ShowDialog();
            //Now we will process the 'result' here to extract the important data.  Basically Yes or No on the eligibility.
            //We might not do this for any other trans type besides eligibility.
            string           retVal        = "Eligibility check on " + DateTime.Today.ToShortDateString() + "\r\n";
            CCDFieldInputter fieldInputter = new CCDFieldInputter(result);
            CCDField         field         = fieldInputter.GetFieldById("G05");//response status

            //CCDFieldInputter could really use a GetValue(string fieldId) method so I don't have to use a field object.
            switch (field.valuestr)
            {
            case "E":
                retVal += "Patient is eligible.";
                break;

            case "R":
                retVal += "Patient not eligible, or error in data.";
                break;

            case "M":
                retVal += "Manual claimform should be submitted for employer certified plan.";
                break;
            }
            CCDField[] fields = fieldInputter.GetFieldsById("G08");          //Error Codes
            for (int i = 0; i < fields.Length; i++)
            {
                retVal += "\r\n";
                retVal += fields[i].valuestr;              //todo: need to turn this into a readable string.
            }
            fields = fieldInputter.GetFieldsById("G32");   //Display messages
            for (int i = 0; i < fields.Length; i++)
            {
                retVal += "\r\n";
                retVal += fields[i].valuestr;
            }
            return(retVal);
        }
Exemplo n.º 7
0
        public static List <Carriers> GetCarriersWhere(Carriers carr)
        {
            string              sql       = @"SELECT

        CarriersID,
		SendCompany,
		SendAddress,
		SendLinkman,
		SendPhone,
		ReceiveCompany,
		ReceiveAddress,
		ReceiveLinkman,
		ReceivePhone,
		LeaverDate,
		FinishedState,
		InsuranceCost,
		TransportCost,
		OtherCost,
		TotalCost,
		Remark,
		FK_UserID,
		CheckInTime,
		IsDelete,
		AlterTime
    FROM

        Carriers
    WHERE FinishedState = 0 AND IsDelete = 0";
            List <string>       wherelist = new List <string>();
            List <SqlParameter> paralist  = new List <SqlParameter>();

            if (carr.CarriersID != 0)
            {
                wherelist.Add(" CarriersID=@CarriersID");
                paralist.Add(new SqlParameter("@CarriersID", carr.CarriersID));
            }
            if (!string.IsNullOrWhiteSpace(carr.LeaverDateS))
            {
                wherelist.Add(" LeaverDate>@LeaverDateS");
                paralist.Add(new SqlParameter("@LeaverDateS", carr.LeaverDateS));
            }
            if (!string.IsNullOrWhiteSpace(carr.LeaverDateE))
            {
                wherelist.Add(" LeaverDate<@LeaverDateE");
                paralist.Add(new SqlParameter("@LeaverDateE", carr.LeaverDateE));
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveLinkman))
            {
                wherelist.Add(" ReceiveLinkman like @ReceiveLinkman");
                paralist.Add(new SqlParameter("@ReceiveLinkman", "%" + carr.ReceiveLinkman + "%"));
            }
            if (!string.IsNullOrWhiteSpace(carr.SendLinkman))
            {
                wherelist.Add(" SendLinkman like @SendLinkman");
                paralist.Add(new SqlParameter("@SendLinkman", "%" + carr.SendLinkman + "%"));
            }
            if (wherelist.Count > 0)
            {
                sql += " and " + string.Join(" and ", wherelist.ToArray());
            }
            SqlDataReader   reader   = DBHelper.ExecuteReader(sql, paralist.ToArray());
            List <Carriers> carrlist = new List <Carriers>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Carriers car = new Carriers();
                    car.CarriersID     = Convert.ToInt32(reader["CarriersID"]);
                    car.SendLinkman    = reader["SendLinkman"].ToString();
                    car.SendCompany    = reader["SendCompany"].ToString();
                    car.SendAddress    = reader["SendAddress"].ToString();
                    car.ReceiveLinkman = reader["ReceiveLinkman"].ToString();
                    car.ReceiveCompany = reader["ReceiveCompany"].ToString();
                    car.ReceiveAddress = reader["ReceiveAddress"].ToString();
                    car.LeaverDate     = Convert.ToDateTime(reader["LeaverDate"]);
                    car.TotalCost      = Convert.ToDouble(reader["TotalCost"]);
                    car.FinishedState  = Convert.ToByte(reader["FinishedState"]);
                    carrlist.Add(car);
                }
            }
            return(carrlist);
        }
Exemplo n.º 8
0
        ///<summary>Called once for each claim to be created.  For claims with a lot of procedures, this may actually create multiple claims.
        ///Normally returns empty string unless something went wrong.</summary>
        public static bool CreateClaim(Clearinghouse clearinghouseClin, ClaimSendQueueItem queueItem, int batchNum)
        {
            StringBuilder strb = new StringBuilder();
            string        t    = "\t";

            strb.Append("110\t111\t112\t118\t203/403\tF108/204/404\t205/405\t206\t207\t208\t209\t210\t211\t212\t215\t217\t219\t406\t408\t409\t410\t411\t413\t414\t415\t416\t418\t419\t420\t421\t422\t423\t424\t425\t426\t428\t429\t430\t432\t433\r\n");
            Claim            claim              = Claims.GetClaim(queueItem.ClaimNum);
            Provider         provBill           = Providers.GetProv(claim.ProvBill);
            Patient          pat                = Patients.GetPat(claim.PatNum);
            InsPlan          insplan            = InsPlans.GetPlan(claim.PlanNum, new List <InsPlan>());
            InsSub           insSub             = InsSubs.GetSub(claim.InsSubNum, new List <InsSub>());
            Carrier          carrier            = Carriers.GetCarrier(insplan.CarrierNum);
            List <ClaimProc> claimProcList      = ClaimProcs.Refresh(pat.PatNum);
            List <ClaimProc> claimProcsForClaim = ClaimProcs.GetForSendClaim(claimProcList, claim.ClaimNum);
            List <Procedure> procList           = Procedures.Refresh(claim.PatNum);
            Procedure        proc;
            ProcedureCode    procCode;

            //ProcedureCode procCode;
            for (int i = 0; i < claimProcsForClaim.Count; i++)
            {
                //claimProcsForClaim already excludes any claimprocs with ProcNum=0, so no payments etc.
                proc = Procedures.GetProcFromList(procList, claimProcsForClaim[i].ProcNum);
                //procCode=Pro
                strb.Append(provBill.SSN + t);        //110
                strb.Append(provBill.MedicaidID + t); //111
                strb.Append(t);                       //112
                strb.Append(t);                       //118
                strb.Append(pat.SSN + t);             //203/403
                strb.Append(carrier.CarrierName + t); //carrier name?
                strb.Append(insSub.SubscriberID + t);
                strb.Append(pat.PatNum.ToString() + t);
                strb.Append(pat.Birthdate.ToString("dd-MM-yyyy") + t);
                if (pat.Gender == PatientGender.Female)
                {
                    strb.Append("2" + t);                  //"V"+t);
                }
                else
                {
                    strb.Append("1" + t);                  //M"+t);
                }
                strb.Append("1" + t);
                strb.Append(DutchLName(pat.LName) + t);                //last name without prefix
                strb.Append(DutchLNamePrefix(pat.LName) + t);          //prefix
                strb.Append("2" + t);
                strb.Append(DutchInitials(pat) + t);                   //215. initials
                strb.Append(pat.Zip + t);
                strb.Append(DutchAddressNumber(pat.Address) + t);      //219 house number.  Already validated.
                strb.Append(t);
                strb.Append(proc.ProcDate.ToString("dd-MM-yyyy") + t); //procDate
                procCode = ProcedureCodes.GetProcCode(proc.CodeNum);
                string strProcCode = procCode.ProcCode;
                if (strProcCode.EndsWith("00"))                 //ending with 00 indicates it's a lab code.
                {
                    strb.Append("02" + t);
                }
                else
                {
                    strb.Append("01" + t);                  //409. Procedure code (01) or lab costs (02)
                }
                strb.Append(t);
                strb.Append(t);
                strb.Append(strProcCode + t);
                strb.Append(GetUL(proc, procCode) + t);                             //414. U/L.
                strb.Append(Tooth.ToInternat(proc.ToothNum) + t);
                strb.Append(Tooth.SurfTidyForClaims(proc.Surf, proc.ToothNum) + t); //needs validation
                strb.Append(t);
                if (claim.AccidentRelated == "")                                    //not accident
                {
                    strb.Append("N" + t);
                }
                else
                {
                    strb.Append("J" + t);
                }
                strb.Append(pat.SSN + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append("1" + t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append("\r\n");
            }
            string saveFolder = clearinghouseClin.ExportPath;

            if (!Directory.Exists(saveFolder))
            {
                MessageBox.Show(saveFolder + " " + Lans.g("Dutch", "not found."));
                return(false);
            }
            string saveFile = ODFileUtils.CombinePaths(saveFolder, "claims" + claim.ClaimNum.ToString() + ".txt");

            File.WriteAllText(saveFile, strb.ToString());
            //MessageBox.Show(strb.ToString());
            return(true);
        }
Exemplo n.º 9
0
        ///<summary>Returns the number of plans updated.</summary>
        private static int ProcessTrojanPlan(string trojanPlan)
        {
            //MessageBox.Show(trojanPlan);
            string[] lines = trojanPlan.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            //MessageBox.Show(lines[0]);
            //MessageBox.Show(lines.Length.ToString());
            string line;

            string[] fields;
            int      percent;

            string[]  splitField;                   //if a field is a sentence with more than one word, we can split it for analysis
            InsPlan   plan         = new InsPlan(); //many fields will be absent.  This is a conglomerate.
            Carrier   carrier      = new Carrier();
            ArrayList benefitList  = new ArrayList();
            bool      usesAnnivers = false;
            Benefit   ben;

            for (int i = 0; i < lines.Length; i++)
            {
                line   = lines[i];
                fields = line.Split(new char[] { '\t' });
                if (fields.Length != 3)
                {
                    continue;
                }
                //remove any trailing or leading spaces:
                fields[0] = fields[0].Trim();
                fields[1] = fields[1].Trim();
                fields[2] = fields[2].Trim();
                if (fields[2] == "")
                {
                    continue;
                }
                else                 //as long as there is data, add it to the notes
                {
                    if (plan.BenefitNotes != "")
                    {
                        plan.BenefitNotes += "\r\n";
                    }
                    plan.BenefitNotes += fields[1] + ": " + fields[2];
                }
                switch (fields[0])
                {
                //default://for all rows that are not handled below
                case "TROJANID":
                    plan.TrojanID = fields[2];
                    break;

                case "ENAME":
                    plan.EmployerNum = Employers.GetEmployerNum(fields[2]);
                    break;

                case "PLANDESC":
                    plan.GroupName = fields[2];
                    break;

                case "ELIGPHONE":
                    carrier.Phone = fields[2];
                    break;

                case "POLICYNO":
                    plan.GroupNum = fields[2];
                    break;

                case "ECLAIMS":
                    if (fields[2] == "YES")                           //accepts eclaims
                    {
                        carrier.NoSendElect = false;
                    }
                    else
                    {
                        carrier.NoSendElect = true;
                    }
                    break;

                case "PAYERID":
                    carrier.ElectID = fields[2];
                    break;

                case "MAILTO":
                    carrier.CarrierName = fields[2];
                    break;

                case "MAILTOST":
                    carrier.Address = fields[2];
                    break;

                case "MAILCITYONLY":
                    carrier.City = fields[2];
                    break;

                case "MAILSTATEONLY":
                    carrier.State = fields[2];
                    break;

                case "MAILZIPONLY":
                    carrier.Zip = fields[2];
                    break;

                case "PLANMAX":                        //eg $3000 per person per year
                    if (!fields[2].StartsWith("$"))
                    {
                        break;
                    }
                    fields[2] = fields[2].Remove(0, 1);
                    fields[2] = fields[2].Split(new char[] { ' ' })[0];
                    if (CovCatB.ListShort.Length > 0)
                    {
                        ben             = new Benefit();
                        ben.BenefitType = InsBenefitType.Limitations;
                        ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
                        ben.MonetaryAmt = PIn.PDouble(fields[2]);
                        ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                        benefitList.Add(ben.Copy());
                    }
                    break;

                case "PLANYR":                        //eg Calendar year or Anniversary year
                    if (fields[2] != "Calendar year")
                    {
                        usesAnnivers = true;
                        //MessageBox.Show("Warning.  Plan uses Anniversary year rather than Calendar year.  Please verify the Plan Start Date.");
                    }
                    break;

                case "DEDUCT":                        //eg There is no deductible
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Deductible;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    if (!fields[2].StartsWith("$"))
                    {
                        ben.MonetaryAmt = 0;
                    }
                    else
                    {
                        fields[2]       = fields[2].Remove(0, 1);
                        fields[2]       = fields[2].Split(new char[] { ' ' })[0];
                        ben.MonetaryAmt = PIn.PDouble(fields[2]);
                    }
                    benefitList.Add(ben.Copy());
                    break;

                case "PREV":                        //eg 100%
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    break;

                case "BASIC":
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    break;

                case "MAJOR":
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    //does prosthodontics include crowns?
                    break;
                }        //switch
            }            //for
            //now, save this all to the database.
            //carrier
            if (carrier.CarrierName == null || carrier.CarrierName == "")
            {
                //if, for some reason, carrier is absent from the file, we can't do a thing with it.
                return(0);
            }
            //Carriers.Cur=carrier;
            Carriers.GetCurSame(carrier);
            //set calendar vs serviceyear
            if (usesAnnivers)
            {
                for (int i = 0; i < benefitList.Count; i++)
                {
                    ((Benefit)benefitList[i]).TimePeriod = BenefitTimePeriod.ServiceYear;
                }
            }
            //plan
            plan.CarrierNum = carrier.CarrierNum;
            string    command = "SELECT PlanNum FROM insplan WHERE TrojanID='" + POut.PString(plan.TrojanID) + "'";
            DataTable table   = General.GetTable(command);
            int       planNum;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                planNum = PIn.PInt(table.Rows[i][0].ToString());
                //update plan
                command = "UPDATE insplan SET "
                          + "EmployerNum='" + POut.PInt(plan.EmployerNum) + "', "
                          + "GroupName='" + POut.PString(plan.GroupName) + "', "
                          + "GroupNum='" + POut.PString(plan.GroupNum) + "', "
                          + "CarrierNum='" + POut.PInt(plan.CarrierNum) + "', "
                          + "BenefitNotes='" + POut.PString(plan.BenefitNotes) + "' "
                          + "WHERE PlanNum=" + POut.PInt(planNum);
                General.NonQ(command);
                //clear benefits
                command = "DELETE FROM benefit WHERE PlanNum=" + POut.PInt(planNum);
                General.NonQ(command);
                //benefitList
                for (int j = 0; j < benefitList.Count; j++)
                {
                    ((Benefit)benefitList[j]).PlanNum = planNum;
                    Benefits.Insert((Benefit)benefitList[j]);
                }
                InsPlans.ComputeEstimatesForPlan(planNum);
            }
            return(table.Rows.Count);
            //MessageBox.Show(plan.BenefitNotes);
        }
Exemplo n.º 10
0
        public static List <Carriers> GetCostByUserId(int userId, Carriers carr, int pageSize, int pageIndex, out int recordCount)
        {
            recordCount = 0;
            Paging page = new Paging();

            page.TableName  = "[Carriers] a inner join [Scheduling] b on a.CarriersID=b.FK_CarriersID";
            page.PrimaryKey = "[SchedulingID]";
            page.Fields     = @"[SchedulingID]
      ,[CarriersID]
      ,[SendCompany]
      ,[ReceiveDate]
      ,[FinishedState]
      ,a.[TotalCost] as [TotalCostC]
      ,[OilCost]
      ,[Toll]
      ,[Fine]
      ,b.[OtherCost]
      ,b.[TotalCost] as [TotalCostS]
      ,b.[FK_UserID]
      ,b.[IsDelete]
      ,b.[AlterTime]";
            List <string> wherelist = new List <string>();

            StringBuilder where = new StringBuilder();
            where.Append("b.IsDelete=0 and FinishedState>1");
            if (carr.FinishedState != 0)
            {
                if (carr.FinishedState == 1)
                {
                    wherelist.Add($" FinishedState=2");
                }
                else
                {
                    wherelist.Add($" FinishedState=3");
                }
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveDateS))
            {
                wherelist.Add($" ReceiveDate>'{carr.ReceiveDateS}'");
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveDateE))
            {
                wherelist.Add($" ReceiveDate<'{carr.ReceiveDateE}'");
            }
            if (wherelist.Count > 0)
            {
                where.Append(" and " + string.Join($" and ", wherelist));
            }
            page.Condition = where.ToString();
            page.PageSize  = pageSize;
            page.PageIndex = pageIndex;
            DataTable       dt       = PublicPaging.ProcGetPageData(page, out recordCount);
            List <Carriers> carrlist = new List <Carriers>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Carriers ca = new Carriers();
                    ca.CarriersID   = Convert.ToInt32(item["CarriersID"]);
                    ca.SchedulingID = Convert.ToInt32(item["SchedulingID"]);
                    ca.SendCompany  = item["SendCompany"].ToString();

                    ca.ReceiveDate = Convert.ToDateTime(item["ReceiveDate"]);



                    ca.FinishedState = Convert.ToByte(item["FinishedState"]);
                    ca.TotalCost     = Convert.ToDouble(item["TotalCostC"]);
                    ca.OilCost       = Convert.ToDouble(item["OilCost"]);
                    ca.Toll          = Convert.ToDouble(item["Toll"]);
                    ca.Fine          = Convert.ToDouble(item["Fine"]);
                    ca.OtherCost     = Convert.ToDouble(item["OtherCost"]);
                    ca.TotalCostS    = Convert.ToDouble(item["TotalCostS"]);
                    ca.FK_UserID     = Convert.ToInt32(item["FK_UserID"]);
                    ca.IsDelete      = Convert.ToByte(item["IsDelete"]);
                    ca.AlterTime     = Convert.ToDateTime(item["AlterTime"]);
                    carrlist.Add(ca);
                }
            }
            return(carrlist);
        }
Exemplo n.º 11
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> listProcs, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)
        {
            //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
            //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
            MessageHL7 msgHl7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def     hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment    apt          = Appointments.GetOneApt(aptNum);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int repeatCount = 1;
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1)
                {
                    repeatCount = listProcs.Count;
                }
                else if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    repeatCount = listPatPlans.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                //or the patient does not have any current insplans for IN1 segments
                for (int j = 0; j < repeatCount; j++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList, IN1 is optional and can repeat as well, repeat for the number of patplans in patplanList
                {
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1 && listProcs.Count > j)
                    {
                        prov = Providers.GetProv(listProcs[j].ProvNum);
                    }
                    Procedure proc = null;
                    if (listProcs.Count > j)                   //procList could be an empty list
                    {
                        proc = listProcs[j];
                    }
                    PatPlan patPlanCur = null;
                    InsPlan insPlanCur = null;
                    InsSub  insSubCur  = null;
                    Carrier carrierCur = null;
                    Patient subscriber = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                    {
                        patPlanCur = listPatPlans[j];
                        insSubCur  = InsSubs.GetOne(patPlanCur.InsSubNum);
                        insPlanCur = InsPlans.RefreshOne(insSubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insPlanCur.CarrierNum);
                        subscriber = Patients.GetPat(insSubCur.Subscriber);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patPlanCur, insSubCur, insPlanCur, carrierCur, listPatPlans.Count, subscriber);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateField(hl7Def, fieldName, MessageTypeHL7.DFT, pat, prov, proc, guar, apt, j + 1, eventType,
                                                                            pdfDescription, pdfDataString, MessageStructureHL7.DFT_P03, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }
Exemplo n.º 12
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound ADT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateADT(Patient pat, Patient guar, EventTypeHL7 eventType)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound ADT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.ADT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //ADT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7     messageHL7   = new MessageHL7(MessageTypeHL7.ADT);
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int countRepeat = 1;
                //IN1 segment can repeat, get the number of current insurance plans attached to the patient
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    countRepeat = listPatPlans.Count;
                }
                //countRepeat is usually 1, but for repeatable/optional fields, it may be 0 or greater than 1
                //for example, countRepeat can be zero if the patient does not have any current insplans, in which case no IN1 segments will be included
                for (int j = 0; j < countRepeat; j++)           //IN1 is optional and can repeat so add as many as listPatplans
                {
                    PatPlan patplanCur = null;
                    InsPlan insplanCur = null;
                    InsSub  inssubCur  = null;
                    Carrier carrierCur = null;
                    Patient patSub     = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)                   //index repeat is guaranteed to be less than listPatplans.Count
                    {
                        patplanCur = listPatPlans[j];
                        inssubCur  = InsSubs.GetOne(patplanCur.InsSubNum);
                        insplanCur = InsPlans.RefreshOne(inssubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insplanCur.CarrierNum);
                        if (pat.PatNum == inssubCur.Subscriber)
                        {
                            patSub = pat.Copy();
                        }
                        else
                        {
                            patSub = Patients.GetPat(inssubCur.Subscriber);
                        }
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patplanCur, inssubCur, insplanCur, carrierCur, listPatPlans.Count, patSub);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateFieldADT(hl7Def, fieldName, pat, prov, guar, j + 1, eventType, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }
Exemplo n.º 13
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtSendCompany.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入发货单位!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtReceiveCompany.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入收货单位!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtSendAddress.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入发货单位地址!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtReceiveAddress.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入收货单位地址!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtSendLinkman.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入发货人!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtReceiveLinkman.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入收货人!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtSendPhone.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入发货人电话!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtReceivePhone.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入收货人电话!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtInsuranceCost.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入保险费!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtTransportCost.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入运费!')", true);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtOtherCost.Text))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入其他费用!')", true);
                return;
            }
            Carriers carr = new Carriers();

            carr.SendCompany    = txtSendCompany.Text;
            carr.SendAddress    = txtSendAddress.Text;
            carr.SendLinkman    = txtSendLinkman.Text;
            carr.SendPhone      = txtSendPhone.Text;
            carr.ReceiveCompany = txtReceiveCompany.Text;
            carr.ReceiveAddress = txtReceiveAddress.Text;
            carr.ReceiveLinkman = txtReceiveLinkman.Text;
            carr.ReceivePhone   = txtReceivePhone.Text;
            carr.InsuranceCost  = Convert.ToDouble(txtInsuranceCost.Text);
            carr.TransportCost  = Convert.ToDouble(txtTransportCost.Text);
            carr.OtherCost      = Convert.ToDouble(txtOtherCost.Text);
            carr.FK_UserID      = (Session["User"] as List <Users>)[0].UserID;
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + LogisticsManagerBLL.CarriersBLL.AddCarriers(carr) + "')", true);
        }
Exemplo n.º 14
0
 public void addCarrier(Carriers carrier)
 {
     _context.Add(carrier);
     _context.SaveChanges();
 }
Exemplo n.º 15
0
        public static List <Carriers> GetCarriersH(Carriers carr, int pageSize, int pageIndex, out int recordCount)
        {
            recordCount = 0;
            Paging page = new Paging();

            page.TableName  = "[Carriers]";
            page.PrimaryKey = "[CarriersID]";
            page.Fields     = @"[CarriersID]
      ,[SendCompany]
      ,[SendLinkman]
      ,[ReceiveCompany]
      ,[ReceiveLinkman]
      ,[LeaverDate]
      ,[TotalCost]
      ,[FK_UserID]";
            List <string> wherelist = new List <string>();

            StringBuilder where = new StringBuilder();
            where.Append("IsDelete=0 and FinishedState=3");
            if (carr.CarriersID != 0)
            {
                wherelist.Add($" CarriersID='{carr.CarriersID}'");
            }
            if (!string.IsNullOrWhiteSpace(carr.LeaverDateS))
            {
                wherelist.Add($" LeaverDate>'{carr.LeaverDateS}'");
            }
            if (!string.IsNullOrWhiteSpace(carr.LeaverDateE))
            {
                wherelist.Add($" LeaverDate<'{carr.LeaverDateE}'");
            }
            if (!string.IsNullOrWhiteSpace(carr.SendLinkman))
            {
                wherelist.Add($" SendLinkman like '%{carr.SendLinkman}%'");
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveLinkman))
            {
                wherelist.Add($" ReceiveLinkman like '%{carr.ReceiveLinkman}%'");
            }
            if (!string.IsNullOrWhiteSpace(carr.UserName))
            {
                wherelist.Add($" FK_UserID in (select UserID from [User] where UserName like '%{carr.UserName}%')");
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveDateS))
            {
                wherelist.Add($" ReceiveDate>'{carr.ReceiveDateS}'");
            }
            if (!string.IsNullOrWhiteSpace(carr.ReceiveDateE))
            {
                wherelist.Add($" ReceiveDate<'{carr.ReceiveDateE}'");
            }
            if (wherelist.Count > 0)
            {
                where.Append(" and " + string.Join($" and ", wherelist));
            }
            page.Condition = where.ToString();
            page.PageSize  = pageSize;
            page.PageIndex = pageIndex;
            DataTable       dt       = PublicPaging.ProcGetPageData(page, out recordCount);
            List <Carriers> carrlist = new List <Carriers>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Carriers ca = new Carriers();
                    ca.CarriersID     = Convert.ToInt32(item["CarriersID"]);
                    ca.SendCompany    = item["SendCompany"].ToString();
                    ca.SendLinkman    = item["SendLinkman"].ToString();
                    ca.ReceiveCompany = item["ReceiveCompany"].ToString();
                    ca.ReceiveLinkman = item["ReceiveLinkman"].ToString();
                    ca.LeaverDate     = Convert.ToDateTime(item["LeaverDate"]);
                    ca.TotalCost      = Convert.ToDouble(item["TotalCost"]);
                    ca.FK_UserID      = Convert.ToInt32(item["FK_UserID"]);

                    carrlist.Add(ca);
                }
            }
            return(carrlist);
        }
Exemplo n.º 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);
        }
Exemplo n.º 17
0
        public static string SetInitialCarriers()
        {
            //We are starting with zero carriers
            CanadianNetwork network = new CanadianNetwork();

            network.Abbrev   = "CDANET14";
            network.Descript = "CDANET14";
            network.CanadianTransactionPrefix = "CDANET14";
            CanadianNetworks.Insert(network);
            Carrier carrier = new Carrier();

            carrier.IsCDA                    = true;
            carrier.CarrierName              = "Carrier 1";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "04";
            carrier.ElectID                  = "666666";
            carrier.CanadianEncryptionMethod = 2;
            carrier.CanadianSupportedTypes
            //claim_01 is implied
                = CanSupTransTypes.CobClaimTransaction_07
                  //claimAck_11 is implied
                  //claimEob_21 is implied
                  | CanSupTransTypes.ClaimReversal_02
                  | CanSupTransTypes.ClaimReversalResponse_12
                  | CanSupTransTypes.PredeterminationSinglePage_03
                  | CanSupTransTypes.PredeterminationMultiPage_03
                  | CanSupTransTypes.RequestForOutstandingTrans_04
                  | CanSupTransTypes.EmailTransaction_24
                  | CanSupTransTypes.RequestForSummaryReconciliation_05
                  | CanSupTransTypes.RequestForPaymentReconciliation_06;
            Carriers.Insert(carrier);
            //Carrier2---------------------------------------------------
            network          = new CanadianNetwork();
            network.Abbrev   = "A";
            network.Descript = "A";
            network.CanadianTransactionPrefix = "A";
            CanadianNetworks.Insert(network);
            carrier                          = new Carrier();
            carrier.IsCDA                    = true;
            carrier.CarrierName              = "Carrier 2";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "04";
            carrier.ElectID                  = "777777";
            carrier.CanadianEncryptionMethod = 1;
            carrier.CanadianSupportedTypes
                = CanSupTransTypes.EligibilityTransaction_08
                  //claim_01 is implied
                  //claimAck_11 is implied
                  //claimEob_21 is implied
                  | CanSupTransTypes.ClaimReversal_02
                  | CanSupTransTypes.PredeterminationSinglePage_03
                  | CanSupTransTypes.RequestForOutstandingTrans_04
                  | CanSupTransTypes.EmailTransaction_24
                  | CanSupTransTypes.RequestForPaymentReconciliation_06;
            Carriers.Insert(carrier);
            //Carrier3---------------------------------------------------
            network          = new CanadianNetwork();
            network.Abbrev   = "AB";
            network.Descript = "AB";
            network.CanadianTransactionPrefix = "AB";
            CanadianNetworks.Insert(network);
            carrier                          = new Carrier();
            carrier.IsCDA                    = true;
            carrier.CarrierName              = "Carrier 3";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "04";
            carrier.ElectID                  = "888888";
            carrier.CanadianEncryptionMethod = 2;
            carrier.CanadianSupportedTypes
                = CanSupTransTypes.EligibilityTransaction_08
                  //claim_01 is implied
                  | CanSupTransTypes.CobClaimTransaction_07
                  //claimAck_11 is implied
                  //claimEob_21 is implied
                  | CanSupTransTypes.ClaimReversal_02
                  | CanSupTransTypes.PredeterminationSinglePage_03
                  | CanSupTransTypes.RequestForOutstandingTrans_04
                  | CanSupTransTypes.EmailTransaction_24
                  | CanSupTransTypes.RequestForPaymentReconciliation_06;
            Carriers.Insert(carrier);
            //Carrier4---------------------------------------------------
            network          = new CanadianNetwork();
            network.Abbrev   = "ABC";
            network.Descript = "ABC";
            network.CanadianTransactionPrefix = "ABC";
            CanadianNetworks.Insert(network);
            carrier                          = new Carrier();
            carrier.IsCDA                    = true;
            carrier.CarrierName              = "Carrier 4";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "04";
            carrier.ElectID                  = "999111";
            carrier.CanadianEncryptionMethod = 2;
            carrier.CanadianSupportedTypes
                = CanSupTransTypes.EligibilityTransaction_08
                  //claim_01 is implied
                  | CanSupTransTypes.CobClaimTransaction_07
                  //claimAck_11 is implied
                  //claimEob_21 is implied
                  | CanSupTransTypes.ClaimReversal_02
                  | CanSupTransTypes.PredeterminationSinglePage_03
                  | CanSupTransTypes.RequestForOutstandingTrans_04
                  | CanSupTransTypes.EmailTransaction_24
                  | CanSupTransTypes.RequestForPaymentReconciliation_06;
            Carriers.Insert(carrier);
            //Carrier5---------------------------------------------------
            network          = new CanadianNetwork();
            network.Abbrev   = "V2CAR";
            network.Descript = "V2CAR";
            network.CanadianTransactionPrefix = "V2CAR";
            CanadianNetworks.Insert(network);
            carrier                          = new Carrier();
            carrier.IsCDA                    = true;
            carrier.CarrierName              = "Carrier 5";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "02";
            carrier.ElectID                  = "555555";
            carrier.CanadianEncryptionMethod = 0;          //not applicable
            carrier.CanadianSupportedTypes
                = CanSupTransTypes.EligibilityTransaction_08
                  | CanSupTransTypes.EligibilityResponse_18
                  //claim_01 is implied
                  //claimAck_11 is implied
                  //claimEob_21 is implied
                  | CanSupTransTypes.ClaimReversal_02
                  | CanSupTransTypes.PredeterminationSinglePage_03
                  | CanSupTransTypes.PredeterminationMultiPage_03;
            Carriers.Insert(carrier);
            //---------------------------------------------------------
            //Used for Payment Reconciliation test #3 and Summary Reconciliation test #3
            network          = new CanadianNetwork();
            network.Abbrev   = "ABC";
            network.Descript = "ABC";
            network.CanadianTransactionPrefix = "ABC";
            CanadianNetworks.Insert(network);
            carrier                          = new Carrier();
            carrier.IsCDA                    = true;
            carrier.CarrierName              = "111555";
            carrier.CanadianNetworkNum       = network.CanadianNetworkNum;
            carrier.CDAnetVersion            = "04";
            carrier.ElectID                  = "111555";
            carrier.CanadianEncryptionMethod = 0;          //not applicable
            carrier.CanadianSupportedTypes
                = CanSupTransTypes.PaymentReconciliation_16;
            Carriers.Insert(carrier);
            return("Carrier objects set.\r\n");
        }
Exemplo n.º 18
0
 public void InitSelectedItems()
 {
     Crop           = Crops.FirstOrDefault(c => c.CropId == Recipe.CropId);
     ProcessingType = ProcessingTypes.FirstOrDefault(pt => pt.ProcessingTypeId == Recipe.ProcessingTypeId);
     Carrier        = Carriers.FirstOrDefault(c => c.ComponentId == Recipe.CarrierId);
 }
Exemplo n.º 19
0
        ///<summary>Returns number of subscribers affected.  Can throw an exception if user clicks cancel in a note box.</summary>
        private static int ProcessTrojanPlan(string trojanPlan, bool updateBenefits, bool updateNoteAutomatic)
        {
            TrojanObject troj    = ProcessTextToObject(trojanPlan);
            Carrier      carrier = new Carrier();

            carrier.Phone       = troj.ELIGPHONE;
            carrier.ElectID     = troj.PAYERID;
            carrier.CarrierName = troj.MAILTO;
            carrier.Address     = troj.MAILTOST;
            carrier.City        = troj.MAILCITYONLY;
            carrier.State       = troj.MAILSTATEONLY;
            carrier.Zip         = troj.MAILZIPONLY;
            carrier.NoSendElect = false;          //regardless of what Trojan says.  Nobody sends paper anymore.
            if (carrier.CarrierName == null || carrier.CarrierName == "")
            {
                //if, for some reason, carrier is absent from the file, we can't do a thing with it.
                return(0);
            }
            carrier = Carriers.GetIdentical(carrier);
            //now, save this all to the database.
            troj.CarrierNum = carrier.CarrierNum;
            InsPlan plan = TrojanQueries.GetPlanWithTrojanID(troj.TROJANID);

            if (plan == null)
            {
                return(0);
            }
            TrojanQueries.UpdatePlan(troj, plan.PlanNum, updateBenefits);
            plan = InsPlans.RefreshOne(plan.PlanNum);
            InsPlan planOld = plan.Copy();

            if (updateNoteAutomatic)
            {
                if (plan.PlanNote != troj.PlanNote)
                {
                    plan.PlanNote = troj.PlanNote;
                    InsPlans.Update(plan, planOld);
                }
            }
            else
            {
                //let user pick note
                if (plan.PlanNote != troj.PlanNote)
                {
                    string[] notes = new string[2];
                    notes[0] = plan.PlanNote;
                    notes[1] = troj.PlanNote;
                    FormNotePick FormN = new FormNotePick(notes);
                    FormN.ShowDialog();
                    if (FormN.DialogResult == DialogResult.OK)
                    {
                        if (plan.PlanNote != FormN.SelectedNote)
                        {
                            plan.PlanNote = FormN.SelectedNote;
                            InsPlans.Update(plan, planOld);
                        }
                    }
                }
            }
            return(1);
        }
Exemplo n.º 20
0
 public void SetOrder(Orders order, Packages package)
 {
     orderData   = order;
     packageData = package;
     carrierData = packageData.Method?.Carriers;
 }
Exemplo n.º 21
0
        public async Task <LivePricesServiceResponse> FilterAsync(string currency, double?minPrice, double?maxPrice, int?OutboundMaxStops,
                                                                  DateTime?OutboundDepartureDateTimeFrom, DateTime?OutboundDepartureDateTimeTo, DateTime?OutboundArrivalDateTimeFrom, DateTime?OutboundArrivalDateTimeTo,
                                                                  int?InboundMaxStops,
                                                                  DateTime?InboundDepartureDateTimeFrom, DateTime?InboundDepartureDateTimeTo, DateTime?InboundArrivalDateTimeFrom, DateTime?InboundArrivalDateTimeTo, CancellationToken cancellationToken)
        {
            IFlightSearchEngine flightSearhEngine = new FlightSearchEngineFactory().GetFlightSearchEngine("skyscanner");

            foreach (Segment s in Segments)
            {
                s.CarrierObject   = Carriers.Where(c => c.Id == s.Carrier).FirstOrDefault();
                s.CarrierName     = s.CarrierObject.Name;
                s.CarrierImageUrl = s.CarrierObject.ImageUrl;

                s.OriginPlace      = Places.Where(p => p.Id == s.OriginStation).FirstOrDefault();
                s.DestinationPlace = Places.Where(p => p.Id == s.DestinationStation).FirstOrDefault();

                if (s.DepartureDateTime != null)
                {
                    s.DepartureDateTimeConverted = DateTime.Parse(s.DepartureDateTime);
                }

                if (s.ArrivalDateTime != null)
                {
                    s.ArrivalDateTimeConverted = DateTime.Parse(s.ArrivalDateTime);
                }
            }

            Currency searchCurrency   = null;
            var      filterCurrencies = Currencies.Where(c => currency == null || currency == "" || c.Code == currency).ToList();

            if (filterCurrencies.Count() == 1)
            {
                searchCurrency = filterCurrencies.FirstOrDefault();
            }

            var filterItineries = Itineraries.Where(i =>
                                                    (
                                                        (maxPrice == null || (i.PricingOptions.Any(po => po.Price <= maxPrice && po.Price != 0)))
                                                    )
                                                    &&
                                                    (
                                                        (minPrice == null || (i.PricingOptions.Any(po => po.Price >= minPrice && po.Price != 0)))
                                                    )
                                                    &&
                                                    (
                                                        (OutboundMaxStops == null || i.OutboundLegId == null || (Legs.Where(l => l.Id == i.OutboundLegId).First().Stops.Count() <= OutboundMaxStops))
                                                    )
                                                    &&
                                                    (
                                                        (InboundMaxStops == null || i.InboundLegId == null || (Legs.Where(l => l.Id == i.InboundLegId).First().Stops.Count() <= InboundMaxStops))
                                                    )
                                                    &&
                                                    (
                                                        (OutboundDepartureDateTimeFrom == null || Segments.Where(s => Legs.Where(l => l.Id == i.OutboundLegId).First().SegmentIds.First() == s.Id).First().DepartureDateTimeConverted >= OutboundDepartureDateTimeFrom) &&
                                                        (OutboundDepartureDateTimeTo == null || Segments.Where(s => Legs.Where(l => l.Id == i.OutboundLegId).First().SegmentIds.First() == s.Id).First().DepartureDateTimeConverted <= OutboundDepartureDateTimeTo) &&
                                                        (OutboundArrivalDateTimeFrom == null || Segments.Where(s => Legs.Where(l => l.Id == i.OutboundLegId).First().SegmentIds.First() == s.Id).Last().ArrivalDateTimeConverted >= OutboundArrivalDateTimeFrom) &&
                                                        (OutboundArrivalDateTimeTo == null || Segments.Where(s => Legs.Where(l => l.Id == i.OutboundLegId).First().SegmentIds.First() == s.Id).Last().ArrivalDateTimeConverted <= OutboundArrivalDateTimeTo) &&
                                                        (InboundDepartureDateTimeFrom == null || Segments.Where(s => Legs.Where(l => l.Id == i.InboundLegId).First().SegmentIds.First() == s.Id).First().DepartureDateTimeConverted >= InboundDepartureDateTimeFrom) &&
                                                        (InboundDepartureDateTimeTo == null || Segments.Where(s => Legs.Where(l => l.Id == i.InboundLegId).First().SegmentIds.First() == s.Id).First().DepartureDateTimeConverted <= InboundDepartureDateTimeTo) &&
                                                        (InboundArrivalDateTimeFrom == null || Segments.Where(s => Legs.Where(l => l.Id == i.InboundLegId).First().SegmentIds.First() == s.Id).Last().ArrivalDateTimeConverted >= InboundArrivalDateTimeFrom) &&
                                                        (InboundArrivalDateTimeTo == null || Segments.Where(s => Legs.Where(l => l.Id == i.InboundLegId).First().SegmentIds.First() == s.Id).Last().ArrivalDateTimeConverted <= InboundArrivalDateTimeTo)
                                                    )).ToList();

            foreach (Itinerary i in filterItineries)
            {
                i.PricingOptions.RemoveAll(po => !((po.Price <= maxPrice && po.Price != 0) || maxPrice == null) || !((po.Price >= minPrice && po.Price != 0) || minPrice == null));
            }

            var filterLegs = Legs.Where(l => filterItineries.Any(i => i.OutboundLegId == l.Id || i.InboundLegId == l.Id)).ToList();

            var filterSegments = Segments.Where(s => filterLegs.Any(fl => fl.SegmentIds.Contains(s.Id))).ToList();

            var filterLegPlaces = Places.Where(p => filterLegs.Any(l => l.OriginStation == p.Id || l.DestinationStation == p.Id)).ToList();

            var filterSegmentPlaces = Places.Where(p => filterSegments.Any(s => s.OriginStation == p.Id || s.DestinationStation == p.Id)).ToList();

            var filterPlaces = filterLegPlaces.Union(filterSegmentPlaces, new DND.Common.Helpers.Comparer <Place>((p1, p2) => p1.Id == p2.Id)).ToList();

            List <Place> newPlaces = new List <Place>();

            foreach (Place fp in filterPlaces)
            {
                if (fp.ParentId != 0)
                {
                    fp.ParentPlace = Places.Where(p => p.Id == fp.ParentId).FirstOrDefault();
                    if (!newPlaces.Any(p => p.Id == fp.ParentId))
                    {
                        newPlaces.Add(fp.ParentPlace);
                    }

                    if (fp.ParentPlace.ParentId != 0 && fp.ParentPlace.ParentPlace == null)
                    {
                        fp.ParentPlace.ParentPlace = Places.Where(p => p.Id == fp.ParentPlace.ParentId).FirstOrDefault();
                        if (!newPlaces.Any(p => p.Id == fp.ParentPlace.ParentId))
                        {
                            newPlaces.Add(fp.ParentPlace.ParentPlace);
                        }
                    }
                }
            }

            filterPlaces = filterPlaces.Union(newPlaces, new DND.Common.Helpers.Comparer <Place>((p1, p2) => p1.Id == p2.Id)).ToList();

            foreach (Segment s in filterSegments)
            {
                if (s.OriginPlace != null)
                {
                    s.OriginAirport     = s.OriginPlace.Name;
                    s.OriginAirportCode = s.OriginPlace.Code;
                    var originAirport = new AirportService().GetByIATA(s.OriginPlace.Code);
                    if (originAirport != null)
                    {
                        s.OriginAirportLatitude  = originAirport.LatitudeDecimalDegrees;
                        s.OriginAirportLongitude = originAirport.LongitudeDecimalDegrees;
                    }

                    s.OriginCity    = s.OriginPlace.ParentPlace.Name;
                    s.OriginCountry = s.OriginPlace.ParentPlace.ParentPlace.Name;
                }
                if (s.DestinationPlace != null)
                {
                    s.DestinationAirport     = s.DestinationPlace.Name;
                    s.DestinationAirportCode = s.DestinationPlace.Code;
                    var destinationAirport = new AirportService().GetByIATA(s.DestinationPlace.Code);
                    if (destinationAirport != null)
                    {
                        s.DestinationAirportLatitude  = destinationAirport.LatitudeDecimalDegrees;
                        s.DestinationAirportLongitude = destinationAirport.LongitudeDecimalDegrees;
                    }

                    s.DestinationCity    = s.DestinationPlace.ParentPlace.Name;
                    s.DestinationCountry = s.DestinationPlace.ParentPlace.ParentPlace.Name;
                }

                TimeSpan dt = TimeSpan.FromMinutes(s.Duration);
                s.DurationHourMinuteFormatted = ((dt.Days * 24) + dt.Hours).ToString() + "h " + dt.Minutes.ToString() + "m";
                s.DepartureDateFormattedLong  = s.DepartureDateTimeConverted.ToString(DateFormatLong);
                s.DepartureDateFormattedShort = s.DepartureDateTimeConverted.ToString(DateFormatShort);
                s.DepartureTimeFormatted      = s.DepartureDateTimeConverted.ToString(TimeFormat);
                s.ArrivalDateFormattedLong    = s.ArrivalDateTimeConverted.ToString(DateFormatLong);
                s.ArrivalDateFormattedShort   = s.ArrivalDateTimeConverted.ToString(DateFormatShort);
                s.ArrivalTimeFormatted        = s.ArrivalDateTimeConverted.ToString(TimeFormat);

                s.OriginFormatted      = s.OriginAirport + ", " + s.OriginAirportCode + " (" + s.OriginCountry + ")";
                s.DestinationFormatted = s.DestinationAirport + ", " + s.DestinationAirportCode + " (" + s.DestinationCountry + ")";
            }

            foreach (Leg l in filterLegs)
            {
                List <Carrier> legCarriers = new List <Carrier>();
                List <Segment> legSegments = new List <Segment>();
                foreach (int sId in l.SegmentIds)
                {
                    var segment = filterSegments.Where(s => s.Id == sId).FirstOrDefault();
                    legSegments.Add(segment);
                }

                foreach (int cId in l.Carriers)
                {
                    var carrier = Carriers.Where(c => c.Id == cId).FirstOrDefault();
                    legCarriers.Add(carrier);
                }
                l.CarrierObjects = legCarriers;
                l.Segments       = legSegments;

                l.OriginPlace      = filterPlaces.Where(p => p.Id == l.OriginStation).FirstOrDefault();
                l.DestinationPlace = filterPlaces.Where(p => p.Id == l.DestinationStation).FirstOrDefault();

                l.OriginAirport     = l.OriginPlace.Name;
                l.OriginAirportCode = l.OriginPlace.Code;
                var originAirport = new AirportService().GetByIATA(l.OriginPlace.Code);
                if (originAirport != null)
                {
                    l.OriginAirportLatitude  = originAirport.LatitudeDecimalDegrees;
                    l.OriginAirportLongitude = originAirport.LongitudeDecimalDegrees;
                }

                l.OriginCity    = l.OriginPlace.ParentPlace.Name;
                l.OriginCountry = l.OriginPlace.ParentPlace.ParentPlace.Name;

                l.DestinationAirport     = l.DestinationPlace.Name;
                l.DestinationAirportCode = l.DestinationPlace.Code;
                var destinationAirport = new AirportService().GetByIATA(l.DestinationPlace.Code);
                if (destinationAirport != null)
                {
                    l.DestinationAirportLatitude  = destinationAirport.LatitudeDecimalDegrees;
                    l.DestinationAirportLongitude = destinationAirport.LongitudeDecimalDegrees;
                }
                l.DestinationCity    = l.DestinationPlace.ParentPlace.Name;
                l.DestinationCountry = l.DestinationPlace.ParentPlace.ParentPlace.Name;
                l.StopCount          = l.Stops.Count();

                l.DepartureDateTimeConverted = DateTime.Parse(l.Departure);
                l.ArrivalDateTimeConverted   = DateTime.Parse(l.Arrival);
                TimeSpan dt = TimeSpan.FromMinutes(l.Duration);
                l.DurationHourMinuteFormatted = ((dt.Days * 24) + dt.Hours).ToString() + "h " + dt.Minutes.ToString() + "m";
                if (l.StopCount == 0)
                {
                    l.DurationHourMinuteFormatted = l.DurationHourMinuteFormatted + ", Direct";
                }

                l.DepartureDateFormattedLong  = l.DepartureDateTimeConverted.ToString(DateFormatLong);
                l.DepartureDateFormattedShort = l.DepartureDateTimeConverted.ToString(DateFormatShort);
                l.DepartureTimeFormatted      = l.DepartureDateTimeConverted.ToString(TimeFormat);
                l.ArrivalDateFormattedLong    = l.ArrivalDateTimeConverted.ToString(DateFormatLong);
                l.ArrivalDateFormattedShort   = l.ArrivalDateTimeConverted.ToString(DateFormatShort);
                l.ArrivalTimeFormatted        = l.ArrivalDateTimeConverted.ToString(TimeFormat);

                l.OriginFormatted      = l.OriginAirport + ", " + l.OriginAirportCode + " (" + l.OriginCountry + ")";
                l.DestinationFormatted = l.DestinationAirport + ", " + l.DestinationAirportCode + " (" + l.DestinationCountry + ")";
            }

            foreach (Itinerary i in filterItineries)
            {
                if (i.OutboundLegId != null && i.OutboundLegId != "")
                {
                    i.OutboundLeg = filterLegs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault();

                    i.OutboundOriginPlace      = filterPlaces.Where(p => p.Id == (Legs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault().OriginStation)).FirstOrDefault();
                    i.OutboundDestinationPlace = filterPlaces.Where(p => p.Id == (Legs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault().DestinationStation)).FirstOrDefault();

                    i.OutboundDepartureDateTime           = filterLegs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault().DepartureDateTimeConverted;
                    i.OutboundArrivalDateTime             = filterLegs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault().ArrivalDateTimeConverted;
                    i.OutboundStopCount                   = filterLegs.Where(l => l.Id == i.OutboundLegId).FirstOrDefault().Stops.Count();
                    i.OutboundCarriers                    = i.OutboundLeg.CarrierObjects;
                    i.OutboundDuration                    = i.OutboundLeg.Duration;
                    i.OutboundDurationHourMinuteFormatted = i.OutboundLeg.DurationHourMinuteFormatted;

                    i.OutboundDepartureDateFormattedLong  = i.OutboundLeg.DepartureDateFormattedLong;
                    i.OutboundDepartureDateFormattedShort = i.OutboundLeg.DepartureDateFormattedShort;
                    i.OutboundDepartureTimeFormatted      = i.OutboundLeg.DepartureTimeFormatted;

                    i.OutboundArrivalDateFormattedLong  = i.OutboundLeg.ArrivalDateFormattedLong;
                    i.OutboundArrivalDateFormattedShort = i.OutboundLeg.ArrivalDateFormattedShort;
                    i.OutboundArrivalTimeFormatted      = i.OutboundLeg.ArrivalTimeFormatted;

                    i.OutboundOriginFormatted      = i.OutboundLeg.OriginFormatted;
                    i.OutboundDestinationFormatted = i.OutboundLeg.DestinationFormatted;
                }
                if (i.InboundLegId != null && i.InboundLegId != "")
                {
                    i.ReturnFlight = true;
                    i.InboundLeg   = filterLegs.Where(l => l.Id == i.InboundLegId).FirstOrDefault();

                    i.InboundOriginPlace      = filterPlaces.Where(p => p.Id == (Legs.Where(l => l.Id == i.InboundLegId).FirstOrDefault().OriginStation)).FirstOrDefault();
                    i.InboundDestinationPlace = filterPlaces.Where(p => p.Id == (Legs.Where(l => l.Id == i.InboundLegId).FirstOrDefault().DestinationStation)).FirstOrDefault();

                    i.InboundDepartureDateTime           = filterLegs.Where(l => l.Id == i.InboundLegId).FirstOrDefault().DepartureDateTimeConverted;
                    i.InboundArrivalDateTime             = filterLegs.Where(l => l.Id == i.InboundLegId).FirstOrDefault().ArrivalDateTimeConverted;
                    i.InboundStopCount                   = filterLegs.Where(l => l.Id == i.InboundLegId).FirstOrDefault().Stops.Count();
                    i.InboundCarriers                    = i.InboundLeg.CarrierObjects;
                    i.InboundDuration                    = i.InboundLeg.Duration;
                    i.InboundDurationHourMinuteFormatted = i.InboundLeg.DurationHourMinuteFormatted;

                    i.InboundDepartureDateFormattedLong  = i.InboundLeg.DepartureDateFormattedLong;
                    i.InboundDepartureDateFormattedShort = i.InboundLeg.DepartureDateFormattedShort;
                    i.InboundDepartureTimeFormatted      = i.InboundLeg.DepartureTimeFormatted;

                    i.InboundArrivalDateFormattedLong  = i.InboundLeg.ArrivalDateFormattedLong;
                    i.InboundArrivalDateFormattedShort = i.InboundLeg.ArrivalDateFormattedShort;
                    i.InboundArrivalTimeFormatted      = i.InboundLeg.ArrivalTimeFormatted;

                    i.InboundOriginFormatted      = i.InboundLeg.OriginFormatted;
                    i.InboundDestinationFormatted = i.InboundLeg.DestinationFormatted;
                }

                foreach (PricingOption p in i.PricingOptions)
                {
                    p.PriceFormatted        = p.Price.ToString();
                    p.PriceRounded          = (int)Math.Round(p.Price, 0, MidpointRounding.AwayFromZero);
                    p.PriceRoundedFormatted = p.PriceRounded.ToString();

                    if (searchCurrency != null)
                    {
                        string space = "";
                        if (searchCurrency.SpaceBetweenAmountAndSymbol)
                        {
                            space = " ";
                        }

                        p.PriceFormatted = String.Format("{0:#" + searchCurrency.ThousandsSeparator + "##0" + searchCurrency.DecimalSeparator + "#0}", Math.Round(p.Price, searchCurrency.DecimalDigits));

                        if (searchCurrency.SymbolOnLeft)
                        {
                            p.PriceFormatted = searchCurrency.Symbol + space + p.PriceFormatted;
                        }
                        else
                        {
                            p.PriceFormatted = p.PriceFormatted + space + searchCurrency.Symbol;
                        }

                        p.PriceRounded          = (int)Math.Round(p.Price, searchCurrency.RoundingCoefficient, MidpointRounding.AwayFromZero);
                        p.PriceRoundedFormatted = String.Format("{0:#" + searchCurrency.ThousandsSeparator + "##0" + searchCurrency.DecimalSeparator + "##}", p.PriceRounded);

                        if (searchCurrency.SymbolOnLeft)
                        {
                            p.PriceRoundedFormatted = searchCurrency.Symbol + space + p.PriceRoundedFormatted;
                        }
                        else
                        {
                            p.PriceRoundedFormatted = p.PriceRoundedFormatted + space + searchCurrency.Symbol;
                        }
                    }
                }

                var bestPricingOption = i.PricingOptions.OrderBy(po => po.Price).ThenBy(po => po.QuoteAgeInMinutes).FirstOrDefault();
                i.BestPrice                 = bestPricingOption.Price;
                i.BestPriceRounded          = bestPricingOption.PriceRounded;
                i.BestPriceFormatted        = bestPricingOption.PriceFormatted;
                i.BestPriceRoundedFormatted = bestPricingOption.PriceRoundedFormatted;

                i.DeeplinkUrl = bestPricingOption.DeeplinkUrl;

                var bestPricingAgent = Agents.Where(a => a.Id == bestPricingOption.Agents.FirstOrDefault()).FirstOrDefault();
                i.BestPriceAgent = bestPricingAgent;
                i.Agent          = bestPricingAgent.Name;
                i.AgentImageUrl  = bestPricingAgent.ImageUrl;

                i.OutboundOriginAirport      = i.OutboundOriginPlace.Name;
                i.OutboundOriginAirportPlace = i.OutboundOriginPlace;

                i.OutboundOriginAirportCode = i.OutboundOriginPlace.Code;
                var outboundOriginAirport = await flightSearhEngine.GetAirportByIDAsync(i.OutboundOriginPlace.Code, cancellationToken);

                if (outboundOriginAirport != null)
                {
                    i.OutboundOriginAirportLatitude  = outboundOriginAirport.Latitude;
                    i.OutboundOriginAirportLongitude = outboundOriginAirport.Longitude;
                }
                i.OutboundOriginCity      = i.OutboundOriginPlace.ParentPlace.Name;
                i.OutboundOriginCityPlace = i.OutboundOriginPlace.ParentPlace;

                var outboundOriginCity = await flightSearhEngine.GetCityByIDAsync(i.OutboundOriginCityPlace.Code, cancellationToken);

                if (outboundOriginCity != null)
                {
                    i.OutboundOriginCityLatitude  = outboundOriginCity.Latitude;
                    i.OutboundOriginCityLongitude = outboundOriginCity.Longitude;
                }

                i.OutboundOriginCountry      = i.OutboundOriginPlace.ParentPlace.ParentPlace.Name;
                i.OutboundOriginCountryPlace = i.OutboundOriginPlace.ParentPlace.ParentPlace;

                i.OutboundDestinationAirport      = i.OutboundDestinationPlace.Name;
                i.OutboundDestinationAirportPlace = i.OutboundDestinationPlace;
                i.OutboundDestinationAirportCode  = i.OutboundDestinationPlace.Code;
                var outboundDestinationAirport = await flightSearhEngine.GetAirportByIDAsync(i.OutboundDestinationPlace.Code, cancellationToken);

                if (outboundDestinationAirport != null)
                {
                    i.OutboundDestinationAirportLatitude  = outboundDestinationAirport.Latitude;
                    i.OutboundDestinationAirportLongitude = outboundDestinationAirport.Longitude;
                }
                i.OutboundDestinationCity      = i.OutboundDestinationPlace.ParentPlace.Name;
                i.OutboundDestinationCityPlace = i.OutboundDestinationPlace.ParentPlace;

                var outboundDestinationCity = await flightSearhEngine.GetCityByIDAsync(i.OutboundDestinationCityPlace.Code, cancellationToken);

                if (outboundDestinationCity != null)
                {
                    i.OutboundDestinationCityLatitude = outboundDestinationCity.Latitude;
                    i.OutboundDestinationCityLatitude = outboundDestinationCity.Longitude;
                }

                i.OutboundDestinationCountry      = i.OutboundDestinationPlace.ParentPlace.ParentPlace.Name;
                i.OutboundDestinationCountryPlace = i.OutboundDestinationPlace.ParentPlace.ParentPlace;


                if (i.InboundLegId != null && i.InboundLegId != "")
                {
                    i.InboundOriginAirport      = i.InboundOriginPlace.Name;
                    i.InboundOriginAirportPlace = i.InboundOriginPlace;

                    i.InboundOriginAirportCode = i.InboundOriginPlace.Code;
                    var inboundOriginAirport = await flightSearhEngine.GetAirportByIDAsync(i.InboundOriginPlace.Code, cancellationToken);

                    if (inboundOriginAirport != null)
                    {
                        i.InboundOriginAirportLatitude  = inboundOriginAirport.Latitude;
                        i.InboundOriginAirportLongitude = inboundOriginAirport.Longitude;
                    }
                    i.InboundOriginCity      = i.InboundOriginPlace.ParentPlace.Name;
                    i.InboundOriginCityPlace = i.InboundOriginPlace.ParentPlace;


                    var inboundOriginCity = await flightSearhEngine.GetCityByIDAsync(i.InboundOriginCityPlace.Code, cancellationToken);

                    if (inboundOriginCity != null)
                    {
                        i.InboundOriginCityLatitude  = inboundOriginCity.Latitude;
                        i.InboundOriginCityLongitude = inboundOriginCity.Longitude;
                    }

                    i.InboundOriginCountry      = i.InboundOriginPlace.ParentPlace.ParentPlace.Name;
                    i.InboundOriginCountryPlace = i.InboundOriginPlace.ParentPlace.ParentPlace;

                    i.InboundDestinationAirport      = i.InboundDestinationPlace.Name;
                    i.InboundDestinationAirportPlace = i.InboundDestinationPlace;
                    i.InboundDestinationAirportCode  = i.InboundDestinationPlace.Code;
                    var inboundDestinationAirport = await flightSearhEngine.GetAirportByIDAsync(i.InboundDestinationPlace.Code, cancellationToken);

                    if (inboundDestinationAirport != null)
                    {
                        i.InboundDestinationAirportLatitude  = inboundDestinationAirport.Latitude;
                        i.InboundDestinationAirportLongitude = inboundDestinationAirport.Longitude;
                    }
                    i.InboundDestinationCity      = i.InboundDestinationPlace.ParentPlace.Name;
                    i.InboundDestinationCityPlace = i.InboundDestinationPlace.ParentPlace;

                    var inboundDestinationCity = await flightSearhEngine.GetCityByIDAsync(i.InboundDestinationCityPlace.Code, cancellationToken);

                    if (inboundDestinationCity != null)
                    {
                        i.InboundDestinationCityLatitude  = inboundDestinationCity.Latitude;
                        i.InboundDestinationCityLongitude = inboundDestinationCity.Longitude;
                    }

                    i.InboundDestinationCountry      = i.InboundDestinationPlace.ParentPlace.ParentPlace.Name;
                    i.InboundDestinationCountryPlace = i.InboundDestinationPlace.ParentPlace.ParentPlace;
                }
            }

            var filterLegCarriers = Carriers.Where(c => filterLegs.Any(l => l.Carriers.Contains(c.Id))).ToList();

            var filterSegmentCarriers = Carriers.Where(c => filterSegments.Any(s => s.Carrier == c.Id)).ToList();

            var filterCarriers = filterLegCarriers.Union(filterSegmentCarriers, new DND.Common.Helpers.Comparer <Carrier>((c1, c2) => c1.Id == c2.Id)).ToList();

            var filterAgents = Agents.Where(a => filterItineries.Any(i => i.PricingOptions.Any(po => po.Agents.Contains(a.Id)))).ToList();

            LivePricesServiceResponse filterObject = new LivePricesServiceResponse();

            filterObject.SessionKey  = SessionKey;
            filterObject.Query       = Query;
            filterObject.Status      = Status;
            filterObject.Itineraries = filterItineries;
            filterObject.Legs        = filterLegs;
            filterObject.Segments    = filterSegments;
            filterObject.Carriers    = filterCarriers;
            filterObject.Agents      = filterAgents;
            filterObject.Places      = filterPlaces;
            filterObject.Currencies  = filterCurrencies;

            return(filterObject);
        }