Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void UpdateStaff(StaffDetail detail, Staff staff, bool updateElectiveGroups, bool updateNonElectiveGroups, IPersistenceContext context)
        {
            PersonNameAssembler      assembler          = new PersonNameAssembler();
            EmailAddressAssembler    emailAssembler     = new EmailAddressAssembler();
            TelephoneNumberAssembler telephoneAssembler = new TelephoneNumberAssembler();
            AddressAssembler         addressAssembler   = new AddressAssembler();

            staff.Id   = detail.StaffId;
            staff.Type = EnumUtils.GetEnumValue <StaffTypeEnum>(detail.StaffType, context);
            assembler.UpdatePersonName(detail.Name, staff.Name);
            staff.Sex           = EnumUtils.GetEnumValue <Sex>(detail.Sex);
            staff.Title         = detail.Title;
            staff.LicenseNumber = detail.LicenseNumber;
            staff.BillingNumber = detail.BillingNumber;
            staff.Deactivated   = detail.Deactivated;
            staff.UserName      = detail.UserName;

            staff.TelephoneNumbers.Clear();
            if (detail.TelephoneNumbers != null)
            {
                foreach (TelephoneDetail phoneDetail in detail.TelephoneNumbers)
                {
                    staff.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneNumber(phoneDetail));
                }
            }

            staff.Addresses.Clear();
            if (detail.Addresses != null)
            {
                foreach (AddressDetail addressDetail in detail.Addresses)
                {
                    staff.Addresses.Add(addressAssembler.CreateAddress(addressDetail));
                }
            }

            staff.EmailAddresses.Clear();
            if (detail.EmailAddresses != null)
            {
                foreach (EmailAddressDetail emailAddressDetail in detail.EmailAddresses)
                {
                    staff.EmailAddresses.Add(emailAssembler.CreateEmailAddress(emailAddressDetail));
                }
            }

            ExtendedPropertyUtils.Update(staff.ExtendedProperties, detail.ExtendedProperties);

            if (updateElectiveGroups)
            {
                // update elective groups
                UpdateStaffGroups(detail, staff,
                                  delegate(StaffGroupSummary summary) { return(summary.IsElective); },
                                  delegate(StaffGroup group) { return(group.Elective); },
                                  context);
            }

            if (updateNonElectiveGroups)
            {
                // update non-elective groups
                UpdateStaffGroups(detail, staff,
                                  delegate(StaffGroupSummary summary) { return(!summary.IsElective); },
                                  delegate(StaffGroup group) { return(!group.Elective); },
                                  context);
            }
        }
Exemplo n.º 3
0
 public CompositeIdentifierDetail CreateVisitNumberDetail(VisitNumber vn)
 {
     return(new CompositeIdentifierDetail(vn.Id, EnumUtils.GetEnumValueInfo(vn.AssigningAuthority)));
 }