public void DataSetCollectionEvaluate_1_1() { // // SetUp the test data for this test case. // DicomMessageCollection dicomMessageCollection = new DicomMessageCollection(); DicomMessage dicomMessage1 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage1.DataSet.Set("0x00200020", VR.LT, "Long text value"); dicomMessageCollection.Add(dicomMessage1); DicomMessage dicomMessage2 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage2.DataSet.Set("0x00300030", VR.LT, "Long text value"); dicomMessageCollection.Add(dicomMessage2); // // Perform the actual test. // DataSetCollection dataSetCollection = BooleanExpressionDataSet.ContainsAttribute("0x00200020").Evaluate(dicomMessageCollection.DataSets); Assert.That(dataSetCollection.Count, Is.EqualTo(1)); }
protected override void Execute() { ReceiveAssociateRq(); SendAssociateAc(); DicomMessage receivedCFindRequest = ReceiveDicomMessage(); // // Query the information model. // DicomMessageCollection worklistQueryResponses = modalityWorklistInformationModel.QueryInformationModel(receivedCFindRequest); count = worklistQueryResponses.Count; if (worklistQueryResponses.Count > 1) { WriteInformation(string.Format("Sending {0} C-FIND responses after performing query.\r\n", worklistQueryResponses.Count)); } else { WriteWarning("No response from MWL information model after performing query.\r\n"); } // send responses foreach (DicomMessage responseMessage in worklistQueryResponses) { this.Send(responseMessage); } ReceiveReleaseRq(); SendReleaseRp(); }
/// <summary> /// Returns number of responses. /// </summary> /// <param name="studyTime"></param> /// <param name="StydyTimeRange"></param> /// <param name="?"></param> /// <returns></returns> private int Ticket788CommonCode2 (String studyTime, String StydyTimeRange) { QueryRetrievePatientRootInformationModel queryRetrievePatientRootInformationModel = new QueryRetrievePatientRootInformationModel(); DicomFile dicomFile = new DicomFile(); dicomFile.DataSet.Set("0x00100020", VR.LO, "1"); dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1"); dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1"); dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.1"); dicomFile.DataSet.Set("0x00080020", VR.DA, "20090225"); // Study date. dicomFile.DataSet.Set("0x00080030", VR.TM, studyTime); // Study time. queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile); DicomMessage cFindRequest = new DicomMessage(DimseCommand.CFINDRQ); cFindRequest.CommandSet.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.1"); // Set Affected SOP class to Patient Root Query/Retrieve Information Model – FIND cFindRequest.DataSet.Set("0x00100020", VR.LO, "1"); // Patient ID. cFindRequest.DataSet.Set("0x0020000D", VR.UI); // Study instance UID. cFindRequest.Set("0x00080030", VR.TM, StydyTimeRange); // Study time. cFindRequest.DataSet.Set("0x00080052", VR.CS, "STUDY"); // Query Retrieve Level. DicomMessageCollection cFindResponses = queryRetrievePatientRootInformationModel.QueryInformationModel(cFindRequest); return(cFindResponses.Count); }
private bool SendAssociationAndWait(DicomMessageCollection dicomMessages, params PresentationContext[] presentationContexts) { bool isAssociationAccepted = true; // Send the associate request. SendAssociateRq(presentationContexts); // Receive the associate repsonse (may be an accept or reject). DulMessage associateRp = ReceiveAssociateRp(); try { // If an associate accept was received, send the collection of DicomMessages, receive a response and // release the association. if (associateRp is AssociateAc) { // send each message foreach (DicomMessage dicomMessage in dicomMessages) { Send(dicomMessage); DicomMessage responseMessage = ReceiveDicomMessage(); // use the common config option 1 to determine how the storage commitment should be handled if (DicomClient.ConfigOption1.Equals("DO_STORAGE_COMMITMENT_ON_SINGLE_ASSOCIATION") == true) { DicomMessage dicomRequest = ReceiveDicomMessage(); // Validate the received message // System.String iodName = GetIodNameFromDefinition(dicomRequest); // Validate(dicomRequest, iodName); // set up the default N-EVENT-REPORT-RSP with a successful status responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRSP); responseMessage.Set("0x00000900", VR.US, 0); // send the response Send(responseMessage); } } SendReleaseRq(); ReceiveReleaseRp(); } else { isAssociationAccepted = false; } } catch (Exception e) { SendReleaseRq(); ReceiveReleaseRp(); throw e; } return(isAssociationAccepted); }
public void Trigger(DicomMessage dicomMessage, params PresentationContext[] presentationContexts) { DicomMessageCollection dicomMessageCollection = new DicomMessageCollection(); dicomMessageCollection.Add(dicomMessage); Trigger(dicomMessageCollection, presentationContexts); }
/// <summary> /// Trigger a send association and wait until it has been completed. /// </summary> /// <param name="dicomMessageCollection">The DICOM messages to send.</param> /// <param name="presentationContexts">The presentation contexts to propose.</param> /// <returns> /// True indicates the other side has accepted the association, false indicates the other side /// has rejected the association. /// </returns> public bool TriggerSendAssociationAndWait(DicomMessageCollection dicomMessageCollection, params PresentationContext[] presentationContexts) { SendAssociationTrigger sendAssociationTrigger = new SendAssociationTrigger(dicomMessageCollection, presentationContexts); Trigger(sendAssociationTrigger); WaitForLastTriggerCallProcessed(); return(sendAssociationTrigger.returnValue); }
/// <summary> /// Triggers sending of an association. /// </summary> /// <param name="dicomMessage">The DICOM message to send.</param> /// <param name="presentationContexts">The presentation contexts to use for setting up the DICOM association.</param> public void TriggerSendAssociation(DicomMessage dicomMessage, params PresentationContext[] presentationContexts) { DicomMessageCollection dicomMessageCollection = new DicomMessageCollection(); dicomMessageCollection.Add(dicomMessage); SendAssociationTrigger sendAssociationTrigger = new SendAssociationTrigger(dicomMessageCollection, presentationContexts); Trigger(sendAssociationTrigger); }
public void Ticket788_12_1() { QueryRetrievePatientRootInformationModel queryRetrievePatientRootInformationModel = null; DicomMessage cFindRequest = null; Ticket788CommonCode1(@"*\*", out queryRetrievePatientRootInformationModel, out cFindRequest); DicomMessageCollection dicomMessageCollection = queryRetrievePatientRootInformationModel.QueryInformationModel(cFindRequest); // Expect two messages with status pending and on message with status success. Assert.That(dicomMessageCollection.Count, Is.EqualTo(3)); }
/// <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); // perform query DicomMessageCollection responseMessages = _modalityWorklistInformationModel.QueryInformationModel(queryMessage); if (responseMessages.Count > 1) { WriteInformation(string.Format("Sending {0} C-FIND responses after performing query.\r\n", responseMessages.Count)); } else { WriteWarning("No response from MWL information model after performing query.\r\n"); } // 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); } // message handled return(true); }
private void InitializeModalityProcedureStepCompletedDiscontinued() { // Get the C-STORE-RSPs returned foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog) { if (actorsTransaction.FromActorName.Type == ActorTypeEnum.ImageArchive) { BaseTransaction baseTransaction = actorsTransaction.Transaction; if (baseTransaction is DicomTransaction) { DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction; DicomMessageCollection cStoreResponses = dicomTransaction.DicomMessages.CStoreResponses; GenerateTriggers.HandleCStoreResponses(_storageCommitItems, cStoreResponses); } } } }
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); }
/// <summary> /// Handle a Dicom Transaction from the given Actor Name. /// </summary> /// <param name="actorName">Source Actor Name.</param> /// <param name="dicomTransaction">Dicom Transaction.</param> protected override void HandleTransactionFrom(ActorName actorName, DicomTransaction dicomTransaction) { switch (actorName.Type) { case ActorTypeEnum.ImageManager: // received Storage Commitment [RAD-10] DicomMessageCollection nEventReportRequests = dicomTransaction.DicomMessages.NEventReportRequests; foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in nEventReportRequests) { // Update the storage commit items with the appropriate status - as received in the // event report request GenerateTriggers.HandleNEventReportStorageCommitment(_storageCommitItems, dicomMessage); } break; default: break; } }
/// <summary> /// Query the Information Model using the given query message. /// </summary> /// <param name="queryMessage">Message used to query the Information Model.</param> /// <returns>DicomMessageCollection - containing the query responses. The final query response (without a dataset) is also included.</returns> public DicomMessageCollection QueryInformationModel(DicomMessage queryMessage) { DicomMessageCollection responseMessages = new DicomMessageCollection(); DvtkHighLevelInterface.Dicom.Other.Values values = queryMessage.CommandSet["0x00000002"].Values; System.String sopClassUid = values[0]; DataSet queryDataset = queryMessage.DataSet; Dvtk.Dicom.InformationEntity.DataSetCollection queryResponses = _root.QueryInformationModel(queryDataset.DvtkDataDataSet); DvtkData.Dimse.DicomMessage dvtkDicomMessage = null; DvtkData.Dimse.CommandSet dvtkCommand = null; DicomMessage responseMessage = null; if (queryResponses != null) { foreach (DvtkData.Dimse.DataSet dvtkDataset in queryResponses) { dvtkDicomMessage = new DvtkData.Dimse.DicomMessage(); dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP); dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid); dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0xFF00); dvtkDicomMessage.Apply(dvtkCommand, dvtkDataset, queryMessage.EncodedPresentationContextID); responseMessage = new DicomMessage(dvtkDicomMessage); responseMessages.Add(responseMessage); } } dvtkDicomMessage = new DvtkData.Dimse.DicomMessage(); dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP); dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid); dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0x0000); dvtkDicomMessage.Apply(dvtkCommand, queryMessage.EncodedPresentationContextID); responseMessage = new DicomMessage(dvtkDicomMessage); responseMessages.Add(responseMessage); return(responseMessages); }
public void DataSetCollectionEvaluate_2_2() { // // SetUp the test data for this test case. // DicomMessageCollection dicomMessageCollection1 = new DicomMessageCollection(); DicomMessageCollection dicomMessageCollection2 = new DicomMessageCollection(); DicomMessage dicomMessage1 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage1.DataSet.Set("0x00200020", VR.UI, "1.1.1.1"); dicomMessageCollection1.Add(dicomMessage1); DicomMessage dicomMessage2 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage2.DataSet.Set("0x00300030", VR.UI, "1.1.1.1"); dicomMessage2.DataSet.Set("0x00400040", VR.LT, "dicomMessage2"); dicomMessageCollection2.Add(dicomMessage2); DicomMessage dicomMessage3 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage3.DataSet.Set("0x00300030", VR.UI, "2.2.2.2"); dicomMessage3.DataSet.Set("0x00400040", VR.LT, "dicomMessage3"); dicomMessageCollection2.Add(dicomMessage3); DicomMessage dicomMessage4 = new DicomMessage(DimseCommand.CSTORERQ); dicomMessage4.DataSet.Set("0x00300030", VR.UI, "3.3.3.3"); dicomMessage4.DataSet.Set("0x00400040", VR.LT, "dicomMessage4"); dicomMessageCollection2.Add(dicomMessage4); // // Perform the actual test. // GenericCollection <GenericPair <DataSet, DataSet> > collection = BooleanExpressionTwoDataSets.MapsAttributes("0x00200020", "0x00300030").Evaluate(dicomMessageCollection1.DataSets, dicomMessageCollection2.DataSets); Assert.That(collection[0].Element2["0x00400040"].Values[0], Is.EqualTo("dicomMessage2")); }
/// <summary> /// Query the Information Model using the given query message. /// </summary> /// <param name="queryMessage">Message used to query the Information Model.</param> /// <returns>DicomMessageCollection - containing the query responses. The final query response (without a dataset) is also included.</returns> public DicomMessageCollection QueryInformationModel(DicomMessage queryMessage) { DicomMessageCollection responseMessages = new DicomMessageCollection(); DvtkHighLevelInterface.Values values = queryMessage.CommandSet.GetAttributeValues("0x00000002"); System.String sopClassUid = values.GetString(1); DataSet queryDataset = queryMessage.DataSet; DataSetCollection queryResponses = _root.QueryInformationModel(queryDataset.DvtkDataDataSet); DvtkData.Dimse.DicomMessage dvtkDicomMessage = null; DvtkData.Dimse.CommandSet dvtkCommand = null; DicomMessage responseMessage = null; foreach (DvtkData.Dimse.DataSet dvtkDataset in queryResponses) { dvtkDicomMessage = new DvtkData.Dimse.DicomMessage(); dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP); dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid); dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0xFF00); dvtkDicomMessage.Apply(dvtkCommand, dvtkDataset); responseMessage = new DicomMessage(dvtkDicomMessage); responseMessages.Add(responseMessage); } dvtkDicomMessage = new DvtkData.Dimse.DicomMessage(); dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP); dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid); dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0x0000); dvtkDicomMessage.Apply(dvtkCommand); responseMessage = new DicomMessage(dvtkDicomMessage); responseMessages.Add(responseMessage); return(responseMessages); }
public void Ticket788_32_1() { DicomFile dicomFile = null; QueryRetrievePatientRootInformationModel queryRetrievePatientRootInformationModel = new QueryRetrievePatientRootInformationModel(); dicomFile = new DicomFile(); dicomFile.DataSet.Set("0x00100020", VR.LO, "1"); dicomFile.DataSet.Set("0x0020000D", VR.UI, "1.1"); dicomFile.DataSet.Set("0x0020000E", VR.UI, "1.1.1"); dicomFile.DataSet.Set("0x00080060", VR.CS, "OT"); // # Modality dicomFile.DataSet.Set("0x00080018", VR.UI, "1.1.1.1"); queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile); dicomFile = new DicomFile(); dicomFile.DataSet.Set("0x00100020", VR.LO, "2"); dicomFile.DataSet.Set("0x0020000D", VR.UI, "2.1"); dicomFile.DataSet.Set("0x0020000E", VR.UI, "2.1.1"); dicomFile.DataSet.Set("0x00080060", VR.CS, "XA"); // # Modality dicomFile.DataSet.Set("0x00080018", VR.UI, "2.1.1.1"); queryRetrievePatientRootInformationModel.AddToInformationModel(dicomFile); DicomMessage cFindRequest = new DicomMessage(DimseCommand.CFINDRQ); cFindRequest.CommandSet.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.1"); // Set Affected SOP class to Patient Root Query/Retrieve Information Model – FIND cFindRequest.DataSet.Set("0x00080052", VR.CS, "SERIES"); // Query Retrieve Level. cFindRequest.DataSet.Set("0x00100020", VR.LO, "1"); cFindRequest.DataSet.Set("0x0020000D", VR.UI, "1.1"); cFindRequest.DataSet.Set("0x0020000E", VR.UI); cFindRequest.DataSet.Set("0x00080060", VR.CS, "ECG"); DicomMessageCollection responses = queryRetrievePatientRootInformationModel.QueryInformationModel(cFindRequest); // Expect one message with status success. Assert.That(responses.Count, Is.EqualTo(1)); }
public void Trigger(DicomMessageCollection dicomMessageCollection, params PresentationContext[] presentationContexts) { DicomMessageCollectionPresentationContexts trigger = new DicomMessageCollectionPresentationContexts(dicomMessageCollection, presentationContexts); base.Trigger(trigger); }
/// <summary> /// Trigger the Client. /// </summary> /// <param name="actorName">Destination Actor Name.</param> /// <param name="trigger">Trigger message.</param> /// <param name="awaitCompletion">Boolean indicating whether this a synchronous call or not.</param> /// <returns>Boolean indicating success or failure.</returns> public bool TriggerClient(ActorName actorName, BaseTrigger trigger, bool awaitCompletion) { DicomTrigger dicomTrigger = (DicomTrigger)trigger; _scu.SignalCompletion = awaitCompletion; // determine how the handle the trigger - in a single association or not if (dicomTrigger.HandleInSingleAssociation == true) { // set the dicom messages to send DicomMessageCollection dicomMessageCollection = new DicomMessageCollection(); foreach (DicomTriggerItem dicomTriggerItem in dicomTrigger.TriggerItems) { dicomMessageCollection.Add(dicomTriggerItem.Message); } // set the presentation contexts for the association PresentationContext[] presentationContexts = SetPresentationContexts(dicomTrigger); // send in single association _scu.TriggerSendAssociation(dicomMessageCollection, presentationContexts); // Check if this is a synchronous call or not // - timeout of 0 means "no timeout". if (awaitCompletion == true) { _semaphore.Wait(0); } } else { // send the triggers in separate associations foreach (DicomTriggerItem dicomTriggerItem in dicomTrigger.TriggerItems) { // check if the sop class uid and transfer syntax are being explicitly defined if ((dicomTriggerItem.SopClassUid != System.String.Empty) && (dicomTriggerItem.TransferSyntaxes.Length != 0)) { // use the given presentation context PresentationContext[] presentationContexts = new PresentationContext[1]; presentationContexts[0] = new PresentationContext(dicomTriggerItem.SopClassUid, MergeTransferSyntaxes(dicomTriggerItem.TransferSyntaxes)); _scu.TriggerSendAssociation(dicomTriggerItem.Message, presentationContexts); } else { // use the initial presentation context _scu.TriggerSendAssociation(dicomTriggerItem.Message, _presentationContexts); } // Check if this is a synchronous call or not // - timeout of 0 means "no timeout". if (awaitCompletion == true) { _semaphore.Wait(0); } } } // return a boolean indicating if the trigger was processed successfully or not return(_scu.ProcessTriggerResult); }
private bool HandleSubOperation(System.String moveDestinationAE, System.String dcmFilename, int subOperationIndex) { SCU storageScu = new SCU(); storageScu.Initialize(DicomThread.ThreadManager); storageScu.Options.DeepCopyFrom(DicomThread.Options); storageScu.Options.Identifier = "StorageSubOperationAsScu"; ////Check for Secure connection //if (DicomThread.Options.SecureConnection) //{ // storageScu.Options.SecureConnection = true; // storageScu.Options.CertificateFilename = DicomThread.Options.CertificateFilename; // storageScu.Options.CredentialsFilename = DicomThread.Options.CredentialsFilename; //} storageScu.Options.ResultsFileNameOnlyWithoutExtension = "StorageSubOperationAsScu" + subOperationIndex.ToString(); storageScu.Options.ResultsDirectory = DicomThread.Options.ResultsDirectory; storageScu.Options.LocalAeTitle = DicomThread.Options.LocalAeTitle; storageScu.Options.LocalPort = DicomThread.Options.LocalPort; if (IsHaveMoveDestinations) { storageScu.Options.RemoteAeTitle = moveDestinationAE; storageScu.Options.RemotePort = MoveDestiantions[MoveAEdetailsIndex].Port; storageScu.Options.RemoteHostName = MoveDestiantions[MoveAEdetailsIndex].IP; } else { storageScu.Options.RemoteAeTitle = moveDestinationAE; storageScu.Options.RemotePort = DicomThread.Options.RemotePort; storageScu.Options.RemoteHostName = DicomThread.Options.RemoteHostName; } storageScu.Options.DataDirectory = DicomThread.Options.DataDirectory; storageScu.Options.StorageMode = Dvtk.Sessions.StorageMode.AsDataSet; // Read the DCM File DicomFile dcmFile = new DicomFile(); dcmFile.Read(dcmFilename, storageScu); FileMetaInformation fMI = dcmFile.FileMetaInformation; // Get the transfer syntax and SOP class UID System.String transferSyntax = "1.2.840.10008.1.2"; if ((fMI != null) && fMI.Exists("0x00020010")) { // Get the Transfer syntax DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = fMI["0x00020010"]; transferSyntax = tranferSyntaxAttr.Values[0]; } Values values = dcmFile.DataSet["0x00080016"].Values; System.String sopClassUid = values[0]; PresentationContext presentationContext = new PresentationContext(sopClassUid, // Abstract Syntax Name transferSyntax); // Transfer Syntax Name(s) PresentationContext[] presentationContexts = new PresentationContext[1]; presentationContexts[0] = presentationContext; DicomMessage storageMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ); storageMessage.DataSet.CloneFrom(dcmFile.DataSet); storageScu.Start(); bool sendResult = storageScu.TriggerSendAssociationAndWait(storageMessage, presentationContexts); if (!sendResult) { WriteWarning("Association to move destination for Storage Sub-Operation is rejected."); } if (storageScu.HasExceptionOccured) { WriteError("Storage Sub-Operation As SCU Failed"); } storageScu.Stop(); DicomMessageCollection cStoreResponses = storageScu.Messages.DicomMessages.CStoreResponses; // Obtain the value of the C-STORE RSP.The value of this variable is used to determine the attributes of the C-MOVE RSP. foreach (DicomMessage cStoreRsp in cStoreResponses) { cStoreStatusVal = Int32.Parse(cStoreRsp.CommandSet.GetValues("0x00000900")[0]); } // Transform the sub results Xslt.StyleSheetFullFileName = DicomThread.Options.StyleSheetFullFileName; System.String htmlResultsFilename = Xslt.Transform(storageScu.Options.ResultsDirectory, storageScu.Options.ResultsFileNameOnly); // Make link to the sub-operation results file System.String message = System.String.Format("<a href=\"{0}\">Storage sub-operation {1} to AE Title \"{2}\"</a><br/>", htmlResultsFilename, subOperationIndex, moveDestinationAE); DicomThread.WriteHtmlInformation(message); return(sendResult); }
/// <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); }
/// <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); }
public SendAssociationTrigger(DicomMessageCollection dicomMessageCollection, PresentationContext[] presentationContexts) { this.dicomMessageCollection = dicomMessageCollection; this.presentationContexts = presentationContexts; this.returnValue = true; }
/// <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); }
/// <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> /// 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) { // Query response messages DicomMessageCollection responseMessages = new DicomMessageCollection(); DvtkHighLevelInterface.Dicom.Other.Values values = queryMessage.CommandSet["0x00000002"].Values; System.String sopClassUid = values[0]; DicomMessage responseMessage = null; foreach (DataSet randomDataset in randomizedDatasets) { responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP); responseMessage.CommandSet.Set("0x00000002", DvtkData.Dimse.VR.UI, sopClassUid); responseMessage.CommandSet.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFF00); responseMessage.DataSet.CloneFrom(randomDataset); responseMessages.Add(responseMessage); } responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP); responseMessage.CommandSet.Set("0x00000002", DvtkData.Dimse.VR.UI, sopClassUid); responseMessage.CommandSet.Set("0x00000900", DvtkData.Dimse.VR.US, 0x0000); responseMessages.Add(responseMessage); // handle responses foreach (DicomMessage rspMessage in responseMessages) { try { 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(rspMessage); } catch (Exception) { string theErrorText = "DICOM Connection Error: RIS Emulator is failed to send the C-FIND-RSP."; WriteError(theErrorText); } } // message handled return(true); }
public DicomMessageCollectionPresentationContexts(DicomMessageCollection dicomMessageCollection, params PresentationContext[] presentationContexts) { this.dicomMessageCollection = dicomMessageCollection; this.presentationContexts = new ArrayList(presentationContexts); }