Exemplo n.º 1
0
        /// <summary>
        /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
        /// </summary>
        /// <param name="scp">the provider which will perform the move</param>
        /// <param name="sopUid">the uid of the image to be moved</param>
        /// <param name="patientId">the patient id of the image</param>
        /// <param name="toAETite">the entity title which will receive the image</param>
        /// <param name="msgId">the message id</param>
        /// <returns>the move response</returns>
        public CMoveResponse SendCMoveImage(Entity daemon, CFindImageIOD iod, string toAETite, ref ushort msgId)
        {
            ManualResetEvent mr   = new ManualResetEvent(false);
            CMoveResponse    resp = null;
            var cr = new EvilDICOM.Network.Services.DIMSEService.DIMSEResponseHandler <CMoveResponse>((res, asc) =>
            {
                if (!(res.Status == (ushort)Status.PENDING))
                {
                    mr.Set();
                }
                resp = res;
            });
            var result = new CMoveIOD()
            {
                QueryLevel = QueryLevel.IMAGE, SOPInstanceUID = iod.SOPInstanceUID, PatientId = iod.PatientId, StudyInstanceUID = iod.StudyInstanceUID, SeriesInstanceUID = iod.SeriesInstanceUID
            };
            var request = new CMoveRequest(result, toAETite, Root.STUDY, EvilDICOM.Core.Enums.Priority.MEDIUM, msgId);

            this.DIMSEService.CMoveResponseReceived += cr;
            this.SendMessage(request, daemon);
            mr.WaitOne();
            this.DIMSEService.CMoveResponseReceived -= cr;
            msgId += 2;
            return(resp);
        }
Exemplo n.º 2
0
        public static CFindRequest CreateImageQuery(string seriesUid)
        {
            var iod = new CFindImageIOD();

            iod.SeriesInstanceUID = seriesUid;
            return(new CFindRequest(iod, Root.STUDY));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Instructs a C-MOVE operation for an image from the SCP of the QueryBuilder to the input AETitle
 /// </summary>
 /// <param name="ir">the C Find iod of the a query (get ImageUids())</param>
 /// <param name="receivingAETitle">the AE title to send the image to (from the SCP of this query builder)</param>
 /// <param name="msgId">the message id for this image. It will NOT be incremented for looping operations within this method</param>
 /// <returns>a C-MOVE response for this operation</returns>
 public async Task <CMoveResponse> SendImageAsync(CFindImageIOD ir, string receivingAETitle, ushort msgId)
 {
     return(await Task.Run(() =>
     {
         var resp = _scu.SendCMoveImage(_scp, ir, receivingAETitle, ref msgId);
         return resp;
     }));
 }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            List <IDpair> idPairs = new List <IDpair>();
            var           IDlist  = new List <string>();

            if (args.Length == 1)
            {
                IDlist = args[0].Split(';').ToList();
            }
            else
            {
                throw new Exception("Wrong number of inputs");
            }


            // Split in pairs
            foreach (string line in IDlist)
            {
                idPairs.Add(new IDpair(line));
            }

            // Create all required entities
            //var me = new Entity("EvilDICOMC", "10.0.129.139", 50401);
            //var me = Entity.CreateLocal("DCMGRBC", 51167);
            var me  = Entity.CreateLocal("DCMGRBer", 50400);
            var scu = new DICOMSCU(me);

            //var scp = new DICOMSCP
            Entity   reciever = new Entity(AEtitle, ipadress, port);
            DICOMSCP scp      = new DICOMSCP(reciever);
            //var scpEntity = Entity.CreateLocal("EvilDICOM", 50400);
            //var scpEntity = new Entity("EvilDICOM", "10.0.129.139", 50400);
            //var scp = new FileWriterSCP(scpEntity, outPath);
            //var scp = new DICOMSCP(scpEntity);
            //scp.SupportedAbstractSyntaxes = AbstractSyntax.ALL_RADIOTHERAPY_STORAGE;
            //scp.ListenForIncomingAssociations(true);
            //var logger = new ConsoleLogger(scp.Logger, ConsoleColor.Red);
            var    qb    = new QueryBuilder(scu, daemon);
            ushort msgId = 1;

            // Loop over ID pairs and pull files from ARIA OIS to finalPath
            foreach (IDpair idPair in idPairs)
            {
                try
                {
                    //qb.SendImage(new EvilDICOM.Network.DIMSE.IOD.CFindImageIOD() { PatientId = idPair.Id, SOPInstanceUID = idPair.Uid }, "EvilDICOM", ref msgId);
                    CFindImageIOD iod = new CFindImageIOD()
                    {
                        PatientId = idPair.Id, SOPInstanceUID = idPair.Uid
                    };
                    scu.SendCMoveImage(daemon, iod, scp.ApplicationEntity.AeTitle, ref msgId);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + "\n" + idPair.Uid);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
        /// </summary>
        /// <param name="scp">the provider which will perform the move</param>
        /// <param name="sopUid">the uid of the image to be moved</param>
        /// <param name="patientId">the patient id of the image</param>
        /// <param name="toAETite">the entity title which will receive the image</param>
        /// <param name="msgId">the message id</param>
        /// <returns>the move response</returns>
        public CMoveResponse SendCMoveImage(Entity daemon, string patientId, string sopInstanceUid, string toAETite, ref ushort msgId)
        {
            var cfindIod = new CFindImageIOD()
            {
                PatientId = patientId, SOPInstanceUID = sopInstanceUid
            };

            return(SendCMoveImage(daemon, cfindIod, toAETite, ref msgId));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
        /// </summary>
        /// <param name="scp">the provider which will perform the move</param>
        /// <param name="sopUid">the uid of the image to be moved</param>
        /// <param name="patientId">the patient id of the image</param>
        /// <param name="toAETite">the entity title which will receive the image</param>
        /// <param name="msgId">the message id</param>
        /// <returns>the move response</returns>
        public CMoveResponse SendCMove(CFindImageIOD iod, string toAETite, ref ushort msgId)
        {
            var result = new CMoveIOD
            {
                QueryLevel        = QueryLevel.IMAGE,
                SOPInstanceUID    = iod.SOPInstanceUID,
                PatientId         = iod.PatientId,
                StudyInstanceUID  = iod.StudyInstanceUID,
                SeriesInstanceUID = iod.SeriesInstanceUID
            };
            var request = new CMoveRequest(result, toAETite, Root.STUDY, Core.Enums.Priority.MEDIUM, msgId);

            return(_scu.GetResponse <CMoveResponse, CMoveRequest>(request, callingEntity, ref msgId));
        }
Exemplo n.º 7
0
        public CGetRequest(CFindImageIOD iod, Root root = Root.STUDY,
                           Priority priority            = Core.Enums.Priority.MEDIUM,
                           ushort messageId             = 1)
        {
            switch (root)
            {
            case Root.PATIENT:
                AffectedSOPClassUID = AbstractSyntax.PATIENT_GET;
                break;

            case Root.STUDY:
                AffectedSOPClassUID = AbstractSyntax.STUDY_GET;
                break;
            }
            CommandField = (ushort)C.C_GET_RQ;
            Data         = new DICOMObject(iod.Elements);
            Priority     = (ushort)priority;
            MessageID    = messageId;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
        /// </summary>
        /// <param name="scp">the provider which will perform the move</param>
        /// <param name="sopUid">the uid of the image to be moved</param>
        /// <param name="patientId">the patient id of the image</param>
        /// <param name="toAETite">the entity title which will receive the image</param>
        /// <param name="msgId">the message id</param>
        /// <returns>the move response</returns>
        public CGetResponse SendGetImage(Entity daemon, CFindImageIOD iod, ref ushort msgId)
        {
            var          mr   = new ManualResetEvent(false);
            CGetResponse resp = null;
            var          cr   = new Services.DIMSEService.DIMSEResponseHandler <CGetResponse>((res, asc) =>
            {
                if (!(res.Status == (ushort)Status.PENDING))
                {
                    mr.Set();
                }
                resp = res;
            });

            iod.QueryLevel = QueryLevel.IMAGE;

            var request = new CGetRequest(iod, Root.STUDY, Core.Enums.Priority.MEDIUM, msgId);

            DIMSEService.CGetResponseReceived += cr;
            SendMessage(request, daemon);
            mr.WaitOne();
            DIMSEService.CGetResponseReceived -= cr;
            msgId += 2;
            return(resp);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
        /// </summary>
        /// <param name="scp">the provider which will perform the move</param>
        /// <param name="sopUid">the uid of the image to be moved</param>
        /// <param name="patientId">the patient id of the image</param>
        /// <param name="toAETite">the entity title which will receive the image</param>
        /// <param name="msgId">the message id</param>
        /// <returns>the move response</returns>
        public CMoveResponse SendCMoveImage(Entity daemon, CFindImageIOD iod, string toAETite, ref ushort msgId)
        {
            System.DateTime lastContact = System.DateTime.Now;
            int             msWait      = 2000;

            var           mr   = new ManualResetEvent(false);
            CMoveResponse resp = null;
            var           cr   = new Services.DIMSEService.DIMSEResponseHandler <CMoveResponse>((res, asc) =>
            {
                lastContact = System.DateTime.Now;
                if (!(res.Status == (ushort)Status.PENDING))
                {
                    mr.Set();
                }
                resp = res;
            });
            var result = new CMoveIOD
            {
                QueryLevel        = QueryLevel.IMAGE,
                SOPInstanceUID    = iod.SOPInstanceUID,
                PatientId         = iod.PatientId,
                StudyInstanceUID  = iod.StudyInstanceUID,
                SeriesInstanceUID = iod.SeriesInstanceUID
            };
            var request = new CMoveRequest(result, toAETite, Root.STUDY, Core.Enums.Priority.MEDIUM, msgId);

            DIMSEService.CMoveResponseReceived += cr;
            SendMessage(request, daemon);
            while ((System.DateTime.Now - lastContact).TotalMilliseconds < msWait)
            {
                mr.WaitOne(msWait);
            }
            DIMSEService.CMoveResponseReceived -= cr;
            msgId += 2;
            return(resp);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Instructs a C-MOVE operation for an image from the SCP of the QueryBuilder to the input AETitle
        /// </summary>
        /// <param name="ir">the C Find iod of the a query (get ImageUids())</param>
        /// <param name="receivingAETitle">the AE title to send the image to (from the SCP of this query builder)</param>
        /// <param name="msgId">the message id for this image. It will be incremented for looping operations within this method</param>
        /// <returns>a C-MOVE response for this operation</returns>
        public CMoveResponse SendImage(CFindImageIOD ir, string receivingAETitle, ref ushort msgId)
        {
            var resp = _scu.SendCMoveImage(_scp, ir, receivingAETitle, ref msgId);

            return(resp);
        }
Exemplo n.º 11
0
 public static CFindRequest CreateImageQuery(string seriesUid)
 {
     var iod = new CFindImageIOD();
     iod.SeriesInstanceUID = seriesUid;
     return new CFindRequest(iod, Root.STUDY);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
 /// </summary>
 /// <param name="scp">the provider which will perform the move</param>
 /// <param name="sopUid">the uid of the image to be moved</param>
 /// <param name="patientId">the patient id of the image</param>
 /// <param name="toAETite">the entity title which will receive the image</param>
 /// <param name="msgId">the message id</param>
 /// <returns>the move response</returns>
 public CMoveResponse SendCMoveImage(Entity daemon, string patientId, string sopInstanceUid, string toAETite, ref ushort msgId)
 {
     var cfindIod = new CFindImageIOD() { PatientId = patientId, SOPInstanceUID = sopInstanceUid };
     return SendCMoveImage(daemon, cfindIod, toAETite, ref msgId);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Emits a CMove operation to an entity which moves an image from the entity to the specified AETitle
 /// </summary>
 /// <param name="scp">the provider which will perform the move</param>
 /// <param name="sopUid">the uid of the image to be moved</param>
 /// <param name="patientId">the patient id of the image</param>
 /// <param name="toAETite">the entity title which will receive the image</param>
 /// <param name="msgId">the message id</param>
 /// <returns>the move response</returns>
 public CMoveResponse SendCMoveImage(Entity daemon, CFindImageIOD iod, string toAETite, ref ushort msgId)
 {
     ManualResetEvent mr = new ManualResetEvent(false);
     CMoveResponse resp = null;
     var cr = new EvilDICOM.Network.Services.DIMSEService.DIMSEResponseHandler<CMoveResponse>((res, asc) =>
     {
         if (!(res.Status == (ushort)Status.PENDING))
         {
             mr.Set();
         }
         resp = res;
     });
     var result = new CMoveIOD() { QueryLevel = QueryLevel.IMAGE, SOPInstanceUID = iod.SOPInstanceUID, PatientId = iod.PatientId, StudyInstanceUID = iod.StudyInstanceUID, SeriesInstanceUID = iod.SeriesInstanceUID };
     var request = new CMoveRequest(result, toAETite, Root.STUDY, EvilDICOM.Core.Enums.Priority.MEDIUM, msgId);
     this.DIMSEService.CMoveResponseReceived += cr;
     this.SendMessage(request, daemon);
     mr.WaitOne();
     this.DIMSEService.CMoveResponseReceived -= cr;
     msgId += 2;
     return resp;
 }