예제 #1
0
        private static void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems,
			uint tag,
			DvtkData.Dimse.AttributeSet attributeSet,
			InstanceStateEnum newInstanceState)
        {
            ushort group = (ushort)(tag >> 16);
            ushort element = (ushort)(tag & 0x0000FFFF);
            DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element);

            DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue);
            if (referencedSopSequence != null)
            {
                attributeSet.Remove(referencedSopSequence);
            }

            referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ);
            SequenceOfItems referencedSopSequenceOfItems = new SequenceOfItems();
            referencedSopSequence.DicomValue = referencedSopSequenceOfItems;

            foreach(ReferencedSopItem  referencedSopItem in storageCommitItems)
            {
                if (((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) &&
                    (newInstanceState == InstanceStateEnum.InstanceMppsCompleted)) ||
                    ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceMppsCompleted) &&
                    (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested)))
                {

                    DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem();
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid);
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid);
                    referencedSopItem.InstanceState = newInstanceState;
                    referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem);
                }
            }
            attributeSet.Add(referencedSopSequence);
        }
예제 #2
0
        private static void AddDefaultMppsCompletedDiscontinuedValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager,
			ReferencedSopItemCollection storageCommitItems,
			DvtkData.Dimse.DataSet dataset,
			System.String mppsStatus)
        {
            DvtkData.Dimse.SequenceItem performedSeriesSequenceItem = new DvtkData.Dimse.SequenceItem();

            // Series Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PROTOCOL_NAME, VR.LO, performedSeriesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.RETRIEVE_AE_TITLE, VR.AE, performedSeriesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_DESCRIPTION, VR.LO, performedSeriesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMING_PHYSICIANS_NAME, VR.PN, performedSeriesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.OPERATORS_NAME, VR.PN, performedSeriesSequenceItem);

            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_INSTANCE_UID, VR.UI, performedSeriesSequenceItem);

            performedSeriesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STANDALONE_SOP_INSTANCE_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_STANDALONE_SOP_INSTANCE_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);

            // Performed Procedure Step Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME, VR.TM, dataset);

            if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.COMMENTS_ON_THE_PERFORMED_PROCEDURE_STEPS) != System.String.Empty)
            {
                AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.COMMENTS_ON_THE_PERFORMED_PROCEDURE_STEPS, VR.ST, dataset);
            }

            AddReferencedSopSequence(storageCommitItems, 0x00081140, performedSeriesSequenceItem, InstanceStateEnum.InstanceMppsCompleted);

            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ, performedSeriesSequenceItem);

            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.ElementNumber,
                VR.CS, mppsStatus);

            // Add any RadiationDoseDefaultValues default values
            AddRadiationDoseDefaultValues(defaultValueManager, dataset);
        }
예제 #3
0
        private static void AddDefaultMppsInProgressValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, DvtkData.Dimse.DataSet dataset)
        {
            DvtkData.Dimse.SequenceItem scheduledStepAttributesSequenceItem = new DvtkData.Dimse.SequenceItem();

            // Patient Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_NAME, VR.PN, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENT_ID, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_BIRTH_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_SEX, VR.CS, dataset);

            // Study Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_ID, VR.SH, dataset);

            // Requested Procedure Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_ID, VR.SH, scheduledStepAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_DESCRIPTION, VR.LO, scheduledStepAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_INSTANCE_UID, VR.UI, scheduledStepAttributesSequenceItem);

            // Scheduled Procedure Step Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.MODALITY, VR.CS, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_ID, VR.SH, scheduledStepAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_DESCRIPTION, VR.LO, scheduledStepAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_DATE, VR.DA, scheduledStepAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_TIME, VR.TM, scheduledStepAttributesSequenceItem);

            // Performed Procedure Step Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_ID, VR.SH, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_DESCRIPTION, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_TIME, VR.TM, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_STATION_AE_TITLE, VR.AE, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_STATION_NAME, VR.SH, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_LOCATION, VR.SH, dataset);

            // Add in zero length attributes
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE.ElementNumber,
                DvtkData.Dimse.VR.DA);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME.ElementNumber,
                DvtkData.Dimse.VR.TM);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_TYPE_DESCRIPTION.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_TYPE_DESCRIPTION.ElementNumber,
                DvtkData.Dimse.VR.LO);
            dataset.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_PATIENT_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_PATIENT_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PROCEDURE_CODE_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.PROCEDURE_CODE_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_ACTION_ITEM_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_ACTION_ITEM_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);

            scheduledStepAttributesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.SCHEDULED_ACTION_ITEM_CODE_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.SCHEDULED_ACTION_ITEM_CODE_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);
            scheduledStepAttributesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STUDY_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_STUDY_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ);

            dataset.AddAttribute(DvtkData.Dimse.Tag.SCHEDULED_STEP_ATTRIBUTES_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.SCHEDULED_STEP_ATTRIBUTES_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ, scheduledStepAttributesSequenceItem);
            dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.GroupNumber,
                DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.ElementNumber,
                DvtkData.Dimse.VR.CS, "IN PROGRESS");
        }
예제 #4
0
        /// <summary>
        /// Cretae a storage commitment event.
        /// </summary>
        /// <param name="informationModels">The information models.</param>
        /// <param name="actionMessage">The action message.</param>
        /// <returns>The created event.</returns>
        public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeStorageCommitEvent(QueryRetrieveInformationModels informationModels, DvtkHighLevelInterface.Dicom.Messages.DicomMessage actionMessage)
        {
            // refresh the information models
            informationModels.Refresh();

            DvtkHighLevelInterface.Dicom.Messages.DicomMessage eventMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ);
            eventMessage.Set("0x00000002", VR.UI, "1.2.840.10008.1.20.1");
            eventMessage.Set("0x00001000", VR.UI, "1.2.840.10008.1.20.1.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;
                            if (uniqueIdentifier.Values.Count > 0)
                            {
                                sopClassUid = uniqueIdentifier.Values[0];
                            }
                        }

                        attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID);
                        if (attribute != null)
                        {
                            UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                            if (uniqueIdentifier.Values.Count > 0)
                            {
                                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)
                {
                    eventMessage.Set("0x00001002", VR.US, 1);
                    eventDataset.Add(eventReferenceSopSequence);
                }

                if (eventFailedSopSequenceOfItems.Sequence.Count > 0)
                {
                    eventMessage.Set("0x00001002", VR.US, 2);
                    eventDataset.Add(eventFailedSopSequence);
                }
            }

            eventMessage.DataSet.DvtkDataDataSet = eventDataset;

            return eventMessage;
        }
예제 #5
0
        private static void AddStorageCommitmentValues(ReferencedSopItemCollection storageCommitItems,
			DvtkData.Dimse.DataSet dataset,
			System.String storageCommitTransactionUid,
			System.String mppsInstanceUid)
        {
            DvtkData.Dimse.SequenceItem referencedStudyComponentSequenceItem = new DvtkData.Dimse.SequenceItem();
            referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber,
                DvtkData.Dimse.VR.UI, "1.2.840.10008.3.1.2.3.3");
            referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber,
                DvtkData.Dimse.VR.UI, mppsInstanceUid);
            dataset.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ, referencedStudyComponentSequenceItem);

            AddReferencedSopSequence(storageCommitItems, 0x00081199, dataset, InstanceStateEnum.InstanceStorageCommitRequested);

            dataset.AddAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID.GroupNumber,
                DvtkData.Dimse.Tag.TRANSACTION_UID.ElementNumber,
                DvtkData.Dimse.VR.UI, storageCommitTransactionUid);
        }
예제 #6
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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        private static void AddDefaultReturnKeys(DvtkData.Dimse.DataSet dataset)
        {
            // use the Worklist Information Entities to generate the default Return Key attribute set
            PatientInformationEntity patientIe = new PatientInformationEntity();
            foreach(TagType tagType in patientIe.TagTypeList)
            {
                dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr);
            }
            VisitInformationEntity visitIe = new VisitInformationEntity();
            foreach(TagType tagType in visitIe.TagTypeList)
            {
                dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr);
            }
            ImagingServiceRequestInformationEntity imagingServiceRequestIe = new ImagingServiceRequestInformationEntity();
            foreach(TagType tagType in imagingServiceRequestIe.TagTypeList)
            {
                dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr);
            }
            RequestedProcedureInformationEntity requestedProcedureIe = new RequestedProcedureInformationEntity();
            foreach(TagType tagType in requestedProcedureIe.TagTypeList)
            {
                dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr);
            }

            SequenceItem item = new SequenceItem();
            ScheduledProcedureStepInformationEntity scheduledProcedureStepIe = new ScheduledProcedureStepInformationEntity();
            foreach(TagType tagType in scheduledProcedureStepIe.TagTypeList)
            {
                if (tagType.Tag != Tag.SPECIFIC_CHARACTER_SET)
                {
                    item.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr);
                }
            }
            dataset.AddAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.GroupNumber,
                Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.ElementNumber, VR.SQ, item);
        }