Exemplo n.º 1
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            long  sheetNum = (long)gridMain.Rows[e.Row].Tag;
            Sheet sheet    = Sheets.GetSheet(sheetNum);

            GotoModule.GotoFamily(sheet.PatNum);
        }
Exemplo n.º 2
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            long  sheetNum = (long)gridMain.Rows[e.Row].Tag;
            Sheet sheet    = Sheets.GetSheet(sheetNum);

            FormSheetFillEdit.ShowForm(sheet, delegate { FillGrid(); });            //We must refresh the grid because the web form clicked might have been deleted by the user.
        }
Exemplo n.º 3
0
 ///<summary>Used in both modes.  Loads the list of sheets into the listbox.  Then launches the first sheet and goes through the sequence of sheets.  If user clicks cancel, the seqeunce will exit.  If not IsSimpleMode, then the TerminalManager can also send a signal to immediately terminate the sequence.</summary>
 private void LoadPatient()
 {
     SheetList = Sheets.GetForTerminal(PatNum);
     listForms.Items.Clear();
     if (SheetList.Count == 0)
     {
         return;
     }
     for (int i = 0; i < SheetList.Count; i++)
     {
         listForms.Items.Add(SheetList[i].Description);
     }
     for (int i = 0; i < SheetList.Count; i++)
     {
         //we want the very freshest copy of the sheet, so we go straight to the database for it
         Sheet sheet = Sheets.GetSheet(SheetList[i].SheetNum);
         formSheetFillEdit = new FormSheetFillEdit(sheet);
         formSheetFillEdit.IsInTerminal = true;
         if (!IsSimpleMode)
         {
             formSheetFillEdit.TerminalListenShut = true;
         }
         formSheetFillEdit.ShowDialog();
         if (formSheetFillEdit.DialogResult != DialogResult.OK) //either patient clicked cancel, or in not IsSimpleMode a close signal was received.
         {
             return;                                            //breaks out of looping through sheets.
         }
     }
 }
Exemplo n.º 4
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            //Sheets
            long  sheetNum = sheetList[e.Row].SheetNum;       // PIn.Long(table.Rows[e.Row]["SheetNum"].ToString());
            Sheet sheet    = Sheets.GetSheet(sheetNum);       //must use this to get fields

            FormSheetFillEdit.ShowForm(sheet, FormSheetFillEdit_Grid_FormClosing);
        }
Exemplo n.º 5
0
        /*
         * private void menuItemViewSheet_Click(object sender,EventArgs e) {
         *      long sheetNum=(long)gridMain.Rows[gridMain.SelectedIndices[0]].Tag;
         *      Sheet sheet=Sheets.GetSheet(sheetNum);
         *      FormSheetFillEdit FormSF=new FormSheetFillEdit(sheet);
         *      FormSF.ShowDialog();
         * }
         *
         * private void menuItemImportSheet_Click(object sender,EventArgs e) {
         *      long sheetNum=(long)gridMain.Rows[gridMain.SelectedIndices[0]].Tag;
         *      Sheet sheet=Sheets.GetSheet(sheetNum);
         *      FormSheetImport formSI=new FormSheetImport();
         *      formSI.SheetCur=sheet;
         *      formSI.ShowDialog();
         * }*/

        private void menuItemViewAllSheets_Click(object sender, EventArgs e)
        {
            long             sheetNum = (long)gridMain.Rows[gridMain.SelectedIndices[0]].Tag;
            Sheet            sheet    = Sheets.GetSheet(sheetNum);
            FormPatientForms formP    = new FormPatientForms();

            formP.PatNum = sheet.PatNum;
            formP.ShowDialog();
        }
Exemplo n.º 6
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            //Sheets
            long              sheetNum = sheetList[e.Row].SheetNum; // PIn.Long(table.Rows[e.Row]["SheetNum"].ToString());
            Sheet             sheet    = Sheets.GetSheet(sheetNum); //must use this to get fields
            FormSheetFillEdit FormSF   = new FormSheetFillEdit(sheet);

            FormSF.ShowDialog();
            if (FormSF.DialogResult == DialogResult.OK)
            {
                FillGrid();
            }
        }
Exemplo n.º 7
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (table.Rows[e.Row]["DocNum"].ToString() != "0")
            {
                long docNum = PIn.Long(table.Rows[e.Row]["DocNum"].ToString());
                GotoModule.GotoImage(PatNum, docNum);
                return;
            }
            //Sheets
            long  sheetNum = PIn.Long(table.Rows[e.Row]["SheetNum"].ToString());
            Sheet sheet    = Sheets.GetSheet(sheetNum);

            FormSheetFillEdit.ShowForm(sheet, FormSheetFillEdit_FormClosing);
        }
Exemplo n.º 8
0
        private void listForms_DoubleClick(object sender, EventArgs e)
        {
            //this might be used after the patient has completed all the forms and wishes to review or alter one of them
            if (listForms.SelectedIndex == -1)
            {
                return;
            }
            Sheet sheet = Sheets.GetSheet(SheetList[listForms.SelectedIndex].SheetNum);

            formSheetFillEdit = new FormSheetFillEdit(sheet);
            formSheetFillEdit.IsInTerminal = true;
            formSheetFillEdit.ShowDialog();
            //no point in refreshing the list because patient cannot edit description or delete sheet.
        }
Exemplo n.º 9
0
        private void listForms_DoubleClick(object sender, EventArgs e)
        {
            //this might be used after the patient has completed all the forms and wishes to review or alter one of them
            if (listForms.SelectedIndex == -1)
            {
                return;
            }
            Sheet sheet = Sheets.GetSheet(_listSheets[listForms.SelectedIndex].SheetNum);

            _formSheetFillEdit = new FormSheetFillEdit(sheet);
            _formSheetFillEdit.IsInTerminal = true;
            _formSheetFillEdit.ShowDialog();
            LoadPatient(true);            //this will verify that this patient is still loaded in this kiosk and refresh the list of forms for the patient
        }
Exemplo n.º 10
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);
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 11
0
        /// <summary>Compares values of the sheet with values that have been inserted into the db.  Returns false if the data was not saved properly.</summary>
        private bool DataExistsInDb(Sheet sheet)
        {
            bool dataExistsInDb = true;

            if (sheet != null)
            {
                long  SheetNum    = sheet.SheetNum;
                Sheet sheetFromDb = Sheets.GetSheet(SheetNum);
                if (sheetFromDb != null)
                {
                    dataExistsInDb = CompareSheets(sheetFromDb, sheet);
                }
            }
            return(dataExistsInDb);
        }
Exemplo n.º 12
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            //Images
            //Hold onto docNum so Image module refresh persists selection when closing FormPatientForms.
            DocNum = PIn.Long(table.Rows[e.Row]["DocNum"].ToString());          //Set to 0 if not a Document, i.e. a Sheet.
            if (DocNum != 0)
            {
                GotoModule.GotoImage(PatNum, DocNum);
                return;
            }
            //Sheets
            long  sheetNum = PIn.Long(table.Rows[e.Row]["SheetNum"].ToString());
            Sheet sheet    = Sheets.GetSheet(sheetNum);

            FormSheetFillEdit.ShowForm(sheet, FormSheetFillEdit_FormClosing);
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
        private void butCopy_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select one completed sheet from the list above first.");
                return;
            }
            long sheetNum = PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["SheetNum"].ToString());

            if (sheetNum == 0)
            {
                MsgBox.Show(this, "Must select a sheet.");
                return;
            }
            Sheet sheet  = Sheets.GetSheet(sheetNum);
            Sheet sheet2 = sheet.Copy();

            sheet2.DateTimeSheet = DateTime.Now;
            sheet2.SheetFields   = new List <SheetField>(sheet.SheetFields);
            for (int i = 0; i < sheet2.SheetFields.Count; i++)
            {
                sheet2.SheetFields[i].IsNew = true;
                if (sheet2.SheetFields[i].FieldType == SheetFieldType.SigBox)
                {
                    sheet2.SheetFields[i].FieldValue = "";                  //clear signatures
                }
                //no need to set SheetNums here.  That's done from inside FormSheetFillEdit
            }
            sheet2.IsNew = true;
            FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet2);

            FormSF.ShowDialog();
            if (FormSF.DialogResult == DialogResult.OK)
            {
                FillGrid();
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (table.Rows[i]["SheetNum"].ToString() == sheet2.SheetNum.ToString())
                    {
                        gridMain.SetSelected(i, true);
                    }
                }
                SecurityLogs.MakeLogEntry(Permissions.Copy, PatNum, "Patient form " + sheet.Description + " from " + sheet.DateTimeSheet.ToString() + " copied");
            }
        }
Exemplo n.º 15
0
        private void butImport_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select one completed form from the list above first.");
                return;
            }
            long     sheetNum = PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["SheetNum"].ToString());
            long     docNum   = PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["DocNum"].ToString());
            Document doc      = null;

            if (docNum != 0)
            {
                doc = Documents.GetByNum(docNum);
                //Pdf importing broke with dot net 4.0 and was enver reimplemented.
                //See FormSheetImport.Load() region Acro
                //string extens=Path.GetExtension(doc.FileName);
                //if(extens.ToLower()!=".pdf") {
                //	MsgBox.Show(this,"Only pdf's and sheets can be imported into the database.");
                //	return;
                //}
            }
            Sheet sheet = null;

            if (sheetNum != 0)
            {
                sheet = Sheets.GetSheet(sheetNum);
                if (sheet.SheetType != SheetTypeEnum.PatientForm && sheet.SheetType != SheetTypeEnum.MedicalHistory)
                {
                    MsgBox.Show(this, "For now, only sheets of type 'PatientForm' and 'MedicalHistory' can be imported.");
                    return;
                }
            }
            if (sheet == null)
            {
                MsgBox.Show(this, "Only sheets can be imported into the database.");
                return;
            }
            FormSheetImport formSI = new FormSheetImport();

            formSI.SheetCur = sheet;
            formSI.DocCur   = doc;
            formSI.ShowDialog();
            //No need to refresh grid because no changes could have been made.
        }
Exemplo n.º 16
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (table.Rows[e.Row]["DocNum"].ToString() != "0")
            {
                long docNum = PIn.Long(table.Rows[e.Row]["DocNum"].ToString());
                GotoModule.GotoImage(PatNum, docNum);
                return;
            }
            //Sheets
            long              sheetNum = PIn.Long(table.Rows[e.Row]["SheetNum"].ToString());
            Sheet             sheet    = Sheets.GetSheet(sheetNum);
            FormSheetFillEdit FormSF   = new FormSheetFillEdit(sheet);

            FormSF.ShowDialog();
            if (FormSF.DialogResult == DialogResult.OK)
            {
                FillGrid();
            }
        }
Exemplo n.º 17
0
        private void AutoShowSheets()
        {
            //only autoshowsheets if IsSimpleMode or the patient is set/changed
            List <long> listSheetNumsFilled = new List <long>();
            long        patNumCur           = PatNum;
            long        sheetNumCur         = _listSheets?.FirstOrDefault()?.SheetNum ?? 0; //defaults to 0, if 0 no sheet will display

            while (patNumCur == PatNum && sheetNumCur > 0)                                  //if patient is changed or no more sheets to display, break out of loop
            {
                Sheet sheetCur = Sheets.GetSheet(sheetNumCur);                              //we want the very freshest copy of the sheet, so we go straight to the database for it
                _formSheetFillEdit = new FormSheetFillEdit(sheetCur);
                _formSheetFillEdit.IsInTerminal = true;
                _formSheetFillEdit.ShowDialog();
                if (_formSheetFillEdit.DialogResult != DialogResult.OK)
                {
                    break;                    //either patient clicked cancel, or NOT IsSimpleMode and a close signal was received, break out of loop
                }
                listSheetNumsFilled.Add(sheetNumCur);
                sheetNumCur = _listSheets?.FirstOrDefault(x => !listSheetNumsFilled.Contains(x.SheetNum))?.SheetNum ?? 0;            //default to 0
            }
        }
Exemplo n.º 18
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;
        }
Exemplo n.º 19
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;
                    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;
        }