예제 #1
0
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching PATIENT
            PatientInformationEntity patientInformationEntity = null;

            foreach (PatientInformationEntity lPatientInformationEntity in Root)
            {
                if (lPatientInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    patientInformationEntity = lPatientInformationEntity;
                    break;
                }
            }

            if (patientInformationEntity != null)
            {
                // retrieve at the PATIENT level
                if (queryRetrieveLevel == "PATIENT")
                {
                    fileList = patientInformationEntity.FileNames;
                }
                else
                {
                    // find the matching STUDY
                    BaseInformationEntityList studyInformationEntities = patientInformationEntity.ChildrenWithUniqueTagFoundIn(retrieveDataset);

                    // retrieve at the STUDY level
                    if ((studyInformationEntities.Count > 0) &&
                        (queryRetrieveLevel == "STUDY"))
                    {
                        foreach (StudyInformationEntity studyInformationEntity in studyInformationEntities)
                        {
                            foreach (String fileName in studyInformationEntity.FileNames)
                            {
                                fileList.Add(fileName);
                            }
                        }
                    }
                }
            }

            return(fileList);
        }
예제 #2
0
        public override bool HandleCMoveRequest(DicomMessage retrieveMessage)
        {
            if (_informationModels == null)
            {
                return(false);
            }

            // Refresh the Information Models
            _informationModels.Refresh();

            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(retrieveMessage);
            DicomThread.Validate(retrieveMessage, iodName);

            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Values values       = retrieveMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid                  = values.GetString(1);
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // try to get the Move Destination AE.
            values = retrieveMessage.CommandSet.GetAttributeValues("0x00000600");
            System.String moveDestinationAE = values.GetString(1);

            DvtkData.Collections.StringCollection retrieveList = null;

            // check if we should use the Patient Root Information Model
            if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                (_informationModels.PatientRoot != null))
            {
                retrieveList = _informationModels.PatientRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Study Root Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Study_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.StudyRoot != null))
            {
                retrieveList = _informationModels.StudyRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Patient Study Only Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Study_Only_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.PatientStudyOnly != null))
            {
                retrieveList = _informationModels.PatientStudyOnly.RetrieveInformationModel(retrieveMessage);
            }

            // process the retrieve list
            return(ProcessRetrieveList(moveDestinationAE, retrieveList));
        }
        public void Ticket1361_4_1()
        {
            DicomFile dicomFile = null;

            QueryRetrievePatientRootInformationModel queryRetrievePatientRootInformationModel = new QueryRetrievePatientRootInformationModel();

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "1");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.1");
            queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile, false);

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "1");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.2");
            queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile, false);

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "1");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.3");
            queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile, false);

            DicomMessage cMoveRequest = new DicomMessage(DimseCommand.CMOVERQ);

            cMoveRequest.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.2");
            cMoveRequest.Set("0x00000600", VR.AE, "MOVE_DESTINATION");
            cMoveRequest.Set("0x00080052", VR.CS, "IMAGE");
            cMoveRequest.Set("0x00100020", VR.LO, "1");
            cMoveRequest.Set("0x0020000D", VR.UI, "1.1");
            cMoveRequest.Set("0x0020000E", VR.UI, "1.1.1");
            cMoveRequest.Set("0x00080018", VR.UI, "1.1.1.1", "1.1.1.3");

            DvtkData.Collections.StringCollection fileNames = queryRetrievePatientRootInformationModel.RetrieveInformationModel(cMoveRequest);

            Assert.That(fileNames.Count, Is.EqualTo(0));
        }
예제 #4
0
        private bool ProcessRetrieveList(System.String moveDestinationAE, DvtkData.Collections.StringCollection retrieveList)
        {
            UInt16 status = 0x0000;
            UInt16 remainingSubOperations = (UInt16)retrieveList.Count;
            UInt16 completeSubOperations  = 0;
            UInt16 failedSubOperations    = 0;
            UInt16 warningSubOperations   = 0;
            int    subOperationIndex      = 0;

            foreach (System.String dcmFilename in retrieveList)
            {
                status = 0xFF00;
                SendCMoveRsp(status,
                             remainingSubOperations,
                             completeSubOperations,
                             failedSubOperations,
                             warningSubOperations);

                if (HandleSubOperation(moveDestinationAE, dcmFilename, subOperationIndex) == true)
                {
                    completeSubOperations++;
                }
                else
                {
                    failedSubOperations++;
                }
                remainingSubOperations--;
                subOperationIndex++;
            }

            status = 0x0000;
            SendCMoveRsp(status,
                         remainingSubOperations,
                         completeSubOperations,
                         failedSubOperations,
                         warningSubOperations);

            // message handled
            return(true);
        }
예제 #5
0
        public void Ticket788_1_1()
        {
            DicomFile dicomFile = null;

            QueryRetrievePatientStudyOnlyInformationModel queryRetrievePatientStudyOnlyInformationModel = new QueryRetrievePatientStudyOnlyInformationModel();

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "1");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.1");
            queryRetrievePatientStudyOnlyInformationModel.AddToInformationModel(dicomFile);

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "2");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "2.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "2.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "2.1.1.1");
            queryRetrievePatientStudyOnlyInformationModel.AddToInformationModel(dicomFile);

            dicomFile = new DicomFile();
            dicomFile.DataSet.Set("0x00100020", VR.LO, "3");
            dicomFile.DataSet.Set("0x0020000D", VR.UI, "3.1");
            dicomFile.DataSet.Set("0x0020000E", VR.UI, "3.1.1");
            dicomFile.DataSet.Set("0x00080018", VR.UI, "3.1.1.1");
            queryRetrievePatientStudyOnlyInformationModel.AddToInformationModel(dicomFile);

            DicomMessage cMoveRequest = new DicomMessage(Dimse.CMOVERQ);

            cMoveRequest.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.3.2");
            cMoveRequest.Set("0x00000600", VR.AE, "MOVE_DESTINATION");
            cMoveRequest.Set("0x00080052", VR.CS, "PATIENT");
            cMoveRequest.Set("0x00100020", VR.LO, "2");

            DvtkData.Collections.StringCollection fileNames = queryRetrievePatientStudyOnlyInformationModel.RetrieveInformationModel(cMoveRequest);

            Assert.That(fileNames.Count, Is.EqualTo(1));
        }
예제 #6
0
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching STUDY
            StudyInformationEntity studyInformationEntity = null;

            foreach (StudyInformationEntity lStudyInformationEntity in Root)
            {
                if (lStudyInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    studyInformationEntity = lStudyInformationEntity;
                    break;
                }
            }

            if (studyInformationEntity != null)
            {
                // retrieve at the STUDY level
                if (queryRetrieveLevel == "STUDY")
                {
                    foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children)
                    {
                        foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                        {
                            fileList.Add(instanceInformationEntity.Filename);
                        }
                    }
                }
                else
                {
                    // find the matching SERIES
                    SeriesInformationEntity seriesInformationEntity = null;
                    foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
                    {
                        if (lSeriesInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                        {
                            seriesInformationEntity = lSeriesInformationEntity;
                            break;
                        }
                    }
                    if (seriesInformationEntity != null)
                    {
                        // retrieve at the SERIES level
                        if (queryRetrieveLevel == "SERIES")
                        {
                            foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                        else
                        {
                            // find the matching IMAGE
                            InstanceInformationEntity instanceInformationEntity = null;
                            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
                            {
                                if (lInstanceInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                                {
                                    instanceInformationEntity = lInstanceInformationEntity;
                                    break;
                                }
                            }

                            // retrieve at the IMAGE level
                            if ((instanceInformationEntity != null) &&
                                (queryRetrieveLevel == "IMAGE"))
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                    }
                }
            }

            return(fileList);
        }
예제 #7
0
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching STUDY
            BaseInformationEntityList patientStudyInformationEntities = new BaseInformationEntityList();

            foreach (PatientStudyInformationEntity lPatientStudyInformationEntity in Root)
            {
                if (lPatientStudyInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    patientStudyInformationEntities.Add(lPatientStudyInformationEntity);
                }
            }

            if (patientStudyInformationEntities.Count > 0)
            {
                // retrieve at the STUDY level
                if (queryRetrieveLevel == "STUDY")
                {
                    foreach (PatientStudyInformationEntity patientStudyInformationEntity in patientStudyInformationEntities)
                    {
                        foreach (String fileName in patientStudyInformationEntity.FileNames)
                        {
                            fileList.Add(fileName);
                        }
                    }
                }
                else
                {
                    // find the matching SERIES
                    BaseInformationEntityList seriesInformationEntities = patientStudyInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset);

                    if (seriesInformationEntities.Count > 0)
                    {
                        // retrieve at the SERIES level
                        if (queryRetrieveLevel == "SERIES")
                        {
                            foreach (SeriesInformationEntity seriesInformationEntity in seriesInformationEntities)
                            {
                                foreach (String fileName in seriesInformationEntity.FileNames)
                                {
                                    fileList.Add(fileName);
                                }
                            }
                        }
                        else
                        {
                            // find the matching IMAGE
                            BaseInformationEntityList instanceInformationEntities = seriesInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset);

                            // retrieve at the IMAGE level
                            if ((instanceInformationEntities.Count > 0) &&
                                (queryRetrieveLevel == "IMAGE"))
                            {
                                foreach (InstanceInformationEntity instanceInformationEntity in instanceInformationEntities)
                                {
                                    fileList.Add(instanceInformationEntity.Filename);
                                }
                            }
                        }
                    }
                }
            }

            return(fileList);
        }
예제 #8
0
        public override bool HandleCMoveRequest(DicomMessage retrieveMessage)
        {
            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Dicom.Other.Values values = retrieveMessage.CommandSet["0x00000002"].Values;
            System.String sopClassUid = values[0];
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // try to get the Move Destination AE.
            values = retrieveMessage.CommandSet["0x00000600"].Values;
            string vr = retrieveMessage.CommandSet["0x00000600"].VR.ToString();

            System.String moveDestinationAE = values[0];
            string        hexString         = moveDestinationAE;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (DicomThread.Options.LoadedDefinitionFileNames.Length < 10)
            {
                WriteWarning("Some of the definition files is not loaded properly.");
            }
            if (vr == "UN")
            {
                for (int i = 0; i <= hexString.Length - 2; i += 2)
                {
                    sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
                }
            }
            else if (vr == "AE")
            {
                sb.Append(moveDestinationAE);
            }
            if (moveDestinationAE == null || moveDestinationAE == "")
            {
                DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP);
                responseMessage.Set("0x00000900", VR.US, 0xA801);
                responseMessage.Set("0x00000902", VR.LO, "Unknown Move Destination");
                this.Send(responseMessage);
                return(true);
            }
            MoveAEdetailsIndex = FindMoveAEDetails(sb.ToString());
            if (IsHaveMoveDestinations && MoveAEdetailsIndex == -1)
            {
                DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP);
                responseMessage.Set("0x00000900", VR.US, 0xA801);
                responseMessage.Set("0x00000902", VR.LO, "Move Destination not registered in SCP");
                this.Send(responseMessage);
                WriteWarning("Move destination is not registered in SCP");
                return(true);
            }
            DvtkData.Collections.StringCollection retrieveList = null;

            // check if we should use the Patient Root Information Model
            if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                (PatientRootInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientRootInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = PatientRootInformationModel.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Study Root Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Study_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (StudyRootInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    StudyRootInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = StudyRootInformationModel.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Patient Study Only Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Study_Only_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (PatientStudyOnlyInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientStudyOnlyInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = PatientStudyOnlyInformationModel.RetrieveInformationModel(retrieveMessage);
            }

            // process the retrieve list
            return(ProcessRetrieveList(moveDestinationAE, retrieveList));
        }
예제 #9
0
        private bool ProcessRetrieveList(System.String moveDestinationAE, DvtkData.Collections.StringCollection retrieveList)
        {
            UInt16 status = 0x0000;
            UInt16 remainingSubOperations = (UInt16)retrieveList.Count;
            UInt16 completeSubOperations  = 0;
            UInt16 failedSubOperations    = 0;
            UInt16 warningSubOperations   = 0;
            int    subOperationIndex      = 0;
            bool   isCancelRecd           = false;

            foreach (System.String dcmFilename in retrieveList)
            {
                status = 0xFF00;
                SendCMoveRsp(status,
                             remainingSubOperations,
                             completeSubOperations,
                             failedSubOperations,
                             warningSubOperations);

                if (HandleSubOperation(moveDestinationAE, dcmFilename, subOperationIndex) == true && cStoreStatusVal == 0x0000)
                {
                    completeSubOperations++;
                }

                else if (cStoreStatusVal == 0xB007 || cStoreStatusVal == 0xB000 || cStoreStatusVal == 0xB006)
                {
                    warningSubOperations += 1;
                }

                else
                {
                    failedSubOperations++;
                }

                remainingSubOperations--;
                subOperationIndex++;

                int waitedTime = 0;

                // Check for cancel message from SCU
                if (WaitForPendingDataInNetworkInputBuffer(100, ref waitedTime))
                {
                    DicomMessage cancelRq = ReceiveDicomMessage();

                    if (cancelRq.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.CCANCELRQ)
                    {
                        // set up the C-FIND-RSP with cancel status
                        DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP);
                        responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFE00);

                        // send the response
                        this.Send(responseMessage);

                        isCancelRecd = true;
                        break;
                    }
                }
            }

            if (!isCancelRecd)
            {
                if ((failedSubOperations > 0) || (warningSubOperations > 0))
                {
                    status = 0xB000;
                }
                //else if ((failedSubOperations == 0) && (completeSubOperations==0) && (remainingSubOperations==0) &&(warningSubOperations==0))
                //{
                //    status = 0xA702;
                //}
                else
                {
                    status = 0x0000;
                }
                SendCMoveRsp(status,
                             remainingSubOperations,
                             completeSubOperations,
                             failedSubOperations,
                             warningSubOperations);
            }

            // message handled
            return(true);
        }
예제 #10
0
파일: Values.cs 프로젝트: ewcasas/DVTK
        /// <summary>
        /// Converts the supplied array to a DvtkData StringCollection.
        /// </summary>
        /// <remarks>
        /// When an array element is null, it will be skipped.<br></br><br></br>
        /// When an array element cannot be converted, it will be interpreted as a "".
        /// </remarks>
        /// <param name="objects">The array to convert.</param>
        /// <returns>The returned DvtkData StringCollection.</returns>
        private DvtkData.Collections.StringCollection ConvertToStringCollection(object[] objects)
        {
            DvtkData.Collections.StringCollection stringCollection = new DvtkData.Collections.StringCollection();

            foreach (object item in objects)
            {
                if (item != null)
                {
                    String stringValue = "";

                    try
                    {
                        stringValue = System.Convert.ToString(item);
                    }
                    catch
                    {
                        stringValue = "";
                    }

                    stringCollection.Add(stringValue);
                }
            }

            return (stringCollection);
        }
예제 #11
0
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";
            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching STUDY
            BaseInformationEntityList patientStudyInformationEntities = new BaseInformationEntityList();

            foreach (PatientStudyInformationEntity lPatientStudyInformationEntity in Root)
            {
                if (lPatientStudyInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    patientStudyInformationEntities.Add(lPatientStudyInformationEntity);
                }
            }

            if (patientStudyInformationEntities.Count > 0)
            {
                // retrieve at the STUDY level
                if (queryRetrieveLevel == "STUDY")
                {
                    foreach (PatientStudyInformationEntity patientStudyInformationEntity in patientStudyInformationEntities)
                    {
                        foreach (String fileName in patientStudyInformationEntity.FileNames)
                        {
                            fileList.Add(fileName);
                        }
                    }
                }
                else
                {
                    // find the matching SERIES
                    BaseInformationEntityList seriesInformationEntities = patientStudyInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset);

                    if (seriesInformationEntities.Count > 0)
                    {
                        // retrieve at the SERIES level
                        if (queryRetrieveLevel == "SERIES")
                        {
                            foreach (SeriesInformationEntity seriesInformationEntity in seriesInformationEntities)
                            {
                                foreach (String fileName in seriesInformationEntity.FileNames)
                                {
                                    fileList.Add(fileName);
                                }
                            }
                        }
                        else
                        {
                            // find the matching IMAGE
                            BaseInformationEntityList instanceInformationEntities = seriesInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset);

                            // retrieve at the IMAGE level
                            if ((instanceInformationEntities.Count > 0) &&
                                (queryRetrieveLevel == "IMAGE"))
                            {
                                foreach (InstanceInformationEntity instanceInformationEntity in instanceInformationEntities)
                                {
                                    fileList.Add(instanceInformationEntity.Filename);
                                }
                            }
                        }
                    }
                }
            }

            return fileList;
        }
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";
            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching PATIENT
            PatientInformationEntity patientInformationEntity = null;
            foreach (PatientInformationEntity lPatientInformationEntity in Root)
            {
                if (lPatientInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    patientInformationEntity = lPatientInformationEntity;
                    break;
                }
            }

            if (patientInformationEntity != null)
            {
                // retrieve at the PATIENT level
                if (queryRetrieveLevel == "PATIENT")
                {
                    foreach (StudyInformationEntity studyInformationEntity in patientInformationEntity.Children)
                    {
                        foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children)
                        {
                            foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                    }
                }
                else
                {
                    // find the matching STUDY
                    StudyInformationEntity studyInformationEntity = null;
                    foreach (StudyInformationEntity lStudyInformationEntity in patientInformationEntity.Children)
                    {
                        if (lStudyInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                        {
                            studyInformationEntity = lStudyInformationEntity;
                            break;
                        }
                    }

                    // retrieve at the STUDY level
                    if ((studyInformationEntity != null) &&
                        (queryRetrieveLevel == "STUDY"))
                    {
                        foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children)
                        {
                            foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                    }
                }
            }

            return fileList;
        }