コード例 #1
0
        private static async Task <List <DicomDataset> > GetAllItemsFromWorklistAsync(string serverIP, int serverPort, string serverAET, string clientAET)
        {
            var worklistItems = new List <DicomDataset>();
            var cfind         = DicomCFindRequest.CreateWorklistQuery(); // no filter, so query all awailable entries

            cfind.OnResponseReceived = (DicomCFindRequest rq, DicomCFindResponse rp) =>
            {
                if (rp.HasDataset)
                {
                    Console.WriteLine("Study UID: {0}", rp.Dataset.GetSingleValue <string>(DicomTag.StudyInstanceUID));
                    worklistItems.Add(rp.Dataset);
                }
                else
                {
                    Console.WriteLine(rp.Status.ToString());
                }
            };

            var client = new DicomClient(serverIP, serverPort, false, clientAET, serverAET);
            await client.AddRequestAsync(cfind);

            await client.SendAsync();

            return(worklistItems);
        }
コード例 #2
0
        public static List <DicomDataset> GetCachedWorklist()
        {
            //记录查询时间
            System.Diagnostics.Stopwatch stopWatch1 = new System.Diagnostics.Stopwatch();
            stopWatch1.Start();
            DateTime dtRequestBeg = DateTime.Now;

            Logger.Info($">>GetCachedWorklist CreateWorklistQuery BeginTime: {dtRequestBeg.ToString("yyyy-MM-dd HH:mm:ss")}");
            Log.Loger($">>GetCachedWorklist CreateWorklistQuery BeginTime: {dtRequestBeg.ToString("yyyy-MM-dd HH:mm:ss")}");

            DateTime       endDate   = System.DateTime.Today.AddDays(1).AddSeconds(-1);
            DateTime       startDate = endDate.AddDays(_cacheDays * -1);
            DicomDateRange dr        = new DicomDateRange(startDate, endDate);
            var            cfind     = DicomCFindRequest.CreateWorklistQuery(null, null, null, null, null, dr);

            //记录查询时间
            DateTime dtRequestEnd = DateTime.Now;

            Logger.Info($">>CreateWorklistQuery EndTime: {dtRequestEnd.ToString("yyyy-MM-dd HH:mm:ss")}");
            Log.Loger($">>CreateWorklistQuery EndTime: {dtRequestEnd.ToString("yyyy-MM-dd HH:mm:ss")}");
            stopWatch1.Stop();
            Logger.Info($">>CreateWorklistQuery SpentTime: {stopWatch1.Elapsed.TotalSeconds}");
            Log.Loger($">>CreateWorklistQuery SpentTime: {stopWatch1.Elapsed.TotalSeconds}");
            Log.Loger($"\r\n");

            return(GetWorkList(cfind));
        }
コード例 #3
0
        /// <summary>
        /// Convenience method for creating a C-FIND modality worklist query.
        /// from https://github.com/fo-dicom/fo-dicom/blob/development/DICOM/Network/DicomCFindRequest.cs
        /// </summary>
        /// <param name="patientId">Patient ID.</param>
        /// <param name="patientName">Patient name.</param>
        /// <param name="stationAE">Scheduled station Application Entity Title.</param>
        /// <param name="stationName">Scheduled station name.</param>
        /// <param name="modality">Modality.</param>
        /// <param name="scheduledDateTime">Scheduled procedure step start time.</param>
        /// <returns>C-FIND modality worklist query object.</returns>
        public static DicomCFindRequest CreateWorklistQuery(
            string patientId   = null,
            string patientName = null,
            string stationAE   = null,
            string stationName = null,
            string modality    = null,
            DicomDateRange scheduledDateTime = null)
        {
            DicomCFindRequest dimse = DicomCFindRequest.CreateWorklistQuery(patientId, patientName, stationAE, stationName, modality, scheduledDateTime);

            dimse.Dataset.Add(DicomTag.PatientAge, string.Empty);

            return(dimse);
        }
コード例 #4
0
        public IEnumerable <Patient> GetAllPatients()
        {
            var cfind = DicomCFindRequest.CreateWorklistQuery();

            cfind.OnResponseReceived = (DicomCFindRequest rq, DicomCFindResponse rp) =>
            {
                for (int i = 0; i < rp.Dataset.Count(); i++)
                {
                    _patient = GetPatientInformation(rp);
                    _patients.Add(_patient);
                }
            };
            _client.AddRequest(cfind);
            _client.Send(_host, _port, _useTls, _callingAe, _calledAe);
            return(_patients);
        }
コード例 #5
0
 private static DicomCFindRequest CreateDummyRequest()
 {
     return(DicomCFindRequest.CreateWorklistQuery("aaaaa"));
 }
コード例 #6
0
        public static List <DicomDataset> QueryWorklistItems(DicomDataset request)
        {
            if (_isRealTime)
            {
                //记录查询时间
                System.Diagnostics.Stopwatch stopWatch1 = new System.Diagnostics.Stopwatch();
                stopWatch1.Start();
                DateTime dtRequestBeg = DateTime.Now;
                Logger.Info($">>QueryWorklistItems CreateWorklistQuery BeginTime: {dtRequestBeg.ToString("yyyy-MM-dd HH:mm:ss")}");
                Log.Loger($">>QueryWorklistItems CreateWorklistQuery BeginTime: {dtRequestBeg.ToString("yyyy-MM-dd HH:mm:ss")}");

                DateTime endDate   = System.DateTime.Today.AddDays(1).AddSeconds(-1);
                DateTime startDate = endDate.AddDays(_cacheDays * -1);
                string   patientId = string.Empty;

                if (!request.TryGetSingleValue(DicomTag.PatientID, out patientId))
                {
                    patientId = null;
                }
                if (request.Contains(DicomTag.ScheduledProcedureStepSequence))
                {
                    DicomDataset procedureStep = request.GetSequence(DicomTag.ScheduledProcedureStepSequence).First();

                    var scheduledProcedureStepStartDate = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartDate, string.Empty);
                    var scheduledProcedureStepEndDate   = procedureStep.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepEndDate, string.Empty);
                    Logger.Info($"Exam scheduledProcedureStepStartDate: {scheduledProcedureStepStartDate}");
                    Log.Loger($"Exam scheduledProcedureStepStartDate: {scheduledProcedureStepStartDate}");
                    Logger.Info($"Exam scheduledProcedureStepEndDate: {scheduledProcedureStepEndDate}");
                    Log.Loger($"Exam scheduledProcedureStepEndDate: {scheduledProcedureStepEndDate}");

                    var index = scheduledProcedureStepStartDate.IndexOf("-");
                    if (index >= 0)
                    {
                        scheduledProcedureStepEndDate = scheduledProcedureStepStartDate.Substring(index + 1);
                        Logger.Info($"Exam New scheduledProcedureStepEndDate: {scheduledProcedureStepEndDate}");
                        Log.Loger($"Exam New scheduledProcedureStepEndDate: {scheduledProcedureStepEndDate}");

                        scheduledProcedureStepStartDate = scheduledProcedureStepStartDate.Substring(0, index);
                        Logger.Info($"Exam New scheduledProcedureStepStartDate: {scheduledProcedureStepStartDate}");
                        Log.Loger($"Exam New scheduledProcedureStepStartDate: {scheduledProcedureStepStartDate}");
                    }
                    scheduledProcedureStepStartDate = scheduledProcedureStepStartDate.Replace(":", "").Replace(" ", "");
                    scheduledProcedureStepEndDate   = scheduledProcedureStepEndDate.Replace(":", "").Replace(" ", "");

                    if (!string.IsNullOrEmpty(scheduledProcedureStepStartDate) && scheduledProcedureStepStartDate != "*")
                    {
                        startDate = new DicomDateTime(DicomTag.ScheduledProcedureStepStartDate, scheduledProcedureStepStartDate).Get <System.DateTime>();
                    }
                    if (!string.IsNullOrEmpty(scheduledProcedureStepEndDate) && scheduledProcedureStepEndDate != "*")
                    {
                        endDate = new DicomDateTime(DicomTag.ScheduledProcedureStepStartDate, scheduledProcedureStepEndDate).Get <System.DateTime>();
                    }
                }

                DicomDateRange dr    = new DicomDateRange(startDate, endDate);
                var            cfind = DicomCFindRequest.CreateWorklistQuery(patientId, null, null, null, null, dr);

                //记录查询时间
                DateTime dtRequestEnd = DateTime.Now;
                Logger.Info($">>CreateWorklistQuery EndTime: {dtRequestEnd.ToString("yyyy-MM-dd HH:mm:ss")}");
                Log.Loger($">>CreateWorklistQuery EndTime: {dtRequestEnd.ToString("yyyy-MM-dd HH:mm:ss")}");
                stopWatch1.Stop();
                Logger.Info($">>CreateWorklistQuery SpentTime: {stopWatch1.Elapsed.TotalSeconds}");
                Log.Loger($">>CreateWorklistQuery SpentTime: {stopWatch1.Elapsed.TotalSeconds}");
                Log.Loger($"\r\n");

                var newWorklistItems = GetWorkList(cfind);
                Logger.Info($"Get new work list, length: {newWorklistItems.Count}");
                Log.Loger($"Get new work list, length: {newWorklistItems.Count}");
                return(newWorklistItems);
            }
            else
            {
                if (CurrentWorklistItems != null && CurrentWorklistItems.Count == 0)
                {
                    var newWorklistItems = GetCachedWorklist();
                    Logger.Info($"Get new work list, length: {newWorklistItems.Count}");
                    Log.Loger($"Get new work list, length: {newWorklistItems.Count}");
                    CurrentWorklistItems = newWorklistItems;
                }
                return(CurrentWorklistItems);
            }
        }