public PatientAllergySynchronizeHelper(PatientAllergyAssembler assembler, IPersistenceContext context)
     : base(true, true)
 {
     _assembler = assembler;
     _context   = context;
 }
Exemplo n.º 2
0
        public PatientProfileDetail CreatePatientProfileDetail(PatientProfile profile,
                                                               IPersistenceContext context,
                                                               bool includeAddresses,
                                                               bool includeContactPersons,
                                                               bool includeEmailAddresses,
                                                               bool includeTelephoneNumbers,
                                                               bool includeNotes,
                                                               bool includeAttachments,
                                                               bool includeAllergies)
        {
            var healthcardAssembler = new HealthcardAssembler();
            var nameAssembler       = new PersonNameAssembler();
            var addressAssembler    = new AddressAssembler();
            var telephoneAssembler  = new TelephoneNumberAssembler();

            var detail = new PatientProfileDetail
            {
                PatientRef        = profile.Patient.GetRef(),
                PatientProfileRef = profile.GetRef(),
                Mrn                = new MrnAssembler().CreateMrnDetail(profile.Mrn),
                Healthcard         = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard),
                Name               = nameAssembler.CreatePersonNameDetail(profile.Name),
                Sex                = EnumUtils.GetEnumValueInfo(profile.Sex, context),
                DateOfBirth        = profile.DateOfBirth,
                DeathIndicator     = profile.DeathIndicator,
                TimeOfDeath        = profile.TimeOfDeath,
                PrimaryLanguage    = EnumUtils.GetEnumValueInfo(profile.PrimaryLanguage),
                Religion           = EnumUtils.GetEnumValueInfo(profile.Religion),
                CurrentHomeAddress = addressAssembler.CreateAddressDetail(profile.CurrentHomeAddress, context),
                CurrentWorkAddress = addressAssembler.CreateAddressDetail(profile.CurrentWorkAddress, context),
                CurrentHomePhone   = telephoneAssembler.CreateTelephoneDetail(profile.CurrentHomePhone, context),
                CurrentWorkPhone   = telephoneAssembler.CreateTelephoneDetail(profile.CurrentWorkPhone, context),
                BillingInformation = profile.BillingInformation
            };

            if (includeTelephoneNumbers)
            {
                detail.TelephoneNumbers = new List <TelephoneDetail>();
                foreach (var t in profile.TelephoneNumbers)
                {
                    detail.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneDetail(t, context));
                }
            }

            if (includeAddresses)
            {
                detail.Addresses = new List <AddressDetail>();
                foreach (var a in profile.Addresses)
                {
                    detail.Addresses.Add(addressAssembler.CreateAddressDetail(a, context));
                }
            }

            if (includeContactPersons)
            {
                var contactPersonAssembler = new ContactPersonAssembler();
                detail.ContactPersons = new List <ContactPersonDetail>();
                foreach (var cp in profile.ContactPersons)
                {
                    detail.ContactPersons.Add(contactPersonAssembler.CreateContactPersonDetail(cp));
                }
            }

            if (includeEmailAddresses)
            {
                var emailAssembler = new EmailAddressAssembler();
                detail.EmailAddresses = new List <EmailAddressDetail>();
                foreach (var e in profile.EmailAddresses)
                {
                    detail.EmailAddresses.Add(emailAssembler.CreateEmailAddressDetail(e, context));
                }
            }

            if (includeNotes)
            {
                var noteAssembler = new PatientNoteAssembler();
                detail.Notes = new List <PatientNoteDetail>();
                foreach (var n in profile.Patient.Notes)
                {
                    detail.Notes.Add(noteAssembler.CreateNoteDetail(n, context));
                }
            }

            if (includeAttachments)
            {
                var attachmentAssembler = new PatientAttachmentAssembler();
                detail.Attachments = new List <AttachmentSummary>();
                foreach (var a in profile.Patient.Attachments)
                {
                    detail.Attachments.Add(attachmentAssembler.CreatePatientAttachmentSummary(a, context));
                }
            }

            if (includeAllergies)
            {
                var allergyAssembler = new PatientAllergyAssembler();
                detail.Allergies = new List <PatientAllergyDetail>();
                foreach (var a in profile.Patient.Allergies)
                {
                    detail.Allergies.Add(allergyAssembler.CreateAllergyDetail(a));
                }
            }

            return(detail);
        }