示例#1
0
        private void updateAlternativeParameters(ParameterAlternative alternative, IMoleculeBuilder drug)
        {
            var allParameters = alternative.AllParameters().ToList();

            foreach (var alternativeParameter in allParameters)
            {
                //Parameter does not exist in drug?
                var drugParameter = drug.Parameter(alternativeParameter.Name);
                if (drugParameter == null)
                {
                    continue;
                }

                //parameter is a rate. parameter in molecule should be readonly
                if (!alternativeParameter.Formula.IsConstant())
                {
                    drugParameter.Editable = false;
                }

                //target parameter is a rate and source parmaeter is constant
                else if (!drugParameter.Formula.IsConstant())
                {
                    drugParameter.Formula = _objectBaseFactory.Create <ConstantFormula>().WithValue(alternativeParameter.Value);
                }

                _parameterSetUpdater.UpdateValue(alternativeParameter, drugParameter);

                //only update value description if the alternative contains one and one only parameter
                if (allParameters.Count == 1)
                {
                    drugParameter.ValueDescription = alternative.Description;
                }
            }
        }
示例#2
0
        private void updateAlternativeParameters(ParameterAlternative alternative, IMoleculeBuilder drug, IFormulaCache formulaCache)
        {
            var allParameters = alternative.AllParameters().ToList();

            foreach (var alternativeParameter in allParameters)
            {
                //Parameter does not exist in drug?
                var drugParameter = drug.Parameter(alternativeParameter.Name);
                if (drugParameter == null)
                {
                    continue;
                }

                if (alternativeParameter.Formula.IsTable())
                {
                    var tableFormula = _cloner.Clone(alternativeParameter.Formula);
                    formulaCache.Add(tableFormula);
                    drugParameter.Formula = tableFormula;
                }

                //parameter is a rate. parameter in molecule should be readonly
                else if (!alternativeParameter.Formula.IsConstant())
                {
                    drugParameter.Editable = false;
                }

                //target parameter is a rate and source parameter is constant
                else if (!drugParameter.Formula.IsConstant())
                {
                    drugParameter.Formula = _objectBaseFactory.Create <ConstantFormula>().WithValue(alternativeParameter.Value);
                }

                _parameterSetUpdater.UpdateValue(alternativeParameter, drugParameter);

                //Default parameter Default and visible may not match database default and need to be set according to alternative parameter
                drugParameter.IsDefault = alternativeParameter.IsDefault;
                drugParameter.Visible   = alternativeParameter.Visible;
            }
        }