private void TransferCorrespondingDbProperties(
     ref HealthCareCost1Calculator healthCostInput)
 {
     //calculators can use aliases to change db properties
     //but this calc gets its MV from input.CapPrice
     healthCostInput.BasePrice = healthCostInput.CAPPrice;
 }
        public static double GetMultiplierForHealthCareCost1(HealthCareCost1Calculator hcCost1)
        {
            //health input only multiplier (IOHCStockSubscriber uses input.times instead)
            double multiplier = 0;

            //double multiplier = (hcCost1.ActualServingsPerContainer == 0)
            //    ? 1 : hcCost1.ServingsPerContainer / hcCost1.ActualServingsPerContainer;
            return(multiplier);
        }
        public bool RunHCStockCalculations(HealthCareCost1Calculator healthCostInput,
                                           CalculatorParameters calcParameters)
        {
            bool bHasCalculations = false;

            //see if any db props are being changed by calculator
            TransferCorrespondingDbProperties(ref healthCostInput);
            //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(healthCostInput);

            bHasCalculations = healthCostInput.RunHCCalculations(calcParameters, healthCostInput);
            return(bHasCalculations);
        }
Beispiel #4
0
        public static int GetNodePositionCount(this InputHCStock baseStat,
                                               int filePosition, HealthCareCost1Calculator hcInputStock)
        {
            int iNodeCount = 0;

            if (baseStat.HealthCareCost1s == null)
            {
                return(iNodeCount);
            }
            if (baseStat.HealthCareCost1s.ContainsKey(filePosition))
            {
                if (baseStat.HealthCareCost1s[filePosition] != null)
                {
                    iNodeCount = baseStat.HealthCareCost1s[filePosition].Count;
                }
            }
            return(iNodeCount);
        }
Beispiel #5
0
        //add a base health input stock to the baseStat.HealthCareCost1s dictionary
        public static bool AddInputHCStocksToDictionary(this InputHCStock baseStat,
                                                        int filePosition, int nodePosition, HealthCareCost1Calculator hcInputStock)
        {
            bool bIsAdded = false;

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

            if (currentElement.Name.LocalName
                == Input.INPUT_PRICE_TYPES.inputgroup.ToString() &&
                calcParameters.ExtensionDocToCalcURI.URINodeName
                != Constants.LINKEDVIEWS_TYPES.linkedview.ToString())
            {
                bHasCalculations = BIHC1Calculator.SetTotalHCStockCalculations(
                    currentCalculationsElement, currentElement);
            }
            else
            {
                if (currentCalculationsElement != null)
                {
                    HealthCareCost1Calculator healthCostInput = new HealthCareCost1Calculator();
                    //deserialize xml to object
                    healthCostInput.SetHealthCareCost1Properties(calcParameters,
                                                                 currentCalculationsElement, currentElement);
                    //init analyzer props
                    healthCostInput.SetCalculatorProperties(currentCalculationsElement);
                    //run the calculations
                    bHasCalculations = RunHCStockCalculations(healthCostInput,
                                                              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
                    healthCostInput.SetInputAttributes(calcParameters,
                                                       currentElement, updates);
                    //update the calculator attributes
                    healthCostInput.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                                     currentCalculationsElement);
                    healthCostInput.SetNewInputAttributes(calcParameters, currentCalculationsElement);
                    healthCostInput.SetHealthCareCost1Attributes(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(Input.INPUT_PRICE_TYPES.input.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.InputHCStock
                                            .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex,
                                                                  healthCostInput);
                        if (iNodePosition < 0)
                        {
                            iNodePosition = 0;
                        }
                        bHasCalculations = BIHC1Calculator.InputHCStock
                                           .AddInputHCStocksToDictionary(
                            calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition,
                            healthCostInput);
                    }
                }
            }
            return(bHasCalculations);
        }