private void SendCMoveRq() { DIMSE.DicomMessage cMoveRq = PrepareCMoveCommand(); Send(cMoveRq); while (true) { DIMSE.DicomMessage cMoveResponse = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(cMoveResponse.CommandSet.GetValues("0x00000900")[0]); if ((statusVal == 0xff00) || (statusVal == 0xff01)) { continue; } else if (statusVal == 0x0000) { remainingSubOperations = UInt16.Parse(cMoveResponse.CommandSet.GetValues("0x00001020")[0]); completeSubOperations = UInt16.Parse(cMoveResponse.CommandSet.GetValues("0x00001021")[0]); failedSubOperations = UInt16.Parse(cMoveResponse.CommandSet.GetValues("0x00001022")[0]); warningSubOperations = UInt16.Parse(cMoveResponse.CommandSet.GetValues("0x00001023")[0]); break; } else { break; } } }
/// <summary> /// Class constructor. /// </summary> /// <param name="message">DICOM Message to be triggered.</param> /// <param name="sopClassUid">SOP Class UID of DICOM Message.</param> /// <param name="transferSyntaxes">Transfer Syntaxes of DICOM Message</param> public DicomTriggerItem(DicomMessage message, System.String sopClassUid, System.String[] transferSyntaxes) { _message = message; _sopClassUid = sopClassUid; _transferSyntaxes = new System.String[transferSyntaxes.Length]; _transferSyntaxes = transferSyntaxes; }
/// <summary> /// Overridden N-ACTION-RQ message handler. Return an N-EVENT-REPORT-RQ /// after the N-ACTION-RSP. /// </summary> /// <param name="dicomMessage">N-ACTION-RQ and Dataset.</param> /// <returns>Boolean - true if dicomMessage handled here.</returns> public override bool HandleNActionRequest(DicomMessage dicomMessage) { // Validate the received message // System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage); // DicomThread.Validate(dicomMessage, iodName); // set up the default N-ACTION-RSP with a successful status DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NACTIONRSP); responseMessage.Set("0x00000900", VR.US, 0); // send the response this.Send(responseMessage); // delay before generating the N-EVENT-REPORT-RQ System.Threading.Thread.Sleep(_eventDelay); // create the N-EVENT-REPORT-RQ based in the contents of the N-ACTION-RQ DicomMessage requestMessage = GenerateTriggers.MakeStorageCommitEvent(_informationModels, dicomMessage); // send the request this.Send(requestMessage); // message handled return true; }
/// <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); }
private void DoSeriesLevelQuery(string patientId, string studyInstUid) { recdSeriesList = new ArrayList(); try { PrepareRequest("SERIES", patientId, studyInstUid, null); if (!string.IsNullOrEmpty(modality)) { requestMsg.DataSet.Set("0x00080060", VR.CS, modality); } Send(requestMsg); while (true) { DvtkHighLevelInterface.Dicom.Messages.DicomMessage response = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(response.CommandSet.GetValues("0x00000900")[0]); if ((statusVal == 0xff00) || (statusVal == 0xff01)) { Series newSeriesInfo = CreateNewSeriesInfo(response.DataSet); recdSeriesList.Add(newSeriesInfo); continue; } else { break; } } if (selectedQueryRootSop == patientRootQRFindSOP) { AddSeriesInfo(patientId, studyInstUid, recdSeriesList); } else { AddStudyRootSeriesInfo(studyInstUid, recdSeriesList); } for (int i = 0; i < recdSeriesList.Count; i++) { string seriesInstUid = ((Series)recdSeriesList[i]).SeriesUID; if ((this.ThreadState != ThreadState.Stopping) && (this.ThreadState != ThreadState.Stopped)) { DoImageLevelQuery(patientId, studyInstUid, seriesInstUid); } } } catch { return; } }
/// <summary> /// Send an N-SET MPPS COMPLETED message. Take the default values from the Default Value Manager. /// </summary> /// <returns>Boolean indicating success or failure.</returns> public bool SendNSetModalityProcedureStepCompleted() { // Initialize the mpps completed InitializeModalityProcedureStepCompletedDiscontinued(); // Generate the mpps completed from the Default Value Manager DvtkHighLevelInterface.Dicom.Messages.DicomMessage nSetMppsCompleted = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NSETRQ); GenerateTriggers.MakeNSetMppsCompletedDiscontinued(DefaultValueManager, _storageCommitItems, nSetMppsCompleted, _mppsInstanceUid, "COMPLETED"); return(TriggerModalityProcedureStepCompletedDiscontinued(nSetMppsCompleted)); }
public static DicomMessage CreateValidCEchoRq() { DicomMessage dicomMessage = new DicomMessage(DimseCommand.CECHORQ); dicomMessage.CommandSet.Set("0x00000000", VR.UL, 10); // "Group length", set to incorrect value. dicomMessage.CommandSet.Set("0x00000002", VR.UI, "1.2.840.10008.1.1"); // "Affected SOP Class UID" dicomMessage.CommandSet.Set("0x00000110", VR.US, 100); // "Message ID" dicomMessage.CommandSet.Set("0x00000800", VR.US, 0x101); // "Data Set Type" return (dicomMessage); }
/// <summary> /// Send an N-SET MPPS DISCONTINUED message. Take the default values from the given DCM file contents. /// </summary> /// <param name="mppsDiscontinuedDcmFilename">DCM file for default MPPS Discontinued atribute values.</param> /// <returns>Boolean indicating success or failure.</returns> public bool SendNSetModalityProcedureStepDiscontinued(System.String mppsDiscontinuedDcmFilename) { // Initialize the mpps discontinued InitializeModalityProcedureStepCompletedDiscontinued(); // Generate the mpps discontinued from the DCM file content DvtkHighLevelInterface.Dicom.Messages.DicomMessage nSetMppsDiscontinued = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NSETRQ); GenerateTriggers.MakeNSetMppsCompletedDiscontinued(mppsDiscontinuedDcmFilename, DefaultValueManager, _storageCommitItems, nSetMppsDiscontinued, _mppsInstanceUid); return(TriggerModalityProcedureStepCompletedDiscontinued(nSetMppsDiscontinued)); }
private bool TriggerModalityProcedureStepCompletedDiscontinued(DvtkHighLevelInterface.Dicom.Messages.DicomMessage nSetMppsCompletedDiscontinued) { // Trigger the N-SET-RQ MPPS Completed/Discontinued DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_7); trigger.AddItem(nSetMppsCompletedDiscontinued, "1.2.840.10008.3.1.2.3.3", "1.2.840.10008.1.2"); // RAD-7 - trigger the PerformedProcedureStepManager return(TriggerActorInstances(ActorTypeEnum.PerformedProcedureStepManager, trigger, true)); }
/// <summary> /// Initializes the encapsulated Dvtk.Comparator.DicomComparator class with the supplied DICOM message. /// </summary> /// <param name="dicomMessage">The DICOM message.</param> /// <returns>The encapsulated Dvtk.Comparator.DicomComparator instance.</returns> public DicomComparator InitializeDicomComparator(DicomMessage dicomMessage) { _hl7Comparator = null; bool initialized = _dicomComparator.Initialize(dicomMessage.DvtkDataDicomMessage); if (initialized == false) { _dicomComparator = null; } return _dicomComparator; }
/// <summary> /// Constructor with initialization. Shallow copy. /// </summary> /// <param name="arrayOfValues">values to copy.</param> public DicomMessageCollection(DicomMessage[] arrayOfValues) { if (arrayOfValues == null) { throw new ArgumentNullException(); } foreach (DicomMessage value in arrayOfValues) { this.Add(value); } }
/// <summary> /// Trigger a send association and wait until it has been completed. /// </summary> /// <param name="dicomMessage">The DICOM message 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(DicomMessage dicomMessage, params PresentationContext[] presentationContexts) { DicomMessageCollection dicomMessageCollection = new DicomMessageCollection(); dicomMessageCollection.Add(dicomMessage); SendAssociationTrigger sendAssociationTrigger = new SendAssociationTrigger(dicomMessageCollection, presentationContexts); Trigger(sendAssociationTrigger); WaitForLastTriggerCallProcessed(); return(sendAssociationTrigger.returnValue); }
/// <summary> /// Send a single image generated from the Default Value Manager and /// the given Modality Worklist Item. /// </summary> /// <param name="startNewSeries">Boolean indicating if this image is part of a new /// Series or not.</param> /// <param name="modalityWorklistItem">Worklist Item used to provide overruling values for /// the Image header.</param> /// <returns>Boolean indicating success or failure.</returns> public bool SendModalityImagesStored(bool startNewSeries, DicomQueryItem modalityWorklistItem) { if (modalityWorklistItem == null) { return(false); } // Update the default SeriesEntity values for the next Storage Message if (startNewSeries == true) { DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.SeriesEntity); } // Use modality Worklist Item to help construct the Storage Message // Get the attribute values to copy DvtkHighLevelInterface.Comparator.Comparator worklistItemComparator = new DvtkHighLevelInterface.Comparator.Comparator("WorklistItemComparator"); DicomComparator dicomWorklistItemComparator = worklistItemComparator.InitializeDicomComparator(modalityWorklistItem.DicomMessage); // Also try to use the MPPS InProgress Message to help construct the Storage Message DvtkHighLevelInterface.Comparator.Comparator mppsInProgressComparator = new DvtkHighLevelInterface.Comparator.Comparator("MppsInProgressComparator"); DicomComparator dicomMppsInProgressComparator = null; if (_nCreateSetMppsInProgress != null) { dicomMppsInProgressComparator = mppsInProgressComparator.InitializeDicomComparator(_nCreateSetMppsInProgress); } // Create the Storage message DvtkHighLevelInterface.Comparator.Comparator storageComparator = new DvtkHighLevelInterface.Comparator.Comparator("StorageComparator"); DvtkHighLevelInterface.Dicom.Messages.DicomMessage cStoreInstance = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ); GenerateTriggers.MakeCStoreInstance(DefaultValueManager, cStoreInstance); storageComparator.PopulateDicomMessage(cStoreInstance, dicomWorklistItemComparator); if (dicomMppsInProgressComparator != null) { storageComparator.PopulateDicomMessage(cStoreInstance, dicomMppsInProgressComparator); } // Trigger the C-STORE-RQ Instance DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_8); trigger.HandleInSingleAssociation = true; trigger.AddItem(cStoreInstance, "1.2.840.10008.5.1.4.1.1.7", "1.2.840.10008.1.2"); // Update the default InstanceEntity values for the next Storage Message DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.InstanceEntity); // RAD-8 - trigger the ImageArchive return(TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true)); }
private void InitializeModalityProcedureStepInProgress(DvtkData.Dimse.DimseCommand command) { // Generate a new MPPS Instance UID InBuiltDefaultTagValues inbuiltDefaultTagValues = new InBuiltDefaultTagValues(); System.String uidRoot = inbuiltDefaultTagValues.UidRoot; DicomTagValueAutoSetUid tagValueUid = new DicomTagValueAutoSetUid(AffectedEntityEnum.PerformedProcedureStepEntity, Tag.AFFECTED_SOP_INSTANCE_UID, uidRoot, 1); _mppsInstanceUid = tagValueUid.Value; // Create the MPPS In-Progress message _nCreateSetMppsInProgress = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(command); }
public static DicomMessage CreateValidPatientRootQueryRetrieveCFindRq() { DicomMessage dicomMessage = new DicomMessage(DimseCommand.CFINDRQ); dicomMessage.CommandSet.Set("0x00000000", VR.UL, 10); // "Group length", set to incorrect value. dicomMessage.CommandSet.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.1"); // "Affected SOP Class UID" dicomMessage.CommandSet.Set("0x00000110", VR.US, 100); // "Message ID" dicomMessage.CommandSet.Set("0x00000700", VR.US, 0); // "Priority" dicomMessage.CommandSet.Set("0x00000800", VR.US, 0); // "Data Set Type" dicomMessage.DataSet.Set("0x00080052", VR.CS, "PATIENT"); // "Query Retrieve Level" dicomMessage.DataSet.Set("0x00100020", VR.LO); // "Patient ID." return (dicomMessage); }
public override bool HandleCGetRequest(DicomMessage dicomMessage) { // Validate the received message //System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage); //DicomThread.Validate(dicomMessage, iodName); // Storage suboperations should be sent over the same association as the CGET. // The CGET SCU becomes a Storage SCP for the duration of the storage suboperations. // The CGET SCU should ensure that all the necessary storage SOP Classes are negotiated // during association establishment. DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CGETRSP); this.Send(responseMessage); return true; }
/// <summary> /// Overridden N-ACTION-RQ message handler. /// </summary> /// <param name="dicomMessage">N-ACTION-RQ and Dataset.</param> /// <returns>Boolean - true if dicomMessage handled here.</returns> public override bool HandleNActionRequest(DicomMessage dicomMessage) { // Validate the received message // System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage); // DicomThread.Validate(dicomMessage, iodName); // set up the default N-ACTION-RSP with a successful status DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NACTIONRSP); responseMessage.Set("0x00000900", VR.US, 0); // send the response this.Send(responseMessage); // message handled return true; }
public override bool HandleNSetRequest(DicomMessage dicomMessage) { // Try to get the IOD Name System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage); System.String messsage = String.Format("Processed N-SET-RQ {0}", iodName); WriteInformation(messsage); DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NSETRSP); responseMessage.Set("0x00000900", VR.US, 0); this.Send(responseMessage); return 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); // 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; }
/// <summary> /// Send the Storage Commitment message - use the storage commitment details /// built up during any previous SendModalityImagesStored() operations. /// The N-ACTION-RQ will be sent to the Image Manager. /// /// If the configured ActorOption1 for the DicomPeerToPeerConfiguration from the /// AcquisitionModalityActor to the ImageManagerActor is set to the string /// "DO_STORAGE_COMMITMENT_ON_SINGLE_ASSOCIATION" then the framework expects the /// Image Manager to return the N-EVENT-REPORT details over the same association /// as the N-ACTION details were sent. If the ActorOption1 configuration parameter /// is not set as above then the framework will expect the Image Manger to return /// the N-EVENT-REPORT details over a different association than the one used for the /// N-ACTION details. /// </summary> /// <param name="awaitNEventReport">Boolean indicating whether to wait for the /// N-EVENT-REPORT - either over the same or different association before returning /// to the caller.</param> /// <param name="timeOut">Time (in Seconds) to wait for the N-EVENT-REPORT to be sent /// from the Image Manager - only used if "awaitNEventReport" is set true.</param> /// <returns>Boolean indicating success or failure.</returns> public bool SendStorageCommitment(bool awaitNEventReport, int timeOut) { // Check if we need to wait for the Event Report if (awaitNEventReport == true) { // Subscribe to the event SubscribeStorageCommitmentNEventReportResponseEvent(); } // Generate a new Storage Commitment Transaction UID InBuiltDefaultTagValues inbuiltDefaultTagValues = new InBuiltDefaultTagValues(); System.String uidRoot = inbuiltDefaultTagValues.UidRoot; DicomTagValueAutoSetUid tagValueUid = new DicomTagValueAutoSetUid(AffectedEntityEnum.AnyEntity, Tag.TRANSACTION_UID, uidRoot, 1); _storageCommitTransactionUid = tagValueUid.Value; DvtkHighLevelInterface.Dicom.Messages.DicomMessage nActionStorageCommitment = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NACTIONRQ); GenerateTriggers.MakeNActionStorageCommitment(_storageCommitItems, nActionStorageCommitment, _storageCommitTransactionUid, _mppsInstanceUid); // Trigger the N-ACTION-RQ Storage Commitment DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_10); trigger.AddItem(nActionStorageCommitment, "1.2.840.10008.1.20.1", "1.2.840.10008.1.2"); // RAD-10 - trigger the ImageManager bool result = TriggerActorInstances(ActorTypeEnum.ImageManager, trigger, true); if (result == true) { // Check if we need to wait for the Event Report if (awaitNEventReport == true) { // Wait for the N-Event-Report response // for the given timeout result = WaitStorageCommitmentNEventReportResponse(timeOut); // Unsubscribe to the event UnsubscribeStorageCommitmentNEventReportResponseEvent(); } } return(result); }
public override bool HandleNCreateRequest(DicomMessage dicomMessage) { // Try to get the IOD Name System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage); // Try to get the Patient Name DvtkHighLevelInterface.Dicom.Other.Values attributeValues = dicomMessage["0x00100010"].Values; System.String patientName = attributeValues[0]; System.String messsage = String.Format("Processed N-CREATE-RQ {0}: \"{1}\"", iodName, patientName); WriteInformation(messsage); DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NCREATERSP); responseMessage.Set("0x00000900", VR.US, 0); this.Send(responseMessage); return true; }
/// <summary> /// Only intereseted in Storage Commitment N-Event-Report Response messages. /// Signal the local N-Event-Report Response semaphore on receipt of this message type. /// </summary> /// <param name="server">Event source.</param> /// <param name="messageAvailableEvent">Message Available Event Details.</param> private void HandleStorageCommitmentNEventReportResponse(object server, MessageAvailableEventArgs messageAvailableEvent) { if (messageAvailableEvent.Message.Message is DicomProtocolMessage) { DicomProtocolMessage dicomProtocolMessage = (DicomProtocolMessage)messageAvailableEvent.Message.Message; if (dicomProtocolMessage is DvtkHighLevelInterface.Dicom.Messages.DicomMessage) { DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage = (DvtkHighLevelInterface.Dicom.Messages.DicomMessage)dicomProtocolMessage; if (dicomMessage.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.NEVENTREPORTRSP) { if (_storageCommitmentNEventReportResponseSemaphore != null) { _storageCommitmentNEventReportResponseSemaphore.Signal(); } } } } }
private void DoImageLevelQuery(string patientId, string studyInstUid, string seriesInstUid) { recdImageList = new ArrayList(); try { PrepareRequest("IMAGE", patientId, studyInstUid, seriesInstUid); Send(requestMsg); while (true) { DvtkHighLevelInterface.Dicom.Messages.DicomMessage response = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(response.CommandSet.GetValues("0x00000900")[0]); if ((statusVal == 0xff00) || (statusVal == 0xff01)) { Image newImageInfo = CreateNewImageInfo(response.DataSet); recdImageList.Add(newImageInfo); continue; } else { break; } } } catch { return; } if (selectedQueryRootSop == patientRootQRFindSOP) { AddImageInfo(patientId, studyInstUid, seriesInstUid, recdImageList); } else { AddStudyRootImageInfo(studyInstUid, seriesInstUid, recdImageList); } }
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); }
private void DoPatientLevelQuery() { try { PrepareRequest("PATIENT", patientId, null, null); //set patient level keys requestMsg.DataSet.Set("0x00100030", VR.DA, ""); Send(requestMsg); while (true) { DvtkHighLevelInterface.Dicom.Messages.DicomMessage response = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(response.CommandSet.GetValues("0x00000900")[0]); if ((statusVal == 0xff00) || (statusVal == 0xff01)) { Patient newPatientInfo = CreateNewPatientInfo(response.DataSet); recdPatientList.Add(newPatientInfo); continue; } else { break; } } for (int i = 0; i < recdPatientList.Count; i++) { string patId = ((Patient)recdPatientList[i]).PatientId; if ((this.ThreadState != ThreadState.Stopping) && (this.ThreadState != ThreadState.Stopped)) { DoStudyLevelQuery(patId); } } } catch { return; } }
private DIMSE.DicomMessage PrepareCMoveCommand() { DIMSE.DicomMessage cMoveRq = new DIMSE.DicomMessage(DimseCommand.CMOVERQ); if (queryRoot == patientRootQRMoveSOP) { cMoveRq.CommandSet.Set("0x00000002", VR.UI, patientRootQRMoveSOP); } else if (queryRoot == studyRootQRMoveSOP) { cMoveRq.CommandSet.Set("0x00000002", VR.UI, studyRootQRMoveSOP); } cMoveRq.CommandSet.Set("0x00000800", VR.US, 0); cMoveRq.CommandSet.Set("0x00000600", VR.AE, moveDestination); cMoveRq.DataSet.Set("0x00080052", VR.CS, queryLevel); if (!string.IsNullOrEmpty(patientId)) { cMoveRq.DataSet.Set("0x00100020", VR.LO, patientId); } if (!string.IsNullOrEmpty(studyInstanceUID)) { cMoveRq.DataSet.Set("0x0020000D", VR.UI, studyInstanceUID); } if (!string.IsNullOrEmpty(seriesUID)) { cMoveRq.DataSet.Set("0x0020000E", VR.UI, seriesUID); } if (!string.IsNullOrEmpty(sopInstanceUID)) { cMoveRq.DataSet.Set("0x00080018", VR.UI, sopInstanceUID); } return(cMoveRq); }
/// <summary> /// Override to implement how to change an outbound DICOM message. /// </summary> /// <param name="dicomMessage">The outbound DICOM message.</param> public abstract void Apply(DicomMessage dicomMessage);
protected override void AfterHandlingNEventReportRequest(DicomMessage dicomMessage) { base.AfterHandlingNEventReportRequest(dicomMessage); IsMessageHandled = true; // set up the default N-EVENT-REPORT-RSP with a successful status DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRSP); responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0); // send the response this.Send(responseMessage); }
public override bool HandleNSetRequest(DicomMessage dicomMessage) { DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NSETRSP); this.Send(responseMessage); return true; }
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); }
private bool ProcessRetrieveList(System.String moveDestinationAE, DvtkData.Collections.StringCollection retrieveList) { UInt16 status = 0x0000; UInt16 remainingSubOperations = (UInt16)retrieveList.Count; UInt16 completeSubOperations = 0; UInt16 failedSubOperations = 0; UInt16 warningSubOperations = 0; int subOperationIndex = 0; bool isCancelRecd = false; foreach (System.String dcmFilename in retrieveList) { status = 0xFF00; SendCMoveRsp(status, remainingSubOperations, completeSubOperations, failedSubOperations, warningSubOperations); if (HandleSubOperation(moveDestinationAE, dcmFilename, subOperationIndex) == true && cStoreStatusVal == 0x0000) { completeSubOperations++; } else if (cStoreStatusVal == 0xB007 || cStoreStatusVal == 0xB000 || cStoreStatusVal == 0xB006) { warningSubOperations += 1; } else { failedSubOperations++; } remainingSubOperations--; subOperationIndex++; 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 responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP); responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0xFE00); // send the response this.Send(responseMessage); isCancelRecd = true; break; } } } if (!isCancelRecd) { if ((failedSubOperations > 0) || (warningSubOperations > 0)) { status = 0xB000; } //else if ((failedSubOperations == 0) && (completeSubOperations==0) && (remainingSubOperations==0) &&(warningSubOperations==0)) //{ // status = 0xA702; //} else { status = 0x0000; } SendCMoveRsp(status, remainingSubOperations, completeSubOperations, failedSubOperations, warningSubOperations); } // message handled return true; }
/// <summary> /// Inserts an item to the IList at the specified position. /// </summary> /// <param name="index">The zero-based index at which <c>value</c> should be inserted. </param> /// <param name="value">The item to insert into the <see cref="System.Collections.IList"/>.</param> public void Insert(int index, DicomMessage value) { base.Insert(index, value); }
// // - Methods - // /// <summary> /// Adds an item to the <see cref="System.Collections.IList"/>. /// </summary> /// <param name="value">The item to add to the <see cref="System.Collections.IList"/>. </param> /// <returns>The position into which the new element was inserted.</returns> public int Add(DicomMessage value) { return(base.Add(value)); }
private void PrepareRequest( string queryLevel, string patientId, string studyInstUid, string seriesInstUid ) { requestMsg = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DimseCommand.CFINDRQ); requestMsg.CommandSet.Set("0x00000002", VR.UI, selectedQueryRootSop); requestMsg.CommandSet.Set("0x00000800", VR.US, 0); requestMsg.DataSet.Set("0x00080052", VR.CS, queryLevel); // Query/Retrieve Level if (queryLevel == "PATIENT") { if (!string.IsNullOrEmpty(patientName)) { requestMsg.DataSet.Set("0x00100010", VR.PN, patientName);// Patient's name. } else { requestMsg.DataSet.Set("0x00100010", VR.PN);// Patient's name. } if (!string.IsNullOrEmpty(patientId)) { requestMsg.DataSet.Set("0x00100020", VR.LO, patientId);//Patient ID. } else { requestMsg.DataSet.Set("0x00100020", VR.LO);//Patient ID. } } if (queryLevel == "STUDY") { if (!string.IsNullOrEmpty(patientId)) { requestMsg.DataSet.Set("0x00100020", VR.LO, patientId);//Patient ID. } else { requestMsg.DataSet.Set("0x00100020", VR.LO);//Patient ID. } if (!string.IsNullOrEmpty(studyInstUid)) { requestMsg.DataSet.Set("0x0020000D", VR.UI, studyInstUid); } else { requestMsg.DataSet.Set("0x0020000D", VR.UI); } } if (queryLevel == "SERIES") { if (!string.IsNullOrEmpty(patientId)) { requestMsg.DataSet.Set("0x00100020", VR.LO, patientId);//Patient ID. } else { requestMsg.DataSet.Set("0x00100020", VR.LO);//Patient ID. } if (!string.IsNullOrEmpty(studyInstUid)) { requestMsg.DataSet.Set("0x0020000D", VR.UI, studyInstUid); } else { requestMsg.DataSet.Set("0x0020000D", VR.UI); } if (!string.IsNullOrEmpty(seriesInstUid)) { requestMsg.DataSet.Set("0x0020000E", VR.UI, seriesInstUid); } else { requestMsg.DataSet.Set("0x0020000E", VR.UI); } } if (queryLevel == "IMAGE") { if (!string.IsNullOrEmpty(patientId)) { requestMsg.DataSet.Set("0x00100020", VR.LO, patientId);//Patient ID. } else { requestMsg.DataSet.Set("0x00100020", VR.LO);//Patient ID. } if (!string.IsNullOrEmpty(studyInstUid)) { requestMsg.DataSet.Set("0x0020000D", VR.UI, studyInstUid); } else { requestMsg.DataSet.Set("0x0020000D", VR.UI); } if (!string.IsNullOrEmpty(seriesInstUid)) { requestMsg.DataSet.Set("0x0020000E", VR.UI, seriesInstUid); } else { requestMsg.DataSet.Set("0x0020000E", VR.UI); } requestMsg.DataSet.Set("0x00080018", VR.UI); } }
private void DoStudyLevelQuery(string patientId) { recdStudyList = new ArrayList(); try { PrepareRequest("STUDY", patientId, null, null); //Set study level keys if (!string.IsNullOrEmpty(accessionNo)) { requestMsg.DataSet.Set("0x00080050", VR.SH, accessionNo); } else { requestMsg.DataSet.Set("0x00080050", VR.SH, ""); } if (!string.IsNullOrEmpty(studyId)) { requestMsg.DataSet.Set("0x00200010", VR.SH, studyId); } else { requestMsg.DataSet.Set("0x00200010", VR.SH, ""); } if (!string.IsNullOrEmpty(studyDate)) { requestMsg.DataSet.Set("0x00080020", VR.DA, studyDate); } Send(requestMsg); while (true) { DvtkHighLevelInterface.Dicom.Messages.DicomMessage response = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(response.CommandSet.GetValues("0x00000900")[0]); if ((statusVal == 0xff00) || (statusVal == 0xff01)) { Study newStudyInfo = CreateNewStudyInfo(response.DataSet); recdStudyList.Add(newStudyInfo); continue; } else { break; } } AddStudyInfo(patientId, recdStudyList); for (int i = 0; i < recdStudyList.Count; i++) { string studyInstUid = ((Study)recdStudyList[i]).StudyInstanceUID; if ((this.ThreadState != ThreadState.Stopping) && (this.ThreadState != ThreadState.Stopped)) { DoSeriesLevelQuery(patientId, studyInstUid); } } } catch { return; } }
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> /// 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)); }
private void SendCMoveRsp(UInt16 status, UInt16 remainingSubOperations, UInt16 completeSubOperations, UInt16 failedSubOperations, UInt16 warningSubOperations) { DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERSP); responseMessage.Set("0x00000900", VR.US, status); responseMessage.Set("0x00001020", VR.US, remainingSubOperations); responseMessage.Set("0x00001021", VR.US, completeSubOperations); responseMessage.Set("0x00001022", VR.US, failedSubOperations); responseMessage.Set("0x00001023", VR.US, warningSubOperations); this.Send(responseMessage); }
private DicomTrigger GenerateTrigger(DicomMessage dicomMessage) { DicomTrigger storageCommitTrigger = new DicomTrigger(TransactionNameEnum.RAD_10); storageCommitTrigger.AddItem(GenerateTriggers.MakeStorageCommitEvent(_informationModels, dicomMessage), "1.2.840.10008.1.20.1", "1.2.840.10008.1.2"); return storageCommitTrigger; }
private DIMSE.DicomMessage PrepareCMoveCommand() { DIMSE.DicomMessage cMoveRq = new DIMSE.DicomMessage(DimseCommand.CMOVERQ); if (queryRoot == patientRootQRMoveSOP) { cMoveRq.CommandSet.Set("0x00000002", VR.UI, patientRootQRMoveSOP); } else if (queryRoot == studyRootQRMoveSOP) { cMoveRq.CommandSet.Set("0x00000002", VR.UI, studyRootQRMoveSOP); } cMoveRq.CommandSet.Set("0x00000800", VR.US, 0); cMoveRq.CommandSet.Set("0x00000600", VR.AE, moveDestination); cMoveRq.DataSet.Set("0x00080052", VR.CS, queryLevel); if (!string.IsNullOrEmpty(patientId)) cMoveRq.DataSet.Set("0x00100020", VR.LO, patientId); if (!string.IsNullOrEmpty(studyInstanceUID)) cMoveRq.DataSet.Set("0x0020000D", VR.UI, studyInstanceUID); if (!string.IsNullOrEmpty(seriesUID)) cMoveRq.DataSet.Set("0x0020000E", VR.UI, seriesUID); if (!string.IsNullOrEmpty(sopInstanceUID)) cMoveRq.DataSet.Set("0x00080018", VR.UI, sopInstanceUID); return cMoveRq; }
protected override void Execute() { PresentationContext presentationContext = new PresentationContext("1.2.840.10008.1.20.1", // Abstract Syntax Name "1.2.840.10008.1.2"); // Transfer Syntax Name(s) PresentationContext[] presentationContexts = new PresentationContext[1]; presentationContexts[0] = presentationContext; SendAssociateRq(presentationContexts); ReceiveAssociateAc(); if (_nActionMessage != null) { WriteInformation("N-Action Request Information"+"\n"+_nActionMessage.DataSet.Dump("")); Send(_nActionMessage); } ReceiveDicomMessage(); if (_Delay < 0) { // Async storage commitment SendReleaseRq(); ReceiveReleaseRp(); // Start the Storage commit SCP for receiving N-EVENTREPORT EmulateStorageCommitSCP(); } else { string info; if (_Delay == 0) { //Wait for 24 hrs(infinite) int waitingTime = 24 * 60 * 60; _Delay = (short)waitingTime; info = "Waiting forever for N-Event-Report."; } else { info = string.Format("Waiting for N-Event-Report for {0} secs", _Delay); } WriteInformation(info); int waitedTime = 0; if (WaitForPendingDataInNetworkInputBuffer(_Delay * 1000, ref waitedTime)) { DicomMessage nEventReportResponse = ReceiveDicomMessage(); if (nEventReportResponse.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ) { // set up the default N-EVENT-REPORT-RSP with a successful status DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRSP); responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0); // send the response this.Send(responseMessage); string msg = "N-Event-Report is received from PACS."; WriteInformation(msg); WriteInformation("N-Event-Report Information\n"+nEventReportResponse.DataSet.Dump("")); SendReleaseRq(); ReceiveReleaseRp(); return; } } else { SendReleaseRq(); ReceiveReleaseRp(); // Start the Storage commit SCP for receiving N-EVENTREPORT EmulateStorageCommitSCP(); } } }
/// <summary> /// Determines whether the <see cref="System.Collections.IList"/> contains a specific item. /// </summary> /// <param name="value">The item to locate in the <see cref="System.Collections.IList"/>.</param> /// <returns><see langword="true"/> if the item is found in the <see cref="System.Collections.IList"/>; otherwise, <see langword="false"/>.</returns> public bool Contains(DicomMessage value) { return base.Contains(value); }
/// <summary> /// Determines the index of a specific item in the <see cref="System.Collections.IList"/>. /// </summary> /// <param name="value">The item to locate in the <see cref="System.Collections.IList"/>.</param> /// <returns>The index of <c>value</c> if found in the list; otherwise, -1.</returns> public int IndexOf(DicomMessage value) { return(base.IndexOf(value)); }
/// <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) { PatientStudyOnlyInformationModel root = (PatientStudyOnlyInformationModel)Root; return root.RetrieveInformationModel(retrieveMessage.DataSet.DvtkDataDataSet); }
/// <summary> /// Determines the index of a specific item in the <see cref="System.Collections.IList"/>. /// </summary> /// <param name="value">The item to locate in the <see cref="System.Collections.IList"/>.</param> /// <returns>The index of <c>value</c> if found in the list; otherwise, -1.</returns> public int IndexOf(DicomMessage value) { return base.IndexOf(value); }
/// <summary> /// Method to handle the workflow after receiving a C-EHO-RQ. /// </summary> /// <param name="dicomMessage">C-ECHO-RQ message.</param> protected override void AfterHandlingCEchoRequest(DicomMessage dicomMessage) { if (IsMessageHandled == false) { DicomMessage dicomMessageToSend = new DicomMessage(DvtkData.Dimse.DimseCommand.CECHORSP); dicomMessageToSend.Set("0x00000002", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.1"); dicomMessageToSend.Set("0x00000900", DvtkData.Dimse.VR.US, 0); Send(dicomMessageToSend); // message has now been handled IsMessageHandled = true; } }
protected override void Execute() { if (_presentationContexts.Length != 0) SendAssociateRq(_presentationContexts); else { WriteError("There is no presentation context available for proposing."); return; } DulMessage dulMsg = ReceiveAssociateRp(); if(dulMsg is AssociateAc) { AssociateAc assocAc = (AssociateAc)dulMsg; foreach(PresentationContext acceptedPC in assocAc.PresentationContexts) { if (acceptedPC.Result == 0) { string msg = string.Format("Accepted Presentation Context: Abstract Syntax - {0}, Transfer Syntax - {1}", acceptedPC.AbstractSyntax, acceptedPC.TransferSyntax); WriteInformation(msg); string sopClassUid = ""; string sopInstUid = ""; string transferSyntax = ""; foreach (DicomFile dcmFile in _dicomFileCollection) { // Get the SOP Class UID Values values = dcmFile.DataSet["0x00080016"].Values; sopClassUid = values[0]; // Get the SOP Instance UID Values sopClassUidvalues = dcmFile.DataSet["0x00080018"].Values; sopInstUid = sopClassUidvalues[0]; Values transferSyntaxes = dcmFile.FileMetaInformation["0x00020010"].Values; transferSyntax = transferSyntaxes[0]; // try for a match if ((acceptedPC.Result == 0) && (acceptedPC.AbstractSyntax == sopClassUid)&&acceptedPC.TransferSyntax==transferSyntax) { DicomMessage storeMsg = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ, dcmFile.DataSet); string message = string.Format("Sending DICOM object with PC ID - {0}", acceptedPC.ID); WriteInformation(message); System.Diagnostics.Debug.WriteLine(storeMsg.DataSet.Dump("set-")); Send(storeMsg,acceptedPC.ID); DicomMessage rspMsg = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(rspMsg.CommandSet.GetValues("0x00000900")[0]); if (statusVal == 0) { string infoMsg = string.Format("Image with SOP Instance UID{0} stored successfully.", sopInstUid); WriteInformation(infoMsg); } else { string warnMsg = string.Format("Non-zero status returned. Image with SOP Instance UID{0} storage failed.", sopInstUid); WriteWarning(warnMsg); } } } } else { string resultStr = convertAccResult(acceptedPC.Result); string message = string.Format("Can't store DICOM object with Rejected Abstract Syntax - {0}, PC ID - {1}, Reason - {2}", acceptedPC.AbstractSyntax, acceptedPC.ID, resultStr); WriteWarning(message); } } SendReleaseRq(); ReceiveReleaseRp(); } else if (dulMsg is AssociateRj) { AssociateRj assocRj = (AssociateRj)dulMsg; string msg = string.Format("Association Rejected for proposed presentation contexts:\nResult - {0}({1})\nSource - {2}({3})\nReason - {4}({5})", assocRj.Result, convertResult(assocRj.Result), assocRj.Source, convertSource(assocRj.Source), assocRj.Reason, convertReason(assocRj.Source,assocRj.Reason)); WriteInformation(msg); } else { WriteInformation("Unknown message is received from SCP."); } }
/// <summary> /// Removes the first occurrence of a specific item from the IList. /// </summary> /// <param name="value">The item to remove from the <see cref="System.Collections.IList"/>.</param> public void Remove(DicomMessage value) { base.Remove(value); }
/// <summary> /// Determines whether the <see cref="System.Collections.IList"/> contains a specific item. /// </summary> /// <param name="value">The item to locate in the <see cref="System.Collections.IList"/>.</param> /// <returns><see langword="true"/> if the item is found in the <see cref="System.Collections.IList"/>; otherwise, <see langword="false"/>.</returns> public bool Contains(DicomMessage value) { return(base.Contains(value)); }