Example #1
0
        /// <summary>
        /// Starts a C-FIND-RQ operation on a target entity.  The request will be made, and all responses will be aggregated into
        /// a single response structure, which will be returned via the <see cref="FindResponse"/> callback.
        /// </summary>
        /// <param name="hostAE">An entity containing the AE title to represent the SCU.</param>
        /// <param name="remoteAE">An entity containing the SCP to attempt to contact.</param>
        /// <param name="requestData">A filled out <see cref="QRRequestData"/> class with the request information.</param>
        public void Find(ApplicationEntity hostAE, ApplicationEntity remoteAE, QRRequestData requestData)
        {
            findResponse = requestData.GenerateResponse();

            FindRequest = requestData;

            if (requestData.QueryLevel == QueryRetrieveLevel.PatientRoot)
            {
                conn.AddPresentationContext(new PresentationContext(AbstractSyntaxes.PatientRootQueryRetrieveInformationModelFIND, new List <TransferSyntax> {
                    TransferSyntaxes.ImplicitVRLittleEndian
                }));
            }
            else if (requestData.QueryLevel == QueryRetrieveLevel.PatientStudyOnly)
            {
                conn.AddPresentationContext(new PresentationContext(AbstractSyntaxes.PatientStudyOnlyQueryRetrieveInformationModelFINDRetired, new List <TransferSyntax> {
                    TransferSyntaxes.ImplicitVRLittleEndian
                }));
            }
            else if (requestData.QueryLevel == QueryRetrieveLevel.StudyRoot)
            {
                conn.AddPresentationContext(new PresentationContext(AbstractSyntaxes.StudyRootQueryRetrieveInformationModelFIND, new List <TransferSyntax> {
                    TransferSyntaxes.ImplicitVRLittleEndian
                }));
            }

            StartConnection(hostAE, remoteAE);
        }
Example #2
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);
        }