public CharacteristicQuantificationDetailsControl(StandardValidTerm characteristicCode, CharacteristicQuantification characteristicQuantification)
        {
            InitializeComponent();

            _characteristicCode = characteristicCode;
            _txtName.Text = string.IsNullOrEmpty(characteristicQuantification.Name) ? @"Name is missing" : characteristicQuantification.Name;
            _quantificationType = IdentifyCharQuantificationType(characteristicQuantification);

            SuspendLayout();

            InitializeCharQuantificationControls(characteristicQuantification);

            if (characteristicQuantification.AnnotatorConfidence)
            {
                _confidenceControl = InitializeConfidenceControl();
                Controls.Add(_confidenceControl);
                Height += _confidenceControl.Height;
            }

            ResumeLayout(false);
            PerformLayout();
        }
        private void InitializeCharQuantificationControls(CharacteristicQuantification characteristicQuantification)
        {
            var selectionItems = new List<object>();
            if (characteristicQuantification.NonQuantifiable != null && characteristicQuantification.NonQuantifiable.Count > 0)
            {

                selectionItems.Add(new CodeSequenceListItem(null));
                foreach (var nonQuantifiable in characteristicQuantification.NonQuantifiable)
                {
                    selectionItems.Add(new CodeSequenceListItem(
                                            new StandardCodeSequence(nonQuantifiable.CodeValue, nonQuantifiable.CodeMeaning, nonQuantifiable.CodingSchemeDesignator,
                                                                     nonQuantifiable.CodingSchemeVersion)));
                }
            }

            switch(CharacteristicQuantificationType)
            {
                case CharacteristicQuantificationType.Numerical:
                    {
                        foreach (var numerical in characteristicQuantification.Numerical)
                        {
                            selectionItems.Add(new NumericalListItem(numerical.Value, numerical.Operator, numerical.UcumString));
                        }
                    }
                    break;
                case CharacteristicQuantificationType.Quantile:
                    {
                        for (var i = 0; i < characteristicQuantification.Quantile.Bins; i++ )
                        {
                            selectionItems.Add(new QuantileListItem(i));
                        }
                    }
                    break;
                case CharacteristicQuantificationType.Scale:
                    {
                        _scaleComment = characteristicQuantification.Scale.Comment;
                        _scaleDescription = characteristicQuantification.Scale.Description;
                        foreach (var ordinalLevel in characteristicQuantification.Scale.OrdinalLevel)
                        {
                            selectionItems.Add(new ScaleListItem(ordinalLevel.IntegerValue, ordinalLevel.Description));
                        }
                    }
                    break;
                case CharacteristicQuantificationType.Interval:
                    {
                        foreach (var interval in characteristicQuantification.Interval)
                        {
                            selectionItems.Add(new IntervalListItem(interval.MinValue, interval.MaxValue, interval.MinOperator, interval.MaxOperator, interval.UcumString));
                        }
                    }
                    break;
                case CharacteristicQuantificationType.NonQuantifiable:
                    break;
            }

            var lastControl = LastControl;
            var ptX = _lblName.Location.X;
            var ptY = lastControl.Location.Y + lastControl.Height + lastControl.Margin.Bottom;

            var ddlQuantificationItems = new ComboBox();
            ddlQuantificationItems.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            ddlQuantificationItems.DropDownStyle = ComboBoxStyle.DropDownList;
            ddlQuantificationItems.FormattingEnabled = true;
            ddlQuantificationItems.Margin = new Padding(4);
            ddlQuantificationItems.Location = new System.Drawing.Point(ptX, ptY + ddlQuantificationItems.Margin.Top);
            ddlQuantificationItems.Name = "_ddlQuantificationItems";
            ddlQuantificationItems.Size = new System.Drawing.Size(Width - Margin.Horizontal, ddlQuantificationItems.Height);
            ddlQuantificationItems.TabIndex = lastControl.TabIndex + 1;

            foreach (var item in selectionItems)
                ddlQuantificationItems.Items.Add(item);
            if (ddlQuantificationItems.Items.Count > 0)
                ddlQuantificationItems.SelectedIndex = 0;
            ddlQuantificationItems.DropDown += OnDropDown;
            ddlQuantificationItems.SelectedIndexChanged += OnSelectedIndexChanged;

            Controls.Add(ddlQuantificationItems);
            Height += ddlQuantificationItems.Height + ddlQuantificationItems.Margin.Top;
        }
        private CharacteristicQuantificationType IdentifyCharQuantificationType(CharacteristicQuantification characteristicQuantification)
        {
            Debug.Assert(characteristicQuantification.Numerical != null ||
                characteristicQuantification.Quantile != null ||
                characteristicQuantification.NonQuantifiable != null ||
                characteristicQuantification.Scale != null ||
                characteristicQuantification.Interval != null);

            if (characteristicQuantification.Numerical != null && characteristicQuantification.Numerical.Count != 0)
                return CharacteristicQuantificationType.Numerical;

            if (characteristicQuantification.Quantile != null)
                return CharacteristicQuantificationType.Quantile;

            if (characteristicQuantification.Scale!= null)
                return CharacteristicQuantificationType.Scale;

            if (characteristicQuantification.Interval!= null && characteristicQuantification.Interval.Count != 0)
                return CharacteristicQuantificationType.Interval;

            if (characteristicQuantification.NonQuantifiable != null)
                return CharacteristicQuantificationType.NonQuantifiable;

            return CharacteristicQuantificationType.NonQuantifiable;
        }