コード例 #1
0
 private void FormRpRouting_Load(object sender, System.EventArgs e)
 {
     if (ApptNum != 0)
     {
         Appts = new Appointment[] { Appointments.GetOneApt(ApptNum) };
         if (Appts.Length == 0 || Appts[0] == null)
         {
             MsgBox.Show(this, "Appointment not found");
             return;
         }
         pagesPrinted                   = 0;
         pd                             = new PrintDocument();
         pd.PrintPage                  += new PrintPageEventHandler(this.pd_PrintPage);
         pd.OriginAtMargins             = true;
         pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
         printPreview                   = new OpenDental.UI.PrintPreview(PrintSituation.Default, pd, Appts.Length);
         printPreview.ShowDialog();
         DialogResult = DialogResult.OK;
     }
     for (int i = 0; i < Providers.List.Length; i++)
     {
         listProv.Items.Add(Providers.List[i].Abbr + " - " + Providers.List[i].LName + ", "
                            + Providers.List[i].FName);
         listProv.SetSelected(i, true);
     }
     textDate.Text = DateTime.Today.ToShortDateString();
 }
コード例 #2
0
ファイル: DashApptGrid.cs プロジェクト: ChemBrain/OpenDental
 ///<summary>Returns true if SelectedApptOther is null or is set to an appointment with an AptNum that is not in the database.
 ///If SelectedApptOther was null or set to a valid appointment but is now invalid (no longer in the database) then a warning message will display
 ///to the user and RefreshAppts will be invoked in order to remove the invalid appt from the UI.</summary>
 public bool IsSelectedApptOtherNull()
 {
     if (SelectedApptOther == null || Appointments.GetOneApt(SelectedApptOther.AptNum) == null)
     {
         MsgBox.Show(this, "Selected appointment no longer exists.");
         RefreshAppts();
         return(true);
     }
     return(false);
 }
コード例 #3
0
 ///<summary>Pass in the currently selected apptNum along with all ApptNums that are associated to the current pinboard.</summary>
 public FormApptSearchAdvanced(long apptNum)
 {
     InitializeComponent();
     Lan.F(this);
     _appt = Appointments.GetOneApt(apptNum);
     if (_appt == null)
     {
         MsgBox.Show(this, "Invalid appointment on the Pinboard.");
         DialogResult = DialogResult.Abort;
         return;
     }
 }
コード例 #4
0
ファイル: FormProcEditAll.cs プロジェクト: steev90/opendental
 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++)
         {
             ProcList[i].ProcDate = procDate;
             Procedures.Update(ProcList[i], ProcOldList[i]);
         }
         Recalls.Synch(ProcList[0].PatNum);
         if (AnyAreC)
         {
             Patient       pat   = Patients.GetPat(ProcList[0].PatNum);
             string        codes = "";
             ProcedureCode ProcedureCode2;
             for (int i = 0; i < ProcList.Count; i++)
             {
                 if (i > 0)
                 {
                     codes += ", ";
                 }
                 ProcedureCode2 = ProcedureCodes.GetProcCode(ProcList[i].CodeNum);
                 codes         += ProcedureCode2.ProcCode;
             }
             SecurityLogs.MakeLogEntry(Permissions.ProcComplEdit, ProcList[0].PatNum,
                                       pat.GetNameLF() + codes + ", New date:" + procDate.ToShortDateString());
         }
     }
     DialogResult = DialogResult.OK;
 }
コード例 #5
0
        private void mainGridMenuItemPatChart_Click(object sender, EventArgs e)
        {
            List <GridRow> listSelected = gridMain.SelectedGridRows;

            if (listSelected.Count == 1)
            {
                long        aptNum = PIn.Long(listSelected[0].Tag.ToString());
                Appointment apt    = Appointments.GetOneApt(aptNum);
                GotoModule.GotoChart(apt.PatNum);
                DialogResult = DialogResult.OK;
            }
        }
コード例 #6
0
        private void userControlTasks1_GoToChanged(object sender, EventArgs e)
        {
            TaskObjectType gotoType   = userControlTasks1.GotoType;
            long           gotoKeyNum = userControlTasks1.GotoKeyNum;

            if (gotoType == TaskObjectType.Patient)
            {
                if (gotoKeyNum != 0)
                {
                    Patient pat = Patients.GetPat(gotoKeyNum);
                    //OnPatientSelected(pat);
                    if (IsTriage)
                    {
                        GotoModule.GotoChart(pat.PatNum);
                    }
                    else
                    {
                        GotoModule.GotoAccount(pat.PatNum);
                    }
                }
            }
            if (gotoType == TaskObjectType.Appointment)
            {
                if (gotoKeyNum != 0)
                {
                    Appointment apt = Appointments.GetOneApt(gotoKeyNum);
                    if (apt == null)
                    {
                        MsgBox.Show(this, "Appointment has been deleted, so it's not available.");
                        return;
                        //this could be a little better, because window has closed, but they will learn not to push that button.
                    }
                    DateTime dateSelected = DateTime.MinValue;
                    if (apt.AptStatus == ApptStatus.Planned || apt.AptStatus == ApptStatus.UnschedList)
                    {
                        //I did not add feature to put planned or unsched apt on pinboard.
                        MsgBox.Show(this, "Cannot navigate to appointment.  Use the Other Appointments button.");
                        //return;
                    }
                    else
                    {
                        dateSelected = apt.AptDateTime;
                    }
                    Patient pat = Patients.GetPat(apt.PatNum);
                    //OnPatientSelected(pat);
                    GotoModule.GotoAppointment(dateSelected, apt.AptNum);
                }
            }
            //DialogResult=DialogResult.OK;
        }
コード例 #7
0
 private void FillObject()
 {
     if (Cur.ObjectType == TaskObjectType.None)
     {
         listObjectType.SelectedIndex = 0;
         panelObject.Visible          = false;
     }
     else if (Cur.ObjectType == TaskObjectType.Patient)
     {
         listObjectType.SelectedIndex = 1;
         panelObject.Visible          = true;
         labelObjectDesc.Text         = Lan.g(this, "Patient Name");
         if (Cur.KeyNum > 0)
         {
             textObjectDesc.Text = Patients.GetPat(Cur.KeyNum).GetNameLF();
         }
         else
         {
             textObjectDesc.Text = "";
         }
     }
     else if (Cur.ObjectType == TaskObjectType.Appointment)
     {
         listObjectType.SelectedIndex = 2;
         panelObject.Visible          = true;
         labelObjectDesc.Text         = Lan.g(this, "Appointment Desc");
         if (Cur.KeyNum > 0)
         {
             Appointment AptCur = Appointments.GetOneApt(Cur.KeyNum);
             if (AptCur == null)
             {
                 textObjectDesc.Text = Lan.g(this, "(appointment deleted)");
             }
             else
             {
                 textObjectDesc.Text = Patients.GetPat(AptCur.PatNum).GetNameLF()
                                       + "  " + AptCur.AptDateTime.ToString()
                                       + "  " + AptCur.ProcDescript
                                       + "  " + AptCur.Note;
             }
         }
         else
         {
             textObjectDesc.Text = "";
         }
     }
 }
コード例 #8
0
        private void comboStatus_SelectionChangeCommitted(object sender, System.EventArgs e)
        {
            if (grid.SelectedIndices.Length == 0)
            {
                return;                //because user could never initiate this action.
            }
            Appointment apt;

            Cursor = Cursors.WaitCursor;
            int[] selectedApts = new int[grid.SelectedIndices.Length];
            for (int i = 0; i < grid.SelectedIndices.Length; i++)
            {
                selectedApts[i] = PIn.PInt(table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString());
            }
            for (int i = 0; i < grid.SelectedIndices.Length; i++)
            {
                apt = Appointments.GetOneApt(PIn.PInt(table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()));
                Appointment aptOld    = apt.Copy();
                int         selectedI = comboStatus.SelectedIndex;
                apt.Confirmed = DefB.Short[(int)DefCat.ApptConfirmed][selectedI].DefNum;
                try{
                    Appointments.InsertOrUpdate(apt, aptOld, false);
                }
                catch (ApplicationException ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            FillMain();
            //reselect all the apts
            for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < selectedApts.Length; j++)
                {
                    if (PIn.PInt(table.Rows[i]["AptNum"].ToString()) == selectedApts[j])
                    {
                        grid.SetSelected(i, true);
                    }
                }
            }
            SetFamilyColors();
            comboStatus.SelectedIndex = -1;
            Cursor = Cursors.Default;
        }
コード例 #9
0
        private void grid_CellDoubleClick(object sender, OpenDental.UI.ODGridClickEventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            int          selectedApt = PIn.PInt(table.Rows[e.Row]["AptNum"].ToString());
            Appointment  apt         = Appointments.GetOneApt(selectedApt);
            FormApptEdit FormA       = new FormApptEdit(apt);

            FormA.ShowDialog();
            //if(FormA.DialogResult==DialogResult.Cancel){
            //	Cursor=Cursors.Default;
            FillMain();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (PIn.PInt(table.Rows[i]["AptNum"].ToString()) == selectedApt)
                {
                    grid.SetSelected(i, true);
                }
            }
            SetFamilyColors();
            Cursor = Cursors.Default;
        }
コード例 #10
0
        private void menuItemGoTo_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a lab case first.");
                return;
            }
            if (table.Rows[gridMain.GetSelectedIndex()]["AptNum"].ToString() == "0")
            {
                MsgBox.Show(this, "There are no appointments for unattached lab cases.");
                return;
            }
            Appointment apt = Appointments.GetOneApt(PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["AptNum"].ToString()));

            if (apt.AptStatus == ApptStatus.UnschedList)
            {
                MsgBox.Show(this, "Cannot go to an unscheduled appointment");
                return;
            }
            GoToAptNum = apt.AptNum;
            Close();
        }
コード例 #11
0
        private void FormLabCaseEdit_Load(object sender, System.EventArgs e)
        {
            if (Plugins.HookMethod(this, "FormLabCaseEdit.Load_start", CaseCur, IsNew))
            {
                return;
            }
            if (CaseCur == null)
            {
                MsgBox.Show(this, "Lab case no longer exists.");
                DialogResult = DialogResult.Abort;              //Results in form closing logic
                return;
            }
            Patient pat = Patients.GetPat(CaseCur.PatNum);

            //If pat is null, this can trickle down and allow the user to create a lab sheet with a FK to an invalid Patient.
            if (pat == null)
            {
                MsgBox.Show(this, "There is no valid Patient attached to this Labcase.");
                DialogResult = DialogResult.Abort;              //Results in form closing logic
                return;
            }
            textPatient.Text = pat.GetNameFL();
            ListLabs         = Laboratories.Refresh();
            //Include the current lab, even if it is hidden.
            ListLabs = ListLabs.Where(x => x.LaboratoryNum == CaseCur.LaboratoryNum || !x.IsHidden).ToList();
            for (int i = 0; i < ListLabs.Count; i++)
            {
                listLab.Items.Add(ListLabs[i].Description + " " + ListLabs[i].Phone);
                if (ListLabs[i].LaboratoryNum == CaseCur.LaboratoryNum)
                {
                    listLab.SelectedIndex = i;
                }
            }
            _listProviders = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                comboProv.Items.Add(_listProviders[i].Abbr);
                if (_listProviders[i].ProvNum == CaseCur.ProvNum)
                {
                    comboProv.SelectedIndex = i;
                }
            }
            Appointment apt = Appointments.GetOneApt(CaseCur.AptNum);

            if (apt != null)
            {
                if (apt.AptStatus == ApptStatus.UnschedList)
                {
                    textAppointment.Text = Lan.g(this, "Unscheduled");
                }
                else
                {
                    textAppointment.Text = apt.AptDateTime.ToShortDateString() + " " + apt.AptDateTime.ToShortTimeString();
                }
                textAppointment.Text += ", " + apt.ProcDescript;
            }
            apt = Appointments.GetOneApt(CaseCur.PlannedAptNum);
            if (apt != null)
            {
                textPlanned.Text = apt.ProcDescript;
                if (textPlanned.Text == "")
                {
                    textPlanned.Text = Lan.g(this, "Attached");
                }
            }
            if (CaseCur.DateTimeCreated.Year > 1880)
            {
                textDateCreated.Text = CaseCur.DateTimeCreated.ToString();
            }
            if (CaseCur.DateTimeSent.Year > 1880)
            {
                textDateSent.Text = CaseCur.DateTimeSent.ToString();
            }
            if (CaseCur.DateTimeRecd.Year > 1880)
            {
                textDateRecd.Text = CaseCur.DateTimeRecd.ToString();
            }
            if (CaseCur.DateTimeChecked.Year > 1880)
            {
                textDateChecked.Text = CaseCur.DateTimeChecked.ToString();
            }
            if (CaseCur.DateTimeDue.Year > 1880)
            {
                textDateDue.Text = CaseCur.DateTimeDue.ToShortDateString() + " " + CaseCur.DateTimeDue.ToShortTimeString();
            }
            textInstructions.Text = CaseCur.Instructions;
            textLabFee.Text       = CaseCur.LabFee.ToString("n");
            sheet = Sheets.GetLabSlip(CaseCur.PatNum, CaseCur.LabCaseNum);
            if (sheet == null)
            {
                butSlip.Text = Lan.g(this, "New Slip");
            }
            else
            {
                butSlip.Text = Lan.g(this, "Edit Slip");
            }
            textInvoiceNumber.Text = CaseCur.InvoiceNum;
            Plugins.HookAddCode(this, "FormLabCaseEdit.Load_end", CaseCur, IsNew);
        }
コード例 #12
0
        private void FormEhrAptObsEdit_Load(object sender, EventArgs e)
        {
            _appt = Appointments.GetOneApt(_ehrAptObsCur.AptNum);
            comboObservationQuestion.Items.Clear();
            string[] arrayQuestionNames = Enum.GetNames(typeof(EhrAptObsIdentifier));
            for (int i = 0; i < arrayQuestionNames.Length; i++)
            {
                comboObservationQuestion.Items.Add(arrayQuestionNames[i]);
                EhrAptObsIdentifier ehrAptObsIdentifier = (EhrAptObsIdentifier)i;
                if (_ehrAptObsCur.IdentifyingCode == ehrAptObsIdentifier)
                {
                    comboObservationQuestion.SelectedIndex = i;
                }
            }
            listValueType.Items.Clear();
            string[] arrayValueTypeNames = Enum.GetNames(typeof(EhrAptObsType));
            for (int i = 0; i < arrayValueTypeNames.Length; i++)
            {
                listValueType.Items.Add(arrayValueTypeNames[i]);
                EhrAptObsType ehrAptObsType = (EhrAptObsType)i;
                if (_ehrAptObsCur.ValType == ehrAptObsType)
                {
                    listValueType.SelectedIndex = i;
                }
            }
            if (_ehrAptObsCur.ValType == EhrAptObsType.Coded)
            {
                _strValCodeSystem = _ehrAptObsCur.ValCodeSystem;
                if (_ehrAptObsCur.ValCodeSystem == "LOINC")
                {
                    _loincValue    = Loincs.GetByCode(_ehrAptObsCur.ValReported);
                    textValue.Text = _loincValue.NameShort;
                }
                else if (_ehrAptObsCur.ValCodeSystem == "SNOMEDCT")
                {
                    _snomedValue   = Snomeds.GetByCode(_ehrAptObsCur.ValReported);
                    textValue.Text = _snomedValue.Description;
                }
                else if (_ehrAptObsCur.ValCodeSystem == "ICD9")
                {
                    _icd9Value     = ICD9s.GetByCode(_ehrAptObsCur.ValReported);
                    textValue.Text = _icd9Value.Description;
                }
                else if (_ehrAptObsCur.ValCodeSystem == "ICD10")
                {
                    _icd10Value    = Icd10s.GetByCode(_ehrAptObsCur.ValReported);
                    textValue.Text = _icd10Value.Description;
                }
            }
            else
            {
                textValue.Text = _ehrAptObsCur.ValReported;
            }
            comboUnits.Items.Clear();
            comboUnits.Items.Add("none");
            comboUnits.SelectedIndex = 0;
            List <string> listUcumCodes = Ucums.GetAllCodes();

            for (int i = 0; i < listUcumCodes.Count; i++)
            {
                string ucumCode = listUcumCodes[i];
                comboUnits.Items.Add(ucumCode);
                if (ucumCode == _ehrAptObsCur.UcumCode)
                {
                    comboUnits.SelectedIndex = i + 1;
                }
            }
            SetFlags();
        }
コード例 #13
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;
 }
コード例 #14
0
ファイル: FormReqStudentEdit.cs プロジェクト: nampn/ODental
        private void FormReqStudentEdit_Load(object sender, System.EventArgs e)
        {
            //There should only be two types of users who are allowed to get this far:
            //Students editing their own req, and users with setup perm.  But we will double check.
            Provider provUser = Providers.GetProv(Security.CurUser.ProvNum);

            if (provUser != null && provUser.SchoolClassNum != 0)         //A student is logged in
            //the student only has permission to view/attach/detach their own requirements
            {
                if (provUser.ProvNum != ReqCur.ProvNum)
                {
                    //but this should never happen
                    MsgBox.Show(this, "Students may only edit their own requirements.");
                    butDelete.Enabled = false;
                    butOK.Enabled     = false;
                }
                else                 //the student matches
                {
                    butDelete.Enabled         = false;
                    textDateCompleted.Enabled = false;
                    butNow.Enabled            = false;
                    comboInstructor.Enabled   = false;
                    //a student is only allowed to change the patient and appointment.
                }
            }
            else                                                                        //A student is not logged in
            {
                if (!Security.IsAuthorized(Permissions.Setup, DateTime.MinValue, true)) //suppress message
                {
                    butDelete.Enabled = false;
                    butOK.Enabled     = false;
                }
            }
            textStudent.Text     = Providers.GetLongDesc(ReqCur.ProvNum);
            textCourse.Text      = SchoolCourses.GetDescript(ReqCur.SchoolCourseNum);
            textDescription.Text = ReqCur.Descript;
            if (ReqCur.DateCompleted.Year > 1880)
            {
                textDateCompleted.Text = ReqCur.DateCompleted.ToShortDateString();
            }
            //if an apt is attached, then the same pat must be attached.
            Patient pat = Patients.GetPat(ReqCur.PatNum);

            if (pat != null)
            {
                textPatient.Text = pat.GetNameFL();
            }
            Appointment apt = Appointments.GetOneApt(ReqCur.AptNum);

            if (apt != null)
            {
                if (apt.AptStatus == ApptStatus.UnschedList)
                {
                    textAppointment.Text = Lan.g(this, "Unscheduled");
                }
                else
                {
                    textAppointment.Text = apt.AptDateTime.ToShortDateString() + " " + apt.AptDateTime.ToShortTimeString();
                }
                textAppointment.Text += ", " + apt.ProcDescript;
            }
            comboInstructor.Items.Add(Lan.g(this, "None"));
            comboInstructor.SelectedIndex = 0;
            for (int i = 0; i < ProviderC.ListShort.Count; i++)
            {
                comboInstructor.Items.Add(ProviderC.ListShort[i].GetLongDesc());
                if (ProviderC.ListShort[i].ProvNum == ReqCur.InstructorNum)
                {
                    comboInstructor.SelectedIndex = i + 1;
                }
            }
        }
コード例 #15
0
ファイル: AutomationL.cs プロジェクト: ChemBrain/OpenDental
        public static bool Trigger <T>(AutomationTrigger trigger, List <string> procCodes, long patNum, long aptNum = 0, T triggerObj = default(T))
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            List <Automation> listAutomations = Automations.GetDeepCopy();
            bool automationHappened           = false;

            for (int i = 0; i < listAutomations.Count; i++)
            {
                if (listAutomations[i].Autotrigger != trigger)
                {
                    continue;
                }
                if (trigger == AutomationTrigger.CompleteProcedure || trigger == AutomationTrigger.ScheduleProcedure)
                {
                    if (procCodes == null || procCodes.Count == 0)
                    {
                        continue;                        //fail silently
                    }
                    string[] arrayCodes = listAutomations[i].ProcCodes.Split(',');
                    if (procCodes.All(x => !arrayCodes.Contains(x)))
                    {
                        continue;
                    }
                }
                //matching automation item has been found
                //Get possible list of conditions that exist for this automation item
                List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(listAutomations[i].AutomationNum);
                if (autoConditionsList.Count > 0 && !CheckAutomationConditions(autoConditionsList, patNum, triggerObj))
                {
                    continue;
                }
                SheetDef          sheetDef;
                Sheet             sheet;
                FormSheetFillEdit FormSF;
                Appointment       aptNew;
                Appointment       aptOld;
                switch (listAutomations[i].AutoAction)
                {
                case AutomationAction.CreateCommlog:
                    if (Plugins.HookMethod(null, "AutomationL.Trigger_CreateCommlog_start", patNum, aptNum, listAutomations[i].CommType,
                                           listAutomations[i].MessageContent, trigger))
                    {
                        automationHappened = true;
                        continue;
                    }
                    Commlog commlogCur = new Commlog();
                    commlogCur.PatNum       = patNum;
                    commlogCur.CommDateTime = DateTime.Now;
                    commlogCur.CommType     = listAutomations[i].CommType;
                    commlogCur.Note         = listAutomations[i].MessageContent;
                    commlogCur.Mode_        = CommItemMode.None;
                    commlogCur.UserNum      = Security.CurUser.UserNum;
                    commlogCur.IsNew        = true;
                    FormCommItem commItemView = new FormCommItem(commlogCur);
                    commItemView.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUp:
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUpThenDisable10Min:
                    Plugins.HookAddCode(null, "AutomationL.Trigger_PopUpThenDisable10Min_begin", listAutomations[i], procCodes, patNum);
                    long automationNum      = listAutomations[i].AutomationNum;
                    bool hasAutomationBlock = FormOpenDental.DicBlockedAutomations.ContainsKey(automationNum);
                    if (hasAutomationBlock && FormOpenDental.DicBlockedAutomations[automationNum].ContainsKey(patNum))                             //Automation block exist for current patient.
                    {
                        continue;
                    }
                    if (hasAutomationBlock)
                    {
                        FormOpenDental.DicBlockedAutomations[automationNum].Add(patNum, DateTime.Now.AddMinutes(10)); //Disable for 10 minutes.
                    }
                    else                                                                                              //Add automationNum to higher level dictionary .
                    {
                        FormOpenDental.DicBlockedAutomations.Add(automationNum,
                                                                 new Dictionary <long, DateTime>()
                        {
                            { patNum, DateTime.Now.AddMinutes(10) }                                           //Disable for 10 minutes.
                        });
                    }
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintPatientLetter:
                case AutomationAction.ShowExamSheet:
                case AutomationAction.ShowConsentForm:
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintReferralLetter:
                    long referralNum = RefAttaches.GetReferralNum(patNum);
                    if (referralNum == 0)
                    {
                        MsgBox.Show("Automations", "This patient has no referral source entered.");
                        automationHappened = true;
                        continue;
                    }
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetParameter.SetParameter(sheet, "ReferralNum", referralNum);
                    //Don't fill these params if the sheet doesn't use them.
                    if (sheetDef.SheetFieldDefs.Any(x =>
                                                    (x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted") ||
                                                    (x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart")))
                    {
                        List <Procedure> listProcs = Procedures.GetCompletedForDateRange(DateTime.Today, DateTime.Today
                                                                                         , listPatNums: new List <long>()
                        {
                            patNum
                        }
                                                                                         , includeNote: true
                                                                                         , includeGroupNote: true
                                                                                         );
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted"))
                        {
                            SheetParameter.SetParameter(sheet, "CompletedProcs", listProcs);
                        }
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart"))
                        {
                            SheetParameter.SetParameter(sheet, "toothChartImg", SheetPrinting.GetToothChartHelper(patNum, false, listProceduresFilteredOverride: listProcs));
                        }
                    }
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.SetApptASAP:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld          = aptNew.Copy();
                    aptNew.Priority = ApptPriority.ASAP;
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.SetApptType:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld = aptNew.Copy();
                    aptNew.AppointmentTypeNum = listAutomations[i].AppointmentTypeNum;
                    AppointmentType aptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == aptNew.AppointmentTypeNum);
                    if (aptTypeCur != null)
                    {
                        aptNew.ColorOverride = aptTypeCur.AppointmentTypeColor;
                        aptNew.Pattern       = AppointmentTypes.GetTimePatternForAppointmentType(aptTypeCur);
                        List <Procedure> listProcs = Appointments.ApptTypeMissingProcHelper(aptNew, aptTypeCur, new List <Procedure>());
                        Procedures.UpdateAptNums(listProcs.Select(x => x.ProcNum).ToList(), aptNew.AptNum, aptNew.AptStatus == ApptStatus.Planned);
                    }
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.PatRestrictApptSchedTrue:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to restrict patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.Upsert(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PatRestrictApptSchedFalse:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to allow patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.RemovePatRestriction(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintRxInstruction:
                    List <RxPat> listRx = (List <RxPat>)(object) triggerObj;
                    if (listRx == null)
                    {
                        //Got here via a pre-existing trigger that doesn't pass in triggerObj.  We now block creation of automation triggers that could get
                        //here via code that does not pass in triggerObj.
                        continue;
                    }
                    //We go through each new Rx where the patient note isn't blank.
                    //There should only usually be one new rx, but we'll loop just in case.
                    foreach (RxPat rx in listRx.Where(x => !string.IsNullOrWhiteSpace(x.PatientInstruction)))
                    {
                        //This logic is an exact copy of FormRxManage.butPrintSelect_Click()'s logic when 1 Rx is selected.
                        //If this is updated, that method needs to be updated as well.
                        sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                        sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                        SheetParameter.SetParameter(sheet, "RxNum", rx.RxNum);
                        SheetFiller.FillFields(sheet);
                        SheetUtil.CalculateHeights(sheet);
                        FormSF = new FormSheetFillEdit(sheet);
                        FormSF.ShowDialog();
                        automationHappened = true;
                    }
                    continue;

                case AutomationAction.ChangePatStatus:
                    Patient pat    = Patients.GetPat(patNum);
                    Patient patOld = pat.Copy();
                    pat.PatStatus = listAutomations[i].PatStatus;
                    //Don't allow changing status from Archived if this is a merged patient.
                    if (patOld.PatStatus != pat.PatStatus &&
                        patOld.PatStatus == PatientStatus.Archived &&
                        PatientLinks.WasPatientMerged(patOld.PatNum))
                    {
                        MsgBox.Show("FormPatientEdit", "Not allowed to change the status of a merged patient.");
                        continue;
                    }
                    switch (pat.PatStatus)
                    {
                    case PatientStatus.Deceased:
                        if (patOld.PatStatus != PatientStatus.Deceased)
                        {
                            List <Appointment> listFutureAppts = Appointments.GetFutureSchedApts(pat.PatNum);
                            if (listFutureAppts.Count > 0)
                            {
                                string apptDates = string.Join("\r\n", listFutureAppts.Take(10).Select(x => x.AptDateTime.ToString()));
                                if (listFutureAppts.Count > 10)
                                {
                                    apptDates += "(...)";
                                }
                                if (MessageBox.Show(
                                        Lan.g("FormPatientEdit", "This patient has scheduled appointments in the future") + ":\r\n" + apptDates + "\r\n"
                                        + Lan.g("FormPatientEdit", "Would you like to delete them and set the patient to Deceased?"),
                                        Lan.g("FormPatientEdit", "Delete future appointments?"),
                                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    foreach (Appointment appt in listFutureAppts)
                                    {
                                        Appointments.Delete(appt.AptNum, true);
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        break;
                    }
                    //Re-activate or disable recalls depending on the the status that the patient is changing to.
                    Patients.UpdateRecalls(pat, patOld, "ChangePatStatus automation");
                    if (Patients.Update(pat, patOld))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientEdit, patNum, "Patient status changed from " + patOld.PatStatus.GetDescription() +
                                                  " to " + listAutomations[i].PatStatus.GetDescription() + " through ChangePatStatus automation.");
                    }
                    automationHappened = true;
                    continue;
                }
            }
            return(automationHappened);
        }
コード例 #16
0
        public static bool Trigger <T>(AutomationTrigger trigger, List <string> procCodes, long patNum, long aptNum = 0, T triggerObj = default(T))
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            List <Automation> listAutomations = Automations.GetDeepCopy();
            bool automationHappened           = false;

            for (int i = 0; i < listAutomations.Count; i++)
            {
                if (listAutomations[i].Autotrigger != trigger)
                {
                    continue;
                }
                if (trigger == AutomationTrigger.CompleteProcedure || trigger == AutomationTrigger.ScheduleProcedure)
                {
                    if (procCodes == null || procCodes.Count == 0)
                    {
                        continue;                        //fail silently
                    }
                    string[] arrayCodes = listAutomations[i].ProcCodes.Split(',');
                    if (procCodes.All(x => !arrayCodes.Contains(x)))
                    {
                        continue;
                    }
                }
                //matching automation item has been found
                //Get possible list of conditions that exist for this automation item
                List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(listAutomations[i].AutomationNum);
                if (autoConditionsList.Count > 0 && !CheckAutomationConditions(autoConditionsList, patNum, triggerObj))
                {
                    continue;
                }
                SheetDef          sheetDef;
                Sheet             sheet;
                FormSheetFillEdit FormSF;
                Appointment       aptNew;
                Appointment       aptOld;
                switch (listAutomations[i].AutoAction)
                {
                case AutomationAction.CreateCommlog:
                    if (Plugins.HookMethod(null, "AutomationL.Trigger_CreateCommlog_start", patNum, aptNum, listAutomations[i].CommType,
                                           listAutomations[i].MessageContent))
                    {
                        automationHappened = true;
                        continue;
                    }
                    Commlog commlogCur = new Commlog();
                    commlogCur.PatNum       = patNum;
                    commlogCur.CommDateTime = DateTime.Now;
                    commlogCur.CommType     = listAutomations[i].CommType;
                    commlogCur.Note         = listAutomations[i].MessageContent;
                    commlogCur.Mode_        = CommItemMode.None;
                    commlogCur.UserNum      = Security.CurUser.UserNum;
                    FormCommItem commItemView = new FormCommItem();
                    commItemView.ShowDialog(new CommItemModel()
                    {
                        CommlogCur = commlogCur
                    }, new CommItemController(commItemView)
                    {
                        IsNew = true
                    });
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUp:
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUpThenDisable10Min:
                    long automationNum      = listAutomations[i].AutomationNum;
                    bool hasAutomationBlock = FormOpenDental.DicBlockedAutomations.ContainsKey(automationNum);
                    if (hasAutomationBlock && FormOpenDental.DicBlockedAutomations[automationNum].ContainsKey(patNum))                             //Automation block exist for current patient.
                    {
                        continue;
                    }
                    if (hasAutomationBlock)
                    {
                        FormOpenDental.DicBlockedAutomations[automationNum].Add(patNum, DateTime.Now.AddMinutes(10)); //Disable for 10 minutes.
                    }
                    else                                                                                              //Add automationNum to higher level dictionary .
                    {
                        FormOpenDental.DicBlockedAutomations.Add(automationNum,
                                                                 new Dictionary <long, DateTime>()
                        {
                            { patNum, DateTime.Now.AddMinutes(10) }                                           //Disable for 10 minutes.
                        });
                    }
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintPatientLetter:
                case AutomationAction.ShowExamSheet:
                case AutomationAction.ShowConsentForm:
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintReferralLetter:
                    long referralNum = RefAttaches.GetReferralNum(patNum);
                    if (referralNum == 0)
                    {
                        MsgBox.Show("Automations", "This patient has no referral source entered.");
                        automationHappened = true;
                        continue;
                    }
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetParameter.SetParameter(sheet, "ReferralNum", referralNum);
                    //Don't fill these params if the sheet doesn't use them.
                    if (sheetDef.SheetFieldDefs.Any(x =>
                                                    (x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted") ||
                                                    (x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart")))
                    {
                        List <Procedure> listProcs = Procedures.GetCompletedForDateRange(DateTime.Today, DateTime.Today
                                                                                         , listPatNums: new List <long>()
                        {
                            patNum
                        }
                                                                                         , includeNote: true
                                                                                         , includeGroupNote: true
                                                                                         );
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted"))
                        {
                            SheetParameter.SetParameter(sheet, "CompletedProcs", listProcs);
                        }
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart"))
                        {
                            SheetParameter.SetParameter(sheet, "toothChartImg", SheetPrinting.GetToothChartHelper(patNum, false, listProceduresFilteredOverride: listProcs));
                        }
                    }
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.SetApptASAP:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld          = aptNew.Copy();
                    aptNew.Priority = ApptPriority.ASAP;
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.SetApptType:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld = aptNew.Copy();
                    aptNew.AppointmentTypeNum = listAutomations[i].AppointmentTypeNum;
                    AppointmentType aptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == aptNew.AppointmentTypeNum);
                    if (aptTypeCur != null)
                    {
                        aptNew.ColorOverride = aptTypeCur.AppointmentTypeColor;
                    }
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.PatRestrictApptSchedTrue:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to restrict patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.Upsert(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PatRestrictApptSchedFalse:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to allow patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.RemovePatRestriction(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;
                }
            }
            return(automationHappened);
        }
コード例 #17
0
ファイル: FormLabCaseEdit.cs プロジェクト: kjb7749/testImport
        private void FormLabCaseEdit_Load(object sender, System.EventArgs e)
        {
            if (Plugins.HookMethod(this, "FormLabCaseEdit.Load_start", CaseCur, IsNew))
            {
                return;
            }
            textPatient.Text = Patients.GetPat(CaseCur.PatNum).GetNameFL();
            ListLabs         = Laboratories.Refresh();
            for (int i = 0; i < ListLabs.Count; i++)
            {
                listLab.Items.Add(ListLabs[i].Description + " " + ListLabs[i].Phone);
                if (ListLabs[i].LaboratoryNum == CaseCur.LaboratoryNum)
                {
                    listLab.SelectedIndex = i;
                }
            }
            _listProviders = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                comboProv.Items.Add(_listProviders[i].Abbr);
                if (_listProviders[i].ProvNum == CaseCur.ProvNum)
                {
                    comboProv.SelectedIndex = i;
                }
            }
            Appointment apt = Appointments.GetOneApt(CaseCur.AptNum);

            if (apt != null)
            {
                if (apt.AptStatus == ApptStatus.UnschedList)
                {
                    textAppointment.Text = Lan.g(this, "Unscheduled");
                }
                else
                {
                    textAppointment.Text = apt.AptDateTime.ToShortDateString() + " " + apt.AptDateTime.ToShortTimeString();
                }
                textAppointment.Text += ", " + apt.ProcDescript;
            }
            apt = Appointments.GetOneApt(CaseCur.PlannedAptNum);
            if (apt != null)
            {
                textPlanned.Text = apt.ProcDescript;
                if (textPlanned.Text == "")
                {
                    textPlanned.Text = Lan.g(this, "Attached");
                }
            }
            if (CaseCur.DateTimeCreated.Year > 1880)
            {
                textDateCreated.Text = CaseCur.DateTimeCreated.ToString();
            }
            if (CaseCur.DateTimeSent.Year > 1880)
            {
                textDateSent.Text = CaseCur.DateTimeSent.ToString();
            }
            if (CaseCur.DateTimeRecd.Year > 1880)
            {
                textDateRecd.Text = CaseCur.DateTimeRecd.ToString();
            }
            if (CaseCur.DateTimeChecked.Year > 1880)
            {
                textDateChecked.Text = CaseCur.DateTimeChecked.ToString();
            }
            if (CaseCur.DateTimeDue.Year > 1880)
            {
                textDateDue.Text = CaseCur.DateTimeDue.ToShortDateString() + " " + CaseCur.DateTimeDue.ToShortTimeString();
            }
            textInstructions.Text = CaseCur.Instructions;
            textLabFee.Text       = CaseCur.LabFee.ToString("n");
            sheet = Sheets.GetLabSlip(CaseCur.PatNum, CaseCur.LabCaseNum);
            if (sheet == null)
            {
                butSlip.Text = Lan.g(this, "New Slip");
            }
            else
            {
                butSlip.Text = Lan.g(this, "Edit Slip");
            }
            Plugins.HookAddCode(this, "FormLabCaseEdit.Load_end", CaseCur, IsNew);
        }
コード例 #18
0
        private void FormLabCaseEdit_Load(object sender, System.EventArgs e)
        {
            textPatient.Text = Patients.GetPat(CaseCur.PatNum).GetNameFL();
            ListLabs         = Laboratories.Refresh();
            for (int i = 0; i < ListLabs.Count; i++)
            {
                listLab.Items.Add(ListLabs[i].Description + " " + ListLabs[i].Phone);
                if (ListLabs[i].LaboratoryNum == CaseCur.LaboratoryNum)
                {
                    listLab.SelectedIndex = i;
                }
            }
            for (int i = 0; i < Providers.List.Length; i++)
            {
                comboProv.Items.Add(Providers.List[i].Abbr);
                if (Providers.List[i].ProvNum == CaseCur.ProvNum)
                {
                    comboProv.SelectedIndex = i;
                }
            }
            Appointment apt = Appointments.GetOneApt(CaseCur.AptNum);

            if (apt != null)
            {
                if (apt.AptStatus == ApptStatus.UnschedList)
                {
                    textAppointment.Text = Lan.g(this, "Unscheduled");
                }
                else
                {
                    textAppointment.Text = apt.AptDateTime.ToShortDateString() + " " + apt.AptDateTime.ToShortTimeString();
                }
                textAppointment.Text += ", " + apt.ProcDescript;
            }
            apt = Appointments.GetOneApt(CaseCur.PlannedAptNum);
            if (apt != null)
            {
                textPlanned.Text = apt.ProcDescript;
                if (textPlanned.Text == "")
                {
                    textPlanned.Text = Lan.g(this, "Attached");
                }
            }
            if (CaseCur.DateTimeCreated.Year > 1880)
            {
                textDateCreated.Text = CaseCur.DateTimeCreated.ToString();
            }
            if (CaseCur.DateTimeSent.Year > 1880)
            {
                textDateSent.Text = CaseCur.DateTimeSent.ToString();
            }
            if (CaseCur.DateTimeRecd.Year > 1880)
            {
                textDateRecd.Text = CaseCur.DateTimeRecd.ToString();
            }
            if (CaseCur.DateTimeChecked.Year > 1880)
            {
                textDateChecked.Text = CaseCur.DateTimeChecked.ToString();
            }
            if (CaseCur.DateTimeDue.Year > 1880)
            {
                textDateDue.Text = CaseCur.DateTimeDue.ToShortDateString() + " " + CaseCur.DateTimeDue.ToShortTimeString();
            }
            textInstructions.Text = CaseCur.Instructions;
        }
コード例 #19
0
ファイル: AppointmentL.cs プロジェクト: royedwards/DRDNet
        ///<summary></summary>
        public static List <DateTime> GetSearchResults(long aptNum, DateTime afterDate, List <long> providerNums, int resultCount, TimeSpan beforeTime, TimeSpan afterTime)
        {
            if (beforeTime == TimeSpan.FromSeconds(0))           //if they didn't set a before time, set it to a large timespan so that we can use the same logic for checking appointment times.
            {
                beforeTime = TimeSpan.FromHours(25);             //bigger than any time of day.
            }
            SearchBehaviorCriteria SearchType   = (SearchBehaviorCriteria)PrefC.GetInt(PrefName.AppointmentSearchBehavior);
            List <DateTime>        retVal       = new List <DateTime>();
            DateTime           dayEvaluating    = afterDate.AddDays(1);
            Appointment        appointmentToAdd = Appointments.GetOneApt(aptNum);
            List <DateTime>    potentialProvAppointmentTime;
            List <DateTime>    potentialOpAppointmentTime;
            List <Operatory>   opsListAll                          = Operatories.GetDeepCopy();                 //all operatory Numbers
            List <Schedule>    scheduleListAll                     = Schedules.GetTwoYearPeriod(dayEvaluating); // Schedules for the given day.
            List <Appointment> appointmentListAll                  = Appointments.GetForPeriodList(dayEvaluating, dayEvaluating.AddYears(2));
            List <ScheduleOp>  schedOpListAll                      = ScheduleOps.GetForSchedList(scheduleListAll);
            List <ApptSearchProviderSchedule>  provScheds          = new List <ApptSearchProviderSchedule>();  //Provider Bar, ProviderSched Bar, Date and Provider
            List <ApptSearchOperatorySchedule> operatrorySchedules = new List <ApptSearchOperatorySchedule>(); //filtered based on SearchType
            List <long> operatoryNums = new List <long>();                                                     //more usefull than a list of operatories.

            for (int i = 0; i < opsListAll.Count; i++)
            {
                operatoryNums.Add(opsListAll[i].OperatoryNum);
            }
            while (retVal.Count < resultCount && dayEvaluating < afterDate.AddYears(2))
            {
                potentialOpAppointmentTime = new List <DateTime>();               //clear or create
                //Providers-------------------------------------------------------------------------------------------------------------------------------------
                potentialProvAppointmentTime = new List <DateTime>();             //clear or create
                provScheds = Appointments.GetApptSearchProviderScheduleForProvidersAndDate(providerNums, dayEvaluating, scheduleListAll, appointmentListAll);
                for (int i = 0; i < provScheds.Count; i++)
                {
                    for (int j = 0; j < 288; j++)               //search every 5 minute increment per day
                    {
                        if (j + appointmentToAdd.Pattern.Length > 288)
                        {
                            break;
                        }
                        if (potentialProvAppointmentTime.Contains(dayEvaluating.AddMinutes(j * 5)))
                        {
                            continue;
                        }
                        bool addDateTime = true;
                        for (int k = 0; k < appointmentToAdd.Pattern.Length; k++)
                        {
                            if ((provScheds[i].ProvBar[j + k] == false && appointmentToAdd.Pattern[k] == 'X') || provScheds[i].ProvSchedule[j + k] == false)
                            {
                                addDateTime = false;
                                break;
                            }
                        }
                        if (addDateTime)
                        {
                            potentialProvAppointmentTime.Add(dayEvaluating.AddMinutes(j * 5));
                        }
                    }
                }
                if (SearchType == SearchBehaviorCriteria.ProviderTimeOperatory)               //Handle Operatories here----------------------------------------------------------------------------
                {
                    operatrorySchedules        = GetAllForDate(dayEvaluating, scheduleListAll, appointmentListAll, schedOpListAll, operatoryNums, providerNums);
                    potentialOpAppointmentTime = new List <DateTime>(); //create or clear
                    //for(int j=0;j<operatrorySchedules.Count;j++) {//for each operatory
                    for (int i = 0; i < 288; i++)                       //search every 5 minute increment per day
                    {
                        if (i + appointmentToAdd.Pattern.Length > 288)  //skip if appointment would span across midnight
                        {
                            break;
                        }
                        for (int j = 0; j < operatrorySchedules.Count; j++)                   //for each operatory
                        //if(potentialOpAppointmentTime.Contains(dayEvaluating.AddMinutes(i*5))) {//skip if we already have this dateTime
                        //  break;
                        //}
                        {
                            bool addDateTime = true;
                            for (int k = 0; k < appointmentToAdd.Pattern.Length; k++)                       //check appointment against operatories
                            {
                                if (operatrorySchedules[j].OperatorySched[i + k] == false)
                                {
                                    addDateTime = false;
                                    break;
                                }
                            }
                            if (!addDateTime)
                            {
                                continue;
                            }
                            if (addDateTime)                            // && SearchType==SearchBehaviorCriteria.ProviderTimeOperatory) {//check appointment against providers available for the given operatory
                            {
                                bool provAvail = false;
                                for (int k = 0; k < providerNums.Count; k++)
                                {
                                    if (!operatrorySchedules[j].ProviderNums.Contains(providerNums[k]))
                                    {
                                        continue;
                                    }
                                    provAvail = true;
                                    for (int m = 0; m < appointmentToAdd.Pattern.Length; m++)
                                    {
                                        if ((provScheds[k].ProvBar[i + m] == false && appointmentToAdd.Pattern[m] == 'X') || provScheds[k].ProvSchedule[i + m] == false)                               //if provider bar time slot
                                        {
                                            provAvail = false;
                                            break;
                                        }
                                    }
                                    if (provAvail)                                     //found a provider with an available operatory
                                    {
                                        break;
                                    }
                                }
                                if (provAvail && addDateTime)                                 //operatory and provider are available
                                {
                                    potentialOpAppointmentTime.Add(dayEvaluating.AddMinutes(i * 5));
                                }
                            }
                            else                              //not using SearchBehaviorCriteria.ProviderTimeOperatory
                            {
                                if (addDateTime)
                                {
                                    potentialOpAppointmentTime.Add(dayEvaluating.AddMinutes(i * 5));
                                }
                            }
                        }
                    }
                }
                //At this point the potentialOpAppointmentTime is already filtered and only contains appointment times that match both provider time and operatory time.
                switch (SearchType)
                {
                case SearchBehaviorCriteria.ProviderTime:
                    //Add based on provider bars
                    for (int i = 0; i < potentialProvAppointmentTime.Count; i++)
                    {
                        if (potentialProvAppointmentTime[i].TimeOfDay > beforeTime || potentialProvAppointmentTime[i].TimeOfDay < afterTime)
                        {
                            continue;
                        }
                        retVal.Add(potentialProvAppointmentTime[i]); //add one for this day
                        break;                                       //stop looking through potential times for today.
                    }
                    break;

                case SearchBehaviorCriteria.ProviderTimeOperatory:
                    //add based on provider bar and operatory bar
                    for (int i = 0; i < potentialOpAppointmentTime.Count; i++)
                    {
                        if (potentialOpAppointmentTime[i].TimeOfDay > beforeTime || potentialOpAppointmentTime[i].TimeOfDay < afterTime)
                        {
                            continue;
                        }
                        retVal.Add(potentialOpAppointmentTime[i]); //add one for this day
                        break;                                     //stop looking through potential times for today.
                    }
                    break;
                }
                dayEvaluating = dayEvaluating.AddDays(1);
            }
            return(retVal);
        }
コード例 #20
0
        private bool EntriesAreValid()
        {
            //Get a new recent list of claimprocs for pat to be able to validate for provider and procedure status change.
            if (textDate.Text != "" && textDate.errorProvider1.GetError(textDate) != "")
            {
                //Either loaded blank or user deleted date. Either way blank will not make it to DB.
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            DateTime procDate = PIn.Date(textDate.Text);

            if (textDate.Text != "" && ProcList.Any(x => x.ProcDate != procDate))
            {
                if (!IsUserAuthorizedForProcDate(procDate))                 //Do not allow new ProcDate outside of date limitations.  Mimics behavior in FormProcEdit.
                {
                    return(false);
                }
                Appointment apt;
                foreach (Procedure proc in ProcList)                //first validate for all dates.
                {
                    #region Future dating completed procedures validation.
                    if (!PrefC.GetBool(PrefName.FutureTransDatesAllowed) && proc.ProcStatus == ProcStat.C && procDate > DateTime.Today)
                    {
                        MsgBox.Show(this, "Completed procedures cannot have future dates.");
                        return(false);
                    }
                    #endregion
                    #region Procedures attached to appointments date validation.
                    if (proc.AptNum == 0)
                    {
                        continue;
                    }
                    apt = Appointments.GetOneApt(proc.AptNum);
                    if (proc.ProcDate.Date != apt.AptDateTime.Date)
                    {
                        string error = Lan.g(this, "Date does not match appointment date for a procedure dated:") + " " + proc.ProcDate.ToShortDateString()
                                       + "\r\n" + Lan.g(this, "Continue anyway?");
                        if (MessageBox.Show(error, "", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return(false);
                        }
                        break;
                    }
                    #endregion
                }
            }
            List <ClaimProc> listClaimProcsForPat = ClaimProcs.RefreshForProcs(ProcList.Select(x => x.ProcNum).ToList());
            foreach (Procedure proc in ProcList)
            {
                if (proc.IsLocked)
                {
                    MsgBox.Show(this, "Locked procedures cannot be edited.");
                    return(false);
                }
                #region Provider change validation.
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.GetForProc(listClaimProcsForPat, proc.ProcNum);
                long             selectedProvNum       = (comboProv.GetSelected <Provider>()?.ProvNum ?? 0);//0 if no selection made
                if (selectedProvNum != 0 && !ProcedureL.ValidateProvider(listClaimProcsForProc, selectedProvNum, proc.ProvNum))
                {
                    return(false);
                }
                #endregion
            }
            return(true);
        }
コード例 #21
0
        private void FillMain()
        {
            int      parent;
            DateTime date;

            if (TreeHistory.Count > 0)           //not on main trunk
            {
                parent = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                date   = DateTime.MinValue;
            }
            else              //one of the main trunks
            {
                parent = 0;
                date   = cal.SelectionStart;
            }
            RefreshMainLists(parent, date);
            if (TreeHistory.Count == 0 &&      //main trunk
                (tabContr.SelectedIndex == 2 || tabContr.SelectedIndex == 3 || tabContr.SelectedIndex == 4))               //any of the dated groups
            {
                //clear any lists which are derived from a repeating list and which do not have any itmes checked off
                bool changeMade = false;
                for (int i = 0; i < TaskListsList.Length; i++)
                {
                    if (TaskListsList[i].FromNum == 0)                   //ignore because not derived from a repeating list
                    {
                        continue;
                    }
                    if (!AnyAreMarkedComplete(TaskListsList[i]))
                    {
                        DeleteEntireList(TaskListsList[i]);
                        changeMade = true;
                    }
                }
                //clear any tasks which are derived from a repeating tast and which are not checked off
                for (int i = 0; i < TasksList.Length; i++)
                {
                    if (TasksList[i].FromNum == 0)
                    {
                        continue;
                    }
                    if (!TasksList[i].TaskStatus)
                    {
                        Tasks.Delete(TasksList[i]);
                        changeMade = true;
                    }
                }
                if (changeMade)
                {
                    RefreshMainLists(parent, date);
                }
                //now add back any repeating lists and tasks that meet the criteria
                //Get lists of all repeating lists and tasks of one type.  We will pick items from these two lists.
                TaskList[] repeatingLists = new TaskList[0];
                Task[]     repeatingTasks = new Task[0];
                switch (tabContr.SelectedIndex)
                {
                case 2:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true);
                    break;

                case 3:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true);
                    break;

                case 4:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true);
                    break;
                }
                //loop through list and add back any that meet criteria.
                changeMade = false;
                bool alreadyExists;
                for (int i = 0; i < repeatingLists.Length; i++)
                {
                    //if already exists, skip
                    alreadyExists = false;
                    for (int j = 0; j < TaskListsList.Length; j++)               //loop through Main list
                    {
                        if (TaskListsList[j].FromNum == repeatingLists[i].TaskListNum)
                        {
                            alreadyExists = true;
                            break;
                        }
                    }
                    if (alreadyExists)
                    {
                        continue;
                    }
                    //otherwise, duplicate the list
                    repeatingLists[i].DateTL      = date;
                    repeatingLists[i].FromNum     = repeatingLists[i].TaskListNum;
                    repeatingLists[i].IsRepeating = false;
                    repeatingLists[i].Parent      = 0;
                    repeatingLists[i].ObjectType  = 0;                 //user will have to set explicitly
                    DuplicateExistingList(repeatingLists[i], true);
                    changeMade = true;
                }
                for (int i = 0; i < repeatingTasks.Length; i++)
                {
                    //if already exists, skip
                    alreadyExists = false;
                    for (int j = 0; j < TasksList.Length; j++)               //loop through Main list
                    {
                        if (TasksList[j].FromNum == repeatingTasks[i].TaskNum)
                        {
                            alreadyExists = true;
                            break;
                        }
                    }
                    if (alreadyExists)
                    {
                        continue;
                    }
                    //otherwise, duplicate the task
                    repeatingTasks[i].DateTask    = date;
                    repeatingTasks[i].FromNum     = repeatingTasks[i].TaskNum;
                    repeatingTasks[i].IsRepeating = false;
                    repeatingTasks[i].TaskListNum = 0;
                    Tasks.InsertOrUpdate(repeatingTasks[i], true);
                    changeMade = true;
                }
                if (changeMade)
                {
                    RefreshMainLists(parent, date);
                }
            }            //if main trunk on dated group
            listMain.Items.Clear();
            ListViewItem item;
            string       dateStr = "";

            for (int i = 0; i < TaskListsList.Length; i++)
            {
                dateStr = "";
                if (TaskListsList[i].DateTL.Year > 1880 &&
                    tabContr.SelectedIndex == 0)                     //main
                {
                    //dateStr=TaskListsList[i].DateTL.ToShortDateString()+" - ";
                    if (TaskListsList[i].DateType == TaskDateType.Day)
                    {
                        dateStr = TaskListsList[i].DateTL.ToShortDateString() + " - ";
                    }
                    else if (TaskListsList[i].DateType == TaskDateType.Week)
                    {
                        dateStr = Lan.g(this, "Week of") + " " + TaskListsList[i].DateTL.ToShortDateString() + " - ";
                    }
                    else if (TaskListsList[i].DateType == TaskDateType.Month)
                    {
                        dateStr = TaskListsList[i].DateTL.ToString("MMMM") + " - ";
                    }
                }
                item             = new ListViewItem(dateStr + TaskListsList[i].Descript, 0);
                item.ToolTipText = item.Text;
                listMain.Items.Add(item);
            }
            string objDesc = "";

            for (int i = 0; i < TasksList.Length; i++)
            {
                //checked=1, unchecked=2
                dateStr = "";
                if (tabContr.SelectedIndex == 0)               //main
                {
                    if (TasksList[i].DateTask.Year > 1880)
                    {
                        if (TasksList[i].DateType == TaskDateType.Day)
                        {
                            dateStr = TasksList[i].DateTask.ToShortDateString() + " - ";
                        }
                        else if (TasksList[i].DateType == TaskDateType.Week)
                        {
                            dateStr = Lan.g(this, "Week of") + " " + TasksList[i].DateTask.ToShortDateString() + " - ";
                        }
                        else if (TasksList[i].DateType == TaskDateType.Month)
                        {
                            dateStr = TasksList[i].DateTask.ToString("MMMM") + " - ";
                        }
                    }
                    else if (TasksList[i].DateTimeEntry.Year > 1880)
                    {
                        dateStr = TasksList[i].DateTimeEntry.ToShortDateString() + " - ";
                    }
                }
                objDesc = "";
                if (TasksList[i].ObjectType == TaskObjectType.Patient)
                {
                    if (TasksList[i].KeyNum != 0)
                    {
                        objDesc = Patients.GetPat(TasksList[i].KeyNum).GetNameLF() + " - ";
                    }
                }
                else if (TasksList[i].ObjectType == TaskObjectType.Appointment)
                {
                    if (TasksList[i].KeyNum != 0)
                    {
                        Appointment AptCur = Appointments.GetOneApt(TasksList[i].KeyNum);
                        if (AptCur != null)
                        {
                            objDesc = Patients.GetPat(AptCur.PatNum).GetNameLF()
                                      + "  " + AptCur.AptDateTime.ToString()
                                      + "  " + AptCur.ProcDescript
                                      + "  " + AptCur.Note
                                      + " - ";
                        }
                    }
                }
                if (TasksList[i].TaskStatus)                 //complete
                {
                    item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 1);
                }
                else
                {
                    item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 2);
                }
                item.ToolTipText = item.Text;
                listMain.Items.Add(item);
            }
        }