コード例 #1
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);
            }
        }
コード例 #2
0
ファイル: FormRpRouting.cs プロジェクト: steev90/opendental
        /// <summary>Specify a sheetDefNum of 0 for the internal Routing slip.</summary>
        private void PrintRoutingSlips(List <long> aptNums, long sheetDefNum)
        {
            SheetDef sheetDef;

            if (sheetDefNum == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.RoutingSlip);
            }
            else
            {
                sheetDef = SheetDefs.GetSheetDef(sheetDefNum);              //includes fields and parameters
            }
            List <Sheet> sheetBatch = SheetUtil.CreateBatch(sheetDef, aptNums);

            if (sheetBatch.Count == 0)
            {
                MsgBox.Show(this, "There are no routing slips to print.");
                return;
            }
            try {
                SheetPrinting.PrintBatch(sheetBatch);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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;
        }
コード例 #5
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);
        }
コード例 #6
0
        private Image GetToothChart(long patNum, TreatPlan treatPlan, List <Procedure> listProcs = null)
        {
            if (treatPlan != null && treatPlan.ListProcTPs.IsNullOrEmpty())
            {
                listProcs             = listProcs ?? Procedures.Refresh(patNum);
                treatPlan.ListProcTPs = GetTreatProcTPs(listProcs);
            }
            List <Procedure> listProcsFiltered = SheetPrinting.FilterProceduresForToothChart(listProcs, treatPlan, true);

            return(SheetPrinting.GetToothChartHelper(patNum, true, treatPlan, listProcsFiltered, isInPatientDashboard: true));
        }
コード例 #7
0
ファイル: LabelSingle.cs プロジェクト: radtek/opendental
        ///<summary></summary>
        public static void PrintCarriers(List <long> carrierNums)
        {
            SheetDef     sheetDef   = SheetsInternal.GetSheetDef(SheetInternalType.LabelCarrier);
            List <Sheet> sheetBatch = SheetUtil.CreateBatch(sheetDef, carrierNums);

            try{
                SheetPrinting.PrintBatch(sheetBatch);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
        public void RefreshView()
        {
            Image    img = new Bitmap(_sheetField.Width, _sheetField.Height);
            Graphics g   = Graphics.FromImage(img);

            SheetPrinting.DrawToothChartLegend(0, 0, _sheetField.Width, 0, _listDefs, g, null);
            if (Image != null)
            {
                Image.Dispose();
            }
            Image = img;
            g.Dispose();
        }
コード例 #9
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);
            }
        }
コード例 #10
0
        public void RefreshView()
        {
            Image    img = new Bitmap(_sheetField.Width, _sheetField.Height);
            Graphics g   = Graphics.FromImage(img);

            g.SmoothingMode = SmoothingMode.HighQuality;
            SheetPrinting.DrawScaledImage(0, 0, _sheetField.Width, _sheetField.Height, g, null, _imgToothChart);
            if (Image != null)
            {
                Image.Dispose();
            }
            Image = img;
            g.Dispose();
        }
コード例 #11
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);
        }
コード例 #12
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);
            }
        }
コード例 #13
0
ファイル: FormSheetFillEdit.cs プロジェクト: nampn/ODental
        private void butPDF_Click(object sender, EventArgs e)
        {
            if (!TryToSaveData())
            {
                return;
            }
            SheetCur = Sheets.GetSheet(SheetCur.SheetNum);
            string filePathAndName = Path.ChangeExtension(Path.GetTempFileName(), ".pdf");

            //Graphics g=this.CreateGraphics();
            SheetPrinting.CreatePdf(SheetCur, filePathAndName);
            //g.Dispose();
            Process.Start(filePathAndName);
            DialogResult = DialogResult.OK;
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        private void butPDF_Click(object sender, EventArgs e)
        {
            if (!TryToSaveData())
            {
                return;
            }
            SheetCur = Sheets.GetSheet(SheetCur.SheetNum);
            string filePathAndName = Path.ChangeExtension(Path.GetTempFileName(), ".pdf");

            //Graphics g=this.CreateGraphics();
            SheetPrinting.CreatePdf(SheetCur, filePathAndName);
            //g.Dispose();
            Process.Start(filePathAndName);
            SecurityLogs.MakeLogEntry(Permissions.SheetEdit, SheetCur.PatNum, SheetCur.Description + " from " + SheetCur.DateTimeSheet.ToShortDateString() + " pdf was created");
            DialogResult = DialogResult.OK;
        }
コード例 #16
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;
        }
コード例 #17
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;
            }
        }
コード例 #18
0
ファイル: FormRxManage.cs プロジェクト: ChemBrain/OpenDental
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableRxManage", "Date"), 70);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Drug"), 140);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Sig"), 0);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Disp"), 70);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Refills"), 70);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Provider"), 70);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Notes"), 0);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableRxManage", "Missing Info"), 0);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            _listRx = RxPats.GetAllForPat(_patCur.PatNum);
            _listRx.Sort(SortByRxDate);
            GridRow row;

            for (int i = 0; i < _listRx.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(_listRx[i].RxDate.ToShortDateString());
                row.Cells.Add(_listRx[i].Drug);
                row.Cells.Add(_listRx[i].Sig);
                row.Cells.Add(_listRx[i].Disp);
                row.Cells.Add(_listRx[i].Refills);
                row.Cells.Add(Providers.GetAbbr(_listRx[i].ProvNum));
                row.Cells.Add(_listRx[i].Notes);
                row.Cells.Add(SheetPrinting.ValidateRxForSheet(_listRx[i]));
                row.Tag = _listRx[i].Copy();
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
コード例 #19
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);
            }
        }
コード例 #20
0
        ///<summary></summary>
        public static void PrintCarriers(List <long> carrierNums)
        {
            SheetDef        sheetDef;
            List <SheetDef> customSheetDefs = SheetDefs.GetCustomForType(SheetTypeEnum.LabelCarrier);

            if (customSheetDefs.Count == 0)
            {
                sheetDef = SheetsInternal.GetSheetDef(SheetInternalType.LabelCarrier);
            }
            else
            {
                sheetDef = customSheetDefs[0];
                SheetDefs.GetFieldsAndParameters(sheetDef);
            }
            List <Sheet> sheetBatch = SheetUtil.CreateBatch(sheetDef, carrierNums);

            try{
                SheetPrinting.PrintBatch(sheetBatch);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #21
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);
            }
        }
コード例 #22
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);
            }
        }
コード例 #23
0
        ///<summary>Uses sheet framework to generate a PDF file, save it to patient's image folder, and attempt to launch file with defualt reader.
        ///If using ImagesStoredInDB it will not launch PDF. If no valid patient is selected you cannot perform this action.</summary>
        private void butPDF_Click(object sender, EventArgs e)
        {
            if (PatCur == null)           //not attached to a patient when form loaded and they haven't selected a patient to attach to yet
            {
                MsgBox.Show(this, "The Medical Lab must be attached to a patient before the PDF can be saved.");
                return;
            }
            if (PatCur.PatNum > 0 && _medLabCur.PatNum != PatCur.PatNum)         //save the current patient attached to the MedLab if it has been changed
            {
                MoveLabsAndImagesHelper();
            }
            Cursor = Cursors.WaitCursor;
            SheetDef sheetDef = SheetUtil.GetMedLabResultsSheetDef();
            Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, _medLabCur.PatNum);

            SheetFiller.FillFields(sheet, null, null, _medLabCur);
            //create the file in the temp folder location, then import so it works when storing images in the db
            string tempPath = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), _medLabCur.PatNum.ToString() + ".pdf");

            SheetPrinting.CreatePdf(sheet, tempPath, null, _medLabCur);
            HL7Def defCur   = HL7Defs.GetOneDeepEnabled(true);
            long   category = defCur.LabResultImageCat;

            if (category == 0)
            {
                category = Defs.GetFirstForCategory(DefCat.ImageCats, true).DefNum;             //put it in the first category.
            }
            //create doc--------------------------------------------------------------------------------------
            OpenDentBusiness.Document docc = null;
            try {
                docc = ImageStore.Import(tempPath, category, Patients.GetPat(_medLabCur.PatNum));
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Error saving document.");
                return;
            }
            finally {
                //Delete the temp file since we don't need it anymore.
                try {
                    File.Delete(tempPath);
                }
                catch {
                    //Do nothing.  This file will likely get cleaned up later.
                }
            }
            docc.Description = Lan.g(this, "MedLab Result");
            docc.DateCreated = DateTime.Now;
            Documents.Update(docc);
            string filePathAndName = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                string patFolder = ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath());
                filePathAndName = ODFileUtils.CombinePaths(patFolder, docc.FileName);
            }
            else if (CloudStorage.IsCloudStorage)
            {
                FormProgress FormP = new FormProgress();
                FormP.DisplayText          = "Downloading...";
                FormP.NumberFormat         = "F";
                FormP.NumberMultiplication = 1;
                FormP.MaxVal = 100;              //Doesn't matter what this value is as long as it is greater than 0
                FormP.TickMS = 1000;
                OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(
                    ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath())
                    , docc.FileName
                    , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                if (FormP.ShowDialog() == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                filePathAndName = PrefC.GetRandomTempFile(Path.GetExtension(docc.FileName));
                File.WriteAllBytes(filePathAndName, state.FileContent);
            }
            Cursor = Cursors.Default;
            if (filePathAndName != "")
            {
                Process.Start(filePathAndName);
            }
            SecurityLogs.MakeLogEntry(Permissions.SheetEdit, sheet.PatNum, sheet.Description + " from " + sheet.DateTimeSheet.ToShortDateString() + " pdf was created");
            DialogResult = DialogResult.OK;
        }
コード例 #24
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            if (!TryToSaveData())
            {
                return;
            }
            SheetCur = Sheets.GetSheet(SheetCur.SheetNum);
            //whether this is a new sheet, or one pulled from the database,
            //it will have the extra parameter we are looking for.
            //A new sheet will also have a PatNum parameter which we will ignore.
            FormSheetOutputFormat FormS = new FormSheetOutputFormat();

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.PaperCopies = 2;
            }
            else
            {
                FormS.PaperCopies = 1;
            }
            if (SheetCur.PatNum != 0 &&
                SheetCur.SheetType != SheetTypeEnum.DepositSlip)
            {
                Patient pat = Patients.GetPat(SheetCur.PatNum);
                if (SheetCur.SheetType == SheetTypeEnum.LabSlip)
                {
                    FormS.IsForLab = true;                  //Changes label to "E-mail to Lab:"
                }
                else if (pat.Email != "")
                {
                    FormS.EmailPatOrLabAddress = pat.Email;
                    //No need to email to a patient for sheet types: LabelPatient (0), LabelCarrier (1), LabelReferral (2), ReferralSlip (3), LabelAppointment (4), Rx (5), Consent (6), ReferralLetter (8), ExamSheet (13), DepositSlip (14)
                    //The data is too private to email unencrypted for sheet types: PatientForm (9), RoutingSlip (10), MedicalHistory (11), LabSlip (12)
                    //A patient might want email for the following sheet types and the data is not very private: PatientLetter (7)
                    if (SheetCur.SheetType == SheetTypeEnum.PatientLetter)
                    {
                        //This just defines the default selection. The user can manually change selections in FormSheetOutputFormat.
                        FormS.EmailPatOrLab = true;
                        FormS.PaperCopies--;
                    }
                }
            }
            Referral referral = null;

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.Email2Visible = true;
                SheetParameter parameter = SheetParameter.GetParamByName(SheetCur.Parameters, "ReferralNum");
                if (parameter == null)              //it can be null sometimes because of old bug in db.
                {
                    FormS.Email2Visible = false;    //prevents trying to attach email to nonexistent referral.
                }
                else
                {
                    long referralNum = PIn.Long(parameter.ParamValue.ToString());
                    referral = Referrals.GetReferral(referralNum);
                    if (referral.EMail != "")
                    {
                        FormS.Email2Address = referral.EMail;
                        FormS.Email2        = true;
                        FormS.PaperCopies--;
                    }
                }
            }
            else
            {
                FormS.Email2Visible = false;
            }
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormS.PaperCopies > 0)
            {
                SheetPrinting.Print(SheetCur, FormS.PaperCopies, RxIsControlled);
            }
            EmailMessage message;
            Random       rnd        = new Random();
            string       attachPath = EmailMessages.GetEmailAttachPath();
            string       fileName;
            string       filePathAndName;
            EmailAddress emailAddress;
            Patient      patCur = Patients.GetPat(SheetCur.PatNum);

            if (patCur == null)
            {
                emailAddress = EmailAddresses.GetByClinic(0);
            }
            else
            {
                emailAddress = EmailAddresses.GetByClinic(patCur.ClinicNum);
            }
            //Graphics g=this.CreateGraphics();
            if (FormS.EmailPatOrLab)
            {
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.EmailPatOrLabAddress;
                message.FromAddress = emailAddress.SenderAddress;              //Can be blank just as it could with the old pref.
                message.Subject     = SheetCur.Description.ToString();         //this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            if ((SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                 SheetCur.SheetType == SheetTypeEnum.ReferralLetter) &&
                FormS.Email2)
            {
                //email referral
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.Email2Address;
                message.FromAddress = emailAddress.SenderAddress;                                         //Can be blank just as it could with the old pref.
                message.Subject     = Lan.g(this, "RE: ") + Patients.GetLim(SheetCur.PatNum).GetNameLF(); //works even if patnum invalid
                //SheetCur.Description.ToString()+" to "+Referrals.GetNameFL(referral.ReferralNum);//this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w,'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            //g.Dispose();
            DialogResult = DialogResult.OK;
        }
コード例 #25
0
ファイル: FormSheetFillEdit.cs プロジェクト: nampn/ODental
        private void butPrint_Click(object sender, EventArgs e)
        {
            if (!TryToSaveData())
            {
                return;
            }
            SheetCur = Sheets.GetSheet(SheetCur.SheetNum);
            //whether this is a new sheet, or one pulled from the database,
            //it will have the extra parameter we are looking for.
            //A new sheet will also have a PatNum parameter which we will ignore.
            FormSheetOutputFormat FormS = new FormSheetOutputFormat();

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.PaperCopies = 2;
            }
            else
            {
                FormS.PaperCopies = 1;
            }
            if (SheetCur.PatNum != 0 &&
                SheetCur.SheetType != SheetTypeEnum.DepositSlip)
            {
                Patient pat = Patients.GetPat(SheetCur.PatNum);
                if (SheetCur.SheetType == SheetTypeEnum.LabSlip)
                {
                    FormS.IsForLab = true;                  //Changes label to "E-mail to Lab:"
                }
                else if (pat.Email != "")
                {
                    FormS.EmailPatOrLabAddress = pat.Email;
                    FormS.EmailPatOrLab        = true;
                    FormS.PaperCopies--;
                }
            }
            Referral referral = null;

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.Email2Visible = true;
                SheetParameter parameter = SheetParameter.GetParamByName(SheetCur.Parameters, "ReferralNum");
                if (parameter == null)              //it can be null sometimes because of old bug in db.
                {
                    FormS.Email2Visible = false;    //prevents trying to attach email to nonexistent referral.
                }
                else
                {
                    long referralNum = PIn.Long(parameter.ParamValue.ToString());
                    referral = Referrals.GetReferral(referralNum);
                    if (referral.EMail != "")
                    {
                        FormS.Email2Address = referral.EMail;
                        FormS.Email2        = true;
                        FormS.PaperCopies--;
                    }
                }
            }
            else
            {
                FormS.Email2Visible = false;
            }
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormS.PaperCopies > 0)
            {
                SheetPrinting.Print(SheetCur, FormS.PaperCopies, RxIsControlled);
            }
            EmailMessage message;
            Random       rnd        = new Random();
            string       attachPath = FormEmailMessageEdit.GetAttachPath();
            string       fileName;
            string       filePathAndName;

            //Graphics g=this.CreateGraphics();
            if (FormS.EmailPatOrLab)
            {
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.EmailPatOrLabAddress;
                message.FromAddress = PrefC.GetString(PrefName.EmailSenderAddress);
                message.Subject     = SheetCur.Description.ToString();          //this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            if ((SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                 SheetCur.SheetType == SheetTypeEnum.ReferralLetter) &&
                FormS.Email2)
            {
                //email referral
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.Email2Address;
                message.FromAddress = PrefC.GetString(PrefName.EmailSenderAddress);
                message.Subject     = SheetCur.Description.ToString() + " to " + Referrals.GetNameFL(referral.ReferralNum);      //this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w,'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            //g.Dispose();
            DialogResult = DialogResult.OK;
        }
コード例 #26
0
ファイル: FormTPsign.cs プロジェクト: ChemBrain/OpenDental
        private void FormTPsign_Load(object sender, System.EventArgs e)
        {
            //this window never comes up for new TP.  Always saved ahead of time.
            if (!Security.IsAuthorized(Permissions.TreatPlanSign, TPcur.DateTP))
            {
                butOK.Enabled = false;
                signatureBoxWrapper.Enabled         = false;
                signatureBoxWrapperPractice.Enabled = false;
                textTypeSig.Enabled         = false;
                textTypeSigPractice.Enabled = false;
            }
            _hasSigPractice = (SheetTP == null ? false : (SheetTP.SheetFields.Any(x => x.FieldType == SheetFieldType.SigBoxPractice) && DoPrintUsingSheets));
            LayoutToolBar();
            ToolBarMain.Buttons["FullPage"].Pushed = true;
            previewContr.Location = new Point(0, ToolBarMain.Bottom);
            previewContr.Size     = new Size(ClientRectangle.Width, ClientRectangle.Height - ToolBarMain.Height - panelSig.Height);
            if (Document == null)           //Only set when not pringing using sheets, shet via a MigraDoc.
            //TODO:Implement ODprintout pattern - MigraDoc
            //Just signing the TP, there is no way to print a Treat' Plan from the Sign TP window so suppress the printer dialogs.
            //Users will click the Print TP button from the Treat' Plan module when they want to print.
            {
                PrinterL.ControlPreviewOverride = previewContr;              //Sets the printdoc to previewContr.Document after validation. Otherwise shows error.
                SheetPrinting.Print(SheetTP, isPrintDocument: false, isPreviewMode: true);
                if (ODprintout.CurPrintout.SettingsErrorCode != PrintoutErrorCode.Success)
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                Document = ODprintout.CurPrintout.PrintDoc;
            }
            else              //MigraDoc
            {
                if (Document.DefaultPageSettings.PrintableArea.Height == 0)
                {
                    Document.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
                }
                previewContr.Document = Document;
            }
            SetSize();
            ToolBarMain.Buttons["PageNum"].Text = (previewContr.StartPage + 1).ToString()
                                                  + " / " + TotalPages.ToString();
            proctpList = ProcTPs.RefreshForTP(TPcur.TreatPlanNum);
            //Fill TP signature
            signatureBoxWrapper.SignatureMode = UI.SignatureBoxWrapper.SigMode.TreatPlan;
            string keyData = TreatPlans.GetKeyDataForSignatureHash(TPcur, proctpList);

            signatureBoxWrapper.FillSignature(TPcur.SigIsTopaz, keyData, TPcur.Signature);
            SheetField sheetField;

            if (SheetTP != null)
            {
                sheetField = SheetTP.SheetFields.FirstOrDefault(x => x.FieldType == SheetFieldType.SigBox);
                if (sheetField != null && !string.IsNullOrEmpty(sheetField.FieldName))
                {
                    labelSig.Text = $"{sheetField.FieldName} sign here --->";
                }
                sheetField = SheetTP.GetSheetFieldByName("SignatureText");
                if (sheetField != null)
                {
                    textTypeSig.Text     = TPcur.SignatureText;
                    labelTypeSig.Visible = true;
                    textTypeSig.Visible  = true;
                }
            }
            //Fill TP practice signature if printing using sheets
            if (_hasSigPractice)
            {
                signatureBoxWrapperPractice.Visible       = true;
                labelSigPractice.Visible                  = true;
                signatureBoxWrapperPractice.SignatureMode = UI.SignatureBoxWrapper.SigMode.TreatPlan;
                signatureBoxWrapperPractice.FillSignature(TPcur.SigIsTopaz, keyData, TPcur.SignaturePractice);
                sheetField = SheetTP.SheetFields.FirstOrDefault(x => x.FieldType == SheetFieldType.SigBoxPractice);
                if (sheetField != null && !string.IsNullOrEmpty(sheetField.FieldName))
                {
                    labelSigPractice.Text = $"{sheetField.FieldName} sign here --->";
                }
                sheetField = SheetTP.GetSheetFieldByName("SignaturePracticeText");
                if (sheetField != null)
                {
                    textTypeSigPractice.Text     = TPcur.SignaturePracticeText;
                    labelTypeSigPractice.Visible = true;                  //defaulted to be hidden
                    textTypeSigPractice.Visible  = true;
                }
            }
        }
コード例 #27
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);
        }
コード例 #28
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);
        }