示例#1
0
        static bool GetStudyList(RBStudyQuery query, out List <RBStudy> studyList)
        {
            studyList = new List <RBStudy>();

            int cnt;
            int ret;
            var errmsg = new StringBuilder(IRCOM_MAX_MESSAGE_LENGTH);

            var ptr = RsGetStudyList(AppUtil.rsAddr, AppUtil.rsPort, ref query, out cnt, out ret, errmsg);

            if (ptr == null || ret != 0)
            {
                LogUtil.Error2("RsGetStudyList[{0}] {1}", ret, errmsg);
                return(false);
            }

            try
            {
                for (int i = 0; i < cnt; i++)
                {
                    var study = (RBStudy)Marshal.PtrToStructure(ptr + Marshal.SizeOf(typeof(RBStudy)) * i, typeof(RBStudy));
                    if (study.NoOfImg == 0)
                    {
                        continue;
                    }

                    if (study.DBStatus == RB_STATUS_DBLOCK)
                    {
                        LogUtil.Warn1("RB_STATUS_DBLOCK: {0}", study.StudyUID);
                        continue;
                    }

                    studyList.Add(study);
                }
                return(true);
            }
            finally
            {
                RsFree(ptr);
            }
        }
示例#2
0
        //スタディの取得 (URLコール用)
        public static bool GetStudyKey(FindParam prm, out string patientid, out List <string> studykey)
        {
            patientid = "";
            studykey  = new List <string>();

            using (var db = new TryDbConnection(LCL.settings))
            {
                var studyQuery = new RBStudyQuery();
                studyQuery.is_with_both_exist = AppUtil.rsNas;
                studyQuery.max_no_of_replay   = AppUtil.rsMax;

                if (string.IsNullOrEmpty(prm.PatientID) == false)
                {
                    studyQuery.is_filter_on        = 1;
                    studyQuery.is_pat_id_on        = 1;
                    studyQuery.comp_mode_of_pat_id = AppUtil.cmPatientID;
                    studyQuery.PatientID           = prm.PatientID;
                }

                if (string.IsNullOrEmpty(prm.PatientName) == false)
                {
                    studyQuery.is_filter_on          = 1;
                    studyQuery.is_pat_name_on        = 1;
                    studyQuery.comp_mode_of_pat_name = AppUtil.cmPatientName;
                    studyQuery.PatientName           = prm.PatientName;
                }

                if (string.IsNullOrEmpty(prm.AccessionNumber) == false)
                {
                    studyQuery.is_filter_on        = 1;
                    studyQuery.is_acc_no_on        = 1;
                    studyQuery.comp_mode_of_acc_no = AppUtil.cmAccessionNumber;
                    studyQuery.AccNo = prm.AccessionNumber;
                }

                if (string.IsNullOrEmpty(prm.Modality) == false)
                {
                    studyQuery.is_filter_on          = 1;
                    studyQuery.is_modality_on        = 1;
                    studyQuery.comp_mode_of_modality = AppUtil.cmModality;
                    studyQuery.Modality = prm.Modality.Replace(',', '|');
                }

                if (string.IsNullOrEmpty(prm.StudyDateFrom) == false && string.IsNullOrEmpty(prm.StudyDateTo) == false)
                {
                    studyQuery.is_filter_on  = 1;
                    studyQuery.is_st_date_on = 1;
                    studyQuery.StudyDate     = string.Format("{0}-{1}", prm.StudyDateFrom, prm.StudyDateTo);
                }
                else if (string.IsNullOrEmpty(prm.StudyDateFrom) == false)
                {
                    studyQuery.is_filter_on  = 1;
                    studyQuery.is_st_date_on = 1;
                    studyQuery.StudyDate     = string.Format("{0}-{1}", prm.StudyDateFrom, DateTime.Now.ToString("yyyyMMdd"));
                }
                else if (string.IsNullOrEmpty(prm.StudyDateTo) == false)
                {
                    studyQuery.is_filter_on  = 1;
                    studyQuery.is_st_date_on = 1;
                    studyQuery.StudyDate     = string.Format("{0}-{1}", "19700101", prm.StudyDateTo);
                }

                List <RBStudy> studyList;
                if (!GetStudyList(studyQuery, out studyList))
                {
                    return(false);
                }

                //ソート
                studyList.Sort((x, y) =>
                {
                    int c = (y.StudyDate + y.StudyTime).CompareTo(x.StudyDate + x.StudyTime);
                    if (c == 0)
                    {
                        return(x.StudyUID.CompareTo(y.StudyUID));
                    }
                    else
                    {
                        return(c);
                    }
                });

                foreach (var study in studyList)
                {
                    int nasno = -1;
                    if (!int.TryParse(study.NASHostName, out nasno))
                    {
                        LogUtil.Error1("NASHostName={0}", study.NASHostName);
                        continue;
                    }

                    var key = new StudyKey()
                    {
                        StudyInstanceUID = study.StudyUID,
                        StorageID        = nasno.ToString()
                    };
                    studykey.Add(ConvertUtil.Serialize(key));

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

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

            using (var db = new TryDbConnection(LCL.settings))
            {
                var studyQuery = new RBStudyQuery();
                studyQuery.is_with_both_exist = AppUtil.rsNas;
                studyQuery.max_no_of_replay   = AppUtil.rsMax;

                if (string.IsNullOrEmpty(patientid))
                {
                    studyQuery.is_filter_on          = 1;
                    studyQuery.is_study_id_on        = 1;
                    studyQuery.comp_mode_of_study_id = 1;
                    studyQuery.StudyUID = key.StudyInstanceUID;
                }
                else
                {
                    studyQuery.is_filter_on        = 1;
                    studyQuery.is_pat_id_on        = 1;
                    studyQuery.comp_mode_of_pat_id = 1;
                    studyQuery.PatientID           = patientid;
                }

                List <RBStudy> studyList;
                if (!GetStudyList(studyQuery, out studyList))
                {
                    return;
                }

                var PatName = new Dictionary <string, string>();

                foreach (var study in studyList)
                {
                    int nasno = -1;
                    if (!int.TryParse(study.NASHostName, out nasno))
                    {
                        LogUtil.Error1("NASHostName={0}", study.NASHostName);
                        continue;
                    }

                    var stkey = new StudyKey()
                    {
                        StudyInstanceUID = study.StudyUID,
                        StorageID        = nasno.ToString()
                    };

                    var tag = new StudyTag();
                    tag.StudyKey         = ConvertUtil.Serialize(stkey);
                    tag.StudyDate        = study.StudyDate;
                    tag.StudyTime        = study.StudyTime;
                    tag.AccessionNumber  = study.AccNo;
                    tag.Modality         = study.Modality;
                    tag.StudyDescription = study.StudyDesc;
                    tag.PatientName      = study.PatNameSJ != "" ? study.PatNameSJ : study.PatName;
                    tag.PatientID        = study.PatID;
                    tag.PatientBirthDate = study.BirthDate;
                    tag.PatientSex       = study.Sex;
                    tag.BodyPartExamined = study.BodyPart;
                    tag.NumberOfImages   = (int)study.NoOfImg;

                    //患者名
                    if (PatName.ContainsKey(tag.PatientID))
                    {
                        if (PatName[tag.PatientID] != null)
                        {
                            tag.PatientName = PatName[tag.PatientID];
                        }
                    }
                    else
                    {
                        using (var cmd = db.CreateCommand())
                        {
                            cmd.CommandText = "SELECT PatientName FROM T_Patient WHERE PatientID=@0";
                            cmd.Add(tag.PatientID);

                            using (var dr = cmd.ExecuteReader())
                            {
                                if (dr.Read())
                                {
                                    tag.PatientName = (string)dr["PatientName"];
                                    PatName.Add(tag.PatientID, (string)dr["PatientName"]);
                                }
                                else
                                {
                                    PatName.Add(tag.PatientID, null);
                                }
                            }
                        }
                    }

                    if (AppUtil.HideData == "1")
                    {
                        tag.PatientName = "";
                    }

                    //メモ有無
                    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 = study.StudyUID;

                    tags.Add(tag);
                }
            }

            //ソート
            tags.Sort(new StudyTagComparer());
        }
示例#4
0
 static extern IntPtr RsGetStudyList(byte[] addr, ushort port_no, ref RBStudyQuery query_data, out int no_of_study, out int ret_code, StringBuilder message);