예제 #1
0
        private void butAddCustom_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.RefAttachAdd))
            {
                return;
            }
            FormReferralSelect FormRS = new FormReferralSelect();

            FormRS.IsSelectionMode = true;
            FormRS.ShowDialog();
            if (FormRS.DialogResult != DialogResult.OK)
            {
                return;
            }
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum        = FormRS.SelectedReferral.ReferralNum;
            refattach.PatNum             = PatNum;
            refattach.RefType            = ReferralType.RefCustom;
            refattach.RefDate            = DateTimeOD.Today;
            refattach.IsTransitionOfCare = false;
            refattach.ItemOrder          = RefAttachList.Select(x => x.ItemOrder + 1).OrderByDescending(x => x).FirstOrDefault();//Max+1 or 0
            RefAttaches.Insert(refattach);
            SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred (custom) " + Referrals.GetNameFL(refattach.ReferralNum));
            FillGrid();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].RefAttachNum == refattach.RefAttachNum)
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
        }
예제 #2
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select exactly one referral first.");
                return;
            }
            int selectedIdx = gridMain.GetSelectedIndex();

            if (selectedIdx == gridMain.ListGridRows.Count - 1)         //already at bottom
            {
                return;
            }
            RefAttach sourceAttach = ((RefAttach)gridMain.ListGridRows[selectedIdx].Tag);
            RefAttach destAttach   = ((RefAttach)gridMain.ListGridRows[selectedIdx + 1].Tag);
            int       sourceIdx    = sourceAttach.ItemOrder;

            sourceAttach.ItemOrder = destAttach.ItemOrder;
            RefAttaches.Update(sourceAttach);
            destAttach.ItemOrder = sourceIdx;
            RefAttaches.Update(destAttach);
            if (!gridMain.SwapRows(selectedIdx, selectedIdx + 1))
            {
                MsgBox.Show(this, "Unable to change order.");
                return;
            }
            gridMain.SetSelected(selectedIdx + 1, true);
        }
예제 #3
0
 ///<summary>Surround with try-catch.</summary>
 private void SaveData()
 {
     if (textOrder.errorProvider1.GetError(textOrder) != "" ||
         textRefDate.errorProvider1.GetError(textRefDate) != "")
     {
         throw new ApplicationException(Lan.g(this, "Please fix data entry errors first."));
     }
     if (radioFrom.Checked)
     {
         RefAttachCur.IsFrom = true;
     }
     else
     {
         RefAttachCur.IsFrom = false;
     }
     RefAttachCur.RefDate     = PIn.PDate(textRefDate.Text);
     RefAttachCur.ItemOrder   = PIn.PInt(textOrder.Text);
     RefAttachCur.RefToStatus = (ReferralToStatus)comboRefToStatus.SelectedIndex;
     RefAttachCur.Note        = textNote.Text;
     if (IsNew)
     {
         RefAttaches.Insert(RefAttachCur);
     }
     else
     {
         RefAttaches.Update(RefAttachCur);
     }
 }
예제 #4
0
        private void FillGrid()
        {
            RefAttachList = RefAttaches.RefreshFiltered(PatNum, checkShowAll.Checked, ProcNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRefList", "From/To"), 50);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Name"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Date"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Status"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Proc"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Note"), 200);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //Referral referral;
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                row = new ODGridRow();
                if (RefAttachList[i].IsFrom)
                {
                    row.Cells.Add(Lan.g(this, "From"));
                }
                else
                {
                    row.Cells.Add(Lan.g(this, "To"));
                }
                row.Cells.Add(Referrals.GetNameFL(RefAttachList[i].ReferralNum));
                //referral=ReferralL.GetReferral(RefAttachList[i].ReferralNum);
                if (RefAttachList[i].RefDate.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(RefAttachList[i].RefDate.ToShortDateString());
                }
                row.Cells.Add(Lan.g("enumReferralToStatus", RefAttachList[i].RefToStatus.ToString()));
                if (RefAttachList[i].ProcNum == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    Procedure proc = Procedures.GetOneProc(RefAttachList[i].ProcNum, false);
                    string    str  = Procedures.GetDescription(proc);
                    row.Cells.Add(str);
                }
                row.Cells.Add(RefAttachList[i].Note);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
예제 #5
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, true, "Detach Referral?"))
     {
         return;
     }
     RefAttaches.Delete(RefAttachCur);
     DialogResult = DialogResult.OK;
 }
예제 #6
0
 ///<summary>Gets the first referral "from" for the given patient.  Will return null if no "from" found for patient.</summary>
 public static Referral GetReferralForPat(int patNum)
 {
     RefAttach[] RefAttachList = RefAttaches.Refresh(patNum);
     for (int i = 0; i < RefAttachList.Length; i++)
     {
         if (RefAttachList[i].IsFrom)
         {
             return(GetReferral(RefAttachList[i].ReferralNum));
         }
     }
     return(null);
 }
예제 #7
0
 private void butDetach_Click(object sender, EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.RefAttachDelete))
     {
         return;
     }
     if (!MsgBox.Show(this, true, "Detach Referral?"))
     {
         return;
     }
     SecurityLogs.MakeLogEntry(Permissions.RefAttachDelete, RefAttachCur.PatNum, "Referral attachment deleted for " + Referrals.GetNameFL(RefAttachCur.ReferralNum));
     RefAttaches.Delete(RefAttachCur);
     DialogResult = DialogResult.OK;
 }
예제 #8
0
        private void FillGrid()
        {
            RefAttachList = RefAttaches.Refresh(PatNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRefList", "From/To"), 50);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Name"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Date"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Status"), 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRefList", "Note"), 200);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //Referral referral;
            for (int i = 0; i < RefAttachList.Length; i++)
            {
                row = new ODGridRow();
                if (RefAttachList[i].IsFrom)
                {
                    row.Cells.Add(Lan.g(this, "From"));
                }
                else
                {
                    row.Cells.Add(Lan.g(this, "To"));
                }
                row.Cells.Add(Referrals.GetNameFL(RefAttachList[i].ReferralNum));
                //referral=Referrals.GetReferral(RefAttachList[i].ReferralNum);
                if (RefAttachList[i].RefDate.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(RefAttachList[i].RefDate.ToShortDateString());
                }
                row.Cells.Add(Lan.g("enumReferralToStatus", RefAttachList[i].RefToStatus.ToString()));
                row.Cells.Add(RefAttachList[i].Note);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
예제 #9
0
        private void butAddFrom_Click(object sender, System.EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.RefAttachAdd))
            {
                return;
            }
            FormReferralSelect FormRS = new FormReferralSelect();

            FormRS.IsSelectionMode = true;
            FormRS.ShowDialog();
            if (FormRS.DialogResult != DialogResult.OK)
            {
                return;
            }
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum = FormRS.SelectedReferral.ReferralNum;
            refattach.PatNum      = PatNum;
            refattach.IsFrom      = true;
            refattach.RefDate     = DateTimeOD.Today;
            if (FormRS.SelectedReferral.IsDoctor)             //whether using ehr or not
            //we're not going to ask.  That's stupid.
            //if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Is this an incoming transition of care from another provider?")){
            {
                refattach.IsTransitionOfCare = true;
            }
            int order = 0;

            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ItemOrder > order)
                {
                    order = RefAttachList[i].ItemOrder;
                }
            }
            refattach.ItemOrder = order + 1;
            RefAttaches.Insert(refattach);
            SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred From " + Referrals.GetNameFL(refattach.ReferralNum));
            FillGrid();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].RefAttachNum == refattach.RefAttachNum)
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }
예제 #10
0
        private void butAddTo_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.RefAttachAdd))
            {
                return;
            }
            FormReferralSelect FormRS = new FormReferralSelect();

            FormRS.IsSelectionMode = true;
            FormRS.ShowDialog();
            if (FormRS.DialogResult != DialogResult.OK)
            {
                return;
            }
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum = FormRS.SelectedReferral.ReferralNum;
            refattach.PatNum      = PatNum;
            refattach.IsFrom      = false;
            refattach.RefDate     = DateTimeOD.Today;
            if (FormRS.SelectedReferral.IsDoctor)
            {
                refattach.IsTransitionOfCare = true;
            }
            int order = 0;

            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ItemOrder > order)
                {
                    order = RefAttachList[i].ItemOrder;
                }
            }
            refattach.ItemOrder = order + 1;
            refattach.ProcNum   = ProcNum;
            RefAttaches.Insert(refattach);
            SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred To " + Referrals.GetNameFL(refattach.ReferralNum));
            FillGrid();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ReferralNum == refattach.ReferralNum)
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }
예제 #11
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //We want to help EHR users meet their summary of care measure.  So all outgoing patient referrals should warn them if they didn't enter data correctly.
     if ((ReferralType)listRefType.SelectedIndex == ReferralType.RefTo && PrefC.GetBool(PrefName.ShowFeatureEhr))
     {
         string warning = "";
         if (comboProvNum.SelectedIndex < 0)
         {
             warning += Lans.g(this, "Selected patient referral does not have a referring provider set.");
         }
         if (!checkIsTransitionOfCare.Checked)
         {
             if (warning != "")
             {
                 warning += "\r\n";
             }
             warning += Lans.g(this, "Selected patient referral is not flagged as a transition of care.");
         }
         if (warning != "")
         {
             warning += "\r\n" + Lans.g(this, "It will not meet the EHR summary of care requirements.") + "  " + Lans.g(this, "Continue anyway?");
             if (MessageBox.Show(warning, Lans.g(this, "EHR Measure Warning"), MessageBoxButtons.OKCancel) == DialogResult.Cancel)
             {
                 return;
             }
         }
     }
     //this is an old pattern
     try{
         DataToCur();
         if (IsNew)
         {
             RefAttaches.Insert(RefAttachCur);
         }
         else
         {
             RefAttaches.Update(RefAttachCur, _refAttachOld);
         }
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
예제 #12
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     if (RefAttaches.IsReferralAttached(RefCur.ReferralNum))
     {
         MsgBox.Show(this, "Cannot delete Referral because it is attached to patients");
         return;
     }
     Referrals.Delete(RefCur);
     DialogResult = DialogResult.OK;
 }
예제 #13
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //this is an old pattern
     try{
         DataToCur();
         if (IsNew)
         {
             RefAttaches.Insert(RefAttachCur);
         }
         else
         {
             RefAttaches.Update(RefAttachCur);
         }
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
예제 #14
0
        private void butAddTo_Click(object sender, EventArgs e)
        {
            FormReferralSelect FormRS = new FormReferralSelect();

            FormRS.IsSelectionMode = true;
            FormRS.ShowDialog();
            if (FormRS.DialogResult != DialogResult.OK)
            {
                return;
            }
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum = FormRS.SelectedReferral.ReferralNum;
            refattach.PatNum      = PatNum;
            refattach.IsFrom      = false;
            refattach.RefDate     = DateTime.Today;
            if (FormRS.SelectedReferral.IsDoctor)
            {
                refattach.IsTransitionOfCare = true;
            }
            int order = 0;

            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ItemOrder > order)
                {
                    order = RefAttachList[i].ItemOrder;
                }
            }
            refattach.ItemOrder = order + 1;
            refattach.ProcNum   = ProcNum;
            RefAttaches.Insert(refattach);
            FillGrid();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ReferralNum == refattach.ReferralNum)
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }
예제 #15
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (tbRefSelect.SelectedRow == -1)
            {
                return;
            }
            Referral RefCur = (Referral)AList[tbRefSelect.SelectedRow];

            if (RefAttaches.IsReferralAttached(RefCur.ReferralNum))
            {
                MessageBox.Show(Lan.g(this, "Cannot delete Referral because it is attached to patients"));
                return;
            }
            if (!MsgBox.Show(this, true, "Delete Referral?"))
            {
                return;
            }
            Referrals.Delete(RefCur);
            tbRefSelect.SelectedRow = -1;
            FillTable();
        }
예제 #16
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //Cur.IsFrom already handled
     if (textOrder.errorProvider1.GetError(textOrder) != "" ||
         textRefDate.errorProvider1.GetError(textRefDate) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     RefAttachCur.RefDate   = PIn.PDate(textRefDate.Text);
     RefAttachCur.ItemOrder = PIn.PInt(textOrder.Text);
     if (IsNew)
     {
         RefAttaches.Insert(RefAttachCur);
     }
     else
     {
         RefAttaches.Update(RefAttachCur);
     }
     DialogResult = DialogResult.OK;
 }
예제 #17
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);
        }
예제 #18
0
        private void gridMu_CellClick(object sender, ODGridClickEventArgs e)
        {
            FormMedical FormMed;

            if (e.Col == 3)
            {
                switch (listMu[e.Row].MeasureType)
                {
                case EhrMeasureType.ProblemList:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabProblems");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.MedicationList:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabMedications");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.AllergyList:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabAllergies");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.Demographics:
                    FormPatientEdit FormPatEdit = new FormPatientEdit(PatCur, PatFamCur);
                    FormPatEdit.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.Education:
                    FormEhrEduResourcesPat FormEDUPat = new FormEhrEduResourcesPat();
                    FormEDUPat.patCur = PatCur;
                    FormEDUPat.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.TimelyAccess:
                case EhrMeasureType.ElectronicCopyAccess:
                    FormPatientPortal FormPatPort = new FormPatientPortal(PatCur);
                    FormPatPort.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.ProvOrderEntry:
                case EhrMeasureType.CPOE_MedOrdersOnly:
                case EhrMeasureType.CPOE_PreviouslyOrdered:
                    //LaunchOrdersWindow();
                    break;

                case EhrMeasureType.Rx:
                    //no action available
                    break;

                case EhrMeasureType.VitalSigns:
                case EhrMeasureType.VitalSignsBMIOnly:
                case EhrMeasureType.VitalSignsBPOnly:
                case EhrMeasureType.VitalSigns2014:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabVitalSigns");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.Smoking:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabTobaccoUse");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.Lab:
                    if (DataConnection.DBtype == DatabaseType.Oracle)
                    {
                        MsgBox.Show(this, "Labs not supported with Oracle");
                        break;
                    }
                    FormEhrLabOrders FormLP = new FormEhrLabOrders();
                    FormLP.PatCur = PatCur;
                    FormLP.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.ElectronicCopy:
                    if (listMu[e.Row].Action == "Provide elect copy to Pt")
                    {
                        FormEhrElectronicCopy FormE = new FormEhrElectronicCopy();
                        FormE.PatCur = PatCur;
                        FormE.ShowDialog();
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.ClinicalSummaries:
                    FormEhrClinicalSummary FormCS = new FormEhrClinicalSummary();
                    FormCS.PatCur = PatCur;
                    FormCS.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.Reminders:
                    FormEhrReminders FormRem = new FormEhrReminders();
                    FormRem.PatCur = PatCur;
                    FormRem.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.MedReconcile:
                    int compare = EhrMeasures.CompareReferralsToReconciles(PatNum);
                    if (compare == 1 || compare == 0)                         //Referral count is less than reconcile count or both are zero.
                    {
                        FormReferralSelect FormRS = new FormReferralSelect();
                        FormRS.IsDoctorSelectionMode = true;
                        FormRS.IsSelectionMode       = true;
                        FormRS.ShowDialog();
                        if (FormRS.DialogResult != DialogResult.OK)
                        {
                            return;
                        }
                        List <RefAttach> RefAttachList = RefAttaches.RefreshFiltered(PatNum, false, 0);
                        RefAttach        refattach     = new RefAttach();
                        refattach.ReferralNum = FormRS.SelectedReferral.ReferralNum;
                        refattach.PatNum      = PatNum;
                        refattach.RefType     = ReferralType.RefFrom;
                        refattach.RefDate     = DateTimeOD.Today;
                        if (FormRS.SelectedReferral.IsDoctor)                                 //whether using ehr or not
                        {
                            refattach.IsTransitionOfCare = true;
                        }
                        int order = 0;
                        for (int i = 0; i < RefAttachList.Count; i++)
                        {
                            if (RefAttachList[i].ItemOrder > order)
                            {
                                order = RefAttachList[i].ItemOrder;
                            }
                        }
                        refattach.ItemOrder = order + 1;
                        RefAttaches.Insert(refattach);
                        SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred From " + Referrals.GetNameFL(refattach.ReferralNum));
                    }
                    else if (compare == -1)                           //The referral count is greater than the reconcile count.
                    //So we do not need to show the referral window, we just need to reconcile below.
                    {
                    }
                    FormEhrSummaryOfCare FormMedRec = new FormEhrSummaryOfCare();
                    FormMedRec.PatCur = PatCur;
                    FormMedRec.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.SummaryOfCare:
                    FormEhrSummaryOfCare FormSoC = new FormEhrSummaryOfCare();
                    FormSoC.PatCur = PatCur;
                    FormSoC.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.SummaryOfCareElectronic:
                    FormEhrSummaryOfCare FormSoCE = new FormEhrSummaryOfCare();
                    FormSoCE.PatCur = PatCur;
                    FormSoCE.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.SecureMessaging:
                    if (PrefC.GetInt(PrefName.MeaningfulUseTwo) == 2)                           /*Modified Stage 2*/
                    {
                        FormWebMailMessageEdit FormWMME = new FormWebMailMessageEdit(PatCur.PatNum);
                        FormWMME.ShowDialog();
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.FamilyHistory:
                    FormMed = new FormMedical(PatNotCur, PatCur, "tabFamHealthHist");
                    FormMed.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.ElectronicNote:
                    //Sign a Note
                    break;

                case EhrMeasureType.CPOE_RadiologyOrdersOnly:
                case EhrMeasureType.CPOE_LabOrdersOnly:
                    if (DataConnection.DBtype == DatabaseType.Oracle)
                    {
                        MsgBox.Show(this, "Labs not supported with Oracle");
                        break;
                    }
                    FormEhrLabOrders FormLab = new FormEhrLabOrders();
                    FormLab.PatCur = PatCur;
                    FormLab.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.LabImages:
                    if (DataConnection.DBtype == DatabaseType.Oracle)
                    {
                        MsgBox.Show(this, "Labs not supported with Oracle");
                        break;
                    }
                    FormEhrLabOrders FormLO = new FormEhrLabOrders();
                    FormLO.PatCur = PatCur;
                    FormLO.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.DrugDrugInteractChecking:
                    EhrMeasureEvent measureEventDDIC = new EhrMeasureEvent();
                    measureEventDDIC.DateTEvent = DateTime.Now;
                    measureEventDDIC.EventType  = EhrMeasureEventType.DrugDrugInteractChecking;
                    measureEventDDIC.MoreInfo   = EhrMeasureEvents.GetLatestInfoByType(EhrMeasureEventType.DrugDrugInteractChecking);
                    measureEventDDIC.IsNew      = true;
                    FormEhrMeasureEventEdit FormDDIC = new FormEhrMeasureEventEdit(measureEventDDIC);
                    FormDDIC.MeasureDescript = "Explain how you have enabled Drug-Drug Interaction Checking";
                    FormDDIC.ShowDialog();
                    if (FormDDIC.DialogResult == DialogResult.OK)
                    {
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.DrugFormularyChecking:
                    EhrMeasureEvent measureEventDFC = new EhrMeasureEvent();
                    measureEventDFC.DateTEvent = DateTime.Now;
                    measureEventDFC.EventType  = EhrMeasureEventType.DrugFormularyChecking;
                    measureEventDFC.MoreInfo   = EhrMeasureEvents.GetLatestInfoByType(EhrMeasureEventType.DrugFormularyChecking);
                    measureEventDFC.IsNew      = true;
                    FormEhrMeasureEventEdit FormDFC = new FormEhrMeasureEventEdit(measureEventDFC);
                    FormDFC.MeasureDescript = "Explain how you have enabled Drug Formulary Checks";
                    FormDFC.ShowDialog();
                    if (FormDFC.DialogResult == DialogResult.OK)
                    {
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.ProtectElectHealthInfo:
                    EhrMeasureEvent measureEventPEHI = new EhrMeasureEvent();
                    measureEventPEHI.DateTEvent = DateTime.Now;
                    measureEventPEHI.EventType  = EhrMeasureEventType.ProtectElectHealthInfo;
                    measureEventPEHI.MoreInfo   = EhrMeasureEvents.GetLatestInfoByType(EhrMeasureEventType.ProtectElectHealthInfo);
                    measureEventPEHI.IsNew      = true;
                    FormEhrMeasureEventEdit FormPEHI = new FormEhrMeasureEventEdit(measureEventPEHI);
                    FormPEHI.MeasureDescript = "Have you performed your security risk analysis?  Explain.";
                    FormPEHI.ShowDialog();
                    if (FormPEHI.DialogResult == DialogResult.OK)
                    {
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.ImmunizationRegistries:
                    EhrMeasureEvent measureEventIR = new EhrMeasureEvent();
                    measureEventIR.DateTEvent = DateTime.Now;
                    measureEventIR.EventType  = EhrMeasureEventType.ImmunizationRegistries;
                    measureEventIR.MoreInfo   = EhrMeasureEvents.GetLatestInfoByType(EhrMeasureEventType.ImmunizationRegistries);
                    measureEventIR.IsNew      = true;
                    FormEhrMeasureEventEdit FormIR = new FormEhrMeasureEventEdit(measureEventIR);
                    FormIR.MeasureDescript = "Check with your state agency for guidance and recommendations.  Usually excluded.  Explain.";
                    FormIR.ShowDialog();
                    if (FormIR.DialogResult == DialogResult.OK)
                    {
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.SyndromicSurveillance:
                    EhrMeasureEvent measureEventSS = new EhrMeasureEvent();
                    measureEventSS.DateTEvent = DateTime.Now;
                    measureEventSS.EventType  = EhrMeasureEventType.SyndromicSurveillance;
                    measureEventSS.MoreInfo   = EhrMeasureEvents.GetLatestInfoByType(EhrMeasureEventType.SyndromicSurveillance);
                    measureEventSS.IsNew      = true;
                    FormEhrMeasureEventEdit FormSS = new FormEhrMeasureEventEdit(measureEventSS);
                    FormSS.MeasureDescript = "Check with your state agency for guidance and recommendations.  Usually excluded.  Explain.";
                    FormSS.ShowDialog();
                    if (FormSS.DialogResult == DialogResult.OK)
                    {
                        FillGridMu();
                    }
                    break;

                case EhrMeasureType.PatientList:
                    FormPatListEHR2014 FormPL = new FormPatListEHR2014();
                    FormPL.ShowDialog();
                    FillGridMu();
                    break;

                case EhrMeasureType.ClinicalInterventionRules:
                    FormCdsTriggers FormET = new FormCdsTriggers();
                    FormET.ShowDialog();
                    FillGridMu();
                    break;
                }
            }
            if (e.Col == 4)
            {
                switch (listMu[e.Row].MeasureType)
                {
                case EhrMeasureType.MedReconcile:
                    int compare = EhrMeasures.CompareReferralsToReconciles(PatNum);
                    if (compare == 1 || compare == 0)
                    {
                        FormReferralSelect FormRS = new FormReferralSelect();
                        FormRS.IsDoctorSelectionMode = true;
                        FormRS.IsSelectionMode       = true;
                        FormRS.ShowDialog();
                        if (FormRS.DialogResult == DialogResult.OK)
                        {
                            List <RefAttach> RefAttachList = RefAttaches.RefreshFiltered(PatNum, false, 0);
                            RefAttach        refattach     = new RefAttach();
                            refattach.ReferralNum = FormRS.SelectedReferral.ReferralNum;
                            refattach.PatNum      = PatNum;
                            refattach.RefType     = ReferralType.RefFrom;
                            refattach.RefDate     = DateTimeOD.Today;
                            if (FormRS.SelectedReferral.IsDoctor)                                     //whether using ehr or not
                            //we're not going to ask.  That's stupid.
                            //if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Is this an incoming transition of care from another provider?")){
                            {
                                refattach.IsTransitionOfCare = true;
                            }
                            int order = 0;
                            for (int i = 0; i < RefAttachList.Count; i++)
                            {
                                if (RefAttachList[i].ItemOrder > order)
                                {
                                    order = RefAttachList[i].ItemOrder;
                                }
                            }
                            refattach.ItemOrder = order + 1;
                            RefAttaches.Insert(refattach);
                            SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred From " + Referrals.GetNameFL(refattach.ReferralNum));
                            FormMedicationReconcile FormMedRec = new FormMedicationReconcile();
                            FormMedRec.PatCur = PatCur;
                            FormMedRec.ShowDialog();
                        }
                    }
                    else if (compare == -1)
                    {
                        FormMedicationReconcile FormMedRec = new FormMedicationReconcile();
                        FormMedRec.PatCur = PatCur;
                        FormMedRec.ShowDialog();
                    }
                    FillGridMu();
                    //ResultOnClosing=EhrFormResult.Referrals;
                    //Close();
                    break;

                case EhrMeasureType.SummaryOfCare:
                case EhrMeasureType.SummaryOfCareElectronic:
                    FormReferralsPatient FormRefSum = new FormReferralsPatient();
                    FormRefSum.PatNum = PatCur.PatNum;
                    FormRefSum.ShowDialog();
                    FillGridMu();
                    //ResultOnClosing=EhrFormResult.Referrals;
                    //Close();
                    break;

                case EhrMeasureType.Lab:
                    //Redundant now that everything is done from one window
                    break;

                case EhrMeasureType.CPOE_RadiologyOrdersOnly:
                    if (DataConnection.DBtype == DatabaseType.Oracle)
                    {
                        MsgBox.Show(this, "Labs not supported with Oracle");
                        break;
                    }
                    //As of v15.4 we started storing radiology orders at the procedure level by flagging the procedure itself as IsCpoe.
                    //Show the radiology order window which will be the best way for the provider to mark "radiology orders" as CPOE.
                    FormRadOrderList FormROL = new FormRadOrderList(Security.CurUser);
                    FormROL.ShowDialog();                            //Do not use a non-modal window in this case due to needing to refresh the grid after closing.
                    //FormEhrLabOrders FormRad=new FormEhrLabOrders();
                    //FormRad.PatCur=PatCur;
                    //FormRad.ShowDialog();
                    FillGridMu();
                    break;
                }
            }
        }
예제 #19
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);
        }
예제 #20
0
        private void FormReferralEdit_Load(object sender, System.EventArgs e)
        {
            listSpecialty.Items.Clear();
            for (int i = 0; i < Enum.GetNames(typeof(DentalSpecialty)).Length; i++)
            {
                listSpecialty.Items.Add(Lan.g("enumDentalSpecialty", Enum.GetNames(typeof(DentalSpecialty))[i]));
            }
            if (IsPatient)
            {
                if (IsNew)
                {
                    Text = Lan.g(this, "Add Referral");
                    Family  FamCur = Patients.GetFamily(RefCur.PatNum);
                    Patient PatCur = FamCur.GetPatient(RefCur.PatNum);
                    RefCur.Address  = PatCur.Address;
                    RefCur.Address2 = PatCur.Address2;
                    RefCur.City     = PatCur.City;
                    RefCur.EMail    = PatCur.Email;
                    RefCur.FName    = PatCur.FName;
                    RefCur.LName    = PatCur.LName;
                    RefCur.MName    = PatCur.MiddleI;
                    //RefCur.PatNum=Patients.Cur.PatNum;//already handled
                    RefCur.SSN       = PatCur.SSN;
                    RefCur.Telephone = TelephoneNumbers.FormatNumbersExactTen(PatCur.HmPhone);
                    if (PatCur.WkPhone == "")
                    {
                        RefCur.Phone2 = PatCur.WirelessPhone;
                    }
                    else
                    {
                        RefCur.Phone2 = PatCur.WkPhone;
                    }
                    RefCur.ST  = PatCur.State;
                    RefCur.Zip = PatCur.Zip;
                }
                labelPatient.Visible        = true;
                textLName.ReadOnly          = true;
                textFName.ReadOnly          = true;
                textMName.ReadOnly          = true;
                textTitle.ReadOnly          = true;
                textAddress.ReadOnly        = true;
                textAddress2.ReadOnly       = true;
                textCity.ReadOnly           = true;
                textST.ReadOnly             = true;
                textZip.ReadOnly            = true;
                checkNotPerson.Enabled      = false;
                textPhone1.ReadOnly         = true;
                textPhone2.ReadOnly         = true;
                textPhone3.ReadOnly         = true;
                textSSN.ReadOnly            = true;
                radioTIN.Enabled            = false;
                textEmail.ReadOnly          = true;
                listSpecialty.Enabled       = false;
                listSpecialty.SelectedIndex = -1;
                checkIsDoctor.Enabled       = false;
                textNotes.Select();
            }
            else             //non patient
            {
                if (IsNew)
                {
                    this.Text        = Lan.g(this, "Add Referral");
                    RefCur           = new Referral();
                    RefCur.Specialty = DentalSpecialty.General;
                }
                listSpecialty.SelectedIndex = (int)RefCur.Specialty;
                textLName.Select();
            }
            checkIsDoctor.Checked  = RefCur.IsDoctor;
            checkNotPerson.Checked = RefCur.NotPerson;
            checkHidden.Checked    = RefCur.IsHidden;
            textLName.Text         = RefCur.LName;
            textFName.Text         = RefCur.FName;
            textMName.Text         = RefCur.MName;
            textTitle.Text         = RefCur.Title;
            textAddress.Text       = RefCur.Address;
            textAddress2.Text      = RefCur.Address2;
            textCity.Text          = RefCur.City;
            textST.Text            = RefCur.ST;
            textZip.Text           = RefCur.Zip;
            string phone = RefCur.Telephone;

            if (phone != null && phone.Length == 10)
            {
                textPhone1.Text = phone.Substring(0, 3);
                textPhone2.Text = phone.Substring(3, 3);
                textPhone3.Text = phone.Substring(6);
            }
            textSSN.Text = RefCur.SSN;
            if (RefCur.UsingTIN)
            {
                radioTIN.Checked = true;
            }
            else
            {
                radioSSN.Checked = true;
            }
            textNationalProvID.Text = RefCur.NationalProvID;
            textOtherPhone.Text     = RefCur.Phone2;
            textEmail.Text          = RefCur.EMail;
            textNotes.Text          = RefCur.Note;
            //Patients using:
            string[] patsTo   = RefAttaches.GetPats(RefCur.ReferralNum, false);
            string[] patsFrom = RefAttaches.GetPats(RefCur.ReferralNum, true);
            textPatientsNumTo.Text   = patsTo.Length.ToString();
            textPatientsNumFrom.Text = patsFrom.Length.ToString();
            comboPatientsTo.Items.Clear();
            comboPatientsFrom.Items.Clear();
            for (int i = 0; i < patsTo.Length; i++)
            {
                comboPatientsTo.Items.Add(patsTo[i]);
            }
            for (int i = 0; i < patsFrom.Length; i++)
            {
                comboPatientsFrom.Items.Add(patsFrom[i]);
            }
            if (patsTo.Length > 0)
            {
                comboPatientsTo.SelectedIndex = 0;
            }
            if (patsFrom.Length > 0)
            {
                comboPatientsFrom.SelectedIndex = 0;
            }
            comboSlip.Items.Add(Lan.g(this, "Default"));
            comboSlip.SelectedIndex = 0;
            SlipList = SheetDefs.GetCustomForType(SheetTypeEnum.ReferralSlip);
            for (int i = 0; i < SlipList.Count; i++)
            {
                comboSlip.Items.Add(SlipList[i].Description);
                if (RefCur.Slip == SlipList[i].SheetDefNum)
                {
                    comboSlip.SelectedIndex = i + 1;
                }
            }
        }
예제 #21
0
        private void FillGrid()
        {
            RefAttachList = RefAttaches.RefreshFiltered(PatNum, true, 0);
            string referralDescript = DisplayFields.GetForCategory(DisplayFieldCategory.PatientInformation)
                                      .FirstOrDefault(x => x.InternalName == "Referrals")?.Description;

            if (string.IsNullOrWhiteSpace(referralDescript))             //either not displaying the Referral field or no description entered, default to 'Referral (other)'
            {
                referralDescript = Lan.g(this, "Referral (other)");
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Referral Type"), 85));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Name"), 120));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Date"), 65));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Status"), 70));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Proc"), 120));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Note"), 170));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRefList", "Email"), 190));
            gridMain.ListGridRows.Clear();
            bool          hasInvalidRef = false;
            GridRow       row;
            List <string> listRefTypeNames = new List <string>()
            {
                Lan.g(this, "To"), Lan.g(this, "From"), referralDescript
            };

            for (int i = 0; i < RefAttachList.Count; i++)
            {
                RefAttach refAttachCur = RefAttachList[i];
                if (ProcNum != 0 && !checkShowAll.Checked &&
                    ProcNum != refAttachCur.ProcNum)
                {
                    continue;
                }
                row = new GridRow();
                row.Cells.Add(listRefTypeNames[(int)refAttachCur.RefType]);
                row.Cells.Add(Referrals.GetNameFL(refAttachCur.ReferralNum));
                if (refAttachCur.RefDate.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(refAttachCur.RefDate.ToShortDateString());
                }
                row.Cells.Add(Lan.g("enumReferralToStatus", refAttachCur.RefToStatus.ToString()));
                if (refAttachCur.ProcNum == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    Procedure proc = Procedures.GetOneProc(refAttachCur.ProcNum, false);
                    string    str  = Procedures.GetDescription(proc);
                    row.Cells.Add(str);
                }
                row.Cells.Add(refAttachCur.Note);
                Referral referral = ReferralL.GetReferral(refAttachCur.ReferralNum, false);
                if (referral == null)
                {
                    hasInvalidRef = true;
                    continue;
                }
                row.Cells.Add(referral.EMail);
                row.Tag = refAttachCur;
                gridMain.ListGridRows.Add(row);
            }
            if (hasInvalidRef)
            {
                ReferralL.ShowReferralErrorMsg();
            }
            gridMain.EndUpdate();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].RefAttachNum == DefaultRefAttachNum)
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
        }
예제 #22
0
        private void butAddTo_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.RefAttachAdd))
            {
                return;
            }
            FormReferralSelect FormRS = new FormReferralSelect();

            FormRS.IsSelectionMode = true;
            FormRS.ShowDialog();
            if (FormRS.DialogResult != DialogResult.OK)
            {
                return;
            }
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum        = FormRS.SelectedReferral.ReferralNum;
            refattach.PatNum             = PatNum;
            refattach.RefType            = ReferralType.RefTo;
            refattach.RefDate            = DateTimeOD.Today;
            refattach.IsTransitionOfCare = FormRS.SelectedReferral.IsDoctor;
            refattach.ItemOrder          = RefAttachList.Select(x => x.ItemOrder + 1).OrderByDescending(x => x).FirstOrDefault();//Max+1 or 0
            refattach.ProcNum            = ProcNum;
            //We want to help EHR users meet their measures.  Therefore, we are going to make an educated guess as to who is making this referral.
            //We are doing this for non-EHR users as well because we think it might be nice automation.
            long provNumLastAppt = Appointments.GetProvNumFromLastApptForPat(PatNum);

            if (Security.CurUser.ProvNum != 0)
            {
                refattach.ProvNum = Security.CurUser.ProvNum;
            }
            else if (provNumLastAppt != 0)
            {
                refattach.ProvNum = provNumLastAppt;
            }
            else
            {
                refattach.ProvNum = Patients.GetProvNum(PatNum);
            }
            RefAttaches.Insert(refattach);
            SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd, PatNum, "Referred To " + Referrals.GetNameFL(refattach.ReferralNum));
            if (PrefC.GetBool(PrefName.AutomaticSummaryOfCareWebmail))
            {
                FormRefAttachEdit FormRAE = new FormRefAttachEdit();
                FormRAE.RefAttachCur = refattach;
                FormRAE.ShowDialog();
                //In order to help offices meet EHR Summary of Care measure 1 of Core Measure 15 of 17, we are going to send a summary of care to the patient portal behind the scenes.
                //We can send the summary of care to the patient instead of to the Dr. because of the following point in the Additional Information section of the Core Measure:
                //"The EP can send an electronic or paper copy of the summary care record directly to the next provider or can provide it to the patient to deliver to the next provider, if the patient can reasonably expected to do so and meet Measure 1."
                //We will only send the summary of care if the ref attach is a TO referral and is a transition of care.
                if (FormRAE.DialogResult == DialogResult.OK && refattach.RefType == ReferralType.RefTo && refattach.IsTransitionOfCare)
                {
                    try {
                        //This is like FormEhrClinicalSummary.butSendToPortal_Click such that the email gets treated like a web mail.
                        Patient PatCur = Patients.GetPat(PatNum);
                        string  strCcdValidationErrors = EhrCCD.ValidateSettings();
                        if (strCcdValidationErrors != "")
                        {
                            throw new Exception();
                        }
                        strCcdValidationErrors = EhrCCD.ValidatePatient(PatCur);
                        if (strCcdValidationErrors != "")
                        {
                            throw new Exception();
                        }
                        Provider prov = null;
                        if (Security.CurUser.ProvNum != 0)
                        {
                            prov = Providers.GetProv(Security.CurUser.ProvNum);
                        }
                        else
                        {
                            prov = Providers.GetProv(PatCur.PriProv);
                        }
                        EmailMessage msgWebMail = new EmailMessage();                //New mail object
                        msgWebMail.FromAddress    = prov.GetFormalName();            //Adding from address
                        msgWebMail.ToAddress      = PatCur.GetNameFL();              //Adding to address
                        msgWebMail.PatNum         = PatCur.PatNum;                   //Adding patient number
                        msgWebMail.SentOrReceived = EmailSentOrReceived.WebMailSent; //Setting to sent
                        msgWebMail.ProvNumWebMail = prov.ProvNum;                    //Adding provider number
                        msgWebMail.Subject        = "Referral To " + FormRS.SelectedReferral.GetNameFL();
                        msgWebMail.BodyText       =
                            "You have been referred to another provider.  Your summary of care is attached.\r\n"
                            + "You may give a copy of this summary of care to the referred provider if desired.\r\n"
                            + "The contact information for the doctor you are being referred to is as follows:\r\n"
                            + "\r\n";
                        //Here we provide the same information that would go out on a Referral Slip.
                        //When the user prints a Referral Slip, the doctor referred to information is included and contains the doctor's name, address, and phone.
                        msgWebMail.BodyText += "Name: " + FormRS.SelectedReferral.GetNameFL() + "\r\n";
                        if (FormRS.SelectedReferral.Address.Trim() != "")
                        {
                            msgWebMail.BodyText += "Address: " + FormRS.SelectedReferral.Address.Trim() + "\r\n";
                            if (FormRS.SelectedReferral.Address2.Trim() != "")
                            {
                                msgWebMail.BodyText += "\t" + FormRS.SelectedReferral.Address2.Trim() + "\r\n";
                            }
                            msgWebMail.BodyText += "\t" + FormRS.SelectedReferral.City + " " + FormRS.SelectedReferral.ST + " " + FormRS.SelectedReferral.Zip + "\r\n";
                        }
                        if (FormRS.SelectedReferral.Telephone != "")
                        {
                            msgWebMail.BodyText += "Phone: (" + FormRS.SelectedReferral.Telephone.Substring(0, 3) + ")" + FormRS.SelectedReferral.Telephone.Substring(3, 3) + "-" + FormRS.SelectedReferral.Telephone.Substring(6) + "\r\n";
                        }
                        msgWebMail.BodyText +=
                            "\r\n"
                            + "To view the Summary of Care for the referral to this provider:\r\n"
                            + "1) Download all attachments to the same folder.  Do not rename the files.\r\n"
                            + "2) Open the ccd.xml file in an internet browser.";
                        msgWebMail.MsgDateTime = DateTime.Now;                      //Message time is now
                        msgWebMail.PatNumSubj  = PatCur.PatNum;                     //Subject of the message is current patient
                        string ccd = "";
                        Cursor = Cursors.WaitCursor;
                        ccd    = EhrCCD.GenerateSummaryOfCare(Patients.GetPat(PatNum));                                                           //Create summary of care, can throw exceptions but they're caught below
                        msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xml", Encoding.UTF8.GetBytes(ccd)));                           //Create summary of care attachment, can throw exceptions but caught below
                        msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xsl", Encoding.UTF8.GetBytes(FormEHR.GetEhrResource("CCD")))); //Create xsl attachment, can throw exceptions
                        EmailMessages.Insert(msgWebMail);                                                                                         //Insert mail into DB for patient portal
                        EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
                        newMeasureEvent.DateTEvent = DateTime.Now;
                        newMeasureEvent.EventType  = EhrMeasureEventType.SummaryOfCareProvidedToDr;
                        newMeasureEvent.PatNum     = PatCur.PatNum;
                        newMeasureEvent.FKey       = FormRAE.RefAttachCur.RefAttachNum;                //Can be 0 if user didn't pick a referral for some reason.
                        EhrMeasureEvents.Insert(newMeasureEvent);
                    }
                    catch {
                        //We are just trying to be helpful so it doesn't really matter if something failed above.
                        //They can simply go to the EHR dashboard and send the summary of care manually like they always have.  They will get detailed validation errors there.
                        MsgBox.Show(this, "There was a problem automatically sending a summary of care.  Please go to the EHR dashboard to send a summary of care to meet the summary of care core measure.");
                    }
                }
            }
            Cursor = Cursors.Default;
            FillGrid();
            for (int i = 0; i < RefAttachList.Count; i++)
            {
                if (RefAttachList[i].ReferralNum == refattach.ReferralNum)
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }
예제 #23
0
        private void FillGrid()
        {
            if (textDateTo.errorProvider1.GetError(textDateTo) != "" || textDateFrom.errorProvider1.GetError(textDateFrom) != "")               //Test To and From dates
            {
                MsgBox.Show(this, "Please enter valid To and From dates.");
                return;
            }
            DateFrom = PIn.Date(textDateFrom.Text);
            DateTo   = PIn.Date(textDateTo.Text);
            if (DateTo < DateFrom)
            {
                MsgBox.Show(this, "Date To cannot be before Date From.");
                return;
            }
//todo: checkbox
            RefAttachList = RefAttaches.RefreshForReferralProcTrack(DateFrom, DateTo, checkComplete.Checked);
            Table         = Procedures.GetReferred(DateFrom, DateTo, checkComplete.Checked);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g(this, "Patient"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Referred To"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Description"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Note"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date Referred"), 86);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date Done"), 86);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Status"), 84);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            DateTime  date;

            for (int i = 0; i < Table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Patients.GetPat(PIn.Long(Table.Rows[i]["PatNum"].ToString())).GetNameLF());
                row.Cells.Add(Table.Rows[i]["LName"].ToString() + ", " + Table.Rows[i]["FName"].ToString() + " " + Table.Rows[i]["MName"].ToString());
                row.Cells.Add(ProcedureCodes.GetLaymanTerm(PIn.Long(Table.Rows[i]["CodeNum"].ToString())));
                row.Cells.Add(Table.Rows[i]["Note"].ToString());
                date = PIn.Date(Table.Rows[i]["RefDate"].ToString());
                if (date.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(date.ToShortDateString());
                }
                date = PIn.Date(Table.Rows[i]["DateProcComplete"].ToString());
                if (date.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(date.ToShortDateString());
                }
                ReferralToStatus refStatus = (ReferralToStatus)PIn.Int(Table.Rows[i]["RefToStatus"].ToString());
                if (refStatus == ReferralToStatus.None)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(refStatus.ToString());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
예제 #24
0
        ///<summary>ProcCodes will be null unless trigger is CompleteProcedure.  This routine will generally fail silently.  Will return true if a trigger happened.</summary>
        public static bool Trigger(AutomationTrigger trigger, List <string> procCodes, long patNum)
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            bool automationHappened = false;

            for (int i = 0; i < Automations.Listt.Count; i++)
            {
                if (Automations.Listt[i].Autotrigger != trigger)
                {
                    continue;
                }
                if (trigger == AutomationTrigger.CompleteProcedure)
                {
                    if (procCodes == null)
                    {
                        continue;                        //fail silently
                    }
                    bool     codeFound  = false;
                    string[] arrayCodes = Automations.Listt[i].ProcCodes.Split(',');
                    for (int p = 0; p < procCodes.Count; p++)
                    {
                        for (int a = 0; a < arrayCodes.Length; a++)
                        {
                            if (arrayCodes[a] == procCodes[p])
                            {
                                codeFound = true;
                                break;
                            }
                        }
                    }
                    if (!codeFound)
                    {
                        continue;
                    }
                }
                //matching automation item has been found
                //Get possible list of conditions that exist for this automation item
                List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(Automations.Listt[i].AutomationNum);
                if (Automations.Listt[i].AutoAction == AutomationAction.CreateCommlog)
                {
                    if (autoConditionsList.Count > 0)
                    {
                        if (!CheckAutomationConditions(autoConditionsList, patNum))
                        {
                            continue;
                        }
                    }
                    Commlog CommlogCur = new Commlog();
                    CommlogCur.PatNum       = patNum;
                    CommlogCur.CommDateTime = DateTime.Now;
                    CommlogCur.CommType     = Automations.Listt[i].CommType;
                    CommlogCur.Note         = Automations.Listt[i].MessageContent;
                    CommlogCur.Mode_        = CommItemMode.None;
                    CommlogCur.UserNum      = Security.CurUser.UserNum;
                    FormCommItem FormCI = new FormCommItem(CommlogCur);
                    FormCI.IsNew = true;
                    FormCI.ShowDialog();
                    automationHappened = true;
                }
                else if (Automations.Listt[i].AutoAction == AutomationAction.PopUp)
                {
                    if (autoConditionsList.Count > 0)
                    {
                        if (!CheckAutomationConditions(autoConditionsList, patNum))
                        {
                            continue;
                        }
                    }
                    MessageBox.Show(Automations.Listt[i].MessageContent);
                    automationHappened = true;
                }
                else if (Automations.Listt[i].AutoAction == AutomationAction.PrintPatientLetter)
                {
                    if (autoConditionsList.Count > 0)
                    {
                        if (!CheckAutomationConditions(autoConditionsList, patNum))
                        {
                            continue;
                        }
                    }
                    SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum);
                    Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    //SheetParameter.SetParameter(sheet,"ReferralNum",referral.ReferralNum);
                    SheetFiller.FillFields(sheet);
                    using (Bitmap bmp = new Bitmap(100, 100)) {                //a dummy bitmap for the graphics object
                        using (Graphics g = Graphics.FromImage(bmp)) {
                            SheetUtil.CalculateHeights(sheet, g);
                        }
                    }
                    FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                }
                else if (Automations.Listt[i].AutoAction == AutomationAction.PrintReferralLetter)
                {
                    if (autoConditionsList.Count > 0)
                    {
                        if (!CheckAutomationConditions(autoConditionsList, patNum))
                        {
                            continue;
                        }
                    }
                    long referralNum = RefAttaches.GetReferralNum(patNum);
                    if (referralNum == 0)
                    {
                        MsgBox.Show("Automations", "This patient has no referral source entered.");
                        automationHappened = true;
                        continue;
                    }
                    SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum);
                    Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetParameter.SetParameter(sheet, "ReferralNum", referralNum);
                    SheetFiller.FillFields(sheet);
                    using (Bitmap bmp = new Bitmap(100, 100)) {                //a dummy bitmap for the graphics object
                        using (Graphics g = Graphics.FromImage(bmp)) {
                            SheetUtil.CalculateHeights(sheet, g);
                        }
                    }
                    FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                }
                else if (Automations.Listt[i].AutoAction == AutomationAction.ShowExamSheet)
                {
                    if (autoConditionsList.Count > 0)
                    {
                        if (!CheckAutomationConditions(autoConditionsList, patNum))
                        {
                            continue;
                        }
                    }
                    SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum);
                    Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetFiller.FillFields(sheet);
                    using (Bitmap bmp = new Bitmap(100, 100)) {                //a dummy bitmap for the graphics object
                        using (Graphics g = Graphics.FromImage(bmp)) {
                            SheetUtil.CalculateHeights(sheet, g);
                        }
                    }
                    FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                }
            }
            return(automationHappened);
        }