public ReportDetail CreateReportDetail(Report report, bool includeCancelledParts, IPersistenceContext context)
        {
            ReportDetail detail = new ReportDetail();

            detail.ReportRef    = report.GetRef();
            detail.ReportStatus = EnumUtils.GetEnumValueInfo(report.Status, context);

            ProcedureAssembler rpAssembler = new ProcedureAssembler();

            detail.Procedures = CollectionUtils.Map <Procedure, ProcedureDetail>(report.Procedures,
                                                                                 delegate(Procedure p)
            {
                return(rpAssembler.CreateProcedureDetail(
                           p,
                           delegate(ProcedureStep ps) { return ps.Is <ReportingProcedureStep>(); }, // only Reporting steps are relevant
                           false,                                                                   // exclude protocols
                           context));
            });

            List <ReportPartDetail> parts = CollectionUtils.Map <ReportPart, ReportPartDetail>(report.Parts,
                                                                                               delegate(ReportPart part) { return(CreateReportPartDetail(part, context)); });

            detail.Parts = includeCancelledParts ? parts :
                           CollectionUtils.Select(parts,
                                                  delegate(ReportPartDetail rpp)
            {
                return(rpp.Status.Code.Equals(ReportPartStatus.X.ToString()) == false);
            });

            return(detail);
        }
Example #2
0
        public ReportDetail CreateReportDetail(Report report, bool includeCancelledParts, IPersistenceContext context)
        {
            ReportDetail detail = new ReportDetail();
            detail.ReportRef = report.GetRef();
            detail.ReportStatus = EnumUtils.GetEnumValueInfo(report.Status, context);

            ProcedureAssembler rpAssembler = new ProcedureAssembler();
            detail.Procedures = CollectionUtils.Map<Procedure, ProcedureDetail>(report.Procedures,
                delegate(Procedure p)
                {
                    return rpAssembler.CreateProcedureDetail(
                        p,
                        delegate(ProcedureStep ps) { return ps.Is<ReportingProcedureStep>(); },	// only Reporting steps are relevant
                        false,	// exclude protocols
                        context);
                });

            List<ReportPartDetail> parts = CollectionUtils.Map<ReportPart, ReportPartDetail>(report.Parts,
                delegate(ReportPart part) { return CreateReportPartDetail(part, context); });

            detail.Parts = includeCancelledParts ? parts :
                CollectionUtils.Select(parts,
                    delegate(ReportPartDetail rpp)
                    {
                        return rpp.Status.Code.Equals(ReportPartStatus.X.ToString()) == false;
                    });

            return detail;
        }
Example #3
0
		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 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;
        }
Example #5
0
        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);
        }
Example #6
0
        /// <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);
        }
Example #7
0
		/// <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;
		}