/// <summary>
        /// Re-assigns this step to the specified scheduled performer.
        /// </summary>
        /// <remarks>
        /// If this step is currently Scheduled, the scheduled performer is simply changed
        /// to the specified performer.  If this step is in-progress or suspended, then
        /// it is discontinued, and a new step is scheduled and assigned to the specified performer.
        /// </remarks>
        /// <param name="performer"></param>
        /// <returns>A new step with the assigned performer.</returns>
        public virtual ProcedureStep Reassign(Staff performer)
        {
            if (this.IsTerminated)
            {
                throw new WorkflowException("Cannot re-assign a terminated procedure step.");
            }

            if (this.State == ActivityStatus.SC)
            {
                this.Assign(performer);
                return(this);
            }
            else
            {
                this.Discontinue();
                ProcedureStep newStep = CreateScheduledCopy();

                if (this.Scheduling != null)
                {
                    newStep.Schedule(this.Scheduling.StartTime, this.Scheduling.EndTime);
                }

                newStep.Assign(performer);
                return(newStep);
            }
        }
Example #2
0
        public override void SaveInstance(ProcedureStep prototype, XmlElement xmlNode)
        {
            ModalityProcedureStep step = (ModalityProcedureStep)prototype;

            xmlNode.SetAttribute("description", step.Description);
            xmlNode.SetAttribute("modality", step.Modality.Id);
        }
Example #3
0
        /// <summary>
        /// Initialize this worklist item from the specified procedure step and related entities.
        /// </summary>
        /// <param name="step"></param>
        /// <param name="timeField"></param>
        /// <remarks>
        /// This method is not efficient for generating a large number of worklist items from a large set of procedure steps,
        /// because it causes a large number of secondary references and collections to be initiliazed.
        /// Use <see cref="InitializeFromTuple"/> instead.
        /// </remarks>
        public virtual void InitializeFromProcedureStep(ProcedureStep step, WorklistItemField timeField)
        {
            var rp = step.Procedure;
            var o  = step.Procedure.Order;
            var v  = step.Procedure.Order.Visit;
            var p  = step.Procedure.Order.Patient;
            var pp = step.Procedure.Order.Patient.GetProfile(rp.PerformingFacility);

            this.ProcedureStepRef  = step.GetRef();
            this.ProcedureRef      = rp.GetRef();
            this.OrderRef          = o.GetRef();
            this.PatientRef        = p.GetRef();
            this.PatientProfileRef = pp.GetRef();
            this.Mrn                   = pp.Mrn;
            this.PatientName           = pp.Name;
            this.AccessionNumber       = o.AccessionNumber;
            this.OrderPriority         = o.Priority;
            this.PatientClass          = v.PatientClass;
            this.DiagnosticServiceName = o.DiagnosticService.Name;
            this.ProcedureName         = rp.Type.Name;
            this.ProcedurePortable     = rp.Portable;
            this.ProcedureLaterality   = rp.Laterality;
            this.ProcedureStepName     = step.Name;
            this.ActivityStatus        = step.State;
            this.Time                  = GetTimeValue(step, timeField);
        }
Example #4
0
        /// <summary>
        /// Adds a procedure step.  Use this method rather than adding directly to the <see cref="ProcedureSteps"/>
        /// collection.
        /// </summary>
        /// <param name="step"></param>
        public virtual void AddProcedureStep(ProcedureStep step)
        {
            if ((step.Procedure != null && step.Procedure != this) || step.State != ActivityStatus.SC)
            {
                throw new ArgumentException("Only new ProcedureStep objects may be added to a procedure.");
            }

            step.Procedure = this;
            this.ProcedureSteps.Add(step);
        }
Example #5
0
        /// <summary>
        /// Gets the value for the specified time field from the specified procedure step or its associated entities.
        /// </summary>
        /// <param name="step"></param>
        /// <param name="timeField"></param>
        /// <returns></returns>
        protected virtual DateTime?GetTimeValue(ProcedureStep step, WorklistItemField timeField)
        {
            if (timeField == WorklistItemField.OrderSchedulingRequestTime)
            {
                return(step.Procedure.Order.SchedulingRequestTime);
            }

            if (timeField == WorklistItemField.ProcedureScheduledStartTime)
            {
                return(step.Procedure.ScheduledStartTime);
            }

            if (timeField == WorklistItemField.ProcedureCheckInTime)
            {
                return(step.Procedure.ProcedureCheckIn.CheckInTime);
            }

            if (timeField == WorklistItemField.ProcedureCheckOutTime)
            {
                return(step.Procedure.ProcedureCheckIn.CheckOutTime);
            }

            if (timeField == WorklistItemField.ProcedureStartTime)
            {
                return(step.Procedure.StartTime);
            }

            if (timeField == WorklistItemField.ProcedureEndTime)
            {
                return(step.Procedure.EndTime);
            }

            if (timeField == WorklistItemField.ProcedureStepCreationTime)
            {
                return(step.CreationTime);
            }

            if (timeField == WorklistItemField.ProcedureStepScheduledStartTime)
            {
                return(step.Scheduling != null ? step.Scheduling.StartTime : null);
            }

            if (timeField == WorklistItemField.ProcedureStepStartTime)
            {
                return(step.StartTime);
            }

            if (timeField == WorklistItemField.ProcedureStepEndTime)
            {
                return(step.EndTime);
            }

            throw new WorkflowException("Invalid time field");
        }
Example #6
0
		public ProcedureStepSummary CreateProcedureStepSummary(ProcedureStep ps, IPersistenceContext context)
		{
			var assembler = new ProcedureAssembler();
			var modalityAssembler = new ModalityAssembler();
			return new ProcedureStepSummary(
				ps.GetRef(),
				ps.Name,
				EnumUtils.GetEnumValueInfo(ps.State, context),
				ps.StartTime,
				ps.EndTime,
				ps.Is<ModalityProcedureStep>() ? modalityAssembler.CreateModalitySummary(ps.As<ModalityProcedureStep>().Modality) : null,
				assembler.CreateProcedureSummary(ps.Procedure, context));
		}
Example #7
0
		protected override bool IsRelatedStep(ProcedureStep step)
		{
			// can't have relatives if no report
			if(this.Report == null)
				return false;

			// relatives must be reporting steps
			if (!step.Is<ReportingProcedureStep>())
				return false;

			// check if tied to same report
			ReportingProcedureStep that = step.As<ReportingProcedureStep>();
			return that.Report != null && Equals(this.Report, that.Report);
		}
Example #8
0
		protected override bool IsRelatedStep(ProcedureStep step)
		{
			// can't have relatives if no protocol
			if (this.Protocol == null)
				return false;

			// relatives must be protocol steps
			if (!step.Is<ProtocolProcedureStep>())
				return false;

			// check if tied to same protocol
			ProtocolProcedureStep that = step.As<ProtocolProcedureStep>();
			return that.Protocol != null && Equals(this.Protocol, that.Protocol);
		}
        /// <summary>
        /// Links this step to the specified other step, effectively discontinuing this step.
        /// </summary>
        /// <param name="other"></param>
        public virtual void LinkTo(ProcedureStep other)
        {
            if (this.State != ActivityStatus.SC)
            {
                throw new WorkflowException("Cannot link to another step because this step has already been started.");
            }

            // link the procedure to the specified other step
            other.LinkProcedure(_procedure);

            // record the step that we linked to
            _linkStep = other;

            // discontinue this step so it doesn't show up in any worklists
            this.Discontinue();
        }
Example #10
0
        protected override bool IsRelatedStep(ProcedureStep step)
        {
            // can't have relatives if no protocol
            if (this.Protocol == null)
            {
                return(false);
            }

            // relatives must be protocol steps
            if (!step.Is <ProtocolProcedureStep>())
            {
                return(false);
            }

            // check if tied to same protocol
            ProtocolProcedureStep that = step.As <ProtocolProcedureStep>();

            return(that.Protocol != null && Equals(this.Protocol, that.Protocol));
        }
Example #11
0
		public ProcedureStepDetail CreateProcedureStepDetail(ProcedureStep ps, IPersistenceContext context)
		{
			var staffAssembler = new StaffAssembler();
			var modalityAssembler = new ModalityAssembler();

			return new ProcedureStepDetail(
				ps.GetRef(),
				ps.Name,
				ps.GetClass().Name,
				ps.Is<ModalityProcedureStep>() ? ps.As<ModalityProcedureStep>().Description : null,
				EnumUtils.GetEnumValueInfo(ps.State, context),
				ps.CreationTime,
				ps.Scheduling == null ? null : ps.Scheduling.StartTime,
				ps.StartTime,
				ps.EndTime,
				ps.AssignedStaff == null ? null : staffAssembler.CreateStaffSummary(ps.AssignedStaff, context),
				ps.PerformingStaff == null ? null : staffAssembler.CreateStaffSummary(ps.PerformingStaff, context),
				ps.Is<ModalityProcedureStep>() ? modalityAssembler.CreateModalitySummary(ps.As<ModalityProcedureStep>().Modality) : null);
		}
        protected override bool IsRelatedStep(ProcedureStep step)
        {
            // can't have relatives if no report
            if (this.Report == null)
            {
                return(false);
            }

            // relatives must be reporting steps
            if (!step.Is <ReportingProcedureStep>())
            {
                return(false);
            }

            // check if tied to same report
            ReportingProcedureStep that = step.As <ReportingProcedureStep>();

            return(that.Report != null && Equals(this.Report, that.Report));
        }
Example #13
0
		protected override bool IsRelatedStep(ProcedureStep step)
		{
			// modality steps do not have related steps
			return false;
		}
Example #14
0
 public override void SaveInstance(ProcedureStep prototype, XmlElement xmlNode)
 {
     ModalityProcedureStep step = (ModalityProcedureStep) prototype;
     xmlNode.SetAttribute("description", step.Description);
     xmlNode.SetAttribute("modality", step.Modality.Id);
 }
Example #15
0
		/// <summary>
		/// Initialize this worklist item from the specified procedure step and related entities.
		/// </summary>
		/// <param name="step"></param>
		/// <param name="timeField"></param>
		/// <remarks>
		/// This method is not efficient for generating a large number of worklist items from a large set of procedure steps,
		/// because it causes a large number of secondary references and collections to be initiliazed.
		/// Use <see cref="InitializeFromTuple"/> instead.
		/// </remarks>
		public virtual void InitializeFromProcedureStep(ProcedureStep step, WorklistItemField timeField)
		{
			var rp = step.Procedure;
			var o = step.Procedure.Order;
			var v = step.Procedure.Order.Visit;
			var p = step.Procedure.Order.Patient;
			var pp = step.Procedure.Order.Patient.GetProfile(rp.PerformingFacility);

			this.ProcedureStepRef = step.GetRef();
			this.ProcedureRef = rp.GetRef();
			this.OrderRef = o.GetRef();
			this.PatientRef = p.GetRef();
			this.PatientProfileRef = pp.GetRef();
			this.Mrn = pp.Mrn;
			this.PatientName = pp.Name;
			this.AccessionNumber = o.AccessionNumber;
			this.OrderPriority = o.Priority;
			this.PatientClass = v.PatientClass;
			this.DiagnosticServiceName = o.DiagnosticService.Name;
			this.ProcedureName = rp.Type.Name;
			this.ProcedurePortable = rp.Portable;
			this.ProcedureLaterality = rp.Laterality;
			this.ProcedureStepName = step.Name;
			this.ActivityStatus = step.State;
			this.Time = GetTimeValue(step, timeField);
		}
Example #16
0
		/// <summary>
		/// Gets the value for the specified time field from the specified procedure step or its associated entities.
		/// </summary>
		/// <param name="step"></param>
		/// <param name="timeField"></param>
		/// <returns></returns>
		protected virtual DateTime? GetTimeValue(ProcedureStep step, WorklistItemField timeField)
		{
			if (timeField == WorklistItemField.OrderSchedulingRequestTime)
				return step.Procedure.Order.SchedulingRequestTime;

			if (timeField == WorklistItemField.ProcedureScheduledStartTime)
				return step.Procedure.ScheduledStartTime;

			if (timeField == WorklistItemField.ProcedureCheckInTime)
				return step.Procedure.ProcedureCheckIn.CheckInTime;

			if (timeField == WorklistItemField.ProcedureCheckOutTime)
				return step.Procedure.ProcedureCheckIn.CheckOutTime;

			if (timeField == WorklistItemField.ProcedureStartTime)
				return step.Procedure.StartTime;

			if (timeField == WorklistItemField.ProcedureEndTime)
				return step.Procedure.EndTime;

			if (timeField == WorklistItemField.ProcedureStepCreationTime)
				return step.CreationTime;

			if (timeField == WorklistItemField.ProcedureStepScheduledStartTime)
				return step.Scheduling != null ? step.Scheduling.StartTime : null;

			if (timeField == WorklistItemField.ProcedureStepStartTime)
				return step.StartTime;

			if (timeField == WorklistItemField.ProcedureStepEndTime)
				return step.EndTime;

			throw new WorkflowException("Invalid time field");
		}
Example #17
0
 protected override bool IsRelatedStep(ProcedureStep step)
 {
     // modality steps do not have related steps
     return(false);
 }
Example #18
0
		protected override bool IsRelatedStep(ProcedureStep step)
		{
			// registration steps do not have related steps
			return false;
		}
Example #19
0
 protected override bool IsRelatedStep(ProcedureStep step)
 {
     // documentation steps do not have related steps
     return(false);
 }
 public override void SaveInstance(ProcedureStep prototype, XmlElement xmlNode)
 {
 }
Example #21
0
 /// <summary>
 /// Creates an XML representation of the specified procedure-step prototype.
 /// </summary>
 /// <param name="prototype"></param>
 /// <param name="xmlNode"></param>
 public abstract void SaveInstance(ProcedureStep prototype, XmlElement xmlNode);
 /// <summary>
 /// Tests whether the specified procedure step is directly related to this step,
 /// in the sense that it targets the same work artifact (eg. protocol, report, etc.)
 /// </summary>
 /// <param name="step"></param>
 /// <returns></returns>
 protected abstract bool IsRelatedStep(ProcedureStep step);
Example #23
0
        /// <summary>
		/// Links this step to the specified other step, effectively discontinuing this step.
		/// </summary>
		/// <param name="other"></param>
		public virtual void LinkTo(ProcedureStep other)
		{
			if (this.State != ActivityStatus.SC)
				throw new WorkflowException("Cannot link to another step because this step has already been started.");

			// link the procedure to the specified other step
			other.LinkProcedure(_procedure);

			// record the step that we linked to
			_linkStep = other;

			// discontinue this step so it doesn't show up in any worklists
			this.Discontinue();
		}
Example #24
0
		/// <summary>
		/// Tests whether the specified procedure step is directly related to this step,
		/// in the sense that it targets the same work artifact (eg. protocol, report, etc.)
		/// </summary>
		/// <param name="step"></param>
		/// <returns></returns>
		protected abstract bool IsRelatedStep(ProcedureStep step);
Example #25
0
		/// <summary>
		/// Adds a procedure step.  Use this method rather than adding directly to the <see cref="ProcedureSteps"/>
		/// collection.
		/// </summary>
		/// <param name="step"></param>
		public virtual void AddProcedureStep(ProcedureStep step)
		{
			if ((step.Procedure != null && step.Procedure != this) || step.State != ActivityStatus.SC)
				throw new ArgumentException("Only new ProcedureStep objects may be added to a procedure.");

			step.Procedure = this;
			this.ProcedureSteps.Add(step);
		}
 private void CheckStatus(ActivityStatus status, ProcedureStep o)
 {
     Assert.AreEqual(status, o.State, string.Format("Exptected {0} status {1}", o.GetClass().Name, status.ToString()));
 }
Example #27
0
		public override void SaveInstance(ProcedureStep prototype, XmlElement xmlNode)
		{
		}