Mike Murphy
Mike Murphy

Reputation: 1297

Unable to save DICOM from PACS using fodicom

I'm working with the QueryRetrieve SCU project in the FoDicom sample solution...

FoDicom Samples

The code never hits the SaveImage method. I'm querying www.dicomserver.co.uk for sample images...I'm new to this and at a loss. What am I missing?

            var client = DicomClientFactory.Create(_qrServerHost, _qrServerPort, false, _aet, _qrServerAET);
        client.NegotiateAsyncOps();

        // Find a list of Studies

        var request = CreateStudyRequestByPatientName("Cooper");

        var studyUids = new List<string>();
        request.OnResponseReceived += (req, response) =>
        {
            studyUids.Add(response.Dataset?.GetSingleValue<string>(DicomTag.StudyInstanceUID));
        };
        await client.AddRequestAsync(request);
        await client.SendAsync();

        // find all series from a study that previous was returned
        var studyUID = studyUids[0];
        request = CreateSeriesRequestByStudyUID(studyUID);

        var serieUids = new List<string>();
        request.OnResponseReceived += (req, response) =>
        {
            serieUids.Add(response.Dataset?.GetSingleValue<string>(DicomTag.SeriesInstanceUID));
        };
        await client.AddRequestAsync(request);
        await client.SendAsync();

        // now get all the images of a serie with cGet in the same association

        client = DicomClientFactory.Create(_qrServerHost, _qrServerPort, false, _aet, _qrServerAET);

        var cGetRequest = CreateCGetBySeriesUID(studyUID, serieUids.First());
        client.OnCStoreRequest += (DicomCStoreRequest req) =>
        {
            Console.WriteLine(DateTime.Now.ToString() + " recived");
            SaveImage(req.Dataset);
            return Task.FromResult(new DicomCStoreResponse(req, DicomStatus.Success));
        };

        // the client has to accept storage of the images. We know that the requested images are of SOP class Secondary capture, 
        // so we add the Secondary capture to the additional presentation context
        // a more general approach would be to mace a cfind-request on image level and to read a list of distinct SOP classes of all
        // the images. these SOP classes shall be added here.
        var pcs = DicomPresentationContext.GetScpRolePresentationContextsFromStorageUids(
            DicomStorageCategory.Image,
            DicomTransferSyntax.ExplicitVRLittleEndian,
            DicomTransferSyntax.ImplicitVRLittleEndian,
            DicomTransferSyntax.ImplicitVRBigEndian);
        client.AdditionalPresentationContexts.AddRange(pcs);
        await client.AddRequestAsync(cGetRequest);
        await client.SendAsync();

Upvotes: 1

Views: 596

Answers (1)

Mike Murphy
Mike Murphy

Reputation: 1297

i disabled part of the code i needed. i added the piece of code i needed it starts... // the client has to accept storage of the images....

Upvotes: 2

Related Questions