예제 #1
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);
			}
		}
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
            }
        }
예제 #5
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);
     }
 }
        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);
            }
        }
예제 #7
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");
        }
예제 #8
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)));
        }
예제 #9
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);
        }
예제 #10
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);
        }