public virtual void CopyHealthBenefit1Properties(
     HealthBenefit1Calculator 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;
 }
        public bool RunHCCalculations(CalculatorParameters calcParameters,
                                      HealthBenefit1Calculator 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);
        }
 private void FixSelections(HealthBenefit1Calculator hcBenefit1)
 {
     if (hcBenefit1.Demographics == null)
     {
         hcBenefit1.Demographics = new Demog1();
     }
     Demog1.FixSelections(hcBenefit1.Demographics);
 }
        public static double GetMultiplierForHealthCareCost1(HealthBenefit1Calculator hcCost1)
        {
            //health output only multiplier (IOHCStockSubscriber uses input.times instead)
            double multiplier = 0;

            //double multiplier = (hcCost1.ActualServingsPerContainer == 0)
            //    ? 1 : hcCost1.ServingsPerContainer / hcCost1.ActualServingsPerContainer;
            return(multiplier);
        }
        private List <HealthBenefit1Calculator> GetHealthCareOutputs(CalculatorParameters calcParameters)
        {
            List <HealthBenefit1Calculator> hcOutputs = new List <HealthBenefit1Calculator>();

            foreach (Output output in calcParameters.ParentOutcome.Outputs)
            {
                if (output.AnnuityType == TimePeriod.ANNUITY_TYPES.none &&
                    output.XmlDocElement != null)
                {
                    //0.9.0 stays consistent across all apps by using standard calc patterns
                    if (output.XmlDocElement.HasElements)
                    {
                        XElement oOutputElement = new XElement(output.XmlDocElement);
                        //set the output atts
                        Output.SetOutputAllAttributes(output, ref oOutputElement);
                        string sCalculatorType
                            = CalculatorHelpers.GetCalculatorType(oOutputElement);
                        XElement oHealthCareOutputElement = GetHealthCareCalculator(calcParameters,
                                                                                    sCalculatorType, oOutputElement);
                        if (oHealthCareOutputElement != null && oOutputElement != null)
                        {
                            string sErrorMsg            = string.Empty;
                            bool   bHasThisCalculations = false;
                            sCalculatorType
                                = CalculatorHelpers.GetCalculatorType(oHealthCareOutputElement);
                            if (sCalculatorType
                                == HCCalculatorHelper.CALCULATOR_TYPES.hcbenefit1.ToString())
                            {
                                string sAttNameExtension          = string.Empty;
                                HealthBenefit1Calculator hcOutput = new HealthBenefit1Calculator();
                                //serialize in same manner as OutputHCStockCalculator
                                hcOutput.SetOutputProperties(calcParameters,
                                                             oHealthCareOutputElement, oOutputElement);
                                hcOutput.SetHealthBenefit1Properties(oHealthCareOutputElement);
                                OutputHCStockCalculator hcCalculator = new OutputHCStockCalculator();
                                bHasThisCalculations = hcCalculator.RunHCStockCalculations(hcOutput,
                                                                                           calcParameters);
                                //store the new calculations
                                hcOutput.XmlDocElement      = oHealthCareOutputElement;
                                calcParameters.ErrorMessage = sErrorMsg;
                                //they need to find one another when serializing
                                output.CalculatorId = hcOutput.CalculatorId;
                                hcOutputs.Add(hcOutput);
                            }
                        }
                    }
                }
            }
            return(hcOutputs);
        }
 private void SerializeHealthCareOutputCalculations(CalculatorParameters calcParameters,
                                                    List <HealthBenefit1Calculator> hcOutputs)
 {
     if (calcParameters.ParentOutcome.Outputs != null &&
         hcOutputs != null)
     {
         foreach (Output output in calcParameters.ParentOutcome.Outputs)
         {
             if (output.AnnuityType == TimePeriod.ANNUITY_TYPES.none &&
                 output.XmlDocElement != null)
             {
                 //this was set up when serialized
                 HealthBenefit1Calculator hcOutput = hcOutputs.FirstOrDefault(
                     f => f.CalculatorId == output.CalculatorId);
                 if (hcOutput != null)
                 {
                     if (hcOutput.XmlDocElement != null)
                     {
                         XElement oHealtCareOutputElement = new XElement(hcOutput.XmlDocElement);
                         XElement oOutputElement          = new XElement(output.XmlDocElement);
                         //serialize object back to xml using standard MachCalc1 pattern
                         if (hcOutput.CalculatorType
                             == HCCalculatorHelper.CALCULATOR_TYPES.hcbenefit1.ToString())
                         {
                             string sAttNameExtension = string.Empty;
                             hcOutput.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                                       ref oHealtCareOutputElement);
                             hcOutput.SetNewOutputAttributes(calcParameters, ref oHealtCareOutputElement);
                             hcOutput.SetHealthBenefit1Attributes(sAttNameExtension,
                                                                  ref oHealtCareOutputElement);
                         }
                         //mark this linkedview as edited (GetCalculator uses it later)
                         oHealtCareOutputElement.SetAttributeValue(CostBenefitStatistic01.TYPE_NEWCALCS,
                                                                   "true");
                         //update output agmach linkedview with new calcs
                         oOutputElement = new XElement(output.XmlDocElement);
                         CalculatorHelpers.ReplaceElementInDocument(oHealtCareOutputElement,
                                                                    ref oOutputElement);
                         //update output with new prices and amounts
                         output.XmlDocElement = oOutputElement;
                         output.Price         = hcOutput.Price;
                         //tells calculators to swap out output being calculated with this one
                         output.Type = CostBenefitCalculator.TYPE_NEWCALCS;
                     }
                 }
             }
         }
     }
 }
        public bool RunHCStockCalculations(HealthBenefit1Calculator healthCostOutput,
                                           CalculatorParameters calcParameters)
        {
            bool bHasCalculations = false;

            //see if any db props are being changed by calculator
            TransferCorrespondingDbProperties(ref healthCostOutput);
            //set the multiplier (the multiplier in most inputs is 1,
            //this is kept here to keep a uniform pattern when the multiplier
            //can be changed -see the food nutrition calculator)
            double multiplier = GetMultiplierForHealthCareCost1(healthCostOutput);

            bHasCalculations = healthCostOutput.RunHCCalculations(calcParameters, healthCostOutput);
            return(bHasCalculations);
        }
Exemple #8
0
        public static int GetNodePositionCount(this OutputHCStock baseStat,
                                               int filePosition, HealthBenefit1Calculator hcOutputStock)
        {
            int iNodeCount = 0;

            if (baseStat.HealthCareBenefit1s == null)
            {
                return(iNodeCount);
            }
            if (baseStat.HealthCareBenefit1s.ContainsKey(filePosition))
            {
                if (baseStat.HealthCareBenefit1s[filePosition] != null)
                {
                    iNodeCount = baseStat.HealthCareBenefit1s[filePosition].Count;
                }
            }
            return(iNodeCount);
        }
        private void SetAverageBenefitRating(HealthBenefit1Calculator 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(HealthBenefit1Calculator 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 HealthBenefit1Calculator(HealthBenefit1Calculator healthBenefit1)
     : base(healthBenefit1)
 {
     CopyHealthBenefit1Properties(healthBenefit1);
 }
Exemple #12
0
        //add a hcOutputfact to the baseStat.HealthCareBenefit1s dictionary
        public static bool AddOutputHCStocksToDictionary(this OutputHCStock baseStat,
                                                         int filePosition, int nodePosition, HealthBenefit1Calculator hcOutputStock)
        {
            bool bIsAdded = false;

            if (filePosition < 0 || nodePosition < 0)
            {
                baseStat.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS");
                return(false);
            }
            if (baseStat.HealthCareBenefit1s == null)
            {
                baseStat.HealthCareBenefit1s
                    = new Dictionary <int, List <HealthBenefit1Calculator> >();
            }
            if (baseStat.HealthCareBenefit1s.ContainsKey(filePosition))
            {
                if (baseStat.HealthCareBenefit1s[filePosition] != null)
                {
                    for (int i = 0; i <= nodePosition; i++)
                    {
                        if (baseStat.HealthCareBenefit1s[filePosition].Count <= i)
                        {
                            baseStat.HealthCareBenefit1s[filePosition]
                            .Add(new HealthBenefit1Calculator());
                        }
                    }
                    baseStat.HealthCareBenefit1s[filePosition][nodePosition]
                             = hcOutputStock;
                    bIsAdded = true;
                }
            }
            else
            {
                //add the missing dictionary entry
                List <HealthBenefit1Calculator> baseStats
                    = new List <HealthBenefit1Calculator>();
                KeyValuePair <int, List <HealthBenefit1Calculator> > newStat
                    = new KeyValuePair <int, List <HealthBenefit1Calculator> >(
                          filePosition, baseStats);
                baseStat.HealthCareBenefit1s.Add(newStat);
                bIsAdded = AddOutputHCStocksToDictionary(baseStat,
                                                         filePosition, nodePosition, hcOutputStock);
            }
            return(bIsAdded);
        }
        public bool AddCalculationsToCurrentElement(
            CalculatorParameters calcParameters,
            XElement currentCalculationsElement, XElement currentElement,
            IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            if (currentElement.Name.LocalName
                == Output.OUTPUT_PRICE_TYPES.outputgroup.ToString() &&
                calcParameters.ExtensionDocToCalcURI.URINodeName
                != Constants.LINKEDVIEWS_TYPES.linkedview.ToString())
            {
                bHasCalculations = BIHC1Calculator.SetTotalHCStockCalculations(
                    currentCalculationsElement, currentElement);
            }
            else
            {
                if (currentCalculationsElement != null)
                {
                    HealthBenefit1Calculator healthCostOutput = new HealthBenefit1Calculator();
                    //deserialize xml to object
                    healthCostOutput.SetHealthBenefit1Properties(calcParameters,
                                                                 currentCalculationsElement, currentElement);
                    //init analyzer props
                    healthCostOutput.SetCalculatorProperties(currentCalculationsElement);
                    //run the calculations
                    bHasCalculations = RunHCStockCalculations(healthCostOutput,
                                                              calcParameters);
                    //serialize object back to xml
                    string sAttNameExtension = string.Empty;
                    //bool bRemoveAtts = false;
                    //note that unlike other IOAnalyzers, this runs the input calc too
                    //and must update input props to calculated results (OCAmount and OCPrice calcs)
                    //also note that if input analyzers are needed, probably want to use BIHCStockCalcor
                    //so that does not update input db props and keeps consistent pattern
                    healthCostOutput.SetOutputAttributes(calcParameters,
                                                         currentElement, updates);
                    //update the calculator attributes
                    healthCostOutput.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                                      currentCalculationsElement);
                    healthCostOutput.SetNewOutputAttributes(calcParameters, currentCalculationsElement);
                    healthCostOutput.SetHealthBenefit1Attributes(sAttNameExtension,
                                                                 currentCalculationsElement);

                    //set calculatorid (primary way to display calculation attributes)
                    CalculatorHelpers.SetCalculatorId(
                        currentCalculationsElement, currentElement);
                    //input groups only aggregate inputs (not input series)
                    if (currentElement.Name.LocalName
                        .Contains(Output.OUTPUT_PRICE_TYPES.output.ToString()))
                    {
                        //add the machinery to the machstock.machstocks dictionary
                        //the count is 1-based, while iNodePosition is 0-based
                        //so the count is the correct next index position
                        int iNodePosition = BIHC1Calculator.OutputHCStock
                                            .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex,
                                                                  healthCostOutput);
                        if (iNodePosition < 0)
                        {
                            iNodePosition = 0;
                        }
                        bHasCalculations = BIHC1Calculator.OutputHCStock
                                           .AddOutputHCStocksToDictionary(
                            calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition,
                            healthCostOutput);
                    }
                }
            }
            return(bHasCalculations);
        }
 private void TransferCorrespondingDbProperties(
     ref HealthBenefit1Calculator healthCostOutput)
 {
     //nothing yet
 }