Exemple #1
0
        /// <summary>
        /// Links a <see cref="Procedure"/> to this report, meaning that the protocol covers
        /// this radiology procedure.
        /// </summary>
        /// <param name="procedure"></param>
        protected internal virtual void LinkProcedure(Procedure procedure)
        {
            if (_procedures.Contains(procedure))
            {
                throw new WorkflowException("The procedure is already associated with this protocol.");
            }

            // does the procedure already have a non-new protocol?
            Protocol otherProtocol = procedure.ActiveProtocol;

            if (otherProtocol.IsNew() == false && !this.Equals(otherProtocol))
            {
                throw new WorkflowException("Cannot link this procedure because it already has an active protocol.");
            }

            _procedures.Add(procedure);
            procedure.Protocols.Add(this);

            // dissociate the otherProtocol from the procedure
            // (ideally we should delete otherProtocol too, but how do we do that from here?)
            otherProtocol.Procedures.Remove(procedure);
        }