Beispiel #1
0
        //スタディ一覧の取得 (過去検査)
        public static void GetStudyList_Kako(string patientid, StudyKey key, out List <StudyTag> tags)
        {
            tags = new List <StudyTag>();

            using (var pc = new PacsComm())
            {
                var prm2 = new PacsComm.FindParam();
                if (patientid.Trim() == "")
                {
                    prm2.StudyInstanceUID = key.StudyInstanceUID;
                }
                else
                {
                    prm2.PatientID = patientid;
                }

                DicomTagsResult ret = pc.CFindStudy(prm2);
                if (!ret.IsSuccess)
                {
                    LogUtil.Error("CFINDに失敗しました。");
                    return;
                }

                foreach (var dcmTag in ret.Tags)
                {
                    var stkey = new StudyKey()
                    {
                        StudyInstanceUID = dcmTag.GetTagValue(DicomDic.Find("StudyInstanceUID").Tag),
                        IsPacsSearch     = true
                    };

                    var tag = new StudyTag();
                    tag.StudyKey = ConvertUtil.Serialize(stkey);

                    tag.StudyDate       = dcmTag.GetTagValue(DicomDic.Find("StudyDate").Tag);
                    tag.StudyTime       = dcmTag.GetTagValue(DicomDic.Find("StudyTime").Tag);
                    tag.AccessionNumber = dcmTag.GetTagValue(DicomDic.Find("AccessionNumber").Tag);
                    tag.PatientName     = dcmTag.GetTagValue(DicomDic.Find("PatientsName").Tag);
                    tag.PatientID       = dcmTag.GetTagValue(DicomDic.Find("PatientID").Tag);

                    tag.Modality         = dcmTag.GetTagValue(DicomDic.Find("ModalitiesInStudy").Tag);
                    tag.StudyDescription = dcmTag.GetTagValue(DicomDic.Find("StudyDescription").Tag);
                    tag.PatientBirthDate = dcmTag.GetTagValue(DicomDic.Find("PatientsBirthDate").Tag);
                    tag.PatientSex       = dcmTag.GetTagValue(DicomDic.Find("PatientsSex").Tag);
                    tag.PatientAge       = dcmTag.GetTagValue(DicomDic.Find("PatientsAge").Tag);
                    Int32.TryParse(dcmTag.GetTagValue(DicomDic.Find("NumberOfStudyRelatedInstances").Tag), out tag.NumberOfImages);

                    //メモ有無
                    using (var db = new TryDbConnection(LCL.settings))
                    {
                        using (var cmd = db.CreateCommand())
                        {
                            cmd.CommandText = "SELECT COUNT(*) cnt FROM T_StudyMemo WHERE StudyInstanceUID=@0";
                            cmd.Add(stkey.StudyInstanceUID);

                            using (var dr = cmd.ExecuteReader())
                            {
                                if (dr.Read())
                                {
                                    tag.StudyMemoUmu = Convert.ToInt32(dr["cnt"]);
                                }
                            }
                        }
                    }

                    //ソート用
                    tag.StudyInstanceUID = dcmTag.GetTagValue(DicomDic.Find("StudyInstanceUID").Tag);

                    tags.Add(tag);
                }
            }

            //ソート
            tags.Sort(new StudyTagComparer());
        }
Beispiel #2
0
        //スタディの取得 (URLコール用)
        public static bool GetStudyKey(FindParam prm, out string patientid, out List <string> studykey)
        {
            patientid = "";
            studykey  = new List <string>();

            var tags = new List <StudyTag>();

            using (var pc = new PacsComm())
            {
                var prm2 = new PacsComm.FindParam();
                prm2.SetStudyDate(prm.StudyDateFrom, prm.StudyDateTo);
                prm2.AccessionNumber = prm.AccessionNumber;
                prm2.PatientName     = prm.PatientName;
                prm2.PatientID       = prm.PatientID;
                prm2.Modality        = prm.Modality;

                DicomTagsResult ret = pc.CFindStudy(prm2);
                if (!ret.IsSuccess)
                {
                    LogUtil.Error("CFINDに失敗しました。");
                    return(true);
                }

                foreach (var dcmTag in ret.Tags)
                {
                    var tag = new StudyTag();
                    tag.StudyDate = dcmTag.GetTagValue(DicomDic.Find("StudyDate").Tag);
                    tag.StudyTime = dcmTag.GetTagValue(DicomDic.Find("StudyTime").Tag);
                    tag.PatientID = dcmTag.GetTagValue(DicomDic.Find("PatientID").Tag);

                    //ソート用
                    tag.StudyInstanceUID = dcmTag.GetTagValue(DicomDic.Find("StudyInstanceUID").Tag);

                    tags.Add(tag);
                }
            }

            if (tags.Count == 0)
            {
                return(true);
            }

            //ソート
            tags.Sort(new StudyTagComparer());

            foreach (var tag in tags)
            {
                var key = new StudyKey()
                {
                    StudyInstanceUID = tag.StudyInstanceUID,
                    IsPacsSearch     = true
                };
                studykey.Add(ConvertUtil.Serialize(key));

                if (studykey.Count == 1)
                {
                    patientid = tag.PatientID;
                }
                else
                {
                    if (patientid != tag.PatientID)
                    {
                        patientid = null;
                        studykey  = null;
                        return(false);
                    }
                }
            }

            return(true);
        }