Beispiel #1
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Operatory> TableToList(DataTable table)
        {
            List <Operatory> retVal = new List <Operatory>();
            Operatory        operatory;

            foreach (DataRow row in table.Rows)
            {
                operatory = new Operatory();
                operatory.OperatoryNum   = PIn.Long(row["OperatoryNum"].ToString());
                operatory.OpName         = PIn.String(row["OpName"].ToString());
                operatory.Abbrev         = PIn.String(row["Abbrev"].ToString());
                operatory.ItemOrder      = PIn.Int(row["ItemOrder"].ToString());
                operatory.IsHidden       = PIn.Bool(row["IsHidden"].ToString());
                operatory.ProvDentist    = PIn.Long(row["ProvDentist"].ToString());
                operatory.ProvHygienist  = PIn.Long(row["ProvHygienist"].ToString());
                operatory.IsHygiene      = PIn.Bool(row["IsHygiene"].ToString());
                operatory.ClinicNum      = PIn.Long(row["ClinicNum"].ToString());
                operatory.SetProspective = PIn.Bool(row["SetProspective"].ToString());
                operatory.DateTStamp     = PIn.DateT(row["DateTStamp"].ToString());
                operatory.IsWebSched     = PIn.Bool(row["IsWebSched"].ToString());
                operatory.IsNewPatAppt   = PIn.Bool(row["IsNewPatAppt"].ToString());
                retVal.Add(operatory);
            }
            return(retVal);
        }
Beispiel #2
0
        ///<summary>Refresh all operatories</summary>
        public static void Refresh()
        {
            string command = "SELECT * FROM operatory "
                             + "ORDER BY ItemOrder";
            DataTable table = General.GetTable(command);

            List = new Operatory[table.Rows.Count];
            ArrayList AL = new ArrayList();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new Operatory();
                List[i].OperatoryNum  = PIn.PInt(table.Rows[i][0].ToString());
                List[i].OpName        = PIn.PString(table.Rows[i][1].ToString());
                List[i].Abbrev        = PIn.PString(table.Rows[i][2].ToString());
                List[i].ItemOrder     = PIn.PInt(table.Rows[i][3].ToString());
                List[i].IsHidden      = PIn.PBool(table.Rows[i][4].ToString());
                List[i].ProvDentist   = PIn.PInt(table.Rows[i][5].ToString());
                List[i].ProvHygienist = PIn.PInt(table.Rows[i][6].ToString());
                List[i].IsHygiene     = PIn.PBool(table.Rows[i][7].ToString());
                List[i].ClinicNum     = PIn.PInt(table.Rows[i][8].ToString());
                if (!List[i].IsHidden)
                {
                    AL.Add(List[i]);
                }
            }
            ListShort = new Operatory[AL.Count];
            AL.CopyTo(ListShort);
        }
Beispiel #3
0
        ///<summary></summary>
        public static Operatory CreateOperatory(string abbrev    = "", string opName      = "", long provDentist = 0, long provHygienist = 0, long clinicNum = 0
                                                , bool isHygiene = false, bool isWebSched = false, int itemOrder = 0, bool isNewPatAppt  = false)
        {
            Operatory op = new Operatory();

            op.Abbrev       = abbrev;
            op.ClinicNum    = clinicNum;
            op.IsHygiene    = isHygiene;
            op.IsWebSched   = isWebSched;
            op.IsNewPatAppt = isNewPatAppt;
            op.ItemOrder    = itemOrder;
            if (opName == "")
            {
                op.OpName = "ClinicNum: " + clinicNum.ToString();
            }
            else
            {
                op.OpName = opName;
            }
            op.ProvDentist   = provDentist;
            op.ProvHygienist = provHygienist;
            Operatories.Insert(op);
            if (abbrev == "")
            {
                op.Abbrev = op.OperatoryNum.ToString();
                Operatories.Update(op);
            }
            Operatories.RefreshCache();
            return(op);
        }
Beispiel #4
0
        private void butDown_Click(object sender, System.EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "You must first select a row.");
                return;
            }
            int selected = gridMain.GetSelectedIndex();

            if (selected == gridMain.Rows.Count - 1)
            {
                return;                //already at the bottom
            }
            Operatory selectedOp      = (Operatory)gridMain.Rows[selected].Tag;
            Operatory belowSelectedOp = (Operatory)gridMain.Rows[selected + 1].Tag;
            string    strErr;

            if (!CanReorderOps(selectedOp, belowSelectedOp, out strErr))
            {
                MessageBox.Show(strErr);                 //already translated
                return;
            }
            int selectedItemOrder = selectedOp.ItemOrder;

            //move selected item down
            selectedOp.ItemOrder = belowSelectedOp.ItemOrder;
            //move the one below it up
            belowSelectedOp.ItemOrder = selectedItemOrder;
            //Swap positions
            _listOps = _listOps.OrderBy(x => x.ItemOrder).ToList();
            //FillGrid();  //We don't fill grid anymore because it takes too long and we dont need to pull any new data into the DB.
            SwapGridMainLocations(selected, selected + 1);
            gridMain.SetSelected(selected + 1, true);
        }
Beispiel #5
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            Operatory opCur = new Operatory();

            opCur.IsNew = true;
            if (PrefC.HasClinicsEnabled && !comboClinic.IsAllSelected && !comboClinic.IsNothingSelected)
            {
                opCur.ClinicNum = comboClinic.SelectedClinicNum;
            }
            if (gridMain.SelectedIndices.Length > 0)          //a row is selected
            {
                opCur.ItemOrder = gridMain.SelectedIndices[0];
            }
            else
            {
                opCur.ItemOrder = _listOps.Count;              //goes at end of list
            }
            FormOperatoryEdit FormE = new FormOperatoryEdit(opCur);

            FormE.ListOps = _listOps;
            FormE.IsNew   = true;
            FormE.ShowDialog();
            if (FormE.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            FillGrid();
        }
Beispiel #6
0
 ///<summary>Inserts one Operatory into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Operatory operatory,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         operatory.OperatoryNum=ReplicationServers.GetKey("operatory","OperatoryNum");
     }
     string command="INSERT INTO operatory (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="OperatoryNum,";
     }
     command+="OpName,Abbrev,ItemOrder,IsHidden,ProvDentist,ProvHygienist,IsHygiene,ClinicNum,SetProspective) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(operatory.OperatoryNum)+",";
     }
     command+=
          "'"+POut.String(operatory.OpName)+"',"
         +"'"+POut.String(operatory.Abbrev)+"',"
         +    POut.Int   (operatory.ItemOrder)+","
         +    POut.Bool  (operatory.IsHidden)+","
         +    POut.Long  (operatory.ProvDentist)+","
         +    POut.Long  (operatory.ProvHygienist)+","
         +    POut.Bool  (operatory.IsHygiene)+","
         +    POut.Long  (operatory.ClinicNum)+","
         +    POut.Bool  (operatory.SetProspective)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         operatory.OperatoryNum=Db.NonQ(command,true);
     }
     return operatory.OperatoryNum;
 }
Beispiel #7
0
 ///<summary>Inserts one Operatory into the database.  Returns the new priKey.</summary>
 internal static long Insert(Operatory operatory)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         operatory.OperatoryNum=DbHelper.GetNextOracleKey("operatory","OperatoryNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(operatory,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     operatory.OperatoryNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(operatory,false);
     }
 }
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            Operatory opCur = new Operatory();

            if (gridMain.SelectedIndices.Length > 0)          //a row is selected
            {
                opCur.ItemOrder = gridMain.SelectedIndices[0];
            }
            else
            {
                opCur.ItemOrder = Operatories.List.Length;              //goes at end of list
            }
            FormOperatoryEdit FormE = new FormOperatoryEdit(opCur);

            FormE.IsNew = true;
            FormE.ShowDialog();
            if (FormE.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            if (gridMain.SelectedIndices.Length > 0)
            {
                //fix the itemOrder of every Operatory following this one
                for (int i = gridMain.SelectedIndices[0]; i < Operatories.List.Length; i++)
                {
                    Operatories.List[i].ItemOrder++;
                    Operatories.InsertOrUpdate(Operatories.List[i], false);
                }
            }
            FillGrid();
            changed = true;
        }
Beispiel #9
0
 ///<summary>Inserts one Operatory into the database.  Returns the new priKey.</summary>
 public static long Insert(Operatory operatory)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         operatory.OperatoryNum = DbHelper.GetNextOracleKey("operatory", "OperatoryNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(operatory, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     operatory.OperatoryNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(operatory, false));
     }
 }
Beispiel #10
0
 public RPN(string[] args)
 {
     this.inflix    = checkInput(args[0]);
     this.x         = Convert.ToDouble(args[1]);
     this.x_min     = Convert.ToDouble(args[2]);
     this.x_max     = Convert.ToDouble(args[3]);
     this.n         = Convert.ToDouble(args[4]);
     this.operatory = new Operatory();
 }
 ///<summary></summary>
 public FormOperatoryEdit(Operatory opCur)
 {
     //
     // Required for Windows Form Designer support
     //
     OpCur = opCur;
     InitializeComponent();
     Lan.F(this);
 }
Beispiel #12
0
        private void ButUpdateProvs_Click(object sender, EventArgs e)
        {
            if (IsNew)
            {
                MsgBox.Show(this, "Not for new operatories.");
                return;
            }
            //Check against cache. Instead of saving changes, make them get out and reopen. Safer and simpler.
            Operatory op = Operatories.GetOperatory(OpCur.OperatoryNum);

            if (op.OpName != textOpName.Text ||
                op.Abbrev != textAbbrev.Text ||
                op.IsHidden != checkIsHidden.Checked ||
                op.ClinicNum != comboClinic.SelectedClinicNum ||
                op.ProvDentist != comboProv.GetSelectedProvNum() ||
                op.ProvHygienist != comboHyg.GetSelectedProvNum() ||
                op.IsHygiene != checkIsHygiene.Checked ||
                op.SetProspective != checkSetProspective.Checked ||
                op.IsWebSched != checkIsWebSched.Checked)
            {
                MsgBox.Show(this, "Changes were detected above.  Save all changes, get completely out of the operatories window, and then re-enter.");
                return;
            }
            if (!Security.IsAuthorized(Permissions.Setup) || !Security.IsAuthorized(Permissions.AppointmentEdit))
            {
                return;
            }
            //Operatory operatory=Operatories.GetOperatory(contrApptPanel.OpNumClicked);
            if (Security.CurUser.ClinicIsRestricted && !Clinics.GetForUserod(Security.CurUser).Exists(x => x.ClinicNum == OpCur.ClinicNum))
            {
                MsgBox.Show(this, "You are restricted from accessing the clinic belonging to the selected operatory.  No changes will be made.");
                return;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.YesNo,
                             "WARNING: We recommend backing up your database before running this tool.  "
                             + "This tool may take a very long time to run and should be run after hours.  "
                             + "In addition, this tool could potentially change hundreds of appointments.  "
                             + "The changes made by this tool can only be manually reversed.  "
                             + "Are you sure you want to continue?"))
            {
                return;
            }
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0, Lan.g(this, "Update Provs on Future Appts tool run on operatory ") + OpCur.Abbrev + ".");
            List <Appointment> listAppts = Appointments.GetAppointmentsForOpsByPeriod(new List <long>()
            {
                OpCur.OperatoryNum
            }, DateTime.Now);                                                                                                                      //no end date, so all future
            List <Appointment> listApptsOld = new List <Appointment>();

            foreach (Appointment appt in listAppts)
            {
                listApptsOld.Add(appt.Copy());
            }
            ContrApptRef.MoveAppointments(listAppts, listApptsOld, OpCur);
            MsgBox.Show(this, "Done");
        }
Beispiel #13
0
 ///<summary>Sorts list of operatories by ItemOrder.</summary>
 public static int CompareOps(Operatory op1, Operatory op2)
 {
     if (op1.ItemOrder < op2.ItemOrder)
     {
         return(-1);
     }
     else if (op1.ItemOrder > op2.ItemOrder)
     {
         return(1);
     }
     return(0);
 }
Beispiel #14
0
 ///<summary></summary>
 public static void InsertOrUpdate(Operatory op, bool IsNew)
 {
     //if(){
     //throw new ApplicationException(Lan.g(this,""));
     //}
     if (IsNew)
     {
         Insert(op);
     }
     else
     {
         Update(op);
     }
 }
Beispiel #15
0
        ///<summary>Optionally pass in daysForSchedule to create a schedule for the number of days for each provider. Schedules will all be default 8 to 4.
        ///Note this is for non dynamic scheduling. daysForSchedule will include today, so pass in one extra if search starts with tomorrow.</summary>
        public static AppointmentSearchData CreateScheduleAndOpsForProv(long numOps, long numClinics, long provNum, int daysForSchedule = 0, long hygNum = 0, bool isDynamic = false)
        {
            AppointmentSearchData appSearchData = new UnitTestsCore.AppointmentSearchData();

            appSearchData.Patient = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name + "Pat");
            for (int i = 0; i < numOps; i++)
            {
                Operatory op = OperatoryT.CreateOperatory("abbr" + i, "opName" + i, provDentist: provNum, provHygienist: hygNum);
                appSearchData.ListOps.Add(op);
            }
            for (int i = 0; i < numClinics; i++)
            {
                Clinic clinic = ClinicT.CreateClinic("Clinic " + i);
                appSearchData.ListClinics.Add(clinic);
            }
            //create a general schedule for each prov. Can manipulate later.
            if (daysForSchedule > 0)
            {
                for (int j = 0; j < daysForSchedule; j++)
                {
                    if (DateTime.Today.AddDays(j).DayOfWeek == DayOfWeek.Saturday || DateTime.Today.AddDays(j).DayOfWeek == DayOfWeek.Sunday)
                    {
                        daysForSchedule++;                        //add another day to the loop since we want to skip but still add the schedule on a weekday
                        continue;
                    }
                    Schedule sched;
                    if (isDynamic)
                    {
                        //create schedule for provider but do not assign it to an operatory
                        sched = ScheduleT.CreateSchedule(DateTime.Today.AddDays(j)
                                                         , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 8, 0, 0).TimeOfDay
                                                         , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 16, 0, 0).TimeOfDay
                                                         , ScheduleType.Provider, provNum: provNum, listOpNums: new List <long>()
                        {
                        });                                                                                             //default to 8-4
                    }
                    else
                    {
                        sched = ScheduleT.CreateSchedule(DateTime.Today.AddDays(j)
                                                         , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 8, 0, 0).TimeOfDay
                                                         , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 16, 0, 0).TimeOfDay
                                                         , ScheduleType.Provider, provNum: provNum, listOpNums: appSearchData.ListOps.Select(x => x.OperatoryNum).ToList());//default to 8-4
                    }

                    appSearchData.ListSchedules.Add(sched);
                }
            }
            return(appSearchData);
        }
Beispiel #16
0
 ///<summary>Returns true if Update(Operatory,Operatory) 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(Operatory operatory, Operatory oldOperatory)
 {
     if (operatory.OpName != oldOperatory.OpName)
     {
         return(true);
     }
     if (operatory.Abbrev != oldOperatory.Abbrev)
     {
         return(true);
     }
     if (operatory.ItemOrder != oldOperatory.ItemOrder)
     {
         return(true);
     }
     if (operatory.IsHidden != oldOperatory.IsHidden)
     {
         return(true);
     }
     if (operatory.ProvDentist != oldOperatory.ProvDentist)
     {
         return(true);
     }
     if (operatory.ProvHygienist != oldOperatory.ProvHygienist)
     {
         return(true);
     }
     if (operatory.IsHygiene != oldOperatory.IsHygiene)
     {
         return(true);
     }
     if (operatory.ClinicNum != oldOperatory.ClinicNum)
     {
         return(true);
     }
     if (operatory.SetProspective != oldOperatory.SetProspective)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (operatory.IsWebSched != oldOperatory.IsWebSched)
     {
         return(true);
     }
     if (operatory.IsNewPatAppt != oldOperatory.IsNewPatAppt)
     {
         return(true);
     }
     return(false);
 }
Beispiel #17
0
 ///<summary>Inserts one Operatory into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Operatory operatory)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(operatory, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             operatory.OperatoryNum = DbHelper.GetNextOracleKey("operatory", "OperatoryNum");                  //Cacheless method
         }
         return(InsertNoCache(operatory, true));
     }
 }
Beispiel #18
0
        ///<summary></summary>
        private static void Insert(Operatory op)
        {
            string command = "INSERT INTO operatory (OpName,Abbrev,ItemOrder,IsHidden,ProvDentist,ProvHygienist,"
                             + "IsHygiene,ClinicNum) VALUES("
                             + "'" + POut.PString(op.OpName) + "', "
                             + "'" + POut.PString(op.Abbrev) + "', "
                             + "'" + POut.PInt(op.ItemOrder) + "', "
                             + "'" + POut.PBool(op.IsHidden) + "', "
                             + "'" + POut.PInt(op.ProvDentist) + "', "
                             + "'" + POut.PInt(op.ProvHygienist) + "', "
                             + "'" + POut.PBool(op.IsHygiene) + "', "
                             + "'" + POut.PInt(op.ClinicNum) + "')";

            op.OperatoryNum = General.NonQ(command, true);
        }
Beispiel #19
0
        ///<summary></summary>
        private static void Update(Operatory op)
        {
            string command = "UPDATE operatory SET "
                             + "OpName = '" + POut.PString(op.OpName) + "'"
                             + ",Abbrev = '" + POut.PString(op.Abbrev) + "'"
                             + ",ItemOrder = '" + POut.PInt(op.ItemOrder) + "'"
                             + ",IsHidden = '" + POut.PBool(op.IsHidden) + "'"
                             + ",ProvDentist = '" + POut.PInt(op.ProvDentist) + "'"
                             + ",ProvHygienist = '" + POut.PInt(op.ProvHygienist) + "'"
                             + ",IsHygiene = '" + POut.PBool(op.IsHygiene) + "'"
                             + ",ClinicNum = '" + POut.PInt(op.ClinicNum) + "'"
                             + " WHERE OperatoryNum = '" + POut.PInt(op.OperatoryNum) + "'";

            //MessageBox.Show(string command);
            General.NonQ(command);
        }
Beispiel #20
0
        ///<summary>Updates one Operatory in the database.</summary>
        public static void Update(Operatory operatory)
        {
            string command = "UPDATE operatory SET "
                             + "OpName        = '" + POut.String(operatory.OpName) + "', "
                             + "Abbrev        = '" + POut.String(operatory.Abbrev) + "', "
                             + "ItemOrder     =  " + POut.Int(operatory.ItemOrder) + ", "
                             + "IsHidden      =  " + POut.Bool(operatory.IsHidden) + ", "
                             + "ProvDentist   =  " + POut.Long(operatory.ProvDentist) + ", "
                             + "ProvHygienist =  " + POut.Long(operatory.ProvHygienist) + ", "
                             + "IsHygiene     =  " + POut.Bool(operatory.IsHygiene) + ", "
                             + "ClinicNum     =  " + POut.Long(operatory.ClinicNum) + ", "
                             + "SetProspective=  " + POut.Bool(operatory.SetProspective) + " "
                             + "WHERE OperatoryNum = " + POut.Long(operatory.OperatoryNum);

            Db.NonQ(command);
        }
Beispiel #21
0
 ///<summary>Returns true if the two operatories can be reordered. Returns false and fills in the error string if they cannot.</summary>
 private bool CanReorderOps(Operatory op1, Operatory op2, out string strErrorMsg)
 {
     strErrorMsg = "";
     if (!PrefC.HasClinicsEnabled || comboClinic.IsAllSelected)
     {
         return(true);
     }
     if (!op1.IsInHQView && !op2.IsInHQView)
     {
         return(true);
     }
     strErrorMsg = Lan.g(this, "You cannot change the order of the Operatories") + " '" + op1.Abbrev + "' " + Lan.g(this, "and") + " '" + op2.Abbrev + "' "
                   + Lan.g(this, "with Clinic") + " '" + comboClinic.SelectedAbbr + "' "
                   + Lan.g(this, "selected because it is also a member of a Headquarters Appointment View.") + " "
                   + Lan.g(this, "You must set your clinic selection to 'All' to reorder these operatories.");
     return(false);
 }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Operatory> TableToList(DataTable table){
			List<Operatory> retVal=new List<Operatory>();
			Operatory operatory;
			for(int i=0;i<table.Rows.Count;i++) {
				operatory=new Operatory();
				operatory.OperatoryNum  = PIn.Long  (table.Rows[i]["OperatoryNum"].ToString());
				operatory.OpName        = PIn.String(table.Rows[i]["OpName"].ToString());
				operatory.Abbrev        = PIn.String(table.Rows[i]["Abbrev"].ToString());
				operatory.ItemOrder     = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				operatory.IsHidden      = PIn.Bool  (table.Rows[i]["IsHidden"].ToString());
				operatory.ProvDentist   = PIn.Long  (table.Rows[i]["ProvDentist"].ToString());
				operatory.ProvHygienist = PIn.Long  (table.Rows[i]["ProvHygienist"].ToString());
				operatory.IsHygiene     = PIn.Bool  (table.Rows[i]["IsHygiene"].ToString());
				operatory.ClinicNum     = PIn.Long  (table.Rows[i]["ClinicNum"].ToString());
				operatory.SetProspective= PIn.Bool  (table.Rows[i]["SetProspective"].ToString());
				retVal.Add(operatory);
			}
			return retVal;
		}
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            Operatory         opCur   = (Operatory)gridMain.ListGridRows[e.Row].Tag;
            FormOperatoryEdit FormOE  = new FormOperatoryEdit(opCur);
            List <Operatory>  listOld = new List <Operatory>();

            foreach (Operatory op in _listOps)
            {
                listOld.Add(op.Copy());
            }
            FormOE.ListOps = _listOps;
            FormOE.ShowDialog();
            if (FormOE.DialogResult == DialogResult.OK)
            {
                Operatories.Sync(_listOps, listOld);
                FillGrid();
                DataValid.SetInvalid(InvalidType.Operatories);
            }
        }
Beispiel #24
0
        ///<summary>Inserts one Operatory into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(Operatory operatory, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO operatory (";

            if (!useExistingPK && isRandomKeys)
            {
                operatory.OperatoryNum = ReplicationServers.GetKeyNoCache("operatory", "OperatoryNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "OperatoryNum,";
            }
            command += "OpName,Abbrev,ItemOrder,IsHidden,ProvDentist,ProvHygienist,IsHygiene,ClinicNum,SetProspective,IsWebSched,IsNewPatAppt) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(operatory.OperatoryNum) + ",";
            }
            command +=
                "'" + POut.String(operatory.OpName) + "',"
                + "'" + POut.String(operatory.Abbrev) + "',"
                + POut.Int(operatory.ItemOrder) + ","
                + POut.Bool(operatory.IsHidden) + ","
                + POut.Long(operatory.ProvDentist) + ","
                + POut.Long(operatory.ProvHygienist) + ","
                + POut.Bool(operatory.IsHygiene) + ","
                + POut.Long(operatory.ClinicNum) + ","
                + POut.Bool(operatory.SetProspective) + ","
                //DateTStamp can only be set by MySQL
                + POut.Bool(operatory.IsWebSched) + ","
                + POut.Bool(operatory.IsNewPatAppt) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                operatory.OperatoryNum = Db.NonQ(command, true, "OperatoryNum", "operatory");
            }
            return(operatory.OperatoryNum);
        }
Beispiel #25
0
        ///<summary>Optionally pass in daysForSchedule to create a schedule for the number of days for each provider. Schedules will all be default 8 to 4. </summary>
        public static AppointmentSearchData CreateDataForAppointmentSearch(long numProvs, long numOps, long numClinics, int daysForSchedule = 0)
        {
            AppointmentSearchData appSearchData = new UnitTestsCore.AppointmentSearchData();

            appSearchData.Patient = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name + "Pat");
            for (int i = 0; i < numOps; i++)
            {
                Operatory op = OperatoryT.CreateOperatory("abbr" + i, "opName" + i);
                appSearchData.ListOps.Add(op);
            }
            for (int i = 0; i < numClinics; i++)
            {
                Clinic clinic = ClinicT.CreateClinic("Clinic " + i);
                appSearchData.ListClinics.Add(clinic);
            }
            //loop through and create all the providers.
            for (int i = 0; i < numProvs; i++)
            {
                long prov = ProviderT.CreateProvider(MethodBase.GetCurrentMethod().Name + i);
                appSearchData.ListProvNums.Add(prov);
                //create a general schedule for each prov. Can manipulate later.
                if (daysForSchedule > 0)
                {
                    for (int j = 0; j < daysForSchedule; j++)
                    {
                        if (DateTime.Today.AddDays(j).DayOfWeek == DayOfWeek.Saturday || DateTime.Today.AddDays(j).DayOfWeek == DayOfWeek.Sunday)
                        {
                            daysForSchedule++;                            //add another day to the loop since we want to skip but still add the schedule on a weekday
                            continue;
                        }
                        Schedule sched = ScheduleT.CreateSchedule(DateTime.Today.AddDays(j)
                                                                  , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 8, 0, 0).TimeOfDay
                                                                  , new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(j).Day, 16, 0, 0).TimeOfDay
                                                                  , ScheduleType.Provider, provNum: prov);//default to tomorrow from 8-4
                    }
                }
            }
            return(appSearchData);
        }
Beispiel #26
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Operatory> TableToList(DataTable table)
        {
            List <Operatory> retVal = new List <Operatory>();
            Operatory        operatory;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                operatory = new Operatory();
                operatory.OperatoryNum   = PIn.Long(table.Rows[i]["OperatoryNum"].ToString());
                operatory.OpName         = PIn.String(table.Rows[i]["OpName"].ToString());
                operatory.Abbrev         = PIn.String(table.Rows[i]["Abbrev"].ToString());
                operatory.ItemOrder      = PIn.Int(table.Rows[i]["ItemOrder"].ToString());
                operatory.IsHidden       = PIn.Bool(table.Rows[i]["IsHidden"].ToString());
                operatory.ProvDentist    = PIn.Long(table.Rows[i]["ProvDentist"].ToString());
                operatory.ProvHygienist  = PIn.Long(table.Rows[i]["ProvHygienist"].ToString());
                operatory.IsHygiene      = PIn.Bool(table.Rows[i]["IsHygiene"].ToString());
                operatory.ClinicNum      = PIn.Long(table.Rows[i]["ClinicNum"].ToString());
                operatory.SetProspective = PIn.Bool(table.Rows[i]["SetProspective"].ToString());
                retVal.Add(operatory);
            }
            return(retVal);
        }
Beispiel #27
0
        public void Reactivations_GetReactivationList_DaysPastHasFutureAppt()
        {
            string    name    = MethodBase.GetCurrentMethod().Name;
            Clinic    clinic  = ClinicT.CreateClinic(name);
            long      provNum = ProviderT.CreateProvider(name);
            Operatory op      = OperatoryT.CreateOperatory(name, provDentist: provNum, clinicNum: clinic.ClinicNum);
            Patient   pat     = PatientT.CreatePatient(name, provNum, clinic.ClinicNum, TestEmaiAddress, TestPatPhone, ContactMethod.Mail);
            //Patient has not been seen since further in the past than the ReactivationDaysPast preference.
            Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50, procDate: DateTime.Now.AddYears(-3), provNum: provNum);   //3 year old proc
            //Patient has been contacted, and the ReactivationContactInterval has elapsed.
            Commlog comm = new Commlog()
            {
                PatNum         = pat.PatNum,
                CommDateTime   = DateTime.Now.AddYears(-1),
                CommType       = _reactivationCommLogType,
                Mode_          = CommItemMode.Email,
                SentOrReceived = CommSentOrReceived.Sent,
                CommSource     = CommItemSource.ApptReminder,
            };

            comm.CommlogNum = Commlogs.Insert(comm);
            //Patient has not been marked "Do Not Contact"
            Reactivations.Insert(new Reactivation()
            {
                PatNum       = pat.PatNum,
                DoNotContact = false,
            });
            //Patient has a future appointment scheduled.
            AppointmentT.CreateAppointment(pat.PatNum, DateTime.Today.AddDays(1), op.OperatoryNum, provNum);
            DateTime dateSince = DateTime.Today.AddDays(-PrefC.GetInt(PrefName.ReactivationDaysPast));
            DateTime dateStop  = dateSince.AddMonths(-36);
            //Confirm that the patient does not in the Reactivation List
            DataTable tbl = Reactivations.GetReactivationList(dateSince, dateStop, false, false, true, provNum, clinic.ClinicNum, 0, 0
                                                              , ReactivationListSort.LastContacted, RecallListShowNumberReminders.One);

            //No patients in the list
            Assert.AreEqual(0, tbl.Rows.Count);
        }
Beispiel #28
0
        ///<summary>Inserts one Operatory into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Operatory operatory, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                operatory.OperatoryNum = ReplicationServers.GetKey("operatory", "OperatoryNum");
            }
            string command = "INSERT INTO operatory (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "OperatoryNum,";
            }
            command += "OpName,Abbrev,ItemOrder,IsHidden,ProvDentist,ProvHygienist,IsHygiene,ClinicNum,SetProspective) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(operatory.OperatoryNum) + ",";
            }
            command +=
                "'" + POut.String(operatory.OpName) + "',"
                + "'" + POut.String(operatory.Abbrev) + "',"
                + POut.Int(operatory.ItemOrder) + ","
                + POut.Bool(operatory.IsHidden) + ","
                + POut.Long(operatory.ProvDentist) + ","
                + POut.Long(operatory.ProvHygienist) + ","
                + POut.Bool(operatory.IsHygiene) + ","
                + POut.Long(operatory.ClinicNum) + ","
                + POut.Bool(operatory.SetProspective) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                operatory.OperatoryNum = Db.NonQ(command, true);
            }
            return(operatory.OperatoryNum);
        }
Beispiel #29
0
 ///<summary>Fills visProvs, visOps, forCurView, apptRows, and rowsPerIncr based on the appointment view passed in and whether it is for the week view or not.  This method uses 'out' variables so that the encompassing logic doesn't ALWAYS affect the global static variables used to draw the appointment views.  We don't want the following logic to affect the global static variables in the case where we are trying to get information needed to filter the waiting room.</summary>
 public static void FillForApptView(bool isWeekly, ApptView apptViewCur, out List <Provider> visProvs, out List <Operatory> visOps,
                                    out List <ApptViewItem> forCurView, out List <ApptViewItem> apptRows, out int rowsPerIncr, bool isFillVisProvs = true)
 {
     forCurView = new List <ApptViewItem>();
     visProvs   = new List <Provider>();
     visOps     = new List <Operatory>();
     apptRows   = new List <ApptViewItem>();
     //If there are no appointment views set up (therefore, none selected), then use a hard-coded default view.
     if (ApptViews.IsNoneView(apptViewCur))
     {
         //make visible ops exactly the same as the short ops list (all except hidden)
         visOps.AddRange(
             Operatories.GetWhere(x => !PrefC.HasClinicsEnabled ||                  //if clinics disabled
                                  Clinics.ClinicNum == 0 ||              //or if program level ClinicNum set to Headquarters
                                  x.ClinicNum == Clinics.ClinicNum                 //or this is the program level ClinicNum
                                  , true)
             );
         if (isFillVisProvs)
         {
             if (PrefC.HasClinicsEnabled)
             {
                 foreach (Operatory op in visOps)
                 {
                     Provider provDent = Providers.GetProv(op.ProvDentist);
                     Provider provHyg  = Providers.GetProv(op.ProvHygienist);
                     if (provDent != null)
                     {
                         visProvs.Add(provDent);
                     }
                     if (provHyg != null)
                     {
                         visProvs.Add(provHyg);
                     }
                 }
             }
             else
             {
                 //make visible provs exactly the same as the prov list (all except hidden)
                 visProvs.AddRange(Providers.GetDeepCopy(true));
             }
         }
         //Hard coded elements showing
         apptRows.Add(new ApptViewItem("PatientName", 0, Color.Black));
         apptRows.Add(new ApptViewItem("ASAP", 1, Color.DarkRed));
         apptRows.Add(new ApptViewItem("MedUrgNote", 2, Color.DarkRed));
         apptRows.Add(new ApptViewItem("PremedFlag", 3, Color.DarkRed));
         apptRows.Add(new ApptViewItem("Lab", 4, Color.DarkRed));
         apptRows.Add(new ApptViewItem("Procs", 5, Color.Black));
         apptRows.Add(new ApptViewItem("Note", 6, Color.Black));
         rowsPerIncr = 1;
     }
     //An appointment view is selected, so add provs and ops from the view to our lists of indexes.
     else
     {
         List <ApptViewItem> listApptViewItems = ApptViewItems.GetWhere(x => x.ApptViewNum == apptViewCur.ApptViewNum);
         for (int i = 0; i < listApptViewItems.Count; i++)
         {
             forCurView.Add(listApptViewItems[i]);
             if (listApptViewItems[i].OpNum > 0)                   //op
             {
                 if (apptViewCur.OnlyScheduledProvs && !isWeekly)
                 {
                     continue;                            //handled below in AddOpsForScheduledProvs
                 }
                 Operatory op = Operatories.GetFirstOrDefault(x => x.OperatoryNum == listApptViewItems[i].OpNum, true);
                 if (op != null)
                 {
                     visOps.Add(op);
                 }
             }
             else if (listApptViewItems[i].ProvNum > 0)                   //prov
             {
                 if (!isFillVisProvs)
                 {
                     continue;
                 }
                 Provider prov = Providers.GetFirstOrDefault(x => x.ProvNum == listApptViewItems[i].ProvNum, true);
                 if (prov != null)
                 {
                     visProvs.Add(prov);
                 }
             }
             else                      //element or apptfielddef
             {
                 apptRows.Add(listApptViewItems[i]);
             }
         }
         rowsPerIncr = apptViewCur.RowsPerIncr;
     }
     //Remove any duplicates before return.
     visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList();
     if (isFillVisProvs)
     {
         visProvs = visProvs.GroupBy(x => x.ProvNum).Select(x => x.First()).ToList();
     }
 }
Beispiel #30
0
        ///<summary>When looking at a daily appointment module and the current appointment view is has 'OnlyScheduleProvs' turned on, this method will dynamically add additional operatories to visOps for providers that are scheduled to work.</summary>
        public static void AddOpsForScheduledProvs(bool isWeekly, List <Schedule> dailySched, ApptView apptViewCur, ref List <Operatory> visOps)
        {
            //if this appt view has the option to show only scheduled providers and this is daily view.
            //Remember that there is no intelligence in weekly view for this option, and it behaves just like it always did.
            if (ApptViews.IsNoneView(apptViewCur) ||
                dailySched == null ||
                visOps == null ||
                !apptViewCur.OnlyScheduledProvs ||
                isWeekly)
            {
                return;
            }
            //intelligently decide what ops to show.  It's based on the schedule for the day.
            //visOps will be totally empty right now because it looped out of the above section of code.
            List <long>      listSchedOps;
            bool             opAdded;
            int              indexOp;
            List <Operatory> listOpsShort       = Operatories.GetDeepCopy(true);
            List <long>      listApptViewOpNums = ApptViewItems.GetOpsForView(apptViewCur.ApptViewNum);

            for (int i = 0; i < listOpsShort.Count; i++)       //loop through all ops for all views (except the hidden ones, of course)
            //If this operatory was not one of the selected Ops from the Appt View Edit window, skip it.
            {
                if (!listApptViewOpNums.Contains(listOpsShort[i].OperatoryNum))
                {
                    continue;
                }
                //find any applicable sched for the op
                opAdded = false;
                for (int s = 0; s < dailySched.Count; s++)
                {
                    if (dailySched[s].SchedType != ScheduleType.Provider)
                    {
                        continue;
                    }
                    if (dailySched[s].StartTime == new TimeSpan(0))                   //skip if block starts at midnight.
                    {
                        continue;
                    }
                    if (dailySched[s].StartTime == dailySched[s].StopTime)                   //skip if block has no length.
                    {
                        continue;
                    }
                    if (apptViewCur.OnlySchedAfterTime > new TimeSpan(0, 0, 0))
                    {
                        if (dailySched[s].StartTime < apptViewCur.OnlySchedAfterTime ||
                            dailySched[s].StopTime < apptViewCur.OnlySchedAfterTime)
                        {
                            continue;
                        }
                    }
                    if (apptViewCur.OnlySchedBeforeTime > new TimeSpan(0, 0, 0))
                    {
                        if (dailySched[s].StartTime > apptViewCur.OnlySchedBeforeTime ||
                            dailySched[s].StopTime > apptViewCur.OnlySchedBeforeTime)
                        {
                            continue;
                        }
                    }
                    //this 'sched' must apply to this situation.
                    //listSchedOps is the ops for this 'sched'.
                    listSchedOps = dailySched[s].Ops;
                    //Add all the ops for this 'sched' to the list of visible ops
                    for (int p = 0; p < listSchedOps.Count; p++)
                    {
                        //Filter the ops if the clinic option was set for the appt view.
                        if (apptViewCur.ClinicNum > 0 && apptViewCur.ClinicNum != Operatories.GetOperatory(listSchedOps[p]).ClinicNum)
                        {
                            continue;
                        }
                        if (listSchedOps[p] == listOpsShort[i].OperatoryNum)
                        {
                            Operatory op = listOpsShort[i];
                            indexOp = Operatories.GetOrder(listSchedOps[p]);
                            if (indexOp != -1 && !visOps.Contains(op))                           //prevents adding duplicate ops
                            {
                                visOps.Add(op);
                                opAdded = true;
                                break;
                            }
                        }
                    }
                    //If the provider is not scheduled to any op(s), add their default op(s).
                    if (listOpsShort[i].ProvDentist == dailySched[s].ProvNum && listSchedOps.Count == 0)                 //only if the sched does not specify any ops
                    //Only add the op if the clinic option was not set in the appt view or if the op is assigned to that clinic.
                    {
                        if (apptViewCur.ClinicNum == 0 || apptViewCur.ClinicNum == listOpsShort[i].ClinicNum)
                        {
                            indexOp = Operatories.GetOrder(listOpsShort[i].OperatoryNum);
                            if (indexOp != -1 && !visOps.Contains(listOpsShort[i]))
                            {
                                visOps.Add(listOpsShort[i]);
                                opAdded = true;
                            }
                        }
                    }
                    if (opAdded)
                    {
                        break;                        //break out of the loop of schedules.  Continue with the next op.
                    }
                }
            }
            //Remove any duplicates before return.
            visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList();
        }
		///<summary>Updates one Operatory in the database.</summary>
		public static void Update(Operatory operatory){
			string command="UPDATE operatory SET "
				+"OpName        = '"+POut.String(operatory.OpName)+"', "
				+"Abbrev        = '"+POut.String(operatory.Abbrev)+"', "
				+"ItemOrder     =  "+POut.Int   (operatory.ItemOrder)+", "
				+"IsHidden      =  "+POut.Bool  (operatory.IsHidden)+", "
				+"ProvDentist   =  "+POut.Long  (operatory.ProvDentist)+", "
				+"ProvHygienist =  "+POut.Long  (operatory.ProvHygienist)+", "
				+"IsHygiene     =  "+POut.Bool  (operatory.IsHygiene)+", "
				+"ClinicNum     =  "+POut.Long  (operatory.ClinicNum)+", "
				+"SetProspective=  "+POut.Bool  (operatory.SetProspective)+" "
				+"WHERE OperatoryNum = "+POut.Long(operatory.OperatoryNum);
			Db.NonQ(command);
		}
Beispiel #32
0
        ///<summary>Offers to use unscheduled appt.  Shows ApptEdit window. Sets Prospective, if necessary.  Fires Automation triggers.  ListAptNumsSelected will contain the AptNum of the new appointment.</summary>
        public void MakeAppointment()
        {
            //Check to see if the patient has any unscheduled appointments and inform the user.
            List <Appointment> listUnschedAppts = Appointments.GetUnschedApptsForPat(_patCur.PatNum);

            //Per Nathan, pinboard appointments will not be considered unscheduled for this logic.
            listUnschedAppts.RemoveAll(x => x.AptNum.In(_listPinboardApptNums));
            FormApptEdit formApptEdit            = null;
            long         aptNum                  = 0;
            bool         isSchedulingUnscheduled = false;

            if (listUnschedAppts.Count > 0 &&
                MsgBox.Show(this, MsgBoxButtons.YesNo, "This patient has an unscheduled appointment, would you like to use an existing unscheduled appointment?"))
            {
                if (listUnschedAppts.Count == 1)
                {
                    aptNum = listUnschedAppts[0].AptNum;
                }
                else                  //Multiple unscheduled appointments, let the user pick which one to use.
                {
                    FormUnschedListPatient formUnschedListPatient = new FormUnschedListPatient(_patCur);
                    if (formUnschedListPatient.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    //Use the appointment the user selected.
                    aptNum = formUnschedListPatient.SelectedAppt.AptNum;
                }
                isSchedulingUnscheduled = true;
            }
            formApptEdit       = new FormApptEdit(aptNum, patNum: _patCur.PatNum, useApptDrawingSettings: IsInitialDoubleClick, patient: _patCur, dateTNew: DateTNew, opNumNew: OpNumNew);
            formApptEdit.IsNew = (aptNum == 0);
            formApptEdit.IsSchedulingUnscheduledAppt = isSchedulingUnscheduled;
            formApptEdit.ShowDialog();
            if (formApptEdit.DialogResult != DialogResult.OK)
            {
                return;
            }
            Appointment aptCur = formApptEdit.GetAppointmentCur();

            if (IsInitialDoubleClick)
            {
                if (isSchedulingUnscheduled)                 //User double clicked in Appointment Module, intending to schedule appointment at a specific time/op/etc.
                {
                    Appointment aptOld = aptCur.Copy();
                    aptCur.AptDateTime = DateTimeClicked;
                    aptCur.Op          = OpNumClicked;
                    if (_patCur != null && _patCur.AskToArriveEarly > 0)
                    {
                        aptCur.DateTimeAskedToArrive = aptCur.AptDateTime.AddMinutes(-_patCur.AskToArriveEarly);
                    }
                    aptCur           = Appointments.AssignFieldsForOperatory(aptCur);
                    aptCur.AptStatus = ApptStatus.Scheduled;
                    Appointments.Update(aptCur, aptOld);
                }
                //Change PatStatus to Prospective or from Prospective.
                Operatory opCur = Operatories.GetOperatory(aptCur.Op);
                if (opCur != null)
                {
                    if (opCur.SetProspective && _patCur.PatStatus != PatientStatus.Prospective)                    //Don't need to prompt if patient is already prospective.
                    {
                        if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Patient's status will be set to Prospective."))
                        {
                            Patient patOld = _patCur.Copy();
                            _patCur.PatStatus = PatientStatus.Prospective;
                            Patients.Update(_patCur, patOld);
                        }
                    }
                    else if (!opCur.SetProspective && _patCur.PatStatus == PatientStatus.Prospective)
                    {
                        if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Patient's status will change from Prospective to Patient."))
                        {
                            Patient patOld = _patCur.Copy();
                            _patCur.PatStatus = PatientStatus.Patient;
                            Patients.Update(_patCur, patOld);
                        }
                    }
                }
            }
            ListAptNumsSelected.Add(aptCur.AptNum);
            if (IsInitialDoubleClick)
            {
                _otherResult = OtherResult.CreateNew;
            }
            else
            {
                _otherResult = OtherResult.NewToPinBoard;
            }
            if (aptCur.IsNewPatient)
            {
                AutomationL.Trigger(AutomationTrigger.CreateApptNewPat, null, aptCur.PatNum, aptCur.AptNum);
            }
            AutomationL.Trigger(AutomationTrigger.CreateAppt, null, aptCur.PatNum, aptCur.AptNum);
            DialogResult = DialogResult.OK;
        }
Beispiel #33
0
        private void butNew_Click(object sender, System.EventArgs e)
        {
            Appointment AptCur = new Appointment();

            AptCur.PatNum = PatCur.PatNum;
            if (PatCur.DateFirstVisit.Year < 1880 &&
                !Procedures.AreAnyComplete(PatCur.PatNum))                   //this only runs if firstVisit blank
            {
                AptCur.IsNewPatient = true;
            }
            AptCur.Pattern = "/X/";
            if (PatCur.PriProv == 0)
            {
                AptCur.ProvNum = PIn.PInt(((Pref)PrefB.HList["PracticeDefaultProv"]).ValueString);
            }
            else
            {
                AptCur.ProvNum = PatCur.PriProv;
            }
            AptCur.ProvHyg   = PatCur.SecProv;
            AptCur.AptStatus = ApptStatus.Scheduled;
            AptCur.ClinicNum = PatCur.ClinicNum;
            if (InitialClick)            //initially double clicked on appt module
            {
                DateTime d;
                if (ContrApptSheet.IsWeeklyView)
                {
                    d = ContrAppt.WeekStartDate.AddDays(ContrAppt.SheetClickedonDay);
                }
                else
                {
                    d = Appointments.DateSelected;
                }
                int minutes = (int)(ContrAppt.SheetClickedonMin / ContrApptSheet.MinPerIncr) * ContrApptSheet.MinPerIncr;
                AptCur.AptDateTime = new DateTime(d.Year, d.Month, d.Day
                                                  , ContrAppt.SheetClickedonHour, minutes, 0);
                AptCur.Op = ContrAppt.SheetClickedonOp;
                Operatory curOp = Operatories.GetOperatory(AptCur.Op);
                if (curOp.ProvDentist != 0)
                {
                    AptCur.ProvNum = curOp.ProvDentist;
                }
                AptCur.ProvHyg   = curOp.ProvHygienist;
                AptCur.IsHygiene = curOp.IsHygiene;
                AptCur.ClinicNum = curOp.ClinicNum;
                try {
                    Appointments.InsertOrUpdate(AptCur, null, true);
                }
                catch (ApplicationException ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                //new appt will be placed on pinboard instead of specific time
            }
            try{
                Appointments.InsertOrUpdate(AptCur, null, true);
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            FormApptEdit FormApptEdit2 = new FormApptEdit(AptCur.AptNum);

            FormApptEdit2.IsNew = true;
            FormApptEdit2.ShowDialog();
            if (FormApptEdit2.DialogResult != DialogResult.OK)
            {
                return;
            }
            AptSelected = AptCur.AptNum;
            if (InitialClick)
            {
                oResult = OtherResult.CreateNew;
            }
            else
            {
                oResult = OtherResult.NewToPinBoard;
            }
            DialogResult = DialogResult.OK;
        }
		///<summary>Updates one Operatory 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>
		public static void Update(Operatory operatory,Operatory oldOperatory){
			string command="";
			if(operatory.OpName != oldOperatory.OpName) {
				if(command!=""){ command+=",";}
				command+="OpName = '"+POut.String(operatory.OpName)+"'";
			}
			if(operatory.Abbrev != oldOperatory.Abbrev) {
				if(command!=""){ command+=",";}
				command+="Abbrev = '"+POut.String(operatory.Abbrev)+"'";
			}
			if(operatory.ItemOrder != oldOperatory.ItemOrder) {
				if(command!=""){ command+=",";}
				command+="ItemOrder = "+POut.Int(operatory.ItemOrder)+"";
			}
			if(operatory.IsHidden != oldOperatory.IsHidden) {
				if(command!=""){ command+=",";}
				command+="IsHidden = "+POut.Bool(operatory.IsHidden)+"";
			}
			if(operatory.ProvDentist != oldOperatory.ProvDentist) {
				if(command!=""){ command+=",";}
				command+="ProvDentist = "+POut.Long(operatory.ProvDentist)+"";
			}
			if(operatory.ProvHygienist != oldOperatory.ProvHygienist) {
				if(command!=""){ command+=",";}
				command+="ProvHygienist = "+POut.Long(operatory.ProvHygienist)+"";
			}
			if(operatory.IsHygiene != oldOperatory.IsHygiene) {
				if(command!=""){ command+=",";}
				command+="IsHygiene = "+POut.Bool(operatory.IsHygiene)+"";
			}
			if(operatory.ClinicNum != oldOperatory.ClinicNum) {
				if(command!=""){ command+=",";}
				command+="ClinicNum = "+POut.Long(operatory.ClinicNum)+"";
			}
			if(operatory.SetProspective != oldOperatory.SetProspective) {
				if(command!=""){ command+=",";}
				command+="SetProspective = "+POut.Bool(operatory.SetProspective)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE operatory SET "+command
				+" WHERE OperatoryNum = "+POut.Long(operatory.OperatoryNum);
			Db.NonQ(command);
		}
Beispiel #35
0
        ///<summary>Updates one Operatory 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>
        public static void Update(Operatory operatory, Operatory oldOperatory)
        {
            string command = "";

            if (operatory.OpName != oldOperatory.OpName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OpName = '" + POut.String(operatory.OpName) + "'";
            }
            if (operatory.Abbrev != oldOperatory.Abbrev)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Abbrev = '" + POut.String(operatory.Abbrev) + "'";
            }
            if (operatory.ItemOrder != oldOperatory.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(operatory.ItemOrder) + "";
            }
            if (operatory.IsHidden != oldOperatory.IsHidden)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsHidden = " + POut.Bool(operatory.IsHidden) + "";
            }
            if (operatory.ProvDentist != oldOperatory.ProvDentist)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvDentist = " + POut.Long(operatory.ProvDentist) + "";
            }
            if (operatory.ProvHygienist != oldOperatory.ProvHygienist)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvHygienist = " + POut.Long(operatory.ProvHygienist) + "";
            }
            if (operatory.IsHygiene != oldOperatory.IsHygiene)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsHygiene = " + POut.Bool(operatory.IsHygiene) + "";
            }
            if (operatory.ClinicNum != oldOperatory.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(operatory.ClinicNum) + "";
            }
            if (operatory.SetProspective != oldOperatory.SetProspective)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SetProspective = " + POut.Bool(operatory.SetProspective) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE operatory SET " + command
                      + " WHERE OperatoryNum = " + POut.Long(operatory.OperatoryNum);
            Db.NonQ(command);
        }