public StaffGroupDetail CreateDetail(StaffGroup staffGroup, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); WorklistAssembler worklistAssembler = new WorklistAssembler(); IList <Worklist> worklists = context.GetBroker <IWorklistBroker>().Find(staffGroup); return(new StaffGroupDetail( staffGroup.GetRef(), staffGroup.Name, staffGroup.Description, staffGroup.Elective, CollectionUtils.Map <Staff, StaffSummary>(staffGroup.Members, delegate(Staff staff) { return staffAssembler.CreateStaffSummary(staff, context); }), CollectionUtils.Map <Worklist, WorklistSummary>(worklists, delegate(Worklist worklist) { return worklistAssembler.GetWorklistSummary(worklist, context); }), staffGroup.Deactivated )); }
public ModalityPerformedProcedureStepDetail CreateModalityPerformedProcedureStepDetail(ModalityPerformedProcedureStep mpps, IPersistenceContext context) { var assembler = new ModalityProcedureStepAssembler(); // include the details of each MPS in the mpps summary var mpsDetails = CollectionUtils.Map(mpps.Activities, (ProcedureStep mps) => assembler.CreateProcedureStepSummary(mps.As<ModalityProcedureStep>(), context)); var dicomSeriesAssembler = new DicomSeriesAssembler(); var dicomSeries = dicomSeriesAssembler.GetDicomSeriesDetails(mpps.DicomSeries); StaffSummary mppsPerformer = null; var performer = mpps.Performer as ProcedureStepPerformer; if (performer != null) { var staffAssembler = new StaffAssembler(); mppsPerformer = staffAssembler.CreateStaffSummary(performer.Staff, context); } return new ModalityPerformedProcedureStepDetail( mpps.GetRef(), EnumUtils.GetEnumValueInfo(mpps.State, context), mpps.StartTime, mpps.EndTime, mppsPerformer, mpsDetails, dicomSeries, ExtendedPropertyUtils.Copy(mpps.ExtendedProperties)); }
public ProtocolDetail CreateProtocolDetail(Protocol protocol, IPersistenceContext context) { var detail = new ProtocolDetail(); var staffAssembler = new StaffAssembler(); detail.ProtocolRef = protocol.GetRef(); detail.Author = protocol.Author != null ? staffAssembler.CreateStaffSummary(protocol.Author, context) : null; detail.Supervisor = protocol.Supervisor != null ? staffAssembler.CreateStaffSummary(protocol.Supervisor, context) : null; detail.Status = EnumUtils.GetEnumValueInfo(protocol.Status, context); detail.Urgency = EnumUtils.GetEnumValueInfo(protocol.Urgency); detail.RejectReason = EnumUtils.GetEnumValueInfo(protocol.RejectReason); detail.Codes = protocol.Codes == null ? new List<ProtocolCodeSummary>() : CollectionUtils.Map<ProtocolCode, ProtocolCodeSummary>(protocol.Codes, CreateProtocolCodeSummary); var procedureAssembler = new ProcedureAssembler(); detail.Procedures = protocol.Procedures == null ? new List<ProcedureDetail>() : CollectionUtils.Map<Procedure, ProcedureDetail>( protocol.Procedures, procedure => procedureAssembler.CreateProcedureDetail(procedure, delegate { return false; }, false, context)); return detail; }
public ModalityPerformedProcedureStepDetail CreateModalityPerformedProcedureStepDetail(ModalityPerformedProcedureStep mpps, IPersistenceContext context) { var assembler = new ModalityProcedureStepAssembler(); // include the details of each MPS in the mpps summary var mpsDetails = CollectionUtils.Map(mpps.Activities, (ProcedureStep mps) => assembler.CreateProcedureStepSummary(mps.As <ModalityProcedureStep>(), context)); var dicomSeriesAssembler = new DicomSeriesAssembler(); var dicomSeries = dicomSeriesAssembler.GetDicomSeriesDetails(mpps.DicomSeries); StaffSummary mppsPerformer = null; var performer = mpps.Performer as ProcedureStepPerformer; if (performer != null) { var staffAssembler = new StaffAssembler(); mppsPerformer = staffAssembler.CreateStaffSummary(performer.Staff, context); } return(new ModalityPerformedProcedureStepDetail( mpps.GetRef(), EnumUtils.GetEnumValueInfo(mpps.State, context), mpps.StartTime, mpps.EndTime, mppsPerformer, mpsDetails, dicomSeries, ExtendedPropertyUtils.Copy(mpps.ExtendedProperties))); }
private OrderNoteDetail.StaffRecipientDetail CreateStaffRecipientDetail(Staff staff, bool acknowledged, NoteAcknowledgement acknowledgement, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); return(new OrderNoteDetail.StaffRecipientDetail( staffAssembler.CreateStaffSummary(staff, context), acknowledged, acknowledged ? acknowledgement.Time : null)); }
public AttachmentSummary CreatePatientAttachmentSummary(PatientAttachment attachment, IPersistenceContext context) { AttachedDocumentAssembler attachedDocAssembler = new AttachedDocumentAssembler(); StaffAssembler staffAssembler = new StaffAssembler(); return(new AttachmentSummary( EnumUtils.GetEnumValueInfo(attachment.Category), staffAssembler.CreateStaffSummary(attachment.AttachedBy, context), attachment.AttachedTime, attachedDocAssembler.CreateAttachedDocumentSummary(attachment.Document))); }
private OrderNoteDetail.GroupRecipientDetail CreateGroupRecipientDetail(StaffGroup group, bool acknowledged, NoteAcknowledgement acknowledgement, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler staffGroupAssembler = new StaffGroupAssembler(); return(new OrderNoteDetail.GroupRecipientDetail( staffGroupAssembler.CreateSummary(group), acknowledged, acknowledged ? acknowledgement.Time : null, acknowledged ? staffAssembler.CreateStaffSummary(acknowledgement.Staff, context) : null)); }
public WorklistSummary GetWorklistSummary(Worklist worklist, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler groupAssembler = new StaffGroupAssembler(); return new WorklistSummary( worklist.GetRef(), worklist.Name, worklist.Description, worklist.ClassName, Worklist.GetCategory(worklist.GetClass()), Worklist.GetDisplayName(worklist.GetClass()), worklist.Owner.IsStaffOwner ? staffAssembler.CreateStaffSummary(worklist.Owner.Staff, context) : null, worklist.Owner.IsGroupOwner ? groupAssembler.CreateSummary(worklist.Owner.Group) : null); }
public WorklistSummary GetWorklistSummary(Worklist worklist, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler groupAssembler = new StaffGroupAssembler(); return(new WorklistSummary( worklist.GetRef(), worklist.Name, worklist.Description, worklist.ClassName, Worklist.GetCategory(worklist.GetClass()), Worklist.GetDisplayName(worklist.GetClass()), worklist.Owner.IsStaffOwner ? staffAssembler.CreateStaffSummary(worklist.Owner.Staff, context) : null, worklist.Owner.IsGroupOwner ? groupAssembler.CreateSummary(worklist.Owner.Group) : null)); }
/// <summary> /// Creates an <see cref="OrderNoteSummary"/> from a <see cref="OrderNote"/>. /// </summary> /// <param name="orderNote"></param> /// <param name="context"></param> /// <returns></returns> public OrderNoteSummary CreateOrderNoteSummary(OrderNote orderNote, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler groupAssembler = new StaffGroupAssembler(); return(new OrderNoteSummary( orderNote.OID == null ? null : orderNote.GetRef(), // may be a virtual order note, which is transient orderNote.Category, orderNote.CreationTime, orderNote.PostTime, staffAssembler.CreateStaffSummary(orderNote.Author, context), orderNote.OnBehalfOfGroup == null ? null : groupAssembler.CreateSummary(orderNote.OnBehalfOfGroup), orderNote.IsFullyAcknowledged, orderNote.Urgent, orderNote.Body)); }
public PatientNoteDetail CreateNoteDetail(PatientNote note, IPersistenceContext context) { if (note == null) return null; PatientNoteCategoryAssembler categoryAssembler = new PatientNoteCategoryAssembler(); StaffAssembler staffAssembler = new StaffAssembler(); return new PatientNoteDetail( note.GetRef(), note.Comment, categoryAssembler.CreateNoteCategorySummary(note.Category, context), staffAssembler.CreateStaffSummary(note.Author, context), note.CreationTime, note.ValidRange.From, note.ValidRange.Until, note.IsExpired); }
/// <summary> /// Creates an <see cref="OrderNoteDetail"/> from a <see cref="OrderNote"/>. /// </summary> /// <param name="orderNote"></param> /// <param name="currentUserStaff"></param> /// <param name="context"></param> /// <returns></returns> public OrderNoteDetail CreateOrderNoteDetail(OrderNote orderNote, Staff currentUserStaff, IPersistenceContext context) { List <OrderNoteDetail.StaffRecipientDetail> staffRecipients = new List <OrderNoteDetail.StaffRecipientDetail>(); List <OrderNoteDetail.GroupRecipientDetail> groupRecipients = new List <OrderNoteDetail.GroupRecipientDetail>(); // if the note has been posted, construct the recipients list from the postings, so we can get the ACK status if (orderNote.IsPosted) { foreach (NotePosting posting in orderNote.Postings) { if (posting is GroupNotePosting) { groupRecipients.Add( CreateGroupRecipientDetail(((GroupNotePosting)posting).Recipient, posting.IsAcknowledged, posting.AcknowledgedBy, context)); } else { staffRecipients.Add( CreateStaffRecipientDetail(((StaffNotePosting)posting).Recipient, posting.IsAcknowledged, posting.AcknowledgedBy, context)); } } } StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler groupAssembler = new StaffGroupAssembler(); return(new OrderNoteDetail( orderNote.GetRef(), orderNote.Category, orderNote.CreationTime, orderNote.PostTime, staffAssembler.CreateStaffSummary(orderNote.Author, context), orderNote.OnBehalfOfGroup == null ? null : groupAssembler.CreateSummary(orderNote.OnBehalfOfGroup), orderNote.Urgent, staffRecipients, groupRecipients, orderNote.Body, currentUserStaff == null ? false : orderNote.CanAcknowledge(currentUserStaff))); }
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); }
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)); }
public PatientNoteDetail CreateNoteDetail(PatientNote note, IPersistenceContext context) { if (note == null) { return(null); } PatientNoteCategoryAssembler categoryAssembler = new PatientNoteCategoryAssembler(); StaffAssembler staffAssembler = new StaffAssembler(); return(new PatientNoteDetail( note.GetRef(), note.Comment, categoryAssembler.CreateNoteCategorySummary(note.Category, context), staffAssembler.CreateStaffSummary(note.Author, context), note.CreationTime, note.ValidRange.From, note.ValidRange.Until, note.IsExpired)); }
public ReportPartDetail CreateReportPartDetail(ReportPart reportPart, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); ReportPartDetail summary = new ReportPartDetail( reportPart.GetRef(), reportPart.Index, reportPart.Index > 0, EnumUtils.GetEnumValueInfo(reportPart.Status, context), reportPart.CreationTime, reportPart.PreliminaryTime, reportPart.CompletedTime, reportPart.CancelledTime, reportPart.Supervisor == null ? null : staffAssembler.CreateStaffSummary(reportPart.Supervisor, context), reportPart.Interpreter == null ? null : staffAssembler.CreateStaffSummary(reportPart.Interpreter, context), reportPart.Transcriber == null ? null : staffAssembler.CreateStaffSummary(reportPart.Transcriber, context), reportPart.TranscriptionSupervisor == null ? null : staffAssembler.CreateStaffSummary(reportPart.TranscriptionSupervisor, context), reportPart.Verifier == null ? null : staffAssembler.CreateStaffSummary(reportPart.Verifier, context), EnumUtils.GetEnumValueInfo(reportPart.TranscriptionRejectReason), ExtendedPropertyUtils.Copy(reportPart.ExtendedProperties)); return(summary); }
public ReportPartDetail CreateReportPartDetail(ReportPart reportPart, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); ReportPartDetail summary = new ReportPartDetail( reportPart.GetRef(), reportPart.Index, reportPart.Index > 0, EnumUtils.GetEnumValueInfo(reportPart.Status, context), reportPart.CreationTime, reportPart.PreliminaryTime, reportPart.CompletedTime, reportPart.CancelledTime, reportPart.Supervisor == null ? null : staffAssembler.CreateStaffSummary(reportPart.Supervisor, context), reportPart.Interpreter == null ? null : staffAssembler.CreateStaffSummary(reportPart.Interpreter, context), reportPart.Transcriber == null ? null : staffAssembler.CreateStaffSummary(reportPart.Transcriber, context), reportPart.TranscriptionSupervisor == null ? null : staffAssembler.CreateStaffSummary(reportPart.TranscriptionSupervisor, context), reportPart.Verifier == null ? null : staffAssembler.CreateStaffSummary(reportPart.Verifier, context), EnumUtils.GetEnumValueInfo(reportPart.TranscriptionRejectReason), ExtendedPropertyUtils.Copy(reportPart.ExtendedProperties)); return summary; }
public OrderNoteboxItemSummary CreateSummary(OrderNoteboxItem item, IPersistenceContext context) { var mrnAssembler = new MrnAssembler(); var nameAssembler = new PersonNameAssembler(); var staffAssembler = new StaffAssembler(); var groupAssembler = new StaffGroupAssembler(); var staffRecipients = new List<StaffSummary>(); var groupRecipients = new List<StaffGroupSummary>(); foreach (var recipient in item.Recipients) { if (recipient is Staff) staffRecipients.Add(staffAssembler.CreateStaffSummary((Staff)recipient, context)); if (recipient is StaffGroup) groupRecipients.Add(groupAssembler.CreateSummary((StaffGroup)recipient)); } return new OrderNoteboxItemSummary( item.NoteRef, item.OrderRef, item.PatientRef, item.PatientProfileRef, mrnAssembler.CreateMrnDetail(item.Mrn), nameAssembler.CreatePersonNameDetail(item.PatientName), item.DateOfBirth, item.AccessionNumber, item.DiagnosticServiceName, item.Category, item.Urgent, item.PostTime, staffAssembler.CreateStaffSummary(item.Author, context), item.OnBehalfOfGroup == null ? null : groupAssembler.CreateSummary(item.OnBehalfOfGroup), item.IsAcknowledged, staffRecipients, groupRecipients); }
public ProcedurePlanDetail CreateProcedurePlanSummary(Order order, IPersistenceContext context) { ProcedurePlanDetail detail = new ProcedurePlanDetail(); ProcedureAssembler assembler = new ProcedureAssembler(); StaffAssembler staffAssembler = new StaffAssembler(); detail.OrderRef = order.GetRef(); detail.Procedures = CollectionUtils.Map<Procedure, ProcedureDetail>( order.Procedures, delegate(Procedure rp) { return assembler.CreateProcedureDetail( rp, delegate(ProcedureStep ps) { return ps.Is<ModalityProcedureStep>(); }, // only MPS are relevant here false, context); }); detail.DiagnosticServiceSummary = new DiagnosticServiceSummary(order.DiagnosticService.GetRef(), order.DiagnosticService.Id, order.DiagnosticService.Name, order.DiagnosticService.Deactivated); return detail; }
public ProcedurePlanDetail CreateProcedurePlanSummary(Order order, IPersistenceContext context) { ProcedurePlanDetail detail = new ProcedurePlanDetail(); ProcedureAssembler assembler = new ProcedureAssembler(); StaffAssembler staffAssembler = new StaffAssembler(); detail.OrderRef = order.GetRef(); detail.Procedures = CollectionUtils.Map <Procedure, ProcedureDetail>( order.Procedures, delegate(Procedure rp) { return(assembler.CreateProcedureDetail( rp, delegate(ProcedureStep ps) { return ps.Is <ModalityProcedureStep>(); }, // only MPS are relevant here false, context)); }); detail.DiagnosticServiceSummary = new DiagnosticServiceSummary(order.DiagnosticService.GetRef(), order.DiagnosticService.Id, order.DiagnosticService.Name, order.DiagnosticService.Deactivated); return(detail); }
/// <summary> /// Creates order detail document including only specified parts. /// </summary> public OrderDetail CreateOrderDetail(Order order, CreateOrderDetailOptions options, IPersistenceContext context) { var orderDetail = new OrderDetail(); var practitionerAssembler = new ExternalPractitionerAssembler(); var facilityAssembler = new FacilityAssembler(); var dsAssembler = new DiagnosticServiceAssembler(); var procedureAssembler = new ProcedureAssembler(); var staffAssembler = new StaffAssembler(); orderDetail.OrderRef = order.GetRef(); orderDetail.PatientRef = order.Patient.GetRef(); if (options.IncludeVisit) { var visitAssembler = new VisitAssembler(); orderDetail.Visit = visitAssembler.CreateVisitDetail(order.Visit, context); } orderDetail.PlacerNumber = order.PlacerNumber; orderDetail.AccessionNumber = order.AccessionNumber; orderDetail.DiagnosticService = dsAssembler.CreateSummary(order.DiagnosticService); orderDetail.EnteredTime = order.EnteredTime; orderDetail.EnteredBy = order.EnteredBy == null ? null : staffAssembler.CreateStaffSummary(order.EnteredBy, context); orderDetail.EnteredComment = order.EnteredComment; orderDetail.SchedulingRequestTime = order.SchedulingRequestTime; orderDetail.OrderingPractitioner = practitionerAssembler.CreateExternalPractitionerSummary(order.OrderingPractitioner, context); orderDetail.OrderingFacility = facilityAssembler.CreateFacilitySummary(order.OrderingFacility); orderDetail.ReasonForStudy = order.ReasonForStudy; orderDetail.OrderPriority = EnumUtils.GetEnumValueInfo(order.Priority, context); if (order.CancelInfo != null) { orderDetail.CancelReason = order.CancelInfo.Reason == null ? null : EnumUtils.GetEnumValueInfo(order.CancelInfo.Reason); orderDetail.CancelledBy = order.CancelInfo.CancelledBy == null ? null : staffAssembler.CreateStaffSummary(order.CancelInfo.CancelledBy, context); orderDetail.CancelComment = order.CancelInfo.Comment; } if (options.IncludeProcedures) { orderDetail.Procedures = CollectionUtils.Map(order.Procedures, (Procedure p) => procedureAssembler.CreateProcedureDetail(p, context)); } if (options.IncludeNotes) { var orderNoteAssembler = new OrderNoteAssembler(); var orderNotes = new List<OrderNote>(OrderNote.GetNotesForOrder(order, options.NoteCategoriesFilter, options.IncludeVirtualNotes)); // sort notes by post-time (guaranteed non-null because only "posted" notes are in this collection) orderNotes.Sort((x, y) => x.PostTime.Value.CompareTo(y.PostTime.Value)); // Put most recent notes first orderNotes.Reverse(); orderDetail.Notes = CollectionUtils.Map<OrderNote, OrderNoteSummary>( orderNotes, note => orderNoteAssembler.CreateOrderNoteSummary(note, context)); } if (options.IncludeAttachments) { var orderAttachmentAssembler = new OrderAttachmentAssembler(); var attachments = new List<OrderAttachment>(order.Attachments); orderDetail.Attachments = CollectionUtils.Map<OrderAttachment, AttachmentSummary>( attachments, a => orderAttachmentAssembler.CreateOrderAttachmentSummary(a, context)); } if (options.IncludeResultRecipients) { var resultRecipientAssembler = new ResultRecipientAssembler(); var resultRecipients = new List<ResultRecipient>(order.ResultRecipients); orderDetail.ResultRecipients = CollectionUtils.Map<ResultRecipient, ResultRecipientDetail>( resultRecipients, r => resultRecipientAssembler.CreateResultRecipientDetail(r, context)); } if (options.IncludeExtendedProperties) { orderDetail.ExtendedProperties = ExtendedPropertyUtils.Copy(order.ExtendedProperties); } return orderDetail; }
/// <summary> /// Creates order detail document including only specified parts. /// </summary> public OrderDetail CreateOrderDetail(Order order, CreateOrderDetailOptions options, IPersistenceContext context) { var orderDetail = new OrderDetail(); var practitionerAssembler = new ExternalPractitionerAssembler(); var facilityAssembler = new FacilityAssembler(); var dsAssembler = new DiagnosticServiceAssembler(); var procedureAssembler = new ProcedureAssembler(); var staffAssembler = new StaffAssembler(); orderDetail.OrderRef = order.GetRef(); orderDetail.PatientRef = order.Patient.GetRef(); if (options.IncludeVisit) { var visitAssembler = new VisitAssembler(); orderDetail.Visit = visitAssembler.CreateVisitDetail(order.Visit, context); } orderDetail.PlacerNumber = order.PlacerNumber; orderDetail.AccessionNumber = order.AccessionNumber; orderDetail.DiagnosticService = dsAssembler.CreateSummary(order.DiagnosticService); orderDetail.EnteredTime = order.EnteredTime; orderDetail.EnteredBy = order.EnteredBy == null ? null : staffAssembler.CreateStaffSummary(order.EnteredBy, context); orderDetail.EnteredComment = order.EnteredComment; orderDetail.SchedulingRequestTime = order.SchedulingRequestTime; orderDetail.OrderingPractitioner = practitionerAssembler.CreateExternalPractitionerSummary(order.OrderingPractitioner, context); orderDetail.OrderingFacility = facilityAssembler.CreateFacilitySummary(order.OrderingFacility); orderDetail.ReasonForStudy = order.ReasonForStudy; orderDetail.OrderPriority = EnumUtils.GetEnumValueInfo(order.Priority, context); if (order.CancelInfo != null) { orderDetail.CancelReason = order.CancelInfo.Reason == null ? null : EnumUtils.GetEnumValueInfo(order.CancelInfo.Reason); orderDetail.CancelledBy = order.CancelInfo.CancelledBy == null ? null : staffAssembler.CreateStaffSummary(order.CancelInfo.CancelledBy, context); orderDetail.CancelComment = order.CancelInfo.Comment; } if (options.IncludeProcedures) { orderDetail.Procedures = CollectionUtils.Map(order.Procedures, (Procedure p) => procedureAssembler.CreateProcedureDetail(p, context)); } if (options.IncludeNotes) { var orderNoteAssembler = new OrderNoteAssembler(); var orderNotes = new List <OrderNote>(OrderNote.GetNotesForOrder(order, options.NoteCategoriesFilter, options.IncludeVirtualNotes)); // sort notes by post-time (guaranteed non-null because only "posted" notes are in this collection) orderNotes.Sort((x, y) => x.PostTime.Value.CompareTo(y.PostTime.Value)); // Put most recent notes first orderNotes.Reverse(); orderDetail.Notes = CollectionUtils.Map <OrderNote, OrderNoteSummary>( orderNotes, note => orderNoteAssembler.CreateOrderNoteSummary(note, context)); } if (options.IncludeAttachments) { var orderAttachmentAssembler = new OrderAttachmentAssembler(); var attachments = new List <OrderAttachment>(order.Attachments); orderDetail.Attachments = CollectionUtils.Map <OrderAttachment, AttachmentSummary>( attachments, a => orderAttachmentAssembler.CreateOrderAttachmentSummary(a, context)); } if (options.IncludeResultRecipients) { var resultRecipientAssembler = new ResultRecipientAssembler(); var resultRecipients = new List <ResultRecipient>(order.ResultRecipients); orderDetail.ResultRecipients = CollectionUtils.Map <ResultRecipient, ResultRecipientDetail>( resultRecipients, r => resultRecipientAssembler.CreateResultRecipientDetail(r, context)); } if (options.IncludeExtendedProperties) { orderDetail.ExtendedProperties = ExtendedPropertyUtils.Copy(order.ExtendedProperties); } return(orderDetail); }