Index: Iod/Iods/ModalityWorklistIod.cs =================================================================== --- Iod/Iods/ModalityWorklistIod.cs (revision 9475) +++ Iod/Iods/ModalityWorklistIod.cs (working copy) @@ -95,6 +95,15 @@ { get { return base.GetModuleIod(); } } + + /// + /// Gets the patient medical module module. + /// + /// The patient medical module. + public PatientMedicalModule PatientMedicalModule + { + get { return base.GetModuleIod(); } + } #endregion #region Public Methods @@ -131,6 +140,7 @@ iod.SetAttributeNull(DicomTags.ReferringPhysiciansName); iod.SetAttributeNull(DicomTags.RequestedProcedureLocation); iod.SetAttributeNull(DicomTags.AccessionNumber); + iod.SetAttributeNull(DicomTags.PatientsSex); ScheduledProcedureStepSequenceIod scheduledProcedureStepSequenceIod = new ScheduledProcedureStepSequenceIod(); scheduledProcedureStepSequenceIod.SetCommonTags(); Index: Iod/Sequences/BasicGrayscaleImageSequenceIod.cs =================================================================== --- Iod/Sequences/BasicGrayscaleImageSequenceIod.cs (revision 9475) +++ Iod/Sequences/BasicGrayscaleImageSequenceIod.cs (working copy) @@ -218,7 +218,7 @@ this.SamplesPerPixel = 1; // only possible value for grayscale as per dicom standard - if (imagePixelMacroIod.PhotometricInterpretation != PhotometricInterpretation.Monochrome1 || imagePixelMacroIod.PhotometricInterpretation != PhotometricInterpretation.Monochrome2) + if (imagePixelMacroIod.PhotometricInterpretation != PhotometricInterpretation.Monochrome1 && imagePixelMacroIod.PhotometricInterpretation != PhotometricInterpretation.Monochrome2) { // Dicom File doesn't have Monochrome1 or MonoChrome2 - what to do? throw exception or pick one? let's try picking one... this.PhotometricInterpretation = PhotometricInterpretation.Monochrome1; @@ -232,7 +232,7 @@ this.Columns = imagePixelMacroIod.Columns; PixelAspectRatio ratio = imagePixelMacroIod.PixelAspectRatio; - if (ratio.IsNull) + if (ratio == null || ratio.IsNull) this.PixelAspectRatio = new PixelAspectRatio(1, 1); //TODO: figure out when to make it 12... possible values are only 8 or 12... Index: Network/NetworkBase.cs =================================================================== --- Network/NetworkBase.cs (revision 9475) +++ Network/NetworkBase.cs (working copy) @@ -61,6 +61,7 @@ using ClearCanvas.Common; using ClearCanvas.Dicom.Codec; using ClearCanvas.Dicom.IO; +using System.Diagnostics; namespace ClearCanvas.Dicom.Network { @@ -1358,6 +1359,9 @@ if (!ret) Platform.Log(LogLevel.Error, "Error with OnReceiveDimse"); + Platform.Log(LogLevel.Debug, "Receive Command: " + (_dimse.Command != null ? _dimse.Command.DumpString : String.Empty)); + Platform.Log(LogLevel.Debug, "DataSet: " + (_dimse.Dataset != null ? _dimse.Dataset.DumpString : String.Empty)); + //_assoc.TotalBytesRead += (UInt64)total; _dimse = null; @@ -1478,7 +1482,7 @@ command.CalculateWriteLength(TransferSyntax.ImplicitVrLittleEndian, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths); - if (dataset != null) + if (dataset != null && !dataset.IsEmpty()) total += dataset.CalculateWriteLength(ts, DicomWriteOptions.Default); PDataTFStream pdustream; @@ -1494,6 +1498,8 @@ DimseMessageSending(_assoc, pcid, command, dataset); }; + Platform.Log(LogLevel.Debug, "\r\nSend Command: " + command != null ? command.DumpString : String.Empty); + Platform.Log(LogLevel.Debug, "DataSet: " + dataset != null ? dataset.DumpString : String.Empty); OnSendDimseBegin(pcid, command, dataset); @@ -1649,7 +1655,7 @@ message.Priority = DicomPriority.Medium; //if (message.DataSet != null && !message.DataSet.IsEmpty()) - message.DataSetType = 0x0201; + message.DataSetType = 0x0101; SendDimse(presentationID, message.CommandSet, message.DataSet); } Index: Network/Scu/BasicGrayscalePrintScu.cs =================================================================== --- Network/Scu/BasicGrayscalePrintScu.cs (revision 9475) +++ Network/Scu/BasicGrayscalePrintScu.cs (working copy) @@ -161,17 +161,23 @@ /// /// This stores the film Session Uid that in the Film Session create request, we need it later on... /// - DicomUid _filmSessionUid = null; + string _filmSessionUid = null; /// /// This stores the film BOx Uid that in the Film Box create request, we need it later on... /// - DicomUid _filmBoxUid = null; + private IList _filmBoxUids = new List(); /// + /// Need to remember film box response message because this contains info about the image boxes... note + /// only supports one film box for now... + /// + IDictionary _filmBoxResponseMessages = new Dictionary(); + + /// /// Keeps track of which image is sent /// - int _currentImageBoxIndex; + private int _currentImageBoxIndex; /// /// Basic Film Session request @@ -188,7 +194,6 @@ /// IList _imageBoxPixelModuleIods; - #endregion #region Constructors @@ -201,17 +206,6 @@ } #endregion - #region Public Properties - /// - /// Gets the results of the find request. - /// - /// The results. - public DicomAttributeCollection Results - { - get { return _results; } - } - #endregion - #region Public Methods /// @@ -226,14 +220,14 @@ /// The image box pixel module iods. public DicomState Print(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList imageBoxPixelModuleIods) { - this._results = null; - this._filmSessionUid = null; - this._filmBoxUid = null; + _results = null; + _filmSessionUid = null; _basicFilmSessionModuleIod = basicFilmSessionModuleIod; _basicFilmBoxModuleIod = basicFilmBoxModuleIod; _imageBoxPixelModuleIods = imageBoxPixelModuleIods; - _firstFilmBoxResponseMessage = null; - this._currentImageBoxIndex = 0; + _filmBoxResponseMessages.Clear(); + _currentImageBoxIndex = 0; + _filmBoxUids.Clear(); Connect(clientAETitle, remoteAE, remoteHost, remotePort); return base.ResultStatus; } @@ -282,9 +276,8 @@ DicomMessage newRequestMessage = new DicomMessage(null, (DicomAttributeCollection)_basicFilmSessionModuleIod.DicomAttributeProvider); byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass); - _filmSessionUid = DicomUid.GenerateUid(); _nextRequestType = RequestType.FilmBox; - client.SendNCreateRequest(_filmSessionUid, pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmSession); + client.SendNCreateRequest(DicomUid.GenerateUid(), pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmSession); } private void SendCreateFilmBoxRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage) @@ -299,31 +292,26 @@ byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass); - _filmBoxUid = DicomUid.GenerateUid(); _nextRequestType = RequestType.ImageBox; - client.SendNCreateRequest(_filmBoxUid, pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmBoxSOP); + client.SendNCreateRequest(DicomUid.GenerateUid(), pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmBoxSOP); } - /// - /// Need to remember first film box response message because this contains info about the image boxes... - /// - DicomAttributeCollection _firstFilmBoxResponseMessage; - private void SendSetImageBoxRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage) { if (_currentImageBoxIndex >= _imageBoxPixelModuleIods.Count) { + // done sending images box - send print request _nextRequestType = RequestType.PrintAction; SendActionPrintRequest(client, association, responseMessage); } else { - if (_currentImageBoxIndex == 0) - { - _firstFilmBoxResponseMessage = responseMessage.DataSet; - } + // want to get first film box response - although not sure if CC is using .net 3.5.. prolly not so do it old way + var filmBoxResponseEnumerator = _filmBoxResponseMessages.Values.GetEnumerator(); + filmBoxResponseEnumerator.Reset(); + filmBoxResponseEnumerator.MoveNext(); - BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod(_firstFilmBoxResponseMessage); + BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod(filmBoxResponseEnumerator.Current); if (_currentImageBoxIndex > basicFilmBoxModuleIod.ReferencedImageBoxSequenceList.Count) { @@ -353,7 +341,7 @@ private void SendActionPrintRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage) { DicomMessage newRequestMessage = new DicomMessage(null, null); - newRequestMessage.RequestedSopInstanceUid = _filmBoxUid.UID; + newRequestMessage.RequestedSopInstanceUid = _filmBoxUids[0]; newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmBoxSopClassUid; newRequestMessage.ActionTypeId = 1; _nextRequestType = RequestType.DeleteFilmBox; @@ -364,20 +352,32 @@ private void SendDeleteFilmBoxRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage) { - DicomMessage newRequestMessage = new DicomMessage(null, null); - newRequestMessage.RequestedSopInstanceUid = _filmBoxUid.UID; - newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmBoxSopClassUid; + if (_filmBoxUids.Count == 0) + { + // no more film boxes left to delete - so send delete film session + SendDeleteFilmSessionRequest(client, association, responseMessage); + } + else + { + string currentFilmBoxUid = _filmBoxUids[0]; + _filmBoxUids.Remove(currentFilmBoxUid); - _nextRequestType = RequestType.DeleteFilmSession; + DicomMessage newRequestMessage = new DicomMessage(null, null); + newRequestMessage.RequestedSopInstanceUid = currentFilmBoxUid; + newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmBoxSopClassUid; + newRequestMessage.Priority = DicomPriority.Medium; - byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass); - client.SendNDeleteRequest(pcid, client.NextMessageID(), newRequestMessage); + _nextRequestType = RequestType.DeleteFilmBox; + + byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass); + client.SendNDeleteRequest(pcid, client.NextMessageID(), newRequestMessage); + } } private void SendDeleteFilmSessionRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage) { DicomMessage newRequestMessage = new DicomMessage(null, null); - newRequestMessage.RequestedSopInstanceUid = _filmSessionUid.UID; + newRequestMessage.RequestedSopInstanceUid = _filmSessionUid; newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmSessionSopClassUid; _nextRequestType = RequestType.Close; @@ -385,9 +385,6 @@ client.SendNDeleteRequest(pcid, client.NextMessageID(), newRequestMessage); } - - - #endregion #region Overridden Methods @@ -400,7 +397,9 @@ { base.OnReceiveAssociateAccept(client, association); if (Canceled) + { client.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.NotSpecified); + } else { SendCreateFilmSessionRequest(client, association); @@ -421,8 +420,19 @@ base.ResultStatus = message.Status.Status; if (message.Status.Status == DicomState.Success) { + if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmSessionSopClassUid) + { + _filmSessionUid = message.AffectedSopInstanceUid; + } + + else if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmBoxSopClassUid) + { + _filmBoxUids.Add(message.AffectedSopInstanceUid); + _filmBoxResponseMessages.Add(message.AffectedSopInstanceUid, message.DataSet); + } + Platform.Log(LogLevel.Info, "Success status received in Printer Status Scu!"); - this._results = message.DataSet; + _results = message.DataSet; switch (_nextRequestType) { case RequestType.FilmBox: @@ -503,5 +513,4 @@ } - } Index: Network/Scu/ScuBase.cs =================================================================== --- Network/Scu/ScuBase.cs (revision 9475) +++ Network/Scu/ScuBase.cs (working copy) @@ -594,6 +594,8 @@ if (stopStatus == ScuOperationStatus.Running) stopStatus = ScuOperationStatus.NetworkError; + ResultStatus = DicomState.Failure; + StopRunningOperation(stopStatus); } @@ -605,6 +607,7 @@ public void OnDimseTimeout(DicomClient client, ClientAssociationParameters association) { Status = ScuOperationStatus.TimeoutExpired; + ResultStatus = DicomState.Failure; FailureDescription = String.Format("Timeout Expired for remote host {0}, aborting connection", RemoteAE); if (LogInformation) Platform.Log(LogLevel.Info, FailureDescription );