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 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 ExternalPractitionerDetail CreateExternalPractitionerDetail(ExternalPractitioner prac, IPersistenceContext context) { var assembler = new PersonNameAssembler(); var sortedContactPoints = CollectionUtils.Sort(prac.ContactPoints, (x, y) => { if (ReferenceEquals(x, y)) return 0; if (x.IsDefaultContactPoint) return -1; if (y.IsDefaultContactPoint) return 1; return string.Compare(x.Name, y.Name); }); var contactPointDetails = CollectionUtils.Map( sortedContactPoints, (ExternalPractitionerContactPoint cp) => CreateExternalPractitionerContactPointDetail(cp, context)); var detail = new ExternalPractitionerDetail( prac.GetRef(), assembler.CreatePersonNameDetail(prac.Name), prac.LicenseNumber, prac.BillingNumber, prac.IsVerified, prac.LastVerifiedTime, prac.LastEditedTime, contactPointDetails, ExtendedPropertyUtils.Copy(prac.ExtendedProperties), CreateExternalPractitionerSummary(prac.GetUltimateMergeDestination(), context), prac.IsMerged, prac.Deactivated); return detail; }
public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context) { // validate that only one contact point is specified as default var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint); if(defaultPoints.Count > 1) throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint); var assembler = new PersonNameAssembler(); assembler.UpdatePersonName(detail.Name, prac.Name); prac.LicenseNumber = detail.LicenseNumber; prac.BillingNumber = detail.BillingNumber; prac.MarkDeactivated(detail.Deactivated); // update contact points collection var syncHelper = new CollectionSynchronizeHelper<ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>( delegate (ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail) { // ignore version in this comparison - deal with this issue in the update delegate return cp.GetRef().Equals(cpDetail.ContactPointRef, true); }, delegate (ExternalPractitionerContactPointDetail cpDetail, ICollection<ExternalPractitionerContactPoint> cps) { // create a new contact point var cp = new ExternalPractitionerContactPoint(prac); UpdateExternalPractitionerContactPoint(cpDetail, cp, context); cps.Add(cp); }, (cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context), (cp, cps) => cps.Remove(cp)); syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints); ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties); }
public void UpdateAllergy(Allergy allergy, PatientAllergyDetail source, IPersistenceContext context) { var nameAssembler = new PersonNameAssembler(); allergy.AllergenType = EnumUtils.GetEnumValue <AllergyAllergenTypeEnum>(source.AllergenType, context); allergy.AllergenDescription = source.AllergenDescription; allergy.Severity = EnumUtils.GetEnumValue <AllergySeverityEnum>(source.Severity, context); allergy.Reaction = source.Reaction; allergy.SensitivityType = EnumUtils.GetEnumValue <AllergySensitivityTypeEnum>(source.SensitivityType, context); allergy.OnsetTime = source.OnsetTime; allergy.ReportedTime = source.ReportedTime; nameAssembler.UpdatePersonName(source.ReporterName, allergy.Reporter); allergy.ReporterRelationshipType = EnumUtils.GetEnumValue <PersonRelationshipTypeEnum>(source.ReporterRelationshipType, context); }
public PatientAllergyDetail CreateAllergyDetail(Allergy allergy) { var nameAssembler = new PersonNameAssembler(); return(new PatientAllergyDetail( EnumUtils.GetEnumValueInfo(allergy.AllergenType), allergy.AllergenDescription, EnumUtils.GetEnumValueInfo(allergy.Severity), allergy.Reaction, EnumUtils.GetEnumValueInfo(allergy.SensitivityType), allergy.OnsetTime, allergy.ReportedTime, nameAssembler.CreatePersonNameDetail(allergy.Reporter), EnumUtils.GetEnumValueInfo(allergy.ReporterRelationshipType))); }
public PatientProfileSummary CreatePatientProfileSummary(PatientProfile profile, IPersistenceContext context) { var nameAssembler = new PersonNameAssembler(); var healthcardAssembler = new HealthcardAssembler(); var summary = new PatientProfileSummary { Mrn = new MrnAssembler().CreateMrnDetail(profile.Mrn), DateOfBirth = profile.DateOfBirth, Healthcard = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard), Name = nameAssembler.CreatePersonNameDetail(profile.Name), PatientRef = profile.Patient.GetRef(), PatientProfileRef = profile.GetRef(), Sex = EnumUtils.GetEnumValueInfo(profile.Sex, context) }; return summary; }
public PatientProfileSummary CreatePatientProfileSummary(PatientProfile profile, IPersistenceContext context) { var nameAssembler = new PersonNameAssembler(); var healthcardAssembler = new HealthcardAssembler(); var summary = new PatientProfileSummary { Mrn = new MrnAssembler().CreateMrnDetail(profile.Mrn), DateOfBirth = profile.DateOfBirth, Healthcard = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard), Name = nameAssembler.CreatePersonNameDetail(profile.Name), PatientRef = profile.Patient.GetRef(), PatientProfileRef = profile.GetRef(), Sex = EnumUtils.GetEnumValueInfo(profile.Sex, context) }; return(summary); }
public ExternalPractitionerDetail CreateExternalPractitionerDetail(ExternalPractitioner prac, IPersistenceContext context) { var assembler = new PersonNameAssembler(); var sortedContactPoints = CollectionUtils.Sort(prac.ContactPoints, (x, y) => { if (ReferenceEquals(x, y)) { return(0); } if (x.IsDefaultContactPoint) { return(-1); } if (y.IsDefaultContactPoint) { return(1); } return(string.Compare(x.Name, y.Name)); }); var contactPointDetails = CollectionUtils.Map( sortedContactPoints, (ExternalPractitionerContactPoint cp) => CreateExternalPractitionerContactPointDetail(cp, context)); var detail = new ExternalPractitionerDetail( prac.GetRef(), assembler.CreatePersonNameDetail(prac.Name), prac.LicenseNumber, prac.BillingNumber, prac.IsVerified, prac.LastVerifiedTime, prac.LastEditedTime, contactPointDetails, ExtendedPropertyUtils.Copy(prac.ExtendedProperties), CreateExternalPractitionerSummary(prac.GetUltimateMergeDestination(), context), prac.IsMerged, prac.Deactivated); return(detail); }
public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context) { // validate that only one contact point is specified as default var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint); if (defaultPoints.Count > 1) { throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint); } var assembler = new PersonNameAssembler(); assembler.UpdatePersonName(detail.Name, prac.Name); prac.LicenseNumber = detail.LicenseNumber; prac.BillingNumber = detail.BillingNumber; prac.MarkDeactivated(detail.Deactivated); // update contact points collection var syncHelper = new CollectionSynchronizeHelper <ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>( delegate(ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail) { // ignore version in this comparison - deal with this issue in the update delegate return(cp.GetRef().Equals(cpDetail.ContactPointRef, true)); }, delegate(ExternalPractitionerContactPointDetail cpDetail, ICollection <ExternalPractitionerContactPoint> cps) { // create a new contact point var cp = new ExternalPractitionerContactPoint(prac); UpdateExternalPractitionerContactPoint(cpDetail, cp, context); cps.Add(cp); }, (cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context), (cp, cps) => cps.Remove(cp)); syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints); ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties); }
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 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 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 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)); } }