public StaffDetail CreateStaffDetail(Staff staff, IPersistenceContext context)
        {
            PersonNameAssembler      assembler          = new PersonNameAssembler();
            StaffGroupAssembler      groupAssembler     = new StaffGroupAssembler();
            EmailAddressAssembler    emailAssembler     = new EmailAddressAssembler();
            TelephoneNumberAssembler telephoneAssembler = new TelephoneNumberAssembler();
            AddressAssembler         addressAssembler   = new AddressAssembler();

            return(new StaffDetail(
                       staff.GetRef(),
                       staff.Id,
                       EnumUtils.GetEnumValueInfo(staff.Type),
                       assembler.CreatePersonNameDetail(staff.Name),
                       EnumUtils.GetEnumValueInfo(staff.Sex, context),
                       staff.Title,
                       staff.LicenseNumber,
                       staff.BillingNumber,
                       CollectionUtils.Map <TelephoneNumber, TelephoneDetail>(
                           staff.TelephoneNumbers,
                           delegate(TelephoneNumber tn) { return telephoneAssembler.CreateTelephoneDetail(tn, context); }),
                       CollectionUtils.Map <Address, AddressDetail>(
                           staff.Addresses,
                           delegate(Address a) { return addressAssembler.CreateAddressDetail(a, context); }),
                       CollectionUtils.Map <EmailAddress, EmailAddressDetail>(
                           staff.EmailAddresses,
                           delegate(EmailAddress ea) { return emailAssembler.CreateEmailAddressDetail(ea, context); }),
                       CollectionUtils.Map <StaffGroup, StaffGroupSummary>(
                           staff.Groups,
                           delegate(StaffGroup group) { return groupAssembler.CreateSummary(group); }),
                       ExtendedPropertyUtils.Copy(staff.ExtendedProperties),
                       staff.Deactivated,
                       staff.UserName));
        }
Esempio n. 2
0
		public StaffDetail CreateStaffDetail(Staff staff, IPersistenceContext context)
		{
			PersonNameAssembler assembler = new PersonNameAssembler();
			StaffGroupAssembler groupAssembler = new StaffGroupAssembler();
			EmailAddressAssembler emailAssembler = new EmailAddressAssembler();
			TelephoneNumberAssembler telephoneAssembler = new TelephoneNumberAssembler();
			AddressAssembler addressAssembler = new AddressAssembler();

			return new StaffDetail(
				staff.GetRef(),
				staff.Id,
				EnumUtils.GetEnumValueInfo(staff.Type),
				assembler.CreatePersonNameDetail(staff.Name),
				EnumUtils.GetEnumValueInfo(staff.Sex, context),
				staff.Title,
				staff.LicenseNumber,
				staff.BillingNumber,
				CollectionUtils.Map<TelephoneNumber, TelephoneDetail>(
					staff.TelephoneNumbers,
					delegate(TelephoneNumber tn) { return telephoneAssembler.CreateTelephoneDetail(tn, context); }),
				CollectionUtils.Map<Address, AddressDetail>(
					staff.Addresses,
					delegate(Address a) { return addressAssembler.CreateAddressDetail(a, context); }),
				CollectionUtils.Map<EmailAddress, EmailAddressDetail>(
					staff.EmailAddresses,
					delegate(EmailAddress ea) { return emailAssembler.CreateEmailAddressDetail(ea, context); }),
				CollectionUtils.Map<StaffGroup, StaffGroupSummary>(
					staff.Groups,
					delegate(StaffGroup group) { return groupAssembler.CreateSummary(group); }),
				ExtendedPropertyUtils.Copy(staff.ExtendedProperties),
				staff.Deactivated,
				staff.UserName);
		}
        public ExternalPractitionerContactPointDetail CreateExternalPractitionerContactPointDetail(ExternalPractitionerContactPoint contactPoint,
                                                                                                   IPersistenceContext context)
        {
            var telephoneNumberAssembler = new TelephoneNumberAssembler();
            var addressAssembler         = new AddressAssembler();
            var emailAddressAssembler    = new EmailAddressAssembler();

            var currentPhone        = contactPoint.CurrentPhoneNumber;
            var currentFax          = contactPoint.CurrentFaxNumber;
            var currentAddress      = contactPoint.CurrentAddress;
            var currentEmailAddress = contactPoint.CurrentEmailAddress;

            return(new ExternalPractitionerContactPointDetail(
                       contactPoint.GetRef(),
                       contactPoint.Name,
                       contactPoint.Description,
                       contactPoint.IsDefaultContactPoint,
                       EnumUtils.GetEnumValueInfo(contactPoint.PreferredResultCommunicationMode, context),
                       EnumUtils.GetEnumValueInfo(contactPoint.InformationAuthority),
                       CollectionUtils.Map(contactPoint.TelephoneNumbers, (TelephoneNumber phone) => telephoneNumberAssembler.CreateTelephoneDetail(phone, context)),
                       CollectionUtils.Map(contactPoint.Addresses, (Address address) => addressAssembler.CreateAddressDetail(address, context)),
                       CollectionUtils.Map(contactPoint.EmailAddresses, (EmailAddress emailAddress) => emailAddressAssembler.CreateEmailAddressDetail(emailAddress, context)),
                       currentPhone == null ? null : telephoneNumberAssembler.CreateTelephoneDetail(currentPhone, context),
                       currentFax == null ? null : telephoneNumberAssembler.CreateTelephoneDetail(currentFax, context),
                       currentAddress == null ? null : addressAssembler.CreateAddressDetail(currentAddress, context),
                       currentEmailAddress == null ? null : emailAddressAssembler.CreateEmailAddressDetail(currentEmailAddress, context),
                       CreateExternalPractitionerContactPointSummary(contactPoint.GetUltimateMergeDestination()),
                       contactPoint.IsMerged,
                       contactPoint.Deactivated));
        }
        public void UpdateExternalPractitionerContactPoint(ExternalPractitionerContactPointDetail detail, ExternalPractitionerContactPoint contactPoint, IPersistenceContext context)
        {
            contactPoint.Name                             = detail.Name;
            contactPoint.Description                      = detail.Description;
            contactPoint.IsDefaultContactPoint            = detail.IsDefaultContactPoint;
            contactPoint.PreferredResultCommunicationMode = EnumUtils.GetEnumValue <ResultCommunicationMode>(detail.PreferredResultCommunicationMode);
            contactPoint.InformationAuthority             = EnumUtils.GetEnumValue <InformationAuthorityEnum>(detail.InformationAuthority, context);
            contactPoint.MarkDeactivated(detail.Deactivated);

            var phoneAssembler        = new TelephoneNumberAssembler();
            var addressAssembler      = new AddressAssembler();
            var emailAddressAssembler = new EmailAddressAssembler();

            contactPoint.TelephoneNumbers.Clear();
            if (detail.TelephoneNumbers != null)
            {
                foreach (var phoneDetail in detail.TelephoneNumbers)
                {
                    contactPoint.TelephoneNumbers.Add(phoneAssembler.CreateTelephoneNumber(phoneDetail));
                }
            }

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

            contactPoint.EmailAddresses.Clear();
            if (detail.EmailAddresses != null)
            {
                foreach (var emailAddressDetail in detail.EmailAddresses)
                {
                    contactPoint.EmailAddresses.Add(emailAddressAssembler.CreateEmailAddress(emailAddressDetail));
                }
            }
        }
		public void UpdateExternalPractitionerContactPoint(ExternalPractitionerContactPointDetail detail, ExternalPractitionerContactPoint contactPoint, IPersistenceContext context)
		{
			contactPoint.Name = detail.Name;
			contactPoint.Description = detail.Description;
			contactPoint.IsDefaultContactPoint = detail.IsDefaultContactPoint;
			contactPoint.PreferredResultCommunicationMode = EnumUtils.GetEnumValue<ResultCommunicationMode>(detail.PreferredResultCommunicationMode);
			contactPoint.InformationAuthority = EnumUtils.GetEnumValue<InformationAuthorityEnum>(detail.InformationAuthority, context);
			contactPoint.MarkDeactivated(detail.Deactivated);

			var phoneAssembler = new TelephoneNumberAssembler();
			var addressAssembler = new AddressAssembler();
			var emailAddressAssembler = new EmailAddressAssembler();

			contactPoint.TelephoneNumbers.Clear();
			if (detail.TelephoneNumbers != null)
			{
				foreach (var phoneDetail in detail.TelephoneNumbers)
				{
					contactPoint.TelephoneNumbers.Add(phoneAssembler.CreateTelephoneNumber(phoneDetail));
				}
			}

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

			contactPoint.EmailAddresses.Clear();
			if (detail.EmailAddresses != null)
			{
				foreach (var emailAddressDetail in detail.EmailAddresses)
				{
					contactPoint.EmailAddresses.Add(emailAddressAssembler.CreateEmailAddress(emailAddressDetail));
				}
			}
		}
		public ExternalPractitionerContactPointDetail CreateExternalPractitionerContactPointDetail(ExternalPractitionerContactPoint contactPoint,
			IPersistenceContext context)
		{
			var telephoneNumberAssembler = new TelephoneNumberAssembler();
			var addressAssembler = new AddressAssembler();
			var emailAddressAssembler = new EmailAddressAssembler();

			var currentPhone = contactPoint.CurrentPhoneNumber;
			var currentFax = contactPoint.CurrentFaxNumber;
			var currentAddress = contactPoint.CurrentAddress;
			var currentEmailAddress = contactPoint.CurrentEmailAddress;

			return new ExternalPractitionerContactPointDetail(
				contactPoint.GetRef(),
				contactPoint.Name,
				contactPoint.Description,
				contactPoint.IsDefaultContactPoint,
				EnumUtils.GetEnumValueInfo(contactPoint.PreferredResultCommunicationMode, context),
				EnumUtils.GetEnumValueInfo(contactPoint.InformationAuthority),
				CollectionUtils.Map(contactPoint.TelephoneNumbers, (TelephoneNumber phone) => telephoneNumberAssembler.CreateTelephoneDetail(phone, context)),
				CollectionUtils.Map(contactPoint.Addresses, (Address address) => addressAssembler.CreateAddressDetail(address, context)),
				CollectionUtils.Map(contactPoint.EmailAddresses, (EmailAddress emailAddress) => emailAddressAssembler.CreateEmailAddressDetail(emailAddress, context)),
				currentPhone == null ? null : telephoneNumberAssembler.CreateTelephoneDetail(currentPhone, context),
				currentFax == null ? null : telephoneNumberAssembler.CreateTelephoneDetail(currentFax, context),
				currentAddress == null ? null : addressAssembler.CreateAddressDetail(currentAddress, context),
				currentEmailAddress == null ? null : emailAddressAssembler.CreateEmailAddressDetail(currentEmailAddress, context),
				CreateExternalPractitionerContactPointSummary(contactPoint.GetUltimateMergeDestination()),
				contactPoint.IsMerged,
				contactPoint.Deactivated);
		}
Esempio n. 7
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);
			}
		}
Esempio n. 8
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);
        }
Esempio n. 9
0
        public void UpdatePatientProfile(PatientProfile profile, PatientProfileDetail detail, bool updateMrn, IPersistenceContext context)
        {
            if (updateMrn)
            {
                profile.Mrn.Id = detail.Mrn.Id;
                profile.Mrn.AssigningAuthority = EnumUtils.GetEnumValue <InformationAuthorityEnum>(detail.Mrn.AssigningAuthority, context);
            }

            profile.Healthcard = new HealthcardNumber();
            new HealthcardAssembler().UpdateHealthcard(profile.Healthcard, detail.Healthcard, context);

            var nameAssembler = new PersonNameAssembler();

            nameAssembler.UpdatePersonName(detail.Name, profile.Name);

            profile.Sex            = EnumUtils.GetEnumValue <Sex>(detail.Sex);
            profile.DateOfBirth    = detail.DateOfBirth;
            profile.DeathIndicator = detail.DeathIndicator;
            profile.TimeOfDeath    = detail.TimeOfDeath;

            profile.PrimaryLanguage    = EnumUtils.GetEnumValue <SpokenLanguageEnum>(detail.PrimaryLanguage, context);
            profile.Religion           = EnumUtils.GetEnumValue <ReligionEnum>(detail.Religion, context);
            profile.BillingInformation = detail.BillingInformation;

            var telephoneAssembler = new TelephoneNumberAssembler();

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

            var addressAssembler = new AddressAssembler();

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

            var emailAssembler = new EmailAddressAssembler();

            profile.EmailAddresses.Clear();
            foreach (var e in detail.EmailAddresses)
            {
                profile.EmailAddresses.Add(emailAssembler.CreateEmailAddress(e));
            }

            var contactAssembler = new ContactPersonAssembler();

            profile.ContactPersons.Clear();
            foreach (var cp in detail.ContactPersons)
            {
                profile.ContactPersons.Add(contactAssembler.CreateContactPerson(cp, context));
            }
        }
        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);
            }
        }
		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;
		}
		public void UpdatePatientProfile(PatientProfile profile, PatientProfileDetail detail, bool updateMrn, IPersistenceContext context)
		{
			if(updateMrn)
			{
				profile.Mrn.Id = detail.Mrn.Id;
				profile.Mrn.AssigningAuthority = EnumUtils.GetEnumValue<InformationAuthorityEnum>(detail.Mrn.AssigningAuthority, context);
			}

			profile.Healthcard = new HealthcardNumber();
			new HealthcardAssembler().UpdateHealthcard(profile.Healthcard, detail.Healthcard, context);

			var nameAssembler = new PersonNameAssembler();
			nameAssembler.UpdatePersonName(detail.Name, profile.Name);

			profile.Sex = EnumUtils.GetEnumValue<Sex>(detail.Sex);
			profile.DateOfBirth = detail.DateOfBirth;
			profile.DeathIndicator = detail.DeathIndicator;
			profile.TimeOfDeath = detail.TimeOfDeath;

			profile.PrimaryLanguage = EnumUtils.GetEnumValue<SpokenLanguageEnum>(detail.PrimaryLanguage, context);
			profile.Religion = EnumUtils.GetEnumValue<ReligionEnum>(detail.Religion, context);
			profile.BillingInformation = detail.BillingInformation;

			var telephoneAssembler = new TelephoneNumberAssembler();
			profile.TelephoneNumbers.Clear();
			if (detail.TelephoneNumbers != null)
			{
				foreach (var phoneDetail in detail.TelephoneNumbers)
				{
					profile.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneNumber(phoneDetail));
				}
			}

			var addressAssembler = new AddressAssembler();
			profile.Addresses.Clear();
			if (detail.Addresses != null)
			{
				foreach (var addressDetail in detail.Addresses)
				{
					profile.Addresses.Add(addressAssembler.CreateAddress(addressDetail));
				}
			}

			var emailAssembler = new EmailAddressAssembler();
			profile.EmailAddresses.Clear();
			foreach (var e in detail.EmailAddresses)
			{
				profile.EmailAddresses.Add(emailAssembler.CreateEmailAddress(e));
			}

			var contactAssembler = new ContactPersonAssembler();
			profile.ContactPersons.Clear();
			foreach (var cp in detail.ContactPersons)
			{
				profile.ContactPersons.Add(contactAssembler.CreateContactPerson(cp, context));
			}

		}