/// <summary>
        /// Check if the given match dataset is found in the local dataset using the default Tag Type list.
        /// A check is made to see if all the attributes in the given match dataset are present in the local
        /// dataset. In addition to the base match we need to try to match attributes from the
        /// Request Attributes Sequence (if present).
        /// </summary>
        /// <param name="matchDataset">Match dataset to check.</param>
        /// <returns>Boolean indicating if the match attributes are present in the local dataset.</returns>
        public override bool IsFoundIn(AttributeSet matchDataset)
        {
            bool isFoundIn = base.IsFoundIn(matchDataset);

            if (isFoundIn == false)
            {
                // check if the Request Attributes Sequence is available in the match dataset
                DvtkData.Dimse.Attribute requestAttributesSequence = matchDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
                if (requestAttributesSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        // set up a temporary tag list to check the relevant tags in the Request Attributes Sequence
                        TagTypeList itemTagTypeList = new TagTypeList();
                        itemTagTypeList.Add(new TagType(Tag.REQUESTED_PROCEDURE_ID, TagTypeEnum.TagOptional));

                        DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                        // check if found in item
                        isFoundIn = base.IsFoundIn(itemTagTypeList, item);
                    }
                }
            }

            return(isFoundIn);
        }
        /// <summary>
        /// Copy from the given source Dataset into the local Dataset as defined by the
        /// default Tag Type list. In addition to the base copy we need to copy attributes from the
        /// Request Attributes Sequence (if present) and the Scheduled Procedure Step (if present).
        /// </summary>
        /// <param name="sourceDataset">Source Dataset used to populate the local Dataset.</param>
        public override void CopyFrom(AttributeSet sourceDataset)
        {
            // perform base copy
            base.CopyFrom(sourceDataset);

            // check if the Request Attributes Sequence is available in the source dataset
            DvtkData.Dimse.Attribute requestAttributesSequence = sourceDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
            if (requestAttributesSequence != null)
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // copy item attributes too
                    base.CopyFrom(item);
                }
            }

            // check if the Scheduled Procedure Step Sequence is available in the source dataset
            DvtkData.Dimse.Attribute scheduledProcedureStepSequence = sourceDataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE);
            if (scheduledProcedureStepSequence != null)
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // copy item attributes too
                    base.CopyFrom(item);
                }
            }
        }
Exemple #3
0
        private bool LoadTemplate(DvtkData.Dimse.DataSet dataset)
        {
            if (dataset == null)
            {
                return(false);
            }

            // try to find the template tag in the dataset
            foreach (DicomComparisonTag comparisonTag in this._template.ComparisonTags)
            {
                DvtkData.Dimse.Tag tag = comparisonTag.Tag;
                DvtkData.Dimse.Tag parentSequenceTag = comparisonTag.ParentSequenceTag;
                System.String      attributeValue    = System.String.Empty;

                if (parentSequenceTag != Tag.UNDEFINED)
                {
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(parentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag);
                                attributeValue = GetAttributeValue(attribute);
                            }
                        }
                    }
                }
                else
                {
                    DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag);
                    attributeValue = GetAttributeValue(attribute);
                }

                if (attributeValue != System.String.Empty)
                {
                    comparisonTag.DataFormat.FromDicomFormat(attributeValue);
                }
            }

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Create a Worklist Query Dataset from the given DCM file. We assume that the DCM file
        /// contains the appropriate MWL Query Dataset. If the scheduled procedure step start date
        /// is present in the DCM file, it will be overwritten with the value given by scheduledProcedureStepStartDate.
        /// </summary>
        /// <param name="mwlQueryDcmFilename">MWL Query Dcm Filename.</param>
        /// <param name="userDefinedScheduledProcedureStepStartDate">User Defined Scheduled Procedure Step Start Date.</param>
        /// <returns>DvtkData.Dimse.DataSet - Modality Worklist Query Dataset.</returns>
        public static DvtkData.Dimse.DataSet CreateWorklistQueryDataset(System.String mwlQueryDcmFilename, System.String userDefinedScheduledProcedureStepStartDate)
        {
            // Read the DCM file
            DataSet dataset = Dvtk.DvtkDataHelper.ReadDataSetFromFile(mwlQueryDcmFilename);

            dataset.IodId = "Modality Worklist Information Model - FIND SOP Class";

            // Update the scheduled procedure step start date (if present)
            if (userDefinedScheduledProcedureStepStartDate != System.String.Empty)
            {
                DvtkData.Dimse.Attribute scheduledProcedureStepSequence = dataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE);
                if (scheduledProcedureStepSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        SequenceItem queryItem = sequenceOfItems.Sequence[0];

                        // Try to get the Scheduled Procedure Step Start Date
                        // - update it if there is a value defined in the dataset
                        DvtkData.Dimse.Attribute scheduledProcedureStepStartDate = queryItem.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_START_DATE);
                        if ((scheduledProcedureStepStartDate != null) &&
                            (scheduledProcedureStepStartDate.Length != 0))
                        {
                            // Remove the existing attribute
                            queryItem.Remove(scheduledProcedureStepStartDate);

                            // Modify value to today's date
                            queryItem.AddAttribute(Tag.SCHEDULED_PROCEDURE_STEP_START_DATE.GroupNumber,
                                                   Tag.SCHEDULED_PROCEDURE_STEP_START_DATE.ElementNumber,
                                                   DvtkData.Dimse.VR.DA,
                                                   userDefinedScheduledProcedureStepStartDate);
                        }
                    }
                }
            }

            return(dataset);
        }
Exemple #5
0
        private static void AddTagsToDataset(TagValueCollection tags, DvtkData.Dimse.DataSet dataset)
        {
            // iterate over the tags
            foreach (DicomTagValue tag in tags)
            {
                if (tag.ParentSequenceTag != Tag.UNDEFINED)
                {
                    // try to get the sequence tag in the dataset
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(tag.ParentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                VR vr = VR.UN;

                                // try to get the attribute in the item
                                DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag.Tag);
                                if (attribute != null)
                                {
                                    vr = attribute.ValueRepresentation;
                                    item.Remove(attribute);
                                }

                                // add the query value
                                item.AddAttribute(tag.Tag.GroupNumber,
                                                  tag.Tag.ElementNumber,
                                                  vr,
                                                  tag.Value);
                            }
                        }
                    }
                }
                else
                {
                    VR vr = VR.UN;

                    // try to get the attribute in the dataset
                    DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag.Tag);
                    if (attribute != null)
                    {
                        vr = attribute.ValueRepresentation;
                        dataset.Remove(attribute);
                    }

                    // special check for the SPECIFIC CHARACTER SET attribute
                    if (tag.Tag == Tag.SPECIFIC_CHARACTER_SET)
                    {
                        vr = VR.CS;
                    }

                    // add the query value
                    dataset.AddAttribute(tag.Tag.GroupNumber,
                                         tag.Tag.ElementNumber,
                                         vr,
                                         tag.Value);
                }
            }
        }
Exemple #6
0
        private System.String GetAttributeValue(DvtkData.Dimse.Attribute attribute)
        {
            System.String attributeValue = System.String.Empty;
            if ((attribute == null) ||
                (attribute.Length == 0))
            {
                return(attributeValue);
            }

            switch (attribute.ValueRepresentation)
            {
            case VR.AE:
            {
                ApplicationEntity applicationEntity = (ApplicationEntity)attribute.DicomValue;
                attributeValue = applicationEntity.Values[0];
                break;
            }

            case VR.AS:
            {
                AgeString ageString = (AgeString)attribute.DicomValue;
                attributeValue = ageString.Values[0];
                break;
            }

            case VR.CS:
            {
                CodeString codeString = (CodeString)attribute.DicomValue;
                attributeValue = codeString.Values[0];
                break;
            }

            case VR.DA:
            {
                Date date = (Date)attribute.DicomValue;
                attributeValue = date.Values[0];
                break;
            }

            case VR.DS:
            {
                DecimalString decimalString = (DecimalString)attribute.DicomValue;
                attributeValue = decimalString.Values[0];
                break;
            }

            case VR.DT:
            {
                DvtkData.Dimse.DateTime dateTime = (DvtkData.Dimse.DateTime)attribute.DicomValue;
                attributeValue = dateTime.Values[0];
                break;
            }

            case VR.IS:
            {
                IntegerString integerString = (IntegerString)attribute.DicomValue;
                attributeValue = integerString.Values[0];
                break;
            }

            case VR.LO:
            {
                LongString longString = (LongString)attribute.DicomValue;
                attributeValue = longString.Values[0];
                break;
            }

            case VR.LT:
            {
                LongText longText = (LongText)attribute.DicomValue;
                attributeValue = longText.Value;
                break;
            }

            case VR.PN:
            {
                PersonName personName = (PersonName)attribute.DicomValue;
                attributeValue = personName.Values[0];
                break;
            }

            case VR.SH:
            {
                ShortString shortString = (ShortString)attribute.DicomValue;
                attributeValue = shortString.Values[0];
                break;
            }

            case VR.SQ:
            {
                // Special case looking for the SOP Class UID
                SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue;
                if ((sequenceOfItems != null) &&
                    (sequenceOfItems.Sequence.Count == 1))
                {
                    // Special case looking for the SOP Class UID
                    SequenceItem item = sequenceOfItems.Sequence[0];
                    attribute      = item.GetAttribute(new Tag(0x0008, 0x1150));
                    attributeValue = GetAttributeValue(attribute);
                }
                break;
            }

            case VR.ST:
            {
                ShortText shortText = (ShortText)attribute.DicomValue;
                attributeValue = shortText.Value;
                break;
            }

            case VR.TM:
            {
                Time time = (Time)attribute.DicomValue;
                attributeValue = time.Values[0];
                break;
            }

            case VR.UI:
            {
                UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                attributeValue = uniqueIdentifier.Values[0];
                break;
            }

            default:
                break;
            }

            return(attributeValue);
        }
Exemple #7
0
        private bool CopyToDicomMessage(DvtkData.Dimse.DicomMessage dicomMessage, DicomComparator sourceComparator)
        {
            bool messagePopulated = true;

            // Check if both templates have been initialized correctly
            if ((this.Template == null) ||
                (sourceComparator.Template == null))
            {
                return(false);
            }

            // Iterate over this comparator
            foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
            {
                // try to get the equivalent tag in the sourceComparator
                DicomComparisonTag sourceComparisonTag = sourceComparator.Template.ComparisonTags.Find(thisComparisonTag.Tag);
                if (sourceComparisonTag != null)
                {
                    System.String          stringValue = sourceComparisonTag.DataFormat.ToDicomFormat();
                    DvtkData.Dimse.DataSet dataset     = dicomMessage.DataSet;
                    if (dataset != null)
                    {
                        // we need to see if the parent sequence has been set up in the dataset
                        if (thisComparisonTag.ParentSequenceTag != Tag.UNDEFINED)
                        {
                            // set up the parent sequence and add it to the dataset
                            SequenceOfItems          sequenceOfItems   = null;
                            DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag);
                            if (sequenceAttribute == null)
                            {
                                // add in an empty item
                                DvtkData.Dimse.SequenceItem item = new SequenceItem();
                                dataset.AddAttribute(thisComparisonTag.ParentSequenceTag.GroupNumber,
                                                     thisComparisonTag.ParentSequenceTag.ElementNumber,
                                                     VR.SQ,
                                                     item);
                                sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag);
                            }

                            // get the sequence item and add in the required attribute
                            sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                            if (sequenceOfItems.Sequence.Count == 1)
                            {
                                DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];
                                if (item != null)
                                {
                                    // add the attribute to the item
                                    if (sourceComparisonTag.Vr == VR.SQ)
                                    {
                                        // add in an empty item
                                        // TODO - fix this properly
                                        DvtkData.Dimse.SequenceItem item1 = new SequenceItem();
                                        item.AddAttribute(sourceComparisonTag.Tag.GroupNumber,
                                                          sourceComparisonTag.Tag.ElementNumber,
                                                          VR.SQ,
                                                          item1);
                                    }
                                    else
                                    {
                                        // if the attribute already exists - then we need to remove it
                                        // - it was probably set to the default value
                                        DvtkData.Dimse.Attribute attribute = item.GetAttribute(sourceComparisonTag.Tag);
                                        if (attribute != null)
                                        {
                                            item.Remove(attribute);
                                        }

                                        // add the attribute to the item
                                        item.AddAttribute(sourceComparisonTag.Tag.GroupNumber,
                                                          sourceComparisonTag.Tag.ElementNumber,
                                                          sourceComparisonTag.Vr,
                                                          stringValue);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // if the attribute already exists - then we need to remove it
                            // - it was probably set to the default value
                            DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(sourceComparisonTag.Tag);
                            if (attribute != null)
                            {
                                dataset.Remove(attribute);
                            }

                            // add the attribute at the top level
                            dataset.AddAttribute(sourceComparisonTag.Tag.GroupNumber,
                                                 sourceComparisonTag.Tag.ElementNumber,
                                                 sourceComparisonTag.Vr,
                                                 stringValue);
                        }
                    }
                }
            }

            return(messagePopulated);
        }
        public static DvtkHighLevelInterface.Messages.DicomMessage MakeStorageCommitEvent(QueryRetrieveInformationModels informationModels, DvtkHighLevelInterface.Messages.DicomMessage actionMessage)
        {
            // refresh the information models
            informationModels.Refresh();

            DvtkHighLevelInterface.Messages.DicomMessage eventMessage = new DvtkHighLevelInterface.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ);
            eventMessage.Set("0x00000002", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1");
            eventMessage.Set("0x00001000", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1.1");
            eventMessage.Set("0x00001002", DvtkData.Dimse.VR.US, 1);

            DvtkData.Dimse.DataSet actionDataset = actionMessage.DataSet.DvtkDataDataSet;

            DvtkData.Dimse.DataSet eventDataset = new DvtkData.Dimse.DataSet();

            DvtkData.Dimse.Attribute eventReferenceSopSequence        = new DvtkData.Dimse.Attribute(0x00081199, DvtkData.Dimse.VR.SQ);
            SequenceOfItems          eventReferenceSopSequenceOfItems = new SequenceOfItems();

            eventReferenceSopSequence.DicomValue = eventReferenceSopSequenceOfItems;

            DvtkData.Dimse.Attribute eventFailedSopSequence        = new DvtkData.Dimse.Attribute(0x00081198, DvtkData.Dimse.VR.SQ);
            SequenceOfItems          eventFailedSopSequenceOfItems = new SequenceOfItems();

            eventFailedSopSequence.DicomValue = eventFailedSopSequenceOfItems;

            if (actionDataset != null)
            {
                DvtkData.Dimse.Attribute transactionUid = actionDataset.GetAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID);
                if (transactionUid != null)
                {
                    eventDataset.Add(transactionUid);
                }

                DvtkData.Dimse.Attribute referencedSopSequence = actionDataset.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_SEQUENCE);
                if (referencedSopSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)referencedSopSequence.DicomValue;
                    foreach (DvtkData.Dimse.SequenceItem item in sequenceOfItems.Sequence)
                    {
                        System.String sopClassUid    = "";
                        System.String sopInstanceUid = "";

                        DvtkData.Dimse.Attribute attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID);
                        if (attribute != null)
                        {
                            UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                            sopClassUid = uniqueIdentifier.Values[0];
                        }

                        attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID);
                        if (attribute != null)
                        {
                            UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                            sopInstanceUid = uniqueIdentifier.Values[0];
                        }

                        if (informationModels.PatientRoot.IsInstanceInInformationModel(sopClassUid, sopInstanceUid))
                        {
                            DvtkData.Dimse.SequenceItem itemOk = new DvtkData.Dimse.SequenceItem();
                            itemOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid);
                            itemOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid);

                            // add instance to committed list
                            eventReferenceSopSequenceOfItems.Sequence.Add(itemOk);
                        }
                        else
                        {
                            DvtkData.Dimse.SequenceItem itemNotOk = new DvtkData.Dimse.SequenceItem();
                            itemNotOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid);
                            itemNotOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid);
                            itemNotOk.AddAttribute(0x00081197, DvtkData.Dimse.VR.US, 0x0110);

                            // add instance to failed list
                            eventFailedSopSequenceOfItems.Sequence.Add(itemNotOk);
                        }
                    }
                }

                if (eventReferenceSopSequenceOfItems.Sequence.Count > 0)
                {
                    eventDataset.Add(eventReferenceSopSequence);
                }

                if (eventFailedSopSequenceOfItems.Sequence.Count > 0)
                {
                    eventDataset.Add(eventFailedSopSequence);
                }
            }

            eventMessage.DataSet.DvtkDataDataSet = eventDataset;

            return(eventMessage);
        }
        /// <summary>
        /// Query the Information Model using the given Query Dataset.
        /// </summary>
        /// <param name="queryDataset">Query Dataset.</param>
        /// <returns>A collection of zero or more query reponse datasets.</returns>
        public override DataSetCollection QueryInformationModel(DataSet queryDataset)
        {
            DataSetCollection queryResponses = new DataSetCollection();

            BaseInformationEntityList matchingScheduledProcedureSteps = new BaseInformationEntityList();

            SequenceItem queryItem         = null;
            TagTypeList  queryTagTypeList  = new TagTypeList();
            TagTypeList  returnTagTypeList = new TagTypeList();

            foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
            {
                // special check for the Scheduled Procedure Step Sequence
                if (attribute.Tag == Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        queryItem = sequenceOfItems.Sequence[0];

                        foreach (DvtkData.Dimse.Attribute itemAttribute in queryItem)
                        {
                            if (itemAttribute.Length != 0)
                            {
                                queryTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagRequired));
                            }
                            returnTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagOptional));
                        }
                    }
                }
                else
                {
                    if (attribute.Length != 0)
                    {
                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                    }
                    returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                }
            }

            // iterate over the Modality Worklist Information Model and save all the matching
            // Scheduled Procedure Steps
            // iterate of all Information Entities
            foreach (PatientInformationEntity patientInformationEntity in Root)
            {
                if ((patientInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) ||
                    (patientInformationEntity.UniversalMatch(queryTagTypeList)))
                {
                    foreach (VisitInformationEntity visitInformationEntity in patientInformationEntity.Children)
                    {
                        if ((visitInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) ||
                            (visitInformationEntity.UniversalMatch(queryTagTypeList)))
                        {
                            foreach (ImagingServiceRequestInformationEntity imagingServiceRequestInformationEntity in visitInformationEntity.Children)
                            {
                                if ((imagingServiceRequestInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) ||
                                    (imagingServiceRequestInformationEntity.UniversalMatch(queryTagTypeList)))
                                {
                                    foreach (RequestedProcedureInformationEntity requestedProcedureInformationEntity in imagingServiceRequestInformationEntity.Children)
                                    {
                                        if ((requestedProcedureInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) ||
                                            (requestedProcedureInformationEntity.UniversalMatch(queryTagTypeList)))
                                        {
                                            foreach (ScheduledProcedureStepInformationEntity scheduledProcedureStepInformationEntity in requestedProcedureInformationEntity.Children)
                                            {
                                                if (scheduledProcedureStepInformationEntity.IsFoundIn(queryTagTypeList, queryItem))
                                                {
                                                    // add the scheduled procedure step to the matched list
                                                    matchingScheduledProcedureSteps.Add(scheduledProcedureStepInformationEntity);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // we now have a list of all the matching scheduled procedure steps
            foreach (ScheduledProcedureStepInformationEntity matchingScheduledProcedureStepInformationEntity in matchingScheduledProcedureSteps)
            {
                SequenceItem responseItem = new SequenceItem();
                matchingScheduledProcedureStepInformationEntity.CopyTo(returnTagTypeList, responseItem);
                DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00400100, VR.SQ, responseItem);

                DataSet queryResponse = new DataSet();
                queryResponse.Add(attribute);

                RequestedProcedureInformationEntity matchingRequestedProcedureInformationEntity
                    = (RequestedProcedureInformationEntity)matchingScheduledProcedureStepInformationEntity.Parent;
                matchingRequestedProcedureInformationEntity.CopyTo(returnTagTypeList, queryResponse);

                ImagingServiceRequestInformationEntity matchingImagingServiceRequestInformationEntity
                    = (ImagingServiceRequestInformationEntity)matchingRequestedProcedureInformationEntity.Parent;
                matchingImagingServiceRequestInformationEntity.CopyTo(returnTagTypeList, queryResponse);

                VisitInformationEntity matchingVisitInformationEntity
                    = (VisitInformationEntity)matchingImagingServiceRequestInformationEntity.Parent;
                matchingVisitInformationEntity.CopyTo(returnTagTypeList, queryResponse);

                PatientInformationEntity matchingPatientInformationEntity
                    = (PatientInformationEntity)matchingVisitInformationEntity.Parent;
                matchingPatientInformationEntity.CopyTo(returnTagTypeList, queryResponse);

                queryResponses.Add(queryResponse);
            }

            return(queryResponses);
        }