public CompleteModalityPerformedProcedureStepResponse CompleteModalityPerformedProcedureStep(CompleteModalityPerformedProcedureStepRequest request)
        {
            var mpps = this.PersistenceContext.Load <ModalityPerformedProcedureStep>(request.Mpps.ModalityPerformendProcedureStepRef);

            // update extended properties (should this be in an assembler?)
            ExtendedPropertyUtils.Update(mpps.ExtendedProperties, request.Mpps.ExtendedProperties);

            var dicomSeriesAssembler = new DicomSeriesAssembler();

            dicomSeriesAssembler.SynchronizeDicomSeries(mpps, request.Mpps.DicomSeries, this.PersistenceContext);

            var op = new CompleteModalityPerformedProcedureStepOperation();

            op.Execute(mpps, request.CompletedTime, new PersistentWorkflow(PersistenceContext));

            this.PersistenceContext.SynchState();

            // Drill back to order so we can refresh procedure plan
            var onePs = CollectionUtils.FirstElement(mpps.Activities).As <ProcedureStep>();

            var planAssembler = new ProcedurePlanAssembler();
            var stepAssembler = new ModalityPerformedProcedureStepAssembler();

            return(new CompleteModalityPerformedProcedureStepResponse(
                       planAssembler.CreateProcedurePlanSummary(onePs.Procedure.Order, this.PersistenceContext),
                       stepAssembler.CreateModalityPerformedProcedureStepDetail(mpps, this.PersistenceContext)));
        }
        public SaveOrderDocumentationDataResponse SaveOrderDocumentationData(SaveOrderDocumentationDataRequest request)
        {
            var order = this.PersistenceContext.Load <Order>(request.OrderRef);

            ExtendedPropertyUtils.Update(order.ExtendedProperties, request.OrderExtendedProperties);

            var dicomSeriesAssembler = new DicomSeriesAssembler();

            foreach (var detail in request.ModalityPerformedProcedureSteps)
            {
                var mpps = this.PersistenceContext.Load <ModalityPerformedProcedureStep>(detail.ModalityPerformendProcedureStepRef);
                ExtendedPropertyUtils.Update(mpps.ExtendedProperties, detail.ExtendedProperties);
                dicomSeriesAssembler.SynchronizeDicomSeries(mpps, detail.DicomSeries, this.PersistenceContext);
            }

            // add new order notes
            var noteAssembler = new OrderNoteAssembler();

            noteAssembler.SynchronizeOrderNotes(order, request.OrderNotes, CurrentUserStaff, this.PersistenceContext);

            // assign all procedures for this order to the specified interpreter (or unassign them, if null)
            var interpreter = request.AssignedInterpreter == null
                                ? null
                                : this.PersistenceContext.Load <Staff>(request.AssignedInterpreter.StaffRef, EntityLoadFlags.Proxy);

            foreach (var procedure in order.Procedures)
            {
                if (procedure.IsPerformed)
                {
                    var interpretationStep = GetPendingInterpretationStep(procedure);
                    if (interpretationStep != null)
                    {
                        interpretationStep.Assign(interpreter);
                    }
                }
            }

            this.PersistenceContext.SynchState();

            var planAssembler = new ProcedurePlanAssembler();

            return(new SaveOrderDocumentationDataResponse(planAssembler.CreateProcedurePlanSummary(order, this.PersistenceContext)));
        }
        public DiscontinueModalityPerformedProcedureStepResponse DiscontinueModalityPerformedProcedureStep(DiscontinueModalityPerformedProcedureStepRequest request)
        {
            var mpps = this.PersistenceContext.Load <ModalityPerformedProcedureStep>(request.Mpps.ModalityPerformendProcedureStepRef);

            // update extended properties (should this be in an assembler?)
            ExtendedPropertyUtils.Update(mpps.ExtendedProperties, request.Mpps.ExtendedProperties);

            var dicomSeriesAssembler = new DicomSeriesAssembler();

            dicomSeriesAssembler.SynchronizeDicomSeries(mpps, request.Mpps.DicomSeries, this.PersistenceContext);

            var op = new DiscontinueModalityPerformedProcedureStepOperation();

            op.Execute(mpps, request.DiscontinuedTime, new PersistentWorkflow(PersistenceContext));

            this.PersistenceContext.SynchState();

            // If discontinuing the MPPS caused any associated procedures to be discontinued,
            // create an HL7 event.
            foreach (var activity in mpps.Activities)
            {
                var procedure = activity.As <ProcedureStep>().Procedure;
                if (procedure.IsTerminated)
                {
                    LogicalHL7Event.ProcedureCancelled.EnqueueEvents(procedure);
                }
            }

            // Drill back to order so we can refresh procedure plan
            var order = CollectionUtils.FirstElement(mpps.Activities).As <ProcedureStep>().Procedure.Order;

            var planAssembler = new ProcedurePlanAssembler();
            var stepAssembler = new ModalityPerformedProcedureStepAssembler();

            return(new DiscontinueModalityPerformedProcedureStepResponse(
                       planAssembler.CreateProcedurePlanSummary(order, this.PersistenceContext),
                       stepAssembler.CreateModalityPerformedProcedureStepDetail(mpps, this.PersistenceContext)));
        }
示例#4
0
		public SaveOrderDocumentationDataResponse SaveOrderDocumentationData(SaveOrderDocumentationDataRequest request)
		{
			var order = this.PersistenceContext.Load<Order>(request.OrderRef);

			ExtendedPropertyUtils.Update(order.ExtendedProperties, request.OrderExtendedProperties);

			var dicomSeriesAssembler = new DicomSeriesAssembler();
			foreach (var detail in request.ModalityPerformedProcedureSteps)
			{
				var mpps = this.PersistenceContext.Load<ModalityPerformedProcedureStep>(detail.ModalityPerformendProcedureStepRef);
				ExtendedPropertyUtils.Update(mpps.ExtendedProperties, detail.ExtendedProperties);
				dicomSeriesAssembler.SynchronizeDicomSeries(mpps, detail.DicomSeries, this.PersistenceContext);
			}

			// add new order notes
			var noteAssembler = new OrderNoteAssembler();
			noteAssembler.SynchronizeOrderNotes(order, request.OrderNotes, CurrentUserStaff, this.PersistenceContext);

			// assign all procedures for this order to the specified interpreter (or unassign them, if null)
			var interpreter = request.AssignedInterpreter == null
				? null
				: this.PersistenceContext.Load<Staff>(request.AssignedInterpreter.StaffRef, EntityLoadFlags.Proxy);
			foreach (var procedure in order.Procedures)
			{
				if (procedure.IsPerformed)
				{
					var interpretationStep = GetPendingInterpretationStep(procedure);
					if (interpretationStep != null)
					{
						interpretationStep.Assign(interpreter);
					}
				}
			}

			this.PersistenceContext.SynchState();

			var planAssembler = new ProcedurePlanAssembler();
			return new SaveOrderDocumentationDataResponse(planAssembler.CreateProcedurePlanSummary(order, this.PersistenceContext));
		}
示例#5
0
		public DiscontinueModalityPerformedProcedureStepResponse DiscontinueModalityPerformedProcedureStep(DiscontinueModalityPerformedProcedureStepRequest request)
		{
			var mpps = this.PersistenceContext.Load<ModalityPerformedProcedureStep>(request.Mpps.ModalityPerformendProcedureStepRef);

			// update extended properties (should this be in an assembler?)
			ExtendedPropertyUtils.Update(mpps.ExtendedProperties, request.Mpps.ExtendedProperties);

			var dicomSeriesAssembler = new DicomSeriesAssembler();
			dicomSeriesAssembler.SynchronizeDicomSeries(mpps, request.Mpps.DicomSeries, this.PersistenceContext);

			var op = new DiscontinueModalityPerformedProcedureStepOperation();
			op.Execute(mpps, request.DiscontinuedTime, new PersistentWorkflow(PersistenceContext));

			this.PersistenceContext.SynchState();

			// If discontinuing the MPPS caused any associated procedures to be discontinued,
			// create an HL7 event.
			foreach (var activity in mpps.Activities)
			{
				var procedure = activity.As<ProcedureStep>().Procedure;
				if(procedure.IsTerminated)
					LogicalHL7Event.ProcedureCancelled.EnqueueEvents(procedure);
			}
	
			// Drill back to order so we can refresh procedure plan
			var order = CollectionUtils.FirstElement(mpps.Activities).As<ProcedureStep>().Procedure.Order;

			var planAssembler = new ProcedurePlanAssembler();
			var stepAssembler = new ModalityPerformedProcedureStepAssembler();
			return new DiscontinueModalityPerformedProcedureStepResponse(
				planAssembler.CreateProcedurePlanSummary(order, this.PersistenceContext),
				stepAssembler.CreateModalityPerformedProcedureStepDetail(mpps, this.PersistenceContext));
		}
示例#6
0
		public CompleteModalityPerformedProcedureStepResponse CompleteModalityPerformedProcedureStep(CompleteModalityPerformedProcedureStepRequest request)
		{
			var mpps = this.PersistenceContext.Load<ModalityPerformedProcedureStep>(request.Mpps.ModalityPerformendProcedureStepRef);

			// update extended properties (should this be in an assembler?)
			ExtendedPropertyUtils.Update(mpps.ExtendedProperties, request.Mpps.ExtendedProperties);

			var dicomSeriesAssembler = new DicomSeriesAssembler();
			dicomSeriesAssembler.SynchronizeDicomSeries(mpps, request.Mpps.DicomSeries, this.PersistenceContext);

			var op = new CompleteModalityPerformedProcedureStepOperation();
			op.Execute(mpps, request.CompletedTime, new PersistentWorkflow(PersistenceContext));

			this.PersistenceContext.SynchState();

			// Drill back to order so we can refresh procedure plan
			var onePs = CollectionUtils.FirstElement(mpps.Activities).As<ProcedureStep>();

			var planAssembler = new ProcedurePlanAssembler();
			var stepAssembler = new ModalityPerformedProcedureStepAssembler();
			return new CompleteModalityPerformedProcedureStepResponse(
				planAssembler.CreateProcedurePlanSummary(onePs.Procedure.Order, this.PersistenceContext),
				stepAssembler.CreateModalityPerformedProcedureStepDetail(mpps, this.PersistenceContext));
		}