Пример #1
0
 ///<summary>Inserts one RecallType into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(RecallType recallType,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         recallType.RecallTypeNum=ReplicationServers.GetKey("recalltype","RecallTypeNum");
     }
     string command="INSERT INTO recalltype (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="RecallTypeNum,";
     }
     command+="Description,DefaultInterval,TimePattern,Procedures) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(recallType.RecallTypeNum)+",";
     }
     command+=
          "'"+POut.String(recallType.Description)+"',"
         +    POut.Int   (recallType.DefaultInterval.ToInt())+","
         +"'"+POut.String(recallType.TimePattern)+"',"
         +"'"+POut.String(recallType.Procedures)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         recallType.RecallTypeNum=Db.NonQ(command,true);
     }
     return recallType.RecallTypeNum;
 }
Пример #2
0
 ///<summary>Inserts one RecallType into the database.  Returns the new priKey.</summary>
 internal static long Insert(RecallType recallType)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         recallType.RecallTypeNum=DbHelper.GetNextOracleKey("recalltype","RecallTypeNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(recallType,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     recallType.RecallTypeNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(recallType,false);
     }
 }
Пример #3
0
        public static Appointment CreateAppointmentFromRecall(Recall recall, Patient pat, DateTime aptDateTime, long opNum, long provNum)
        {
            RecallType  recallType = RecallTypes.GetFirstOrDefault(x => x.RecallTypeNum == recall.RecallTypeNum);
            Appointment appt       = CreateAppointment(pat.PatNum, aptDateTime, opNum, provNum, pattern: recallType.TimePattern, clinicNum: pat.ClinicNum);

            foreach (string procCode in RecallTypes.GetProcs(recallType.RecallTypeNum))
            {
                ProcedureT.CreateProcedure(pat, procCode, ProcStat.TP, "", 50, appt.AptDateTime, provNum: provNum, aptNum: appt.AptNum);
            }
            return(appt);
        }
Пример #4
0
        ///<summary>Updates one RecallType in the database.</summary>
        public static void Update(RecallType recallType)
        {
            string command = "UPDATE recalltype SET "
                             + "Description    = '" + POut.String(recallType.Description) + "', "
                             + "DefaultInterval=  " + POut.Int(recallType.DefaultInterval.ToInt()) + ", "
                             + "TimePattern    = '" + POut.String(recallType.TimePattern) + "', "
                             + "Procedures     = '" + POut.String(recallType.Procedures) + "' "
                             + "WHERE RecallTypeNum = " + POut.Long(recallType.RecallTypeNum);

            Db.NonQ(command);
        }
Пример #5
0
        ///<summary>Updates one RecallType in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(RecallType recallType, RecallType oldRecallType)
        {
            string command = "";

            if (recallType.Description != oldRecallType.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(recallType.Description) + "'";
            }
            if (recallType.DefaultInterval != oldRecallType.DefaultInterval)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DefaultInterval = " + POut.Int(recallType.DefaultInterval.ToInt()) + "";
            }
            if (recallType.TimePattern != oldRecallType.TimePattern)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimePattern = '" + POut.String(recallType.TimePattern) + "'";
            }
            if (recallType.Procedures != oldRecallType.Procedures)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Procedures = '" + POut.String(recallType.Procedures) + "'";
            }
            if (recallType.AppendToSpecial != oldRecallType.AppendToSpecial)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AppendToSpecial = " + POut.Bool(recallType.AppendToSpecial) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE recalltype SET " + command
                      + " WHERE RecallTypeNum = " + POut.Long(recallType.RecallTypeNum);
            Db.NonQ(command);
            return(true);
        }
Пример #6
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<RecallType> TableToList(DataTable table){
			List<RecallType> retVal=new List<RecallType>();
			RecallType recallType;
			for(int i=0;i<table.Rows.Count;i++) {
				recallType=new RecallType();
				recallType.RecallTypeNum  = PIn.Long  (table.Rows[i]["RecallTypeNum"].ToString());
				recallType.Description    = PIn.String(table.Rows[i]["Description"].ToString());
				recallType.DefaultInterval= new Interval(PIn.Int(table.Rows[i]["DefaultInterval"].ToString()));
				recallType.TimePattern    = PIn.String(table.Rows[i]["TimePattern"].ToString());
				recallType.Procedures     = PIn.String(table.Rows[i]["Procedures"].ToString());
				retVal.Add(recallType);
			}
			return retVal;
		}
Пример #7
0
 ///<summary>Inserts one RecallType into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RecallType recallType)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(recallType, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             recallType.RecallTypeNum = DbHelper.GetNextOracleKey("recalltype", "RecallTypeNum");                  //Cacheless method
         }
         return(InsertNoCache(recallType, true));
     }
 }
Пример #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <RecallType> TableToList(DataTable table)
        {
            List <RecallType> retVal = new List <RecallType>();
            RecallType        recallType;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                recallType = new RecallType();
                recallType.RecallTypeNum   = PIn.Long(table.Rows[i]["RecallTypeNum"].ToString());
                recallType.Description     = PIn.String(table.Rows[i]["Description"].ToString());
                recallType.DefaultInterval = new Interval(PIn.Int(table.Rows[i]["DefaultInterval"].ToString()));
                recallType.TimePattern     = PIn.String(table.Rows[i]["TimePattern"].ToString());
                recallType.Procedures      = PIn.String(table.Rows[i]["Procedures"].ToString());
                retVal.Add(recallType);
            }
            return(retVal);
        }
Пример #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <RecallType> TableToList(DataTable table)
        {
            List <RecallType> retVal = new List <RecallType>();
            RecallType        recallType;

            foreach (DataRow row in table.Rows)
            {
                recallType = new RecallType();
                recallType.RecallTypeNum   = PIn.Long(row["RecallTypeNum"].ToString());
                recallType.Description     = PIn.String(row["Description"].ToString());
                recallType.DefaultInterval = new Interval(PIn.Int(row["DefaultInterval"].ToString()));
                recallType.TimePattern     = PIn.String(row["TimePattern"].ToString());
                recallType.Procedures      = PIn.String(row["Procedures"].ToString());
                recallType.AppendToSpecial = PIn.Bool(row["AppendToSpecial"].ToString());
                retVal.Add(recallType);
            }
            return(retVal);
        }
Пример #10
0
        ///<summary>Updates one RecallType in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(RecallType recallType, RecallType oldRecallType)
        {
            string command = "";

            if (recallType.Description != oldRecallType.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(recallType.Description) + "'";
            }
            if (recallType.DefaultInterval != oldRecallType.DefaultInterval)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DefaultInterval = " + POut.Int(recallType.DefaultInterval.ToInt()) + "";
            }
            if (recallType.TimePattern != oldRecallType.TimePattern)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimePattern = '" + POut.String(recallType.TimePattern) + "'";
            }
            if (recallType.Procedures != oldRecallType.Procedures)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Procedures = '" + POut.String(recallType.Procedures) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE recalltype SET " + command
                      + " WHERE RecallTypeNum = " + POut.Long(recallType.RecallTypeNum);
            Db.NonQ(command);
        }
Пример #11
0
        ///<summary>Gets up to 30 days of open time slots based on the recall passed in.
        ///Open time slots are found by looping through operatories flagged for Web Sched and finding openings that can hold the recall.
        ///The amount of time required to be considered "available" is dictated by the RecallType associated to the recall passed in.
        ///Throws exceptions.</summary>
        public static List <TimeSlot> GetAvailableWebSchedTimeSlots(long recallNum, DateTime dateStart, DateTime dateEnd, long provNum = 0,
                                                                    bool allowOtherProv = true)
        {
            //No need to check RemotingRole; no call to db.
            Clinic clinic = Clinics.GetClinicForRecall(recallNum);
            Recall recall = Recalls.GetRecall(recallNum);

            if (recall == null)
            {
                throw new ODException(Lans.g("WebSched", "The recall appointment you are trying to schedule is no longer available.") + "\r\n"
                                      + Lans.g("WebSched", "Please call us to schedule your appointment."));
            }
            List <Provider> listProviders = Providers.GetProvidersForWebSched(recall.PatNum);

            if (provNum > 0 && !allowOtherProv)
            {
                listProviders = listProviders.FindAll(x => x.ProvNum == provNum);
            }
            RecallType recallType = RecallTypes.GetFirstOrDefault(x => x.RecallTypeNum == recall.RecallTypeNum);

            return(GetAvailableWebSchedTimeSlots(recallType, listProviders, clinic, dateStart, dateEnd, recall));
        }
Пример #12
0
        ///<summary>Gets up to 30 days of open time slots based on the RecallType passed in.
        ///Open time slots are found by looping through operatories flagged for Web Sched and finding openings that can hold the RecallType.
        ///The RecallType passed in must be a valid recall type.
        ///Providers passed in will be the only providers considered when looking for available time slots.
        ///Passing in a null clinic will only consider operatories with clinics set to 0 (unassigned).
        ///The timeslots on and between the Start and End dates passed in will be considered and potentially returned as available.
        ///Optionally pass in a recall object in order to consider all other recalls due for the patient.  This will potentially affect the time pattern.
        ///Throws exceptions.</summary>
        public static List <TimeSlot> GetAvailableWebSchedTimeSlots(RecallType recallType, List <Provider> listProviders, Clinic clinic
                                                                    , DateTime dateStart, DateTime dateEnd, Recall recallCur = null, Logger.IWriteLine log = null)
        {
            //No need to check RemotingRole; no call to db.
            if (recallType == null)           //Validate that recallType is not null.
            {
                throw new ODException(Lans.g("WebSched", "The recall appointment you are trying to schedule is no longer available.") + "\r\n"
                                      + Lans.g("WebSched", "Please call us to schedule your appointment."));
            }
            //Get all the Operatories that are flagged for Web Sched.
            List <Operatory> listOperatories = Operatories.GetOpsForWebSched();

            if (listOperatories.Count < 1)             //This is very possible for offices that aren't set up the way that we expect them to be.
            {
                throw new ODException(Lans.g("WebSched", "There are no operatories set up for Web Sched.") + "\r\n"
                                      + Lans.g("WebSched", "Please call us to schedule your appointment."), ODException.ErrorCodes.NoOperatoriesSetup);
            }
            log?.WriteLine("listOperatories:\r\n\t" + string.Join(",\r\n\t", listOperatories.Select(x => x.OperatoryNum + " - " + x.Abbrev)), LogLevel.Verbose);
            List <long>     listProvNums  = listProviders.Select(x => x.ProvNum).Distinct().ToList();
            List <Schedule> listSchedules = Schedules.GetSchedulesAndBlockoutsForWebSched(listProvNums, dateStart, dateEnd, true
                                                                                          , (clinic == null) ? 0 : clinic.ClinicNum, log);

            log?.WriteLine("listSchedules:\r\n\t" + string.Join(",\r\n\t", listSchedules.Select(x => x.ScheduleNum + " - " + x.SchedDate + " " + x.StartTime))
                           , LogLevel.Verbose);
            string timePatternRecall = recallType.TimePattern;

            //Apparently scheduling this one recall can potentially schedule a bunch of other recalls at the same time.
            //We need to potentially bloat our time pattern based on the other recalls that are due for this specific patient.
            if (recallCur != null)
            {
                Patient       patCur      = Patients.GetPat(recallCur.PatNum);
                List <Recall> listRecalls = Recalls.GetList(recallCur.PatNum);
                timePatternRecall = Recalls.GetRecallTimePattern(recallCur, listRecalls, patCur, new List <string>());
            }
            string timePatternAppointment = RecallTypes.ConvertTimePattern(timePatternRecall);

            return(GetTimeSlotsForRange(dateStart, dateEnd, timePatternAppointment, listProvNums, listOperatories, listSchedules, clinic, log: log,
                                        isDoubleBookingAllowed: PrefC.GetInt(PrefName.WebSchedRecallDoubleBooking) == 0));//is double booking allowed according to the preference
        }
Пример #13
0
        ///<summary>Gets up to 30 days of open time slots based on the recall passed in.
        ///Open time slots are found by looping through operatories flagged for Web Sched and finding openings that can hold the recall.
        ///The amount of time required to be considered "available" is dictated by the RecallType associated to the recall passed in.
        ///Throws exceptions.</summary>
        public static List <TimeSlot> GetAvailableWebSchedTimeSlots(long recallNum, DateTime dateStart, DateTime dateEnd, long provNum = 0,
                                                                    bool allowOtherProv = true, Logger.IWriteLine log = null)
        {
            //No need to check RemotingRole; no call to db.
            Clinic clinic = Clinics.GetClinicForRecall(recallNum);
            Recall recall = Recalls.GetRecall(recallNum);

            if (recall == null)
            {
                throw new ODException(Lans.g("WebSched", "The recall appointment you are trying to schedule is no longer available.") + "\r\n"
                                      + Lans.g("WebSched", "Please call us to schedule your appointment."));
            }
            List <Provider> listProviders = Providers.GetProvidersForWebSched(recall.PatNum, clinic?.ClinicNum ?? 0);

            if (provNum > 0 && !allowOtherProv)
            {
                listProviders = listProviders.FindAll(x => x.ProvNum == provNum);
            }
            log?.WriteLine("listProviders:\r\n\t" + string.Join(",\r\n\t", listProviders.Select(x => x.ProvNum + " - " + x.Abbr)), LogLevel.Verbose);
            RecallType recallType = RecallTypes.GetFirstOrDefault(x => x.RecallTypeNum == recall.RecallTypeNum);

            return(GetAvailableWebSchedTimeSlots(recallType, listProviders, clinic, dateStart, dateEnd, recall, log));
        }
Пример #14
0
 ///<summary>Returns true if Update(RecallType,RecallType) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(RecallType recallType, RecallType oldRecallType)
 {
     if (recallType.Description != oldRecallType.Description)
     {
         return(true);
     }
     if (recallType.DefaultInterval != oldRecallType.DefaultInterval)
     {
         return(true);
     }
     if (recallType.TimePattern != oldRecallType.TimePattern)
     {
         return(true);
     }
     if (recallType.Procedures != oldRecallType.Procedures)
     {
         return(true);
     }
     if (recallType.AppendToSpecial != oldRecallType.AppendToSpecial)
     {
         return(true);
     }
     return(false);
 }
Пример #15
0
 ///<summary>Inserts one RecallType into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RecallType recallType)
 {
     return(InsertNoCache(recallType, false));
 }
Пример #16
0
 ///<summary>Updates one RecallType in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
 internal static void Update(RecallType recallType,RecallType oldRecallType)
 {
     string command="";
     if(recallType.Description != oldRecallType.Description) {
         if(command!=""){ command+=",";}
         command+="Description = '"+POut.String(recallType.Description)+"'";
     }
     if(recallType.DefaultInterval != oldRecallType.DefaultInterval) {
         if(command!=""){ command+=",";}
         command+="DefaultInterval = "+POut.Int(recallType.DefaultInterval.ToInt())+"";
     }
     if(recallType.TimePattern != oldRecallType.TimePattern) {
         if(command!=""){ command+=",";}
         command+="TimePattern = '"+POut.String(recallType.TimePattern)+"'";
     }
     if(recallType.Procedures != oldRecallType.Procedures) {
         if(command!=""){ command+=",";}
         command+="Procedures = '"+POut.String(recallType.Procedures)+"'";
     }
     if(command==""){
         return;
     }
     command="UPDATE recalltype SET "+command
         +" WHERE RecallTypeNum = "+POut.Long(recallType.RecallTypeNum);
     Db.NonQ(command);
 }
Пример #17
0
 ///<summary>Updates one RecallType in the database.</summary>
 internal static void Update(RecallType recallType)
 {
     string command="UPDATE recalltype SET "
         +"Description    = '"+POut.String(recallType.Description)+"', "
         +"DefaultInterval=  "+POut.Int   (recallType.DefaultInterval.ToInt())+", "
         +"TimePattern    = '"+POut.String(recallType.TimePattern)+"', "
         +"Procedures     = '"+POut.String(recallType.Procedures)+"' "
         +"WHERE RecallTypeNum = "+POut.Long(recallType.RecallTypeNum);
     Db.NonQ(command);
 }