private void butOK_Click(object sender, System.EventArgs e) { if (textPercent.errorProvider1.GetError(textPercent) != "" //|| textPriBasicPercent.errorProvider1.GetError(textPriBasicPercent)!="" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } _covCatCur.Description = textDescription.Text; if (textPercent.Text == "") { _covCatCur.DefaultPercent = -1; } else { _covCatCur.DefaultPercent = PIn.Int(textPercent.Text); } _covCatCur.IsHidden = checkHidden.Checked; _covCatCur.EbenefitCat = (EbenefitCategory)comboCat.SelectedIndex; if (IsNew) { CovCats.Insert(_covCatCur); } else { CovCats.Update(_covCatCur); } DialogResult = DialogResult.OK; }
private void butDown_Click(object sender, System.EventArgs e) { if (gridMain.SelectedIndices.Length < 1) { MsgBox.Show(this, "Please select a category first."); return; } if (gridMain.Rows[gridMain.SelectedIndices[0]].Tag.GetType() != typeof(CovCat)) { MsgBox.Show(this, "Please select a category first."); return; } long catNum = ((CovCat)gridMain.Rows[gridMain.SelectedIndices[0]].Tag).CovCatNum; CovCats.MoveDown((CovCat)gridMain.Rows[gridMain.SelectedIndices[0]].Tag); changed = true; FillSpans(); for (int i = 0; i < gridMain.Rows.Count; i++) { if (gridMain.Rows[i].Tag.GetType() == typeof(CovCat) && catNum == ((CovCat)gridMain.Rows[i].Tag).CovCatNum) { gridMain.SetSelected(i, true); } } }
/* * private void butDefaultsCheck_Click(object sender,EventArgs e) { * string retVal=CheckDefaults(); * if(retVal=="") { * MsgBox.Show(this,"Categories are set up correctly. Spans have not been checked. Push the Reset button to automatically reset the spans to default."); * } * else { * MessageBox.Show(retVal); * } * }*/ private string CheckDefaults() { //There needs to be at least 14 categories, each with an etype and no duplicates. string retVal = ""; int count; for (int i = 1; i < 15; i++) //starts with 1 because we don't care about None category { count = CovCats.CountForEbenCat((EbenefitCategory)i); if (count > 1) { retVal += "Duplicate category: " + ((EbenefitCategory)i).ToString() + "\r\n"; } if (count == 0) { retVal += "Missing category: " + ((EbenefitCategory)i).ToString() + "\r\n"; } } if (retVal != "") { retVal = "The following errors must be fixed manually:\r\n\r\n" + retVal + "\r\n" + "Remember that any changes you make affect all current patients who are using those categories."; } return(retVal); }
///<summary>Makes the "Before" and "After" columns human-readable for certain logs.</summary> private void TranslateBeforeAndAfter() { foreach (InsEditLog logCur in _listLogs) { long beforeKey = PIn.Long(logCur.OldValue, false); long afterKey = PIn.Long(logCur.NewValue, false); switch (logCur.FieldName) { case "CarrierNum": if (logCur.LogType == InsEditLogType.Carrier) { break; } string carrierNameBefore = Carriers.GetCarrier(beforeKey).CarrierName; string carrierNameAfter = Carriers.GetCarrier(afterKey).CarrierName; if (logCur.LogType == InsEditLogType.InsPlan && carrierNameBefore == carrierNameAfter) //Edits to carrier. { break; //Don't translate CarrierNum to CarrierName when both carriers have the same name, loses too much useful detail. } logCur.OldValue = beforeKey == 0 ? logCur.OldValue : carrierNameBefore; logCur.NewValue = afterKey == 0 ? logCur.NewValue : carrierNameAfter; break; case "EmployerNum": if (logCur.LogType == InsEditLogType.Employer) { break; } logCur.OldValue = beforeKey == 0 ? logCur.OldValue : Employers.GetName(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : Employers.GetName(afterKey); break; case "FeeSched": case "CopayFeeSched": case "AllowedFeeSched": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : FeeScheds.GetDescription(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : FeeScheds.GetDescription(afterKey); break; case "BenefitType": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : Enum.GetName(typeof(InsBenefitType), beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : Enum.GetName(typeof(InsBenefitType), afterKey); break; case "CovCatNum": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : CovCats.GetDesc(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : CovCats.GetDesc(afterKey); break; case "CodeNum": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : ProcedureCodes.GetStringProcCode(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : ProcedureCodes.GetStringProcCode(afterKey); break; default: break; } } }
///<summary></summary> public static void MoveDown(CovCat covcat) { CovCats.Refresh(); int oldOrder = CovCatB.GetOrderLong(covcat.CovCatNum); if (oldOrder == CovCatB.Listt.Length - 1) { return; } SetOrder(CovCatB.Listt[oldOrder], oldOrder + 1); SetOrder(CovCatB.Listt[oldOrder + 1], oldOrder); }
///<summary></summary> public static void MoveUp(CovCat covcat) { CovCats.Refresh(); int oldOrder = CovCatB.GetOrderLong(covcat.CovCatNum); if (oldOrder == 0) { return; } SetOrder(CovCatB.Listt[oldOrder], oldOrder - 1); SetOrder(CovCatB.Listt[oldOrder - 1], oldOrder); }
///<summary>Makes the "Before" and "After" columns human-readable for certain logs.</summary> private void TranslateBeforeAndAfter() { foreach (InsEditLog logCur in _listLogs) { long beforeKey = PIn.Long(logCur.OldValue, false); long afterKey = PIn.Long(logCur.NewValue, false); switch (logCur.FieldName) { case "CarrierNum": if (logCur.LogType == InsEditLogType.Carrier) { break; } logCur.OldValue = beforeKey == 0 ? logCur.OldValue : Carriers.GetCarrier(beforeKey).CarrierName; logCur.NewValue = afterKey == 0 ? logCur.NewValue : Carriers.GetCarrier(afterKey).CarrierName; break; case "EmployerNum": if (logCur.LogType == InsEditLogType.Employer) { break; } logCur.OldValue = beforeKey == 0 ? logCur.OldValue : Employers.GetName(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : Employers.GetName(afterKey); break; case "FeeSched": case "CopayFeeSched": case "AllowedFeeSched": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : FeeScheds.GetDescription(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : FeeScheds.GetDescription(afterKey); break; case "BenefitType": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : Enum.GetName(typeof(InsBenefitType), beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : Enum.GetName(typeof(InsBenefitType), afterKey); break; case "CovCatNum": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : CovCats.GetDesc(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : CovCats.GetDesc(afterKey); break; case "CodeNum": logCur.OldValue = beforeKey == 0 ? logCur.OldValue : ProcedureCodes.GetStringProcCode(beforeKey); logCur.NewValue = afterKey == 0 ? logCur.NewValue : ProcedureCodes.GetStringProcCode(afterKey); break; default: break; } } }
private void butDefaultsReset_Click(object sender, EventArgs e) { string retVal = CheckDefaults(); if (retVal != "") { MessageBox.Show(retVal); return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Reset orders and spans to default?")) { return; } CovCats.SetOrdersToDefault(); CovCats.SetSpansToDefault(); FillSpans(); MsgBox.Show(this, "Done."); }
///<summary>Pass in list of procedures and covCat, return the sum of all CanadaTimeUnits of the procedures in that covCat as a double.</summary> private double GetAmtUsedForCat(List <Procedure> listProcs, CovCat covCat) { List <ProcedureCode> listProcCodes = new List <ProcedureCode>(); for (int i = 0; i < listProcs.Count; i++) { listProcCodes.Add(ProcedureCodes.GetProcCode(listProcs[i].CodeNum)); //turn list of procedures into list of procedurecodes. } double total = 0; //CanadaTimeUnits can be decimal numbers, like 0.5. for (int i = 0; i < listProcCodes.Count; i++) //for every procedurecode //Can be null if the procedure doesn't fall within any spans (like note proc, the code is "clinical" so doesn't fall inside any spans) { CovCat benCat = CovCats.GetCovCat(CovSpans.GetCat(listProcCodes[i].ProcCode)); //if the covCat of that code is the same as the passed-in covCat if (benCat != null && benCat.EbenefitCat == covCat.EbenefitCat) { total += listProcCodes[i].CanadaTimeUnits; //add the Canada time units to the total. } } return(total); }
///<summary>raised for each page to be printed. One page per appointment.</summary> private void pd_PrintPage(object sender, PrintPageEventArgs ev) { if (ApptNum != 0) //just for one appointment { date = Appointments.DateSelected; } Graphics g = ev.Graphics; float y = 50; float x = 0; string str; float sizeW; //used when measuring text for placement Font fontTitle = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold); Font fontHeading = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold); Font font = new Font(FontFamily.GenericSansSerif, 8); SolidBrush brush = new SolidBrush(Color.Black); //Title---------------------------------------------------------------------------------------------------------- str = Lan.g(this, "Routing Slip"); sizeW = g.MeasureString(str, fontTitle).Width; x = 425 - sizeW / 2; g.DrawString(str, fontTitle, brush, x, y); y += 35; x = 75; //Today's appointment, including procedures----------------------------------------------------------------------- Family fam = Patients.GetFamily(Appts[pagesPrinted].PatNum); Patient pat = fam.GetPatient(Appts[pagesPrinted].PatNum); str = pat.GetNameFL(); g.DrawString(str, fontHeading, brush, x, y); y += 18; str = Appts[pagesPrinted].AptDateTime.ToShortTimeString() + " " + Appts[pagesPrinted].AptDateTime.ToShortDateString(); g.DrawString(str, fontHeading, brush, x, y); y += 18; str = (Appts[pagesPrinted].Pattern.Length * 5).ToString() + " " + Lan.g(this, "minutes"); g.DrawString(str, font, brush, x, y); y += 15; str = Providers.GetAbbr(Appts[pagesPrinted].ProvNum); g.DrawString(str, font, brush, x, y); y += 15; if (Appts[pagesPrinted].ProvHyg != 0) { str = Providers.GetAbbr(Appts[pagesPrinted].ProvHyg); g.DrawString(str, font, brush, x, y); y += 15; } str = Lan.g(this, "Procedures:"); g.DrawString(str, font, brush, x, y); y += 15; Procedure[] procsAll = Procedures.Refresh(pat.PatNum); Procedure[] procsApt = Procedures.GetProcsOneApt(Appts[pagesPrinted].AptNum, procsAll); for (int i = 0; i < procsApt.Length; i++) { str = " " + Procedures.GetDescription(procsApt[i]); g.DrawString(str, font, brush, x, y); y += 15; } str = Lan.g(this, "Note:") + " " + Appts[pagesPrinted].Note; g.DrawString(str, font, brush, x, y); y += 25; //Patient/Family Info--------------------------------------------------------------------------------------------- g.DrawLine(Pens.Black, 75, y, 775, y); str = Lan.g(this, "Patient Info"); g.DrawString(str, fontHeading, brush, x, y); y += 18; str = Lan.g(this, "PatNum:") + " " + pat.PatNum.ToString(); g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Age:") + " "; if (pat.Age > 0) { str += pat.Age.ToString(); } g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Date of First Visit:") + " "; if (pat.DateFirstVisit.Year < 1880) { str += "?"; } else if (pat.DateFirstVisit == Appts[pagesPrinted].AptDateTime.Date) { str += Lan.g(this, "New Patient"); } else { str += pat.DateFirstVisit.ToShortDateString(); } g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Billing Type:") + " " + DefB.GetName(DefCat.BillingTypes, pat.BillingType); g.DrawString(str, font, brush, x, y); y += 15; Recall[] recallList = Recalls.GetList(new int[] { pat.PatNum }); str = Lan.g(this, "Recall Due Date:") + " "; if (recallList.Length > 0) { str += recallList[0].DateDue.ToShortDateString(); } g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Medical notes:") + " " + pat.MedUrgNote; g.DrawString(str, font, brush, x, y); y += 25; //Other Family Members str = Lan.g(this, "Other Family Members"); g.DrawString(str, fontHeading, brush, x, y); y += 18; for (int i = 0; i < fam.List.Length; i++) { if (fam.List[i].PatNum == pat.PatNum) { continue; } str = fam.List[i].GetNameFL(); if (fam.List[i].Age > 0) { str += ", " + fam.List[i].Age.ToString(); } g.DrawString(str, font, brush, x, y); y += 15; } y += 10; //Insurance Info-------------------------------------------------------------------------------------------------- g.DrawLine(Pens.Black, 75, y, 775, y); str = Lan.g(this, "Insurance"); g.DrawString(str, fontHeading, brush, x, y); y += 18; PatPlan[] patPlanList = PatPlans.Refresh(pat.PatNum); InsPlan[] plans = InsPlans.Refresh(fam); ClaimProc[] claimProcList = ClaimProcs.Refresh(pat.PatNum); Benefit[] benefits = Benefits.Refresh(patPlanList); InsPlan plan; Carrier carrier; string subscriber; double max; double deduct; if (patPlanList.Length == 0) { str = Lan.g(this, "none"); g.DrawString(str, font, brush, x, y); y += 15; } for (int i = 0; i < patPlanList.Length; i++) { plan = InsPlans.GetPlan(patPlanList[i].PlanNum, plans); carrier = Carriers.GetCarrier(plan.CarrierNum); str = carrier.CarrierName; g.DrawString(str, fontHeading, brush, x, y); y += 18; subscriber = fam.GetNameInFamFL(plan.Subscriber); if (subscriber == "") //subscriber from another family { subscriber = Patients.GetLim(plan.Subscriber).GetNameLF(); } str = Lan.g(this, "Subscriber:") + " " + subscriber; g.DrawString(str, font, brush, x, y); y += 15; bool isFamMax = Benefits.GetIsFamMax(benefits, plan.PlanNum); str = ""; if (isFamMax) { str += Lan.g(this, "Family "); } str += Lan.g(this, "Annual Max:") + " "; max = Benefits.GetAnnualMax(benefits, plan.PlanNum, patPlanList[i].PatPlanNum); if (max != -1) { str += max.ToString("n0") + " "; } str += " "; bool isFamDed = Benefits.GetIsFamDed(benefits, plan.PlanNum); if (isFamDed) { str += Lan.g(this, "Family "); } str += Lan.g(this, "Deductible:") + " "; deduct = Benefits.GetDeductible(benefits, plan.PlanNum, patPlanList[i].PatPlanNum); if (deduct != -1) { str += deduct.ToString("n0"); } g.DrawString(str, font, brush, x, y); y += 15; str = ""; for (int j = 0; j < benefits.Length; j++) { if (benefits[j].PlanNum != plan.PlanNum) { continue; } if (benefits[j].BenefitType != InsBenefitType.Percentage) { continue; } if (str != "") { str += ", "; } str += CovCats.GetDesc(benefits[j].CovCatNum) + " " + benefits[j].Percent.ToString() + "%"; } if (str != "") { g.DrawString(str, font, brush, x, y); y += 15; } double pend = 0; double used = 0; if (isFamMax || isFamDed) { ClaimProc[] claimProcsFam = ClaimProcs.RefreshFam(plan.PlanNum); used = InsPlans.GetInsUsed(claimProcsFam, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits); pend = InsPlans.GetPending(claimProcsFam, date, plan, patPlanList[i].PatPlanNum, -1, benefits); } else { used = InsPlans.GetInsUsed(claimProcList, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits); pend = InsPlans.GetPending(claimProcList, date, plan, patPlanList[i].PatPlanNum, -1, benefits); } str = Lan.g(this, "Ins Used:") + " " + used.ToString("n"); g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Ins Pending:") + " " + pend.ToString("n"); g.DrawString(str, font, brush, x, y); y += 15; } y += 10; //Account Info--------------------------------------------------------------------------------------------------- g.DrawLine(Pens.Black, 75, y, 775, y); str = Lan.g(this, "Account Info"); g.DrawString(str, fontHeading, brush, x, y); y += 18; str = Lan.g(this, "Guarantor:") + " " + fam.List[0].GetNameFL(); g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Balance:") + (fam.List[0].BalTotal - fam.List[0].InsEst).ToString("c"); if (fam.List[0].InsEst > .01) { str += " (" + fam.List[0].BalTotal.ToString("c") + " - " + fam.List[0].InsEst.ToString("c") + " " + Lan.g(this, "InsEst") + ")"; } g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Aging:") + " 0-30:" + fam.List[0].Bal_0_30.ToString("c") + " 31-60:" + fam.List[0].Bal_31_60.ToString("c") + " 61-90:" + fam.List[0].Bal_61_90.ToString("c") + " 90+:" + fam.List[0].BalOver90.ToString("c"); g.DrawString(str, font, brush, x, y); y += 15; str = Lan.g(this, "Fam Urgent Fin Note:") + fam.List[0].FamFinUrgNote; g.DrawString(str, font, brush, x, y); y += 15; y += 10; //Treatment Plan-------------------------------------------------------------------------------------------------- g.DrawLine(Pens.Black, 75, y, 775, y); str = Lan.g(this, "Treatment Plan"); g.DrawString(str, fontHeading, brush, x, y); y += 18; for (int i = 0; i < procsAll.Length; i++) { if (procsAll[i].ProcStatus != ProcStat.TP) { continue; } str = Procedures.GetDescription(procsAll[i]); g.DrawString(str, font, brush, x, y); y += 15; } pagesPrinted++; if (pagesPrinted == Appts.Length) { ev.HasMorePages = false; pagesPrinted = 0; } else { ev.HasMorePages = true; } }
private void FillSpans() { CovCats.RefreshCache(); CovSpans.RefreshCache(); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Category", 90); gridMain.Columns.Add(col); col = new ODGridColumn("From ADA", 70); gridMain.Columns.Add(col); col = new ODGridColumn("To ADA", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Hidden", 45); gridMain.Columns.Add(col); col = new ODGridColumn("E-Benefit Category", 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; CovSpan[] spansForCat; for (int i = 0; i < CovCatC.Listt.Count; i++) { row = new ODGridRow(); row.Tag = CovCatC.Listt[i].Copy(); row.ColorBackG = Color.FromArgb(225, 225, 225); if (i != 0) { gridMain.Rows[gridMain.Rows.Count - 1].ColorLborder = Color.Black; } row.Cells.Add(CovCatC.Listt[i].Description); row.Cells.Add(""); row.Cells.Add(""); if (CovCatC.Listt[i].IsHidden) { row.Cells.Add("X"); } else { row.Cells.Add(""); } if (CovCatC.Listt[i].EbenefitCat == EbenefitCategory.None) { row.Cells.Add(""); } else { row.Cells.Add(CovCatC.Listt[i].EbenefitCat.ToString()); } gridMain.Rows.Add(row); spansForCat = CovSpans.GetForCat(CovCatC.Listt[i].CovCatNum); for (int j = 0; j < spansForCat.Length; j++) { row = new ODGridRow(); row.Tag = spansForCat[j].Copy(); row.Cells.Add(""); row.Cells.Add(spansForCat[j].FromCode); row.Cells.Add(spansForCat[j].ToCode); row.Cells.Add(""); row.Cells.Add(""); gridMain.Rows.Add(row); } } gridMain.EndUpdate(); }
///<summary></summary> private void butOK_Click(object sender, System.EventArgs e) { if (textMain.Text == "") { MsgBox.Show(this, "Please paste the text generated by the other program into the large box first."); return; } pat = new Patient(); pat.PriProv = PrefC.GetLong(PrefName.PracticeDefaultProv); pat.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType); guar = new Patient(); guar.PriProv = PrefC.GetLong(PrefName.PracticeDefaultProv); guar.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType); subsc = new Patient(); subsc.PriProv = PrefC.GetLong(PrefName.PracticeDefaultProv); subsc.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType); sub = new InsSub(); sub.ReleaseInfo = true; sub.AssignBen = true; plan = new InsPlan(); carrier = new Carrier(); insRelat = "self"; //this is the default if not included guarRelat = "self"; InsEmp = ""; GuarEmp = ""; NoteMedicalComp = ""; insPresent = false; annualMax = -1; deductible = -1; XmlTextReader reader = new XmlTextReader(new StringReader(textMain.Text)); reader.WhitespaceHandling = WhitespaceHandling.None; string element = ""; string textValue = ""; string rootElement = ""; string segment = ""; //eg PatientIdentification string field = ""; //eg NameLast string endelement = ""; warnings = ""; try{ while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: element = reader.Name; if (rootElement == "") //should be the first node { if (element == "Message") { rootElement = "Message"; } else { throw new Exception(element + " should not be the first element."); } } else if (segment == "") //expecting a new segment { segment = element; if (segment != "MessageHeader" && segment != "PatientIdentification" && segment != "Guarantor" && segment != "Insurance") { throw new Exception(segment + " is not a recognized segment."); } } else //expecting a new field { field = element; } if (segment == "Insurance") { insPresent = true; } break; case XmlNodeType.Text: textValue = reader.Value; if (field == "") { throw new Exception("Unexpected text: " + textValue); } break; case XmlNodeType.EndElement: endelement = reader.Name; if (field == "") //we're not in a field, so we must be closing a segment or rootelement { if (segment == "") //we're not in a segment, so we must be closing the rootelement { if (rootElement == "Message") { rootElement = ""; } else { throw new Exception("Message closing element expected."); } } else //must be closing a segment { segment = ""; } } else //closing a field { field = ""; textValue = ""; } break; } //switch if (rootElement == "") { break; //this will ignore anything after the message endelement } if (field != "" && textValue != "") { if (segment == "MessageHeader") { ProcessMSH(field, textValue); } else if (segment == "PatientIdentification") { ProcessPID(field, textValue); } else if (segment == "Guarantor") { ProcessGT(field, textValue); } else if (segment == "Insurance") { ProcessINS(field, textValue); } } } //while } catch (Exception ex) { MessageBox.Show(ex.Message); //MsgBox.Show(this,"Error in the XML format."); reader.Close(); return; } finally{ reader.Close(); } //Warnings and errors----------------------------------------------------------------------------- if (pat.LName == "" || pat.FName == "" || pat.Birthdate.Year < 1880) { MsgBox.Show(this, "Patient first and last name and birthdate are required. Could not import."); return; } //if guarRelat is not self, and name and birthdate not supplied, no error. Just make guar self. if (guarRelat != "self") { if (guar.LName == "" || guar.FName == "" || guar.Birthdate.Year < 1880) { warnings += "Guarantor information incomplete. Guarantor will be self.\r\n"; guarRelat = "self"; } } if (insPresent) { if (carrier.CarrierName == "") { warnings += "Insurance CompanyName is missing. No insurance info will be imported.\r\n"; insPresent = false; } else if (insRelat != "self") { if (subsc.LName == "" || subsc.FName == "" || subsc.Birthdate.Year < 1880) { warnings += "Subscriber name or birthdate is missing. No insurance info will be imported.\r\n"; insPresent = false; } } else if (sub.SubscriberID == "") { warnings += "PolicyNumber/SubscriberID missing.\r\n"; sub.SubscriberID = " "; } } if (warnings != "") { if (MessageBox.Show("It's safe to import, but you should be aware of the following issues:\r\n" + warnings + "\r\nContinue with Import?", "Warnings", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } //Patient------------------------------------------------------------------------------------- //DataTable table; long patNum = Patients.GetPatNumByNameAndBirthday(pat.LName, pat.FName, pat.Birthdate); Patient existingPat = null; existingPatOld = null; //we will need this to do an update. if (patNum != 0) //a patient already exists, so only add missing fields { existingPat = Patients.GetPat(patNum); existingPatOld = existingPat.Copy(); if (existingPat.MiddleI == "") //only alter existing if blank { existingPat.MiddleI = pat.MiddleI; } if (pat.Gender != PatientGender.Unknown) { existingPat.Gender = pat.Gender; } if (existingPat.Preferred == "") { existingPat.Preferred = pat.Preferred; } if (existingPat.Address == "") { existingPat.Address = pat.Address; } if (existingPat.Address2 == "") { existingPat.Address2 = pat.Address2; } if (existingPat.City == "") { existingPat.City = pat.City; } if (existingPat.State == "") { existingPat.State = pat.State; } if (existingPat.Zip == "") { existingPat.Zip = pat.Zip; } if (existingPat.HmPhone == "") { existingPat.HmPhone = pat.HmPhone; } if (existingPat.Email == "") { existingPat.Email = pat.Email; } if (existingPat.WkPhone == "") { existingPat.WkPhone = pat.WkPhone; } if (existingPat.Position == PatientPosition.Single) { existingPat.Position = pat.Position; } if (existingPat.SSN == "") { existingPat.SSN = pat.SSN; } existingPat.AddrNote += pat.AddrNote; //concat Patients.Update(existingPat, existingPatOld); PatientNote PatientNoteCur = PatientNotes.Refresh(existingPat.PatNum, existingPat.Guarantor); PatientNoteCur.MedicalComp += NoteMedicalComp; PatientNotes.Update(PatientNoteCur, existingPat.Guarantor); //guarantor will not be altered in any way } //if patient already exists else //patient is new, so insert { Patients.Insert(pat, false); SecurityLogs.MakeLogEntry(Permissions.PatientCreate, pat.PatNum, "Created from Import Patient XML tool."); existingPatOld = pat.Copy(); pat.Guarantor = pat.PatNum; //this can be changed later. Patients.Update(pat, existingPatOld); PatientNote PatientNoteCur = PatientNotes.Refresh(pat.PatNum, pat.Guarantor); PatientNoteCur.MedicalComp += NoteMedicalComp; PatientNotes.Update(PatientNoteCur, pat.Guarantor); } //guar----------------------------------------------------------------------------------------------------- if (existingPat == null) //only add or alter guarantor for new patients { if (guarRelat == "self") { //pat is already set with guar as self //ignore all guar fields except EmployerName existingPatOld = pat.Copy(); pat.EmployerNum = Employers.GetEmployerNum(GuarEmp); Patients.Update(pat, existingPatOld); } else { //if guarRelat is not self, and name and birthdate not supplied, a warning was issued, and relat was changed to self. //add guarantor or attach to an existing guarantor long guarNum = Patients.GetPatNumByNameAndBirthday(guar.LName, guar.FName, guar.Birthdate); if (guarNum != 0) //a guar already exists, so simply attach. Make no other changes { existingPatOld = pat.Copy(); pat.Guarantor = guarNum; if (guarRelat == "parent") { pat.Position = PatientPosition.Child; } Patients.Update(pat, existingPatOld); } else //we need to completely create guar, then attach { Patients.Insert(guar, false); SecurityLogs.MakeLogEntry(Permissions.PatientCreate, guar.PatNum, "Created from Import Patient XML tool."); //set guar for guar existingPatOld = guar.Copy(); guar.Guarantor = guar.PatNum; guar.EmployerNum = Employers.GetEmployerNum(GuarEmp); Patients.Update(guar, existingPatOld); //set guar for pat existingPatOld = pat.Copy(); pat.Guarantor = guar.PatNum; if (guarRelat == "parent") { pat.Position = PatientPosition.Child; } Patients.Update(pat, existingPatOld); } } } //subsc-------------------------------------------------------------------------------------------------- if (!insPresent) { //this takes care of missing carrier name or subscriber info. MsgBox.Show(this, "Done"); DialogResult = DialogResult.OK; } if (insRelat == "self") { sub.Subscriber = pat.PatNum; } else //we need to find or add the subscriber { patNum = Patients.GetPatNumByNameAndBirthday(subsc.LName, subsc.FName, subsc.Birthdate); if (patNum != 0) //a subsc already exists, so simply attach. Make no other changes { sub.Subscriber = patNum; } else //need to create and attach a subscriber { Patients.Insert(subsc, false); SecurityLogs.MakeLogEntry(Permissions.PatientCreate, subsc.PatNum, "Created from Import Patient XML tool."); //set guar to same guar as patient existingPatOld = subsc.Copy(); subsc.Guarantor = pat.Guarantor; Patients.Update(subsc, existingPatOld); sub.Subscriber = subsc.PatNum; } } //carrier------------------------------------------------------------------------------------------------- //Carriers.Cur=carrier; carrier = Carriers.GetIdentical(carrier); //this automatically finds or creates a carrier //plan------------------------------------------------------------------------------------------------------ plan.EmployerNum = Employers.GetEmployerNum(InsEmp); plan.CarrierNum = carrier.CarrierNum; InsPlans.Insert(plan); //Attach plan to subscriber sub.PlanNum = plan.PlanNum; InsSubs.Insert(sub); //Then attach plan List <PatPlan> PatPlanList = PatPlans.Refresh(pat.PatNum); PatPlan patplan = new PatPlan(); patplan.Ordinal = (byte)(PatPlanList.Count + 1); //so the ordinal of the first entry will be 1, NOT 0. patplan.PatNum = pat.PatNum; patplan.InsSubNum = sub.InsSubNum; switch (insRelat) { case "self": patplan.Relationship = Relat.Self; break; case "parent": patplan.Relationship = Relat.Child; break; case "spouse": patplan.Relationship = Relat.Spouse; break; case "guardian": patplan.Relationship = Relat.Dependent; break; } PatPlans.Insert(patplan); //benefits if (annualMax != -1 && CovCats.GetCount(true) > 0) { Benefit ben = new Benefit(); ben.BenefitType = InsBenefitType.Limitations; ben.CovCatNum = CovCats.GetFirst(true).CovCatNum; ben.MonetaryAmt = annualMax; ben.PlanNum = plan.PlanNum; ben.TimePeriod = BenefitTimePeriod.CalendarYear; Benefits.Insert(ben); } if (deductible != -1 && CovCats.GetCount(true) > 0) { Benefit ben = new Benefit(); ben.BenefitType = InsBenefitType.Deductible; ben.CovCatNum = CovCats.GetFirst(true).CovCatNum; ben.MonetaryAmt = deductible; ben.PlanNum = plan.PlanNum; ben.TimePeriod = BenefitTimePeriod.CalendarYear; Benefits.Insert(ben); } MsgBox.Show(this, "Done"); DialogResult = DialogResult.OK; }
private void FormBenefitEdit_Load(object sender, System.EventArgs e) { if (BenCur == null) { MessageBox.Show("Benefit cannot be null."); DialogResult = DialogResult.Cancel; return; } if (!Security.IsAuthorized(Permissions.InsPlanEdit)) { butOK.Enabled = false; } if (BenCur.PatPlanNum == 0) //attached to insplan { checkPat.Checked = false; } else { checkPat.Checked = true; } listCategory.Items.Clear(); listCategory.Items.Add(Lan.g(this, "None")); listCategory.SelectedIndex = 0; _listCovCats = CovCats.GetDeepCopy(true); for (int i = 0; i < _listCovCats.Count; i++) { listCategory.Items.Add(_listCovCats[i].Description); if (_listCovCats[i].CovCatNum == BenCur.CovCatNum) { listCategory.SelectedIndex = i + 1; } } textProcCode.Text = ProcedureCodes.GetStringProcCode(BenCur.CodeNum); listType.Items.Clear(); for (int i = 0; i < Enum.GetNames(typeof(InsBenefitType)).Length; i++) { listType.Items.Add(Lan.g("enumInsBenefitType", Enum.GetNames(typeof(InsBenefitType))[i])); if ((int)BenCur.BenefitType == i) { listType.SelectedIndex = i; } } if (BenCur.Percent == -1) { textPercent.Text = ""; } else { textPercent.Text = BenCur.Percent.ToString(); } if (BenCur.MonetaryAmt == -1) { textAmount.Text = ""; } else { textAmount.Text = BenCur.MonetaryAmt.ToString("n"); } listTimePeriod.Items.Clear(); for (int i = 0; i < Enum.GetNames(typeof(BenefitTimePeriod)).Length; i++) { listTimePeriod.Items.Add(Lan.g("enumBenefitTimePeriod", Enum.GetNames(typeof(BenefitTimePeriod))[i])); if ((int)BenCur.TimePeriod == i) { listTimePeriod.SelectedIndex = i; } } textQuantity.Text = BenCur.Quantity.ToString(); listQuantityQualifier.Items.Clear(); for (int i = 0; i < Enum.GetNames(typeof(BenefitQuantity)).Length; i++) { listQuantityQualifier.Items.Add(Lan.g("enumBenefitQuantity", Enum.GetNames(typeof(BenefitQuantity))[i])); if ((int)BenCur.QuantityQualifier == i) { listQuantityQualifier.SelectedIndex = i; } } for (int i = 0; i < Enum.GetNames(typeof(BenefitCoverageLevel)).Length; i++) { listCoverageLevel.Items.Add(Lan.g("enumBenefitCoverageLevel", Enum.GetNames(typeof(BenefitCoverageLevel))[i])); if ((int)BenCur.CoverageLevel == i) { listCoverageLevel.SelectedIndex = i; } } //determine if this is an annual max /*if(textCode.Text=="" * && listType.SelectedIndex==(int)InsBenefitType.Limitations * && (listTimePeriod.SelectedIndex==(int)BenefitTimePeriod.CalendarYear || listTimePeriod.SelectedIndex==(int)BenefitTimePeriod.ServiceYear) || && listQuantityQualifier.SelectedIndex==(int)BenefitQuantity.None) ||{ || isAnnualMax=true; ||}*/ }
private void FillGrid() { gridRemainTimeUnits.BeginUpdate(); gridRemainTimeUnits.ListGridRows.Clear(); List <PatPlan> listPatPlans = PatPlans.Refresh(_patCur.PatNum); List <InsSub> listInsSubs = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList()); List <Benefit> listPatBenefits = Benefits.Refresh(listPatPlans, listInsSubs); if (listPatBenefits.IsNullOrEmpty()) { gridRemainTimeUnits.EndUpdate(); return; } List <InsPlan> listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList()); List <Carrier> listCarriers = Carriers.GetCarriers(listInsPlans.Select(x => x.CarrierNum).ToList()); //Get the LIM information for all potential subscribers. List <Patient> listSubscribers = Patients.GetLimForPats(listInsSubs.Select(x => x.Subscriber).ToList()); GridRow gridRow; //Get the last year of completed procedures because there is no current TimePeriod for benefits that will care about older procedures. //A subset of these procedures will be used for each specific benefit in order to correctly represent the time units remaining. List <Procedure> listCompletedProcs = Procedures.GetCompletedForDateRange( DateTime.Today.AddYears(-1), DateTimeOD.Today, listPatNums: new List <long> { _patCur.PatNum }); //Get all of the claimprocs associated to the completed procedures in order to link procedures to insurance plans. List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listCompletedProcs.Select(x => x.ProcNum).ToList()); foreach (Benefit benefit in listPatBenefits) { if (benefit.CovCatNum == 0 || //no category benefit.BenefitType != InsBenefitType.Limitations || //benefit type is not limitations (benefit.TimePeriod != BenefitTimePeriod.CalendarYear && //neither calendar year, serviceyear, or 12 months benefit.TimePeriod != BenefitTimePeriod.ServiceYear && benefit.TimePeriod != BenefitTimePeriod.NumberInLast12Months) || benefit.Quantity < 0 || //quantity is negative (negatives are allowed in FormBenefitEdit) benefit.QuantityQualifier != BenefitQuantity.NumberOfServices || //qualifier us not the number of services (benefit.CoverageLevel != BenefitCoverageLevel.Family && //neither individual nor family coverage level benefit.CoverageLevel != BenefitCoverageLevel.Individual)) { continue; } List <Procedure> listProcs; //for calendar year, get completed procs from January.01.CurYear ~ Curdate if (benefit.TimePeriod == BenefitTimePeriod.CalendarYear) { //01/01/CurYear. is there a better way? listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, 1, 1)); } else if (benefit.TimePeriod == BenefitTimePeriod.NumberInLast12Months) { //today - 12 months - 1 day. Procedures exactly 1 year ago are not counted in the range listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= DateTimeOD.Today.AddYears(-1).AddDays(1)); } else //if not calendar year, then it must be service year { int monthRenew = InsPlans.RefreshOne(benefit.PlanNum).MonthRenew; //monthrenew only stores the month as an int. if (DateTimeOD.Today.Month >= monthRenew) //if the the current date is past the renewal month, use the current year { listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, monthRenew, 1)); } else //otherwise use the previous year { listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1)); } } Dictionary <long, List <ClaimProc> > dictClaimProcsPerSub; if (benefit.PatPlanNum != 0) { //The list of benefits that we are looping through was filled via listPatPlans so this will never fail. //If this line fails then it means that there was a valid PlanNum AND a valid PatPlanNum set on the benefit which is invalid ATM. dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.InsSubNum == listPatPlans.First(y => y.PatPlanNum == benefit.PatPlanNum).InsSubNum) .GroupBy(x => x.InsSubNum) .ToDictionary(x => x.Key, x => x.ToList()); } else //benefit.PatPlanNum was not set so benefit.PlanNum must be set. { dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.PlanNum == benefit.PlanNum) .GroupBy(x => x.InsSubNum) .ToDictionary(x => x.Key, x => x.ToList()); } foreach (long insSubNum in dictClaimProcsPerSub.Keys) { //The insSubNum should have a corresponding entry within listInsSubs. InsSub insSub = listInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNum); if (insSub == null) { continue; //If not found then there are claimprocs associated to an inssub that is associated to a dropped or missing plan. } InsPlan insPlan = listInsPlans.FirstOrDefault(x => x.PlanNum == insSub.PlanNum); Carrier carrier = listCarriers.FirstOrDefault(x => x.CarrierNum == insPlan.CarrierNum); Patient subscriber = listSubscribers.FirstOrDefault(x => x.PatNum == insSub.Subscriber); CovCat category = CovCats.GetCovCat(benefit.CovCatNum); //Filter out any procedures that are not associated to the insurance plan of the current benefit. List <Procedure> listFilterProcs = listProcs.FindAll(x => x.ProcNum.In(dictClaimProcsPerSub[insSubNum].Select(y => y.ProcNum))); //Calculate the amount used for one benefit. double amtUsed = CovCats.GetAmtUsedForCat(listFilterProcs, category); double amtRemain = benefit.Quantity - amtUsed; gridRow = new GridRow((carrier == null) ? "Unknown" : carrier.CarrierName, (subscriber == null) ? "Unknown" : subscriber.GetNameFL(), category.Description.ToString(), benefit.Quantity.ToString(), amtUsed.ToString("F"), (amtRemain > 0) ? amtRemain.ToString("F") : "0"); gridRemainTimeUnits.ListGridRows.Add(gridRow); } } gridRemainTimeUnits.EndUpdate(); }
private void FillGrid() { gridRemainTimeUnits.BeginUpdate(); gridRemainTimeUnits.Rows.Clear(); List <Benefit> listPatBenefits = Benefits.Refresh(PatPlans.Refresh(_patCur.PatNum), InsSubs.GetListForSubscriber(_patCur.PatNum)); ODGridRow gridRow; List <Procedure> listProcs; double amtUsed; int monthRenew; if (listPatBenefits.Count > 0) { for (int i = 0; i < listPatBenefits.Count; i++) { if (listPatBenefits[i].CovCatNum == 0 || //no category listPatBenefits[i].BenefitType != InsBenefitType.Limitations || //benefit type is not limitations (listPatBenefits[i].TimePeriod != BenefitTimePeriod.CalendarYear && //neither calendar year nor serviceyear listPatBenefits[i].TimePeriod != BenefitTimePeriod.ServiceYear) || listPatBenefits[i].Quantity < 0 || //quantity is negative (negatives are allowed in FormBenefitEdit) listPatBenefits[i].QuantityQualifier != BenefitQuantity.NumberOfServices || //qualifier us not the number of services (listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Family && //neither individual nor family coverage level listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Individual)) { continue; } //for calendar year, get completed procs from January.01.CurYear ~ Curdate List <long> listPatNums = new List <long> { _patCur.PatNum }; //for current patient. if (listPatBenefits[i].TimePeriod == BenefitTimePeriod.CalendarYear) { //01/01/CurYear. is there a better way? listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, 1, 1), DateTimeOD.Today, null, listPatNums); } else //if not calendar year, then it must be service year { monthRenew = InsPlans.RefreshOne(listPatBenefits[i].PlanNum).MonthRenew; //monthrenew only stores the month as an int. if (DateTimeOD.Today.Month >= monthRenew) //if the the current date is past the renewal month, use the current year { listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, monthRenew, 1), DateTimeOD.Today, null, listPatNums); } else //otherwise use the previous year { listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1), DateTimeOD.Today, null, listPatNums); } } //Calculate the amount used for one benefit. amtUsed = GetAmtUsedForCat(listProcs, CovCats.GetCovCat(listPatBenefits[i].CovCatNum)); gridRow = new ODGridRow(); gridRow.Cells.Add(CovCats.GetCovCat(listPatBenefits[i].CovCatNum).EbenefitCat.ToString()); //Coverage Category gridRow.Cells.Add(listPatBenefits[i].Quantity.ToString()); //Quantity gridRow.Cells.Add(amtUsed.ToString("F")); //Used double amtRemain = listPatBenefits[i].Quantity - amtUsed; if (amtRemain > 0) { gridRow.Cells.Add(amtRemain.ToString("F")); //quantity-used. } else //if less then 0, just 0. { gridRow.Cells.Add("0"); } gridRemainTimeUnits.Rows.Add(gridRow); } } gridRemainTimeUnits.EndUpdate(); }