示例#1
0
        public override bool HandleCMoveRequest(DicomMessage retrieveMessage)
        {
            if (_informationModels == null)
            {
                return(false);
            }

            // Refresh the Information Models
            _informationModels.Refresh();

            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(retrieveMessage);
            DicomThread.Validate(retrieveMessage, iodName);

            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Values values       = retrieveMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid                  = values.GetString(1);
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // try to get the Move Destination AE.
            values = retrieveMessage.CommandSet.GetAttributeValues("0x00000600");
            System.String moveDestinationAE = values.GetString(1);

            DvtkData.Collections.StringCollection retrieveList = null;

            // check if we should use the Patient Root Information Model
            if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                (_informationModels.PatientRoot != null))
            {
                retrieveList = _informationModels.PatientRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Study Root Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Study_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.StudyRoot != null))
            {
                retrieveList = _informationModels.StudyRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Patient Study Only Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Study_Only_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.PatientStudyOnly != null))
            {
                retrieveList = _informationModels.PatientStudyOnly.RetrieveInformationModel(retrieveMessage);
            }

            // process the retrieve list
            return(ProcessRetrieveList(moveDestinationAE, retrieveList));
        }
示例#2
0
        /// <summary>
        /// Overridden C-FIND-RQ message handler that makes use of the appropriate Information Model to handle the query.
        /// </summary>
        /// <param name="queryMessage">C-FIND-RQ Identifier (Dataset) containing query attributes.</param>
        /// <returns>Boolean - true if dicomMessage handled here.</returns>
        public override bool HandleCFindRequest(DicomMessage queryMessage)
        {
            if (_informationModels == null)
            {
                return(false);
            }

            // Refresh the Information Models
            _informationModels.Refresh();

            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(queryMessage);
            DicomThread.Validate(queryMessage, iodName);

            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Values values       = queryMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid                  = values.GetString(1);
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // check if we should use the Patient Root Information Model
            if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Root_Query_Retrieve_Information_Model_FIND.UID) &&
                (_informationModels.PatientRoot != null))
            {
                DicomMessageCollection responseMessages = _informationModels.PatientRoot.QueryInformationModel(queryMessage);

                foreach (DicomMessage responseMessage in responseMessages)
                {
                    this.Send(responseMessage);
                }
            }
            // check if we should use the Study Root Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Study_Root_Query_Retrieve_Information_Model_FIND.UID) &&
                     (_informationModels.StudyRoot != null))
            {
                DicomMessageCollection responseMessages = _informationModels.StudyRoot.QueryInformationModel(queryMessage);

                foreach (DicomMessage responseMessage in responseMessages)
                {
                    this.Send(responseMessage);
                }
            }
            // check if we should use the Patient Study Only Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Study_Only_Query_Retrieve_Information_Model_FIND.UID) &&
                     (_informationModels.PatientStudyOnly != null))
            {
                DicomMessageCollection responseMessages = _informationModels.PatientStudyOnly.QueryInformationModel(queryMessage);

                foreach (DicomMessage responseMessage in responseMessages)
                {
                    this.Send(responseMessage);
                }
            }
            else
            {
                // should never get here - but send a final CFINDRSP anyway
                DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP);
                this.Send(responseMessage);
            }

            // message handled
            return(true);
        }
示例#3
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;
        }