Пример #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textSubject.Text == "" && textBodyText.Text == "")
     {
         MsgBox.Show(this, "Both the subject and body of the template cannot be left blank.");
         return;
     }
     if (textDescription.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     ETcur.Subject     = textSubject.Text;
     ETcur.BodyText    = textBodyText.Text;
     ETcur.Description = textDescription.Text;
     if (IsNew)
     {
         EmailTemplates.Insert(ETcur);
     }
     else
     {
         EmailTemplates.Update(ETcur);
     }
     foreach (EmailAttach attachment in _listEmailAttachDisplayed)
     {
         attachment.EmailTemplateNum = ETcur.EmailTemplateNum;
     }
     //Sync the email attachments and pass in an emailMessageNum of 0 because we will be providing _listEmailAttachOld.
     EmailAttaches.Sync(0, _listEmailAttachDisplayed, _listEmailAttachOld);
     DialogResult = DialogResult.OK;
 }
Пример #2
0
		public void FillAttachments() {
			_listEmailAttachDisplayed=new List<EmailAttach>();
			if(!_isComposing) {
				SetSig(null);
			}
			gridAttachments.BeginUpdate();
			gridAttachments.ListGridRows.Clear();
			gridAttachments.ListGridColumns.Clear();
			gridAttachments.ListGridColumns.Add(new OpenDental.UI.GridColumn("",0));//No name column, since there is only one column.
			for(int i=0;i<_emailMessage.Attachments.Count;i++) {
				if(_emailMessage.Attachments[i].DisplayedFileName.ToLower()=="smime.p7s") {
					if(!_isComposing) {
						string smimeP7sFilePath=FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(),_emailMessage.Attachments[i].ActualFileName);
						string localFile=PrefC.GetRandomTempFile(".p7s");
						FileAtoZ.Copy(smimeP7sFilePath,localFile,FileAtoZSourceDestination.AtoZToLocal,doOverwrite:true);
						SetSig(EmailMessages.GetEmailSignatureFromSmimeP7sFile(localFile));
					}
					//Do not display email signatures in the attachment list, because "smime.p7s" has no meaning to a user
					//Also, Windows will install the smime.p7s into an useless place in the Windows certificate store.
					continue;
				}
				OpenDental.UI.GridRow row=new UI.GridRow();
				row.Cells.Add(_emailMessage.Attachments[i].DisplayedFileName);
				gridAttachments.ListGridRows.Add(row);
				_listEmailAttachDisplayed.Add(_emailMessage.Attachments[i]);
			}
			gridAttachments.EndUpdate();
			if(gridAttachments.ListGridRows.Count>0) {
				gridAttachments.SetSelected(0,true);
			}
		}
Пример #3
0
 private void FormEmailTemplateEdit_Load(object sender, System.EventArgs e)
 {
     gridAttachments.ContextMenu = contextMenuAttachments;
     textSubject.Text            = ETcur.Subject;
     textDescription.Text        = ETcur.Description;
     if (ETcur.EmailTemplateNum == 0)           //New email template
     {
         _listEmailAttachDisplayed = new List <EmailAttach>();
         ETcur.BodyText            = "";
     }
     else
     {
         _listEmailAttachDisplayed = EmailAttaches.GetForTemplate(ETcur.EmailTemplateNum);
         foreach (EmailAttach attachment in _listEmailAttachDisplayed)
         {
             _listEmailAttachOld.Add(attachment.Copy());
         }
     }
     textBodyText.Text = ETcur.BodyText;
     if (EmailMessages.IsHtmlEmail(ETcur.TemplateType))
     {
         _hasTextChanged = true;
         _isRaw          = (ETcur.TemplateType == EmailType.RawHtml);
         ChangeView(true);
     }
     FillAttachments();
 }
Пример #4
0
        private void listAttachments_DoubleClick(object sender, EventArgs e)
        {
            if (listAttachments.SelectedIndex == -1)
            {
                return;
            }
            EmailAttach attach = _listAttachments[listAttachments.SelectedIndex];

            FileAtoZ.OpenFile(FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), attach.ActualFileName), attach.DisplayedFileName);
        }
Пример #5
0
        public void EmailAttaches_CreateAttach_InvalidDisaplyName()
        {
            string      displayName       = "invalid*display?Name.gif";
            EmailAttach emailAttachFirst  = EmailAttaches.CreateAttach(displayName, "", Encoding.UTF8.GetBytes(_attachmentRaw), false);
            EmailAttach emailAttachSecond = EmailAttaches.CreateAttach(displayName, "", Encoding.UTF8.GetBytes(_attachmentRaw), false);

            Assert.IsTrue(File.Exists(ODFileUtils.CombinePaths(EmailAttaches.GetAttachPath(), emailAttachFirst.ActualFileName)));
            Assert.IsTrue(File.Exists(ODFileUtils.CombinePaths(EmailAttaches.GetAttachPath(), emailAttachSecond.ActualFileName)));
            Assert.AreNotEqual(emailAttachFirst.ActualFileName, emailAttachSecond.ActualFileName);
        }
Пример #6
0
        private void OpenFile()
        {
            EmailAttach emailAttach       = _listEmailAttachDisplayed[gridAttachments.SelectedIndices[0]];
            string      strFilePathAttach = FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), emailAttach.ActualFileName);

            try {
                if (EhrCCD.IsCcdEmailAttachment(emailAttach))
                {
                    string strTextXml = FileAtoZ.ReadAllText(strFilePathAttach);
                    if (EhrCCD.IsCCD(strTextXml))
                    {
                        Patient patEmail = null;                      //Will be null for most email messages.
                        if (_emailMessage.SentOrReceived == EmailSentOrReceived.ReadDirect || _emailMessage.SentOrReceived == EmailSentOrReceived.ReceivedDirect)
                        {
                            patEmail = _patCur;                          //Only allow reconcile if received via Direct.
                        }
                        string strAlterateFilPathXslCCD = "";
                        //Try to find a corresponding stylesheet. This will only be used in the event that the default stylesheet cannot be loaded from the EHR dll.
                        for (int i = 0; i < _listEmailAttachDisplayed.Count; i++)
                        {
                            if (Path.GetExtension(_listEmailAttachDisplayed[i].ActualFileName).ToLower() == ".xsl")
                            {
                                strAlterateFilPathXslCCD = FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), _listEmailAttachDisplayed[i].ActualFileName);
                                break;
                            }
                        }
                        FormEhrSummaryOfCare.DisplayCCD(strTextXml, patEmail, strAlterateFilPathXslCCD);
                        return;
                    }
                }
                else if (IsORU_R01message(strFilePathAttach))
                {
                    if (DataConnection.DBtype == DatabaseType.Oracle)
                    {
                        MsgBox.Show(this, "Labs not supported with Oracle.  Opening raw file instead.");
                    }
                    else
                    {
                        FormEhrLabOrderImport FormELOI = new FormEhrLabOrderImport();
                        FormELOI.Hl7LabMessage = FileAtoZ.ReadAllText(strFilePathAttach);
                        FormELOI.ShowDialog();
                        return;
                    }
                }
                FileAtoZ.OpenFile(FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), emailAttach.ActualFileName), emailAttach.DisplayedFileName);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Пример #7
0
 private void menuItemAttachmentRemove_Click(object sender, EventArgs e)
 {
     try {
         if (listAttachments.SelectedIndex == -1)
         {
             return;
         }
         FileAtoZ.Delete(FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), _listAttachments[listAttachments.SelectedIndex].ActualFileName));
         _listAttachments.RemoveAt(listAttachments.SelectedIndex);
         FillAttachments();
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
Пример #8
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textSubject.Text == "" && textBodyText.Text == "")
     {
         MsgBox.Show(this, "Both the subject and body of the template cannot be left blank.");
         return;
     }
     if (textDescription.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     ETcur.Subject     = textSubject.Text;
     ETcur.BodyText    = textBodyText.Text;       //always save as plain text version. We will translate to html on loading.
     ETcur.Description = textDescription.Text;
     if (!webBrowserHtml.Visible)
     {
         ETcur.TemplateType = EmailType.Regular;
     }
     else
     {
         ETcur.TemplateType = EmailType.Html;
         if (_isRaw)
         {
             ETcur.TemplateType = EmailType.RawHtml;
         }
     }
     if (IsNew)
     {
         EmailTemplates.Insert(ETcur);
     }
     else
     {
         EmailTemplates.Update(ETcur);
     }
     foreach (EmailAttach attachment in _listEmailAttachDisplayed)
     {
         attachment.EmailTemplateNum = ETcur.EmailTemplateNum;
     }
     //Sync the email attachments and pass in an emailMessageNum of 0 because we will be providing _listEmailAttachOld.
     EmailAttaches.Sync(0, _listEmailAttachDisplayed, _listEmailAttachOld);
     DialogResult = DialogResult.OK;
 }
Пример #9
0
 private void FormEmailTemplateEdit_Load(object sender, System.EventArgs e)
 {
     gridAttachments.ContextMenu = contextMenuAttachments;
     textSubject.Text            = ETcur.Subject;
     textBodyText.Text           = ETcur.BodyText;
     textDescription.Text        = ETcur.Description;
     if (ETcur.EmailTemplateNum == 0)           //New email template
     {
         _listEmailAttachDisplayed = new List <EmailAttach>();
     }
     else
     {
         _listEmailAttachDisplayed = EmailAttaches.GetForTemplate(ETcur.EmailTemplateNum);
         foreach (EmailAttach attachment in _listEmailAttachDisplayed)
         {
             _listEmailAttachOld.Add(attachment.Copy());
         }
     }
     FillAttachments();
 }
        private void SaveAttachment()
        {
            Patient PatCur = Patients.GetPat(PatNum);

            //if(PatCur.ImageFolder=="") {
            //	MsgBox.Show(this,"Invalid patient image folder.");
            //	return;
            //}
            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                MsgBox.Show(this, "Error. Not using AtoZ images folder.");
                return;
            }
            string patfolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
            //ODFileUtils.CombinePaths(
            //FormPath.GetPreferredImagePath(),PatCur.ImageFolder.Substring(0,1).ToUpper(),PatCur.ImageFolder);
            //if(!Directory.Exists(patfolder)) {
            //	MsgBox.Show(this,"Patient folder not found in AtoZ folder.");
            //	return;
            //}
            Document doc = Docs[gridMain.GetSelectedIndex()];

            if (!ImageHelper.HasImageExtension(doc.FileName))
            {
                MsgBox.Show(this, "Invalid file.  Only images may be attached, no other file format.");
                return;
            }
            string oldPath = ODFileUtils.CombinePaths(patfolder, doc.FileName);
            Random rnd     = new Random();
            string newName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString()
                             + Path.GetExtension(oldPath);
            string attachPath = EmailAttaches.GetAttachPath();
            string newPath    = ODFileUtils.CombinePaths(attachPath, newName);

            if (CloudStorage.IsCloudStorage)
            {
                oldPath = oldPath.Replace("\\", "/");
                newPath = newPath.Replace("\\", "/");
            }
            try {
                if (ImageHelper.HasImageExtension(oldPath))
                {
                    if (doc.CropH != 0 ||
                        doc.CropW != 0 ||
                        doc.CropX != 0 ||
                        doc.CropY != 0 ||
                        doc.DegreesRotated != 0 ||
                        doc.IsFlipped ||
                        doc.WindowingMax != 0 ||
                        doc.WindowingMin != 0 ||
                        CloudStorage.IsCloudStorage)
                    {
                        //this does result in a significantly larger images size if jpg.  A later optimization would recompress it.
                        Bitmap bitmapold = null;
                        if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                        {
                            bitmapold = (Bitmap)Bitmap.FromFile(oldPath);
                            Bitmap bitmapnew = ImageHelper.ApplyDocumentSettingsToImage(doc, bitmapold, ImageSettingFlags.ALL);
                            bitmapnew.Save(newPath);
                        }
                        else if (CloudStorage.IsCloudStorage)
                        {
                            //First, download the file.
                            FormProgress FormP = new FormProgress();
                            FormP.DisplayText          = "Downloading Image...";
                            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(patfolder
                                                                                                      , doc.FileName
                                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                            FormP.ShowDialog();
                            if (FormP.DialogResult == DialogResult.Cancel)
                            {
                                state.DoCancel = true;
                                return;
                            }
                            //Successfully downloaded, now do stuff with state.FileContent
                            FormP                      = new FormProgress();
                            FormP.DisplayText          = "Uploading Image for Claim Attach...";
                            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.TaskStateUpload state2 = CloudStorage.UploadAsync(attachPath
                                                                                                   , newName
                                                                                                   , state.FileContent
                                                                                                   , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                            FormP.ShowDialog();
                            if (FormP.DialogResult == DialogResult.Cancel)
                            {
                                state2.DoCancel = true;
                                return;
                            }
                            //Upload was successful
                        }
                    }
                    else
                    {
                        File.Copy(oldPath, newPath);
                    }
                }
                else
                {
                    File.Copy(oldPath, newPath);
                }
                ClaimAttachNew = new ClaimAttach();
                ClaimAttachNew.DisplayedFileName = Docs[gridMain.GetSelectedIndex()].FileName;
                ClaimAttachNew.ActualFileName    = newName;
                DialogResult = DialogResult.OK;
            }
            catch (FileNotFoundException ex) {
                MessageBox.Show(Lan.g(this, "File not found: ") + ex.Message);
                return;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Пример #11
0
        private void butAddTo_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.RefAttachAdd))
            {
                return;
            }
            FormReferralSelect FormRS = new FormReferralSelect();

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

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

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

            if (strCcdValidationErrors != "")            //Do not even try to export if global settings are invalid.
            {
                MessageBox.Show(strCcdValidationErrors); //We do not want to use translations here, because the text is dynamic. The errors are generated in the business layer, and Lan.g() is not available there.
                return;
            }
            strCcdValidationErrors = EhrCCD.ValidatePatient(PatCur);          //Patient cannot be null, because a patient must be selected before the EHR dashboard will open.
            if (strCcdValidationErrors != "")
            {
                MessageBox.Show(strCcdValidationErrors);                //We do not want to use translations here, because the text is dynamic. The errors are generated in the business layer, and Lan.g() is not available there.
                return;
            }
            Provider prov = null;

            if (Security.CurUser.ProvNum != 0)           //If the current user is a provider.
            {
                prov = Providers.GetProv(Security.CurUser.ProvNum);
            }
            else
            {
                prov = Providers.GetProv(PatCur.PriProv);              //PriProv is not 0, because EhrCCD.ValidatePatient() will block if PriProv is 0.
            }
            try {
                //Create the Clinical Summary.
                FormEhrExportCCD FormEEC = new FormEhrExportCCD(PatCur);
                FormEEC.ShowDialog();
                if (FormEEC.DialogResult != DialogResult.OK)               //Canceled
                {
                    return;
                }
                //Save the clinical summary (ccd.xml) and style sheet (ccd.xsl) as webmail message attachments.
                //TODO: It would be more patient friendly if we instead generated a PDF file containing the Clinical Summary printout, or if we simply displayed the Clinical Summary in the portal.
                //The CMS definition does not prohibit sending human readable files, and sending a PDF to the portal mimics printing the Clinical Summary and handing to patient.
                Random             rnd             = new Random();
                string             attachPath      = EmailAttaches.GetAttachPath();
                List <EmailAttach> listAttachments = new List <EmailAttach>();
                EmailAttach        attachCcd       = new EmailAttach(); //Save Clinical Summary to file in the email attachments folder.
                attachCcd.DisplayedFileName = "ccd.xml";
                attachCcd.ActualFileName    = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".xml";
                listAttachments.Add(attachCcd);
                FileAtoZ.WriteAllText(FileAtoZ.CombinePaths(attachPath, attachCcd.ActualFileName), FormEEC.CCD, "Uploading Attachment for Clinical Summary...");
                EmailAttach attachSs = new EmailAttach();                                                                         //Style sheet attachment.
                attachSs.DisplayedFileName = "ccd.xsl";
                attachSs.ActualFileName    = attachCcd.ActualFileName.Substring(0, attachCcd.ActualFileName.Length - 4) + ".xsl"; //Same base name as the CCD.  The base names must match or the file will not display properly in internet browsers.
                listAttachments.Add(attachSs);
                FileAtoZ.WriteAllText(FileAtoZ.CombinePaths(attachPath, attachSs.ActualFileName), FormEHR.GetEhrResource("CCD"),
                                      "Uploading Attachment for Clinical Summary...");
                //Create and save the webmail message containing the attachments.
                EmailMessage msgWebMail = new EmailMessage();
                msgWebMail.FromAddress    = prov.GetFormalName();
                msgWebMail.ToAddress      = PatCur.GetNameFL();
                msgWebMail.PatNum         = PatCur.PatNum;
                msgWebMail.SentOrReceived = EmailSentOrReceived.WebMailSent;
                msgWebMail.ProvNumWebMail = prov.ProvNum;
                msgWebMail.Subject        = "Clinical Summary";
                msgWebMail.BodyText       = "To view the clinical summary:\r\n1) Download all attachments to the same folder.  Do not rename the files.\r\n2) Open the ccd.xml file in an internet browser.";
                msgWebMail.MsgDateTime    = DateTime.Now;
                msgWebMail.PatNumSubj     = PatCur.PatNum;
                msgWebMail.Attachments    = listAttachments;
                EmailMessages.Insert(msgWebMail);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = DateTime.Now;
            newMeasureEvent.EventType  = EhrMeasureEventType.ClinicalSummaryProvidedToPt;
            newMeasureEvent.PatNum     = PatCur.PatNum;
            EhrMeasureEvents.Insert(newMeasureEvent);
            FillGridEHRMeasureEvents();            //This will cause the measure event to show in the grid below the popup message on the next line.  Reassures the user that the event was immediately recorded.
            MsgBox.Show(this, "Clinical Summary Sent");
        }
Пример #13
0
        public void EmailAttaches_CreateAttach_Outbound()
        {
            EmailAttach emailAttach = EmailAttaches.CreateAttach("map_of_argentina.gif", "", Encoding.UTF8.GetBytes(_attachmentRaw), true);

            Assert.IsTrue(File.Exists(ODFileUtils.CombinePaths(EmailAttaches.GetAttachPath(), emailAttach.ActualFileName)));
        }
Пример #14
0
        private void menuItemOpen_Click(object sender, EventArgs e)
        {
            EmailAttach attach = _listEmailAttachDisplayed[gridAttachments.SelectedIndices[0]];

            FileAtoZ.OpenFile(FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(), attach.ActualFileName), attach.DisplayedFileName);
        }
Пример #15
0
        ///<summary>Allow the user to pick the files to be attached. The 'pat' argument can be null. If the user cancels at any step, the return value
        ///will be an empty list.</summary>
        public static List <EmailAttach> PickAttachments(Patient pat)
        {
            List <EmailAttach> listAttaches = new List <EmailAttach>();
            OpenFileDialog     dlg          = new OpenFileDialog();

            dlg.Multiselect = true;
            bool          isLocalFileSelected = false;
            List <string> listFileNames;

            if (pat != null && PrefC.AtoZfolderUsed != DataStorageType.InDatabase)
            {
                string patFolder = ImageStore.GetPatientFolder(pat, ImageStore.GetPreferredAtoZpath());
                if (CloudStorage.IsCloudStorage)
                {
                    FormFilePicker FormFP = new FormFilePicker(patFolder);
                    if (FormFP.ShowDialog() != DialogResult.OK)
                    {
                        return(listAttaches);
                    }
                    isLocalFileSelected = FormFP.WasLocalFileSelected;
                    listFileNames       = FormFP.SelectedFiles;
                }
                else
                {
                    dlg.InitialDirectory = patFolder;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return(listAttaches);
                    }
                    isLocalFileSelected = true;
                    listFileNames       = dlg.FileNames.ToList();
                }
            }
            else              //No patient selected or images in database
                              //Use the OS default directory for this type of file viewer.
            {
                dlg.InitialDirectory = "";
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return(listAttaches);
                }
                isLocalFileSelected = true;
                listFileNames       = dlg.FileNames.ToList();
            }
            try {
                for (int i = 0; i < listFileNames.Count; i++)
                {
                    if (CloudStorage.IsCloudStorage)
                    {
                        FileAtoZSourceDestination sourceDestination;
                        if (isLocalFileSelected)
                        {
                            sourceDestination = FileAtoZSourceDestination.LocalToAtoZ;
                        }
                        else
                        {
                            sourceDestination = FileAtoZSourceDestination.AtoZToAtoZ;
                        }
                        //Create EmailAttach using EmailAttaches.CreateAttach logic, shortened for our specific purpose.
                        EmailAttach emailAttach = new EmailAttach();
                        emailAttach.DisplayedFileName = Path.GetFileName(listFileNames[i]);
                        string attachDir = EmailAttaches.GetAttachPath();
                        string subDir    = "Out";
                        emailAttach.ActualFileName = ODFileUtils.CombinePaths(subDir,
                                                                              DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString()
                                                                              + "_" + MiscUtils.CreateRandomAlphaNumericString(4) + "_" + emailAttach.DisplayedFileName).Replace("\\", "/");
                        FileAtoZ.Copy(listFileNames[i], FileAtoZ.CombinePaths(attachDir, emailAttach.ActualFileName), sourceDestination);
                        listAttaches.Add(emailAttach);
                    }
                    else                      //Not cloud
                    {
                        listAttaches.Add(EmailAttaches.CreateAttach(Path.GetFileName(listFileNames[i]), File.ReadAllBytes(listFileNames[i])));
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            return(listAttaches);
        }