예제 #1
0
        public void Rate()
        {
            Logger.Log("Starting ExecuteSomething");

            string policyJson = PolicySource.GetPolicyFromSource();

            var policy = PolicySerializer.GetPolicyFromJsonString(policyJson);

            switch (policy.Type)
            {
            case PolicyType.Auto:
                Logger.Log("Rating AUTO policy...");
                if (policy.Make == "BMW")
                {
                    if (policy.Deductible < 500)
                    {
                        Rating = 1000m;
                    }
                    Rating = 900m;
                }
                break;

            case PolicyType.Land:
                Logger.Log("Rating LAND policy...");
                if (policy.BondAmount == 0 || policy.Valuation == 0)
                {
                    Console.WriteLine("Land policy must specify Bond Amount and Valuation.");
                    return;
                }
                Rating = policy.BondAmount * 0.05m;
                break;

            case PolicyType.Life:
                Logger.Log("Rating LIFE policy...");
                int     age      = DateTime.Today.Year - policy.DateOfBirth.Year;
                decimal baseRate = policy.Amount * age / 200;
                if (policy.IsSmoker)
                {
                    Rating = baseRate * 2;
                    break;
                }
                Rating = baseRate;
                break;

            default:
                Logger.Log("Unknown policy type");
                break;
            }
        }
예제 #2
0
        public void Rate()
        {
            Logger.Log("Starting rate.");
            Logger.Log("Loading policy.");

            // load policy - open file policy.json
            string policyJson = PolicySource.GettPolicyFromSource();
            var    policy     = PolicySerializer.GetPolicyFromJsonString(policyJson);

            var factory = new RaterFactory();
            var rater   = factory.Create(policy, this);

            rater.Rate(policy);

            Logger.Log("Rating completed.");
        }
예제 #3
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 73, Configuration.FieldSeparator),
                       Id,
                       InsuredsEmployeeId != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsEmployeeId.Select(x => x.ToDelimitedString())) : null,
                       InsuredsSocialSecurityNumber,
                       InsuredsEmployersNameAndId != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsEmployersNameAndId.Select(x => x.ToDelimitedString())) : null,
                       EmployerInformationData?.ToDelimitedString(),
                       MailClaimParty != null ? string.Join(Configuration.FieldRepeatSeparator, MailClaimParty.Select(x => x.ToDelimitedString())) : null,
                       MedicareHealthInsCardNumber,
                       MedicaidCaseName != null ? string.Join(Configuration.FieldRepeatSeparator, MedicaidCaseName.Select(x => x.ToDelimitedString())) : null,
                       MedicaidCaseNumber,
                       MilitarySponsorName != null ? string.Join(Configuration.FieldRepeatSeparator, MilitarySponsorName.Select(x => x.ToDelimitedString())) : null,
                       MilitaryIdNumber,
                       DependentOfMilitaryRecipient?.ToDelimitedString(),
                       MilitaryOrganization,
                       MilitaryStation,
                       MilitaryService?.ToDelimitedString(),
                       MilitaryRankGrade?.ToDelimitedString(),
                       MilitaryStatus?.ToDelimitedString(),
                       MilitaryRetireDate.HasValue ? MilitaryRetireDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       MilitaryNonAvailCertOnFile,
                       BabyCoverage,
                       CombineBabyBill,
                       BloodDeductible,
                       SpecialCoverageApprovalName != null ? string.Join(Configuration.FieldRepeatSeparator, SpecialCoverageApprovalName.Select(x => x.ToDelimitedString())) : null,
                       SpecialCoverageApprovalTitle,
                       NonCoveredInsuranceCode != null ? string.Join(Configuration.FieldRepeatSeparator, NonCoveredInsuranceCode.Select(x => x.ToDelimitedString())) : null,
                       PayorId != null ? string.Join(Configuration.FieldRepeatSeparator, PayorId.Select(x => x.ToDelimitedString())) : null,
                       PayorSubscriberId != null ? string.Join(Configuration.FieldRepeatSeparator, PayorSubscriberId.Select(x => x.ToDelimitedString())) : null,
                       EligibilitySource?.ToDelimitedString(),
                       RoomCoverageTypeAmount != null ? string.Join(Configuration.FieldRepeatSeparator, RoomCoverageTypeAmount.Select(x => x.ToDelimitedString())) : null,
                       PolicyTypeAmount != null ? string.Join(Configuration.FieldRepeatSeparator, PolicyTypeAmount.Select(x => x.ToDelimitedString())) : null,
                       DailyDeductible?.ToDelimitedString(),
                       LivingDependency?.ToDelimitedString(),
                       AmbulatoryStatus != null ? string.Join(Configuration.FieldRepeatSeparator, AmbulatoryStatus.Select(x => x.ToDelimitedString())) : null,
                       Citizenship != null ? string.Join(Configuration.FieldRepeatSeparator, Citizenship.Select(x => x.ToDelimitedString())) : null,
                       PrimaryLanguage?.ToDelimitedString(),
                       LivingArrangement?.ToDelimitedString(),
                       PublicityCode?.ToDelimitedString(),
                       ProtectionIndicator,
                       StudentIndicator?.ToDelimitedString(),
                       Religion?.ToDelimitedString(),
                       MothersMaidenName != null ? string.Join(Configuration.FieldRepeatSeparator, MothersMaidenName.Select(x => x.ToDelimitedString())) : null,
                       Nationality?.ToDelimitedString(),
                       EthnicGroup != null ? string.Join(Configuration.FieldRepeatSeparator, EthnicGroup.Select(x => x.ToDelimitedString())) : null,
                       MaritalStatus != null ? string.Join(Configuration.FieldRepeatSeparator, MaritalStatus.Select(x => x.ToDelimitedString())) : null,
                       InsuredsEmploymentStartDate.HasValue ? InsuredsEmploymentStartDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       EmploymentStopDate.HasValue ? EmploymentStopDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       JobTitle,
                       JobCodeClass?.ToDelimitedString(),
                       JobStatus?.ToDelimitedString(),
                       EmployerContactPersonName != null ? string.Join(Configuration.FieldRepeatSeparator, EmployerContactPersonName.Select(x => x.ToDelimitedString())) : null,
                       EmployerContactPersonPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, EmployerContactPersonPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       EmployerContactReason?.ToDelimitedString(),
                       InsuredsContactPersonsName != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsContactPersonsName.Select(x => x.ToDelimitedString())) : null,
                       InsuredsContactPersonPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsContactPersonPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       InsuredsContactPersonReason != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsContactPersonReason.Select(x => x.ToDelimitedString())) : null,
                       RelationshipToThePatientStartDate.HasValue ? RelationshipToThePatientStartDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       RelationshipToThePatientStopDate != null ? string.Join(Configuration.FieldRepeatSeparator, RelationshipToThePatientStopDate.Select(x => x.ToString(Consts.DateFormatPrecisionDay, culture))) : null,
                       InsuranceCoContactReason?.ToDelimitedString(),
                       InsuranceCoContactPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, InsuranceCoContactPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       PolicyScope?.ToDelimitedString(),
                       PolicySource?.ToDelimitedString(),
                       PatientMemberNumber?.ToDelimitedString(),
                       GuarantorsRelationshipToInsured?.ToDelimitedString(),
                       InsuredsPhoneNumberHome != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsPhoneNumberHome.Select(x => x.ToDelimitedString())) : null,
                       InsuredsEmployerPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredsEmployerPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       MilitaryHandicappedProgram?.ToDelimitedString(),
                       SuspendFlag,
                       CopayLimitFlag,
                       StoplossLimitFlag,
                       InsuredOrganizationNameAndId != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredOrganizationNameAndId.Select(x => x.ToDelimitedString())) : null,
                       InsuredEmployerOrganizationNameAndId != null ? string.Join(Configuration.FieldRepeatSeparator, InsuredEmployerOrganizationNameAndId.Select(x => x.ToDelimitedString())) : null,
                       Race != null ? string.Join(Configuration.FieldRepeatSeparator, Race.Select(x => x.ToDelimitedString())) : null,
                       PatientsRelationshipToInsured?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
예제 #4
0
        public void Rate()
        {
            Logger.Log("Starting rate.");

            Logger.Log("Loading policy.");

            var policyJson = PolicySource.GetPolicyFromSource();

            var policy = PolicySerializer.GetPolicyFromJsonString(policyJson);

            switch (policy.Type)
            {
            case PolicyType.Auto:
                Logger.Log("Rating AUTO policy...");

                Logger.Log("Validating policy.");

                if (string.IsNullOrEmpty(policy.Make))
                {
                    Logger.Log("Auto policy must specify make");

                    return;
                }

                if (policy.Make == "BMW")
                {
                    if (policy.Deductible < 500)
                    {
                        Rating = 1000m;
                    }

                    Rating = 900m;
                }

                break;

            case PolicyType.Land:
                Logger.Log("Rating LAND policy.");

                Logger.Log("Validating policy.");

                if (policy.BondAmount == 0 || policy.Valuation == 0)
                {
                    Logger.Log("Land policy must specify Bond Amount and Valuation.");

                    return;
                }

                if (policy.BondAmount < 0.8m * policy.Valuation)
                {
                    Logger.Log("Insufficient bond amount");

                    return;
                }

                Rating = policy.BondAmount * 0.05m;

                break;

            default:
                Logger.Log("Unknown policy type.");

                break;
            }

            Logger.Log("Rating completed.");
        }