示例#1
0
        //GSPSの取得
        public static void GetGsps(GSPSKey key, out List <ImageKey> items)
        {
            items = new List <ImageKey>();

            using (var db = new TryDbConnection(settings))
            {
                using (var cmd = db.CreateCommand())
                {
                    if (key.ReferencedSOPInstanceUID == "")
                    {
                        cmd.CommandText = "SELECT DISTINCT SeriesInstanceUID,SOPInstanceUID,StorageID FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1 AND ContentLabel=@2";
                        cmd.Add(key.StudyInstanceUID);
                        cmd.Add(key.ReferencedSeriesInstanceUID);
                        cmd.Add(key.ContentLabel);
                    }
                    else
                    {
                        cmd.CommandText = "SELECT DISTINCT SeriesInstanceUID,SOPInstanceUID,StorageID FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1 AND ReferencedSOPInstanceUID=@2 AND ContentLabel=@3";
                        cmd.Add(key.StudyInstanceUID);
                        cmd.Add(key.ReferencedSeriesInstanceUID);
                        cmd.Add(key.ReferencedSOPInstanceUID);
                        cmd.Add(key.ContentLabel);
                    }
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var imkey = new ImageKey()
                            {
                                StudyInstanceUID  = key.StudyInstanceUID,
                                SeriesInstanceUID = (string)dr["SeriesInstanceUID"],
                                SOPInstanceUID    = (string)dr["SOPInstanceUID"],
                                StorageID         = (string)dr["StorageID"]
                            };

                            items.Add(imkey);
                        }
                    }
                }
            }
        }
示例#2
0
 public static void GetGsps(GSPSKey key, out List <ImageKey> items)
 {
     LCL.GetGsps(key, out items);
 }
示例#3
0
        //GSPS一覧の取得
        public static void GetGspsList(SeriesKey key, out List <GSPSItem> items)
        {
            items = new List <GSPSItem>();

            using (var db = new TryDbConnection(settings))
            {
                using (var cmd = db.CreateCommand())
                {
                    if (!key.IsImage)
                    {
                        cmd.CommandText = "SELECT DISTINCT ContentLabel,ContentDescription,PresentationCreationDate,PresentationCreationTime,ContentCreatorName FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1 ORDER BY PresentationCreationDate DESC,PresentationCreationTime DESC";
                        cmd.Add(key.StudyInstanceUID);
                        cmd.Add(key.SeriesInstanceUID);

                        using (var dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                var gspskey = new GSPSKey()
                                {
                                    StudyInstanceUID            = key.StudyInstanceUID,
                                    ReferencedSeriesInstanceUID = key.SeriesInstanceUID,
                                    ReferencedSOPInstanceUID    = "",
                                    ContentLabel = (string)dr["ContentLabel"],
                                };

                                var item = new GSPSItem();
                                item.GSPSKey                  = ConvertUtil.Serialize(gspskey);
                                item.ContentLabel             = (string)dr["ContentLabel"];
                                item.ContentDescription       = (string)dr["ContentDescription"];
                                item.PresentationCreationDate = (string)dr["PresentationCreationDate"];
                                item.PresentationCreationTime = (string)dr["PresentationCreationTime"];
                                item.ContentCreatorName       = (string)dr["ContentCreatorName"];

                                items.Add(item);
                            }
                        }
                    }
                    else
                    {
                        cmd.CommandText = "SELECT DISTINCT ContentLabel,ContentDescription,PresentationCreationDate,PresentationCreationTime,ContentCreatorName FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1 AND ReferencedSOPInstanceUID=@2 ORDER BY PresentationCreationDate DESC,PresentationCreationTime DESC";
                        cmd.Add(key.StudyInstanceUID);
                        cmd.Add(key.SeriesInstanceUID);
                        cmd.Add(key.SOPInstanceUID);

                        using (var dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                var gspskey = new GSPSKey()
                                {
                                    StudyInstanceUID            = key.StudyInstanceUID,
                                    ReferencedSeriesInstanceUID = key.SeriesInstanceUID,
                                    ReferencedSOPInstanceUID    = key.SOPInstanceUID,
                                    ContentLabel = (string)dr["ContentLabel"],
                                };

                                var item = new GSPSItem();
                                item.GSPSKey                  = ConvertUtil.Serialize(gspskey);
                                item.ContentLabel             = (string)dr["ContentLabel"];
                                item.ContentDescription       = (string)dr["ContentDescription"];
                                item.PresentationCreationDate = (string)dr["PresentationCreationDate"];
                                item.PresentationCreationTime = (string)dr["PresentationCreationTime"];
                                item.ContentCreatorName       = (string)dr["ContentCreatorName"];

                                items.Add(item);
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public static void GetGsps(GSPSKey key, out Dictionary <string, GSPSDataItem> items)
        {
            items = null;

            var tmpItems  = new Dictionary <string, GSPSDataItem>();
            var tmpSeries = new Dictionary <string, string>();
            var delItems  = new List <string>(); //マルチフレーム時の調整

            //GSPSのImageKey取得
            List <ImageKey> gspsImkeys;

            DbUtil.GetGsps(key, out gspsImkeys);

            foreach (var gspsImKey in gspsImkeys)
            {
                var file = FileUtil.GetDicomFile(gspsImKey);
                try
                {
                    using (var dcm = new DicomData(file, DicomTransferSyntax.LittleEndianImplicit))
                    {
                        var pr = new PRAnalyzer(dcm);

                        var tmpSop = new List <PRReferenceSOP>();

                        //ReferencedSeriesSequence
                        foreach (var seq in pr.References)
                        {
                            tmpSop.AddRange(seq.SopRefs);

                            //ReferencedImageSequence
                            foreach (var sop in seq.SopRefs)
                            {
                                if (!tmpSeries.ContainsKey(sop.SOPInstanceUID))
                                {
                                    tmpSeries.Add(sop.SOPInstanceUID, seq.SeriesInstanceUID);
                                }

                                var imkey = new ImageKey()
                                {
                                    StudyInstanceUID  = key.StudyInstanceUID,
                                    SeriesInstanceUID = seq.SeriesInstanceUID,
                                    SOPInstanceUID    = sop.SOPInstanceUID,
                                    FrameNumber       = sop.FrameNumber,
                                    StorageID         = gspsImKey.StorageID
                                };

                                var imkey2 = ConvertUtil.Serialize(imkey);
                                tmpItems.Add(imkey2, new GSPSDataItem());

                                tmpItems[imkey2].Flip   = pr.Flip.ToString().ToLower();
                                tmpItems[imkey2].Rotate = pr.Rotate.ToString();
                            }
                        }

                        //SoftcopyVOILUTSequence
                        foreach (var seq in pr.VoiLuts)
                        {
                            if (seq.SopRefs.Length == 0)
                            {
                                seq.SopRefs = tmpSop.ToArray();
                            }

                            //ReferencedImageSequence
                            foreach (var sop in seq.SopRefs)
                            {
                                var imkey = new ImageKey()
                                {
                                    StudyInstanceUID  = key.StudyInstanceUID,
                                    SeriesInstanceUID = tmpSeries[sop.SOPInstanceUID],
                                    SOPInstanceUID    = sop.SOPInstanceUID,
                                    FrameNumber       = sop.FrameNumber,
                                    StorageID         = gspsImKey.StorageID
                                };

                                var imkey2 = ConvertUtil.Serialize(imkey);

                                if (!tmpItems.ContainsKey(imkey2))
                                {
                                    tmpItems.Add(imkey2, new GSPSDataItem());
                                }

                                tmpItems[imkey2].VoiLut = seq.ToString();
                            }
                        }

                        //GraphicAnnotationSequence
                        foreach (var seq in pr.Infos)
                        {
                            //ReferencedImageSequence
                            foreach (var sop in seq.Reference.SopRefs)
                            {
                                var imkey = new ImageKey()
                                {
                                    StudyInstanceUID  = key.StudyInstanceUID,
                                    SeriesInstanceUID = tmpSeries[sop.SOPInstanceUID],
                                    SOPInstanceUID    = sop.SOPInstanceUID,
                                    FrameNumber       = sop.FrameNumber,
                                    StorageID         = gspsImKey.StorageID
                                };

                                var imkey2 = ConvertUtil.Serialize(imkey);

                                if (!tmpItems.ContainsKey(imkey2))
                                {
                                    tmpItems.Add(imkey2, new GSPSDataItem());
                                }

                                tmpItems[imkey2].Info = seq.ToString();
                            }
                        }

                        //DisplayedAreaSelectionSequence
                        foreach (var seq in pr.DisplayAreas)
                        {
                            if (seq.SopRefs.Length == 0)
                            {
                                seq.SopRefs = tmpSop.ToArray();
                            }

                            //ReferencedImageSequence
                            foreach (var sop in seq.SopRefs)
                            {
                                var imkey = new ImageKey()
                                {
                                    StudyInstanceUID  = key.StudyInstanceUID,
                                    SeriesInstanceUID = tmpSeries[sop.SOPInstanceUID],
                                    SOPInstanceUID    = sop.SOPInstanceUID,
                                    FrameNumber       = sop.FrameNumber,
                                    StorageID         = gspsImKey.StorageID
                                };

                                var imkey2 = ConvertUtil.Serialize(imkey);

                                if (!tmpItems.ContainsKey(imkey2))
                                {
                                    tmpItems.Add(imkey2, new GSPSDataItem());
                                }

                                tmpItems[imkey2].DisplayArea = seq.ToString();

                                //マルチフレーム時の調整
                                if (sop.FrameNumber > 0)
                                {
                                    var imkey3 = new ImageKey()
                                    {
                                        StudyInstanceUID  = key.StudyInstanceUID,
                                        SeriesInstanceUID = tmpSeries[sop.SOPInstanceUID],
                                        SOPInstanceUID    = sop.SOPInstanceUID,
                                        FrameNumber       = 0,
                                        StorageID         = gspsImKey.StorageID
                                    };

                                    var imkey4 = ConvertUtil.Serialize(imkey3);

                                    if (tmpItems.ContainsKey(imkey4))
                                    {
                                        if (tmpItems[imkey2].Flip == "")
                                        {
                                            tmpItems[imkey2].Flip = tmpItems[imkey4].Flip;
                                        }

                                        if (tmpItems[imkey2].Rotate == "")
                                        {
                                            tmpItems[imkey2].Rotate = tmpItems[imkey4].Rotate;
                                        }

                                        if (!delItems.Contains(imkey4))
                                        {
                                            delItems.Add(imkey4);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    LogUtil.Error1("PR Error [{0}]", file);
                    throw;
                }
            }

            //マルチフレーム時の調整
            if (delItems.Count > 0)
            {
                foreach (var delItem in delItems)
                {
                    tmpItems.Remove(delItem);
                }
            }

            items = tmpItems;
        }