Exemplo n.º 1
0
        public static void Save(ProviderAdminDetailView parent, SubEntity providerTypes, int providerId)
        {
            try
            {
                providerTypes.ErrorMessage = string.Empty;

                //Existing Records Added
                foreach (var record in providerTypes.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderProviderTypeRequest()
                    {
                        ProviderId = providerId,
                        ProviderTypeId = int.Parse(parent.GetFieldValue(record.Fields, _providerTypeId))
                    };

                    parent.ProcessRequest<AddProviderProviderTypeResponse>(request);
                }

                //New Records Created
                foreach (var record in providerTypes.Records.Where(r => r.Action == RecordActions.New))
                {
                    //Add New Provider Type
                    var addTypeRequest = new AddProviderTypeRequest()
                    {
                        Name = parent.GetFieldValue(record.Fields, _providerTypeName),
                        IsEnabled = true
                    };
                    var addedTypeId = parent.ProcessRequest<AddProviderTypeResponse>(addTypeRequest).Id;

                    //Add newly created type to provider
                    var request = new AddProviderProviderTypeRequest()
                    {
                        ProviderId = providerId,
                        ProviderTypeId = addedTypeId
                    };

                    parent.ProcessRequest<AddProviderProviderTypeResponse>(request);
                }

                //Deletes
                foreach (var record in providerTypes.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderProviderTypeRequest()
                    {
                        ProviderId = providerId,
                        ProviderTypeId = int.Parse(parent.GetFieldValue(record.Fields, _providerTypeId))
                    };
                    parent.ProcessRequest<DeleteProviderProviderTypeResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerTypes.ErrorMessage = ex.Message;
                throw;
            }

            providerTypes = BuildProviderTypesSubEntity(parent, providerId);
        }
Exemplo n.º 2
0
        public static void Save(ProviderAdminDetailView parent, SubEntity directUrls, int providerId)
        {
            try
            {
                directUrls.ErrorMessage = string.Empty;

                //Deletes
                foreach (var record in directUrls.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteDirectUrlHistoryRequest()
                    {
                        Id = int.Parse(parent.GetFieldValue(record.Fields, _id))
                    };
                    parent.ProcessRequest<DeleteDirectUrlHistoryResponse>(request);
                }
            }
            catch (Exception ex)
            {
                directUrls.ErrorMessage = ex.Message;
                throw;
            }

            directUrls = BuildDirectUrlHistorySubEntity(parent, providerId);
        }
        private static void Validate(ProviderAdminDetailView parent, SubEntityRecord record)
        {
            if (!CommonUtils.IsPhoneNumber(parent.GetFieldValue(record.Fields, _phone)))
                throw new BusinessException("Location Phone Number is invalid");

            if (!CommonUtils.IsPhoneNumber(parent.GetFieldValue(record.Fields, _fax)))
                throw new BusinessException("Location Fax Number is invalid");
        }
        private static void SaveServices(ProviderAdminDetailView parent, SubEntity subentity, int providerOrgUnitId)
        {
            try
            {
                //New Records
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.New))
                {
                    var addServiceRequest = new AddServiceRequest()
                    {
                        Name = parent.GetFieldValue(record.Fields, "ServiceName"),
                        IsEnabled = true
                    };
                    var serviceResponseId = parent.ProcessRequest<AddServiceResponse>(addServiceRequest).Id;

                    var request = new AddProviderOrgUnitServiceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        ServiceId = serviceResponseId
                    };
                    parent.ProcessRequest<AddProviderOrgUnitServiceResponse>(request);
                }

                //Added Records
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderOrgUnitServiceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        ServiceId = int.Parse(parent.GetFieldValue(record.Fields, _serviceId))
                    };
                    parent.ProcessRequest<AddProviderOrgUnitServiceResponse>(request);
                }

                //Deletes
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderOrgUnitServiceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        ServiceId = int.Parse(parent.GetFieldValue(record.Fields, _serviceId))
                    };
                    parent.ProcessRequest<DeleteProviderOrgUnitServiceResponse>(request);
                }
            }
            catch (Exception ex)
            {
                subentity.ErrorMessage = ex.Message;
                throw;
            }
        }
        private static void SaveHours(ProviderAdminDetailView parent, SubEntity subentity)
        {
            try
            {
                //Deletes
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderOrgUnitScheduleRequest()
                    {
                        ProviderOrgUnitScheduleId = int.Parse(parent.GetFieldValue(record.Fields, _id))
                    };
                    var response = parent.ProcessRequest<DeleteProviderOrgUnitScheduleResponse>(request);
                }

                //New
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.New))
                {
                    var timeSpan = CommonUtils.CreateScheduleTimeSpan(parent.GetFieldValue(record.Fields, "Day"), parent.GetFieldValue(record.Fields, "OpenTime"), parent.GetFieldValue(record.Fields, "CloseTime"));

                    var request = new AddProviderOrgUnitScheduleRequest()
                    {
                        ProviderOrgUnitId = int.Parse(parent.GetFieldValue(record.Fields, _providerOrgUnitId)),
                        TimeSpan = timeSpan
                    };
                    var response = parent.ProcessRequest<AddProviderOrgUnitScheduleResponse>(request);
                }
            }
            catch (Exception ex)
            {
                subentity.ErrorMessage = ex.Message;
                throw;
            }
        }
        public static void Save(ProviderAdminDetailView parent, SubEntity providerOrgUnits, int providerId)
        {
            foreach (var record in providerOrgUnits.Records)
            {
                Validate(parent, record);

                //Update Record
                try
                {
                    //Edits
                    if (record.Action == RecordActions.Edited)
                    {
                        var request = new UpdateProviderOrgUnitRequest
                        {
                            Id = int.Parse(parent.GetFieldValue(record.Fields, _id), CultureInfo.InvariantCulture),
                            IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary)),
                            DisplayPhone = parent.GetFieldValue(record.Fields, _phone),
                            DisplayFax = parent.GetFieldValue(record.Fields, _fax),
                            IsAcceptingNewPatients = bool.Parse(parent.GetFieldValue(record.Fields, _isAcceptingNewPatients)),
                            AllowAppointmentRequests = bool.Parse(parent.GetFieldValue(record.Fields, _allowAppointmentRequests))
                        };
                        parent.ProcessRequest<UpdateProviderOrgUnitResponse>(request);
                    }

                    //Adds
                    if (record.Action == RecordActions.Added)
                    {
                        var request = new AddProviderOrgUnitRequest
                        {
                            ProviderId = providerId,
                            OrgUnitId = int.Parse(parent.GetFieldValue(record.Fields, _orgUntiId)),
                            IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary)),
                            DisplayPhone = parent.GetFieldValue(record.Fields, _phone),
                            DisplayFax = parent.GetFieldValue(record.Fields, _fax),
                            IsAcceptingNewPatients = bool.Parse(parent.GetFieldValue(record.Fields, _isAcceptingNewPatients)),
                            AllowAppointmentRequests = bool.Parse(parent.GetFieldValue(record.Fields, _allowAppointmentRequests))
                        };
                        parent.ProcessRequest<AddProviderOrgUnitResponse>(request);
                    }

                    //Deletes
                    if (record.Action == RecordActions.Deleted)
                    {
                        var request = new DeleteProviderOrgUnitRequest()
                        {
                            ProviderId = providerId,
                            OrgUnitId = int.Parse(parent.GetFieldValue(record.Fields, _orgUntiId))
                        };
                        parent.ProcessRequest<DeleteProviderOrgUnitResponse>(request);
                    }
                }
                catch (Exception ex)
                {
                    providerOrgUnits.ErrorMessage = ex.Message;
                    throw;
                }

                //Update Subentities for Record
                foreach (var subentity in record.SubEntities)
                {
                    if (subentity.EntityName == ProviderAdminDetailView._providerOrgUnitInsurancesSubEntity)
                        SaveInsurances(parent, subentity, int.Parse(parent.GetFieldValue(record.Fields, _id)));
                    else if (subentity.EntityName == ProviderAdminDetailView._providerOrgUnitServicesSubEntity)
                        SaveServices(parent, subentity, int.Parse(parent.GetFieldValue(record.Fields, _id)));
                    else if (subentity.EntityName == _hoursSubEntity)

                        SaveHours(parent, subentity);
                }
            }

            providerOrgUnits = BuildLocationsSubEntity(parent, providerId);
        }
        public static void Save(ProviderAdminDetailView parent, SubEntity providerSpecialties, int providerId)
        {
            try
            {
                providerSpecialties.ErrorMessage = string.Empty;

                if (providerSpecialties.Records.Count(s => s.Fields.Any(f => f.FieldName == _isPrimary) && bool.Parse(parent.GetFieldValue(s.Fields, _isPrimary))) > 1)
                {
                    throw new BusinessException("Only one Provider Specialty can be set as the primary specialty");
                }

                //Edits
                foreach (var record in providerSpecialties.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    if (parent.GetFieldValue(record.Fields, _specialtyType) == "Specialty")
                    {
                        var request = new UpdateProviderSpecialtyRequest();

                        request.Id = int.Parse(parent.GetFieldValue(record.Fields, _id));
                        request.IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary));
                        request.IsBoardCertified = bool.Parse(parent.GetFieldValue(record.Fields, _isBoardCertified));

                        parent.ProcessRequest<UpdateProviderSpecialtyResponse>(request);
                    }
                }

                //Existing Records Added
                foreach (var record in providerSpecialties.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        SpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _specialtyId))
                    };

                    if (record.Fields.Any(f => f.FieldName == _isPrimary))
                        request.IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary));
                    if (record.Fields.Any(f => f.FieldName == _isBoardCertified))
                        request.IsBoardCertified = bool.Parse(parent.GetFieldValue(record.Fields, _isBoardCertified));

                    parent.ProcessRequest<AddProviderSpecialtyResponse>(request);
                }

                //New Records Created
                foreach (var record in providerSpecialties.Records.Where(r => r.Action == RecordActions.New))
                {
                    //Add New Specialty/Condition
                    var addSpecialtyRequest = new AddSpecialtyRequest()
                    {
                        Name = parent.GetFieldValue(record.Fields, _name),
                        SpecialtyType = parent.GetFieldValue(record.Fields, _specialtyType),
                        IsEnabled = true
                    };
                    var addedSpecialtyId = parent.ProcessRequest<AddSpecialtyResponse>(addSpecialtyRequest).Id;

                    //Add newly created specialty to provider
                    var request = new AddProviderSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        SpecialtyId = addedSpecialtyId
                    };

                    if (addSpecialtyRequest.SpecialtyType == "Specialty")
                    {
                        request.IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary));
                        request.IsBoardCertified = bool.Parse(parent.GetFieldValue(record.Fields, _isBoardCertified));
                    }

                    parent.ProcessRequest<AddProviderSpecialtyResponse>(request);
                }

                //Records Deleted
                foreach (var record in providerSpecialties.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderSpecialtyRequest()
                    {
                        ProviderId = int.Parse(parent.GetFieldValue(record.Fields, _providerId)),
                        SpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _specialtyId))
                    };
                    parent.ProcessRequest<DeleteProviderSpecialtyResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerSpecialties.ErrorMessage = ex.Message;
                throw;
            }

            providerSpecialties = BuildSpecialtiesSubEntity(parent, providerId);
        }
        public static void Save(ProviderAdminDetailView parent, SubEntity providerCertificationSpecialties, int providerId)
        {
            try
            {
                providerCertificationSpecialties.ErrorMessage = string.Empty;

                //Edits
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    var yearOfIssuance = Validate(parent, record);

                    var request = new UpdateProviderCertificationSpecialtyRequest();

                    request.Id = int.Parse(parent.GetFieldValue(record.Fields, _id));
                    request.ProviderId = providerId;
                    request.CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId));
                    request.YearOfIssuance = yearOfIssuance;

                    parent.ProcessRequest<UpdateProviderCertificationSpecialtyResponse>(request);
                }

                //Existing Records Added
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var yearOfIssuance = Validate(parent, record);

                    var request = new AddProviderCertificationSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId)),
                        YearOfIssuance = yearOfIssuance
                    };

                    parent.ProcessRequest<AddProviderCertificationSpecialtyResponse>(request);
                }

                //Deletes
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderCertificationSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId))
                    };
                    parent.ProcessRequest<DeleteProviderCertificationSpecialtyResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerCertificationSpecialties.ErrorMessage = ex.Message;
                throw;
            }

            providerCertificationSpecialties = BuildCertificationSubEntity(parent, providerId);
        }
        private static string Validate(ProviderAdminDetailView parent, SubEntityRecord record)
        {
            var yearOfIssuance = parent.GetFieldValue(record.Fields, _yearOfIssuance);
            if (string.IsNullOrEmpty(yearOfIssuance))
                throw new BusinessException("Year of Issuance is required for all certification specialties");

            var temp = 0;
            if (!int.TryParse(yearOfIssuance, out temp))
                throw new BusinessException("Year of Issuance is not valid");
            return yearOfIssuance;
        }
Exemplo n.º 10
0
        public static void Save(ProviderAdminDetailView parent, SubEntity providerLanguages, int providerId)
        {
            try
            {
                providerLanguages.ErrorMessage = string.Empty;

                if (providerLanguages.Records.Count(s => bool.Parse(parent.GetFieldValue(s.Fields, _isPrimary))) > 1)
                {
                    throw new BusinessException("Only one Provider Language can be set as the primary language");
                }

                //Edits
                foreach (var record in providerLanguages.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    var request = new UpdateProviderLanguageRequest();

                    request.Id = int.Parse(parent.GetFieldValue(record.Fields, _id));
                    request.IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary));
                    request.IsFluent = bool.Parse(parent.GetFieldValue(record.Fields, _isFluent));

                    parent.ProcessRequest<UpdateProviderLanguageResponse>(request);
                }

                //Existing Records Added
                foreach (var record in providerLanguages.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderLanguageRequest()
                    {
                        ProviderId = providerId,
                        LanguageId = int.Parse(parent.GetFieldValue(record.Fields, _languageId)),
                        IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary)),
                        IsFluent = bool.Parse(parent.GetFieldValue(record.Fields, _isFluent))
                    };

                    parent.ProcessRequest<AddProviderLanguageResponse>(request);
                }

                //New Records Created
                foreach (var record in providerLanguages.Records.Where(r => r.Action == RecordActions.New))
                {
                    //Add New Language
                    var addLanguageRequest = new AddLanguageRequest()
                    {
                        Name = parent.GetFieldValue(record.Fields, _languageName),
                        IsEnabled = true
                    };
                    var addedLanguageId = parent.ProcessRequest<AddLanguageResponse>(addLanguageRequest).Id;

                    //Add newly created language to provider
                    var request = new AddProviderLanguageRequest()
                    {
                        ProviderId = providerId,
                        LanguageId = addedLanguageId,
                        IsPrimary = bool.Parse(parent.GetFieldValue(record.Fields, _isPrimary)),
                        IsFluent = bool.Parse(parent.GetFieldValue(record.Fields, _isFluent))
                    };

                    parent.ProcessRequest<AddProviderLanguageResponse>(request);
                }

                //Deletes
                foreach (var record in providerLanguages.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderLanguageRequest()
                    {
                        ProviderId = providerId,
                        LanguageId = int.Parse(parent.GetFieldValue(record.Fields, _languageId))
                    };
                    parent.ProcessRequest<DeleteProviderLanguageResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerLanguages.ErrorMessage = ex.Message;
                throw;
            }

            providerLanguages = BuildLanguagesSubEntity(parent, providerId);
        }
Exemplo n.º 11
0
        public static void Save(ProviderAdminDetailView parent, SubEntity providerEducations, int providerId)
        {
            try
            {
                providerEducations.ErrorMessage = string.Empty;

                //Edits
                foreach (var record in providerEducations.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    var request = new UpdateProviderEducationRequest();

                    request.ProviderId = providerId;
                    request.Id = int.Parse(parent.GetFieldValue(record.Fields, _id));
                    request.EducationTypeId = int.Parse(parent.GetFieldValue(record.Fields, _educationTypeId));
                    request.InstitutionName = parent.GetFieldValue(record.Fields, _institutionName);
                    request.IsCompleted = bool.Parse(parent.GetFieldValue(record.Fields, _isCompleted));
                    request.YearCompleted = parent.GetFieldValue(record.Fields, _yearCompleted);

                    parent.ProcessRequest<UpdateProviderEducationResponse>(request);
                }

                //Existing Records Added
                foreach (var record in providerEducations.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderEducationRequest()
                    {
                        ProviderId = providerId,
                        EducationTypeId = int.Parse(parent.GetFieldValue(record.Fields, _educationTypeId)),
                        InstitutionName = parent.GetFieldValue(record.Fields, _institutionName),
                        IsCompleted = bool.Parse(parent.GetFieldValue(record.Fields, _isCompleted)),
                        YearCompleted = parent.GetFieldValue(record.Fields, _yearCompleted)
                    };

                    parent.ProcessRequest<AddProviderEducationResponse>(request);
                }

                //New Records Created
                foreach (var record in providerEducations.Records.Where(r => r.Action == RecordActions.New))
                {
                    if (string.IsNullOrEmpty(parent.GetFieldValue(record.Fields, _educationTypeId)))
                    {
                        //Add New Language
                        var addEducationTypeRequest = new AddEducationTypeRequest()
                        {
                            Name = parent.GetFieldValue(record.Fields, _educationTypeName),
                            IsEnabled = true
                        };
                        record.Fields.First(f => f.FieldName == _educationTypeId).FieldValue = parent.ProcessRequest<AddEducationTypeResponse>(addEducationTypeRequest).Id;
                    }

                    //Add newly created language to provider
                    var request = new AddProviderEducationRequest()
                    {
                        ProviderId = providerId,
                        EducationTypeId = int.Parse(parent.GetFieldValue(record.Fields, _educationTypeId)),
                        InstitutionName = parent.GetFieldValue(record.Fields, _institutionName),
                        IsCompleted = bool.Parse(parent.GetFieldValue(record.Fields, _isCompleted)),
                        YearCompleted = parent.GetFieldValue(record.Fields, _yearCompleted)
                    };

                    parent.ProcessRequest<AddProviderEducationResponse>(request);
                }

                //Deletes
                foreach (var record in providerEducations.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderEducationRequest()
                    {
                        Id = int.Parse(parent.GetFieldValue(record.Fields, _id))
                    };
                    parent.ProcessRequest<DeleteProviderEducationResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerEducations.ErrorMessage = ex.Message;
                throw;
            }

            providerEducations = BuildEducationsSubEntity(parent, providerId);
        }