///<summary>Get pending insurance for a given plan for one benefit year. Include a ClaimProcList which is all claimProcs for the patient. Must supply all benefits for patient so that we know if it's a service year or a calendar year. asofDate used to determine which benefit year to calc. Usually the date of service for a claim. The insplan.PlanNum is the plan to get value for.</summary> public static double GetPending(ClaimProc[] ClaimProcList, DateTime asofDate, InsPlan curPlan, int patPlanNum, int excludeClaim, Benefit[] benList) { //InsPlan curPlan=GetPlan(planNum,PlanList); if (curPlan == null) { return(0); } //get the most recent renew date, possibly including today: DateTime renewDate = Benefits.GetRenewDate(benList, curPlan.PlanNum, patPlanNum, curPlan.DateEffective, asofDate); DateTime stopDate = renewDate.AddYears(1); double retVal = 0; for (int i = 0; i < ClaimProcList.Length; i++) { if (ClaimProcList[i].PlanNum == curPlan.PlanNum && ClaimProcList[i].ClaimNum != excludeClaim && ClaimProcList[i].ProcDate < stopDate && ClaimProcList[i].ProcDate >= renewDate //enum ClaimProcStatus{NotReceived,Received,Preauth,Adjustment,Supplemental} && ClaimProcList[i].Status == ClaimProcStatus.NotReceived) //Status Adjustment has no insPayEst, so can ignore it here. { retVal += ClaimProcList[i].InsPayEst; } } return(retVal); }
public void RefreshInsurance(Patient pat, List <InsPlan> listInsPlans, List <InsSub> listInsSubs, List <PatPlan> listPatPlans, List <Benefit> listBenefits) { textFamPriMax.Text = ""; textFamPriDed.Text = ""; textFamSecMax.Text = ""; textFamSecDed.Text = ""; if (pat == null) { return; } double maxFam = 0; double maxInd = 0; double dedFam = 0; InsPlan PlanCur; //=new InsPlan(); InsSub SubCur; if (listPatPlans.Count > 0) { SubCur = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); PlanCur = InsPlans.GetPlan(SubCur.PlanNum, listInsPlans); maxFam = Benefits.GetAnnualMaxDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[0].PatPlanNum, true); maxInd = Benefits.GetAnnualMaxDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[0].PatPlanNum, false); if (maxFam == -1) { textFamPriMax.Text = ""; } else { textFamPriMax.Text = maxFam.ToString("F"); } //deductible: dedFam = Benefits.GetDeductGeneralDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[0].PatPlanNum, BenefitCoverageLevel.Family); if (dedFam != -1) { textFamPriDed.Text = dedFam.ToString("F"); } } if (listPatPlans.Count > 1) { SubCur = InsSubs.GetSub(listPatPlans[1].InsSubNum, listInsSubs); PlanCur = InsPlans.GetPlan(SubCur.PlanNum, listInsPlans); //max=Benefits.GetAnnualMaxDisplay(listBenefits,PlanCur.PlanNum,listPatPlans[1].PatPlanNum); maxFam = Benefits.GetAnnualMaxDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[1].PatPlanNum, true); maxInd = Benefits.GetAnnualMaxDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[1].PatPlanNum, false); if (maxFam == -1) { textFamSecMax.Text = ""; } else { textFamSecMax.Text = maxFam.ToString("F"); } //deductible: dedFam = Benefits.GetDeductGeneralDisplay(listBenefits, PlanCur.PlanNum, listPatPlans[1].PatPlanNum, BenefitCoverageLevel.Family); if (dedFam != -1) { textFamSecDed.Text = dedFam.ToString("F"); } } }
private void butMerge_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length < 2) { MessageBox.Show(Lan.g(this, "Please select at least two items first.")); return; } InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length]; for (int i = 0; i < listSelected.Length; i++) { listSelected[i] = InsPlans.GetPlan(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null); listSelected[i].NumberSubscribers = PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["subscribers"].ToString()); } FormInsPlansMerge FormI = new FormInsPlansMerge(); FormI.ListAll = listSelected; FormI.ShowDialog(); if (FormI.DialogResult != DialogResult.OK) { return; } //Do the merge. InsPlan planToMergeTo = FormI.PlanToMergeTo.Copy(); //List<Benefit> benList=Benefits.RefreshForPlan(planToMergeTo,0); Cursor = Cursors.WaitCursor; for (int i = 0; i < listSelected.Length; i++) //loop through each selected plan //skip the planToMergeTo, because it's already correct { if (planToMergeTo.PlanNum == listSelected[i].PlanNum) { continue; } //==Michael - We are changing plans here, but not carriers, so this is not needed: //SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName InsPlans.ChangeReferences(listSelected[i].PlanNum, planToMergeTo.PlanNum); Benefits.DeleteForPlan(listSelected[i].PlanNum); InsPlans.Delete(listSelected[i].PlanNum); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} } FillGrid(); //highlight the merged plan for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < listSelected.Length; j++) { if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString()) { gridMain.SetSelected(i, true); } } } Cursor = Cursors.Default; }
///<summary>Used in FormInsPlan to sych database with changes user made to the benefit list for a plan. Must supply an old list for comparison. Only the differences are saved.</summary> public static void UpdateList(List <Benefit> oldBenefitList, List <Benefit> newBenefitList) { Benefit newBenefit; for (int i = 0; i < oldBenefitList.Count; i++) //loop through the old list { newBenefit = null; for (int j = 0; j < newBenefitList.Count; j++) { if (newBenefitList[j] == null || newBenefitList[j].BenefitNum == 0) { continue; } if (oldBenefitList[i].BenefitNum == newBenefitList[j].BenefitNum) { newBenefit = newBenefitList[j]; break; } } if (newBenefit == null) { //benefit with matching benefitNum was not found, so it must have been deleted Delete(oldBenefitList[i]); continue; } //benefit was found with matching benefitNum, so check for changes if (newBenefit.PlanNum != oldBenefitList[i].PlanNum || newBenefit.PatPlanNum != oldBenefitList[i].PatPlanNum || newBenefit.CovCatNum != oldBenefitList[i].CovCatNum //|| newBenefit.OldCode != oldBenefitList[i].OldCode || newBenefit.BenefitType != oldBenefitList[i].BenefitType || newBenefit.Percent != oldBenefitList[i].Percent || newBenefit.MonetaryAmt != oldBenefitList[i].MonetaryAmt || newBenefit.TimePeriod != oldBenefitList[i].TimePeriod || newBenefit.QuantityQualifier != oldBenefitList[i].QuantityQualifier || newBenefit.Quantity != oldBenefitList[i].Quantity || newBenefit.CodeNum != oldBenefitList[i].CodeNum || newBenefit.CoverageLevel != oldBenefitList[i].CoverageLevel) { Benefits.Update(newBenefit); } } for (int i = 0; i < newBenefitList.Count; i++) //loop through the new list { if (newBenefitList[i] == null) { continue; } if (((Benefit)newBenefitList[i]).BenefitNum != 0) { continue; } //benefit with benefitNum=0, so it's new Benefits.Insert((Benefit)newBenefitList[i]); } }
private void CreateFrequencyBenefit(ValidNumber textBox, ComboBox comboBox, string procCodeStr) { if (PIn.Byte(textBox.Text, false) == 0 || ProcedureCodes.GetCodeNum(procCodeStr) == 0) { return; } Benefit ben = Benefits.CreateFrequencyBenefit(ProcedureCodes.GetCodeNum(procCodeStr), PIn.Byte(textBox.Text), GetQuantityQualifier(comboBox), _planNum, GetTimePeriod(comboBox.SelectedIndex)); _listBenefitsAll.Add(ben); }
///<summary>Used once from Claims and also in ContrTreat. Gets insurance deductible remaining for one benefit year which includes the given date. Must supply all claimprocs for the patient. Must supply all benefits for patient so that we know if it's a service year or a calendar year. Date used to determine which benefit year to calc. Usually today's date. The insplan.PlanNum is the plan to get value for. ExcludeClaim is the ClaimNum to exclude, or enter -1 to include all. The supplied adaCode is needed because some deductibles, for instance, do not apply to preventive.</summary> public static double GetDedRem(ClaimProc[] ClaimProcList, DateTime date, int planNum, int patPlanNum, int excludeClaim, InsPlan[] PlanList, Benefit[] benList, string adaCode) { double dedTot = Benefits.GetDeductibleByCode(benList, planNum, patPlanNum, adaCode); double dedUsed = GetDedUsed(ClaimProcList, date, planNum, patPlanNum, excludeClaim, PlanList, benList); if (dedTot - dedUsed < 0) { return(0); } return(dedTot - dedUsed); }
/// <summary>Get insurance benefits used for one benefit year. Returns actual insurance used based on ClaimProc data. Must supply all claimprocs for the patient. Must supply all benefits for patient so that we know if it's a service year or a calendar year. asofDate is used to determine which benefit year to calc. Usually date of service for a claim. The insplan.PlanNum is the plan to get value for. ExcludeClaim is the ClaimNum to exclude, or enter -1 to include all.</summary> public static double GetInsUsed(ClaimProc[] ClaimProcList, DateTime asofDate, int planNum, int patPlanNum, int excludeClaim, InsPlan[] PlanList, Benefit[] benList) { InsPlan curPlan = GetPlan(planNum, PlanList); if (curPlan == null) { return(0); } //get the most recent renew date, possibly including today: DateTime renewDate = Benefits.GetRenewDate(benList, planNum, patPlanNum, curPlan.DateEffective, asofDate); //DateTime startDate;//for benefit year DateTime stopDate = renewDate.AddYears(1); /* * //if renew date is earlier this year or is today(assuming typical situation of date being today) * if(renewDate.Month <= date.Month && renewDate.Day <= date.Day) { * startDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year+1,renewDate.Month,renewDate.Day); * } * else {//otherwise, renew date must be late last year * startDate=new DateTime(date.Year-1,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * }*/ double retVal = 0; for (int i = 0; i < ClaimProcList.Length; i++) { if (ClaimProcList[i].PlanNum == planNum && ClaimProcList[i].ClaimNum != excludeClaim && ClaimProcList[i].ProcDate < stopDate && ClaimProcList[i].ProcDate >= renewDate //enum ClaimProcStatus{NotReceived,Received,Preauth,Adjustment,Supplemental} && ClaimProcList[i].Status != ClaimProcStatus.Preauth) { if (ClaimProcList[i].Status == ClaimProcStatus.Received || ClaimProcList[i].Status == ClaimProcStatus.Adjustment || ClaimProcList[i].Status == ClaimProcStatus.Supplemental) { retVal += ClaimProcList[i].InsPayAmt; } else //NotReceived //retVal-=ClaimProcList[i].InsPayEst; { } } } return(retVal); }
/// <summary>Only used once in Claims.cs. Gets insurance benefits remaining for one benefit year. Returns actual remaining insurance based on ClaimProc data, taking into account inspaid and ins pending. Must supply all claimprocs for the patient. Date used to determine which benefit year to calc. Usually today's date. The insplan.PlanNum is the plan to get value for. ExcludeClaim is the ClaimNum to exclude, or enter -1 to include all. This does not yet handle calculations where ortho max is different from regular max. Just takes the most general annual max, and subtracts all benefits used from all categories.</summary> public static double GetInsRem(ClaimProc[] ClaimProcList, DateTime date, int planNum, int patPlanNum, int excludeClaim, InsPlan[] PlanList, Benefit[] benList) { double insUsed = GetInsUsed(ClaimProcList, date, planNum, patPlanNum, excludeClaim, PlanList, benList); double insPending = GetPending(ClaimProcList, date, planNum, patPlanNum, excludeClaim, PlanList, benList); double annualMax = Benefits.GetAnnualMax(benList, planNum, patPlanNum); if (annualMax < 0) { return(999999); } if (annualMax - insUsed - insPending < 0) { return(0); } return(annualMax - insUsed - insPending); }
public void RefreshData(Patient pat, SheetField sheetField) { _listInsPlans = new List <InsPlan>(); _listInsSubs = new List <InsSub>(); _listPatPlans = new List <PatPlan>(); _listBenefits = new List <Benefit>(); _pat = pat; if (_pat == null) { return; } _listPatPlans = PatPlans.Refresh(_pat.PatNum); _listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(_pat.PatNum)); _listInsPlans = InsPlans.RefreshForSubList(_listInsSubs); _listBenefits = Benefits.Refresh(_listPatPlans, _listInsSubs); }
///<summary>Get pending insurance for a given plan for one benefit year. Include a ClaimProcList which is all claimProcs for the patient. Must supply all benefits for patient so that we know if it's a service year or a calendar year. asofDate used to determine which benefit year to calc. Usually the date of service for a claim. The insplan.PlanNum is the plan to get value for.</summary> public static double GetPending(ClaimProc[] ClaimProcList, DateTime asofDate, int planNum, int patPlanNum, int excludeClaim, InsPlan[] PlanList, Benefit[] benList) { InsPlan curPlan = GetPlan(planNum, PlanList); if (curPlan == null) { return(0); } //get the most recent renew date, possibly including today: //MessageBox.Show("mark1"); DateTime renewDate = Benefits.GetRenewDate(benList, planNum, patPlanNum, curPlan.DateEffective, asofDate); //MessageBox.Show("mark2"); //DateTime startDate;//for benefit year DateTime stopDate = renewDate.AddYears(1); //if renew date is earlier this year or is today(assuming typical situation of date being today) //Debug.WriteLine(renewDate.Month); //Debug.WriteLine(date.Month); //MessageBox.Show((renewDate.Month <= date.Month).ToString()); //MessageBox.Show((renewDate.Day <= date.Day).ToString()); /*if(renewDate.Month <= date.Month && renewDate.Day <= date.Day) { * startDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year+1,renewDate.Month,renewDate.Day); * } * else {//otherwise, renew date must be late last year * startDate=new DateTime(date.Year-1,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * }*/ double retVal = 0; for (int i = 0; i < ClaimProcList.Length; i++) { if (ClaimProcList[i].PlanNum == planNum && ClaimProcList[i].ClaimNum != excludeClaim && ClaimProcList[i].ProcDate < stopDate && ClaimProcList[i].ProcDate >= renewDate //enum ClaimProcStatus{NotReceived,Received,Preauth,Adjustment,Supplemental} && ClaimProcList[i].Status == ClaimProcStatus.NotReceived) //Status Adjustment has no insPayEst, so can ignore it here. { retVal += ClaimProcList[i].InsPayEst; } } return(retVal); }
///<summary>Deletes the patplan with the specified patPlanNum. Rearranges the other patplans for the patient to keep the ordinal sequence contiguous. Then, recomputes all estimates for this patient because their coverage is now different. Also sets patient.HasIns to the correct value.</summary> public static void Delete(int patPlanNum) { string command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum); DataTable table = General.GetTable(command); if (table.Rows.Count == 0) { return; } int patNum = PIn.PInt(table.Rows[0][0].ToString()); PatPlan[] patPlans = Refresh(patNum); bool doDecrement = false; for (int i = 0; i < patPlans.Length; i++) { if (doDecrement) //patPlan has already been deleted, so decrement the rest. { command = "UPDATE patplan SET Ordinal=" + POut.PInt(patPlans[i].Ordinal - 1) + " WHERE PatPlanNum=" + POut.PInt(patPlans[i].PatPlanNum); General.NonQ(command); continue; } if (patPlans[i].PatPlanNum == patPlanNum) { command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum); General.NonQ(command); command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.PInt(patPlanNum); General.NonQ(command); doDecrement = true; } } Family fam = Patients.GetFamily(patNum); Patient pat = fam.GetPatient(patNum); ClaimProc[] claimProcs = ClaimProcs.Refresh(patNum); Procedure[] procs = Procedures.Refresh(patNum); patPlans = PatPlans.Refresh(patNum); InsPlan[] planList = InsPlans.Refresh(fam); Benefit[] benList = Benefits.Refresh(patPlans); Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, planList, patPlans, benList); Patients.SetHasIns(patNum); }
///<summary>Used when closing the edit plan window to find all patients using this plan and to update all claimProcs for each patient. This keeps estimates correct.</summary> public static void ComputeEstimatesForPlan(int planNum) { string command = "SELECT PatNum FROM patplan WHERE PlanNum=" + POut.PInt(planNum); DataTable table = General.GetTable(command); int patNum = 0; for (int i = 0; i < table.Rows.Count; i++) { patNum = PIn.PInt(table.Rows[i][0].ToString()); Family fam = Patients.GetFamily(patNum); Patient pat = fam.GetPatient(patNum); ClaimProc[] claimProcs = ClaimProcs.Refresh(patNum); Procedure[] procs = Procedures.Refresh(patNum); InsPlan[] plans = InsPlans.Refresh(fam); PatPlan[] patPlans = PatPlans.Refresh(patNum); Benefit[] benefitList = Benefits.Refresh(patPlans); Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, plans, patPlans, benefitList); Patients.SetHasIns(patNum); } }
///<summary>Get insurance deductible used for one benefit year. Must supply all claimprocs for the patient. Must supply all benefits for patient so that we know if it's a service year or a calendar year. asofDate is used to determine which benefit year to calc. Usually date of service for a claim. The insplan.PlanNum is the plan to get value for. ExcludeClaim is the ClaimNum to exclude, or enter -1 to include all.</summary> public static double GetDedUsed(ClaimProc[] ClaimProcList, DateTime asofDate, int planNum, int patPlanNum, int excludeClaim, InsPlan[] PlanList, Benefit[] benList) { InsPlan curPlan = GetPlan(planNum, PlanList); if (curPlan == null) { return(0); } //get the most recent renew date, possibly including today. Date based on annual max. DateTime renewDate = Benefits.GetRenewDate(benList, planNum, patPlanNum, curPlan.DateEffective, asofDate); //DateTime startDate;//for benefit year DateTime stopDate = renewDate.AddYears(1); /*if(renewDate.Month <= date.Month && renewDate.Day <= date.Day) { * startDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year+1,renewDate.Month,renewDate.Day); * } * else {//otherwise, renew date must be late last year * startDate=new DateTime(date.Year-1,renewDate.Month,renewDate.Day); * stopDate=new DateTime(date.Year,renewDate.Month,renewDate.Day); * }*/ double retVal = 0; for (int i = 0; i < ClaimProcList.Length; i++) { if (ClaimProcList[i].PlanNum == planNum && ClaimProcList[i].ClaimNum != excludeClaim && ClaimProcList[i].ProcDate < stopDate && ClaimProcList[i].ProcDate >= renewDate //enum ClaimProcStatus{NotReceived,Received,Preauth,Adjustment,Supplemental} && (ClaimProcList[i].Status == ClaimProcStatus.Adjustment || ClaimProcList[i].Status == ClaimProcStatus.NotReceived || ClaimProcList[i].Status == ClaimProcStatus.Received || ClaimProcList[i].Status == ClaimProcStatus.Supplemental) ) { retVal += ClaimProcList[i].DedApplied; } } return(retVal); }
private void AddBenefits() { CreateFrequencyBenefit(textBW, comboBW, ProcedureCodes.BitewingCode); CreateFrequencyBenefit(textPano, comboPano, ProcedureCodes.PanoCode); if (PIn.Byte(textExams.Text, false) != 0) { Benefit ben = Benefits.CreateFrequencyBenefit(EbenefitCategory.RoutinePreventive, PIn.Byte(textExams.Text), GetQuantityQualifier(comboExams), _planNum, GetTimePeriod(comboExams.SelectedIndex)); _listBenefitsAll.Add(ben); } CreateFrequencyBenefit(textCancerScreenings, comboCancerScreenings, ProcedureCodes.CancerScreeningCode); CreateFrequencyBenefit(textProphy, comboProphy, ProcedureCodes.ProphyCode); CreateFrequencyBenefit(textFlouride, comboFlouride, ProcedureCodes.FlourideCode); CreateFrequencyBenefit(textSealants, comboSealants, ProcedureCodes.SealantCode); CreateFrequencyBenefit(textCrown, comboCrown, ProcedureCodes.CrownCode); CreateFrequencyBenefit(textSRP, comboSRP, ProcedureCodes.SRPCode); CreateFrequencyBenefit(textDebridement, comboDebridement, ProcedureCodes.FullDebridementCode); CreateFrequencyBenefit(textPerioMaint, comboPerioMaint, ProcedureCodes.PerioMaintCode); CreateFrequencyBenefit(textDentures, comboDentures, ProcedureCodes.DenturesCode); CreateFrequencyBenefit(textImplant, comboImplant, ProcedureCodes.ImplantCode); }
///<summary>Runs Procedures.ComputeEstimates for given proc and listClaimProcs. ///Does not update existing ClaimProcs or insert new ClaimProcs in the database. ///Outs new ClaimProcs added by Procedures.ComputeEstimates, listClaimProcs will contain any added claimProcs.</summary> private void RecomputeEstimates(Procedure proc, List <ClaimProc> listClaimProcs, out List <ClaimProc> listNewClaimProcs, OrthoProcLink orthoProcLink, OrthoCase orthoCase, OrthoSchedule orthoSchedule, List <OrthoProcLink> listOrthoProcLinksForOrthoCase) { List <ClaimProc> listOrigClaimProcs = new List <ClaimProc>(listClaimProcs); Patient pat = Patients.GetPat(proc.PatNum); List <PatPlan> listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum); List <InsSub> listInsSubs = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList()); List <InsPlan> listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList()); List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); //Same method used in FormProcEdit.Load()->GetLoadData() //FormProcEdit uses GetHistList(....,procDate:DateTimeOD.Today,...) List <ClaimProcHist> listHist = ClaimProcs.GetHistList(pat.PatNum, listBenefits, listPatPlans, listInsPlans, DateTimeOD.Today, listInsSubs); bool isSaveToDb = false; //When isSaveToDb is true any estimates that are missing will be inserted into DB and it refreshes listClaimProcs from the Db. //Refreshing the list results in losing the changes to ProvNum and ProcDate. Procedures.ComputeEstimates(proc, pat.PatNum, ref listClaimProcs, false, listInsPlans, listPatPlans, listBenefits, listHist, new List <ClaimProcHist> { }, isSaveToDb, pat.Age, listInsSubs , useProcDateOnProc: true, orthoProcLink: orthoProcLink, orthoCase: orthoCase, orthoSchedule: orthoSchedule, listOrthoProcLinksForOrthoCase: listOrthoProcLinksForOrthoCase); listNewClaimProcs = listClaimProcs.Except(listOrigClaimProcs).ToList(); }
private void butMerge_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.InsPlanMerge)) { return; } if (gridMain.SelectedIndices.Length < 2) { MessageBox.Show(Lan.g(this, "Please select at least two items first.")); return; } InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length]; for (int i = 0; i < listSelected.Length; i++) { listSelected[i] = InsPlans.GetPlan(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null); listSelected[i].NumberSubscribers = PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["subscribers"].ToString()); } FormInsPlansMerge FormI = new FormInsPlansMerge(); FormI.ListAll = listSelected; FormI.ShowDialog(); if (FormI.DialogResult != DialogResult.OK) { return; } //Do the merge. InsPlan planToMergeTo = FormI.PlanToMergeTo.Copy(); //List<Benefit> benList=Benefits.RefreshForPlan(planToMergeTo,0); Cursor = Cursors.WaitCursor; bool didMerge = false; List <long> listMergedPlanNums = new List <long>(); for (int i = 0; i < listSelected.Length; i++) //loop through each selected plan //skip the planToMergeTo, because it's already correct { if (planToMergeTo.PlanNum == listSelected[i].PlanNum) { continue; } //==Michael - We are changing plans here, but not carriers, so this is not needed: //SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName InsPlans.ChangeReferences(listSelected[i].PlanNum, planToMergeTo.PlanNum); Benefits.DeleteForPlan(listSelected[i].PlanNum); try { InsPlans.Delete(listSelected[i], canDeleteInsSub: false); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); SecurityLogs.MakeLogEntry(Permissions.InsPlanEdit, 0, Lan.g(this, "InsPlan Combine delete validation failed. Plan was not deleted."), listSelected[i].PlanNum, listSelected[i].SecDateTEdit); //new plan, no date needed. //Since we already deleted/changed all of the other dependencies, //we should continue in making the Securitylog entry and cleaning up. } didMerge = true; listMergedPlanNums.Add(listSelected[i].PlanNum); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} } if (didMerge) { string logText = Lan.g(this, "Merged the following PlanNum(s): ") + string.Join(", ", listMergedPlanNums) + " " + Lan.g(this, "into") + " " + planToMergeTo.PlanNum; SecurityLogs.MakeLogEntry(Permissions.InsPlanMerge, 0, logText); } FillGrid(); //highlight the merged plan for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < listSelected.Length; j++) { if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString()) { gridMain.SetSelected(i, true); } } } Cursor = Cursors.Default; }
///<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 FillFrequencies() { foreach (Benefit ben in _listBenefitsAll) { bool isFrequencyBen = true; //Diagnostic group if (Benefits.IsBitewingFrequency(ben)) { FillBenefit(ben, textBW, comboBW); } else if (Benefits.IsPanoFrequency(ben)) { FillBenefit(ben, textPano, comboPano); } else if (Benefits.IsExamFrequency(ben)) { FillBenefit(ben, textExams, comboExams); } else if (Benefits.IsCancerScreeningFrequency(ben)) { FillBenefit(ben, textCancerScreenings, comboCancerScreenings); } //Preventive group else if (Benefits.IsProphyFrequency(ben)) { FillBenefit(ben, textProphy, comboProphy); } else if (Benefits.IsFlourideFrequency(ben)) { FillBenefit(ben, textFlouride, comboFlouride); } else if (Benefits.IsSealantFrequency(ben)) { FillBenefit(ben, textSealants, comboSealants); } //Restorative group else if (Benefits.IsCrownFrequency(ben)) { FillBenefit(ben, textCrown, comboCrown); } //Periodontal group else if (Benefits.IsSRPFrequency(ben)) { FillBenefit(ben, textSRP, comboSRP); } else if (Benefits.IsFullDebridementFrequency(ben)) { FillBenefit(ben, textDebridement, comboDebridement); } else if (Benefits.IsPerioMaintFrequency(ben)) { FillBenefit(ben, textPerioMaint, comboPerioMaint); } //Prosthodontics group else if (Benefits.IsDenturesFrequency(ben)) { FillBenefit(ben, textDentures, comboDentures); } //Implants group else if (Benefits.IsImplantFrequency(ben)) { FillBenefit(ben, textImplant, comboImplant); } else { isFrequencyBen = false; } if (isFrequencyBen) { _listFrequencyBenefits.Add(ben); } } }
private void butOK_Click(object sender, System.EventArgs e) { RepeatCharge[] chargeList = RepeatCharges.Refresh(0); //Gets all repeating charges for all patients, they may be disabled int countAdded = 0; int claimsAdded = 0; DateTime startDate; Procedure proc; for (int i = 0; i < chargeList.Length; i++) { if (!chargeList[i].IsEnabled) //first make sure it is not disabled { continue; } if (chargeList[i].DateStart > DateTime.Today) //not started yet { continue; } //if(chargeList[i].DateStop.Year>1880//not blank // && chargeList[i].DateStop<DateTime.Today)//but already ended //{ // continue; //} //get a list dates of all completed procedures with this Code and patNum ArrayList ALdates = RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode), chargeList[i].PatNum); startDate = chargeList[i].DateStart; //This is the repeating date using the old methodology. It is necessary for checking if the repeating procedure was already added using the old methodology. DateTime possibleDateOld = startDate; //This is a more accurate repeating date which will allow procedures to be added on the 28th and later. DateTime possibleDateNew = startDate; int countMonths = 0; //start looping through possible dates, beginning with the start date of the repeating charge while (possibleDateNew <= DateTime.Today) { //Only allow back dating up to one month and 20 days. if (possibleDateNew < DateTime.Today.AddDays(-50)) { possibleDateOld = possibleDateOld.AddMonths(1); countMonths++; possibleDateNew = startDate.AddMonths(countMonths); continue; //don't go back more than one month and 20 days } //check to see if the possible date is present in the list if (ALdates.Contains(possibleDateNew) || ALdates.Contains(possibleDateOld)) { possibleDateOld = possibleDateOld.AddMonths(1); countMonths++; possibleDateNew = startDate.AddMonths(countMonths); continue; } if (chargeList[i].DateStop.Year > 1880 && //not blank chargeList[i].DateStop < possibleDateNew) //but already ended { break; } //otherwise, insert a procedure to db proc = new Procedure(); proc.CodeNum = ProcedureCodes.GetCodeNum(chargeList[i].ProcCode); proc.DateEntryC = DateTimeOD.Today; proc.PatNum = chargeList[i].PatNum; proc.ProcDate = possibleDateNew; proc.DateTP = possibleDateNew; proc.ProcFee = chargeList[i].ChargeAmt; proc.ProcStatus = ProcStat.C; proc.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv); proc.MedicalCode = ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode; proc.BaseUnits = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits; proc.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs); //Check if the repeating charge has been flagged to copy it's note into the billing note of the procedure. if (chargeList[i].CopyNoteToProc) { proc.BillingNote = chargeList[i].Note; } Procedures.Insert(proc); //no recall synch needed because dental offices don't use this feature countAdded++; possibleDateOld = possibleDateOld.AddMonths(1); countMonths++; possibleDateNew = startDate.AddMonths(countMonths); if (chargeList[i].CreatesClaim && !ProcedureCodes.GetProcCode(chargeList[i].ProcCode).NoBillIns) { List <PatPlan> patPlanList = PatPlans.Refresh(chargeList[i].PatNum); List <InsSub> subList = InsSubs.RefreshForFam(Patients.GetFamily(chargeList[i].PatNum)); List <InsPlan> insPlanList = InsPlans.RefreshForSubList(subList);; List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); Claim claimCur; List <Procedure> procCurList = new List <Procedure>(); procCurList.Add(proc); if (patPlanList.Count == 0) //no current insurance, do not create a claim { continue; } //create the claimprocs Procedures.ComputeEstimates(proc, proc.PatNum, new List <ClaimProc>(), true, insPlanList, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); //get claimprocs for this proc, may be more than one List <ClaimProc> claimProcList = ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum), proc.ProcNum); string claimType = "P"; if (patPlanList.Count == 1 && PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, insPlanList, subList) > 0) //if there's exactly one medical plan { claimType = "Med"; } claimCur = CreateClaim(claimType, patPlanList, insPlanList, claimProcList, proc, subList); claimProcList = ClaimProcs.Refresh(proc.PatNum); if (claimCur.ClaimNum == 0) { continue; } claimsAdded++; ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); if (PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, insPlanList, subList) > 0 && //if there exists a secondary plan !CultureInfo.CurrentCulture.Name.EndsWith("CA")) //and not canada (don't create secondary claim for canada) { claimCur = CreateClaim("S", patPlanList, insPlanList, claimProcList, proc, subList); if (claimCur.ClaimNum == 0) { continue; } claimsAdded++; claimProcList = ClaimProcs.Refresh(proc.PatNum); claimCur.ClaimStatus = "H"; ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList); } } } } //MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added.")); MessageBox.Show(countAdded.ToString() + " " + Lan.g(this, "procedures added.") + "\r\n" + claimsAdded.ToString() + " " + Lan.g(this, "claims added.")); DialogResult = DialogResult.OK; }
///<summary>All of the code from this method is copied directly from the account module, ContrAccount.FillSummary().</summary> private void FillSummary() { textFamPriMax.Text = ""; textFamPriDed.Text = ""; textFamSecMax.Text = ""; textFamSecDed.Text = ""; textPriMax.Text = ""; textPriDed.Text = ""; textPriDedRem.Text = ""; textPriUsed.Text = ""; textPriPend.Text = ""; textPriRem.Text = ""; textSecMax.Text = ""; textSecDed.Text = ""; textSecDedRem.Text = ""; textSecUsed.Text = ""; textSecPend.Text = ""; textSecRem.Text = ""; if (_patCur == null) { return; } double maxFam = 0; double maxInd = 0; double ded = 0; double dedFam = 0; double dedRem = 0; double remain = 0; double pend = 0; double used = 0; InsPlan PlanCur; InsSub SubCur; List <PatPlan> PatPlanList = PatPlans.Refresh(_patCur.PatNum); if (!PatPlans.IsPatPlanListValid(PatPlanList)) { //PatPlans had invalid references and need to be refreshed. PatPlanList = PatPlans.Refresh(_patCur.PatNum); } List <InsSub> subList = InsSubs.RefreshForFam(_famCur); List <InsPlan> InsPlanList = InsPlans.RefreshForSubList(subList); List <Benefit> BenefitList = Benefits.Refresh(PatPlanList, subList); List <Claim> ClaimList = Claims.Refresh(_patCur.PatNum); List <ClaimProcHist> HistList = ClaimProcs.GetHistList(_patCur.PatNum, BenefitList, PatPlanList, InsPlanList, DateTimeOD.Today, subList); if (PatPlanList.Count > 0) { SubCur = InsSubs.GetSub(PatPlanList[0].InsSubNum, subList); PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList); pend = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[0].PatPlanNum, -1, _patCur.PatNum, PatPlanList[0].InsSubNum, BenefitList); used = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[0].InsSubNum); textPriPend.Text = pend.ToString("F"); textPriUsed.Text = used.ToString("F"); maxFam = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, true); maxInd = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, false); if (maxFam == -1) { textFamPriMax.Text = ""; } else { textFamPriMax.Text = maxFam.ToString("F"); } if (maxInd == -1) //if annual max is blank { textPriMax.Text = ""; textPriRem.Text = ""; } else { remain = maxInd - used - pend; if (remain < 0) { remain = 0; } //textFamPriMax.Text=max.ToString("F"); textPriMax.Text = maxInd.ToString("F"); textPriRem.Text = remain.ToString("F"); } //deductible: ded = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Individual); dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Family); if (ded != -1) { textPriDed.Text = ded.ToString("F"); dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, -1, InsPlanList, _patCur.PatNum, ded, dedFam); textPriDedRem.Text = dedRem.ToString("F"); } if (dedFam != -1) { textFamPriDed.Text = dedFam.ToString("F"); } } if (PatPlanList.Count > 1) { SubCur = InsSubs.GetSub(PatPlanList[1].InsSubNum, subList); PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList); pend = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[1].PatPlanNum, -1, _patCur.PatNum, PatPlanList[1].InsSubNum, BenefitList); textSecPend.Text = pend.ToString("F"); used = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[1].InsSubNum); textSecUsed.Text = used.ToString("F"); //max=Benefits.GetAnnualMaxDisplay(BenefitList,PlanCur.PlanNum,PatPlanList[1].PatPlanNum); maxFam = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, true); maxInd = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, false); if (maxFam == -1) { textFamSecMax.Text = ""; } else { textFamSecMax.Text = maxFam.ToString("F"); } if (maxInd == -1) //if annual max is blank { textSecMax.Text = ""; textSecRem.Text = ""; } else { remain = maxInd - used - pend; if (remain < 0) { remain = 0; } //textFamSecMax.Text=max.ToString("F"); textSecMax.Text = maxInd.ToString("F"); textSecRem.Text = remain.ToString("F"); } //deductible: ded = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Individual); dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Family); if (ded != -1) { textSecDed.Text = ded.ToString("F"); dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, -1, InsPlanList, _patCur.PatNum, ded, dedFam); textSecDedRem.Text = dedRem.ToString("F"); } if (dedFam != -1) { textFamSecDed.Text = dedFam.ToString("F"); } } }
/* * ///<summary>Only used in GetSearchResults. All times between start and stop get set to true in provBarSched.</summary> * private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){ * int startI=GetProvBarIndex(timeStart); * int stopI=GetProvBarIndex(timeStop); * for(int i=startI;i<=stopI;i++){ * provBarSched[i]=true; * } * } * * private static int GetProvBarIndex(TimeSpan time) { * return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr +(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)) *(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr) * /ApptDrawing.LineH;//rounds down * }*/ ///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule. This method creates the appointment and attaches all appropriate procedures. It's up to the calling class to then place the appointment on the pinboard. If the appointment doesn't get scheduled, it's important to delete it. If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary> public static Appointment CreateRecallApt(Patient patCur, List <Procedure> procList, List <InsPlan> planList, long recallNum, List <InsSub> subList) { List <Recall> recallList = Recalls.GetList(patCur.PatNum); Recall recallCur = null; if (recallNum > 0) { recallCur = Recalls.GetRecall(recallNum); } else { for (int i = 0; i < recallList.Count; i++) { if (recallList[i].RecallTypeNum == RecallTypes.PerioType || recallList[i].RecallTypeNum == RecallTypes.ProphyType) { if (!recallList[i].IsDisabled) { recallCur = recallList[i]; } break; } } } if (recallCur == null) // || recallCur.DateDue.Year<1880){ { throw new ApplicationException(Lan.g("AppointmentL", "No recall is due.")); //should never happen because everyone has a recall. } if (recallCur.DateScheduled.Date >= DateTime.Now.Date) { throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString()); } Appointment AptCur = new Appointment(); AptCur.PatNum = patCur.PatNum; AptCur.AptStatus = ApptStatus.UnschedList; //In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared. if (patCur.PriProv == 0) { AptCur.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv); } else { AptCur.ProvNum = patCur.PriProv; } AptCur.ProvHyg = patCur.SecProv; if (AptCur.ProvHyg != 0) { AptCur.IsHygiene = true; } AptCur.ClinicNum = patCur.ClinicNum; //whether perio or prophy: List <string> procs = RecallTypes.GetProcs(recallCur.RecallTypeNum); string recallPattern = RecallTypes.GetTimePattern(recallCur.RecallTypeNum); if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum) && patCur.Birthdate.AddYears(12) > ((recallCur.DateDue > DateTime.Today)?recallCur.DateDue:DateTime.Today)) //if pt's 12th birthday falls after recall date. ie younger than 12. { for (int i = 0; i < RecallTypeC.Listt.Count; i++) { if (RecallTypeC.Listt[i].RecallTypeNum == RecallTypes.ChildProphyType) { List <string> childprocs = RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum); if (childprocs.Count > 0) { procs = childprocs; //overrides adult procs. } string childpattern = RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum); if (childpattern != "") { recallPattern = childpattern; //overrides adult pattern. } } } } //convert time pattern to 5 minute increment StringBuilder savePattern = new StringBuilder(); for (int i = 0; i < recallPattern.Length; i++) { savePattern.Append(recallPattern.Substring(i, 1)); if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 10) { savePattern.Append(recallPattern.Substring(i, 1)); } if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append(recallPattern.Substring(i, 1)); savePattern.Append(recallPattern.Substring(i, 1)); } } if (savePattern.ToString() == "") { if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append("///XXX///"); } else { savePattern.Append("//XX//"); } } AptCur.Pattern = savePattern.ToString(); //Add films------------------------------------------------------------------------------------------------------ if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)) //if this is a prophy or perio { for (int i = 0; i < recallList.Count; i++) { if (recallCur.RecallNum == recallList[i].RecallNum) { continue; //already handled. } if (recallList[i].IsDisabled) { continue; } if (recallList[i].DateDue.Year < 1880) { continue; } if (recallList[i].DateDue > recallCur.DateDue && //if film due date is after prophy due date recallList[i].DateDue > DateTime.Today) //and not overdue { continue; } //incomplete: exclude manual recall types procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum)); } } AptCur.ProcDescript = ""; for (int i = 0; i < procs.Count; i++) { if (i > 0) { AptCur.ProcDescript += ", "; } AptCur.ProcDescript += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc; } Appointments.Insert(AptCur); Procedure ProcCur; List <PatPlan> patPlanList = PatPlans.Refresh(patCur.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); InsPlan priplan = null; InsSub prisub = null; if (patPlanList.Count > 0) { prisub = InsSubs.GetSub(patPlanList[0].InsSubNum, subList); priplan = InsPlans.GetPlan(prisub.PlanNum, planList); } double insfee; double standardfee; for (int i = 0; i < procs.Count; i++) { ProcCur = new Procedure(); //this will be an insert //procnum ProcCur.PatNum = patCur.PatNum; ProcCur.AptNum = AptCur.AptNum; ProcCur.CodeNum = ProcedureCodes.GetCodeNum(procs[i]); ProcCur.ProcDate = DateTime.Now; ProcCur.DateTP = DateTime.Now; //Check if it's a medical procedure. bool isMed = false; ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode; if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") { isMed = true; } //Get fee schedule for medical or dental. long feeSch; if (isMed) { feeSch = Fees.GetMedFeeSched(patCur, planList, patPlanList, subList); } else { feeSch = Fees.GetFeeSched(patCur, planList, patPlanList, subList); } //Get the fee amount for medical or dental. if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) { insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch); } else { insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch); } if (priplan != null && priplan.PlanType == "p") //PPO { standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched); if (standardfee > insfee) { ProcCur.ProcFee = standardfee; } else { ProcCur.ProcFee = insfee; } } else { ProcCur.ProcFee = insfee; } //surf //toothnum //Procedures.Cur.ToothRange=""; //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns; //priority ProcCur.ProcStatus = ProcStat.TP; ProcCur.Note = ""; //Procedures.Cur.PriEstim= //Procedures.Cur.SecEstim= //claimnum ProcCur.ProvNum = patCur.PriProv; //Procedures.Cur.Dx= ProcCur.ClinicNum = patCur.ClinicNum; //nextaptnum ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits; Procedures.Insert(ProcCur); //no recall synch required Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new List <ClaimProc>(), false, planList, patPlanList, benefitList, patCur.Age, subList); if (Programs.UsingOrion) { FormProcEdit FormP = new FormProcEdit(ProcCur, patCur.Copy(), Patients.GetFamily(patCur.PatNum)); FormP.IsNew = true; FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { //Do not synch. Recalls based on ScheduleByDate reports in Orion mode. //Recalls.Synch(PatCur.PatNum); } } } return(AptCur); }
///<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 butAdd_Click(object sender, EventArgs e) { FormProcCodes FormP = new FormProcCodes(); FormP.IsSelectionMode = true; FormP.ShowDialog(); if (FormP.DialogResult != DialogResult.OK) { return; } Procedure ProcCur; ProcCur = new Procedure(); //going to be an insert, so no need to set Procedures.CurOld ProcCur.CodeNum = FormP.SelectedCodeNum; //procnum ProcCur.PatNum = AptCur.PatNum; //aptnum //proccode //ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set ProcCur.ProcDate = DateTime.Today; ProcCur.DateTP = ProcCur.ProcDate; //int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty; Family fam = Patients.GetFamily(AptCur.PatNum); Patient pat = fam.GetPatient(AptCur.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum); ProcedureCode procCodeCur = ProcedureCodes.GetProcCode(ProcCur.CodeNum); ProcCur.MedicalCode = procCodeCur.MedicalCode; if (procCodeCur.IsHygiene && pat.SecProv != 0) { ProcCur.ProvNum = pat.SecProv; } else { ProcCur.ProvNum = pat.PriProv; } ProcCur.ClinicNum = pat.ClinicNum; ProcCur.ProcFee = Procedures.GetProcFee(pat, patPlanList, subList, planList, ProcCur.CodeNum, ProcCur.ProvNum, ProcCur.ClinicNum, ProcCur.MedicalCode); //surf //ToothNum //Procedures.Cur.ToothRange //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ProcCode).NoBillIns; ProcCur.Priority = 0; ProcCur.ProcStatus = ProcStat.TP; ProcCur.Note = ""; //dx //nextaptnum ProcCur.DateEntryC = DateTime.Now; ProcCur.BaseUnits = procCodeCur.BaseUnits; ProcCur.SiteNum = pat.SiteNum; ProcCur.RevCode = procCodeCur.RevenueCodeDefault; ProcCur.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs); ProcCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. if (Userods.IsUserCpoe(Security.CurUser)) { //This procedure is considered CPOE because the provider is the one that has added it. ProcCur.IsCpoe = true; } Procedures.Insert(ProcCur); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); Procedures.ComputeEstimates(ProcCur, pat.PatNum, new List <ClaimProc>(), true, planList, patPlanList, benefitList, pat.Age, subList); FormProcEdit FormPE = new FormProcEdit(ProcCur, pat.Copy(), fam); FormPE.IsNew = true; FormPE.ShowDialog(); if (FormPE.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (Programs.UsingOrion) { //No need to synch with Orion mode. } else { //Default is set to TP, so Synch is usually not needed. if (ProcCur.ProcStatus == ProcStat.C || ProcCur.ProcStatus == ProcStat.EC || ProcCur.ProcStatus == ProcStat.EO) { Recalls.Synch(pat.PatNum); } } FillGrid(); }
///<summary>Sets given appt.AptStatus to broken. ///Provide procCode that should be charted, can be null but will not chart a broken procedure. ///Also considers various broken procedure based prefs. ///Makes its own securitylog entries.</summary> public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode) { //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed. DateTime datePrevious = appt.DateTStamp; bool suppressHistory = false; if (procCode != null) { suppressHistory = (procCode.ProcCode.In("D9986", "D9987")); } Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods if (appt.AptStatus != ApptStatus.Complete) //seperate log entry for completed appointments. { SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } else { SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } #region HL7 //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if (HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt); //Will be null if there is no outbound SIU message defined, so do nothing if (messageHL7 != null) { HL7Msg hl7Msg = new HL7Msg(); hl7Msg.AptNum = appt.AptNum; hl7Msg.HL7Status = HL7MessageStatus.OutPending; //it will be marked outSent by the HL7 service. hl7Msg.MsgText = messageHL7.ToString(); hl7Msg.PatNum = pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show("Appointments", messageHL7.ToString()); #endif } } #endregion #region Charting the proc if (procCode != null) { switch (procCode.ProcCode) { case "D9986": //Missed HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed); break; case "D9987": //Cancelled HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled); break; } Procedure procedureCur = new Procedure(); procedureCur.PatNum = pat.PatNum; procedureCur.ProvNum = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum); procedureCur.CodeNum = procCode.CodeNum; procedureCur.ProcDate = DateTime.Today; procedureCur.DateEntryC = DateTime.Now; procedureCur.ProcStatus = ProcStat.C; procedureCur.ClinicNum = appt.ClinicNum; procedureCur.UserNum = Security.CurUser.UserNum; procedureCur.Note = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); procedureCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. List <InsSub> listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan insPlanPrimary = null; InsSub insSubPrimary = null; if (listPatPlans.Count > 0) { insSubPrimary = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans); } double procFee; long feeSch; if (insPlanPrimary == null || procCode.NoBillIns) { feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, procedureCur.ProvNum); } else //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns { feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, procedureCur.ProvNum); } procFee = Fees.GetAmount0(procedureCur.CodeNum, feeSch, procedureCur.ClinicNum, procedureCur.ProvNum); if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical) //PPO { double provFee = Fees.GetAmount0(procedureCur.CodeNum, Providers.GetProv(procedureCur.ProvNum).FeeSched, procedureCur.ClinicNum, procedureCur.ProvNum); procedureCur.ProcFee = Math.Max(provFee, procFee); } else { procedureCur.ProcFee = procFee; } if (!PrefC.GetBool(PrefName.EasyHidePublicHealth)) { procedureCur.SiteNum = pat.SiteNum; } Procedures.Insert(procedureCur); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(procedureCur.ProcNum); Procedures.ComputeEstimates(procedureCur, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs); FormProcBroken FormPB = new FormProcBroken(procedureCur); FormPB.IsNew = true; FormPB.ShowDialog(); } #endregion #region BrokenApptAdjustment if (PrefC.GetBool(PrefName.BrokenApptAdjustment)) { Adjustment AdjustmentCur = new Adjustment(); AdjustmentCur.DateEntry = DateTime.Today; AdjustmentCur.AdjDate = DateTime.Today; AdjustmentCur.ProcDate = DateTime.Today; AdjustmentCur.ProvNum = appt.ProvNum; AdjustmentCur.PatNum = pat.PatNum; AdjustmentCur.AdjType = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum = appt.ClinicNum; FormAdjust FormA = new FormAdjust(pat, AdjustmentCur); FormA.IsNew = true; FormA.ShowDialog(); } #endregion #region BrokenApptCommLog if (PrefC.GetBool(PrefName.BrokenApptCommLog)) { Commlog CommlogCur = new Commlog(); CommlogCur.PatNum = pat.PatNum; CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); CommlogCur.Mode_ = CommItemMode.None; CommlogCur.UserNum = Security.CurUser.UserNum; FormCommItem FormCI = new FormCommItem(); FormCI.ShowDialog(new CommItemModel() { CommlogCur = CommlogCur }, new CommItemController(FormCI) { IsNew = true }); } #endregion AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum); Recalls.SynchScheduledApptFull(appt.PatNum); }
///<summary>Calculates the Base estimate for a procedure. This is not done on the fly. Use Procedure.GetEst to later retrieve the estimate. This function duplicates/replaces all of the upper estimating logic that is within FormClaimProc. BaseEst=((fee or allowedAmt)-Copay) x (percentage or percentOverride). The result is now stored in a claimProc. The claimProcs do get updated frequently depending on certain actions the user takes. The calling class must have already created the claimProc, and this function simply updates the BaseEst field of that claimproc. pst.Tot not used. For Estimate and CapEstimate, all the estimate fields will be recalculated except the three overrides.</summary> public static void ComputeBaseEst(ClaimProc cp, Procedure proc, PriSecTot pst, InsPlan[] PlanList, PatPlan[] patPlans, Benefit[] benList) //,bool resetValues){ { if (cp.Status == ClaimProcStatus.CapClaim || cp.Status == ClaimProcStatus.CapComplete || cp.Status == ClaimProcStatus.Preauth || cp.Status == ClaimProcStatus.Supplemental) { return; //never compute estimates for those types listed above. } bool resetAll = false; if (cp.Status == ClaimProcStatus.Estimate || cp.Status == ClaimProcStatus.CapEstimate) { resetAll = true; } //NoBillIns is only calculated when creating the claimproc, even if resetAll is true. //If user then changes a procCode, it does not cause an update of all procedures with that ADACode. if (cp.NoBillIns) { cp.AllowedAmt = -1; cp.CopayAmt = 0; cp.CopayOverride = -1; cp.DedApplied = 0; cp.Percentage = -1; cp.PercentOverride = -1; cp.WriteOff = 0; cp.BaseEst = 0; return; } //This function is called every time a ProcFee is changed, //so the BaseEst does reflect the new ProcFee. cp.BaseEst = proc.ProcFee; //if(resetAll){ //AllowedAmt=-1; //actually, this is a bad place for altering AllowedAmt. //Best to set it at the same time as the fee. //} if (cp.AllowedAmt == -1) //If allowedAmt is blank, try to find an allowed amount. { cp.AllowedAmt = InsPlans.GetAllowed(proc.ADACode, cp.PlanNum, PlanList); //later add posterior composite functionality. Needs to go here because the substitute fee changes. } if (cp.AllowedAmt != -1) { cp.BaseEst = cp.AllowedAmt; } //dedApplied is never recalculated here //deductible is initially 0 anyway, so this calculation works. //Once there is a deductible included, this calculation would come out different, which is also ok. if (cp.DedBeforePerc) { cp.BaseEst -= cp.DedApplied; } //copayAmt //copayOverride never recalculated InsPlan plan = null; if (pst == PriSecTot.Pri) { plan = InsPlans.GetPlan(patPlans[0].PlanNum, PlanList); } else if (pst == PriSecTot.Sec) { plan = InsPlans.GetPlan(patPlans[1].PlanNum, PlanList); } if (resetAll) { if (pst == PriSecTot.Pri) { cp.CopayAmt = InsPlans.GetCopay(proc.ADACode, plan); } else if (pst == PriSecTot.Sec) { cp.CopayAmt = InsPlans.GetCopay(proc.ADACode, plan); } else //pst.Other { cp.CopayAmt = -1; } if (cp.Status == ClaimProcStatus.CapEstimate) { //this does automate the Writeoff. If user does not want writeoff automated, //then they will have to complete the procedure first. (very rare) if (cp.CopayAmt == -1) { cp.CopayAmt = 0; } if (cp.CopayOverride != -1) //override the copay { cp.WriteOff = proc.ProcFee - cp.CopayOverride; } else if (cp.CopayAmt != -1) //use the calculated copay { cp.WriteOff = proc.ProcFee - cp.CopayAmt; } //else{//no copay at all // WriteOff=proc.ProcFee; //} if (cp.WriteOff < 0) { cp.WriteOff = 0; } cp.AllowedAmt = -1; cp.DedApplied = 0; cp.Percentage = -1; cp.PercentOverride = -1; cp.BaseEst = 0; return; } } if (cp.CopayOverride != -1) //subtract copay if override { cp.BaseEst -= cp.CopayOverride; } else if (cp.CopayAmt != -1) //otherwise subtract calculated copay { cp.BaseEst -= cp.CopayAmt; } //percentage //percentoverride never recalculated if (pst == PriSecTot.Pri) { cp.Percentage = Benefits.GetPercent(proc.ADACode, plan, patPlans[0], benList); //will never =-1 } else if (pst == PriSecTot.Sec) { cp.Percentage = Benefits.GetPercent(proc.ADACode, plan, patPlans[1], benList); } if (cp.PercentOverride == -1) //no override, so use calculated Percentage { cp.BaseEst = cp.BaseEst * (double)cp.Percentage / 100; } else //override, so use PercentOverride { cp.BaseEst = cp.BaseEst * (double)cp.PercentOverride / 100; } }
///<summary>Sets given appt.AptStatus to broken. ///Provide procCode that should be charted, can be null but will not chart a broken procedure. ///Also considers various broken procedure based prefs. ///Makes its own securitylog entries.</summary> public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode) { //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed. DateTime datePrevious = appt.DateTStamp; bool suppressHistory = false; if (procCode != null) { suppressHistory = (procCode.ProcCode.In("D9986", "D9987")); } Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods if (appt.AptStatus != ApptStatus.Complete) //seperate log entry for completed appointments. { SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } else { SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } #region HL7 //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if (HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt); //Will be null if there is no outbound SIU message defined, so do nothing if (messageHL7 != null) { HL7Msg hl7Msg = new HL7Msg(); hl7Msg.AptNum = appt.AptNum; hl7Msg.HL7Status = HL7MessageStatus.OutPending; //it will be marked outSent by the HL7 service. hl7Msg.MsgText = messageHL7.ToString(); hl7Msg.PatNum = pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show("Appointments", messageHL7.ToString()); #endif } } #endregion List <Procedure> listProcedures = new List <Procedure>(); //splits should only exist on procs if they are using tp pre-payments List <PaySplit> listSplitsForApptProcs = new List <PaySplit>(); bool isNonRefundable = false; double brokenProcAmount = 0; Procedure brokenProcedure = new Procedure(); bool wasBrokenProcDeleted = false; if (PrefC.GetYN(PrefName.PrePayAllowedForTpProcs)) { listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false); if (listProcedures.Count > 0) { listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList()); } } #region Charting the proc if (procCode != null) { switch (procCode.ProcCode) { case "D9986": //Missed HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed); break; case "D9987": //Cancelled HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled); break; } brokenProcedure.PatNum = pat.PatNum; brokenProcedure.ProvNum = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum); brokenProcedure.CodeNum = procCode.CodeNum; brokenProcedure.ProcDate = DateTime.Today; brokenProcedure.DateEntryC = DateTime.Now; brokenProcedure.ProcStatus = ProcStat.C; brokenProcedure.ClinicNum = appt.ClinicNum; brokenProcedure.UserNum = Security.CurUser.UserNum; brokenProcedure.Note = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. List <InsSub> listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan insPlanPrimary = null; InsSub insSubPrimary = null; if (listPatPlans.Count > 0) { insSubPrimary = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans); } double procFee; long feeSch; if (insPlanPrimary == null || procCode.NoBillIns) { feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum); } else //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns { feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum); } procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical) //PPO { double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); brokenProcedure.ProcFee = Math.Max(provFee, procFee); } else if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986") { //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user. brokenProcedure.ProcFee = listSplitsForApptProcs.Sum(x => x.SplitAmt); isNonRefundable = true; } else { brokenProcedure.ProcFee = procFee; } if (!PrefC.GetBool(PrefName.EasyHidePublicHealth)) { brokenProcedure.SiteNum = pat.SiteNum; } Procedures.Insert(brokenProcedure); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum); Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs); FormProcBroken FormPB = new FormProcBroken(brokenProcedure, isNonRefundable); FormPB.IsNew = true; FormPB.ShowDialog(); brokenProcAmount = FormPB.AmountTotal; wasBrokenProcDeleted = FormPB.IsProcDeleted; } #endregion #region BrokenApptAdjustment if (PrefC.GetBool(PrefName.BrokenApptAdjustment)) { Adjustment AdjustmentCur = new Adjustment(); AdjustmentCur.DateEntry = DateTime.Today; AdjustmentCur.AdjDate = DateTime.Today; AdjustmentCur.ProcDate = DateTime.Today; AdjustmentCur.ProvNum = appt.ProvNum; AdjustmentCur.PatNum = pat.PatNum; AdjustmentCur.AdjType = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum = appt.ClinicNum; FormAdjust FormA = new FormAdjust(pat, AdjustmentCur); FormA.IsNew = true; FormA.ShowDialog(); } #endregion #region BrokenApptCommLog if (PrefC.GetBool(PrefName.BrokenApptCommLog)) { Commlog commlogCur = new Commlog(); commlogCur.PatNum = pat.PatNum; commlogCur.CommDateTime = DateTime.Now; commlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); commlogCur.Note = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); commlogCur.Mode_ = CommItemMode.None; commlogCur.UserNum = Security.CurUser.UserNum; commlogCur.IsNew = true; FormCommItem FormCI = new FormCommItem(commlogCur); FormCI.ShowDialog(); } #endregion #region Transfer money from TP Procedures if necessary //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure. if (isNonRefundable && !wasBrokenProcDeleted && listSplitsForApptProcs.Count > 0) { //transfer what the user specified in the broken appointment window. //transfer up to the amount specified by the user foreach (Procedure proc in listProcedures) { if (brokenProcAmount == 0) { break; } List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum); foreach (PaySplit split in listSplitsForAppointmentProcedure) { if (brokenProcAmount == 0) { break; } double amt = Math.Min(brokenProcAmount, split.SplitAmt); Payments.CreateTransferForTpProcs(proc, new List <PaySplit> { split }, brokenProcedure, amt); double amtPaidOnApt = listSplitsForApptProcs.Sum(x => x.SplitAmt); if (amtPaidOnApt > amt) { //If the original prepayment amount is greater than the amt being specified for the appointment break, transfer //the difference to an Unallocated Unearned Paysplit on the account. double remainingAmt = amtPaidOnApt - amt; //We have to create a new transfer payment here to correlate to the split. Payment txfrPayment = new Payment(); txfrPayment.PayAmt = 0; txfrPayment.PayDate = DateTime.Today; txfrPayment.ClinicNum = split.ClinicNum; txfrPayment.PayNote = "Automatic transfer from treatment planned procedure prepayment."; txfrPayment.PatNum = split.PatNum; //ultimately where the payment ends up. txfrPayment.PayType = 0; Payments.Insert(txfrPayment); PaymentEdit.IncomeTransferData transferData = PaymentEdit.IncomeTransferData.CreateTransfer(split, txfrPayment.PayNum, true, remainingAmt); PaySplit offset = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum != 0); long offsetSplitNum = PaySplits.Insert(offset); //Get the FSplitNum from the offset PaySplit allocation = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum == 0); allocation.FSplitNum = offsetSplitNum; PaySplits.Insert(allocation); //Insert so the split is now up to date SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, txfrPayment.PatNum, "Automatic transfer of funds for treatment plan procedure pre-payments."); } brokenProcAmount -= amt; } } } //if broken appointment procedure was deleted (user cancelled out of the window) just keep money on the original procedure. #endregion AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt); AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum); Recalls.SynchScheduledApptFull(appt.PatNum); }
private void butAdd_Click(object sender, EventArgs e) { FormProcCodes FormP = new FormProcCodes(); FormP.IsSelectionMode = true; FormP.ShowDialog(); if (FormP.DialogResult != DialogResult.OK) { return; } Procedure ProcCur; ProcCur = new Procedure(); //going to be an insert, so no need to set Procedures.CurOld ProcCur.CodeNum = FormP.SelectedCodeNum; //procnum ProcCur.PatNum = AptCur.PatNum; //aptnum //proccode //ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set ProcCur.ProcDate = DateTime.Today; ProcCur.DateTP = ProcCur.ProcDate; //int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty; InsPlan priplan = null; InsSub prisub = null; Family fam = Patients.GetFamily(AptCur.PatNum); Patient pat = fam.GetPatient(AptCur.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum); if (patPlanList.Count > 0) { prisub = InsSubs.GetSub(patPlanList[0].InsSubNum, subList); priplan = InsPlans.GetPlan(prisub.PlanNum, planList); } //Check if it's a medical procedure. double insfee; bool isMed = false; ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode; if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") { isMed = true; } //Get fee schedule for medical or dental. long feeSch; if (isMed) { feeSch = Fees.GetMedFeeSched(pat, planList, patPlanList, subList); } else { feeSch = Fees.GetFeeSched(pat, planList, patPlanList, subList); } //Get the fee amount for medical or dental. if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) { insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch); } else { insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch); } if (priplan != null && priplan.PlanType == "p") //PPO { double standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(pat)).FeeSched); if (standardfee > insfee) { ProcCur.ProcFee = standardfee; } else { ProcCur.ProcFee = insfee; } } else { ProcCur.ProcFee = insfee; } //surf //ToothNum //Procedures.Cur.ToothRange //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ProcCode).NoBillIns; ProcCur.Priority = 0; ProcCur.ProcStatus = ProcStat.TP; if (ProcedureCodes.GetProcCode(ProcCur.CodeNum).IsHygiene && pat.SecProv != 0) { ProcCur.ProvNum = pat.SecProv; } else { ProcCur.ProvNum = pat.PriProv; } ProcCur.Note = ""; ProcCur.ClinicNum = pat.ClinicNum; //dx //nextaptnum ProcCur.DateEntryC = DateTime.Now; ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits; ProcCur.SiteNum = pat.SiteNum; ProcCur.RevCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).RevenueCodeDefault; ProcCur.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs); Procedures.Insert(ProcCur); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); Procedures.ComputeEstimates(ProcCur, pat.PatNum, new List <ClaimProc>(), true, planList, patPlanList, benefitList, pat.Age, subList); FormProcEdit FormPE = new FormProcEdit(ProcCur, pat.Copy(), fam); FormPE.IsNew = true; FormPE.ShowDialog(); if (FormPE.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (Programs.UsingOrion) { //No need to synch with Orion mode. } else { //Default is set to TP, so Synch is usually not needed. if (ProcCur.ProcStatus == ProcStat.C || ProcCur.ProcStatus == ProcStat.EC || ProcCur.ProcStatus == ProcStat.EO) { Recalls.Synch(pat.PatNum); } } FillGrid(); }
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(); }
public void RefreshInsurance(Patient pat, List <InsPlan> listInsPlans, List <InsSub> listInsSubs, List <PatPlan> listPatPlans, List <Benefit> listBenefits, List <ClaimProcHist> histList) { textPriMax.Text = ""; textPriDed.Text = ""; textPriDedRem.Text = ""; textPriUsed.Text = ""; textPriPend.Text = ""; textPriRem.Text = ""; textSecMax.Text = ""; textSecDed.Text = ""; textSecDedRem.Text = ""; textSecUsed.Text = ""; textSecPend.Text = ""; textSecRem.Text = ""; if (pat == null) { return; } double maxInd = 0; double ded = 0; double dedFam = 0; double dedRem = 0; double remain = 0; double pend = 0; double used = 0; InsPlan isnPlanCur; //=new InsPlan(); InsSub subCur; if (listPatPlans.Count > 0) { subCur = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); isnPlanCur = InsPlans.GetPlan(subCur.PlanNum, listInsPlans); pend = InsPlans.GetPendingDisplay(histList, DateTime.Today, isnPlanCur, listPatPlans[0].PatPlanNum, -1, pat.PatNum, listPatPlans[0].InsSubNum, listBenefits); used = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, isnPlanCur.PlanNum, listPatPlans[0].PatPlanNum, -1, listInsPlans, listBenefits, pat.PatNum, listPatPlans[0].InsSubNum); textPriPend.Text = pend.ToString("F"); textPriUsed.Text = used.ToString("F"); maxInd = Benefits.GetAnnualMaxDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[0].PatPlanNum, false); if (maxInd == -1) //if annual max is blank { textPriMax.Text = ""; textPriRem.Text = ""; } else { remain = maxInd - used - pend; if (remain < 0) { remain = 0; } //textFamPriMax.Text=max.ToString("F"); textPriMax.Text = maxInd.ToString("F"); textPriRem.Text = remain.ToString("F"); } //deductible: ded = Benefits.GetDeductGeneralDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[0].PatPlanNum, BenefitCoverageLevel.Individual); dedFam = Benefits.GetDeductGeneralDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[0].PatPlanNum, BenefitCoverageLevel.Family); if (ded != -1) { textPriDed.Text = ded.ToString("F"); dedRem = InsPlans.GetDedRemainDisplay(histList, DateTime.Today, isnPlanCur.PlanNum, listPatPlans[0].PatPlanNum, -1, listInsPlans, pat.PatNum, ded, dedFam); textPriDedRem.Text = dedRem.ToString("F"); } } if (listPatPlans.Count > 1) { subCur = InsSubs.GetSub(listPatPlans[1].InsSubNum, listInsSubs); isnPlanCur = InsPlans.GetPlan(subCur.PlanNum, listInsPlans); pend = InsPlans.GetPendingDisplay(histList, DateTime.Today, isnPlanCur, listPatPlans[1].PatPlanNum, -1, pat.PatNum, listPatPlans[1].InsSubNum, listBenefits); textSecPend.Text = pend.ToString("F"); used = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, isnPlanCur.PlanNum, listPatPlans[1].PatPlanNum, -1, listInsPlans, listBenefits, pat.PatNum, listPatPlans[1].InsSubNum); textSecUsed.Text = used.ToString("F"); maxInd = Benefits.GetAnnualMaxDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[1].PatPlanNum, false); if (maxInd == -1) //if annual max is blank { textSecMax.Text = ""; textSecRem.Text = ""; } else { remain = maxInd - used - pend; if (remain < 0) { remain = 0; } //textFamSecMax.Text=max.ToString("F"); textSecMax.Text = maxInd.ToString("F"); textSecRem.Text = remain.ToString("F"); } //deductible: ded = Benefits.GetDeductGeneralDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[1].PatPlanNum, BenefitCoverageLevel.Individual); dedFam = Benefits.GetDeductGeneralDisplay(listBenefits, isnPlanCur.PlanNum, listPatPlans[1].PatPlanNum, BenefitCoverageLevel.Family); if (ded != -1) { textSecDed.Text = ded.ToString("F"); dedRem = InsPlans.GetDedRemainDisplay(histList, DateTime.Today, isnPlanCur.PlanNum, listPatPlans[1].PatPlanNum, -1, listInsPlans, pat.PatNum, ded, dedFam); textSecDedRem.Text = dedRem.ToString("F"); } } }
private void butGenerateClaims_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Count() < 1) { MsgBox.Show(this, "Please select the rows for which you would like to create procedures and claims."); return; } if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure you want to generate claims and procedures for all patients and insurance plans?")) { return; } List <long> listPlanNums = new List <long>(); List <long> listPatPlanNums = new List <long>(); List <long> listInsSubNums = new List <long>(); for (int i = 0; i < gridMain.SelectedIndices.Count(); i++) { DataRow rowCur = (DataRow)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; listPlanNums.Add(PIn.Long(rowCur["PlanNum"].ToString())); listPatPlanNums.Add(PIn.Long(rowCur["PatPlanNum"].ToString())); listInsSubNums.Add(PIn.Long(rowCur["InsSubNum"].ToString())); } List <InsPlan> listSelectedInsPlans = InsPlans.GetPlans(listPlanNums); List <PatPlan> listSelectedPatPlans = PatPlans.GetPatPlans(listPatPlanNums); List <InsSub> listSelectedInsSubs = InsSubs.GetMany(listInsSubNums); List <DataRow> rowsSucceeded = new List <DataRow>(); int rowsFailed = 0; List <Benefit> listBenefitsAll = Benefits.Refresh(listSelectedPatPlans, listSelectedInsSubs); for (int i = 0; i < gridMain.SelectedIndices.Count(); i++) { try { DataRow rowCur = (DataRow)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; long patNumCur = PIn.Long(rowCur["PatNum"].ToString()); Patient patCur = Patients.GetPat(patNumCur); PatientNote patNoteCur = PatientNotes.Refresh(patNumCur, patCur.Guarantor); long codeNumCur = PIn.Long(rowCur["AutoCodeNum"].ToString()); long provNumCur = PIn.Long(rowCur["ProvNum"].ToString()); long clinicNumCur = PIn.Long(rowCur["ClinicNum"].ToString()); long insPlanNumCur = PIn.Long(rowCur["PlanNum"].ToString()); long patPlanNumCur = PIn.Long(rowCur["PatPlanNum"].ToString()); long insSubNumCur = PIn.Long(rowCur["InsSubNum"].ToString()); int monthsTreat = PIn.Int(rowCur["MonthsTreat"].ToString()); DateTime dateDue = PIn.Date(rowCur["OrthoAutoNextClaimDate"].ToString()); //for each selected row //create a procedure //Procedures.CreateProcForPat(patNumCur,codeNumCur,"","",ProcStat.C,provNumCur); Procedure proc = Procedures.CreateOrthoAutoProcsForPat(patNumCur, codeNumCur, provNumCur, clinicNumCur, dateDue); InsPlan insPlanCur = InsPlans.GetPlan(insPlanNumCur, listSelectedInsPlans); PatPlan patPlanCur = listSelectedPatPlans.FirstOrDefault(x => x.PatPlanNum == patPlanNumCur); InsSub insSubCur = listSelectedInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNumCur); List <Benefit> benefitList = listBenefitsAll.FindAll(x => x.PatPlanNum == patPlanCur.PatPlanNum || x.PlanNum == insSubCur.PlanNum); //create a claimproc List <ClaimProc> listClaimProcs = new List <ClaimProc>(); Procedures.ComputeEstimates(proc, patNumCur, ref listClaimProcs, true, new List <InsPlan> { insPlanCur }, new List <PatPlan> { patPlanCur }, benefitList, null, null, true, patCur.Age, new List <InsSub> { insSubCur }, isForOrtho: true); //make the feebilled == the insplan feebilled or patplan feebilled double feebilled = patPlanCur.OrthoAutoFeeBilledOverride == -1 ? insPlanCur.OrthoAutoFeeBilled : patPlanCur.OrthoAutoFeeBilledOverride; //create a claim with that claimproc string claimType = ""; switch (patPlanCur.Ordinal) { case 1: claimType = "P"; break; case 2: claimType = "S"; break; } DateTimeOD dateTMonthsRem = new DateTimeOD(PIn.Date(rowCur["DateBanding"].ToString()).AddMonths(PIn.Int(rowCur["MonthsTreat"].ToString())), DateTimeOD.Today); Claims.CreateClaimForOrthoProc(claimType, patPlanCur, insPlanCur, insSubCur, ClaimProcs.GetForProcWithOrdinal(proc.ProcNum, patPlanCur.Ordinal), proc, feebilled, PIn.Date(rowCur["DateBanding"].ToString()), PIn.Int(rowCur["MonthsTreat"].ToString()), ((dateTMonthsRem.YearsDiff * 12) + dateTMonthsRem.MonthsDiff)); PatPlans.IncrementOrthoNextClaimDates(patPlanCur, insPlanCur, monthsTreat, patNoteCur); rowsSucceeded.Add(rowCur); SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate, patCur.PatNum , Lan.g(this, "Automatic ortho procedure and claim generated for") + " " + dateDue.ToShortDateString()); } catch (Exception) { rowsFailed++; } } string message = Lan.g(this, "Done.") + " " + Lan.g(this, "There were") + " " + rowsSucceeded.Count + " " + Lan.g(this, "claim(s) generated and") + " " + rowsFailed + " " + Lan.g(this, "failures") + "."; MessageBox.Show(message); foreach (DataRow row in rowsSucceeded) { _tableOutstandingAutoClaims.Rows.Remove(row); } FillGrid(); }