How to update the Modality Performed Procedure Step

1,002 views
Skip to first unread message

ncwo...@gmail.com

unread,
Sep 26, 2017, 8:18:42 AM9/26/17
to Fellow Oak DICOM
Hi,

I am new to DICOM and to FO-DICOM.

I used CreateWorklistQuery to query the MWL and I am receiving the result back successfully.

I hope I am asking it right, I need to update the MPPS how do I use N-CREATE and N-Set in FO-DICOM?


Thank Noah

Anders Gustafsson Cureos AB

unread,
Sep 28, 2017, 5:24:48 AM9/28/17
to Fellow Oak DICOM
Hi Noah,

I am not an expert on MWL:s, but for general use of N-CREATE and N-SET you could take a look at the Print SCU and Print SCP applications in the fo-dicom-samples repository.

Regards,
Anders @ Cureos

ncwo...@gmail.com

unread,
Oct 8, 2017, 9:28:59 AM10/8/17
to Fellow Oak DICOM
Thanks for your quick response.

But I am sill strangling on how to create MPPS from the return MWL query.

I tried using the below code using the value I get from the query: 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 DicomUID EffectedinstanceUid = DicomUID.Generate();

var request = new DicomNCreateRequest(DicomUID.ModalityPerformedProcedureStepSOPClass, EffectedinstanceUid );
  
                 request.Command.AddOrUpdate(DicomTag.ScheduledProcedureStepID, dataGridView1.Rows[0].Cells[12].Value.ToString());//SPSID                 
                 request.Command.AddOrUpdate(DicomTag.RequestedProcedureID, dataGridView1.Rows[0].Cells[13].Value.ToString()); // Request ProcID
                 request.Command.AddOrUpdate(DicomTag.PatientID, dataGridView1.Rows[0].Cells[1].Value.ToString());                          //PatinetID
                 request.Command.AddOrUpdate(DicomTag.AccessionNumber, dataGridView1.Rows[0].Cells[5].Value.ToString());           // AccessionNumber
                 request.Command.AddOrUpdate(DicomTag.PatientName, dataGridView1.Rows[0].Cells[2].Value.ToString());                   // PatientName
                 request.Command.AddOrUpdate(DicomTag.Modality, dataGridView1.Rows[0].Cells[6].Value.ToString());                          //Modality
                 request.Command.AddOrUpdate(DicomTag.PerformedProcedureStepStartDate, DateTime.Now);
                 request.Command.AddOrUpdate(DicomTag.PerformedProcedureStepStartDateTime, DateTime.Now);
                 request.Command.AddOrUpdate(DicomTag.PerformedProcedureStepStatus, "IN PROGRESS"); 
       
                 client.AddRequest(request);
                 client.Send(QRServerHost, Port, false, AET, QRServerAET);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

But I am doing something wrong:
  • Not sure if I am sending the correct parameters values in: DicomNCreateRequest(DicomUID.ModalityPerformedProcedureStepSOPClass ?, EffectedinstanceUid ?) 
  • which UID do I need to send for EffectedClassUid and for EffectedInstanceUid to send? 
  • Not sure it will help but I am getting the below error.
Please I need your help.

Many Thanks

Capture.JPG

Yves Vander Haeghen

unread,
Nov 16, 2017, 10:27:03 AM11/16/17
to Fellow Oak DICOM
Hi there,

I have a similar problem trying to get MPPS to work.
Just as Noah, I have no problem obtaining MWL entries, but I am baffled as to what I need to send in the N-CREATE DIMSE command. I had a look at the PRINT-SCU and based my code on it, but to no avail.

I have no idea if there is a problem with the PACS (Agfa IMPAX 6.5) or I am doing something wrong ...
In my case the PACS storage SCP seems to answer, but it keeps refusing my N-create command.

BTW, great work on the library, but I feel some more examples could be useful (obviously an MPPS example, :-) ), espcially as standard DICOM and PACS documentation are very complex ...
Any comments are greatly appreciated.

N-Create request [2]
--------------------------------------------------------------------------------
 DIMSE Command:
--------------------------------------------------------------------------------
(0000,0002) UI [1.2.840.10008.3.1.2.3.3]                        #    24, AffectedSOPClassUID
(0000,0100) US 320                                              #     2, CommandField
(0000,0110) US 2                                                #     2, MessageID
(0000,0800) US 514                                              #     2, CommandDataSetType
(0000,1000) UI [1.08.1982.10121984.2.0.07.636464422131932766]   #    44, AffectedSOPInstanceUID

--------------------------------------------------------------------------------
 DIMSE Dataset:
--------------------------------------------------------------------------------
(0008,0060) CS [OT]                                             #     2, Modality
(0010,0010) PN [Test^Geniuz^^]                                  #    14, PatientName
(0010,0020) LO [900215 091A05]                                  #    14, PatientID
(0010,0030) DA [19900215]                                       #     8, PatientBirthDate
(0010,0040) CS [M]                                              #     2, PatientSex
(0020,0010) SH (no value available)                             #     0, StudyID
(0040,0241) AE [DIGOK_OT_93735]                                 #    14, PerformedStationAETitle
(0040,0242) SH (no value available)                             #     0, PerformedStationName
(0040,0252) CS [IN PROGRESS]                                    #    12, PerformedProcedureStepStatus
(0040,0254) LO (no value available)                             #     0, PerformedProcedureStepDescription
(0040,0270) SQ Scheduled Step Attributes Sequence
  Item:
    > (0008,0050) SH [000055629332]                             #    12, AccessionNumber
    > (0008,1110) SQ Referenced Study Sequence
      Item:
        > (0008,1150) UI [1.2.840.10008.3.1.2.3.1]              #    24, ReferencedSOPClassUID
        > (0008,1155) UI [1.2.124.113532.80.22170.21533.201711) #    52, ReferencedSOPInstanceUID
    > (0020,000d) UI [1.2.124.113532.80.22170.21533.20171114.1) #    52, StudyInstanceUID
    > (0032,1060) LO [Amputatie teen]                           #    14, RequestedProcedureDescription
    > (0040,0007) LO [Amputatie teen]                           #    14, ScheduledProcedureStepDescription
    > (0040,0009) SH [000055629332]                             #    12, ScheduledProcedureStepID
    > (0040,1001) SH [000055629332]                             #    12, RequestedProcedureID
(0040,4050) DT [20171116161653+0100]                            #    20, PerformedProcedureStepStartDateTime
(0040,4051) DT (no value available)                             #     0, PerformedProcedureStepEndDateTime

--------------------------------------------------------------------------------

N-Create response [2]: Refused: SOP class not supported
--------------------------------------------------------------------------------
 DIMSE Command:
--------------------------------------------------------------------------------
(0000,0002) UI [1.2.840.10008.3.1.2.3.3]                        #    24, AffectedSOPClassUID
(0000,0100) US 33088                                            #     2, CommandField
(0000,0120) US 2                                                #     2, MessageIDBeingRespondedTo
(0000,0800) US 257                                              #     2, CommandDataSetType
(0000,0900) US 290                                              #     2, Status
(0000,1000) UI [1.08.1982.10121984.2.0.07.636464422131932766]   #    44, AffectedSOPInstanceUID

--------------------------------------------------------------------------------

ncwo...@gmail.com

unread,
Nov 20, 2017, 3:00:31 AM11/20/17
to Fellow Oak DICOM
Hi Yves,

I succeeded to do MPPS (N-CREATE and N-SET) after many attempts and digging in google,  the below link have helped me.

I used C# code for my MPPS commands see below my code:


 public MessageContent MPPS_Set_StartInPogress(string P_uid)
        {
            var client = new DicomClient();
            var dataset = new DicomDataset();
            MessageContent msgContent = new MessageContent();
            try
            {
                //query MWL by patient id
                var retCFindResponse = QueryMWL(P_uid);
                DicomSequence sq = retCFindResponse.Dataset.Get<DicomSequence>(DicomTag.ScheduledProcedureStepSequence);

                DicomDataset content = new DicomDataset();
                // get study instance UID from MWL query resault
                string studyInstanceUID = retCFindResponse.Dataset.Get<string>(DicomTag.StudyInstanceUID, DicomUID.Generate().ToString()); ;
                DicomUID instanceDicomUid = DicomUID.Generate();
                DicomUID sopDicomUid = DicomUID.Generate();

                // set Attribute Sequence data 
                content.Add(DicomTag.StudyInstanceUID, studyInstanceUID);
                content.Add(DicomTag.ReferencedStudySequence, new DicomDataset());
                content.Add(DicomTag.AccessionNumber,retCFindResponse.Dataset.Get<string>(DicomTag.AccessionNumber, String.Empty));
                content.Add(DicomTag.RequestedProcedureID,retCFindResponse.Dataset.Get<string>(DicomTag.RequestedProcedureID, String.Empty));
                content.Add(DicomTag.RequestedProcedureDescription, retCFindResponse.Dataset.Get<String>(DicomTag.RequestedProcedureDescription,String.Empty));
                content.Add(DicomTag.ScheduledProcedureStepID, sq.Items[0].Get<String>(DicomTag.ScheduledProcedureStepID, String.Empty));
                content.Add(DicomTag.ScheduledProcedureStepDescription, sq.Items[0].Get<String>(DicomTag.ScheduledProcedureStepID, String.Empty));
                content.Add(DicomTag.ScheduledProtocolCodeSequence, new DicomDataset());

                DicomSequence attr_Sequence = new DicomSequence(DicomTag.ScheduledStepAttributesSequence, content);//"Scheduled Step Attribute Sequence"
                dataset.Add(attr_Sequence);

                dataset.Add(DicomTag.PatientName, retCFindResponse.Dataset.Get<string>(DicomTag.PatientName, String.Empty));
                dataset.Add(DicomTag.PatientID, retCFindResponse.Dataset.Get<string>(DicomTag.PatientID, String.Empty));
                dataset.Add(DicomTag.PatientBirthDate, retCFindResponse.Dataset.Get<string>(DicomTag.PatientBirthDate, String.Empty));
                dataset.Add(DicomTag.PatientSex, retCFindResponse.Dataset.Get<string>(DicomTag.PatientSex, String.Empty));

                dataset.Add(DicomTag.ReferencedPatientSequence, new DicomDataset());
                dataset.Add(DicomTag.PerformedProcedureStepID, "1.2.3.4.5.6"); // can be any key
                dataset.Add(DicomTag.PerformedStationAETitle, "UNKNOWN");
                dataset.Add(DicomTag.PerformedStationName, "UNKNOWN");
                dataset.Add(DicomTag.PerformedLocation, string.Empty);
                dataset.Add(DicomTag.PerformedProcedureStepStartDate, DateTime.Now);
                dataset.Add(DicomTag.PerformedProcedureStepStartTime, DateTime.Now);
                // set status 
                dataset.Add(DicomTag.PerformedProcedureStepStatus, "IN PROGRESS");
                dataset.Add(DicomTag.PerformedProcedureStepDescription, string.Empty);
                dataset.Add(DicomTag.PerformedProcedureTypeDescription, string.Empty);
               
                dataset.Add(DicomTag.PerformedProcedureStepEndDate, string.Empty);
                dataset.Add(DicomTag.PerformedProcedureStepEndTime, string.Empty);
                // get modality from MWL query resault 
                dataset.Add(DicomTag.Modality, sq.Items[0].Get<String>(DicomTag.Modality, String.Empty));
                dataset.Add(DicomTag.StudyID, string.Empty);
                dataset.Add(DicomTag.PerformedProtocolCodeSequence, new DicomDataset());
                dataset.Add(DicomTag.PerformedSeriesSequence, new DicomDataset());
                // I used the studyInstanceUID as the effectedinstamceUid, this id will be needed for the N-SET also
                DicomUID effectedinstamceUid = new DicomUID(studyInstanceUID, "effectedinstamceUid", DicomUidType.SOPInstance);// = new DicomDataset();

               var dicomStart =  new DicomNCreateRequest(DicomUID.ModalityPerformedProcedureStepSOPClass, effectedinstamceUid)
                {
                    Dataset = dataset
                };

               dicomStart.OnResponseReceived += (req, response) =>
                {
                    if (!(response.Equals(null)))
                    {
                        Debug.WriteLine(response);
                        //msgContent is a class object that has 2 string Status and Message for the return mpps message
                        msgContent.Status = response.Status.ToString();
                        msgContent.Message = response.ToString();
                    }
                };
                
                client.AddRequest(dicomStart);
                client.Send(ServerHost, ServerPort, false, ClientAET, ServerAET);
            }
            #region handle exceptions
            catch (DicomAssociationRejectedException assRejected)
            {
                Debug.WriteLine(assRejected);
                msgContent.Status = "Rejected";
                msgContent.Message = assRejected.Message;
            }
            catch (DicomAssociationAbortedException assAborted)
            {
                Debug.WriteLine(assAborted);
                msgContent.Status = "Aborted";
                msgContent.Message = assAborted.Message;
            }
            catch (SocketException sEx)
            {
                Debug.WriteLine(sEx);
                msgContent.Status = "Socket_Exception";
                msgContent.Message = sEx.Message;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                msgContent.Status = "Exception";
                msgContent.Message = ex.Message;
            }
            #endregion
            return msgContent;

        }
Reply all
Reply to author
Forward
0 new messages