Esempio n. 1
0
        public bool SetUp(DvtkData.Dimse.DicomMessage dicomMessage)
        {
            DvtkData.Dimse.DimseCommand command = dicomMessage.CommandField;
            System.String sopClassUid           = System.String.Empty;

            // To be fixed - why is the SOP Class UID not always filled in?
            // RB: TODO
            if (command == DvtkData.Dimse.DimseCommand.CSTORERQ)
            {
                sopClassUid = "1.2.840.10008.5.1.4.1.1.7";
            }

            DvtkData.Dimse.Attribute attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.AFFECTED_SOP_CLASS_UID);
            if (attribute == null)
            {
                attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.REQUESTED_SOP_CLASS_UID);
            }
            if ((attribute != null) &&
                (attribute.Length != 0))
            {
                UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                sopClassUid = uniqueIdentifier.Values[0];
            }

            // Try to initialise a template
            _template = new DicomComparisonTemplate();
            bool setUpDone = _template.Initialize(command, sopClassUid);

            return(setUpDone);
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize the DicomComparator
        /// </summary>
        /// <param name="dicomMessage"></param>
        /// <returns></returns>
        /// <returns>bool - true = template initialized, false template not initialized</returns>
        public bool Initialize(DvtkData.Dimse.DicomMessage dicomMessage)
        {
            DvtkData.Dimse.DimseCommand command = dicomMessage.CommandField;
            System.String sopClassUid           = System.String.Empty;

            DvtkData.Dimse.Attribute attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.AFFECTED_SOP_CLASS_UID);
            if (attribute == null)
            {
                attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.REQUESTED_SOP_CLASS_UID);
            }
            if ((attribute != null) &&
                (attribute.Length != 0))
            {
                UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                sopClassUid = uniqueIdentifier.Values[0];
            }

            // Try to initialise a template
            _template = new DicomComparisonTemplate();
            bool initialized = _template.Initialize(command, sopClassUid);

            if (initialized == true)
            {
                // Load the template with the corresponding attribute values
                initialized = LoadTemplate(dicomMessage.DataSet);
            }

            return(initialized);
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize the DicomComparator
        /// </summary>
        /// <param name="dicomMessage"></param>
        /// <returns>bool - true = template initialized, false template not initialized</returns>
        public bool Initialize(DvtkData.Dimse.DicomMessage dicomMessage)
        {
            // Set up the comparator using the templates
            bool setUpOk = SetUp(dicomMessage);

            if (setUpOk == true)
            {
                // Load the template with the corresponding attribute values
                setUpOk = LoadTemplate(dicomMessage.DataSet);
            }

            return(setUpOk);
        }
Esempio n. 4
0
        public bool PopulateMessage(DvtkData.Dimse.DicomMessage dicomMessage, DicomComparator sourceComparator)
        {
            // Check for comparator equality
            if (this == sourceComparator)
            {
                return(false);
            }

            // Set up the comparator using the templates
            bool setUpOk = SetUp(dicomMessage);

            if (setUpOk == true)
            {
                // Copy the source comparator values into the dicom message if the tags are in this comparator
                setUpOk = CopyToDicomMessage(dicomMessage, sourceComparator);
            }

            return(setUpOk);
        }
Esempio n. 5
0
        /// <summary>
        /// <see cref="ISniffer.Validate"/>
        /// </summary>
        public bool Validate(
			DicomMessage message, 
			ValidationControlFlags validationControlFlags)
        {
            if (message == null) throw new System.ArgumentNullException();

            //Set the validation options
            Wrappers.ValidationControlFlags
                wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None;
            if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0)
                wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions;
            if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0)
                wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations;

            return (this.m_adaptee as Wrappers.MSnifferSession).Validate(
                message,
                wrappersValidationControlFlags);
        }
Esempio n. 6
0
        /// <summary>
        /// Method for comparing pixel data in two DICOM messages
        /// </summary>
        /// <param name="message"></param>
        /// <param name="referenceMessage"></param>
        /// <returns></returns>
        public bool ComparePixelData(DicomMessage message, DicomMessage referenceMessage)
        {
            if (message == null) throw new System.ArgumentNullException();
            if (referenceMessage == null) throw new System.ArgumentNullException();

            return (this.m_adaptee as Wrappers.MScriptSession).ComparePixelData(
                message,
                referenceMessage);
        }
Esempio n. 7
0
        /// <summary>
        /// <see cref="IDimseValidation.Validate( DicomMessage ,
        /// DicomMessage ,
        /// DicomMessage ,
        /// ValidationControlFlags )"/>
        /// </summary>
        public bool Validate(
            DicomMessage message,
            DicomMessage referenceMessage,
            DicomMessage lastMessage,
            ValidationControlFlags validationControlFlags)
        {
            if (message == null) throw new System.ArgumentNullException();
            // referenceMessage may be null
            //
            // Convert flags
            //
            Wrappers.ValidationControlFlags
                wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None;
            if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0)
                wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions;
            if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0)
                wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences;
            if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0)
                wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations;

            return (this.m_adaptee as Wrappers.MScriptSession).Validate(
                message,
                referenceMessage,
                lastMessage,
                wrappersValidationControlFlags);
        }
Esempio n. 8
0
        /// <summary>
        /// <see cref="IDimseMessaging.Send(DicomMessage)"/>
        /// With the new UPS SOP classes (Unified Procedure Step – Push SOP Class, Unified Procedure Step – 
        /// Watch SOP Class, Unified Procedure Step – Pull SOP Class, Unified Procedure Step – Event SOP Class), 
        /// fully specified in frozen supplement 96, it is now possible to send a DICOM message with an affected 
        /// or requested SOP Class UID attribute that is different from the abstract syntax UID in an accepted 
        /// presentation context.
        /// </summary>
        public SendReturnCode Send(DicomMessage dicomMessage, int presentationContextId)
        {
            if (dicomMessage == null) throw new System.ArgumentNullException("dicomMessage");

            Wrappers.SendReturnCode wrappersSendReturnCode =
                (this.m_adaptee as Wrappers.MScriptSession).Send(dicomMessage, presentationContextId);
            return _Convert(wrappersSendReturnCode);
        }
Esempio n. 9
0
 /// <summary>
 /// <see cref="IDimseMessaging.Receive(out DicomMessage)"/>
 /// </summary>
 public ReceiveReturnCode Receive(out DicomMessage dicomMessage)
 {
     dicomMessage = null;
     Wrappers.ReceiveReturnCode wrappersReceiveReturnCode =
         (this.m_adaptee as Wrappers.MScriptSession).Receive(out dicomMessage);
     return _Convert(wrappersReceiveReturnCode);
 }
Esempio n. 10
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);
        }