private static List <OrderNote> CreateReplaceDestinationNotes(Order order, IPersistenceContext context)
        {
            var where = new OrderSearchCriteria();
            where.CancelInfo.ReplacementOrder.EqualTo(order);

            // expect 0 or 1 results
            var replacedOrder = CollectionUtils.FirstElement(context.GetBroker <IOrderBroker>().Find(where));

            if (replacedOrder == null)
            {
                return(new List <OrderNote>());
            }

            var text = string.Format(SR.OrderNoteOrderReplacedBy, replacedOrder.AccessionNumber);
            var note = OrderNote.CreateVirtualNote(
                order,
                OrderNote.Categories.General,
                replacedOrder.CancelInfo.CancelledBy,
                text,
                replacedOrder.EndTime.Value);

            return(new List <OrderNote> {
                note
            });
        }
        private static OrderNote CreateMergeDestinationNote(ICollection <Order> sourceOrders, Order order, Staff staff, DateTime time)
        {
            var text = sourceOrders.Count == 1 ?
                       string.Format(SR.OrderNoteOrderMergeFrom, CollectionUtils.FirstElement(sourceOrders).AccessionNumber)
                                                : string.Format(SR.OrderNoteOrdersMergeFrom, StringUtilities.Combine(sourceOrders, ", ", o => o.AccessionNumber));

            return(OrderNote.CreateVirtualNote(order, OrderNote.Categories.General, staff, text, time));
        }
        private static OrderNote CreateMergeSourceNote(Order order)
        {
            var destOrder = order.MergeInfo.MergeDestinationOrder;
            var text      = string.Format(SR.OrderNoteOrderMergeTo, destOrder.AccessionNumber);

            return(OrderNote.CreateVirtualNote(
                       order,
                       OrderNote.Categories.General,
                       order.MergeInfo.MergedBy,
                       text,
                       order.MergeInfo.MergedTime.Value));
        }
        private static OrderNote CreateReplaceSourceNote(Order order)
        {
            var replacementOrder = order.CancelInfo.ReplacementOrder;
            var reason           = order.CancelInfo.Reason;
            var text             = string.Format(SR.OrderNoteOrderReplacedByReason, replacementOrder.AccessionNumber, reason.Value);

            return(OrderNote.CreateVirtualNote(
                       order,
                       OrderNote.Categories.General,
                       order.CancelInfo.CancelledBy,
                       text,
                       order.EndTime.Value));
        }