コード例 #1
0
        private void butSlip_Click(object sender, EventArgs e)
        {
            int idx = gridMain.GetSelectedIndex();

            if (idx == -1)
            {
                MsgBox.Show(this, "Please select a referral first");
                return;
            }
            Referral referral = ReferralL.GetReferral(((RefAttach)gridMain.ListGridRows[idx].Tag).ReferralNum);

            if (referral == null)
            {
                return;
            }
            SheetDef sheetDef;

            if (referral.Slip == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.ReferralSlip);
            }
            else
            {
                sheetDef = SheetDefs.GetSheetDef(referral.Slip);
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef, PatNum);

            SheetParameter.SetParameter(sheet, "PatNum", PatNum);
            SheetParameter.SetParameter(sheet, "ReferralNum", referral.ReferralNum);
            SheetFiller.FillFields(sheet);
            SheetUtil.CalculateHeights(sheet);
            FormSheetFillEdit.ShowForm(sheet);
        }
コード例 #2
0
ファイル: SheetUtil.cs プロジェクト: nampn/ODental
        ///<summary>Supply a template sheet as well as a list of primary keys.  This method creates a new collection of sheets which each have a parameter of int.  It also fills the sheets with data from the database, so no need to run that separately.</summary>
        public static List <Sheet> CreateBatch(SheetDef sheetDef, List <long> priKeys)
        {
            //we'll assume for now that a batch sheet has only one parameter, so no need to check for values.
            //foreach(SheetParameter param in sheet.Parameters){
            //	if(param.IsRequired && param.ParamValue==null){
            //		throw new ApplicationException(Lan.g("Sheet","Parameter not specified for sheet: ")+param.ParamName);
            //	}
            //}
            List <Sheet> retVal = new List <Sheet>();
            //List<int> paramVals=(List<int>)sheet.Parameters[0].ParamValue;
            Sheet          newSheet;
            SheetParameter paramNew;

            for (int i = 0; i < priKeys.Count; i++)
            {
                newSheet            = CreateSheet(sheetDef);
                newSheet.Parameters = new List <SheetParameter>();
                paramNew            = new SheetParameter(sheetDef.Parameters[0].IsRequired, sheetDef.Parameters[0].ParamName);
                paramNew.ParamValue = priKeys[i];
                newSheet.Parameters.Add(paramNew);
                SheetFiller.FillFields(newSheet);
                retVal.Add(newSheet);
            }
            return(retVal);
        }
コード例 #3
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            //only visible if sheet==null.
            if (comboSendStatus.SelectedIndex == (int)RxSendStatus.InElectQueue ||
                comboSendStatus.SelectedIndex == (int)RxSendStatus.SentElect)
            {
                //do not change status
            }
            else
            {
                comboSendStatus.SelectedIndex = (int)RxSendStatus.Printed;
            }
            if (!SaveRx())
            {
                return;
            }
            SheetDef        sheetDef;
            List <SheetDef> customSheetDefs = SheetDefs.GetCustomForType(SheetTypeEnum.Rx);

            if (customSheetDefs.Count == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.Rx);
            }
            else
            {
                sheetDef = customSheetDefs[0];
                SheetDefs.GetFieldsAndParameters(sheetDef);
            }
            sheet = SheetUtil.CreateSheet(sheetDef, PatCur.PatNum);
            SheetParameter.SetParameter(sheet, "RxNum", RxPatCur.RxNum);
            SheetFiller.FillFields(sheet);
            SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
            SheetPrinting.PrintRx(sheet, RxPatCur.IsControlled);
            DialogResult = DialogResult.OK;
        }
コード例 #4
0
ファイル: FormExamSheets.cs プロジェクト: steev90/opendental
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.ExamSheet;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef sheetDef;
            Sheet    sheet = null;       //only useful if not Terminal

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                sheetDef = FormS.SelectedSheetDefs[i];
                sheet    = SheetUtil.CreateSheet(sheetDef, PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", PatNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
            }
            FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);

            FormSF.ShowDialog();
            if (FormSF.DialogResult == DialogResult.OK)
            {
                FillGrid();
                gridMain.SetSelected(false);                         //unselect all rows
                gridMain.SetSelected(gridMain.Rows.Count - 1, true); //Select the newly added row. Always last, since ordered by date.
            }
        }
コード例 #5
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        ///<summary></summary>
        public static void PrintAppointment(long aptNum)
        {
            SheetDef        sheetDef;
            List <SheetDef> customSheetDefs = SheetDefs.GetCustomForType(SheetTypeEnum.LabelAppointment);

            if (customSheetDefs.Count == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelAppointment);
            }
            else
            {
                sheetDef = customSheetDefs[0];
                SheetDefs.GetFieldsAndParameters(sheetDef);
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "AptNum", aptNum);
            SheetFiller.FillFields(sheet);
            try {
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
        private void butLettersPreview_Click(object sender, EventArgs e)
        {
            //Create letters. loop through each row and insert information into sheets,
            //take all the sheets and add to one giant pdf for preview.
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select patient(s) first.");
                return;
            }
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.PatientLetter;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef     sheetDef;
            Sheet        sheet      = null;
            List <Sheet> listSheets = new List <Sheet>();         //for saving

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                PdfDocument document        = new PdfDocument();
                PdfPage     page            = new PdfPage();
                string      filePathAndName = "";
                for (int j = 0; j < gridMain.SelectedIndices.Length; j++)
                {
                    sheetDef = FormS.SelectedSheetDefs[i];
                    sheet    = SheetUtil.CreateSheet(sheetDef, PIn.Long(((DataRow)gridMain.SelectedGridRows[j].Tag)["PatNum"].ToString()));
                    SheetParameter.SetParameter(sheet, "PatNum", PIn.Long(((DataRow)gridMain.SelectedGridRows[j].Tag)["PatNum"].ToString()));
                    SheetFiller.FillFields(sheet);
                    sheet.SheetFields.Sort(SheetFields.SortDrawingOrderLayers);
                    SheetUtil.CalculateHeights(sheet);
                    SheetPrinting.PagesPrinted = 0;                  //Clear out the pages printed variable before printing all pages for this pdf.
                    int pageCount = Sheets.CalculatePageCount(sheet, SheetPrinting.PrintMargin);
                    for (int k = 0; k < pageCount; k++)
                    {
                        page = document.AddPage();
                        SheetPrinting.CreatePdfPage(sheet, page, null);
                    }
                    listSheets.Add(sheet);
                }
                filePathAndName = PrefC.GetRandomTempFile(".pdf");
                document.Save(filePathAndName);
                if (ODBuild.IsWeb())
                {
                    ThinfinityUtils.HandleFile(filePathAndName);
                }
                else
                {
                    Process.Start(filePathAndName);
                }
                DialogResult = DialogResult.OK;
            }
            if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to save the sheets for the selected patients?"))
            {
                Sheets.SaveNewSheetList(listSheets);
            }
        }
コード例 #7
0
        private void butSlip_Click(object sender, EventArgs e)
        {
            int idx = gridMain.GetSelectedIndex();

            if (idx == -1)
            {
                MsgBox.Show(this, "Please select a referral first");
                return;
            }
            Referral referral = Referrals.GetReferral(RefAttachList[idx].ReferralNum);
            SheetDef sheetDef;

            if (referral.Slip == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.ReferralSlip);
            }
            else
            {
                sheetDef = SheetDefs.GetSheetDef(referral.Slip);
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef, PatNum);

            SheetParameter.SetParameter(sheet, "PatNum", PatNum);
            SheetParameter.SetParameter(sheet, "ReferralNum", referral.ReferralNum);
            SheetFiller.FillFields(sheet);
            SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
            FormSheetFillEdit FormS = new FormSheetFillEdit(sheet);

            FormS.ShowDialog();
            //grid will not be refilled, so no need to reselect.
        }
コード例 #8
0
        private void PrintClickHelper(bool isPreviewMode)
        {
            Sheet sheet = SheetUtil.CreateSheet(SheetDefs.GetInternalOrCustom(SheetInternalType.ERA));

            SheetParameter.GetParamByName(sheet.Parameters, "ERA").ParamValue = _x835;         //Required param
            SheetFiller.FillFields(sheet);
            SheetPrinting.Print(sheet, isPreviewMode: isPreviewMode);
        }
コード例 #9
0
        private void CreateStaticTextData()
        {
            if (Pat == null)
            {
                return;
            }
            //Procedure CodeNums-------------------------------------------------------------------------------------------------------------
            List <long> listProcCodeNums = new List <long>();
            //ListIntraoralAndBiteWings consists of the following proccodes: D0210, D0270, D0272, D0274, D0277, D0273
            List <long> listIntraoralAndBiteWings = new List <long>();
            //listOralEvals consists of the following proccodes: D0120, D0140, D0150, D0160
            List <long> listOralEvals = new List <long>();
            //listProphy consists of the following proccodes: D1110, D1120, D1201, D1205
            List <long> listProphy                     = new List <long>();
            List <long> listIntraoralComplete          = new List <long>();
            List <long> listBiteWingSingle             = new List <long>();
            List <long> listBiteWingsTwo               = new List <long>();
            List <long> listBiteWingsFour              = new List <long>();
            List <long> listVertBiteWings7to8          = new List <long>();
            List <long> listBiteWingsThree             = new List <long>();
            List <long> listPerioOralEval              = new List <long>();
            List <long> listLimitedOralEval            = new List <long>();
            List <long> listCompOralEval               = new List <long>();
            List <long> listDetailedExtensiveOralEval  = new List <long>();
            List <long> listPerioMaintenance           = new List <long>();
            List <long> listPanoramicFilm              = new List <long>();
            List <long> listProphylaxisAdult           = new List <long>();
            List <long> listProphylaxisChild           = new List <long>();
            List <long> listTopicalFluorideProphyChild = new List <long>();
            List <long> listTopicalFluorideProphyAdult = new List <long>();

            listProcCodeNums = SheetFiller.GetListProcCodeNumsForStaticText(listIntraoralAndBiteWings, listOralEvals, listProphy, ref listIntraoralComplete
                                                                            , ref listBiteWingSingle, ref listBiteWingsTwo, ref listBiteWingsThree, ref listBiteWingsFour, ref listVertBiteWings7to8, ref listPerioOralEval
                                                                            , ref listLimitedOralEval, ref listCompOralEval, ref listDetailedExtensiveOralEval, ref listPerioMaintenance, ref listPanoramicFilm
                                                                            , ref listProphylaxisAdult, ref listProphylaxisChild, ref listTopicalFluorideProphyChild, ref listTopicalFluorideProphyAdult);
            //Create a new StaticTextData object, using data we already have, supplementing with queried data where necessary.
            StaticTextData                       = new StaticTextData();
            StaticTextData.PatNote               = PatNote;
            StaticTextData.ListRefAttaches       = ListRefAttaches;
            StaticTextData.ListInsSubs           = ListInsSubs;
            StaticTextData.ListInsPlans          = ListInsPlans;
            StaticTextData.ListPatPlans          = ListPatPlans;
            StaticTextData.ListBenefits          = ListBenefits;
            StaticTextData.HistList              = HistList;
            StaticTextData.ListTreatPlans        = ListTreatPlans;
            StaticTextData.ListRecallsForFam     = ListRecalls;
            StaticTextData.ListAppts             = ListAppts;
            StaticTextData.ListFutureApptsForFam = ListAppts?.FindAll(x => x.AptDateTime > DateTime.Now && x.AptStatus == ApptStatus.Scheduled);
            StaticTextData.ListDiseases          = ListDiseases;
            StaticTextData.ListAllergies         = ListAllergies;
            StaticTextData.ListMedicationPats    = ListMedPats;
            //StaticTextData.ListFamPopups=Popups.GetForFamily(Pat);//Will be handled by StaticTextData.GetStaticTextData() if necessary.
            StaticTextData.ListProceduresSome = ListProcedures?.FindAll(x => x.CodeNum.In(listProcCodeNums));
            StaticTextData.ListDocuments      = ListDocuments;
            StaticTextData.ListProceduresPat  = ListProcedures;
            StaticTextData.ListPlannedAppts   = ListPlannedAppts;
        }
コード例 #10
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.PatientForm;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef sheetDef;
            Sheet    sheet = null;       //only useful if not Terminal
            bool     isPatUsingEClipboard = MobileAppDevices.PatientIsAlreadyUsingDevice(PatNum);

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                sheetDef = FormS.SelectedSheetDefs[i];
                if (FormS.TerminalSend && isPatUsingEClipboard && !sheetDef.HasMobileLayout)
                {
                    if (!MsgBox.Show(MsgBoxButtons.YesNo, $"The patient is currently using an eClipboard to fill out forms, but the " +
                                     $"{sheetDef.Description} sheet does not have a mobile layout and cannot be used with eClipboard. " +
                                     $"If you add this form to the patient's list it will not be shown in eClipboard. Do you still want to add this form?"))
                    {
                        continue;
                    }
                }
                sheet = SheetUtil.CreateSheet(sheetDef, PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", PatNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet);
                if (FormS.TerminalSend)
                {
                    sheet.InternalNote   = "";                //because null not ok
                    sheet.ShowInTerminal = (byte)(Sheets.GetBiggestShowInTerminal(PatNum) + 1);
                    Sheets.SaveNewSheet(sheet);               //save each sheet.
                    //Push new sheet to eClipboard.
                    if (isPatUsingEClipboard && sheetDef.HasMobileLayout)
                    {
                        OpenDentBusiness.WebTypes.PushNotificationUtils.CI_AddSheet(sheet.PatNum, sheet.SheetNum);
                    }
                }
            }
            if (FormS.TerminalSend)
            {
                //do not show a dialog now.  User will need to click the terminal button.
                FillGrid();
                Signalods.SetInvalid(InvalidType.Kiosk);
            }
            else if (sheet != null)
            {
                FormSheetFillEdit.ShowForm(sheet, FormSheetFillEdit_FormClosing);
            }
        }
コード例 #11
0
        private List <Sheet> GetSheetsForTransfer(List <long> listPatNumsToTransfer)
        {
            List <Sheet>   retVal       = new List <Sheet>();
            List <Patient> listPatients = Patients.GetMultPats(listPatNumsToTransfer).ToList();

            foreach (Patient pat in listPatients)
            {
                Sheet sheetCemt = SheetUtil.CreateSheet(SheetsInternal.GetSheetDef(SheetInternalType.PatientTransferCEMT));
                SheetFiller.FillFieldsForPatientTransferCEMT(sheetCemt, pat);
                retVal.Add(sheetCemt);
            }
            return(retVal);
        }
コード例 #12
0
ファイル: FormDepositEdit.cs プロジェクト: nampn/ODental
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (IsNew)
            {
                if (!SaveToDB())
                {
                    return;
                }
            }
            else             //not new
                             //Only allowed to change date and bank account info, NOT attached checks.
                             //We enforce security here based on date displayed, not date entered.
                             //If user is trying to change date without permission:
            {
                DateTime date = PIn.Date(textDate.Text);
                if (Security.IsAuthorized(Permissions.DepositSlips, date, true))
                {
                    if (!SaveToDB())
                    {
                        return;
                    }
                }
                //if security.NotAuthorized, then it simply skips the save process before printing
            }
            SheetDef        sheetDef         = null;
            List <SheetDef> depositSheetDefs = SheetDefs.GetCustomForType(SheetTypeEnum.DepositSlip);

            if (depositSheetDefs.Count > 0)
            {
                sheetDef = depositSheetDefs[0];
                SheetDefs.GetFieldsAndParameters(sheetDef);
            }
            else
            {
                sheetDef = SheetsInternal.DepositSlip();
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef, 0);

            SheetParameter.SetParameter(sheet, "DepositNum", DepositCur.DepositNum);
            SheetFiller.FillFields(sheet);
            SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
            FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);

            FormSF.ShowDialog();
            DialogResult = DialogResult.OK;          //this is imporant, since we don't want to insert the deposit slip twice.
        }
コード例 #13
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        public static void PrintPatientLFPatNum(long patNum)
        {
            SheetDef sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelPatientLFPatNum);
            Sheet    sheet    = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "PatNum", patNum);
            SheetFiller.FillFields(sheet);
            try {
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #14
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        public static void PrintCustomPatient(long patNum, SheetDef sheetDef)
        {
            SheetDefs.GetFieldsAndParameters(sheetDef);
            Sheet sheet = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "PatNum", patNum);
            SheetFiller.FillFields(sheet);
            try {
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #15
0
ファイル: FormLabCaseEdit.cs プロジェクト: nampn/ODental
        /*private void buttonEmail_Click(object sender,EventArgs e) {
         *      int CurPatNum=CaseCur.PatNum;
         *      EmailMessage message=new EmailMessage();
         *      message.PatNum=CurPatNum;
         *      Patient pat=Patients.GetPat(CurPatNum);
         *      message.ToAddress="";//pat.Email;
         *      message.FromAddress=PrefC.GetString(PrefName.EmailSenderAddress");
         *      message.Subject=Lan.g(this,"RE: ")+pat.GetNameFL();
         *      FormEmailMessageEdit FormE=new FormEmailMessageEdit(message);
         *      FormE.IsNew=true;
         *      FormE.ShowDialog();
         *
         * }*/

        private void butSlip_Click(object sender, EventArgs e)
        {
            if (sheet == null)           //create new
            {
                if (!SaveToDb())
                {
                    return;
                }
                Laboratory lab = ListLabs[listLab.SelectedIndex];
                SheetDef   sheetDef;
                if (lab.Slip == 0)
                {
                    sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabSlip);
                }
                else
                {
                    sheetDef = SheetDefs.GetSheetDef(lab.Slip);
                }
                sheet = SheetUtil.CreateSheet(sheetDef, CaseCur.PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", CaseCur.PatNum);
                SheetParameter.SetParameter(sheet, "LabCaseNum", CaseCur.LabCaseNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
                FormSheetFillEdit FormS = new FormSheetFillEdit(sheet);
                FormS.ShowDialog();
                //if(FormS.DialogResult!=DialogResult.OK) {
                //	sheet=null;
                //	return;
                //}
            }
            else              //edit existing
            {
                SheetFields.GetFieldsAndParameters(sheet);
                FormSheetFillEdit FormS = new FormSheetFillEdit(sheet);
                FormS.ShowDialog();
                //if(FormS.DialogResult!=DialogResult.OK) {
                //	return;
                //}
            }
            //refresh
            sheet = Sheets.GetLabSlip(CaseCur.PatNum, CaseCur.LabCaseNum);
            if (sheet == null)
            {
                butSlip.Text = Lan.g(this, "New Slip");
            }
            else
            {
                butSlip.Text = Lan.g(this, "Edit Slip");
            }
        }
コード例 #16
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            Sheet sheet = SheetUtil.CreateSheet(SheetDefs.GetInternalOrCustom(SheetInternalType.ERA));
            X835  x835  = _x835.Copy();

            x835.ListClaimsPaid = new List <Hx835_Claim>()
            {
                _claimPaid
            };                                                                                      //Only print the current claim.
            SheetParameter.GetParamByName(sheet.Parameters, "ERA").ParamValue = x835;               //Required param
            SheetParameter.GetParamByName(sheet.Parameters, "IsSingleClaimPaid").ParamValue = true; //Value is null if not set
            SheetFiller.FillFields(sheet);
            SheetPrinting.Print(sheet, isPreviewMode: true);
        }
コード例 #17
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        public static void PrintText(long patNum, string text)
        {
            SheetDef sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelText);
            Sheet    sheet    = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "PatNum", patNum);
            sheet.Parameters.Add(new SheetParameter(false, "text"));
            SheetParameter.SetParameter(sheet, "text", text);
            SheetFiller.FillFields(sheet);
            try {
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #18
0
ファイル: FormRxEdit.cs プロジェクト: royedwards/DRDNet
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (PrinterSettings.InstalledPrinters.Count == 0)
            {
                MsgBox.Show(this, "Error: No Printers Installed\r\n" +
                            "If you do have a printer installed, restarting the workstation may solve the problem."
                            );
                return;
            }
            //only visible if sheet==null.
            if (comboSendStatus.SelectedIndex == (int)RxSendStatus.InElectQueue ||
                comboSendStatus.SelectedIndex == (int)RxSendStatus.SentElect)
            {
                //do not change status
            }
            else
            {
                comboSendStatus.SelectedIndex = (int)RxSendStatus.Printed;
            }
            if (!SaveRx())
            {
                return;
            }
            //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 sheetDef = SheetDefs.GetSheetsDefault(SheetTypeEnum.Rx, Clinics.ClinicNum);

            sheet = SheetUtil.CreateSheet(sheetDef, PatCur.PatNum);
            SheetParameter.SetParameter(sheet, "RxNum", RxPatCur.RxNum);
            SheetFiller.FillFields(sheet);
            SheetUtil.CalculateHeights(sheet);
            if (!SheetPrinting.PrintRx(sheet, RxPatCur))
            {
                return;
            }
            if (RxPatCur.IsNew)
            {
                AutomationL.Trigger(AutomationTrigger.RxCreate, new List <string>(), PatCur.PatNum, 0, new List <RxPat>()
                {
                    RxPatCur
                });
            }
            DialogResult = DialogResult.OK;
        }
コード例 #19
0
        /*private void buttonEmail_Click(object sender,EventArgs e) {
         *      int CurPatNum=CaseCur.PatNum;
         *      EmailMessage message=new EmailMessage();
         *      message.PatNum=CurPatNum;
         *      Patient pat=Patients.GetPat(CurPatNum);
         *      message.ToAddress="";//pat.Email;
         *      message.FromAddress=PrefC.GetString(PrefName.EmailSenderAddress");
         *      message.Subject=Lan.g(this,"RE: ")+pat.GetNameFL();
         *      FormEmailMessageEdit FormE=new FormEmailMessageEdit(message);
         *      FormE.IsNew=true;
         *      FormE.ShowDialog();
         *
         * }*/

        private void butSlip_Click(object sender, EventArgs e)
        {
            if (sheet == null)           //create new
            {
                if (!SaveToDb())
                {
                    return;
                }
                Laboratory lab = ListLabs[listLab.SelectedIndex];
                SheetDef   sheetDef;
                if (lab.Slip == 0)
                {
                    sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabSlip);
                }
                else
                {
                    sheetDef = SheetDefs.GetSheetDef(lab.Slip);
                }
                sheet = SheetUtil.CreateSheet(sheetDef, CaseCur.PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", CaseCur.PatNum);
                SheetParameter.SetParameter(sheet, "LabCaseNum", CaseCur.LabCaseNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
                FormSheetFillEdit FormS = new FormSheetFillEdit(sheet);
                FormS.ShowDialog();
            }
            else              //edit existing
            {
                SheetFields.GetFieldsAndParameters(sheet);
                FormSheetFillEdit FormS = new FormSheetFillEdit(sheet);
                FormS.ShowDialog();
            }
            //refresh
            sheet = Sheets.GetLabSlip(CaseCur.PatNum, CaseCur.LabCaseNum);
            if (sheet == null)
            {
                butSlip.Text = Lan.g(this, "New Slip");
            }
            else
            {
                butSlip.Text      = Lan.g(this, "Edit Slip");
                butCancel.Enabled = false;              //user can still click X to close window, but we do handle that as well.
            }
        }
コード例 #20
0
        private void butLettersPreview_Click(object sender, EventArgs e)
        {
            //Create letters. loop through each row and insert information into sheets,
            //take all the sheets and add to one giant pdf for preview.
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select patient(s) first.");
                return;
            }
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.PatientLetter;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef sheetDef;
            Sheet    sheet = null;

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                PdfDocument       document        = new PdfDocument();
                FormSheetFillEdit FormSF          = null;
                PdfPage           page            = new PdfPage();
                string            filePathAndName = "";
                for (int j = 0; j < gridMain.SelectedIndices.Length; j++)
                {
                    page     = document.AddPage();
                    sheetDef = FormS.SelectedSheetDefs[i];
                    sheet    = SheetUtil.CreateSheet(sheetDef, PIn.Long(table.Rows[gridMain.SelectedIndices[j]]["PatNum"].ToString()));
                    SheetParameter.SetParameter(sheet, "PatNum", PIn.Long(table.Rows[gridMain.SelectedIndices[j]]["PatNum"].ToString()));
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
                    FormSF = new FormSheetFillEdit(sheet);
                    SheetPrinting.CreatePdfPage(sheet, page);
                }
                filePathAndName = Path.ChangeExtension(Path.GetTempFileName(), ".pdf");
                document.Save(filePathAndName);
                Process.Start(filePathAndName);
                DialogResult = DialogResult.OK;
            }
        }
コード例 #21
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.PatientForm;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef sheetDef;
            Sheet    sheet = null;       //only useful if not Terminal

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                sheetDef = FormS.SelectedSheetDefs[i];
                sheet    = SheetUtil.CreateSheet(sheetDef, PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", PatNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet, this.CreateGraphics());
                if (FormS.TerminalSend)
                {
                    sheet.InternalNote   = "";                //because null not ok
                    sheet.ShowInTerminal = (byte)(Sheets.GetBiggestShowInTerminal(PatNum) + 1);
                    Sheets.SaveNewSheet(sheet);               //save each sheet.
                }
            }
            if (FormS.TerminalSend)
            {
                //do not show a dialog now.
                //User will need to click the terminal button.
                FillGrid();
            }
            else
            {
                FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet);
                FormSF.ShowDialog();
                if (FormSF.DialogResult == DialogResult.OK)
                {
                    FillGrid();
                }
            }
        }
コード例 #22
0
ファイル: FormRxManage.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Prints the selected rx's. If one rx is selected, uses single rx sheet. If more than one is selected, uses multirx sheet</summary>
        private void butPrintSelect_Click(object sender, EventArgs e)
        {
            List <RxPat> listSelectRx = new List <RxPat>();
            SheetDef     sheetDef;
            Sheet        sheet;

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                listSelectRx.Add(_listRx[gridMain.SelectedIndices[i]]);
            }
            if (listSelectRx.Count == 0)
            {
                MsgBox.Show(this, "At least one prescription must be selected");
                return;
            }
            if (PrinterSettings.InstalledPrinters.Count == 0)
            {
                MsgBox.Show(this, "Error: No Printers Installed\r\n" +
                            "If you do have a printer installed, restarting the workstation may solve the problem."
                            );
                return;
            }
            if (listSelectRx.Count == 1)           //old way of printing one rx
            //This logic is an exact copy of FormRxEdit.butPrint_Click()'s logic.  If this is updated, that method needs to be updated as well.
            {
                sheetDef = SheetDefs.GetSheetsDefault(SheetTypeEnum.Rx, Clinics.ClinicNum);
                sheet    = SheetUtil.CreateSheet(sheetDef, _patCur.PatNum);
                SheetParameter.SetParameter(sheet, "RxNum", listSelectRx[0].RxNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet);
                SheetPrinting.PrintRx(sheet, listSelectRx[0]);
            }
            else               //multiple rx selected
                               //Print batch list of rx
            {
                SheetPrinting.PrintMultiRx(listSelectRx);
            }
        }
コード例 #23
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        ///<summary></summary>
        public static void PrintPat(long patNum)
        {
            SheetDef sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelPatientMail);

            if (PrefC.GetLong(PrefName.LabelPatientDefaultSheetDefNum) != 0)           //Try to use custom label sheet.
            {
                try {
                    sheetDef = SheetDefs.GetSheetDef(PrefC.GetLong(PrefName.LabelPatientDefaultSheetDefNum));
                }
                catch {                //The default label could not be retrieved so just use the internal sheet.
                }
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "PatNum", patNum);
            SheetFiller.FillFields(sheet);
            try{
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #24
0
        public void UpdateSpendPoints(Character monPerso, Character newVersion)
        {
            logger.Log("Inside character repository.UpdateSkills.");
            SheetFiller sFiller = new SheetFiller();

            // This might be reworked
            string mypath = ConfigurationManager.AppSettings["path"];
            string path   = System.Web.HttpContext.Current.Server.MapPath(mypath);

            bool sanCheck = true;

            foreach (var sPoint in newVersion.SpendPoints)
            {
                sanCheck = sPoint.Validate();
            }
            if (!sanCheck)
            {
                return;
            }

            // Record the new values
            sFiller.FillSpendablePoints(newVersion, path);
        }
コード例 #25
0
ファイル: FormExamSheets.cs プロジェクト: royedwards/DRDNet
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormSheetPicker FormS = new FormSheetPicker();

            FormS.SheetType = SheetTypeEnum.ExamSheet;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            SheetDef sheetDef;
            Sheet    sheet = null;       //only useful if not Terminal

            for (int i = 0; i < FormS.SelectedSheetDefs.Count; i++)
            {
                sheetDef = FormS.SelectedSheetDefs[i];
                sheet    = SheetUtil.CreateSheet(sheetDef, PatNum);
                SheetParameter.SetParameter(sheet, "PatNum", PatNum);
                SheetFiller.FillFields(sheet);
                SheetUtil.CalculateHeights(sheet);
            }
            FormSheetFillEdit.ShowForm(sheet, FormSheetFillEdit_Add_FormClosing);
        }
コード例 #26
0
ファイル: LabelSingle.cs プロジェクト: nampn/ODental
        ///<summary></summary>
        public static void PrintPat(long patNum)
        {
            SheetDef sheetDef;

            if (PrefC.GetLong(PrefName.LabelPatientDefaultSheetDefNum) == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelPatientMail);
            }
            else
            {
                sheetDef = SheetDefs.GetSheetDef(PrefC.GetLong(PrefName.LabelPatientDefaultSheetDefNum));
            }
            Sheet sheet = SheetUtil.CreateSheet(sheetDef);

            SheetParameter.SetParameter(sheet, "PatNum", patNum);
            SheetFiller.FillFields(sheet);
            try{
                SheetPrinting.Print(sheet);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #27
0
        //UPDATE
        // TODO : ADD ADMIN RIGHTS ONLY
        public void Update(Character newVersion)
        {
            logger.Log("Inside character repository.Update.");

            var monPerso = Get(newVersion.CharacterName);

            if (monPerso == null)
            {
                return;
            }

            if (monPerso.GameName != newVersion.GameName)
            {
                return;
            }

            SheetFiller sFiller = new SheetFiller();
            // This might be reworked
            string mypath = ConfigurationManager.AppSettings["path"];
            string path   = System.Web.HttpContext.Current.Server.MapPath(mypath);

            // Save existing version in "backup" sub-folder
            sFiller.backUpCharacter(monPerso, path);

            try
            {
                UpdateSkills(monPerso, newVersion);
                UpdateStats(monPerso, newVersion);
                UpdateBaseAttr(monPerso, newVersion);
                UpdateSpendPoints(monPerso, newVersion);
            }
            catch (Exception ex)
            {
                logger.Log(String.Format("Error in Repo.update character : {0}", ex.Message));
                throw ex;
            }
        }
コード例 #28
0
        ///<summary>Called by eClipboard check-in once an appointment has been moved to the waiting room and the patient is ready to fill out forms.
        ///Returns number of new sheets created and inserted into Sheet table.</summary>
        public static int CreateSheetsForCheckIn(Appointment appt)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), appt));
            }
            if (!MobileAppDevices.IsClinicSignedUpForEClipboard(PrefC.HasClinicsEnabled?appt.ClinicNum:0))              //this clinic isn't signed up for this feature
            {
                return(0);
            }
            if (!ClinicPrefs.GetBool(PrefName.EClipboardCreateMissingFormsOnCheckIn, appt.ClinicNum))             //This feature is turned off
            {
                return(0);
            }
            bool useDefault = ClinicPrefs.GetBool(PrefName.EClipboardUseDefaults, appt.ClinicNum);
            List <EClipboardSheetDef> listSheetsToCreate = EClipboardSheetDefs.GetForClinic(useDefault ? 0 : appt.ClinicNum);

            if (listSheetsToCreate.Count == 0)            //There aren't any sheets to create here
            {
                return(0);
            }
            List <Sheet> listAlreadyCompleted  = Sheets.GetForPatient(appt.PatNum);
            List <Sheet> listAlreadyInTerminal = Sheets.GetForTerminal(appt.PatNum);

            //if we already have sheets queued for the patient don't add duplicates
            if (listAlreadyInTerminal.Count > 0)
            {
                listAlreadyCompleted.RemoveAll(x => listAlreadyInTerminal.Select(y => y.SheetNum).Contains(x.SheetNum));
                listSheetsToCreate.RemoveAll(x => listAlreadyInTerminal.Select(y => y.SheetDefNum).Contains(x.SheetDefNum));
            }
            byte         showInTerminal = GetBiggestShowInTerminal(appt.PatNum);
            List <Sheet> listNewSheets  = new List <Sheet>();

            foreach (EClipboardSheetDef sheetInsert in listSheetsToCreate.OrderBy(x => x.ItemOrder))
            {
                //First check if we've already completed this form against our resubmission interval rules
                DateTime lastCompleted = listAlreadyCompleted
                                         .Where(x => x.SheetDefNum == sheetInsert.SheetDefNum)
                                         .OrderBy(x => x.DateTimeSheet)
                                         .LastOrDefault()?.DateTimeSheet ?? DateTime.MinValue;
                if (lastCompleted > DateTime.MinValue)
                {
                    if (sheetInsert.ResubmitInterval.Days == 0)
                    {
                        continue;                         //If this interval is set to 0 and they've already completed this form once, we never want to create it automatically again
                    }
                    int elapsed = (DateTime.Today - lastCompleted.Date).Days;
                    if (elapsed < sheetInsert.ResubmitInterval.Days)
                    {
                        continue;                         //The interval hasn't elapsed yet so we don't want to create this sheet
                    }
                }
                SheetDef def      = SheetDefs.GetSheetDef(sheetInsert.SheetDefNum);
                Sheet    newSheet = CreateSheetFromSheetDef(def, appt.PatNum);
                SheetParameter.SetParameter(newSheet, "PatNum", appt.PatNum);
                SheetFiller.FillFields(newSheet);
                //Counting starts at 1 in this case and we don't want to ovewrite the previous number so increment first
                newSheet.ShowInTerminal = ++showInTerminal;
                listNewSheets.Add(newSheet);
            }
            SaveNewSheetList(listNewSheets);
            return(listNewSheets.Count);
        }
コード例 #29
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);
        }
コード例 #30
0
ファイル: AutomationL.cs プロジェクト: ChemBrain/OpenDental
        public static bool Trigger <T>(AutomationTrigger trigger, List <string> procCodes, long patNum, long aptNum = 0, T triggerObj = default(T))
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            List <Automation> listAutomations = Automations.GetDeepCopy();
            bool automationHappened           = false;

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

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

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

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

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

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

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

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

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

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

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