Ejemplo n.º 1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textDate.errorProvider1.GetError(textDate) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDate.Text != "")
     {
         DateTime    procDate = PIn.Date(textDate.Text);
         Appointment apt;
         for (int i = 0; i < ProcList.Count; i++)
         {
             if (ProcList[i].AptNum == 0)
             {
                 continue;
             }
             apt = Appointments.GetOneApt(ProcList[i].AptNum);
             if (ProcList[i].ProcDate != procDate)
             {
                 if (!MsgBox.Show(this, true, "Date does not match appointment date.  Continue anyway?"))
                 {
                     return;
                 }
                 break;
             }
         }
         for (int i = 0; i < ProcList.Count; i++)
         {
             if (ProcList[i].ProcStatus == ProcStat.C && ProcList[i].ProcDate > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
             {
                 MsgBox.Show(this, "Completed procedures cannot be set for future dates.");
                 return;
             }
             ProcList[i].ProcDate = procDate;
             Procedures.Update(ProcList[i], ProcOldList[i]);
         }
         ClaimProcs.UpdateProcDate(ProcList.Select(x => x.ProcNum).ToList(), procDate);
         Recalls.Synch(ProcList[0].PatNum);
         if (_hasCompletedProc || _hasExistingProc)
         {
             Patient pat = Patients.GetPat(ProcList[0].PatNum);
             if (_hasCompletedProc)
             {
                 string completeCodes = string.Join(", ",
                                                    ProcList.Where(x => x.ProcStatus == ProcStat.C).Select(x => ProcedureCodes.GetProcCode(x.CodeNum))
                                                    );
                 SecurityLogs.MakeLogEntry(Permissions.ProcComplEdit, ProcList[0].PatNum,
                                           pat.GetNameLF() + " " + completeCodes + ", New date:" + procDate.ToShortDateString());
             }
             if (_hasExistingProc)
             {
                 string existingCodes = string.Join(", ",
                                                    ProcList.Where(x => x.ProcStatus.In(ProcStat.EO, ProcStat.EC)).Select(x => ProcedureCodes.GetProcCode(x.CodeNum))
                                                    );
                 SecurityLogs.MakeLogEntry(Permissions.ProcExistingEdit, ProcList[0].PatNum,
                                           pat.GetNameLF() + " " + existingCodes + ", New date:" + procDate.ToShortDateString());
             }
         }
     }
     DialogResult = DialogResult.OK;
 }