public CompleteDowntimeProcedureResponse CompleteDowntimeProcedure(CompleteDowntimeProcedureRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.ProcedureRef, "ProcedureRef"); var procedure = this.PersistenceContext.Load<Procedure>(request.ProcedureRef); if (request.ReportProvided) { Platform.CheckMemberIsSet(request.InterpreterRef, "InterpreterRef"); var interpreter = this.PersistenceContext.Load<Staff>(request.InterpreterRef); var transcriptionist = request.TranscriptionistRef == null ? null : this.PersistenceContext.Load<Staff>(request.TranscriptionistRef); // find the relevant interpretation step for this procedure var interpStep = procedure. GetProcedureStep(ps => ps.Is<InterpretationStep>() && ps.State == ActivityStatus.SC). As<InterpretationStep>(); // ideally this should not happen, but what do we do if it does? if (interpStep == null) throw new RequestValidationException("Report cannot be submitted for this procedure. It may have been submitted previously."); // start interpretation, using specified interpreter // the report will end up in their drafts folder var startOp = new Operations.StartInterpretation(); startOp.Execute(interpStep, interpreter, new List<InterpretationStep>(), new PersistentWorkflow(this.PersistenceContext)); // save the report data SaveReportHelper(request.ReportPartExtendedProperties, interpStep, null, false); ValidateReportTextExists(interpStep); // set the transcriptionist if known interpStep.ReportPart.Transcriber = transcriptionist; } // flip the downtime mode switch procedure.DowntimeRecoveryMode = false; return new CompleteDowntimeProcedureResponse(); }
public StartInterpretationResponse StartInterpretation(StartInterpretationRequest request) { var interpretation = this.PersistenceContext.Load<InterpretationStep>(request.InterpretationStepRef, EntityLoadFlags.CheckVersion); var staffAssignedBeforeStart = interpretation.AssignedStaff; var linkedInterpretations = new List<InterpretationStep>(); if (request.LinkedInterpretationStepRefs != null && request.LinkedInterpretationStepRefs.Count > 0) { linkedInterpretations = CollectionUtils.Map<EntityRef, InterpretationStep>( request.LinkedInterpretationStepRefs, stepRef => this.PersistenceContext.Load<InterpretationStep>(stepRef)); } var op = new Operations.StartInterpretation(); op.Execute(interpretation, this.CurrentUserStaff, linkedInterpretations, new PersistentWorkflow(this.PersistenceContext)); this.PersistenceContext.SynchState(); return new StartInterpretationResponse(interpretation.GetRef(), staffAssignedBeforeStart == null ? null : interpretation.AssignedStaff.GetRef()); }