Ejemplo n.º 1
0
        ///<summary>Gets the data necessary to load FormProcEdit.</summary>
        public static LoadData GetLoadData(Procedure proc, Patient pat, Family fam)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), proc, pat, fam));
            }
            LoadData data = new LoadData();

            data.ListPatPlans = PatPlans.Refresh(pat.PatNum);
            if (!PatPlans.IsPatPlanListValid(data.ListPatPlans))             //PatPlans had invalid references and need to be refreshed.
            {
                data.ListPatPlans = PatPlans.Refresh(pat.PatNum);
            }
            data.ListInsSubs           = InsSubs.RefreshForFam(fam);
            data.ListInsPlans          = InsPlans.RefreshForSubList(data.ListInsSubs);
            data.ListClaims            = Claims.Refresh(pat.PatNum);
            data.ListClaimProcsForProc = ClaimProcs.RefreshForProc(proc.ProcNum);
            data.ListBenefits          = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs);
            data.ListRefAttaches       = RefAttaches.RefreshFiltered(proc.PatNum, false, proc.ProcNum);
            data.ArrPaySplits          = PaySplits.Refresh(proc.PatNum);
            List <long> listPayNums = data.ArrPaySplits.Where(x => x.ProcNum == proc.ProcNum).Select(x => x.PayNum).ToList();

            data.ListPaymentsForProc = Payments.GetPayments(listPayNums);
            data.ArrAdjustments      = Adjustments.Refresh(proc.PatNum);
            data.OrthoProcedureLink  = OrthoProcLinks.GetByProcNum(proc.ProcNum);
            return(data);
        }
Ejemplo n.º 2
0
        ///<summary>Gets a good chunk of the data used in the TP Module.</summary>
        public static TPModuleData GetModuleData(long patNum, bool doMakeSecLog)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)           //Remoting role check here to reduce round-trips to the server.
            {
                return(Meth.GetObject <TPModuleData>(MethodBase.GetCurrentMethod(), patNum, doMakeSecLog));
            }
            TPModuleData tpData = new TPModuleData();

            tpData.Fam         = Patients.GetFamily(patNum);
            tpData.Pat         = tpData.Fam.GetPatient(patNum);
            tpData.PatPlanList = PatPlans.Refresh(patNum);
            if (!PatPlans.IsPatPlanListValid(tpData.PatPlanList))
            {
                //PatPlans had invalid references and need to be refreshed.
                tpData.PatPlanList = PatPlans.Refresh(patNum);
            }
            tpData.SubList     = InsSubs.RefreshForFam(tpData.Fam);
            tpData.InsPlanList = InsPlans.RefreshForSubList(tpData.SubList);
            tpData.BenefitList = Benefits.Refresh(tpData.PatPlanList, tpData.SubList);
            tpData.ClaimList   = Claims.Refresh(tpData.Pat.PatNum);
            tpData.HistList    = ClaimProcs.GetHistList(tpData.Pat.PatNum, tpData.BenefitList, tpData.PatPlanList, tpData.InsPlanList, DateTime.Today,
                                                        tpData.SubList);
            tpData.ListSubstLinks = SubstitutionLinks.GetAllForPlans(tpData.InsPlanList);
            TreatPlanType tpTypeCur = (tpData.Pat.DiscountPlanNum == 0?TreatPlanType.Insurance:TreatPlanType.Discount);

            TreatPlans.AuditPlans(patNum, tpTypeCur);
            tpData.ListProcedures = Procedures.Refresh(patNum);
            tpData.ListTreatPlans = TreatPlans.GetAllForPat(patNum);
            tpData.ArrProcTPs     = ProcTPs.Refresh(patNum);
            if (doMakeSecLog)
            {
                SecurityLogs.MakeLogEntry(Permissions.TPModule, patNum, "");
            }
            return(tpData);
        }
Ejemplo n.º 3
0
        ///<summary>Gets most of the data necessary to fill the static text fields.</summary>
        public static StaticTextData GetStaticTextData(Patient pat, Family fam, List <long> listProcCodeNums)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <StaticTextData>(MethodBase.GetCurrentMethod(), pat, fam, listProcCodeNums));
            }
            StaticTextData data = new StaticTextData();

            data.PatNote               = PatientNotes.Refresh(pat.PatNum, pat.Guarantor);
            data.ListRefAttaches       = RefAttaches.Refresh(pat.PatNum);
            data.ListSubs              = InsSubs.RefreshForFam(fam);
            data.ListPlans             = InsPlans.RefreshForSubList(data.ListSubs);
            data.ListPatPlans          = PatPlans.Refresh(pat.PatNum);
            data.ListBenefits          = Benefits.Refresh(data.ListPatPlans, data.ListSubs);
            data.HistList              = ClaimProcs.GetHistList(pat.PatNum, data.ListBenefits, data.ListPatPlans, data.ListPlans, DateTime.Today, data.ListSubs);
            data.ListTreatPlans        = TreatPlans.Refresh(pat.PatNum);
            data.ListRecallsForFam     = Recalls.GetList(fam.ListPats.Select(x => x.PatNum).ToList());
            data.ListAppts             = Appointments.GetListForPat(pat.PatNum);
            data.ListFutureApptsForFam = Appointments.GetFutureSchedApts(fam.ListPats.Select(x => x.PatNum).ToList());
            data.ListDiseases          = Diseases.Refresh(pat.PatNum, true);
            data.ListAllergies         = Allergies.GetAll(pat.PatNum, false);
            data.ListMedicationPats    = MedicationPats.Refresh(pat.PatNum, false);
            data.ListFamPopups         = Popups.GetForFamily(pat);
            data.ListProceduresSome    = Procedures.RefreshForProcCodeNums(pat.PatNum, listProcCodeNums);
            return(data);
        }
Ejemplo n.º 4
0
        ///<summary>Gets the data necesary to load FormApptEdit.</summary>
        public static LoadData GetLoadData(Appointment AptCur, bool IsNew)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), AptCur, IsNew));
            }
            LoadData data = new LoadData();

            data.ListProcsForAppt = Procedures.GetProcsForApptEdit(AptCur);
            data.ListAppointments = Appointments.GetAppointmentsForProcs(data.ListProcsForAppt);
            data.Family           = Patients.GetFamily(AptCur.PatNum);
            data.ListPatPlans     = PatPlans.Refresh(AptCur.PatNum);
            data.ListInsSubs      = InsSubs.RefreshForFam(data.Family);
            data.ListBenefits     = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs);
            data.ListInsPlans     = InsPlans.RefreshForSubList(data.ListInsSubs);
            data.TableApptFields  = Appointments.GetApptFields(AptCur.AptNum);
            data.TableComms       = Appointments.GetCommTable(AptCur.PatNum.ToString(), AptCur.AptNum);
            data.Lab          = (IsNew ? null : LabCases.GetForApt(AptCur));
            data.PatientTable = Appointments.GetPatTable(AptCur.PatNum.ToString());
            if (!PrefC.GetBool(PrefName.EasyHideDentalSchools))
            {
                data.ListStudents = ReqStudents.GetForAppt(AptCur.AptNum);
            }
            return(data);
        }
Ejemplo n.º 5
0
        ///<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(long patPlanNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNum);
                return;
            }
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            long           patNum      = PIn.Long(table.Rows[0][0].ToString());
            List <PatPlan> patPlans    = PatPlans.Refresh(patNum);
            bool           doDecrement = false;

            for (int i = 0; i < patPlans.Count; i++)
            {
                if (doDecrement)                 //patPlan has already been deleted, so decrement the rest.
                {
                    command = "UPDATE patplan SET Ordinal=" + POut.Long(patPlans[i].Ordinal - 1)
                              + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum);
                    Db.NonQ(command);
                    continue;
                }
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    RemoveAssignedUser(patPlans[i]);
                    command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    doDecrement = true;
                    InsVerifies.DeleteByFKey(patPlanNum, VerifyTypes.PatientEnrollment);
                }
            }
            Family           fam                = Patients.GetFamily(patNum);
            Patient          pat                = fam.GetPatient(patNum);
            List <ClaimProc> claimProcs         = ClaimProcs.Refresh(patNum);
            List <ClaimProc> listClaimProcsEsts = claimProcs.Where(x => x.Status.In(ClaimProcStatus.Estimate, ClaimProcStatus.CapEstimate)).ToList();
            List <Procedure> procs              = Procedures.Refresh(patNum);

            patPlans = PatPlans.Refresh(patNum);
            List <InsSub>  subList  = InsSubs.RefreshForFam(fam);
            List <InsPlan> planList = InsPlans.RefreshForSubList(subList);
            List <Benefit> benList  = Benefits.Refresh(patPlans, subList);

            Procedures.ComputeEstimatesForAll(patNum, listClaimProcsEsts, procs, planList, patPlans, benList, pat.Age, subList, claimProcs);
            Patients.SetHasIns(patNum);
//Cameron_ Possibly create outbound ADT message to update insurance info
        }
Ejemplo n.º 6
0
        ///<summary>Do not call this until after determining if the repeate charge might generate a claim.  This function checks current insurance and
        ///may not add claims if no insurance is found.</summary>
        private static List <Claim> AddClaimsHelper(RepeatCharge repeateCharge, Procedure proc)
        {
            //No remoting role check; no call to db
            List <PatPlan> patPlanList = PatPlans.Refresh(repeateCharge.PatNum);
            List <InsSub>  subList     = InsSubs.RefreshForFam(Patients.GetFamily(repeateCharge.PatNum));
            List <InsPlan> insPlanList = InsPlans.RefreshForSubList(subList);
            List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList);
            List <Claim>   retVal      = new List <Claim>();
            Claim          claimCur;

            if (patPlanList.Count == 0)           //no current insurance, do not create a claim
            {
                return(retVal);
            }
            //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      = Claims.CreateClaimForRepeatCharge(claimType, patPlanList, insPlanList, claimProcList, proc, subList);
            claimProcList = ClaimProcs.Refresh(proc.PatNum);
            if (claimCur.ClaimNum == 0)
            {
                return(retVal);
            }
            retVal.Add(claimCur);
            Claims.CalculateAndUpdate(new List <Procedure> {
                proc
            }, 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 = Claims.CreateClaimForRepeatCharge("S", patPlanList, insPlanList, claimProcList, proc, subList);
                if (claimCur.ClaimNum == 0)
                {
                    return(retVal);
                }
                retVal.Add(claimCur);
                ClaimProcs.Refresh(proc.PatNum);
                claimCur.ClaimStatus = "H";
                Claims.CalculateAndUpdate(new List <Procedure> {
                    proc
                }, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
            }
            return(retVal);
        }
Ejemplo n.º 7
0
        ///<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(long patPlanNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNum);
                return;
            }
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            long           patNum      = PIn.Long(table.Rows[0][0].ToString());
            List <PatPlan> patPlans    = PatPlans.Refresh(patNum);
            bool           doDecrement = false;

            for (int i = 0; i < patPlans.Count; i++)
            {
                if (doDecrement)                 //patPlan has already been deleted, so decrement the rest.
                {
                    command = "UPDATE patplan SET Ordinal=" + POut.Long(patPlans[i].Ordinal - 1)
                              + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum);
                    Db.NonQ(command);
                    continue;
                }
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    doDecrement = true;
                }
            }
            Family           fam        = Patients.GetFamily(patNum);
            Patient          pat        = fam.GetPatient(patNum);
            List <ClaimProc> claimProcs = ClaimProcs.Refresh(patNum);
            List <Procedure> procs      = Procedures.Refresh(patNum);

            patPlans = PatPlans.Refresh(patNum);
            List <InsSub>  subList  = InsSubs.RefreshForFam(fam);
            List <InsPlan> planList = InsPlans.RefreshForSubList(subList);
            List <Benefit> benList  = Benefits.Refresh(patPlans, subList);

            Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, planList, patPlans, benList, pat.Age, subList);
            Patients.SetHasIns(patNum);
        }
Ejemplo n.º 8
0
        ///<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(long patPlanNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNum);
                return;
            }
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            long           patNum      = PIn.Long(table.Rows[0][0].ToString());
            List <PatPlan> patPlans    = PatPlans.Refresh(patNum);
            bool           doDecrement = false;

            for (int i = 0; i < patPlans.Count; i++)
            {
                if (doDecrement)                 //patPlan has already been deleted, so decrement the rest.
                {
                    command = "UPDATE patplan SET Ordinal=" + POut.Long(patPlans[i].Ordinal - 1)
                              + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum);
                    Db.NonQ(command);
                    continue;
                }
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    RemoveAssignedUser(patPlans[i]);
                    command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlanNum);
                    Db.NonQ(command);
                    doDecrement = true;
                    InsVerifies.DeleteByFKey(patPlanNum, VerifyTypes.PatientEnrollment);
                }
            }
            InsPlans.ComputeEstimatesForPatNums(new List <long> {
                patNum
            });
//Cameron_ Possibly create outbound ADT message to update insurance info
        }
Ejemplo n.º 9
0
        public static LoadData GetLoadData(Patient pat, Family fam, Claim claim)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), pat, fam, claim));
            }
            LoadData data = new LoadData();

            data.ListPatPlans            = PatPlans.Refresh(pat.PatNum);
            data.ListInsSubs             = InsSubs.RefreshForFam(fam);
            data.ListInsPlans            = InsPlans.RefreshForSubList(data.ListInsSubs);
            data.ListClaimProcs          = ClaimProcs.Refresh(pat.PatNum);
            data.ListProcs               = Procedures.Refresh(pat.PatNum);
            data.ListClaimValCodes       = ClaimValCodeLogs.GetForClaim(claim.ClaimNum);
            data.ClaimCondCodeLogCur     = ClaimCondCodeLogs.GetByClaimNum(claim.ClaimNum);
            data.TablePayments           = ClaimPayments.GetForClaim(claim.ClaimNum);
            data.TablePayments.TableName = "ClaimPayments";
            data.ListToothInitials       = ToothInitials.Refresh(pat.PatNum);
            data.ListCustomStatusEntries = ClaimTrackings.RefreshForClaim(ClaimTrackingType.StatusHistory, claim.ClaimNum);
            return(data);
        }
Ejemplo n.º 10
0
        ///<summary>Returns the number of subscribers moved.
        ///No need to pass in userNum, it's set before remoting role check and passed to the server if necessary.</summary>
        public static long MoveSubscribers(long insPlanNumFrom, long insPlanNumTo, long userNum = 0)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod(), insPlanNumFrom, insPlanNumTo, userNum));
            }
            List <InsSub> listInsSubsFrom    = GetListForPlanNum(insPlanNumFrom);
            List <long>   listBlockedPatNums = new List <long>();

            //Perform the same validation as when the user manually drops insplans from FormInsPlan using the Drop button.
            for (int i = 0; i < listInsSubsFrom.Count; i++)
            {
                InsSub         insSubFrom      = listInsSubsFrom[i];
                List <PatPlan> listPatPlanFrom = PatPlans.Refresh(insSubFrom.Subscriber);
                for (int j = 0; j < listPatPlanFrom.Count; j++)
                {
                    PatPlan patPlanFrom = listPatPlanFrom[j];
                    //The following comments and logic are copied from the FormInsPlan Drop button...
                    //If they have a claim for this ins with today's date, don't let them drop.
                    //We already have code in place to delete claimprocs when we drop ins, but the claimprocs attached to claims are protected.
                    //The claim clearly needs to be deleted if they are dropping.  We need the user to delete the claim before they drop the plan.
                    //We also have code in place to add new claimprocs when they add the correct insurance.
                    List <Claim> listClaims = Claims.Refresh(patPlanFrom.PatNum);                 //Get all claims for patient.
                    for (int k = 0; k < listClaims.Count; k++)
                    {
                        if (listClaims[k].PlanNum != insPlanNumFrom)                       //Make sure the claim is for the insurance plan we are about to change, not any other plans the patient might have.
                        {
                            continue;
                        }
                        if (listClaims[k].DateService != DateTime.Today)                       //not today
                        {
                            continue;
                        }
                        //Patient currently has a claim for the insplan they are trying to drop.
                        if (!listBlockedPatNums.Contains(patPlanFrom.PatNum))
                        {
                            listBlockedPatNums.Add(patPlanFrom.PatNum);
                        }
                    }
                }
            }
            if (listBlockedPatNums.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < listBlockedPatNums.Count; i++)
                {
                    sb.Append("\r\n");
                    Patient pat = Patients.GetPat(listBlockedPatNums[i]);
                    sb.Append("#" + listBlockedPatNums[i] + " " + pat.GetNameFLFormal());
                }
                throw new ApplicationException(Lans.g("InsSubs", "Before changing the subscribers on the insurance plan being moved from, please delete all of today's claims related to the insurance plan being moved from for the following patients") + ":" + sb.ToString());
            }
            //This loop mimics some of the logic in PatPlans.Delete().
            int insSubMovedCount = 0;

            for (int i = 0; i < listInsSubsFrom.Count; i++)
            {
                InsSub inssub       = listInsSubsFrom[i];
                long   oldInsSubNum = inssub.InsSubNum;
                inssub.InsSubNum       = 0;        //This will allow us to insert a new record.
                inssub.PlanNum         = insPlanNumTo;
                inssub.DateEffective   = DateTime.MinValue;
                inssub.BenefitNotes    = "";
                inssub.SubscNote       = "";
                inssub.SecUserNumEntry = userNum;
                long      insSubNumNew       = InsSubs.Insert(inssub);
                string    command            = "SELECT PatNum FROM patplan WHERE InsSubNum=" + POut.Long(oldInsSubNum);
                DataTable tablePatsForInsSub = Db.GetTable(command);
                if (tablePatsForInsSub.Rows.Count == 0)
                {
                    continue;
                }
                insSubMovedCount++;
                for (int j = 0; j < tablePatsForInsSub.Rows.Count; j++)
                {
                    long           patNum       = PIn.Long(tablePatsForInsSub.Rows[j]["PatNum"].ToString());
                    List <PatPlan> listPatPlans = PatPlans.Refresh(patNum);
                    for (int k = 0; k < listPatPlans.Count; k++)
                    {
                        PatPlan patPlan = listPatPlans[k];
                        if (patPlan.InsSubNum == oldInsSubNum)
                        {
                            command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlan.PatPlanNum);                         //Delete patient specific benefits (rare).
                            Db.NonQ(command);
                            patPlan.InsSubNum = insSubNumNew;
                            PatPlans.Update(patPlan);
                        }
                    }
                    //Now that the plan has changed for the current subscriber, recalculate estimates.
                    bool prefChanged = false;
                    //Forcefully set pref false to prevent creating new estimates for all procs (including completed, sent procs)
                    if (Prefs.UpdateBool(PrefName.ClaimProcsAllowedToBackdate, false))
                    {
                        prefChanged = true;                      //We will turn the preference back on for the user after we finish our computations.
                    }
                    Family           fam            = Patients.GetFamily(patNum);
                    Patient          pat            = fam.GetPatient(patNum);
                    List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(patNum);
                    List <Procedure> listProcs      = Procedures.Refresh(patNum);
                    listPatPlans = PatPlans.Refresh(patNum);
                    List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(fam);
                    List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs);
                    List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs);
                    Procedures.ComputeEstimatesForAll(patNum, listClaimProcs, listProcs, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                    if (prefChanged)
                    {
                        Prefs.UpdateBool(PrefName.ClaimProcsAllowedToBackdate, true);                       //set back to original value if changed.
                    }
                }
            }
            InsPlan insPlanFrom = InsPlans.RefreshOne(insPlanNumFrom);
            InsPlan planOld     = insPlanFrom.Copy();

            insPlanFrom.IsHidden = true;
            InsPlans.Update(insPlanFrom, planOld);
            return(insSubMovedCount);
        }
Ejemplo n.º 11
0
        ///<summary>Gets the data necessary to load the Family Module.</summary>
        public static LoadData GetLoadData(long patNum, bool doCreateSecLog)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), patNum, doCreateSecLog));
            }
            LoadData data = new LoadData();

            data.Fam          = Patients.GetFamily(patNum);
            data.Pat          = data.Fam.GetPatient(patNum);
            data.ListPatPlans = PatPlans.Refresh(patNum);
            if (!PatPlans.IsPatPlanListValid(data.ListPatPlans))             //PatPlans had invalid references and need to be refreshed.
            {
                data.ListPatPlans = PatPlans.Refresh(patNum);
            }
            data.PatNote               = PatientNotes.Refresh(patNum, data.Pat.Guarantor);
            data.ListInsSubs           = InsSubs.RefreshForFam(data.Fam);
            data.ListInsPlans          = InsPlans.RefreshForSubList(data.ListInsSubs);
            data.ListBenefits          = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs);
            data.ListRecalls           = Recalls.GetList(data.Fam.ListPats.Select(x => x.PatNum).ToList());
            data.ArrPatFields          = PatFields.Refresh(patNum);
            data.SuperFamilyMembers    = Patients.GetBySuperFamily(data.Pat.SuperFamily);
            data.SuperFamilyGuarantors = Patients.GetSuperFamilyGuarantors(data.Pat.SuperFamily);
            data.DictCloneSpecialities = Patients.GetClonesAndSpecialties(patNum);
            data.PatPict               = Documents.GetPatPictFromDb(patNum);
            data.HasPatPict            = (data.PatPict == null ? YN.No : YN.Yes);
            List <DisplayField> listDisplayFields = DisplayFields.GetForCategory(DisplayFieldCategory.PatientInformation);

            foreach (DisplayField field in listDisplayFields)
            {
                switch (field.InternalName)
                {
                case "Guardians":
                    data.ListGuardians = Guardians.Refresh(patNum);
                    break;

                case "Pat Restrictions":
                    data.ListPatRestricts = PatRestrictions.GetAllForPat(patNum);
                    break;

                case "Payor Types":
                    data.PayorTypeDesc = PayorTypes.GetCurrentDescription(patNum);
                    break;

                case "PatFields":
                    data.ListPatFieldDefLinks = FieldDefLinks.GetForLocation(FieldLocations.Family);
                    break;

                case "References":
                    data.ListCustRefEntries = CustRefEntries.GetEntryListForCustomer(patNum);
                    break;

                case "Referrals":
                    data.ListRefAttaches = RefAttaches.Refresh(patNum);
                    break;

                case "ResponsParty":
                    if (data.Pat.ResponsParty != 0)
                    {
                        data.ResponsibleParty = Patients.GetLim(data.Pat.ResponsParty);
                    }
                    break;
                }
            }
            if (data.Pat.DiscountPlanNum != 0)
            {
                data.DiscountPlan = DiscountPlans.GetPlan(data.Pat.DiscountPlanNum);
            }
            data.ListMergeLinks = PatientLinks.GetLinks(data.Fam.ListPats.Select(x => x.PatNum).ToList(), PatientLinkType.Merge);
            if (doCreateSecLog)
            {
                SecurityLogs.MakeLogEntry(Permissions.FamilyModule, patNum, "");
            }
            return(data);
        }
Ejemplo n.º 12
0
        ///<summary>Runs the required queries to populate the necessary StaticTextData fields corresponding to staticTextDependencies.</summary>
        private void LoadData(StaticTextFieldDependency staticTextDependencies, Patient pat, Family fam, List <long> listProcCodeNums)
        {
            bool isMiddleTier = (RemotingClient.RemotingRole == RemotingRole.ServerWeb);

            System.Diagnostics.Stopwatch timer = null;
            if (ODBuild.IsDebug())
            {
                timer = new System.Diagnostics.Stopwatch();
                timer.Start();
            }
            if (staticTextDependencies.HasFlag(StaticTextFieldDependency.Pat))
            {
                //patient should already be loaded.
            }
            if (fam == null && staticTextDependencies.HasFlag(StaticTextFieldDependency.Fam))
            {
                fam = Patients.GetFamily(pat.PatNum);
            }
            if (PatNote == null)
            {
                if (staticTextDependencies.HasFlag(StaticTextFieldDependency.PatNote))
                {
                    PatNote = PatientNotes.Refresh(pat.PatNum, pat.Guarantor);
                }
                else
                {
                    PatNote = new PatientNote();
                }
            }
            bool IsQueryNeeded <T>(ref List <T> list, StaticTextFieldDependency dependency)
            {
                if (list == null || (isMiddleTier && list.Count == 0))             //Middle Tier deserializes null lists to empty lists.
                {
                    if (staticTextDependencies.HasFlag(dependency))
                    {
                        return(true);
                    }
                    else
                    {
                        list = new List <T>();
                    }
                }
                return(false);
            }

            if (IsQueryNeeded(ref ListRefAttaches, StaticTextFieldDependency.ListRefAttaches))
            {
                ListRefAttaches = RefAttaches.Refresh(pat.PatNum);
            }
            if (IsQueryNeeded(ref ListInsSubs, StaticTextFieldDependency.ListInsSubs))
            {
                ListInsSubs = InsSubs.RefreshForFam(fam);
            }
            if (IsQueryNeeded(ref ListInsPlans, StaticTextFieldDependency.ListInsPlans))
            {
                ListInsPlans = InsPlans.RefreshForSubList(ListInsSubs);
            }
            if (IsQueryNeeded(ref ListPatPlans, StaticTextFieldDependency.ListPatPlans))
            {
                ListPatPlans = PatPlans.Refresh(pat.PatNum);
            }
            if (IsQueryNeeded(ref ListBenefits, StaticTextFieldDependency.ListBenefits))
            {
                ListBenefits = Benefits.Refresh(ListPatPlans, ListInsSubs);
            }
            if (IsQueryNeeded(ref HistList, StaticTextFieldDependency.HistList))
            {
                HistList = ClaimProcs.GetHistList(pat.PatNum, ListBenefits, ListPatPlans, ListInsPlans, DateTime.Today, ListInsSubs);
            }
            if (IsQueryNeeded(ref ListTreatPlans, StaticTextFieldDependency.ListTreatPlans))
            {
                ListTreatPlans = TreatPlans.Refresh(pat.PatNum);
            }
            if (IsQueryNeeded(ref ListRecallsForFam, StaticTextFieldDependency.ListRecallsForFam))
            {
                ListRecallsForFam = Recalls.GetList(fam.ListPats.Select(x => x.PatNum).ToList());
            }
            if (IsQueryNeeded(ref ListAppts, StaticTextFieldDependency.ListAppts))
            {
                ListAppts = Appointments.GetListForPat(pat.PatNum);
            }
            if (IsQueryNeeded(ref ListFutureApptsForFam, StaticTextFieldDependency.ListFutureApptsForFam))
            {
                ListFutureApptsForFam = Appointments.GetFutureSchedApts(fam.ListPats.Select(x => x.PatNum).ToList());
            }
            if (IsQueryNeeded(ref ListDiseases, StaticTextFieldDependency.ListDiseases))
            {
                ListDiseases = Diseases.Refresh(pat.PatNum, true);
            }
            if (IsQueryNeeded(ref ListAllergies, StaticTextFieldDependency.ListAllergies))
            {
                ListAllergies = Allergies.GetAll(pat.PatNum, false);
            }
            if (IsQueryNeeded(ref ListMedicationPats, StaticTextFieldDependency.ListMedicationPats))
            {
                ListMedicationPats = MedicationPats.Refresh(pat.PatNum, false);
            }
            if (IsQueryNeeded(ref ListFamPopups, StaticTextFieldDependency.ListFamPopups))
            {
                ListFamPopups = Popups.GetForFamily(pat);
            }
            if (IsQueryNeeded(ref ListProceduresSome, StaticTextFieldDependency.ListProceduresSome))
            {
                ListProceduresSome = Procedures.RefreshForProcCodeNums(pat.PatNum, listProcCodeNums);
            }
            if (IsQueryNeeded(ref ListProceduresPat, StaticTextFieldDependency.ListProceduresPat))
            {
                ListProceduresPat = Procedures.Refresh(pat.PatNum);
            }
            if (IsQueryNeeded(ref ListPlannedAppts, StaticTextFieldDependency.ListPlannedAppts))
            {
                ListPlannedAppts = new List <PlannedAppt>();
                PlannedAppt plannedAppt = PlannedAppts.GetOneOrderedByItemOrder(pat.PatNum);
                if (plannedAppt != null)
                {
                    ListPlannedAppts.Add(plannedAppt);
                }
            }
            if (ODBuild.IsDebug())
            {
                timer.Stop();
                Console.WriteLine("Static text field query time (ms): " + timer.ElapsedMilliseconds);
            }
        }