Exemple #1
0
        void finder_FindResponse_Series(DICOMFinder finder, QRResponseData response)
        {
            pendingFinders.Remove(finder);
            if (response == null)
            {
                return;
            }

            foreach (Dictionary <uint, object> row in response.ResponseRows)
            {
                string SerDesc = "";
                if (row.ContainsKey(DICOMTags.SeriesDescription))
                {
                    SerDesc = (string)row[DICOMTags.SeriesDescription]; //series desc
                }
                else if (row.ContainsKey(DICOMTags.BodyPartExamined))
                {
                    SerDesc = (string)row[DICOMTags.BodyPartExamined];  //bodypartexa
                }
                string SerTime = ValOrBlank(row, DICOMTags.SeriesTime);
                if (SerTime != "" && SerTime.Length >= 6)
                {
                    SerTime = SerTime.Substring(0, 6);
                }

                string seriesInsUID = ValOrBlank(row, DICOMTags.SeriesInstanceUID);

                string imCount = "";
                if (row.ContainsKey(DICOMTags.NumberOfSeriesRelatedInstances))
                {
                    imCount = row[DICOMTags.NumberOfSeriesRelatedInstances].ToString();
                }

                this.Invoke((MethodInvoker) delegate
                {
                    SerList.Items.Add(new ListViewItem(new string[]
                    {
                        ValOrBlank(row, DICOMTags.Modality),     //modality
                        ValOrBlank(row, DICOMTags.SeriesDate),   //ser date
                        SerTime,                                 //ser time
                        ValOrBlank(row, DICOMTags.SeriesNumber), //series number
                        SerDesc,                                 //description
                        imCount,                                 //will be the number of images, after they're retrieved
                        seriesInsUID                             //Series UID, Hidden!
                    }));
                });

                if (imCount == "")
                {
                    QRRequestData request = new QRRequestData(QueryRetrieveLevel.StudyRoot, QRLevelType.Image);
                    request.SearchTerms[DICOMTags.SeriesInstanceUID] = seriesInsUID;
                    DICOMFinder newfinder = new DICOMFinder(new NullLogger(), "", false);
                    pendingFinders.Add(finder);
                    newfinder.FindResponse += new DICOMFinder.FindResponseHandler(newfinder_FindResponse_Image);
                    newfinder.Find(new ApplicationEntity(MyAE), TargetAE.ToAE(), request);
                }
            }
        }
Exemple #2
0
        void newfinder_FindResponse_Image(DICOMFinder finder, QRResponseData response)
        {
            pendingFinders.Remove(finder);
            if (response == null)
            {
                return;
            }

            string seriesInsUID = (string)finder.FindRequest.SearchTerms[DICOMTags.SeriesInstanceUID];

            //now modify the actual visible listview
            this.Invoke((MethodInvoker) delegate
            {
                for (int i = 0; i < SerList.Items.Count; i++)
                {
                    if (SerList.Items[i].SubItems[6].Text == seriesInsUID)
                    {
                        SerList.Items[i].SubItems[5].Text = response.ResponseRows.Count.ToString();
                    }
                }
            });
        }
Exemple #3
0
        void finder_FindResponse_Study(DICOMFinder finder, QRResponseData response)
        {
            pendingFinders.Remove(finder);
            if (response == null)
            {
                return;
            }

            foreach (Dictionary <uint, object> row in response.ResponseRows)
            {
                string StuDesc = "";
                if (row.ContainsKey(DICOMTags.StudyDescription))
                {
                    StuDesc = (string)row[DICOMTags.StudyDescription];  //study desc
                }
                else if (row.ContainsKey(DICOMTags.BodyPartExamined))
                {
                    StuDesc = (string)row[DICOMTags.BodyPartExamined];  //bodypartexa
                }
                this.Invoke((MethodInvoker) delegate
                {
                    SearchList.Items.Add(new ListViewItem(new string[]
                    {
                        ValOrBlank(row, DICOMTags.PatientID),
                        ValOrBlank(row, DICOMTags.PatientName),
                        ValOrBlank(row, DICOMTags.Modality),
                        ValOrBlank(row, DICOMTags.AccessionNumber),
                        ValOrBlank(row, DICOMTags.StudyDate),
                        ValOrBlank(row, DICOMTags.StudyTime),
                        StuDesc,
                        ValOrBlank(row, DICOMTags.PatientSex),
                        ValOrBlank(row, DICOMTags.PatientBirthDate),
                        ValOrBlank(row, DICOMTags.StudyInstanceUID)     //Study UID, Hidden!
                    }));
                });
            }
        }
        private void conn_CommandReceived(DICOMConnection conn, PDATACommands command, DICOMData cmdDICOM, DICOMData dataDICOM)
        {
            switch (command)
            {
            case PDATACommands.CECHORQ:
                conn.LogLine(LogLevel.Info, "Received C-ECHO-RQ");
                conn.SendCECHORSP();
                break;

            case PDATACommands.CSTORERQ:
                conn.LogLine(LogLevel.Info, "Received C-STORE-RQ");

                //Add source AE title to image
                dataDICOM[DICOMTags.SourceApplicationEntityTitle].Data = conn.CallingAE;

                if (StoreRequest != null)
                {
                    StoreRequest(conn, dataDICOM);
                }
                else
                {
                    conn.SendCSTORERSP(CommandStatus.Success);
                }
                break;

            case PDATACommands.CSTORERSP:
                conn.LogLine(LogLevel.Info, "Received C-STORE-RSP");

                break;

            case PDATACommands.CFINDRQ:
                conn.LogLine(LogLevel.Info, "Received C-FIND-RQ");
                if (FindRequest != null)
                {
                    QRResponseData response = FindRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                    conn.SendCFINDRSP(response);
                }
                else
                {
                    conn.SendCFINDRSP(null, CommandStatus.Success);
                }
                break;

            case PDATACommands.CGETRQ:
                conn.LogLine(LogLevel.Info, "Received C-GET-RQ");
                if (GetRequest != null)
                {
                    QRResponseData response = GetRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                    conn.StartGetResponse(response);
                }
                else
                {
                    conn.SendCGETRSP((ushort)cmdDICOM[DICOMTags.MessageID].Data, CommandStatus.Success, 0, 0, 0, 0);
                }
                break;

            case PDATACommands.CMOVERQ:
                conn.LogLine(LogLevel.Info, "Received C-MOVE-RQ");
                if (MoveRequest != null)
                {
                    string            newAE  = cmdDICOM[DICOMTags.MoveDestination].Display.Trim();
                    ApplicationEntity entity = null;
                    if (EntityLookup != null)
                    {
                        entity = EntityLookup(newAE);
                    }

                    if (entity != null)
                    {
                        QRResponseData response = MoveRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                        conn.StartMoveResponse(entity, response);
                    }
                    else
                    {
                        conn.LogLine(LogLevel.Warning, "No entity found for the MOVE request: " + newAE);
                        conn.SendCMOVERSP(CommandStatus.Error_ProcessingFailure, 0, 0, 0, 0);
                    }
                }
                else
                {
                    conn.SendCMOVERSP(CommandStatus.Error_ProcessingFailure, 0, 0, 0, 0);
                }
                break;

            case PDATACommands.NGETRQ:
                conn.LogLine(LogLevel.Info, "Received N-GET-RQ");

                // No idea what we're supposed to do with these yet
                conn.SendNGETRSP(CommandStatus.Refused_SOPClassNotSupported, null);
                break;

            default:
                conn.LogLine(LogLevel.Warning, "Unhandled P-DATA Command Type: " + command + "...");
                break;
            }
        }
Exemple #5
0
        static QRResponseData listener_FindRequest(DICOMConnection conn, QRRequestData request)
        {
            QRResponseData response = request.GenerateResponse();

            foreach (DICOMData data in storedData)
            {
                //check fields
                bool works = true;
                foreach (uint tag in request.SearchTerms.Keys)
                {
                    object search = request.SearchTerms[tag];
                    if (search.ToString() == "")
                    {
                        continue;
                    }

                    if (!data.Elements.ContainsKey(tag))
                    {
                        works = false;
                        break;
                    }

                    if (search.ToString().Contains("-"))
                    {
                        //range

                        string[] range = search.ToString().Split('-');
                        if (range[0] != "" && data[tag].Display.CompareTo(range[0]) < 0)
                        {
                            works = false;
                            break;
                        }
                        if (range[1] != "" && data[tag].Display.CompareTo(range[1]) > 0)
                        {
                            works = false;
                            break;
                        }
                    }
                    else if (search.ToString().Contains("*"))
                    {
                        if (!Regex.IsMatch(data[tag].Display, search.ToString()))
                        {
                            works = false;
                            break;
                        }
                    }
                    else if (data[tag].Display != search.ToString())
                    {
                        works = false;
                        break;
                    }
                }

                if (!works)
                {
                    continue;
                }

                DICOMData ndata = new DICOMData();
                foreach (uint tag in response.TagsToFill)
                {
                    if (data.Elements.ContainsKey(tag))
                    {
                        ndata[tag].Data = data[tag].Data;
                    }
                }
            }

            return(response);
        }