Exemplo n.º 1
0
 private void butPerio_Click(object sender, EventArgs e)
 {
     //make sure we have both special types properly setup.
     if (!RecallTypes.PerioAndProphyBothHaveTriggers())
     {
         MsgBox.Show(this, "Prophy and Perio special recall types are not setup properly.  They must both exist, and they must both have a trigger.");
         return;
     }
     if (IsPerio)
     {
         //change the perio types to prophy
         for (int i = 0; i < RecallList.Count; i++)
         {
             if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallList[i].RecallTypeNum)
             {
                 RecallList[i].RecallTypeNum  = PrefC.GetLong(PrefName.RecallTypeSpecialProphy);
                 RecallList[i].RecallInterval = RecallTypes.GetInterval(PrefC.GetLong(PrefName.RecallTypeSpecialProphy));
                 //previous date will be reset below in synch, but probably won't change since similar triggers.
                 Recalls.Update(RecallList[i]);
                 SecurityLogs.MakeLogEntry(Permissions.RecallEdit, RecallList[i].PatNum, "Recall changed to Prophy from the Recalls for Patient window.");
                 break;
             }
         }
     }
     else
     {
         bool found = false;
         //change any prophy types to perio
         for (int i = 0; i < RecallList.Count; i++)
         {
             if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallList[i].RecallTypeNum)
             {
                 RecallList[i].RecallTypeNum  = PrefC.GetLong(PrefName.RecallTypeSpecialPerio);
                 RecallList[i].RecallInterval = RecallTypes.GetInterval(PrefC.GetLong(PrefName.RecallTypeSpecialPerio));
                 //previous date will be reset below in synch, but probably won't change since similar triggers.
                 Recalls.Update(RecallList[i]);
                 SecurityLogs.MakeLogEntry(Permissions.RecallEdit, RecallList[i].PatNum, "Recall changed to Perio from the Recalls for Patient window.");
                 found = true;
                 break;
             }
         }
         //if none found, then add a perio
         if (!found)
         {
             Recall recall = new Recall();
             recall.PatNum         = PatNum;
             recall.RecallInterval = RecallTypes.GetInterval(PrefC.GetLong(PrefName.RecallTypeSpecialPerio));
             recall.RecallTypeNum  = PrefC.GetLong(PrefName.RecallTypeSpecialPerio);
             Recalls.Insert(recall);
             SecurityLogs.MakeLogEntry(Permissions.RecallEdit, recall.PatNum, "Perio recall added from the Recalls for Patient window.");
         }
     }
     FillGrid();
 }
Exemplo n.º 2
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateDue.errorProvider1.GetError(textDateDue) != "" ||
         textYears.errorProvider1.GetError(textYears) != "" ||
         textMonths.errorProvider1.GetError(textMonths) != "" ||
         textWeeks.errorProvider1.GetError(textWeeks) != "" ||
         textDays.errorProvider1.GetError(textDays) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     RecallCur.IsDisabled            = checkIsDisabled.Checked;
     RecallCur.DateDue               = PIn.PDate(textDateDue.Text);
     RecallCur.RecallInterval.Years  = PIn.PInt(textYears.Text);
     RecallCur.RecallInterval.Months = PIn.PInt(textMonths.Text);
     RecallCur.RecallInterval.Weeks  = PIn.PInt(textWeeks.Text);
     RecallCur.RecallInterval.Days   = PIn.PInt(textDays.Text);
     if (comboStatus.SelectedIndex == 0)
     {
         RecallCur.RecallStatus = 0;
     }
     else
     {
         RecallCur.RecallStatus
             = DefB.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex - 1].DefNum;
     }
     RecallCur.Note = textNote.Text;
     if (IsNew)
     {
         if (!Recalls.IsAllDefault(RecallCur))                //only save if something meaningful
         {
             Recalls.Insert(RecallCur);
         }
     }
     else
     {
         if (Recalls.IsAllDefault(RecallCur))
         {
             Recalls.Delete(RecallCur);
             DialogResult = DialogResult.OK;
             return;
         }
         else
         {
             Recalls.Update(RecallCur);
         }
     }
     Recalls.Synch(PatCur.PatNum, RecallCur);
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (comboType.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please pick a type first.");
                return;
            }
            if (textDateDue.errorProvider1.GetError(textDateDue) != "" ||
                textYears.errorProvider1.GetError(textYears) != "" ||
                textMonths.errorProvider1.GetError(textMonths) != "" ||
                textWeeks.errorProvider1.GetError(textWeeks) != "" ||
                textDays.errorProvider1.GetError(textDays) != "" ||
                textBalance.errorProvider1.GetError(textBalance) != "" ||
                textDisableDate.errorProvider1.GetError(textDisableDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            double disableUntilBalance = PIn.Double(textBalance.Text);

            if (disableUntilBalance < 0)
            {
                MsgBox.Show(this, "Disabled balance must be greater than zero.");
                return;
            }
            RecallCur.RecallTypeNum         = _listRecallTypes[comboType.SelectedIndex].RecallTypeNum;
            RecallCur.IsDisabled            = checkIsDisabled.Checked;
            RecallCur.DisableUntilBalance   = disableUntilBalance;
            RecallCur.DisableUntilDate      = PIn.Date(textDisableDate.Text);
            RecallCur.DateDue               = PIn.Date(textDateDue.Text);
            RecallCur.RecallInterval.Years  = PIn.Int(textYears.Text);
            RecallCur.RecallInterval.Months = PIn.Int(textMonths.Text);
            RecallCur.RecallInterval.Weeks  = PIn.Int(textWeeks.Text);
            RecallCur.RecallInterval.Days   = PIn.Int(textDays.Text);
            if (comboStatus.SelectedIndex == 0)
            {
                RecallCur.RecallStatus = 0;
            }
            else
            {
                RecallCur.RecallStatus
                    = _listRecallUnschedStatusDefs[comboStatus.SelectedIndex - 1].DefNum;
            }
            RecallCur.Note     = textNote.Text;
            RecallCur.Priority = (checkASAP.Checked ? RecallPriority.ASAP : RecallPriority.Normal);
            if (IsNew)
            {
                //if(Recalls.IsAllDefault(RecallCur)){//only save if something meaningful
                //	MsgBox.Show(this,"Recall cannot be saved if all values are still default.");
                //	return;
                //}
                Recalls.Insert(RecallCur);
                SecurityLogs.MakeLogEntry(Permissions.RecallEdit, RecallCur.PatNum, "Recall added from the Edit Recall window.");
            }
            else
            {
                /*if(Recalls.IsAllDefault(RecallCur)){
                 *      if(!MsgBox.Show(this,true,"All values are default.  This recall will be deleted.  Continue?")){
                 *              return;
                 *      }
                 *      Recalls.Delete(RecallCur);
                 *      DialogResult=DialogResult.OK;
                 *      return;
                 * }
                 * else{*/
                Recalls.Update(RecallCur);
                SecurityLogs.MakeLogEntry(Permissions.RecallEdit, RecallCur.PatNum, "Recall edited from the Edit Recall window.");
                //}
            }
            //Recalls.Synch(PatCur.PatNum,RecallCur);//This was moved up into FormRecallsPat.FillGrid.  This is the only way to access a recall.
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 4
0
        ///<summary>Synchronizes all recall for one patient. If datePrevious has changed, then it completely deletes the old recall information and sets a new dateDueCalc and DatePrevious.  Also updates dateDue to match dateDueCalc if not disabled.  The supplied recall can be null if patient has no existing recall. Deletes or creates any recalls as necessary.</summary>
        public static void Synch(int patNum, Recall recall)
        {
            DateTime previousDate = GetPreviousDate(patNum);

            if (recall != null &&
                !recall.IsDisabled &&
                previousDate.Year > 1880 &&              //this protects recalls that were manually added as part of a conversion
                previousDate != recall.DatePrevious)                     //if datePrevious has changed, reset
            {
                recall.RecallStatus = 0;
                recall.Note         = "";
                recall.DateDue      = recall.DateDueCalc; //now it is allowed to be changed in the steps below
            }
            if (previousDate.Year < 1880)                 //if no previous date
            {
                if (recall == null)                       //no recall present
                //do nothing.
                {
                }
                else
                {
                    recall.DatePrevious = DateTime.MinValue;
                    if (recall.DateDue == recall.DateDueCalc)                  //user did not enter a DateDue
                    {
                        recall.DateDue = DateTime.MinValue;
                    }
                    recall.DateDueCalc = DateTime.MinValue;
                    Recalls.Update(recall);
                    if (Recalls.IsAllDefault(recall))                    //no useful info
                    {
                        Recalls.Delete(recall);
                        recall = null;
                    }
                }
            }
            else                    //if previous date is a valid date
            {
                if (recall == null) //no recall present
                {
                    recall                = new Recall();
                    recall.PatNum         = patNum;
                    recall.DatePrevious   = previousDate;
                    recall.RecallInterval = new Interval(0, 0, 6, 0);
                    recall.DateDueCalc    = previousDate + recall.RecallInterval;
                    recall.DateDue        = recall.DateDueCalc;
                    Recalls.Insert(recall);
                    return;
                }
                else
                {
                    recall.DatePrevious = previousDate;
                    if (recall.IsDisabled)                  //if the existing recall is disabled
                    {
                        recall.DateDue = DateTime.MinValue; //DateDue is always blank
                    }
                    else                                    //but if not disabled
                    {
                        if (recall.DateDue == recall.DateDueCalc ||                  //if user did not enter a DateDue
                            recall.DateDue.Year < 1880)                                   //or DateDue was blank
                        {
                            recall.DateDue = recall.DatePrevious + recall.RecallInterval; //set same as DateDueCalc
                        }
                    }
                    recall.DateDueCalc = recall.DatePrevious + recall.RecallInterval;
                    Recalls.Update(recall);
                }
            }
        }