///<summary>Converts the text for one plan into an object which will then be processed as needed.</summary> public static TrojanObject ProcessTextToObject(string text) { string[] lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string line; string[] fields; int percent; double amt; string rowVal; TrojanObject troj = new TrojanObject(); troj.BenefitList = new List <Benefit>(); troj.BenefitNotes = ""; bool usesAnnivers = false; Benefit ben; Benefit benCrownMajor = null; Benefit benCrownOnly = null; 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(); rowVal = fields[2].Trim(); if (fields[2] == "") { continue; } else //as long as there is data, add it to the notes { if (troj.BenefitNotes != "") { troj.BenefitNotes += "\r\n"; } troj.BenefitNotes += fields[1] + ": " + fields[2]; if (fields.Length == 4) { troj.BenefitNotes += " " + fields[3]; } } switch (fields[0]) { //default://for all rows that are not handled below case "TROJANID": troj.TROJANID = fields[2]; break; case "ENAME": troj.ENAME = fields[2]; break; case "PLANDESC": troj.PLANDESC = fields[2]; break; case "ELIGPHONE": troj.ELIGPHONE = fields[2]; break; case "POLICYNO": troj.POLICYNO = fields[2]; break; case "ECLAIMS": if (fields[2] == "YES") //accepts eclaims { troj.ECLAIMS = true; } else { troj.ECLAIMS = false; } break; case "PAYERID": troj.PAYERID = fields[2]; break; case "MAILTO": troj.MAILTO = fields[2]; break; case "MAILTOST": troj.MAILTOST = fields[2]; break; case "MAILCITYONLY": troj.MAILCITYONLY = fields[2]; break; case "MAILSTATEONLY": troj.MAILSTATEONLY = fields[2]; break; case "MAILZIPONLY": troj.MAILZIPONLY = 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 (CovCats.GetCount(true) > 0) { ben = new Benefit(); ben.BenefitType = InsBenefitType.Limitations; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum; ben.MonetaryAmt = PIn.Double(fields[2]); ben.TimePeriod = BenefitTimePeriod.CalendarYear; ben.CoverageLevel = BenefitCoverageLevel.Individual; troj.BenefitList.Add(ben.Copy()); } break; case "PLANYR": //eg Calendar year or Anniversary year or month renewal string monthName = fields[2].Split(new char[] { ' ' })[0]; usesAnnivers = true; if (fields[2] == "Calendar year" || monthName.In(DateTimeFormatInfo.CurrentInfo.MonthNames)) { usesAnnivers = false; troj.MonthRenewal = DateTimeFormatInfo.CurrentInfo.MonthNames.ToList().IndexOf(monthName) + 1; } //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 if (!fields[2].StartsWith("$")) { amt = 0; } else { fields[2] = fields[2].Remove(0, 1); fields[2] = fields[2].Split(new char[] { ' ' })[0]; amt = PIn.Double(fields[2]); } ben = new Benefit(); ben.BenefitType = InsBenefitType.Deductible; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum; ben.TimePeriod = BenefitTimePeriod.CalendarYear; ben.MonetaryAmt = amt; ben.CoverageLevel = BenefitCoverageLevel.Individual; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.Deductible; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum; ben.TimePeriod = BenefitTimePeriod.CalendarYear; ben.MonetaryAmt = 0; //amt; ben.CoverageLevel = BenefitCoverageLevel.Individual; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.Deductible; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum; ben.TimePeriod = BenefitTimePeriod.CalendarYear; ben.MonetaryAmt = 0; //amt; ben.CoverageLevel = BenefitCoverageLevel.Individual; troj.BenefitList.Add(ben.Copy()); break; case "PREV": //eg 100% or 'Incentive begins at 70%' or '80% Endo Major see notes' if (rowVal.ToLower() == "not covered") { percent = 0; } else { percent = ConvertPercentToInt(rowVal); //remove % } if (percent < 0 || percent > 100) { break; } ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); break; case "BASIC": if (rowVal.ToLower() == "not covered") { percent = 0; } else { percent = ConvertPercentToInt(rowVal); //remove % } if (percent < 0 || percent > 100) { break; } ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.OralSurgery).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); break; case "MAJOR": if (rowVal.ToLower() == "not covered") { percent = 0; } else { percent = ConvertPercentToInt(rowVal); //remove % } if (percent < 0 || percent > 100) { break; } ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); benCrownMajor = new Benefit(); benCrownMajor.BenefitType = InsBenefitType.CoInsurance; benCrownMajor.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Crowns).CovCatNum; benCrownMajor.Percent = percent; benCrownMajor.TimePeriod = BenefitTimePeriod.CalendarYear; //troj.BenefitList.Add(ben.Copy());//later break; case "CROWNS": //Examples: Paid Major, or 80%. We will only process percentages. if (rowVal.ToLower() == "not covered") { percent = 0; } else { percent = ConvertPercentToInt(rowVal); //remove % } if (percent < 0 || percent > 100) { break; } benCrownOnly = new Benefit(); benCrownOnly.BenefitType = InsBenefitType.CoInsurance; benCrownOnly.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Crowns).CovCatNum; benCrownOnly.Percent = percent; benCrownOnly.TimePeriod = BenefitTimePeriod.CalendarYear; //troj.BenefitList.Add(ben.Copy()); break; case "ORMAX": //eg $3500 lifetime if (!fields[2].StartsWith("$")) { break; } fields[2] = fields[2].Remove(0, 1); fields[2] = fields[2].Split(new char[] { ' ' })[0]; if (CovCats.GetCount(true) > 0) { ben = new Benefit(); ben.BenefitType = InsBenefitType.Limitations; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum; ben.MonetaryAmt = PIn.Double(fields[2]); ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); } break; case "ORPCT": if (rowVal.ToLower() == "not covered") { percent = 0; } else { percent = ConvertPercentToInt(rowVal); //remove % } if (percent < 0 || percent > 100) { break; } ben = new Benefit(); ben.BenefitType = InsBenefitType.CoInsurance; ben.CovCatNum = CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum; ben.Percent = percent; ben.TimePeriod = BenefitTimePeriod.CalendarYear; troj.BenefitList.Add(ben.Copy()); break; /*case "FEE": * if(!ProcedureCodes.IsValidCode(fields[1])) { * break;//skip * } * if(textTrojanID.Text==""){ * break; * } * feeSchedNum=Fees.ImportTrojan(fields[1],PIn.PDouble(fields[3]),textTrojanID.Text); * //the step above probably created a new feeschedule, requiring a reset of the three listboxes. * resetFeeSched=true; * break;*/ case "NOTES": //typically multiple instances if (troj.PlanNote != null && troj.PlanNote != "") { troj.PlanNote += "\r\n"; } troj.PlanNote += fields[2]; break; } //switch } //for //Set crowns if (benCrownOnly != null) { troj.BenefitList.Add(benCrownOnly.Copy()); } else if (benCrownMajor != null) { troj.BenefitList.Add(benCrownMajor.Copy()); } //set calendar vs serviceyear if (usesAnnivers) { for (int i = 0; i < troj.BenefitList.Count; i++) { troj.BenefitList[i].TimePeriod = BenefitTimePeriod.ServiceYear; } } return(troj); }
///<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); }