///<summary>Called by local practice db to query HQ for EService setup info. Must remain very lite and versionless. Will be used by signup portal. ///If HasClinics==true then any SignupOut.EServices entries where ClinicNum==0 are invalid and should be ignored. ///If HasClinics==false then SignupOut.EServices should only pay attention items where ClinicNum==0. ///This list is kept completely unfiltered by ClinicNum for forward compatibility reasons. ///The ClinicNum 0 items are always used by the Signup portal to determine default signup preferences. ///However, these items are only used for validation and billing in the case where HasClinics==true.</summary> public static EServiceSetup.SignupOut GetEServiceSetupFull(SignupPortalPermission permission, bool isSwitchClinicPref = false) { //Clinics will be stored in this order at HQ to allow signup portal to display them in proper order. List <Clinic> clinics = Clinics.GetDeepCopy().OrderBy(x => x.ItemOrder).ToList(); if (PrefC.GetBool(PrefName.ClinicListIsAlphabetical)) { clinics = clinics.OrderBy(x => x.Abbr).ToList(); } #if DEBUG bool isMockChanged = false; if (WebServiceMainHQProxy.MockWebServiceMainHQ == null) { WebServiceMainHQProxy.MockWebServiceMainHQ = new WebServiceMainHQMockDemo(); isMockChanged = true; } #endif EServiceSetup.SignupOut signupOut = ReadXml <EServiceSetup.SignupOut> ( WebSerializer.DeserializePrimitiveOrThrow <string> ( GetWebServiceMainHQInstance().EServiceSetup ( CreateWebServiceHQPayload ( WriteXml(new EServiceSetup.SignupIn() { MethodNameInt = (int)EServiceSetup.SetupMethod.GetSignupOutFull, HasClinics = PrefC.HasClinicsEnabled, //ClinicNum is not currently used as input. ClinicNum = 0, ProgramVersionStr = PrefC.GetString(PrefName.ProgramVersion), SignupPortalPermissionInt = (int)permission, Clinics = clinics .Select(x => new EServiceSetup.SignupIn.ClinicLiteIn() { ClinicNum = x.ClinicNum, ClinicTitle = x.Abbr, IsHidden = x.IsHidden, }).ToList(), IsSwitchClinicPref = isSwitchClinicPref, }), eServiceCode.Undefined ) ) ) ); #if DEBUG if (isMockChanged) { WebServiceMainHQProxy.MockWebServiceMainHQ = null; } #endif //We just got the latest sync info from HQ so update the local db to reflect what HQ says is true. #region Reconcile Phones List <SmsPhone> listPhonesHQ = signupOut.Phones.Select(x => new SmsPhone() { ClinicNum = x.ClinicNum, CountryCode = x.CountryCode, DateTimeActive = x.DateTimeActive, DateTimeInactive = x.DateTimeInactive, InactiveCode = x.InactiveCode, PhoneNumber = x.PhoneNumber, }).ToList(); bool isCacheInvalid = false; isCacheInvalid |= SmsPhones.UpdateOrInsertFromList(listPhonesHQ); #endregion #region Reconcile practice and clinics List <EServiceSetup.SignupOut.SignupOutSms> smsSignups = GetSignups <EServiceSetup.SignupOut.SignupOutSms>(signupOut, eServiceCode.IntegratedTexting); bool isSmsEnabled = false; if (PrefC.HasClinicsEnabled) //Clinics are ON so loop through all clinics and reconcile with HQ. { List <Clinic> listClinicsAll = Clinics.GetDeepCopy(); foreach (Clinic clinicDb in listClinicsAll) { WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms clinicSignup = smsSignups.FirstOrDefault(x => x.ClinicNum == clinicDb.ClinicNum) ?? new WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms() { //Not found so turn it off. SmsContractDate = DateTime.MinValue, MonthlySmsLimit = 0, IsEnabled = false, }; Clinic clinicNew = clinicDb.Copy(); clinicNew.SmsContractDate = clinicSignup.SmsContractDate; clinicNew.SmsMonthlyLimit = clinicSignup.MonthlySmsLimit; isCacheInvalid |= Clinics.Update(clinicNew, clinicDb); isSmsEnabled |= clinicSignup.IsEnabled; } } else //Clinics are off so ClinicNum 0 is the practice clinic. { WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms practiceSignup = smsSignups.FirstOrDefault(x => x.ClinicNum == 0) ?? new WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms() { //Not found so turn it off. SmsContractDate = DateTime.MinValue, MonthlySmsLimit = 0, IsEnabled = false, }; isCacheInvalid |= Prefs.UpdateDateT(PrefName.SmsContractDate, practiceSignup.SmsContractDate) | Prefs.UpdateLong(PrefName.TextingDefaultClinicNum, 0) | Prefs.UpdateDouble(PrefName.SmsMonthlyLimit, practiceSignup.MonthlySmsLimit); isSmsEnabled |= practiceSignup.IsEnabled; } #endregion #region Reconcile CallFire //Turn off CallFire if SMS has been activated. //This only happens the first time SMS is turned on and CallFire is still activated. if (isSmsEnabled && Programs.IsEnabled(ProgramName.CallFire)) { Program callfire = Programs.GetCur(ProgramName.CallFire); if (callfire != null) { callfire.Enabled = false; Programs.Update(callfire); Signalods.Insert(new Signalod() { IType = InvalidType.Providers }); signupOut.Prompts.Add("Call Fire has been disabled. Cancel Integrated Texting and access program properties to retain Call Fire."); } } #endregion #region eConfirmations if (Prefs.UpdateBool(PrefName.ApptConfirmAutoSignedUp, IsEServiceActive(signupOut, eServiceCode.ConfirmationRequest))) { //HQ does not match the local pref. Make it match with HQ. isCacheInvalid = true; SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Automated appointment eConfirmations automatically changed by HQ. Local pref set to " + IsEServiceActive(signupOut, eServiceCode.ConfirmationRequest).ToString() + "."); } #endregion if (isCacheInvalid) //Something changed in the db. Alert other workstations and change this workstation immediately. { Signalods.Insert(new Signalod() { IType = InvalidType.Prefs }); Prefs.RefreshCache(); Signalods.Insert(new Signalod() { IType = InvalidType.Providers }); Providers.RefreshCache(); Clinics.RefreshCache(); Signalods.Insert(new Signalod() { IType = InvalidType.SmsPhones }); SmsPhones.RefreshCache(); } return(signupOut); }
///<summary>If ClientWeb, then this method is instead run on the server, and the result passed back to the client. And since it's ClientWeb, FillCache will be run on the client.</summary> public static DataSet GetCacheDs(string itypesStr) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetDS(MethodBase.GetCurrentMethod(), itypesStr)); } //so this part below only happens if direct or server------------------------------------------------ List <int> itypes = new List <int>(); string[] strArray = itypesStr.Split(','); for (int i = 0; i < strArray.Length; i++) { itypes.Add(PIn.Int(strArray[i])); } bool isAll = false; if (itypes.Contains((int)InvalidType.AllLocal)) { isAll = true; } DataSet ds = new DataSet(); if (itypes.Contains((int)InvalidType.AccountingAutoPays) || isAll) { ds.Tables.Add(AccountingAutoPays.RefreshCache()); } if (itypes.Contains((int)InvalidType.AutoCodes) || isAll) { ds.Tables.Add(AutoCodes.RefreshCache()); ds.Tables.Add(AutoCodeItems.RefreshCache()); ds.Tables.Add(AutoCodeConds.RefreshCache()); } if (itypes.Contains((int)InvalidType.Automation) || isAll) { ds.Tables.Add(Automations.RefreshCache()); } if (itypes.Contains((int)InvalidType.AutoNotes) || isAll) { ds.Tables.Add(AutoNotes.RefreshCache()); ds.Tables.Add(AutoNoteControls.RefreshCache()); } if (itypes.Contains((int)InvalidType.Carriers) || isAll) { ds.Tables.Add(Carriers.RefreshCache()); //run on startup, after telephone reformat, after list edit. } if (itypes.Contains((int)InvalidType.ClaimForms) || isAll) { ds.Tables.Add(ClaimFormItems.RefreshCache()); ds.Tables.Add(ClaimForms.RefreshCache()); } if (itypes.Contains((int)InvalidType.ClearHouses) || isAll) { ds.Tables.Add(Clearinghouses.RefreshCache()); //kh wants to add an EasyHideClearHouses to disable this } if (itypes.Contains((int)InvalidType.Computers) || isAll) { ds.Tables.Add(Computers.RefreshCache()); ds.Tables.Add(Printers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Defs) || isAll) { ds.Tables.Add(Defs.RefreshCache()); } if (itypes.Contains((int)InvalidType.DentalSchools) || isAll) { ds.Tables.Add(SchoolClasses.RefreshCache()); ds.Tables.Add(SchoolCourses.RefreshCache()); } if (itypes.Contains((int)InvalidType.DictCustoms) || isAll) { ds.Tables.Add(DictCustoms.RefreshCache()); } if (itypes.Contains((int)InvalidType.Diseases) || isAll) { ds.Tables.Add(DiseaseDefs.RefreshCache()); ds.Tables.Add(ICD9s.RefreshCache()); } if (itypes.Contains((int)InvalidType.DisplayFields) || isAll) { ds.Tables.Add(DisplayFields.RefreshCache()); } if (itypes.Contains((int)InvalidType.ElectIDs) || isAll) { ds.Tables.Add(ElectIDs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Email) || isAll) { ds.Tables.Add(EmailAddresses.RefreshCache()); ds.Tables.Add(EmailTemplates.RefreshCache()); } if (itypes.Contains((int)InvalidType.Employees) || isAll) { ds.Tables.Add(Employees.RefreshCache()); ds.Tables.Add(PayPeriods.RefreshCache()); } if (itypes.Contains((int)InvalidType.Employers) || isAll) { ds.Tables.Add(Employers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Fees) || isAll) { ds.Tables.Add(Fees.RefreshCache()); } if (itypes.Contains((int)InvalidType.FeeScheds) || isAll) { ds.Tables.Add(FeeScheds.RefreshCache()); } if (itypes.Contains((int)InvalidType.HL7Defs) || isAll) { ds.Tables.Add(HL7Defs.RefreshCache()); ds.Tables.Add(HL7DefMessages.RefreshCache()); ds.Tables.Add(HL7DefSegments.RefreshCache()); ds.Tables.Add(HL7DefFields.RefreshCache()); } if (itypes.Contains((int)InvalidType.InsCats) || isAll) { ds.Tables.Add(CovCats.RefreshCache()); ds.Tables.Add(CovSpans.RefreshCache()); } if (itypes.Contains((int)InvalidType.InsFilingCodes) || isAll) { ds.Tables.Add(InsFilingCodes.RefreshCache()); ds.Tables.Add(InsFilingCodeSubtypes.RefreshCache()); } if (itypes.Contains((int)InvalidType.Languages) || isAll) { if (CultureInfo.CurrentCulture.Name != "en-US") { ds.Tables.Add(Lans.RefreshCache()); } } if (itypes.Contains((int)InvalidType.Letters) || isAll) { ds.Tables.Add(Letters.RefreshCache()); } if (itypes.Contains((int)InvalidType.LetterMerge) || isAll) { ds.Tables.Add(LetterMergeFields.RefreshCache()); ds.Tables.Add(LetterMerges.RefreshCache()); } if (itypes.Contains((int)InvalidType.Operatories) || isAll) { ds.Tables.Add(Operatories.RefreshCache()); } if (itypes.Contains((int)InvalidType.PatFields) || isAll) { ds.Tables.Add(PatFieldDefs.RefreshCache()); ds.Tables.Add(ApptFieldDefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Pharmacies) || isAll) { ds.Tables.Add(Pharmacies.RefreshCache()); } if (itypes.Contains((int)InvalidType.Prefs) || isAll) { ds.Tables.Add(Prefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProcButtons) || isAll) { ds.Tables.Add(ProcButtons.RefreshCache()); ds.Tables.Add(ProcButtonItems.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProcCodes) || isAll) { ds.Tables.Add(ProcedureCodes.RefreshCache()); ds.Tables.Add(ProcCodeNotes.RefreshCache()); } if (itypes.Contains((int)InvalidType.Programs) || isAll) { ds.Tables.Add(Programs.RefreshCache()); ds.Tables.Add(ProgramProperties.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProviderIdents) || isAll) { ds.Tables.Add(ProviderIdents.RefreshCache()); } if (itypes.Contains((int)InvalidType.Providers) || isAll) { ds.Tables.Add(Providers.RefreshCache()); } if (itypes.Contains((int)InvalidType.QuickPaste) || isAll) { ds.Tables.Add(QuickPasteNotes.RefreshCache()); ds.Tables.Add(QuickPasteCats.RefreshCache()); } if (itypes.Contains((int)InvalidType.RecallTypes) || isAll) { ds.Tables.Add(RecallTypes.RefreshCache()); ds.Tables.Add(RecallTriggers.RefreshCache()); } if (itypes.Contains((int)InvalidType.ReplicationServers) || isAll) { ds.Tables.Add(ReplicationServers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Security) || isAll) { ds.Tables.Add(Userods.RefreshCache()); ds.Tables.Add(UserGroups.RefreshCache()); } if (itypes.Contains((int)InvalidType.Sheets) || isAll) { ds.Tables.Add(SheetDefs.RefreshCache()); ds.Tables.Add(SheetFieldDefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Signals) || isAll) { ds.Tables.Add(SigElementDefs.RefreshCache()); ds.Tables.Add(SigButDefs.RefreshCache()); //includes SigButDefElements.Refresh() } if (itypes.Contains((int)InvalidType.Sites) || isAll) { ds.Tables.Add(Sites.RefreshCache()); } if (itypes.Contains((int)InvalidType.Sops) || isAll) { ds.Tables.Add(Sops.RefreshCache()); } //InvalidTypes.Tasks not handled here. if (itypes.Contains((int)InvalidType.TimeCardRules) || isAll) { ds.Tables.Add(TimeCardRules.RefreshCache()); } if (itypes.Contains((int)InvalidType.ToolBut) || isAll) { ds.Tables.Add(ToolButItems.RefreshCache()); } if (itypes.Contains((int)InvalidType.Vaccines) || isAll) { ds.Tables.Add(VaccineDefs.RefreshCache()); ds.Tables.Add(DrugManufacturers.RefreshCache()); ds.Tables.Add(DrugUnits.RefreshCache()); } if (itypes.Contains((int)InvalidType.Views) || isAll) { ds.Tables.Add(ApptViews.RefreshCache()); ds.Tables.Add(ApptViewItems.RefreshCache()); ds.Tables.Add(AppointmentRules.RefreshCache()); ds.Tables.Add(ProcApptColors.RefreshCache()); } if (itypes.Contains((int)InvalidType.Wiki) || isAll) { ds.Tables.Add(WikiListHeaderWidths.RefreshCache()); ds.Tables.Add(WikiPages.RefreshCache()); } if (itypes.Contains((int)InvalidType.ZipCodes) || isAll) { ds.Tables.Add(ZipCodes.RefreshCache()); } return(ds); }