/// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string                  localStatus               = "FAILED";
            string                  _dcmInstanceId            = UnitId.Get(context);
            int                     nDcmInstanceId            = Convert.ToInt32(_dcmInstanceId);
            IList <string>          sourceFrameOfReferenceUid = new List <string>();
            string                  targetFrameOfReferenceUid = "";
            IList <IList <double> > transformationMatrix      = new List <IList <double> >();
            IList <string>          transformationComment     = new List <string>();
            byte                    nRegistrationType         = 0;

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            _processSpatialRegistrationObject.ParseTreatmentPlanningSpatialRegistration(nDcmInstanceId, ref sourceFrameOfReferenceUid, ref targetFrameOfReferenceUid, ref transformationMatrix, ref transformationComment, ref nRegistrationType);

            if (sourceFrameOfReferenceUid != null && sourceFrameOfReferenceUid.Count > 0)
            {
                localStatus = "SUCCESS";
            }

            SourceFrameOfReferenceUID.Set(context, sourceFrameOfReferenceUid);
            TargetFrameOfReferenceUID.Set(context, targetFrameOfReferenceUid);
            TransformationMatrix.Set(context, transformationMatrix);
            TransformationMatrixComment.Set(context, transformationComment);
            RegistrationType.Set(context, nRegistrationType);
            ActivityStatus.Set(context, localStatus);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        protected override void BeforeDoWork(NativeActivityContext context)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processSpatialRegistrationObject.ConstructedBy));

            var registrationType        = SpatialRegistrationObjectType.Get(context);
            var planningSopInstanceUids = PlanningImageSopInstanceValues.Get(context);

            switch (registrationType)
            {
            case "2D":
                _processSpatialRegistrationObject.GetReferenced2DImageInfo(Int32.Parse(UnitId.Get(context)), planningSopInstanceUids);
                break;

            case "3D":
                _processSpatialRegistrationObject.GetReferenced3DImageInfo(Int32.Parse(UnitId.Get(context)), planningSopInstanceUids);
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string localStatus = "FAILED";

            ActivityStatus.Set(context, localStatus);
            string sSpatialRegistrationObjectType = "";
            int    nPatientID       = 0;
            string sManfacturer     = "";
            string sModel           = "";
            string sSoftwareVersion = "";
            string sModality        = "";
            string _dcmInstanceId   = UnitId.Get(context);
            int    nDcmInstanceId   = Convert.ToInt32(_dcmInstanceId);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            try
            {
                _processSpatialRegistrationObject.RetrieveSpatialRegistrationDetails(nDcmInstanceId, ref nPatientID, ref sManfacturer, ref sModel, ref sSoftwareVersion, ref sModality, ref sSpatialRegistrationObjectType);
                if (nPatientID > 0)
                {
                    localStatus = "SUCCESS";
                }
                SpatialRegistrationObjectType.Set(context, sSpatialRegistrationObjectType);
                PatientID.Set(context, nPatientID);
                Manufacturer.Set(context, sManfacturer);
                Model.Set(context, sModel);
                SoftwareVersion.Set(context, sSoftwareVersion);
                Modality.Set(context, sModality);
                ActivityStatus.Set(context, localStatus);
            }
            catch (Exception e)
            {
                ActivityStatus.Set(context, localStatus);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="obj"></param>
        protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.Assert(bookmark.Name == BookmarkName);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));

            string referencedSiteId = _processSpatialRegistrationObject.GetReferencedSiteId(Int32.Parse(UnitId.Get(context)));
            var    refFrameOfRefUid = _processSpatialRegistrationObject.GetReferencedFrameOfReferenceInfo(Int32.Parse(UnitId.Get(context)));

            if (referencedSiteId != "")
            {
                var tmpList = _processSpatialRegistrationObject.GetReferenceStructureSetDcmInstances(refFrameOfRefUid, referencedSiteId, Int32.Parse(UnitId.Get(context)));

                foreach (string rtssId in tmpList)
                {
                    _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found structure set id: [{2}]",
                                                                           Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), rtssId));
                }
                OutStructureSetIds.Set(context, tmpList);

                OutUnitId.Set(context, UnitId.Get(context));
                _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                       Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
            }
        }
Ejemplo n.º 5
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string                  localStatus               = "FAILED";
            string                  _dcmInstanceId            = UnitId.Get(context);
            int                     nDcmInstanceId            = Convert.ToInt32(_dcmInstanceId);
            byte                    nRegistrationType         = RegistrationType.Get(context);
            string                  _manufacturer             = Manufacturer.Get(context);
            string                  _model                    = ModelName.Get(context);
            string                  _softwareVersion          = SoftwareVersions.Get(context);
            IList <string>          sourceFrameOfReferenceUid = SourceFrameOfReferenceUID.Get(context);
            string                  targetFrameOfReferenceUid = TargetFrameOfReferenceUID.Get(context);
            IList <IList <double> > transformationMatrix      = TransformationMatrix.Get(context);
            IList <string>          transformationComment     = TransformationMatrixComment.Get(context);
            string                  _offsetId                 = OffsetID.Get(context);
            int                     nOffsetId                 = 0;

            if (_offsetId.Length > 0)
            {
                nOffsetId = Convert.ToInt32(_offsetId);
            }

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            try
            {
                _processSpatialRegistrationObject.CreateRegistrationRecord(nDcmInstanceId, transformationMatrix, transformationComment, sourceFrameOfReferenceUid, targetFrameOfReferenceUid, nRegistrationType, _manufacturer, _model, _softwareVersion, nOffsetId);
                localStatus = "SUCCESS";
                ActivityStatus.Set(context, localStatus);
            }
            catch (Exception ex)
            {
                ActivityStatus.Set(context, localStatus);
            }
        }
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _processStructureSet.CreateRelatedSeriesLinkRecord(UnitId.Get(context)) ? "SUCCESS" : "FAIL";

            ActivityStatus.Set(context, localStatus);
        }
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _processConventionalPlan.PopulatePlanAndBeamTables(UnitId.Get(context));

            ActivityStatus.Set(context, localStatus);
        }
Ejemplo n.º 8
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _createDoseVolume.ProcessDoseCreateDoseVolume(UnitId.Get(context));

            ActivityStatus.Set(context, localStatus);
        }
Ejemplo n.º 9
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _createAnatomySets.GenerateSurfaceMesh(UnitId.Get(context));

            ActivityStatus.Set(context, localStatus);
        }
Ejemplo n.º 10
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _regenerateAvsVolume.RegenerateAvsForImageSeries(UnitId.Get(context));

            ActivityStatus.Set(context, localStatus);
        }
Ejemplo n.º 11
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ActivityStatus.Set(context, "FAILED");
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            string localStatus = _processImageSeries.ConvertExistingVolumes(UnitId.Get(context));

            ActivityStatus.Set(context, localStatus);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="obj"></param>
        protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.Assert(bookmark.Name == BookmarkName);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
            var registrationType = SpatialRegistrationObjectType.Get(context);

            if (registrationType.Equals("2D"))
            {
                IList <int> imageIds = new List <int>();
                _processSpatialRegistrationObject.GetReferencedImageIds(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceValues.Get(context), ref imageIds);
                foreach (int image_id in imageIds)
                {
                    _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), image_id.ToString()));
                }
                if (imageIds.Count == 0)
                {
                    _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Image Id list was not set correctly", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                    ActivityStatus.Set(context, "FAILED");
                }
                else
                {
                    ActivityStatus.Set(context, "SUCCESS");
                }
                VerificationImageIds.Set(context, imageIds);
                OutUnitId.Set(context, UnitId.Get(context));
                ActivityStatus.Set(context, "SUCCESS");
            }
            else if (registrationType.Equals("3D"))
            {
                IList <int> imageIds = new List <int>();
                _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceValues.Get(context), ref imageIds);
                foreach (int image_id in imageIds)
                {
                    _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), image_id.ToString()));
                }
                if (imageIds.Count == 0)
                {
                    _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Image Id list was not set correctly", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                    ActivityStatus.Set(context, "FAILED");
                }
                else
                {
                    ActivityStatus.Set(context, "SUCCESS");
                }
                VerificationImageIds.Set(context, imageIds);
                OutUnitId.Set(context, UnitId.Get(context));
            }
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
        }
Ejemplo n.º 13
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string                  localStatus                           = "FAILED";
            string                  _dcmInstanceId                        = UnitId.Get(context);
            int                     nDcmInstanceId                        = Convert.ToInt32(_dcmInstanceId);
            IList <string>          sourceFrameOfReferenceUid             = SourceFrameOfReferenceUID.Get(context);
            string                  targetFrameOfReferenceUid             = TargetFrameOfReferenceUID.Get(context);
            IList <IList <double> > transformationMatrix                  = TransformationMatrix.Get(context);
            IList <int>             planningImageIdValues                 = PlanningImageIdValues.Get(context);
            IList <int>             verificationImageIdValues             = VerificationImageIdValues.Get(context);
            IList <string>          planningImageSopInstanceUidValues     = PlanningImageSopInstanceValues.Get(context);
            IList <string>          verificationImageSopInstanceUidValues = VerificationImageSopInstanceValues.Get(context);
            IList <string>          planningFrameOfReferenceUidValues     = PlanningImageFrameOfReferenceUidValues.Get(context);
            string                  spatialRegistrationObjectType         = SpatialRegistrationObjectType.Get(context);
            string                  siteID        = SiteID.Get(context);
            IList <decimal>         dOffsetValues = new List <decimal>(6);
            int                     nOffsetId     = 0;
            int                     nSiteID       = 0;
            int                     nPatientID    = 0;

            if (siteID.Length > 0)
            {
                nSiteID = Convert.ToInt32(siteID);
            }

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);


            bool result =
                _processSpatialRegistrationObject.PrepAndCreateOffsetRecords(
                    nDcmInstanceId,
                    spatialRegistrationObjectType,
                    planningImageIdValues,
                    verificationImageIdValues,
                    planningImageSopInstanceUidValues,
                    verificationImageSopInstanceUidValues,
                    planningFrameOfReferenceUidValues,
                    sourceFrameOfReferenceUid,
                    targetFrameOfReferenceUid,
                    transformationMatrix,
                    nSiteID,
                    ref nPatientID,
                    ref nOffsetId,
                    ref dOffsetValues);

            if (result)
            {
                localStatus = "SUCCESS";
            }
            PatientID.Set(context, nPatientID.ToString());
            OffsetID.Set(context, nOffsetId.ToString());
            SroProcessedResult.Set(context, result);
            OffsetValues.Set(context, dOffsetValues);
            ActivityStatus.Set(context, localStatus);
        }
        protected override void BeforeDoWork(NativeActivityContext context)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processDose.ConstructedBy));
        }
        protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            bool validRefForSequenceInSS = true;

            pCancelBookmarkCreation = false;
            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Enter: Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processSS.ConstructedBy));

            var refStudyInfo = _processSS.GetReferencedStudyInfo(Int32.Parse(UnitId.Get(context)));

            foreach (var tuple in refStudyInfo)
            {
                string refForUid = _processSS.GetReferencedFrameOfRefUid(Int32.Parse(UnitId.Get(context)));
                var    metadata  = _processSS.BuildMonitorMetadata(tuple.Item2, tuple.Item3, refForUid);

                //
                // If the dataset we are planning to wait is already available
                // skip the bookmark creation and proceed to next activity.
                //
                if (_waitSetDataWrapper.IsDataAvailable(metadata))
                {
                    pCancelBookmarkCreation = true;
                    OutUnitId.Set(context, UnitId.Get(context));
                    //if (!base._useQueryNotificationFor3DWorkflows)
                    //{
                    //    if (!String.IsNullOrEmpty(metadata.DataMonitoringEventId))
                    //    {
                    //        WaitEventManager.TryRemoveEvent(metadata.DataMonitoringEventId);
                    //    }
                    //}
                }
                else
                {
                    BookmarkMetadata.Set(context, metadata.ToString());
                    if (base._useQueryNotificationFor3DWorkflows)
                    {
                        _waitSetDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                                metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                    }
                    else
                    {
                        _waitSetDataWrapper.InitiateWaitForDataEvent(context.WorkflowInstanceId, BookmarkName,
                                                                     metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                    }
                }
            }
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
Ejemplo n.º 16
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            int    nPatientID          = PatientID.Get(context);
            string _dcmInstanceId      = UnitId.Get(context);
            int    nDcmInstanceId      = Convert.ToInt32(_dcmInstanceId);
            int    nFrameOfReferenceId = FrameOfReferenceId.Get(context);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            // Update the registration record
            //_processSpatialRegistrationObject.UpdateRegistrationRecord(Guid, nDcmInstanceId, nPatientID, nFrameOfReferenceId);
        }
Ejemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="obj"></param>
        protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.Assert(bookmark.Name == BookmarkName);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
            OutUnitId.Set(context, UnitId.Get(context));
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
        }
Ejemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="obj"></param>
        protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.Assert(bookmark.Name == BookmarkName);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing SRO UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));

            // get the Image IDs for the Verification and Planning images
            IList <int> verifImageIds = new List <int>();

            _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)),
                                                                                       VerificationImageSopInstanceUidValues.Get(context), ref verifImageIds);

            IList <int> planningImageIds = new List <int>();

            _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)),
                                                                                       PlanningImageSopInstanceUidValues.Get(context), ref planningImageIds);

            // (NB for an XVI 5x SRO we only expect a single Planning image & a single Verificationn image
            if (verifImageIds.Count != 1 || planningImageIds.Count != 1)
            {
                _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Verification and/or Planning Image Ids were not correctly found", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                ActivityStatus.Set(context, "FAILED");
            }
            else
            {
                ActivityStatus.Set(context, "SUCCESS");
            }

            foreach (int imageId in verifImageIds)
            {
                _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Verification Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString()));
            }

            foreach (int imageId in planningImageIds)
            {
                _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Planning Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString()));
            }

            PlanningImageIds.Set(context, planningImageIds);
            VerificationImageIds.Set(context, verifImageIds);
            OutUnitId.Set(context, UnitId.Get(context));

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing SRO UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
        }
Ejemplo n.º 19
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string                  localStatus                           = "FAILED";
            string                  _dcmInstanceId                        = UnitId.Get(context);
            int                     nDcmInstanceId                        = Convert.ToInt32(_dcmInstanceId);
            IList <string>          sourceFrameOfReferenceUid             = new List <string>();
            string                  targetFrameOfReferenceUid             = "";
            IList <IList <double> > transformationMatrix                  = new List <IList <double> >();
            IList <string>          transformationComment                 = new List <string>();
            IList <int>             planningImageIdValues                 = new List <int>();
            IList <string>          planningImageSopInstanceUidValues     = new List <string>();
            IList <string>          planningFrameOfReferenceUidValues     = new List <string>();
            IList <string>          verificationImageSopInstanceUidValues = new List <string>();
            string                  spatialRegistrationType               = SpatialRegistrationObjectType.Get(context);
            IList <string>          _structureSetIds                      = StructureSetIds.Get(context);
            IList <string>          structureSetIds;

            if (spatialRegistrationType == "3D" && _structureSetIds != null && _structureSetIds.Count > 0)
            {
                structureSetIds = _structureSetIds;
            }
            else
            {
                structureSetIds = new List <string>();
            }
            byte nRegistrationType = 0;

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            _processSpatialRegistrationObject.ParseTreatmentDeliverySpatialRegistration(nDcmInstanceId, spatialRegistrationType, structureSetIds, ref sourceFrameOfReferenceUid, ref targetFrameOfReferenceUid, ref transformationMatrix, ref transformationComment, ref planningImageSopInstanceUidValues, ref planningImageIdValues, ref planningFrameOfReferenceUidValues, ref verificationImageSopInstanceUidValues, ref nRegistrationType);

            if (sourceFrameOfReferenceUid != null && sourceFrameOfReferenceUid.Count > 0)
            {
                localStatus = "SUCCESS";
            }

            SourceFrameOfReferenceUID.Set(context, sourceFrameOfReferenceUid);
            TargetFrameOfReferenceUID.Set(context, targetFrameOfReferenceUid);
            TransformationMatrix.Set(context, transformationMatrix);
            TransformationMatrixComment.Set(context, transformationComment);
            PlanningImageSopInstanceValues.Set(context, planningImageSopInstanceUidValues);
            PlanningImageIdValues.Set(context, planningImageIdValues);
            PlanningImageFrameOfReferenceUidValues.Set(context, planningFrameOfReferenceUidValues);
            VerificationImageSopInstanceValues.Set(context, verificationImageSopInstanceUidValues);
            RegistrationType.Set(context, nRegistrationType);
            ActivityStatus.Set(context, localStatus);
        }
Ejemplo n.º 20
0
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string localStatus    = "FAILED";
            string _dcmInstanceId = UnitId.Get(context);
            int    nDcmInstanceId = Convert.ToInt32(_dcmInstanceId);

            ActivityStatus.Set(context, localStatus);
            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            bool result = _saveRTSSIsocenter.SaveSpatialIsocenterCoordinates(nDcmInstanceId);

            if (result)
            {
                localStatus = "SUCCESS";
            }
            ActivityStatus.Set(context, localStatus);
        }
        /// <summary> </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            string localStatus = "FAILED";

            ActivityStatus.Set(context, localStatus);
            string _dcmInstanceId = UnitId.Get(context);
            int    nDcmInstanceId = Convert.ToInt32(_dcmInstanceId);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);

            bool result = _processSpatialRegistrationObject.IsSimpleGenericSRO(nDcmInstanceId);

            if (result)
            {
                localStatus = "SUCCESS";
            }

            Result.Set(context, result);
            ActivityStatus.Set(context, localStatus);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="obj"></param>
        protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.Assert(bookmark.Name == BookmarkName);

            context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));

            var refPlanInfo = _processDose.GetReferencedPlanInfo(Int32.Parse(UnitId.Get(context)));
            var tmpList     = _processDose.GetReferenceStructureSetDcmInstances(refPlanInfo.Item1);
            var stringArray = new string[tmpList.Count];

            tmpList.CopyTo(stringArray, 0);
            OutStructureSetIds.Set(context, stringArray);

            OutUnitId.Set(context, UnitId.Get(context));
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name));
        }
        protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            pCancelBookmarkCreation = false;
            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Enter: Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processDose.ConstructedBy));

            var refPlanInfo = _processDose.GetReferencedPlanInfo(Int32.Parse(UnitId.Get(context)));

            var metadata = _processDose.BuildStructureSetMonitorMetadata(refPlanInfo.Item1);

            //
            // If the dataset we are planning to wait is already available
            // skip the bookmark creation and proceed to next activity.
            //
            if (_waitDataWrapper.IsDataAvailable(metadata))
            {
                pCancelBookmarkCreation = true;

                var tmpList     = _processDose.GetReferenceStructureSetDcmInstances(refPlanInfo.Item1);
                var stringArray = new string[tmpList.Count];
                tmpList.CopyTo(stringArray, 0);
                OutStructureSetIds.Set(context, stringArray);

                OutUnitId.Set(context, UnitId.Get(context));
            }
            else
            {
                BookmarkMetadata.Set(context, metadata.ToString());
                _waitDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                     metadata, _waitHandlersRepository.Get("WorkQueueElement"));
            }
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
Ejemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pCancelBookmarkCreation"></param>
        protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            pCancelBookmarkCreation = false;
            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Enter: Processing SRO UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processSpatialRegistrationObject.ConstructedBy));

            var planningSopInstanceUids     = PlanningImageSopInstanceUidValues.Get(context);
            var verificationSopInstanceUids = VerificationImageSopInstanceUidValues.Get(context);

            // we want to wait for both planning and verification instances
            //IList<string> instanceUidsToWaitFor =
            //        planningSopInstanceUids.Concat(verificationSopInstanceUids).ToList();

            string verForUid = string.Empty;

            if (!base._useQueryNotificationFor3DWorkflows)
            {
                verForUid = _processSpatialRegistrationObject.GetLocalizationFrameOfRefFromXVISRO(Int32.Parse(UnitId.Get(context)));
            }
            var metadata = _processSpatialRegistrationObject.BuildMonitorMetadataForXVI5xReferencedDicomData(verForUid, verificationSopInstanceUids);

            //
            // If the dataset we are planning to wait for is already available
            // skip the bookmark creation and proceed to next activity.
            //
            if (_waitSetDataWrapper.IsDataAvailable(metadata))
            {
                pCancelBookmarkCreation = true;

                // get the Image IDs for the Verification and Planning images
                IList <int> verifImageIds = new List <int>();
                _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)),
                                                                                           VerificationImageSopInstanceUidValues.Get(context), ref verifImageIds);

                IList <int> planningImageIds = new List <int>();
                _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)),
                                                                                           PlanningImageSopInstanceUidValues.Get(context), ref planningImageIds);

                // (NB for an XVI 5x SRO we only expect a single Planning image & a single Verification image
                if (verifImageIds.Count != 1 || planningImageIds.Count != 1)
                {
                    _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Verification and/or Planning Image Ids were not correctly found", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                    ActivityStatus.Set(context, "FAILED");
                }
                else
                {
                    ActivityStatus.Set(context, "SUCCESS");
                }

                foreach (int imageId in verifImageIds)
                {
                    _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Verification Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString()));
                }

                foreach (int imageId in planningImageIds)
                {
                    _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Planning Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString()));
                }

                PlanningImageIds.Set(context, planningImageIds);
                VerificationImageIds.Set(context, verifImageIds);
                OutUnitId.Set(context, UnitId.Get(context));

                //if (!base._useQueryNotificationFor3DWorkflows)
                //{
                //    if (!String.IsNullOrEmpty(metadata.DataMonitoringEventId))
                //    {
                //        WaitEventManager.TryRemoveEvent(metadata.DataMonitoringEventId);
                //    }
                //}
            }
            else
            {
                BookmarkMetadata.Set(context, metadata.ToString());
                if (base._useQueryNotificationFor3DWorkflows)
                {
                    _waitSetDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                            metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                }
                else
                {
                    _waitSetDataWrapper.InitiateWaitForDataEvent(context.WorkflowInstanceId, BookmarkName,
                                                                 metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                }
            }

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing SRO UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
        protected override void OnAddToWorklist(NativeActivityContext context, Guid instanceId)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));

            var    bookmarkManager = context.GetExtension <IQWorklistManager>();
            string bookmarkDesc    = BookmarkDesc.Get(context);

            bookmarkDesc = String.IsNullOrEmpty(bookmarkDesc) ? String.Empty : bookmarkDesc.Trim();
            bookmarkManager.AddWorklistItem(BookmarkName, IQBookmarkType.DBMonitor, bookmarkDesc, BookmarkMetadata.Get(context));

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing UnitId: [{1}], Context Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pCancelBookmarkCreation"></param>
        protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            pCancelBookmarkCreation = false;
            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Enter: Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processSpatialRegistrationObject.ConstructedBy));

            var registrationType        = SpatialRegistrationObjectType.Get(context);
            var planningSopInstanceUids = PlanningImageSopInstanceValues.Get(context);

            switch (registrationType)
            {
            case "2D":
                var ref2DImageInfo = _processSpatialRegistrationObject.GetReferenced2DImageInfo(Int32.Parse(UnitId.Get(context)), planningSopInstanceUids);
                foreach (var tuple in ref2DImageInfo)
                {
                    foreach (string refSopInstanceUid in tuple.Item2)
                    {
                        _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Looking for IMG with SOP Instance: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), refSopInstanceUid));
                    }

                    var         metadata = _processSpatialRegistrationObject.BuildMonitorMetadataForReferencedImageData(tuple.Item1, tuple.Item2);
                    IList <int> imageIds = new List <int>();

                    //
                    // If the dataset we are planning to wait is already available
                    // skip the bookmark creation and proceed to next activity.
                    //
                    if (_waitSetDataWrapper.IsDataAvailable(metadata))
                    {
                        pCancelBookmarkCreation = true;
                        _processSpatialRegistrationObject.GetReferencedImageIds(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceValues.Get(context), ref imageIds);
                        if (imageIds.Count > 0)
                        {
                            foreach (int image_id in imageIds)
                            {
                                _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), image_id.ToString()));
                            }
                        }
                        if (imageIds.Count == 0)
                        {
                            _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Image Id list was not set correctly", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                            ActivityStatus.Set(context, "FAILED");
                        }
                        else
                        {
                            ActivityStatus.Set(context, "SUCCESS");
                        }
                        VerificationImageIds.Set(context, imageIds);
                        OutUnitId.Set(context, UnitId.Get(context));
                    }
                    else
                    {
                        // Perform manual processing to see which images are currently available
                        // This needs to handle 1-N cases
                        _processSpatialRegistrationObject.GetReferencedImageIds(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceValues.Get(context), ref imageIds);
                        // based on that result set, set the bookmark if we are still missing some data
                        if (imageIds.Count < VerificationImageSopInstanceValues.Get(context).Count)
                        {
                            BookmarkMetadata.Set(context, metadata.ToString());
                            _waitSetDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                                    metadata,
                                                                    _waitHandlersRepository.Get("WorkQueueElement"));
                        }
                    }
                }
                break;

            case "3D":
                var ref3DImageInfo = _processSpatialRegistrationObject.GetReferenced3DImageInfo(Int32.Parse(UnitId.Get(context)), planningSopInstanceUids);
                int i = 0;
                foreach (var tuple in ref3DImageInfo)
                {
                    if (tuple.Item2.Count == 0)
                    {
                        continue;
                    }

                    foreach (string refSopInstanceUid in tuple.Item3)
                    {
                        _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Looking for DCM SOP Instance: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), refSopInstanceUid));
                    }

                    string verForUid = string.Empty;
                    if (!base._useQueryNotificationFor3DWorkflows)
                    {
                        verForUid = _processSpatialRegistrationObject.GetReferencedFrameOfReferenceInfo(Int32.Parse(UnitId.Get(context)));
                    }
                    var metadata = _processSpatialRegistrationObject.BuildMonitorMetadataForReferencedDicomData(tuple.Item1, tuple.Item2[i], verForUid, tuple.Item3);
                    //
                    // If the dataset we are planning to wait is already available
                    // skip the bookmark creation and proceed to next activity.
                    //
                    if (_waitSetDataWrapper.IsDataAvailable(metadata))
                    {
                        pCancelBookmarkCreation = true;
                        IList <int> imageIds = new List <int>();
                        _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceValues.Get(context), ref imageIds);
                        foreach (int image_id in imageIds)
                        {
                            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), image_id.ToString()));
                        }
                        if (imageIds.Count == 0)
                        {
                            _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Image Id list was not set correctly", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context)));
                            ActivityStatus.Set(context, "FAILED");
                        }
                        else
                        {
                            ActivityStatus.Set(context, "SUCCESS");
                        }
                        VerificationImageIds.Set(context, imageIds);
                        OutUnitId.Set(context, UnitId.Get(context));

                        //if (!base._useQueryNotificationFor3DWorkflows)
                        //{
                        //    if (!String.IsNullOrEmpty(metadata.DataMonitoringEventId))
                        //    {
                        //        WaitEventManager.TryRemoveEvent(metadata.DataMonitoringEventId);
                        //    }
                        //}
                    }
                    else
                    {
                        BookmarkMetadata.Set(context, metadata.ToString());
                        if (base._useQueryNotificationFor3DWorkflows)
                        {
                            _waitSetDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                                    metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                        }
                        else
                        {
                            _waitSetDataWrapper.InitiateWaitForDataEvent(context.WorkflowInstanceId, BookmarkName,
                                                                         metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                        }
                    }
                    i++;
                }
                break;
            }

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pCancelBookmarkCreation"></param>
        protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            pCancelBookmarkCreation = false;
            _logger.Log(EventSeverity.Debug, method,
                        string.Format("[{0}] Enter: Processing UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]",
                                      Thread.CurrentThread.ManagedThreadId,
                                      UnitId.Get(context), BookmarkName, _processSpatialRegistrationObject.ConstructedBy));

            string verificationForUid = _processSpatialRegistrationObject.GetReferencedFrameOfReferenceInfo(Int32.Parse(UnitId.Get(context)));

            var metadata = _processSpatialRegistrationObject.BuildMonitorMetadataForStructureSetData(verificationForUid);

            //
            // If the dataset we are planning to wait is already available
            // skip the bookmark creation and proceed to next activity.
            //
            if (_waitDataWrapper.IsDataAvailable(metadata))
            {
                pCancelBookmarkCreation = true;
                string referencedSiteId = _processSpatialRegistrationObject.GetReferencedSiteId(Int32.Parse(UnitId.Get(context)));
                if (referencedSiteId != "")
                {
                    //get DcmInstanceId of planning structure set. The verification FrameofRefUid is
                    //passed as an argument but is redundant. (confusing also)
                    var tmpList = _processSpatialRegistrationObject.GetReferenceStructureSetDcmInstances(verificationForUid, referencedSiteId, Int32.Parse(UnitId.Get(context)));

                    foreach (string rtssId in tmpList)
                    {
                        _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing UnitId: [{1}], Found structure set id: [{2}]",
                                                                               Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), rtssId));
                    }
                    OutStructureSetIds.Set(context, tmpList);

                    OutUnitId.Set(context, UnitId.Get(context));

                    //if (!base._useQueryNotificationFor3DWorkflows)
                    //{
                    //    if (!String.IsNullOrEmpty(metadata.DataMonitoringEventId))
                    //    {
                    //        WaitEventManager.TryRemoveEvent(metadata.DataMonitoringEventId);
                    //    }
                    //}
                }
            }
            else
            {
                BookmarkMetadata.Set(context, metadata.ToString());
                if (base._useQueryNotificationFor3DWorkflows)
                {
                    _waitDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName,
                                                         metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                }
                else
                {
                    _waitDataWrapper.InitiateWaitForDataEvent(context.WorkflowInstanceId, BookmarkName,
                                                              metadata, _waitHandlersRepository.Get("WorkQueueElement"));
                }
            }
            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing UnitId: [{1}], Bookmark name: [{2}]",
                                                                   Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName));
        }
Ejemplo n.º 28
0
 /// <summary> </summary>
 /// <param name="context"></param>
 protected override void DoWork(CodeActivityContext context)
 {
     context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this);
     ReferencedPlanSOPInstances.Set(context, _createDoseVolume.GetReferencedPlanInfo(Int32.Parse(UnitId.Get(context))).Item2);
 }