///<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); }
///<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); }
///<summary>Gets the first referral "from" for the given patient. Will return null if no "from" found for patient.</summary> public static Referral GetReferralForPat(long patNum) { //No need to check RemotingRole; no call to db. List <RefAttach> RefAttachList = RefAttaches.Refresh(patNum); for (int i = 0; i < RefAttachList.Count; i++) { if (RefAttachList[i].IsFrom) { return(GetReferral(RefAttachList[i].ReferralNum)); } } return(null); }
///<summary>Gets the first referral "from" for the given patient. Will return null if no "from" found for patient.</summary> public static Referral GetReferralForPat(long patNum, List <RefAttach> listRefAttaches = null) { //No need to check RemotingRole; no call to db. listRefAttaches = listRefAttaches ?? RefAttaches.Refresh(patNum); for (int i = 0; i < listRefAttaches.Count; i++) { if (listRefAttaches[i].RefType == ReferralType.RefFrom) { Referral referral; if (TryGetReferral(listRefAttaches[i].ReferralNum, out referral)) { return(referral); } } } return(null); }
///<summary>Gets IsDoctors referred "from" referrals for the given patient. Will return empty list if no "from" and IsDoctor found for patient.</summary> public static List <Referral> GetIsDoctorReferralsForPat(long patNum, List <RefAttach> listRefAttaches = null) { //No need to check RemotingRole; no call to db. List <Referral> retVal = new List <Referral>(); listRefAttaches = listRefAttaches ?? RefAttaches.Refresh(patNum); for (int i = 0; i < listRefAttaches.Count; i++) { if (listRefAttaches[i].RefType == ReferralType.RefFrom) { Referral referral; if (TryGetReferral(listRefAttaches[i].ReferralNum, out referral) && referral.IsDoctor) { retVal.Add(referral); } } } return(retVal); }
///<summary></summary> public static void Delete(Referral refer) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), refer); return; } if (RefAttaches.IsReferralAttached(refer.ReferralNum)) { throw new ApplicationException(Lans.g("FormReferralEdit", "Cannot delete Referral because it is attached to patients")); } if (Claims.IsReferralAttached(refer.ReferralNum)) { throw new ApplicationException(Lans.g("FormReferralEdit", "Cannot delete Referral because it is attached to claims")); } if (Procedures.IsReferralAttached(refer.ReferralNum)) { throw new ApplicationException(Lans.g("FormReferralEdit", "Cannot delete Referral because it is attached to procedures")); } string command = "DELETE FROM referral " + "WHERE ReferralNum = '" + POut.Long(refer.ReferralNum) + "'"; Db.NonQ(command); }
///<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); }
///<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); } }