private bool TriggerModalityWorklistQuery(DicomTrigger trigger)
        {
            // Start with empty worklist and storage commit items
            _modalityWorklistItems = new DicomQueryItemCollection();
            _storageCommitItems = new ReferencedSopItemCollection();
            _nCreateSetMppsInProgress = null;

            // RAD-5 - trigger the DssOrderFiller
            bool triggerResult = TriggerActorInstances(ActorTypeEnum.DssOrderFiller, trigger, true);

            // Get the worklist items returned
            if (triggerResult == true)
            {
                foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog)
                {
                    if (actorsTransaction.FromActorName.Type == ActorTypeEnum.DssOrderFiller)
                    {
                        BaseTransaction baseTransaction = actorsTransaction.Transaction;
                        if (baseTransaction is DicomTransaction)
                        {
                            DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction;
                            if (dicomTransaction.Processed == false)
                            {
                                DicomMessageCollection cFindResponses = dicomTransaction.DicomMessages.CFindResponses;
                                int index = 0;
                                foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in cFindResponses)
                                {
                                    if (dicomMessage.DataSet.Count != 0)
                                    {
                                        DicomQueryItem dicomWorklistItem = new DicomQueryItem(index++, dicomMessage);
                                        _modalityWorklistItems.Add(dicomWorklistItem);
                                    }
                                }
                                dicomTransaction.Processed = true;
                            }
                        }
                    }
                }
            }

            return triggerResult;
        }
Beispiel #2
0
        /// <summary>
        /// Send a C-FIND-RQ Information Model Query.
        /// Query based on the informationModel provided and the query/retrieve level. Take
        /// the query tags from the queryTags provided.
        /// 
        /// The C-FIND-RSP messages returned are stored in a DicomQueryItemCollection named QueryItems.
        /// </summary>
        /// <param name="informationModel">Q/R Information Model to be used in the query operation.</param>
        /// <param name="level">Query / retrieve level.</param>
        /// <param name="queryTags">List of Query Tags.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendQueryImages(QueryRetrieveInformationModelEnum informationModel, QueryRetrieveLevelEnum level, TagValueCollection queryTags)
        {
            System.String queryRetrieveLevel = System.String.Empty;
            switch(level)
            {
                case QueryRetrieveLevelEnum.PatientQueryRetrieveLevel:
                    _patientLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "PATIENT";
                    break;
                case QueryRetrieveLevelEnum.StudyQueryRetrieveLevel:
                    _studyLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "STUDY";
                    break;
                case QueryRetrieveLevelEnum.SeriesQueryRetrieveLevel:
                    _seriesLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "SERIES";
                    break;
                case QueryRetrieveLevelEnum.InstanceQueryRetrieveLevel:
                    _instanceLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "IMAGE";
                    break;
                default:
                    return false;
            }
            if (queryTags.Find(Tag.QUERY_RETRIEVE_LEVEL) == null)
            {
                queryTags.Add(new DicomTagValue(Tag.QUERY_RETRIEVE_LEVEL, queryRetrieveLevel));
            }

            DicomQueryItemCollection queryItems = QueryItems(level);

            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_14);
            System.String sopClassUid = System.String.Empty;
            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.1.1";
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.2.1";
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.3.1";
                    break;
                default:
                    return false;
            }
            trigger.AddItem(GenerateTriggers.MakeCFindQuery(informationModel, queryTags),
                            sopClassUid,
                            "1.2.840.10008.1.2");

            // RAD-14 - trigger the ImageArchive
            bool triggerResult = TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true);

            // Get the query items returned
            if (triggerResult == true)
            {
                foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog)
                {
                    if (actorsTransaction.FromActorName.Type == ActorTypeEnum.ImageArchive)
                    {
                        BaseTransaction baseTransaction = actorsTransaction.Transaction;
                        if (baseTransaction is DicomTransaction)
                        {
                            DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction;
                            if (dicomTransaction.Processed == false)
                            {
                                DicomMessageCollection cFindResponses = dicomTransaction.DicomMessages.CFindResponses;
                                int index = 0;
                                foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in cFindResponses)
                                {
                                    if (dicomMessage.DataSet.Count != 0)
                                    {
                                        DicomQueryItem dicomQueryItem = new DicomQueryItem(index++, dicomMessage);
                                        queryItems.Add(dicomQueryItem);
                                    }
                                }
                                dicomTransaction.Processed = true;
                            }
                        }
                    }
                }
            }

            return triggerResult;
        }
 /// <summary>
 /// Inserts an <see cref="DicomQueryItem"/> element into the <see cref="DicomQueryItemCollection"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="DicomQueryItem"/> to insert.</param>
 public void Insert(int index, DicomQueryItem value)
 {
     List.Insert(index, value);
 }
        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);
        }
Beispiel #5
0
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="DicomQueryItem"/> from the <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to remove from the <see cref="DicomQueryItemCollection"/>.</param>
 public void Remove(DicomQueryItem value)
 {
     List.Remove(value);
 }
 /// <summary>
 /// Send Images - called from GUI IMAGES button
 /// </summary>
 public bool SendImages(DicomQueryItem modalityWorklistItem, bool withSingleAssociation)
 {
     // Send the images - read images based on worklist map to storage directory
     return _acquisitionModality.SendModalityImagesStored(modalityWorklistItem, withSingleAssociation);
 }
        /// <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);
        }
Beispiel #8
0
 /// <summary>
 /// Searches for the specified <see cref="DicomQueryItem"/> and
 /// returns the zero-based index of the first occurrence within the entire <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to locate in the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="DicomQueryItemCollection"/>,
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(DicomQueryItem value)
 {
     return(List.IndexOf(value));
 }
 /// <summary>
 /// Copies the elements of the <see cref="ICollection"/> to a strong-typed <c>DicomQueryItem[]</c>, 
 /// starting at a particular <c>DicomQueryItem[]</c> index.
 /// </summary>
 /// <param name="array">
 /// The one-dimensional <c>DicomQueryItem[]</c> that is the destination of the elements 
 /// copied from <see cref="ICollection"/>.
 /// The <c>DicomQueryItem[]</c> must have zero-based indexing. 
 /// </param>
 /// <param name="index">
 /// The zero-based index in array at which copying begins.
 /// </param>
 /// <remarks>
 /// Provides the strongly typed member for <see cref="ICollection"/>.
 /// </remarks>
 public void CopyTo(DicomQueryItem[] array, int index)
 {
     ((ICollection)this).CopyTo(array, index);
 }
Beispiel #10
0
        private void selectPatient()
        {
            // Pop up MWL rsp dialog
            MWLResponse dlg = new MWLResponse(wrapper.ModalityActor.ModalityWorklistItems);
            DialogResult result = dlg.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                buttonReqWL.Enabled = true;
                toolBarButtonStop.Enabled = true;
                buttonStoreImage.Enabled = false;
                buttonMPPSMsg.Enabled = false;
                toolBarButtonConfigSys.Enabled = true;
            }
            else
            {
                selectedMWLItem = dlg.SelectedPatient;

                if (selectedMWLItem == null)
                {
                    buttonReqWL.Enabled = true;
                    toolBarButtonLog.Enabled = false;
                    toolBarButtonStop.Enabled = false;
                    buttonStoreImage.Enabled = false;
                    buttonMPPSMsg.Enabled = false;
                    toolBarButtonConfigSys.Enabled = true;
                    toolBarButtonResults.Enabled = false;
                }
                else
                {
                    //buttonReqWL.Enabled = false;
                    buttonStoreImage.Enabled = true;
                    buttonMPPSMsg.Enabled = true;
                    buttonMPPSMsg.Text = "Send MPPS Progress";
                }
            }
        }
 /// <summary>
 /// Determines whether the <see cref="DicomQueryItemCollection"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to locate in the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="DicomQueryItemCollection"/> contains the specified value; 
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(DicomQueryItem value)
 {
     // If value is not of type Code, this will return false.
     return (List.Contains(value));
 }
 /// <summary>
 /// Adds an object to the end of the <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to be added to the end of the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>The <see cref="DicomQueryItemCollection"/> index at which the value has been added.</returns>
 public int Add(DicomQueryItem value)
 {
     return (List.Add(value));
 }
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="DicomQueryItem"/> from the <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to remove from the <see cref="DicomQueryItemCollection"/>.</param>
 public void Remove(DicomQueryItem value)
 {
     List.Remove(value);
 }
Beispiel #14
0
        /// <summary>
        /// Send a C-MOVE-RQ Information Model Retrieve.
        /// Retrieve based on the informationModel provided and the query/retrieve level. Take
        /// the retrieve tags from the retrieveTags provided. The retrieve is done to the move
        /// destination.
        /// 
        /// The C-MOVE-RSP messages returned are stored in a DicomQueryItemCollection named RetrieveItems.
        /// </summary>
        /// <param name="informationModel">Q/R Information Model to be used in the retrieve operation.</param>
        /// <param name="level">Query / retrieve level.</param>
        /// <param name="moveDestination">AE Title of the "move" destination.</param>
        /// <param name="retrieveTags">List of Retrieve Tags.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendRetrieveImages(QueryRetrieveInformationModelEnum informationModel, QueryRetrieveLevelEnum level, System.String moveDestination, TagValueCollection retrieveTags)
        {
            System.String queryRetrieveLevel = System.String.Empty;
            switch(level)
            {
                case QueryRetrieveLevelEnum.PatientQueryRetrieveLevel:
                    queryRetrieveLevel = "PATIENT";
                    break;
                case QueryRetrieveLevelEnum.StudyQueryRetrieveLevel:
                    queryRetrieveLevel = "STUDY";
                    break;
                case QueryRetrieveLevelEnum.SeriesQueryRetrieveLevel:
                    queryRetrieveLevel = "SERIES";
                    break;
                case QueryRetrieveLevelEnum.InstanceQueryRetrieveLevel:
                    queryRetrieveLevel = "IMAGE";
                    break;
                default:
                    return false;
            }
            if (retrieveTags.Find(Tag.QUERY_RETRIEVE_LEVEL) == null)
            {
                retrieveTags.Add(new DicomTagValue(Tag.QUERY_RETRIEVE_LEVEL, queryRetrieveLevel));
            }
            _retrieveItems = new DicomQueryItemCollection();

            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_16);
            System.String sopClassUid = System.String.Empty;
            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.1.2";
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.2.2";
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.3.2";
                    break;
                default:
                    return false;
            }
            trigger.AddItem(GenerateTriggers.MakeCMoveRetrieve(informationModel, moveDestination, retrieveTags),
                            sopClassUid,
                            "1.2.840.10008.1.2");

            // RAD-16 - trigger the ImageArchive
            bool triggerResult = TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true);

            // Get the retrieve items returned
            if (triggerResult == true)
            {
                foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog)
                {
                    if (actorsTransaction.FromActorName.Type == ActorTypeEnum.ImageArchive)
                    {
                        BaseTransaction baseTransaction = actorsTransaction.Transaction;
                        if (baseTransaction is DicomTransaction)
                        {
                            DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction;
                            if (dicomTransaction.Processed == false)
                            {
                                DicomMessageCollection cMoveResponses = dicomTransaction.DicomMessages.CMoveResponses;
                                int index = 0;
                                foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in cMoveResponses)
                                {
                                    // store all C-MOVE-RSP messages
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_COMPLETED_SUBOPERATIONS) to get completed count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_FAILED_SUBOPERATIONS) to get failed count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_REMAINING_SUBOPERATIONS) to get remaining count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_WARNING_SUBOPERATIONS) to get warning count
                                    DicomQueryItem dicomRetriveItem = new DicomQueryItem(index++, dicomMessage);
                                    _retrieveItems.Add(dicomRetriveItem);
                                }
                                dicomTransaction.Processed = true;
                            }
                        }
                    }
                }
            }

            return triggerResult;
        }
        /// <summary>
        /// Send all the images found in the data directory mapped from the given
        /// Modality Worklist item - the MapWorklistItemToStorageDirectory defines
        /// the data directory / worklist item attribute value mapping.
        /// </summary>
        /// <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(DicomQueryItem modalityWorklistItem, bool withSingleAssociation)
        {
            if (modalityWorklistItem == null) return false;

            // use the MapWorklistItemToStorageDirectory to get the MapTag
            DvtkData.Dimse.Tag mapTag = _mapWorklistItemToStorageDirectory.MapTag;
            if (mapTag == null)
            {
                throw new System.Exception("No MapTag defined for MapWorklistItemToStorageDirectory.");
            }

            // The MapTag is then used to search the worklist item for a matching description
            // - first try in the Scheduled Procedure Step Sequence
            System.String description = modalityWorklistItem.GetValue(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE, mapTag);
            if (description == "Default")
            {
                // - now try in the remaining dataset
                description = modalityWorklistItem.GetValue(mapTag);
            }

            // Use the description to get the storage directory containing the DCM files that should be sent
            System.String storageDirectory = _mapWorklistItemToStorageDirectory.GetStorageDirectory(description);
            if (storageDirectory == System.String.Empty)
            {
                // Try the default mapping
                storageDirectory = _mapWorklistItemToStorageDirectory.GetStorageDirectory("Default");
            }
            if (storageDirectory == System.String.Empty)
            {
                System.String message = System.String.Format("No storageDirectory mapping found for description \"{0}\" or \"Default\".", description);
                throw new System.Exception(message);
            }

            // Send the contents of the storage directory - updated by the modality worklist item contents
            return SendModalityImagesStored(storageDirectory, modalityWorklistItem, withSingleAssociation);
        }
Beispiel #16
0
 /// <summary>
 /// Adds an object to the end of the <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to be added to the end of the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>The <see cref="DicomQueryItemCollection"/> index at which the value has been added.</returns>
 public int Add(DicomQueryItem value)
 {
     return(List.Add(value));
 }
        /// <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 #18
0
 /// <summary>
 /// Inserts an <see cref="DicomQueryItem"/> element into the <see cref="DicomQueryItemCollection"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="DicomQueryItem"/> to insert.</param>
 public void Insert(int index, DicomQueryItem value)
 {
     List.Insert(index, value);
 }
        /// <summary>
        /// Send an N-CREATE MPPS IN-PROGRESS message by using the Default Value Manager.
        /// Use the modalityWorklistItem to overwrite the appropriate attribute values.
        /// </summary>
        /// <param name="modalityWorklistItem">Modality Worklist Item used to update MPPS IN-PROGRESS dataset.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendNCreateModalityProcedureStepInProgress(DicomQueryItem modalityWorklistItem)
        {
            // Initialize the N-CREATE MPPS IN-PROGRESS
            InitializeModalityProcedureStepInProgress(DvtkData.Dimse.DimseCommand.NCREATERQ);

            // Generate the N-CREATE MPPS IN-PROGRESS from the Default Value Manager
            GenerateTriggers.MakeMppsInProgress(DefaultValueManager, _nCreateSetMppsInProgress, _mppsInstanceUid);

            return TriggerModalityProcedureStepInProgress(modalityWorklistItem);
        }
Beispiel #20
0
 /// <summary>
 /// Determines whether the <see cref="DicomQueryItemCollection"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to locate in the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="DicomQueryItemCollection"/> contains the specified value;
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(DicomQueryItem value)
 {
     // If value is not of type Code, this will return false.
     return(List.Contains(value));
 }
        /// <summary>
        /// Send an N-SET MPPS IN-PROGRESS message from the given mppsInProgressDcmFilename.
        /// Use the modalityWorklistItem to overwrite the appropriate attribute values.
        /// NOTE: This call should only be made after the SendModalityProcedureStepInProgress() (using default N-CREATE) 
        /// has been made.
        /// </summary>
        /// <param name="mppsInProgressDcmFilename">DCM Filename - contains MPPS IN-PROGRESS dataset.</param>
        /// <param name="modalityWorklistItem">Modality Worklist Item used to update MPPS IN-PROGRESS dataset.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendNSetModalityProcedureStepInProgress(System.String mppsInProgressDcmFilename, DicomQueryItem modalityWorklistItem)
        {
            // Initialize the N-SET MPPS IN-PROGRESS
            InitializeModalityProcedureStepInProgress(DvtkData.Dimse.DimseCommand.NSETRQ);

            // Generate the N-SET MPPS IN-PROGRESS from the DCM file contents (default values)
            GenerateTriggers.MakeMppsInProgress(mppsInProgressDcmFilename, DefaultValueManager, _nCreateSetMppsInProgress, _mppsInstanceUid);

            return TriggerModalityProcedureStepInProgress(modalityWorklistItem);
        }
 /// <summary>
 /// Send MPPS IN-PROGRESS - called from GUI IN-PROGRESS button
 /// </summary>
 public bool SendMppsInProgress(DicomQueryItem modalityWorklistItem, System.String mppsInProgressDcmFilename)
 {
     // send the mpps in-progress
     return _acquisitionModality.SendNCreateModalityProcedureStepInProgress(mppsInProgressDcmFilename, modalityWorklistItem);
 }
 /// <summary>
 /// Searches for the specified <see cref="DicomQueryItem"/> and 
 /// returns the zero-based index of the first occurrence within the entire <see cref="DicomQueryItemCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="DicomQueryItem"/> to locate in the <see cref="DicomQueryItemCollection"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="DicomQueryItemCollection"/>, 
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(DicomQueryItem value)
 {
     return (List.IndexOf(value));
 }