public bool RunHCCalculations(CalculatorParameters calcParameters,
                                      HealthBenefit2Calculator hcBenefit1)
        {
            bool bHasCalculations = false;

            if (hcBenefit1 != null)
            {
                FixSelections(hcBenefit1);
                //calculate the adjusted benefit
                hcBenefit1.AdjustedBenefit = hcBenefit1.OutputCost * (hcBenefit1.BenefitAdjustment / 100);

                //set the base input properties
                //remember not to set amounts or the calcs have to be rerun in npv calcors
                hcBenefit1.Price = hcBenefit1.AdjustedBenefit;
                hcBenefit1.Unit  = (hcBenefit1.Unit != string.Empty && hcBenefit1.Unit != Constants.NONE)
                    ? hcBenefit1.Unit : Constants.EACH;
                //set the bcrating (equally weighted)
                SetAverageBenefitRating(hcBenefit1);
                bHasCalculations = true;
            }
            else
            {
                calcParameters.ErrorMessage = Errors.MakeStandardErrorMsg("CALCULATORS_WRONG_ONE");
            }
            return(bHasCalculations);
        }
 public virtual void CopyHealthBenefit2Properties(
     HealthBenefit2Calculator calculator)
 {
     this.Demographics.CopyDemog1Properties(calculator.Demographics);
     this.OutputCost               = calculator.OutputCost;
     this.BenefitAdjustment        = calculator.BenefitAdjustment;
     this.AdjustedBenefit          = calculator.AdjustedBenefit;
     this.OutputEffect1Name        = calculator.OutputEffect1Name;
     this.OutputEffect1Unit        = calculator.OutputEffect1Unit;
     this.OutputEffect1Amount      = calculator.OutputEffect1Amount;
     this.OutputEffect1Price       = calculator.OutputEffect1Price;
     this.OutputEffect1Cost        = calculator.OutputEffect1Cost;
     this.AverageBenefitRating     = calculator.AverageBenefitRating;
     this.PhysicalHealthRating     = calculator.PhysicalHealthRating;
     this.EmotionalHealthRating    = calculator.EmotionalHealthRating;
     this.SocialHealthRating       = calculator.SocialHealthRating;
     this.EconomicHealthRating     = calculator.EconomicHealthRating;
     this.HealthCareDeliveryRating = calculator.HealthCareDeliveryRating;
     this.BeforeQOLRating          = calculator.BeforeQOLRating;
     this.AfterQOLRating           = calculator.AfterQOLRating;
     this.BeforeYears              = calculator.BeforeYears;
     this.AfterYears               = calculator.AfterYears;
     this.AfterYearsProb           = calculator.AfterYearsProb;
     this.TimeTradeoffYears        = calculator.TimeTradeoffYears;
     this.EquityMultiplier         = calculator.EquityMultiplier;
     this.BenefitAssessment        = calculator.BenefitAssessment;
     this.QALY         = calculator.QALY;
     this.ICERQALY     = calculator.ICERQALY;
     this.TTOQALY      = calculator.TTOQALY;
     this.WillDoSurvey = calculator.WillDoSurvey;
 }
 private void FixSelections(HealthBenefit2Calculator hcBenefit1)
 {
     if (hcBenefit1.Demographics == null)
     {
         hcBenefit1.Demographics = new Demog1();
     }
     Demog1.FixSelections(hcBenefit1.Demographics);
 }
        private void SetAverageBenefitRating(HealthBenefit2Calculator hcBenefit1)
        {
            //five dimension benefit rating
            SetBenefitRating(hcBenefit1);
            //effects
            hcBenefit1.OutputEffect1Cost = hcBenefit1.OutputEffect1Amount * hcBenefit1.OutputEffect1Price;

            //these need to be discounted by real rate and before or after years
            //conversion to double
            double onehundred        = 100;
            double dbBeforeQOLRating = (hcBenefit1.BeforeQOLRating / onehundred);
            double dbAfterQOLRating  = (hcBenefit1.AfterQOLRating / onehundred);
            //discounted QALY
            double dbAfterDiscountFactor = MathHelpers.DiscountFactor(hcBenefit1.Local.RealRate, hcBenefit1.AfterYears);

            hcBenefit1.QALY = dbAfterQOLRating * hcBenefit1.AfterYears * dbAfterDiscountFactor;
            //discounted QALY
            double dbBeforeDiscountFactor = MathHelpers.DiscountFactor(hcBenefit1.Local.RealRate, hcBenefit1.BeforeYears);
            double dbBeforeQALY           = dbBeforeQOLRating * hcBenefit1.BeforeYears * dbBeforeDiscountFactor;

            if (hcBenefit1.EquityMultiplier > 0)
            {
                dbBeforeQALY = dbBeforeQALY * (hcBenefit1.EquityMultiplier / onehundred);
            }
            if (hcBenefit1.AfterYearsProb > 0 && hcBenefit1.AfterYearsProb < onehundred)
            {
                hcBenefit1.QALY = (hcBenefit1.QALY * (hcBenefit1.AfterYearsProb / onehundred))
                                  + (dbBeforeQALY * ((onehundred - hcBenefit1.AfterYearsProb) / onehundred));
            }
            if (hcBenefit1.EquityMultiplier > 0)
            {
                hcBenefit1.QALY = hcBenefit1.QALY * (hcBenefit1.EquityMultiplier / onehundred);
            }
            //incremental QALY gain
            hcBenefit1.ICERQALY = hcBenefit1.QALY - dbBeforeQALY;

            //ttoqaly (qaly weight * after years * discount factor)
            hcBenefit1.TTOQALY = (hcBenefit1.TimeTradeoffYears / hcBenefit1.BeforeYears) * hcBenefit1.AfterYears * dbAfterDiscountFactor;
            if (hcBenefit1.EquityMultiplier > 0)
            {
                hcBenefit1.TTOQALY = hcBenefit1.TTOQALY * (hcBenefit1.EquityMultiplier / onehundred);
            }
        }
        private void SetBenefitRating(HealthBenefit2Calculator hcBenefit1)
        {
            double dbBCRating = 0;
            int    iDivisor   = 0;

            if (hcBenefit1.PhysicalHealthRating > 0)
            {
                dbBCRating += hcBenefit1.PhysicalHealthRating;
                iDivisor   += 1;
            }
            if (hcBenefit1.EmotionalHealthRating > 0)
            {
                dbBCRating += hcBenefit1.EmotionalHealthRating;
                iDivisor   += 1;
            }
            if (hcBenefit1.SocialHealthRating > 0)
            {
                dbBCRating += hcBenefit1.SocialHealthRating;
                iDivisor   += 1;
            }
            if (hcBenefit1.EconomicHealthRating > 0)
            {
                dbBCRating += hcBenefit1.EconomicHealthRating;
                iDivisor   += 1;
            }
            if (hcBenefit1.HealthCareDeliveryRating > 0)
            {
                dbBCRating += hcBenefit1.HealthCareDeliveryRating;
                iDivisor   += 1;
            }
            if (iDivisor == 0)
            {
                hcBenefit1.AverageBenefitRating = 0;
            }
            else
            {
                hcBenefit1.AverageBenefitRating = dbBCRating / iDivisor;
            }
        }
 //copy constructor
 public HealthBenefit2Calculator(HealthBenefit2Calculator healthBenefit1)
     : base(healthBenefit1)
 {
     CopyHealthBenefit2Properties(healthBenefit1);
 }