Search code examples
c#dicommedicalfo-dicom

Storage Commitment with fo-dicom


I am trying to implement a storage commitment with FO-DICOM framework, but with no result. I am able to create the N-ACTION request. I am able to receive the N-ACTION response. But I don't know how to receive the EVENTREPORT. Anyone can help me and address me to the right way?

private DicomStatus _responseStatus;

public void SendRequestForCommitment(string scImageUid)
{
    var client = new DicomClient();

    var nAction = new DicomNActionRequest(DicomUID.StorageCommitmentPushModelSOPClass,
        new UIDGenerator().PrivatelyDefinedSoapInstanceUid(), 1);

    var ds = new DicomDataset();
    nAction.Dataset = ds;
    nAction.Dataset.Add(DicomTag.TransactionUID, new UIDGenerator().uid);

    var sps = new DicomDataset();
    nAction.Dataset.Add(new DicomSequence(DicomTag.ReferencedSOPSequence, sps));

    sps.Add(DicomTag.ReferencedSOPClassUID, DicomUID.SecondaryCaptureImageStorage);
    sps.Add(DicomTag.ReferencedSOPInstanceUID, scImageUid);

    DicomNActionRequest.ResponseDelegate nActionResponseDelegate = NActionResponse;
    nAction.OnResponseReceived = nActionResponseDelegate;

    client.AddRequest(nAction);
    client.Send("127.0.0.1", 105, false, "myAE", "DVTK_STRC_SCP");


}

private void NActionResponse(DicomNActionRequest request, DicomNActionResponse response)
{
    _responseStatus = response.Status;
}

Solution

  • Disclaimer: I never used FO-DICOM. The code below is just a pseudo code and is NOT FO-DICOM syntax. I hope looking at pseudo code, you will able to figure out exact members (properties, methods, and events) in toolkit.

    In your code, you are already building request dataset. Then, you are calling client.AddRequest(nAction); and then client.Send(.......);. I assume this will internally establish a connection, association and will send NAction request.

    Then you have subscribed for private void NActionResponse(....) event. I assume this event is being fired and you are getting NAction Response.

    Similarly, you should subscribe NEventReport event something (look for exact syntax in toolkit) like following:

    private void NEventReportReceived(DicomNEventReport request, ......)
    {
        //Parse the request here.
        //Check what files were archived and what were failed.
        //Do your stuff accordingly.
        //Send NEventReport response conveying the status.
    
        client.SendReleaseRequest();
    }
    

    Subscribe another event to handle release response.

    private void ReleaseResponseReceived(......)
    {
        //Close connection
    }
    

    As I said in other answer, your SCU should have ability to process NEventReport. You have added NAction to your client by writing line client.AddRequest(nAction);. Check the toolkit documentation to see if you also need to add similar for NEventReport. I strongly think this should not be needed; you just need to subscribe an event.