Example #1
0
        public List <SeriesImage> GetAllPatientImages(string patientID)
        {
            List <SeriesImage> seriesImages;
            DataSet            instances;


            seriesImages = new List <SeriesImage>();
            instances    = QueryCurrentPatient(patientID);

            foreach (DataRow row in instances.Tables[DataTableHelper.InstanceTableName].Rows)
            {
                RasterImage image;
                string      referencedFile = row.Field <string>("ReferencedFile");

                using (var dicomDs = new DicomDataSet())
                {
                    dicomDs.Load(referencedFile, DicomDataSetLoadFlags.None);
                    double xDpi = 0;
                    double yDpi = 0;
                    AddInsUtils.GetDpi(dicomDs, out xDpi, out yDpi);
                    image = GetImage(dicomDs);
                    if (image != null)
                    {
                        string      seriesIntanceUID = dicomDs.GetValue <string>(DicomTag.SeriesInstanceUID, string.Empty);
                        string      sopInstanceUID   = dicomDs.GetValue <string>(DicomTag.SOPInstanceUID, string.Empty);
                        SeriesImage si = new SeriesImage(seriesIntanceUID, sopInstanceUID, image, xDpi, yDpi);

                        seriesImages.Add(si);
                    }
                }
            }
            return(seriesImages);
        }
Example #2
0
        private void ProcessInstance(SeriesImage seriesImage, string userName, PrintOptions options, Dictionary <string, List <AnnContainer> > annotations)
        {
            ResetGrayscale(seriesImage.Image, options.ReduceGrayscaleTo8BitsSelected);

            List <DicomDataSet> ds = _Exporter.GetInstanceDatasets(new string[] { seriesImage.SOPInstanceUID });

            double xDpi = 0;
            double yDpi = 0;

            if (ds.Count > 0)
            {
                AddInsUtils.GetDpi(ds[0], out xDpi, out yDpi);

                if (options.PatientInfo)
                {
                    string name             = ds[0].GetValue <string>(DicomTag.PatientName, string.Empty);
                    string id               = ds[0].GetValue <string>(DicomTag.PatientID, string.Empty);
                    string sex              = ds[0].GetValue <string>(DicomTag.PatientSex, string.Empty);
                    string date             = ds[0].GetValue <string>(DicomTag.SeriesDate, string.Empty);
                    string icomments        = ds[0].GetValue <string>(DicomTag.ImageComments, string.Empty);
                    string fcomments        = ds[0].GetValue <string>(DicomTag.FrameComments, string.Empty);
                    string patientDOB       = ds[0].GetValue <string>(DicomTag.PatientBirthDate, string.Empty);
                    string seriesDecription = ds[0].GetValue <string>(DicomTag.SeriesDescription, string.Empty);

                    string tag = string.Empty;

                    if (!string.IsNullOrEmpty(name))
                    {
                        tag += string.Format("Patient: {1}{0}", Environment.NewLine, name.Replace('^', ' '));
                    }
                    if (!string.IsNullOrEmpty(id))
                    {
                        tag += string.Format("Patient ID: {1}{0}", Environment.NewLine, id);
                    }
                    if (!string.IsNullOrEmpty(sex))
                    {
                        tag += string.Format("Sex: {1}{0}", Environment.NewLine, sex);
                    }
                    if (!string.IsNullOrEmpty(date))
                    {
                        tag += string.Format("Date: {1}{0}", Environment.NewLine, date);
                    }
                    if (!string.IsNullOrEmpty(icomments))
                    {
                        tag += string.Format("Comments: {1}{0}", Environment.NewLine, icomments);
                    }
                    if (!string.IsNullOrEmpty(fcomments))
                    {
                        tag += string.Format("Comments: {1}{0}", Environment.NewLine, fcomments);
                    }


                    if (options.LayoutPatientInfo)
                    {
                        tag = string.Empty;

                        if (!string.IsNullOrEmpty(id))
                        {
                            tag += string.Format("Patient ID: {1}{0}", Environment.NewLine, id);
                        }

                        if (!string.IsNullOrEmpty(name))
                        {
                            tag += string.Format("Patient: {1}{0}", Environment.NewLine, name.Replace('^', ' '));
                        }

                        if (!string.IsNullOrEmpty(patientDOB))
                        {
                            tag += string.Format("Brith Date: {1}{0}", Environment.NewLine, patientDOB);
                        }

                        if (!string.IsNullOrEmpty(sex))
                        {
                            tag += string.Format("Sex: {1}{0}", Environment.NewLine, sex);
                        }

                        if (!string.IsNullOrEmpty(date))
                        {
                            tag += string.Format("Date: {1}{0}", Environment.NewLine, date);
                        }

                        if (!string.IsNullOrEmpty(seriesDecription))
                        {
                            tag += string.Format("Description: {1}{0}", Environment.NewLine, date);
                        }
                    }


                    if (!string.IsNullOrEmpty(tag))
                    {
                        // adjust the text size based on the size of the output image.
                        var imageTagged = AddTextFooter(seriesImage.Image, tag, options.LayoutPatientInfo ? Math.Max(100, seriesImage.Image.Height / 5) : 100);
                        seriesImage.Image.Dispose();
                        seriesImage.Image = null;
                        seriesImage.Image = imageTagged;
                    }
                }
            }

            try
            {
                if (options.BurnAnnotations)
                {
                    if (annotations.ContainsKey(seriesImage.SOPInstanceUID))
                    {
                        foreach (AnnContainer container in annotations[seriesImage.SOPInstanceUID])
                        {
                            container.IsVisible = true;
                            seriesImage.Image.Burn(container, xDpi, yDpi);
                        }
                    }
                }
            }
            catch { }//ignored
        }