Example #1
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;
        }
Example #2
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;
 }
		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;
		}
Example #4
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;
        }