private Patient SavePatient(PatientSearchResultDto patientSearchResult, long agencyKey)
        {
            CheckPhoneAndAddressRequiredFields(patientSearchResult);

            var agency = _agencyRepository.GetByKey(agencyKey);

            var personName = new PersonName(
                patientSearchResult.PrefixName,
                patientSearchResult.FirstName,
                patientSearchResult.MiddleName,
                patientSearchResult.LastName,
                patientSearchResult.SuffixName);

            var patientGender = (patientSearchResult.PatientGender == null)
                                    ? null
                                    : _mappingHelper.MapLookupField <PatientGender> (patientSearchResult.PatientGender);
            var patientProfile = new PatientProfileBuilder()
                                 .WithBirthDate(patientSearchResult.BirthDate)
                                 .WithPatientGender(patientGender)
                                 .Build();

            var patient = _patientFactory.CreatePatient(agency, personName, patientProfile);

            PopulatePatientAddresses(patient, patientSearchResult);
            PopulatePatientPhones(patient, patientSearchResult);

            _patientRepository.MakePersistent(patient);

            return(patient);
        }
Esempio n. 2
0
        /// <summary>
        /// Processes the single aggregate.
        /// </summary>
        /// <param name="dto">The dto to process.</param>
        /// <param name="patient">The patient.</param>
        /// <returns>A <see cref="System.Boolean"/></returns>
        protected override bool ProcessSingleAggregate(PatientProfileDto dto, Patient patient)
        {
            var name = new PersonNameBuilder()
                       .WithFirst(dto.FirstName)
                       .WithMiddle(dto.MiddleName)
                       .WithLast(dto.LastName)
                       .WithSuffix(dto.SuffixName)
                       .Build();

            if (patient.Name != name)
            {
                patient.Rename(name);
            }

            var patientGender     = (dto.PatientGender == null) ? null : _mappingHelper.MapLookupField <PatientGender> (dto.PatientGender);
            var contactPreference = _mappingHelper.MapLookupField <ContactPreference> (dto.ContactPreference);

            var patientProfile = new PatientProfileBuilder()
                                 .WithPatientGender(patientGender)
                                 .WithBirthDate(dto.BirthDate)
                                 .WithDeathDate(dto.DeathDate)
                                 .WithContactPreference(contactPreference)
                                 .WithEmailAddress(string.IsNullOrWhiteSpace(dto.EmailAddress) ? null : new EmailAddress(dto.EmailAddress))
                                 .Build();

            patient.ReviseProfile(patientProfile);

            return(true);
        }
Esempio n. 3
0
        private void BuildTaddYoungPatient()
        {
            PersonName name = new PersonNameBuilder()
                              .WithFirst("Tadd")
                              .WithLast("Young")
                              .Build();
            PatientProfile profile = new PatientProfileBuilder()
                                     .WithBirthDate(DateTime.Parse("5/10/2000"))
                                     .WithPatientGender(MaleGender)
                                     .Build();

            TaddYoungPatient = new Patient(SafeHarborAgency, name, profile);
            TaddYoungPatient.UpdateUniqueIdentifier("taddyoung");

            TaddYoungPatient.AddPhoneNumber(new PatientPhone(HomePatientPhoneType, "555-255-5454"));

            var patientRace = new PatientRace(WhiteRace);

            TaddYoungPatient.AddPatientRace(patientRace);
            TaddYoungPatient.SetPrimaryRace(WhiteRace);

            TaddYoungPatient.AddAlias(new PatientAlias(NicknamePatientAliasType, "Tadd"));

            TaddYoungPatient.AddPatientDisability(new PatientDisability(DeafDisability));

            Session.SaveOrUpdate(TaddYoungPatient);
        }
        /// <summary>
        /// Handles the request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="response">The response.</param>
        protected override void HandleRequest(CreateNewPatientRequest request, CreateNewPatientResponse response)
        {
            var session = SessionProvider.GetSession();
            var agency  = session.Load <Agency> (request.AgencyKey);

            var name = new PersonNameBuilder()
                       .WithFirst(request.FirstName)
                       .WithMiddle(request.MiddleName)
                       .WithLast(request.LastName)
                       .WithSuffix(request.Suffix == null ? null : request.Suffix.Name)
                       .Build();

            PatientGender patientGender = null;

            if (request.Gender != null)
            {
                patientGender = _mappingHelper.MapLookupField <PatientGender> (request.Gender);
            }

            var patientProfile = new PatientProfileBuilder()
                                 .WithPatientGender(patientGender)
                                 .WithBirthDate(request.BirthDate)
                                 .Build();

            var patient = _patientFactory.CreatePatient(agency, name, patientProfile);

            if (Success)
            {
                response.PatientDto = Mapper.Map <Patient, PatientDto> (patient);
            }
        }
Esempio n. 5
0
        private void BuildAlbertSmithPatient()
        {
            PersonName name = new PersonNameBuilder()
                              .WithFirst("Albert")
                              .WithLast("Smith")
                              .Build();
            PatientProfile profile = new PatientProfileBuilder()
                                     .WithBirthDate(DateTime.Parse("5/10/1971"))
                                     .WithPatientGender(MaleGender)
                                     .Build();

            AlbertSmithPatient = new Patient(SafeHarborAgency, name, profile);
            AlbertSmithPatient.UpdateUniqueIdentifier("albertsmith");

            var address = new AddressBuilder()
                          .WithFirstStreetAddress("14235 South St")
                          .WithCityName("Baltimore")
                          .WithPostalCode(new PostalCode("21075"))
                          .WithStateProvince(MarylandStateProvince)
                          .Build();

            PatientAddress albertSmithAddress = new PatientAddressBuilder()
                                                .WithPatientAddressType(HomePatientAddressType)
                                                .WithAddress(address)
                                                .Build();

            AlbertSmithPatient.AddAddress(albertSmithAddress);

            AlbertSmithPatient.AddPhoneNumber(new PatientPhone(HomePatientPhoneType, "555-255-5454"));

            var patientRace = new PatientRace(WhiteRace);

            AlbertSmithPatient.AddPatientRace(patientRace);
            AlbertSmithPatient.SetPrimaryRace(WhiteRace);

            AlbertSmithPatient.AddAlias(new PatientAlias(NicknamePatientAliasType, "Al-bear"));

            AlbertSmithPatient.AddPatientDisability(new PatientDisability(DeafDisability));

            Session.SaveOrUpdate(AlbertSmithPatient);
        }