How to implement C-MOVE in DicomObjects
DicomObjects.NET
C-MOVE is slightly more complicated but user has a lot more flexibility. Following is VB.NET sample code showing how to do a proper C-MOVE via DicomQuery Object and how to receive C-MOVE responses.
DicomImageCollection images = new DicomImageCollection();
private void Move(object sender, EventArgs e)
{
// set up the image receiver
using(DicomServer server = new DicomServer())
{
server.InstanceReceived += Server_InstanceReceived;
server.Listen(1111);
DicomQuery query = new DicomQuery();
// the C-MOVE destination value must be known to PACS to perform reverse C-STORE
query.Destination = "Move_Destination";
query.Node = pacs_ip;
query.Port = 104;
query.Level = QueryLevel.STUDY;
query.Root = QueryRoot.Study;
query.PatientID = "1234";
query.StudyUID = "1.2.3.4.5.6.7";
query.Move();
// by the time the above call returns, the images should have been collected!
MessageBox.Show(images.Count.ToString());
server.Unlisten(1111);
}
}
C-MOVE responses are received in the DicomServer.InstanceReceived event:
private void Server_InstanceReceived(object Sender, DicomObjects.EventArguments.InstanceReceivedArgs e)
{
images.Add(new DicomImage(e.Instance));
e.Status = 0; // Tell PACS that you have received the image
}
DicomObjects.COM
The above .NET would not have worked in the COM version of DicomObjects as there would have been a deadlock, as the InstanceReceived Event could not have fired whilst Move was in progress, but that is no problem in .NET. To make it work in COM version, you can simply use the GetUsingMove method as shown below.
Dim q As New DicomQuery
Dim images As DicomImages
q.PatientID = "1234"
q.StudyUID = "1.2.3.4.5.6.7"
q.Level = "STUDY"
' the C-MOVE destination value must be known to PACS to perform reverse C-STORE
q.Destination = "Move_Destination"
q.ReceivePort = optionsRef.Port
Set images = q.GetUsingMove