///<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>Merge the PatientNote for patFrom into the PatientNote for patTo. Appends to FamFinancial, Medical, Service, MedicalComp, Treatment. ///Overwrites ICEName, ICEPhone, OrthoMonthsTreatOverride, DateOrthoPlacementOverride, but only if those fields are not already set for patTo. ///</summary> public static void Merge(Patient patFrom, Patient patTo) { PatientNote patNoteFrom = PatientNotes.Refresh(patFrom.PatNum, patFrom.Guarantor); //Never returns null. PatientNote patNoteTo = PatientNotes.Refresh(patTo.PatNum, patTo.Guarantor); //Never returns null. string strMergeDiv = "\r\n"; if (!string.IsNullOrEmpty(patNoteTo.FamFinancial)) //FamFinancial { patNoteTo.FamFinancial += strMergeDiv; } patNoteTo.FamFinancial += patNoteFrom.FamFinancial; //Skip ApptPhone, no longer used as of 4/2007. if (!string.IsNullOrEmpty(patNoteTo.Medical)) //Medical { patNoteTo.Medical += strMergeDiv; } patNoteTo.Medical += patNoteFrom.Medical; if (!string.IsNullOrEmpty(patNoteTo.Service)) //Service { patNoteTo.Service += strMergeDiv; } patNoteTo.Service += patNoteFrom.Service; if (!string.IsNullOrEmpty(patNoteTo.MedicalComp)) //MedicalComp { patNoteTo.MedicalComp += strMergeDiv; } patNoteTo.MedicalComp += patNoteFrom.MedicalComp; if (!string.IsNullOrEmpty(patNoteTo.Treatment)) //Treatment { patNoteTo.Treatment += strMergeDiv; } patNoteTo.Treatment += patNoteFrom.Treatment; if (string.IsNullOrEmpty(patNoteTo.ICEName)) //ICEName, only change if patNotTo was not set. { patNoteTo.ICEName += patNoteFrom.ICEName; } if (string.IsNullOrEmpty(patNoteTo.ICEPhone)) //ICEPhone, only change if patNotTo was not set. { patNoteTo.ICEPhone += patNoteFrom.ICEPhone; } if (patNoteTo.OrthoMonthsTreatOverride == -1) //OrthoMonthsTreatOverride, only change if patNoteTo was not set. { patNoteTo.OrthoMonthsTreatOverride = patNoteFrom.OrthoMonthsTreatOverride; } if (patNoteTo.DateOrthoPlacementOverride != DateTime.MinValue) //DateOrthoPlacementOverride, only change if patNotTo was not set. { patNoteTo.DateOrthoPlacementOverride = patNoteFrom.DateOrthoPlacementOverride; } PatientNotes.Update(patNoteTo, patTo.Guarantor); //Will cause the guarantor's FamFinancial field to be updated. }
///<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); } }