Example #1
0
        /// <summary>
        /// Constructor that takes 6 params.
        /// </summary>
        /// <param name="yourZendeskUrl">Will be formated to "https://yoursite.zendesk.com/api/v2"</param>
        /// <param name="user">Email adress of the user</param>
        /// <param name="password">LEAVE BLANK IF USING TOKEN</param>
        /// <param name="apiToken">Used if specified instead of the password</param>
        /// <param name="locale">Locale to use for Help Center requests. Defaults to "en-us" if no value is provided.</param>
        public ZendeskApi(string yourZendeskUrl,
                          string user,
                          string password,
                          string apiToken,
                          string locale,
                          string p_OAuthToken)
        {
            var formattedUrl = GetFormattedZendeskUrl(yourZendeskUrl).AbsoluteUri;

            Tickets             = new Tickets(formattedUrl, user, password, apiToken, p_OAuthToken);
            Attachments         = new Attachments(formattedUrl, user, password, apiToken, p_OAuthToken);
            Brands              = new Brands(formattedUrl, user, password, apiToken, p_OAuthToken);
            Views               = new Views(formattedUrl, user, password, apiToken, p_OAuthToken);
            Users               = new Users(formattedUrl, user, password, apiToken, p_OAuthToken);
            Requests            = new Requests.Requests(formattedUrl, user, password, apiToken, p_OAuthToken);
            Groups              = new Groups(formattedUrl, user, password, apiToken, p_OAuthToken);
            CustomAgentRoles    = new CustomAgentRoles(formattedUrl, user, password, apiToken, p_OAuthToken);
            Organizations       = new Organizations(formattedUrl, user, password, apiToken, p_OAuthToken);
            Search              = new Search(formattedUrl, user, password, apiToken, p_OAuthToken);
            Tags                = new Tags(formattedUrl, user, password, apiToken, p_OAuthToken);
            AccountsAndActivity = new AccountsAndActivity(formattedUrl, user, password, apiToken, p_OAuthToken);
            JobStatuses         = new JobStatuses(formattedUrl, user, password, apiToken, p_OAuthToken);
            Locales             = new Locales(formattedUrl, user, password, apiToken, p_OAuthToken);
            Macros              = new Macros(formattedUrl, user, password, apiToken, p_OAuthToken);
            SatisfactionRatings = new SatisfactionRatings(formattedUrl, user, password, apiToken, p_OAuthToken);
            SharingAgreements   = new SharingAgreements(formattedUrl, user, password, apiToken, p_OAuthToken);
            Triggers            = new Triggers(formattedUrl, user, password, apiToken, p_OAuthToken);
            HelpCenter          = new HelpCenterApi(formattedUrl, user, password, apiToken, locale, p_OAuthToken);
            Voice               = new Voice(formattedUrl, user, password, apiToken, p_OAuthToken);
            Schedules           = new Schedules(formattedUrl, user, password, apiToken, p_OAuthToken);
            Targets             = new Targets(formattedUrl, user, password, apiToken, p_OAuthToken);
            Automations         = new Automations(formattedUrl, user, password, apiToken, p_OAuthToken);

            ZendeskUrl = formattedUrl;
        }
Example #2
0
        private void FillGrid()
        {
            Automations.RefreshCache();
            _listAutomations = Automations.GetDeepCopy();
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Description", 200);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Trigger", 150);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Action", 150);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Details", 200);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            UI.GridRow row;
            string     detail;

            for (int i = 0; i < _listAutomations.Count; i++)
            {
                row = new OpenDental.UI.GridRow();
                row.Cells.Add(_listAutomations[i].Description);
                if (_listAutomations[i].Autotrigger == AutomationTrigger.CompleteProcedure)
                {
                    row.Cells.Add(_listAutomations[i].ProcCodes);
                }
                else
                {
                    row.Cells.Add(_listAutomations[i].Autotrigger.ToString());
                }
                row.Cells.Add(_listAutomations[i].AutoAction.ToString());
                //details:
                detail = "";
                if (_listAutomations[i].AutoAction == AutomationAction.CreateCommlog)
                {
                    detail += Defs.GetName(DefCat.CommLogTypes, _listAutomations[i].CommType)
                              + ".  " + _listAutomations[i].MessageContent;
                }
                else if (_listAutomations[i].AutoAction == AutomationAction.PrintPatientLetter)
                {
                    detail += SheetDefs.GetDescription(_listAutomations[i].SheetDefNum);
                }
                else if (_listAutomations[i].AutoAction == AutomationAction.PrintReferralLetter)
                {
                    detail += SheetDefs.GetDescription(_listAutomations[i].SheetDefNum);
                }
                else if (_listAutomations[i].AutoAction == AutomationAction.ChangePatStatus)
                {
                    detail += Lans.g("enum" + nameof(PatientStatus), _listAutomations[i].PatStatus.GetDescription());
                }
                row.Cells.Add(detail);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
 private void FormAutomationEdit_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         return;
     }
     //this happens if cancel or if user deletes a new automation
     if (IsNew)
     {
         AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum);
         Automations.Delete(AutoCur);
     }
 }
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;              //delete takes place in FormClosing
     }
     else
     {
         AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum);
         Automations.Delete(AutoCur);
         DialogResult = DialogResult.OK;
     }
 }
Example #5
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            Automation auto = new Automation();

            Automations.Insert(auto);            //so that we can attach conditions
            FormAutomationEdit FormA = new FormAutomationEdit(auto);

            FormA.IsNew = true;
            FormA.ShowDialog();
            if (FormA.DialogResult != DialogResult.OK)
            {
                return;
            }
            FillGrid();
            changed = true;
        }
Example #6
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     //if(IsNew){
     //
     //	return;
     //}
     AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum);
     Automations.Delete(AutoCur);
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         DialogResult = DialogResult.OK;
     }
 }
 public static Automations CreateAutomations(global::System.Guid automationId, string automationName, bool suspended)
 {
     Automations automations = new Automations();
     automations.AutomationId = automationId;
     automations.AutomationName = automationName;
     automations.Suspended = suspended;
     return automations;
 }
 public void AddToAutomations(Automations automations)
 {
     base.AddObject("Automations", automations);
 }
Example #9
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, 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);
        }
Example #10
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);
        }
Example #11
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description not allowed to be blank.");
                return;
            }
            AutoCur.Description = textDescription.Text;
            AutoCur.Autotrigger = (AutomationTrigger)comboTrigger.SelectedIndex; //should never be <0
            #region ProcCodes
            AutoCur.ProcCodes = "";                                              //set to correct proc code string below if necessary
            if (new[] { AutomationTrigger.CompleteProcedure, AutomationTrigger.ScheduleProcedure }.Contains(AutoCur.Autotrigger))
            {
                if (textProcCodes.Text.Contains(" "))
                {
                    MsgBox.Show(this, "Procedure codes cannot contain any spaces.");
                    return;
                }
                if (textProcCodes.Text == "")
                {
                    MsgBox.Show(this, "Please enter valid procedure code(s) first.");
                    return;
                }
                string strInvalidCodes = string.Join(", ", textProcCodes.Text.Split(',').Where(x => !ProcedureCodes.IsValidCode(x)));
                if (!string.IsNullOrEmpty(strInvalidCodes))
                {
                    MessageBox.Show(Lan.g(this, "The following procedure code(s) are not valid") + ": " + strInvalidCodes);
                    return;
                }
                AutoCur.ProcCodes = textProcCodes.Text;
            }
            #endregion ProcCodes
            #region Automation Action
            //Dictionary linking actions to their associated sheet types and the string to add to the message box text.
            //Only valid for actions PrintPatientLetter, PrintReferralLetter, ShowExamSheet, and ShowConsentForm.
            Dictionary <AutomationAction, Tuple <SheetTypeEnum, string> > dictAutoActionSheetType = new Dictionary <AutomationAction, Tuple <SheetTypeEnum, string> >()
            {
                { AutomationAction.PrintPatientLetter, Tuple.Create(SheetTypeEnum.PatientLetter, "a patient letter") },
                { AutomationAction.PrintReferralLetter, Tuple.Create(SheetTypeEnum.ReferralLetter, "a referral letter") },
                { AutomationAction.ShowExamSheet, Tuple.Create(SheetTypeEnum.ExamSheet, "an exam sheet") },
                { AutomationAction.ShowConsentForm, Tuple.Create(SheetTypeEnum.Consent, "a consent form") }
            };
            AutoCur.AutoAction         = _listAutoActions[comboAction.SelectedIndex];
            AutoCur.SheetDefNum        = 0;
            AutoCur.CommType           = 0;
            AutoCur.MessageContent     = "";
            AutoCur.AptStatus          = ApptStatus.None;
            AutoCur.AppointmentTypeNum = 0;
            switch (AutoCur.AutoAction)
            {
            case AutomationAction.CreateCommlog:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "A commlog type must be selected.");
                    return;
                }
                AutoCur.CommType       = _listCommLogTypeDefs[comboActionObject.SelectedIndex].DefNum;
                AutoCur.MessageContent = textMessage.Text;
                break;

            case AutomationAction.PopUp:
            case AutomationAction.PopUpThenDisable10Min:
                if (string.IsNullOrEmpty(textMessage.Text.Trim()))
                {
                    MsgBox.Show(this, "The message cannot be blank.");
                    return;
                }
                AutoCur.MessageContent = textMessage.Text;
                break;

            case AutomationAction.PrintPatientLetter:
            case AutomationAction.PrintReferralLetter:
            case AutomationAction.ShowExamSheet:
            case AutomationAction.ShowConsentForm:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "A sheet definition must be selected.");
                    return;
                }
                if (SheetDefs.GetDeepCopy()[comboActionObject.SelectedIndex].SheetType != dictAutoActionSheetType[AutoCur.AutoAction].Item1)
                {
                    MessageBox.Show(this, Lan.g(this, "The selected sheet type must be") + " " + dictAutoActionSheetType[AutoCur.AutoAction].Item2 + ".");
                    return;
                }
                AutoCur.SheetDefNum = SheetDefs.GetDeepCopy()[comboActionObject.SelectedIndex].SheetDefNum;
                break;

            case AutomationAction.SetApptStatus:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "An appointment status must be selected.");
                    return;
                }
                AutoCur.AptStatus = _listApptStatuses[comboActionObject.SelectedIndex];
                break;

            case AutomationAction.SetApptType:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "An appointment type must be selected.");
                    return;
                }
                AutoCur.AppointmentTypeNum = _listAptTypes[comboActionObject.SelectedIndex].AppointmentTypeNum;
                break;
            }
            #endregion Automation Action
            Automations.Update(AutoCur);            //Because always inserted before opening this form.
            DialogResult = DialogResult.OK;
        }
Example #12
0
 private void FillGrid()
 {
     if (checkDeleted.Checked)
     {
         _listPopups = Popups.GetDeletedForFamily(PatCur);
     }
     else
     {
         _listPopups = Popups.GetForFamily(PatCur);
     }
     #region Automation PopUpThenDisable10Min
     //Joe - We are mimicing popups through a new AutomationAction PopUpThenDisable10Min.
     //We want to show it in this list to avoid confusion and phone calls.
     List <long> listAutoNums = FormOpenDental.DicBlockedAutomations.Keys.ToList();
     Dictionary <long, DateTime> dictPatDate;
     //First level dictionary key is an AutomationNum.
     //Value is Dictionary<long,DateTime>.
     Popup             popup;
     Automation        autoCur;
     List <Automation> listAutomations = Automations.GetDeepCopy();
     foreach (long automationNum in listAutoNums)
     {
         dictPatDate = FormOpenDental.DicBlockedAutomations[automationNum];              //Gets all patnums for current automation.
         //Second level dictionary key is a patNum for current AutomationNum key.
         //Value is DateTime representing block until time.
         foreach (KeyValuePair <long, DateTime> kvp in dictPatDate)
         {
             if (!Patients.GetAllFamilyPatNums(new List <long>()
             {
                 kvp.Key
             }).Contains(PatCur.PatNum))
             {
                 continue;                        //Not in the same family.
             }
             autoCur = listAutomations.FirstOrDefault(x => x.AutomationNum == automationNum);
             if (autoCur == null)
             {
                 continue;
             }
             #region Dummy PopUp
             //Create dummy Popup.
             //Since we never insert these into the DB we just put them in our list that we fill the grid with.
             popup = new Popup()
             {
                 PopupNum      = automationNum,
                 PatNum        = kvp.Key,
                 PopupLevel    = EnumPopupLevel.Automation,
                 DateTimeEntry = kvp.Value.AddMinutes(-10),
                 Description   = autoCur.MessageContent
             };
             _listPopups.Add(popup);
             #endregion Dummy PopUp
         }
     }
     _listPopups = _listPopups.OrderBy(x => x.PatNum).ThenBy(x => x.PopupLevel).ToList();
     #endregion Automation PopUpThenDisable10Min
     gridMain.BeginUpdate();
     gridMain.ListGridColumns.Clear();
     GridColumn col = new GridColumn(Lan.g("TablePopupsForFamily", "Patient"), 120);
     gridMain.ListGridColumns.Add(col);
     col = new GridColumn(Lan.g("TablePopupsForFamily", "Level"), 80);
     gridMain.ListGridColumns.Add(col);
     col = new GridColumn(Lan.g("TablePopupsForFamily", "Disabled"), 60, HorizontalAlignment.Center);
     gridMain.ListGridColumns.Add(col);
     col = new GridColumn(Lan.g("TablePopupsForFamily", "Last Viewed"), 80, HorizontalAlignment.Center);
     gridMain.ListGridColumns.Add(col);
     if (checkDeleted.Checked)
     {
         col = new GridColumn(Lan.g("TablePopupsForFamily", "Deleted"), 60, HorizontalAlignment.Center);
         gridMain.ListGridColumns.Add(col);
     }
     col = new GridColumn(Lan.g("TablePopupsForFamily", "Popup Message"), 120);
     gridMain.ListGridColumns.Add(col);
     gridMain.ListGridRows.Clear();
     GridRow row;
     _listPopups.RemoveAll(x => x.PopupLevel == EnumPopupLevel.Automation && !listAutomations.Any(y => y.AutomationNum == x.PopupNum));
     for (int i = 0; i < _listPopups.Count; i++)
     {
         row = new GridRow();
         row.Cells.Add(Patients.GetPat(_listPopups[i].PatNum).GetNameLF());
         if (_listPopups[i].PopupLevel == EnumPopupLevel.Automation)
         {
             autoCur = Automations.GetFirstOrDefault(x => x.AutomationNum == _listPopups[i].PopupNum);                //Get by PK.
             //this should never happen because we remove any where the AutomationNum is not in Automations.Listt
             //if(autoCur==null) {
             //	continue;
             //}
             row.Cells.Add(Lan.g("enumEnumPopupLevel", "Auto") + ": " + Lan.g("enumEnumPopupLevel", autoCur.Autotrigger.ToString()));
             row.Cells.Add("");                    //Disabled column. Will never happen for automations.
             row.Cells.Add(_listPopups[i].DateTimeEntry.ToShortTimeString());
         }
         else
         {
             row.Cells.Add(Lan.g("enumEnumPopupLevel", _listPopups[i].PopupLevel.ToString()));
             row.Cells.Add(_listPopups[i].IsDisabled?"X":"");
             PopupEvent popEvent = _listPopEvents.FirstOrDefault(x => x.PopupNum == _listPopups[i].PopupNum);
             if (popEvent != null && popEvent.LastViewed.Year > 1880)
             {
                 row.Cells.Add(popEvent.LastViewed.ToShortTimeString());
             }
             else
             {
                 row.Cells.Add("");
             }
         }
         if (checkDeleted.Checked)
         {
             row.Cells.Add(_listPopups[i].IsArchived?"X":"");
         }
         row.Cells.Add(_listPopups[i].Description);
         row.Tag = _listPopups[i];
         gridMain.ListGridRows.Add(row);
     }
     gridMain.EndUpdate();
 }
Example #13
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDescription.Text == "")
     {
         MsgBox.Show(this, "Description not allowed to be blank.");
         return;
     }
     if (comboTrigger.SelectedIndex == (int)AutomationTrigger.CompleteProcedure)
     {
         if (textProcCodes.Text.Contains(" "))
         {
             MsgBox.Show(this, "Procedure codes cannot contain any spaces.");
             return;
         }
         if (textProcCodes.Text == "")
         {
             MsgBox.Show(this, "Please enter valid procedure code(s) first.");
             return;
         }
         string[] arrayCodes = textProcCodes.Text.Split(',');
         for (int i = 0; i < arrayCodes.Length; i++)
         {
             if (!ProcedureCodes.IsValidCode(arrayCodes[i]))
             {
                 MessageBox.Show(arrayCodes[i] + Lan.g(this, " is not a valid procedure code."));
                 return;
             }
         }
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.CreateCommlog)
     {
         if (comboCommType.SelectedIndex == -1)
         {
             MsgBox.Show(this, "A CommType must be selected.");
             return;
         }
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.PopUp)
     {
         if (textMessage.Text.Trim() == string.Empty)
         {
             MsgBox.Show(this, "Message cannot be blank.");
             return;
         }
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.PrintPatientLetter)
     {
         if (comboSheetDef.SelectedIndex == -1)
         {
             MsgBox.Show(this, "A SheetDef must be selected.");
             return;
         }
         if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.PatientLetter)
         {
             MsgBox.Show(this, "The selected sheet type must be a patient letter.");
             return;
         }
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.PrintReferralLetter)
     {
         if (comboSheetDef.SelectedIndex == -1)
         {
             MsgBox.Show(this, "A SheetDef must be selected.");
             return;
         }
         if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.ReferralLetter)
         {
             MsgBox.Show(this, "The selected sheet type must be a referral letter.");
             return;
         }
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.ShowExamSheet)
     {
         if (comboSheetDef.SelectedIndex == -1)
         {
             MsgBox.Show(this, "A SheetDef must be selected.");
             return;
         }
         if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.ExamSheet)
         {
             MsgBox.Show(this, "The selected sheet type must be an exam sheet.");
             return;
         }
     }
     AutoCur.Description = textDescription.Text;
     AutoCur.Autotrigger = (AutomationTrigger)comboTrigger.SelectedIndex;
     if (comboTrigger.SelectedIndex == (int)AutomationTrigger.CompleteProcedure)
     {
         AutoCur.ProcCodes = textProcCodes.Text;
     }
     else
     {
         AutoCur.ProcCodes = "";
     }
     AutoCur.AutoAction = (AutomationAction)comboAction.SelectedIndex;
     if (comboAction.SelectedIndex == (int)AutomationAction.PrintPatientLetter ||
         comboAction.SelectedIndex == (int)AutomationAction.PrintReferralLetter ||
         comboAction.SelectedIndex == (int)AutomationAction.ShowExamSheet)
     {
         AutoCur.SheetDefNum = SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetDefNum;
     }
     else
     {
         AutoCur.SheetDefNum = 0;
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.CreateCommlog)
     {
         AutoCur.CommType       = DefC.Short[(int)DefCat.CommLogTypes][comboCommType.SelectedIndex].DefNum;
         AutoCur.MessageContent = textMessage.Text;
     }
     else
     {
         AutoCur.CommType       = 0;
         AutoCur.MessageContent = "";
     }
     if (comboAction.SelectedIndex == (int)AutomationAction.PopUp)
     {
         AutoCur.MessageContent = textMessage.Text;
     }                            //MessageContent was already set blank if not PopUp or Commlog above.
     Automations.Update(AutoCur); //Because always inserted before opening this form.
     DialogResult = DialogResult.OK;
 }