Beispiel #1
0
        /// <summary>
        /// See the Dvtk.Comparator.DicomComparator.PopulateMessage method.
        /// </summary>
        /// <param name="dicomMessage">See the Dvtk.Comparator.DicomComparator.PopulateMessage method.</param>
        /// <param name="dicomSourceComparator">See the Dvtk.Comparator.DicomComparator.PopulateMessage method.</param>
        /// <returns>See the Dvtk.Comparator.DicomComparator.PopulateMessage method.</returns>
        public bool PopulateDicomMessage(DicomMessage dicomMessage, DicomComparator dicomSourceComparator)
        {
            bool messagePopulated = false;

            if (_dicomComparator != null)
            {
                messagePopulated = _dicomComparator.PopulateMessage(dicomMessage.DvtkDataDicomMessage, dicomSourceComparator);
            }

            return(messagePopulated);
        }
Beispiel #2
0
        public DicomComparator InitializeDicomComparator(DicomMessage dicomMessage)
        {
            DicomComparator dicomComparator = new DicomComparator(_name);
            bool            initialized     = dicomComparator.Initialize(dicomMessage.DvtkDataDicomMessage);

            if (initialized == false)
            {
                dicomComparator = null;
            }

            return(dicomComparator);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the encapsulated Dvtk.Comparator.Hl7Comparator class with the supplied HL7 message.
        /// </summary>
        /// <param name="hl7Message">The HL7 message.</param>
        /// <returns>The encapsulated Dvtk.Comparator.Hl7Comparator instance.</returns>
        public Hl7Comparator InitializeHl7Comparator(Hl7Message hl7Message)
        {
            _dicomComparator = null;

            bool initialized = _hl7Comparator.Initialize(hl7Message);

            if (initialized == false)
            {
                _hl7Comparator = null;
            }

            return(_hl7Comparator);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the encapsulated Dvtk.Comparator.DicomComparator class with the supplied DICOM message.
        /// </summary>
        /// <param name="dicomMessage">The DICOM message.</param>
        /// <returns>The encapsulated Dvtk.Comparator.DicomComparator instance.</returns>
        public DicomComparator InitializeDicomComparator(DicomMessage dicomMessage)
        {
            _hl7Comparator = null;

            bool initialized = _dicomComparator.Initialize(dicomMessage.DvtkDataDicomMessage);

            if (initialized == false)
            {
                _dicomComparator = null;
            }

            return(_dicomComparator);
        }
        /// <summary>
        /// Send a single image generated from the Default Value Manager and
        /// the given Modality Worklist Item.
        /// </summary>
        /// <param name="startNewSeries">Boolean indicating if this image is part of a new
        /// Series or not.</param>
        /// <param name="modalityWorklistItem">Worklist Item used to provide overruling values for
        /// the Image header.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendModalityImagesStored(bool startNewSeries, DicomQueryItem modalityWorklistItem)
        {
            if (modalityWorklistItem == null)
            {
                return(false);
            }

            // Update the default SeriesEntity values for the next Storage Message
            if (startNewSeries == true)
            {
                DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.SeriesEntity);
            }

            // Use modality Worklist Item to help construct the Storage Message
            // Get the attribute values to copy
            DvtkHighLevelInterface.Comparator.Comparator worklistItemComparator = new DvtkHighLevelInterface.Comparator.Comparator("WorklistItemComparator");
            DicomComparator dicomWorklistItemComparator = worklistItemComparator.InitializeDicomComparator(modalityWorklistItem.DicomMessage);

            // Also try to use the MPPS InProgress Message to help construct the Storage Message
            DvtkHighLevelInterface.Comparator.Comparator mppsInProgressComparator = new DvtkHighLevelInterface.Comparator.Comparator("MppsInProgressComparator");
            DicomComparator dicomMppsInProgressComparator = null;

            if (_nCreateSetMppsInProgress != null)
            {
                dicomMppsInProgressComparator = mppsInProgressComparator.InitializeDicomComparator(_nCreateSetMppsInProgress);
            }

            // Create the Storage message
            DvtkHighLevelInterface.Comparator.Comparator       storageComparator = new DvtkHighLevelInterface.Comparator.Comparator("StorageComparator");
            DvtkHighLevelInterface.Dicom.Messages.DicomMessage cStoreInstance    = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ);
            GenerateTriggers.MakeCStoreInstance(DefaultValueManager, cStoreInstance);
            storageComparator.PopulateDicomMessage(cStoreInstance, dicomWorklistItemComparator);
            if (dicomMppsInProgressComparator != null)
            {
                storageComparator.PopulateDicomMessage(cStoreInstance, dicomMppsInProgressComparator);
            }

            // Trigger the C-STORE-RQ Instance
            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_8);

            trigger.HandleInSingleAssociation = true;
            trigger.AddItem(cStoreInstance,
                            "1.2.840.10008.5.1.4.1.1.7",
                            "1.2.840.10008.1.2");

            // Update the default InstanceEntity values for the next Storage Message
            DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.InstanceEntity);

            // RAD-8 - trigger the ImageArchive
            return(TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true));
        }
        private bool TriggerModalityProcedureStepInProgress(DicomQueryItem modalityWorklistItem)
        {
            // Use modality Worklist Item to help construct the MPPS InProgress Message
            // Get the attribute values to copy
            DvtkHighLevelInterface.Comparator.Comparator worklistItemComparator = new DvtkHighLevelInterface.Comparator.Comparator("WorklistItemComparator");
            DicomComparator dicomWorklistItemComparator = worklistItemComparator.InitializeDicomComparator(modalityWorklistItem.DicomMessage);

            DvtkHighLevelInterface.Comparator.Comparator mppsInProgressComparator = new DvtkHighLevelInterface.Comparator.Comparator("MppsInProgressComparator");
            mppsInProgressComparator.PopulateDicomMessage(_nCreateSetMppsInProgress, dicomWorklistItemComparator);

            // Trigger the N-CREATE-RQ MPPS InProgress
            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_6);

            trigger.AddItem(_nCreateSetMppsInProgress,
                            "1.2.840.10008.3.1.2.3.3",
                            "1.2.840.10008.1.2");

            // Update the default PerformedProcedureStepEntity values for the next MPPS In-Progress
            DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.PerformedProcedureStepEntity);

            // RAD-6 - trigger the PerformedProcedureStepManager
            return(TriggerActorInstances(ActorTypeEnum.PerformedProcedureStepManager, trigger, true));
        }
        /// <summary>
        /// Send all the images found in the given storage directory.
        /// </summary>
        /// <param name="storageDirectory">Given storage directory - containing storage DCM files.</param>
        /// <param name="modalityWorklistItem">Worklist Item used to provide overruling values for
        /// the Image headers.</param>
        /// <param name="withSingleAssociation">Boolean indicating whether the images should be sent in a single
        /// association or not.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendModalityImagesStored(System.String storageDirectory, DicomQueryItem modalityWorklistItem, bool withSingleAssociation)
        {
            if ((storageDirectory.Length == 0) ||
                (modalityWorklistItem == null))
            {
                return(false);
            }

            // Use a hash table to store the instance uid mappings
            // - the instance uids for the study, series and sop are going to be updated for all the datasets
            // read from the storageDirectory
            Hashtable instanceMapper = new Hashtable();

            // Get the directory info for the storage directory - and make sure that it exists
            DirectoryInfo directoryInfo = new DirectoryInfo(storageDirectory);

            if (directoryInfo.Exists == false)
            {
                System.String message = System.String.Format("storageDirectory:\"{0}\" - does not exist.", storageDirectory);
                throw new System.Exception(message);
            }

            // Get a trigger
            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_8);

            trigger.HandleInSingleAssociation = withSingleAssociation;

            // Interate over all the DCM files found in the storage directory
            // - update the instances found with the worklist item contents and
            // set up the triggers for the Image Archive
            foreach (FileInfo fileInfo in directoryInfo.GetFiles())
            {
                if ((fileInfo.Extension.ToLower().Equals(".dcm")) ||
                    (fileInfo.Extension == System.String.Empty))
                {
                    // Read the file meta information - it must be present for this actor
                    DvtkData.Media.FileMetaInformation fileMetaInformation = Dvtk.DvtkDataHelper.ReadFMIFromFile(fileInfo.FullName);
                    if (fileMetaInformation == null)
                    {
                        continue;
                    }

                    // Try to get the transfer syntax uid
                    // - start with Implicit VR Little Endian
                    System.String            transferSyntaxUid = "1.2.840.10008.1.2";
                    DvtkData.Dimse.Attribute attribute         = fileMetaInformation.GetAttribute(DvtkData.Dimse.Tag.TRANSFER_SYNTAX_UID);
                    if (attribute != null)
                    {
                        UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                        if (uniqueIdentifier.Values.Count > 0)
                        {
                            transferSyntaxUid = uniqueIdentifier.Values[0];
                        }
                    }

                    // Read the dataset from the DCM file
                    DvtkData.Dimse.DataSet dataset = Dvtk.DvtkDataHelper.ReadDataSetFromFile(fileInfo.FullName);
                    if (dataset == null)
                    {
                        continue;
                    }

                    // Remove any Group Lengths from the dataset
                    dataset.RemoveGroupLengthAttributes();

                    // Try to get the series instance uid
                    System.String            oldSeriesInstanceUid       = System.String.Empty;
                    DvtkData.Dimse.Attribute seriesInstanceUidAttribute = dataset.GetAttribute(Tag.SERIES_INSTANCE_UID);
                    if (seriesInstanceUidAttribute != null)
                    {
                        UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)seriesInstanceUidAttribute.DicomValue;
                        if (uniqueIdentifier.Values.Count > 0)
                        {
                            oldSeriesInstanceUid = uniqueIdentifier.Values[0];
                        }

                        // Remove the old series instance from the dataset
                        dataset.Remove(seriesInstanceUidAttribute);
                    }

                    // See if a mapping exists
                    System.String newSeriesInstanceUid = (System.String)instanceMapper[oldSeriesInstanceUid];
                    if (newSeriesInstanceUid == null)
                    {
                        // Add a mapping
                        DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.SeriesEntity);
                        newSeriesInstanceUid = DefaultValueManager.GetInstantiatedValue(Tag.SERIES_INSTANCE_UID);
                        instanceMapper.Add(oldSeriesInstanceUid, newSeriesInstanceUid);
                    }

                    // Add the new series instance uid to the dataset
                    dataset.AddAttribute(Tag.SERIES_INSTANCE_UID.GroupNumber, Tag.SERIES_INSTANCE_UID.ElementNumber, VR.UI, newSeriesInstanceUid);

                    // Try to get the sop instance uid
                    System.String            oldSopInstanceUid       = System.String.Empty;
                    DvtkData.Dimse.Attribute sopInstanceUidAttribute = dataset.GetAttribute(Tag.SOP_INSTANCE_UID);
                    if (sopInstanceUidAttribute != null)
                    {
                        UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)sopInstanceUidAttribute.DicomValue;
                        if (uniqueIdentifier.Values.Count > 0)
                        {
                            oldSopInstanceUid = uniqueIdentifier.Values[0];
                        }

                        // Remove the old sop instance from the dataset
                        dataset.Remove(sopInstanceUidAttribute);
                    }

                    // See if a mapping exists
                    System.String newSopInstanceUid = (System.String)instanceMapper[oldSopInstanceUid];
                    if (newSopInstanceUid == null)
                    {
                        // Add a mapping
                        DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.InstanceEntity);
                        newSopInstanceUid = DefaultValueManager.GetInstantiatedValue(Tag.SOP_INSTANCE_UID);
                        instanceMapper.Add(oldSopInstanceUid, newSopInstanceUid);
                    }

                    // Add the new sop instance uid to the dataset
                    dataset.AddAttribute(Tag.SOP_INSTANCE_UID.GroupNumber, Tag.SOP_INSTANCE_UID.ElementNumber, VR.UI, newSopInstanceUid);

                    // Use modality Worklist Item to help construct the Storage Message
                    // Get the attribute values to copy
                    DvtkHighLevelInterface.Comparator.Comparator worklistItemComparator = new DvtkHighLevelInterface.Comparator.Comparator("WorklistItemComparator");
                    DicomComparator dicomWorklistItemComparator = worklistItemComparator.InitializeDicomComparator(modalityWorklistItem.DicomMessage);

                    // Also try to use the MPPS InProgress Message to help construct the Storage Message
                    DvtkHighLevelInterface.Comparator.Comparator mppsInProgressComparator = new DvtkHighLevelInterface.Comparator.Comparator("MppsInProgressComparator");
                    DicomComparator dicomMppsInProgressComparator = null;
                    if (_nCreateSetMppsInProgress != null)
                    {
                        dicomMppsInProgressComparator = mppsInProgressComparator.InitializeDicomComparator(_nCreateSetMppsInProgress);
                    }

                    // Create the Storage message
                    DvtkHighLevelInterface.Comparator.Comparator       storageComparator = new DvtkHighLevelInterface.Comparator.Comparator("StorageComparator");
                    DvtkHighLevelInterface.Dicom.Messages.DicomMessage cStoreInstance    = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ);
                    GenerateTriggers.MakeCStoreInstance(DefaultValueManager, cStoreInstance, dataset);
                    storageComparator.PopulateDicomMessage(cStoreInstance, dicomWorklistItemComparator);
                    if (dicomMppsInProgressComparator != null)
                    {
                        storageComparator.PopulateDicomMessage(cStoreInstance, dicomMppsInProgressComparator);
                    }

                    // Try to get the sop class uid
                    System.String            sopClassUid          = System.String.Empty;
                    DvtkData.Dimse.Attribute sopClassUidAttribute = dataset.GetAttribute(Tag.SOP_CLASS_UID);
                    if (sopClassUidAttribute != null)
                    {
                        UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)sopClassUidAttribute.DicomValue;
                        if (uniqueIdentifier.Values.Count > 0)
                        {
                            sopClassUid = uniqueIdentifier.Values[0];
                        }
                    }

                    // Add trigger item to the trigger
                    trigger.AddItem(cStoreInstance,
                                    sopClassUid,
                                    transferSyntaxUid);
                }
            }

            // RAD-8 - trigger the ImageArchive
            return(TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true));
        }
Beispiel #8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="name">Name to supply to the encapsulated Dvtk.Comparator.DicomComparator and Dvtk.Comparator.Hl7Comparator classes.</param>
 public Comparator(System.String name)
 {
     _dicomComparator = new DicomComparator(name);
     _hl7Comparator   = new Hl7Comparator(name);
 }