public void returns_specialties_for_provider()
        {
            //setup
            var request = new ListProviderSpecialtiesRequest();
            request.ProviderId = _idWith4Specialties;
            var handler = CreateHandler();

            //act
            var response = HandleRequest<ListProviderSpecialtiesResponse>(handler, request);

            //assert
            Assert.AreEqual(4, response.ProviderSpecialties.Count());
        }
Exemple #2
0
        private string GetProvider(ConvertServiceRequest request)
        {
            var providerId = 0;
            if (request.Parameters.ContainsKey("externalId"))
            {
                providerId = LookupDataEntityMapId(request.Parameters["externalId"], false);
            }
            else if (request.Parameters.ContainsKey("id"))
            {
                if (!int.TryParse(request.Parameters["id"], out providerId))
                    throw new BusinessException("Provider Id must be a valid integer");
            }

            // create the requests
            var profileRequest = new ReadProviderProfileRequest { ProviderId = providerId, BypassCache = true };
            var locationsRequest = new ListProviderOrgUnitsRequest { ProviderId = providerId, BypassCache = true, IncludeExternalIds = true };
            var educationRequest = new ListProviderEducationRequest { ProviderId = providerId, BypassCache = true, IncludeIncomplete = true };
            var languageRequst = new ListProviderLanguagesRequest { ProviderId = providerId, BypassCache = true };
            var clinicalRequest = new ListProviderClinicalInterestRequest { ProviderId = providerId, BypassCache = true };
            var certificationRequest = new ListProviderCertificationSpecialtyRequest { ProviderId = providerId, BypassCache = true };
            var orgUnitAffiliationRequest = new ListProviderOrgUnitAffiliationRequest { ProviderId = providerId, ShowAdminList = true, BypassCache = true };
            var providerTypesRequest = new ListProviderProviderTypeRequest { ProviderId = providerId, BypassCache = true };
            var providerSpecialtiesRequest = new ListProviderSpecialtiesRequest { ProviderId = providerId, BypassCache = true };

            // add the requests to the dispatcher
            var provider = ProcessRequest<ReadProviderProfileResponse>(profileRequest).Provider;
            var locations = ProcessRequest<ListProviderOrgUnitsResponse>(locationsRequest).OrgUnits;
            var educations = ProcessRequest<ListProviderEducationResponse>(educationRequest).Records;
            var languages = ProcessRequest<ListProviderLanguagesResponse>(languageRequst).Languages;
            var clinicalInterests = ProcessRequest<ListProviderClinicalInterestResponse>(clinicalRequest).ClinicalInterests;
            var certifications = ProcessRequest<ListProviderCertificationSpecialtyResponse>(certificationRequest).CertificationSpecialties;
            var orgUnitAffiliations = ProcessRequest<ListProviderOrgUnitAffiliationResponse>(orgUnitAffiliationRequest).Records;
            var providerTypes = ProcessRequest<ListProviderProviderTypeResponse>(providerTypesRequest).ProviderTypes;
            var providerSpecialties = ProcessRequest<ListProviderSpecialtiesResponse>(providerSpecialtiesRequest).ProviderSpecialties;

            var viewModel = new ProviderV2
            {
                ProviderId = provider.Id.ToString(CultureInfo.InvariantCulture),
                Npi = provider.Npi.HasValue ? provider.Npi.Value.ToString(CultureInfo.InvariantCulture) : null,
                NamePrefix = provider.NamePrefix,
                FirstName = provider.FirstName,
                MiddleName = provider.MiddleName,
                LastName = provider.LastName,
                NameSuffix = provider.NameSuffix,
                AdditionalSuffix = provider.AdditionalSuffix,
                Gender = provider.Gender,
                DateOfBirth = provider.DateOfBirth.HasValue ? provider.DateOfBirth.Value.ToString(CultureInfo.InvariantCulture) : string.Empty,
                Phone = provider.Phone,
                Fax = provider.Fax,
                Email = provider.Email,
                Website = provider.Website,
                PhilosophyOfCare = provider.PhilosophyOfCare,
                AdditionalInformation = provider.AdditionalInformation,
                InPracticeSince = provider.InPracticeSince.HasValue ? provider.InPracticeSince.Value.ToString(CultureInfo.InvariantCulture) : string.Empty,
                ProviderGroup = provider.ProviderGroupName,
                PictureId = provider.PictureId == 0 ? null : provider.PictureId.ToString(CultureInfo.InvariantCulture),
                ImageUrl = provider.ImageUrl,
                VideoContent = provider.VideoContent,
                AboutMe = provider.AboutMe,
                IsEnabled = provider.IsEnabled.ToString(CultureInfo.InvariantCulture),
                ProviderExternalId = provider.ProviderExternalId,
                Keywords = provider.Keywords,
                CustomKeywords = provider.CustomKeywords,
                ExcludedKeywords = provider.ExcludedKeywords,
                Custom1 = provider.Custom1,
                Custom2 = provider.Custom2,
                Custom3 = provider.Custom3,
                DynamicColumns = provider.DynamicColumns,

                Specialties = providerSpecialties.Select(s => new ProviderSpecialtyV2
                {
                    SpecialtyName = s.SpecialtyName,
                    IsPrimary = s.IsPrimary.ToString(CultureInfo.InvariantCulture),
                    IsBoardCertified = s.IsBoardCertified.ToString(CultureInfo.InvariantCulture),
                    SpecialtyType = s.SpecialtyType
                }).ToList(),

                Languages = languages.Select(l => new ProviderLanguageV2
                {
                    LanguageName = l.LanguageName,
                    IsFluent = l.IsFluent.ToString(CultureInfo.InvariantCulture),
                    IsPrimary = l.IsPrimary.ToString(CultureInfo.InvariantCulture)
                }).ToList(),

                EducationTypes = educations.Select(e => new ProviderEducationV2
                {
                    EducationTypeName = e.EducationTypeName,
                    YearCompleted = e.YearCompleted,
                    InstitutionName = e.InstitutionName,
                    IsComplete = e.IsCompleted.ToString(CultureInfo.InvariantCulture)
                }).ToList(),

                ClinicalInterests = clinicalInterests.Select(c => new ProviderClinicalInterestV2
                {
                    Name = c.ClinicalInterestName
                }).ToList(),

                OrgUnits = locations.Select(o => new ProviderOrgUnitV2
                {
                    OrgUnitId = o.OrgUnitId.ToString(CultureInfo.InvariantCulture),
                    OrgUnitExternalId = o.OrgUnitExternalId,
                    Phone = o.DisplayPhone,
                    Fax = o.DisplayFax,
                    IsPrimary = o.IsPrimary.ToString(CultureInfo.InvariantCulture),
                    IsAcceptingNewPatients = o.IsAcceptingNewPatients.ToString(CultureInfo.InvariantCulture),
                    ProviderOrgUnitId = o.Id.ToString(CultureInfo.InvariantCulture),
                    Insurances = o.Insurance.Where(i => !i.IsInheritedDisabled).Select(i => new ProviderOrgUnitInsuranceV2
                    {
                        Name = i.InsuranceName
                    }).ToList(),
                    Services = o.Service.Select(s => new ProviderOrgUnitServiceV2
                    {
                        Name = s.ServiceName
                    }).ToList(),
                    Schedules = o.Schedule.Select(s => new ProviderOrgUnitScheduleV2
                    {
                        OpenTime = s.Open,
                        CloseTime = s.Close,
                        DayOfWeek = s.Day
                    }).ToList(),
                    DisabledInheritedInsurances = o.Insurance.Where(i => i.IsInherited && i.IsInheritedDisabled).Select(i => new DisabledInheritedInsuranceV2
                    {
                        Name = i.InsuranceName
                    }).ToList()
                }).ToList(),

                CertificationAgencies = certifications.Select(c => new CertificationAgencyV2
                {
                    AgencyName = c.CertificationAgencyName,
                    CertificationBoards = new CertificationBoardV2[1]{new CertificationBoardV2
                {
                    BoardName = c.CertificationBoardName,
                    CertificationSpecialties = new CertificationSpecialtyV2[1]{new CertificationSpecialtyV2
                    {
                        Name = c.CertificationSpecialtyName,
                        YearOfIssuance = c.YearOfIssuance
                    }}.ToList()
                }}.ToList()
                }).ToList(),

                OrgUnitAffiliations = orgUnitAffiliations.Select(a => new ProviderOrgUnitAffiliationV2
                {
                    OrgUnitId = a.OrgUnitId.ToString(CultureInfo.InvariantCulture),
                    OrgUnitTypeId = a.OrgUnitTypeId.ToString(CultureInfo.InvariantCulture),
                    Service = a.ServiceName
                }).ToList(),

                ProviderTypes = providerTypes.Select(t => new ProviderTypeV2
                {
                    Name = t.ProviderTypeName
                }).ToList()
            };

            return CommonUtils.XmlSerialize(viewModel);
        }
        private void PopulateFieldData(ModuleInstanceView parent, ProviderProfileDto provider, Field field)
        {
            //Handle Dynamic Column Data
            if (field.FieldName.StartsWith(Constants.DynamicColumnPrefix))
            {
                var dynamicColumnFieldName = field.FieldName.Replace(Constants.DynamicColumnPrefix, string.Empty);
                var dynamicColumn = DynamicColumnData.FirstOrDefault(c => c.FieldName == dynamicColumnFieldName);
                if (dynamicColumn != null && DynamicColumnDefinitions.Any(c => c.Name == dynamicColumnFieldName))
                    field.Value = dynamicColumn.FieldValue;
                else
                    field.Value = string.Empty;
            }
            //Handle Standard Column Data
            else
            {
                switch (field.FieldName)
                {
                    case "Gender":
                        field.Value = provider.Gender;
                        break;
                    case "ProviderName":
                        field.Value = parent.CalculateProviderFullName(provider.NamePrefix, provider.FirstName, provider.MiddleName, provider.LastName, provider.NameSuffix, provider.AdditionalSuffix, field);
                        break;
                    case "Image":
                        if (!string.IsNullOrEmpty(provider.ImageUrl))
                            field.URL = provider.ImageUrl;
                        else
                            field.URL = parent.DefaultProviderImageUrl;

                        field.Value = parent.CalculateProviderFullName(provider.NamePrefix, provider.FirstName, provider.MiddleName, provider.LastName, provider.NameSuffix, provider.AdditionalSuffix, field);
                        break;
                    case "DateOfBirth":
                        field.Value = provider.DateOfBirth.HasValue ? provider.DateOfBirth.Value.ToString("M/d/yyyy") : string.Empty;
                        break;
                    case "InPracticeSince":
                        field.Value = provider.InPracticeSince.HasValue ? provider.DateOfBirth.Value.ToString("M/d/yyyy") : string.Empty;
                        break;
                    case "Age":
                        field.Value = provider.Age;
                        break;
                    case "Experience":
                        field.Value = provider.Experience;
                        break;
                    case "PrimarySpecialty":
                        field.Value = provider.PrimarySpecialtyName;
                        break;
                    case "PrimaryPhone":
                        field.Value = provider.Phone;
                        break;
                    case "PrimaryFax":
                        field.Value = provider.Fax;
                        break;
                    case "PrimaryEmail":
                        field.Value = provider.Email;
                        break;
                    case "PrimaryLocationName":
                        field.Value = provider.PrimaryOrgUnitName;
                        break;
                    case "PrimaryLocationCompleteAddress":
                        field.Value = string.Format("{0}<br />{1}, {2} {3}",
                            !string.IsNullOrEmpty(provider.PrimaryOrgUnitAddress2) ? provider.PrimaryOrgUnitAddress1 + "<br />" + provider.PrimaryOrgUnitAddress2 : provider.PrimaryOrgUnitAddress1,
                            provider.PrimaryOrgUnitCity,
                            provider.PrimaryOrgUnitStateAbbreviated,
                            provider.PrimaryOrgUnitPostalCode);
                        break;
                    case "ProviderTypes":
                        var typesRequest = new ListProviderProviderTypeRequest() { ProviderId = provider.Id };
                        var types = parent.ProcessRequest<ListProviderProviderTypeResponse>(typesRequest).ProviderTypes;
                        field.Values = types.Select(t => t.ProviderTypeName).Cast<object>().ToList();
                        break;
                    case "ProviderLanguages":
                        var languagesRequest = new ListProviderLanguagesRequest() { ProviderId = provider.Id };
                        var languages = parent.ProcessRequest<ListProviderLanguagesResponse>(languagesRequest).Languages;
                        field.Values = languages.Select(l => l.LanguageName).Cast<object>().ToList();
                        break;
                    case "ClinicalInterests":
                        var interestsRequest = new ListProviderClinicalInterestRequest() { ProviderId = provider.Id };
                        var interests = parent.ProcessRequest<ListProviderClinicalInterestResponse>(interestsRequest).ClinicalInterests;
                        field.Values = interests.Select(l => l.ClinicalInterestName).Cast<object>().ToList();
                        break;
                    case "Specialties":
                        var specialtiesRequest = new ListProviderSpecialtiesRequest() { ProviderId = provider.Id };
                        var specialties = parent.ProcessRequest<ListProviderSpecialtiesResponse>(specialtiesRequest).ProviderSpecialties;
                        field.Values = specialties.Select(l => l.SpecialtyName).Cast<object>().ToList();
                        break;
                    case "AboutMe":
                        field.Value = provider.AboutMe;
                        break;
                    case "PhilosophyOfCare":
                        field.Value = provider.PhilosophyOfCare;
                        break;
                    case "AdditionalInfo":
                        field.Value = provider.AdditionalInformation;
                        break;
                    case "Website":
                        field.Value = provider.Website;
                        break;
                    case "Videos":
                        field.Value = provider.VideoContent;
                        break;
                    case "Custom1":
                        field.Value = provider.Custom1;
                        break;
                    case "Custom2":
                        field.Value = provider.Custom2;
                        break;
                    case "Custom3":
                        field.Value = provider.Custom3;
                        break;
                    case "ConditionalField":
                        if (string.IsNullOrEmpty(field.ConditionalSettings.ConditionalField) ||
                            string.IsNullOrEmpty(field.ConditionalSettings.ConditionalValue) ||
                            string.IsNullOrEmpty(field.ConditionalSettings.ConditionOperation))
                            return;

                        var conditionalField = _viewSettings.AvailableFields.First(f => f.FieldName == field.ConditionalSettings.ConditionalField);
                        PopulateFieldData(parent, provider, conditionalField);

                        Field fieldToShow = null;
                        if (!string.IsNullOrEmpty(field.ConditionalSettings.FieldToShow))
                        {
                            fieldToShow = _viewSettings.AvailableFields.First(f => f.FieldName == field.ConditionalSettings.FieldToShow);
                            PopulateFieldData(parent, provider, fieldToShow);
                        }

                        CommonUtils.PopulateConditionalFieldValue(field, conditionalField, fieldToShow);
                        break;
                    case "AppointmentRequestLink":
                        if (provider.PrimaryOrgUnitAllowAppointmentRequests)
                        {
                            field.Value = ProviderUtils.GetAppointmentRequestLinkText(field);
                            field.URL = ProviderUtils.GetAppointmentRequestLinkUrl(field, provider.Id, provider.PrimaryOrgUnitId);
                        }
                        else
                        {
                            field.URL = string.Empty;
                            field.Value = string.Empty;
                        }
                        break;
                }
            }
        }
 private static IEnumerable<ProviderSpecialtyDto> GetProviderSpecialties(ProviderAdminDetailView parent, int providerId)
 {
     var request = new ListProviderSpecialtiesRequest() { ProviderId = providerId };
     return parent.ProcessRequest<ListProviderSpecialtiesResponse>(request).ProviderSpecialties;
 }