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 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); }