//スタディの取得 (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); }
//スタディ一覧の取得 public static void GetStudyList(FindParam prm, out List <StudyTag> tags, out int count) { tags = new List <StudyTag>(); count = 0; 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; } 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); } } count = tags.Count; //ソート tags.Sort(new StudyTagComparer()); if (tags.Count > AppUtil.MaxStudyList) { tags.RemoveRange(AppUtil.MaxStudyList, tags.Count - AppUtil.MaxStudyList); } }