/// <summary>
        /// Retrieve data from the Information Model using the given retrieve message.
        /// </summary>
        /// <param name="retrieveMessage">Message used to retrieve the Information Model.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DicomMessage retrieveMessage)
        {
            StudyRootInformationModel root = (StudyRootInformationModel)Root;

            return(root.RetrieveInformationModel(retrieveMessage.DataSet.DvtkDataDataSet));
        }
Exemplo n.º 2
0
        public override bool HandleCMoveRequest(DicomMessage retrieveMessage)
        {
            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Dicom.Other.Values values = retrieveMessage.CommandSet["0x00000002"].Values;
            System.String sopClassUid = values[0];
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // try to get the Move Destination AE.
            values = retrieveMessage.CommandSet["0x00000600"].Values;
            string vr = retrieveMessage.CommandSet["0x00000600"].VR.ToString();

            System.String moveDestinationAE = values[0];
            string        hexString         = moveDestinationAE;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (DicomThread.Options.LoadedDefinitionFileNames.Length < 10)
            {
                WriteWarning("Some of the definition files is not loaded properly.");
            }
            if (vr == "UN")
            {
                for (int i = 0; i <= hexString.Length - 2; i += 2)
                {
                    sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
                }
            }
            else if (vr == "AE")
            {
                sb.Append(moveDestinationAE);
            }
            if (moveDestinationAE == null || moveDestinationAE == "")
            {
                DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP);
                responseMessage.Set("0x00000900", VR.US, 0xA801);
                responseMessage.Set("0x00000902", VR.LO, "Unknown Move Destination");
                this.Send(responseMessage);
                return(true);
            }
            MoveAEdetailsIndex = FindMoveAEDetails(sb.ToString());
            if (IsHaveMoveDestinations && MoveAEdetailsIndex == -1)
            {
                DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP);
                responseMessage.Set("0x00000900", VR.US, 0xA801);
                responseMessage.Set("0x00000902", VR.LO, "Move Destination not registered in SCP");
                this.Send(responseMessage);
                WriteWarning("Move destination is not registered in SCP");
                return(true);
            }
            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) &&
                (PatientRootInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientRootInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = PatientRootInformationModel.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) &&
                     (StudyRootInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    StudyRootInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = StudyRootInformationModel.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) &&
                     (PatientStudyOnlyInformationModel != null))
            {
                // check if the information model should be refreshed before retrieving
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientStudyOnlyInformationModel.RefreshInformationModel();
                }

                // perform retrieve
                retrieveList = PatientStudyOnlyInformationModel.RetrieveInformationModel(retrieveMessage);
            }

            // process the retrieve list
            return(ProcessRetrieveList(moveDestinationAE, retrieveList));
        }
        /// <summary>
        /// Check if the given instance is present in the Information Model. The instance will be at the leaf nodes of the Information Model.
        /// </summary>
        /// <param name="sopClassUid">SOP Class UID to search for.</param>
        /// <param name="sopInstanceUid">SOP Instance UID to search for.</param>
        /// <returns>Boolean - true if instance found in the Information Model, otherwise false.</returns>
        public bool IsInstanceInInformationModel(System.String sopClassUid, System.String sopInstanceUid)
        {
            StudyRootInformationModel root = (StudyRootInformationModel)Root;

            return(root.IsInstanceInInformationModel(sopClassUid, sopInstanceUid));
        }
Exemplo n.º 4
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)
        {
            // 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.Dicom.Other.Values values = queryMessage.CommandSet["0x00000002"].Values;
            System.String sopClassUid = values[0];
            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) &&
                (PatientRootInformationModel != null))
            {
                // check if the information model should be refreshed before querying
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientRootInformationModel.RefreshInformationModel();
                }

                // perform query
                DicomMessageCollection responseMessages = PatientRootInformationModel.QueryInformationModel(queryMessage);

                // handle responses
                foreach (DicomMessage responseMessage in responseMessages)
                {
                    int waitedTime = 0;

                    // Check for cancel message from SCU
                    if (WaitForPendingDataInNetworkInputBuffer(100, ref waitedTime))
                    {
                        DicomMessage cancelRq = ReceiveDicomMessage();

                        if (cancelRq.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.CCANCELRQ)
                        {
                            // set up the C-FIND-RSP with cancel status
                            DicomMessage respMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP);
                            respMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFE00);

                            // send the response
                            this.Send(respMessage);
                            break;
                        }
                    }

                    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) &&
                     (StudyRootInformationModel != null))
            {
                // check if the information model should be refreshed before querying
                if (RefreshInformationModelBeforeUse == true)
                {
                    StudyRootInformationModel.RefreshInformationModel();
                }

                // perform query
                DicomMessageCollection responseMessages = StudyRootInformationModel.QueryInformationModel(queryMessage);

                // handle responses
                foreach (DicomMessage responseMessage in responseMessages)
                {
                    int waitedTime = 0;

                    // Check for cancel message from SCU
                    if (WaitForPendingDataInNetworkInputBuffer(100, ref waitedTime))
                    {
                        DicomMessage cancelRq = ReceiveDicomMessage();

                        if (cancelRq.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.CCANCELRQ)
                        {
                            // set up the C-FIND-RSP with cancel status
                            DicomMessage respMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP);
                            respMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFE00);

                            // send the response
                            this.Send(respMessage);
                            break;
                        }
                    }

                    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) &&
                     (PatientStudyOnlyInformationModel != null))
            {
                // check if the information model should be refreshed before querying
                if (RefreshInformationModelBeforeUse == true)
                {
                    PatientStudyOnlyInformationModel.RefreshInformationModel();
                }

                // perform query
                DicomMessageCollection responseMessages = PatientStudyOnlyInformationModel.QueryInformationModel(queryMessage);

                // handle responses
                foreach (DicomMessage responseMessage in responseMessages)
                {
                    int waitedTime = 0;

                    // Check for cancel message from SCU
                    if (WaitForPendingDataInNetworkInputBuffer(100, ref waitedTime))
                    {
                        DicomMessage cancelRq = ReceiveDicomMessage();

                        if (cancelRq.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.CCANCELRQ)
                        {
                            // set up the C-FIND-RSP with cancel status
                            DicomMessage respMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP);
                            respMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFE00);

                            // send the response
                            this.Send(respMessage);
                            break;
                        }
                    }

                    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);
        }