Пример #1
0
 ///<summary>Must be called after Preference cache has been filled.
 ///Deletes all signals older than 2 days if this has not been run within the last week.  Will fail silently if anything goes wrong.</summary>
 public static void ClearOldSignals()
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod());
         return;
     }
     try {
         if (Prefs.GetContainsKey(PrefName.SignalLastClearedDate.ToString()) &&
             PrefC.GetDateT(PrefName.SignalLastClearedDate) > MiscData.GetNowDateTime().AddDays(-7)) //Has already been run in the past week. This is all server based time.
         {
             return;                                                                                 //Do not run this process again.
         }
         string command = "";
         if (DataConnection.DBtype == DatabaseType.MySql)                                          //easier to read that using the DbHelper Functions and it also matches the ConvertDB3 script
         {
             command = "DELETE FROM signalod WHERE SigDateTime < DATE_ADD(NOW(),INTERVAL -2 DAY)"; //Itypes only older than 2 days
             Db.NonQ(command);
         }
         else                                                                           //oracle
         {
             command = "DELETE FROM signalod WHERE SigDateTime < CURRENT_TIMESTAMP -2"; //Itypes only older than 2 days
             Db.NonQ(command);
         }
         SigMessages.ClearOldSigMessages();                                            //Clear messaging buttons which use to be stored in the signal table.
         //SigElements.DeleteOrphaned();
         Prefs.UpdateDateT(PrefName.SignalLastClearedDate, MiscData.GetNowDateTime()); //Set Last cleared to now.
     }
     catch (Exception) {
         //fail silently
     }
 }
Пример #2
0
        ///<summary>Returns true if a change was required, or false if no change needed.</summary>
        public static bool UpdateDateT(PrefName prefName, DateTime newValue)
        {
            //Very unusual.  Involves cache, so Meth is used further down instead of here at the top.
            DateTime curValue = PrefC.GetDateT(prefName);

            if (curValue == newValue)
            {
                return(false);               //no change needed
            }
            string command = "UPDATE preference SET "
                             + "ValueString = '" + POut.DateT(newValue, false) + "' "
                             + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'";
            bool retVal = true;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue);
            }
            else
            {
                Db.NonQ(command);
            }
            Pref pref = new Pref();

            pref.PrefName    = prefName.ToString();
            pref.ValueString = POut.DateT(newValue, false);
            Prefs.UpdateValueForKey(pref);
            return(retVal);
        }
Пример #3
0
            ///<summary>Initialize the sender helper for the given PatComms and appointments.</summary>
            ///<param name="clinicNum">The clinic that is doing the sending.</param>
            ///<param name="dtSlotStart">The date time of the time slot for which this list is being sent.</param>
            ///<param name="dtStartSend">The date time when the list should be sent out. This time will be adjusted if necessary.</param>
            internal AsapListSender(SendMode sendMode, List <PatComm> listPatComms, long clinicNum, DateTime dtSlotStart,
                                    DateTime dtStartSend)
            {
                _sendMode         = sendMode;
                _dictPatComms     = listPatComms.GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => x.First());
                _dictPatDetails   = listPatComms.GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => new PatientDetail(x.First()));
                _dictPatAsapComms = GetForPats(listPatComms.Select(x => x.PatNum).ToList()).GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => x.ToList());
                TimeSpan timeAutoCommStart = PrefC.GetDateT(PrefName.AutomaticCommunicationTimeStart).TimeOfDay;
                TimeSpan timeAutoCommEnd   = PrefC.GetDateT(PrefName.AutomaticCommunicationTimeEnd).TimeOfDay;

                DtSendEmail     = dtStartSend;          //All emails will be sent immediately.
                DtStartSendText = dtStartSend;
                if (PrefC.DoRestrictAutoSendWindow)
                {
                    //If the time to start sending is before the automatic send window, set the time to start to the beginning of the send window.
                    if (DtStartSendText.TimeOfDay < timeAutoCommStart)
                    {
                        DtStartSendText     = DtStartSendText.Date.Add(timeAutoCommStart);
                        IsOutsideSendWindow = true;
                    }
                    else if (DtStartSendText.TimeOfDay > timeAutoCommEnd)
                    {
                        //If the time to start sending is after the automatic send window, set the time to start to the beginning of the send window the next day.
                        DtStartSendText     = DtStartSendText.Date.AddDays(1).Add(timeAutoCommStart);
                        IsOutsideSendWindow = true;
                    }
                }
                string maxTextsPrefVal = ClinicPrefs.GetPrefValue(PrefName.WebSchedAsapTextLimit, clinicNum);

                _maxTextsPerDay = String.IsNullOrWhiteSpace(maxTextsPrefVal) ? int.MaxValue : PIn.Int(maxTextsPrefVal);               //The pref may be set to blank to have no limit
                DtTextSendEnd   = DtStartSendText.Date.Add(timeAutoCommEnd);
                _dtSlotStart    = dtSlotStart;
                SetMinutesBetweenTexts(dtSlotStart);
                ListAsapComms = new List <AsapComm>();
            }
Пример #4
0
        ///<summary>Returns true if a change was required, or false if no change needed.</summary>
        public static bool UpdateDateT(PrefName prefName, DateTime newValue)
        {
            //Very unusual.  Involves cache, so Meth is used further down instead of here at the top.
            if (!PrefC.Dict.ContainsKey(prefName.ToString()))
            {
                throw new ApplicationException(prefName + " is an invalid pref name.");
            }
            if (PrefC.GetDateT(prefName) == newValue)
            {
                return(false);               //no change needed
            }
            string command = "UPDATE preference SET "
                             + "ValueString = '" + POut.DateT(newValue, false) + "' "
                             + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'";
            bool retVal = true;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue);
            }
            else
            {
                Db.NonQ(command);
            }
            Pref pref = new Pref();

            pref.PrefName    = prefName.ToString();
            pref.ValueString = POut.DateT(newValue, false);
            PrefC.Dict[prefName.ToString()] = pref;          //in some cases, we just want to change the pref in local memory instead of doing a refresh afterwards.
            return(retVal);
        }
Пример #5
0
 ///<summary>Returns true if texting is enabled for any clinics (including hidden), or if not using clinics, if it is enabled for the practice.</summary>
 public static bool IsIntegratedTextingEnabled()
 {
     //No need to check RemotingRole; no call to db.
     if (Plugins.HookMethod(null, "SmsPhones.IsIntegratedTextingEnabled_start"))
     {
         return(true);
     }
     if (!PrefC.HasClinicsEnabled)
     {
         return(PrefC.GetDateT(PrefName.SmsContractDate).Year > 1880);
     }
     return(Clinics.GetFirstOrDefault(x => x.SmsContractDate.Year > 1880) != null);
 }
Пример #6
0
        ///<summary>Returns true if it is time to retrieve reports.</summary>
        private static bool IsTimeToRetrieveReports(bool isAutomaticMode, out string errorMessage, IODProgressExtended progress = null)
        {
            progress = progress ?? new ODProgressExtendedNull();
            DateTime timeLastReport      = PIn.DateT(PrefC.GetStringNoCache(PrefName.ClaimReportReceiveLastDateTime));
            double   timeReceiveInternal = PIn.Double(PrefC.GetStringNoCache(PrefName.ClaimReportReceiveInterval));        //Interval in minutes.
            DateTime timeToRecieve       = DateTime.Now.Date + PrefC.GetDateT(PrefName.ClaimReportReceiveTime).TimeOfDay;
            double   timeDiff            = DateTime.Now.Subtract(timeLastReport).TotalMinutes;

            errorMessage = "";
            if (isAutomaticMode)
            {
                if (timeReceiveInternal != 0)                //preference is set instead of pref for specific time.
                {
                    if (timeDiff < timeReceiveInternal)
                    {
                        //Automatically retrieving reports from this computer and the report interval has not passed yet.
                        return(false);
                    }
                }
                else                  //pref is set for specific time, not interval
                {
                    if (DateTime.Now.TimeOfDay < timeToRecieve.TimeOfDay ||                 //We haven't reach to the time to retrieve
                        timeLastReport.Date == DateTime.Today)                         //Or we have already retrieved today
                    {
                        //Automatically retrieving reports and the time has not come to pass yet
                        return(false);
                    }
                }
            }
            else if (timeDiff < 1)
            {
                //When the user presses the Get Reports button manually we allow them to get reports up to once per minute
                errorMessage = Lans.g(progress.LanThis, "Reports can only be retrieved once per minute.");
                progress.UpdateProgress(Lans.g(progress.LanThis, "Reports can only be retrieved once per minute. Attempting to import manually downloaded reports."));
                return(false);
            }
            return(true);
        }