Ejemplo n.º 1
0
        private AimTemplateTreeAnatomicEntityNode AimTemplateTreeAnatomicEntityNodeFromXsdAnatomicEntity(TemplateComponent component, TemplateComponentAnatomicEntity anatomicEntity)
        {
            var allowedTerms = new List <AimTemplateTreeAllowedTerm>();

            for (int index = 0; index < component.Items.Length; index++)
            {
                object item = component.Items[index];
                if (item.GetType() == typeof(TemplateComponentAllowedTerm))
                {
                    var term = AllowedTermFromXsdAllowedTerm((TemplateComponentAllowedTerm)item);
                    if (term != null)
                    {
                        term.PresentationIndex = index;
                        allowedTerms.Add(term);
                    }
                }
            }

            var anatomicEntityCharacteristics = new List <AimTemplateTreeAnatomicEntityCharacteristicNode>();

            if (anatomicEntity.AnatomicEntityCharacteristic != null)
            {
                anatomicEntityCharacteristics.AddRange(anatomicEntity.AnatomicEntityCharacteristic.Select(
                                                           anatomicEntityCharacteristic => AimTemplateTreeAnatomicEntityCharacteristicNodeFromXsdAnatomicEntityCharacteristic(anatomicEntityCharacteristic)).ToList());
            }

            var imagingObservationCharacteristics = new List <AimTemplateTreeImagingObservationCharacteristicNode>();

            if (anatomicEntity.ImagingObservationCharacteristic != null)
            {
                imagingObservationCharacteristics.AddRange(anatomicEntity.ImagingObservationCharacteristic.Select(
                                                               imagingObservationCharacteristic => AimTemplateTreeImagingObservationCharacteristicNodeFromXsdImagingObservationCharacteristic(imagingObservationCharacteristic)).ToList());
            }

            int itemNumber;

            int.TryParse(component.itemNumber, out itemNumber);

            int minCardinality;

            int.TryParse(component.minCardinality, out minCardinality);

            int maxCardinality;

            int.TryParse(component.maxCardinality, out maxCardinality);

            string label = component.label;

            if (component.QuestionType != null)
            {
                label = component.QuestionType.codeMeaning;
            }

            var node = new AimTemplateTreeAnatomicEntityNode(
                label,
                itemNumber,
                component.explanatoryText,
                minCardinality,
                maxCardinality,
                component.shouldDisplay,
                component.groupLabel,
                ValidTermFromXsdValidTerm(component.QuestionType),
                anatomicEntity.annotatorConfidence,
                allowedTerms,
                anatomicEntityCharacteristics,
                imagingObservationCharacteristics,
                component.id
                );

            return(node);
        }
        private AimTemplateTreeAnatomicEntityNode AimTemplateTreeAnatomicEntityNodeFromXsdAnatomicEntity(TemplateComponent component, TemplateComponentAnatomicEntity anatomicEntity)
        {
            var allowedTerms = new List<AimTemplateTreeAllowedTerm>();
            for (int index = 0; index < component.Items.Length; index++)
            {
                object item = component.Items[index];
                if (item.GetType() == typeof(TemplateComponentAllowedTerm))
                {
                    var term = AllowedTermFromXsdAllowedTerm((TemplateComponentAllowedTerm)item);
                    if (term != null)
                    {
                        term.PresentationIndex = index;
                        allowedTerms.Add(term);
                    }
                }
            }

            var anatomicEntityCharacteristics = new List<AimTemplateTreeAnatomicEntityCharacteristicNode>();
            if (anatomicEntity.AnatomicEntityCharacteristic != null)
            {
                anatomicEntityCharacteristics.AddRange(anatomicEntity.AnatomicEntityCharacteristic.Select(
                anatomicEntityCharacteristic => AimTemplateTreeAnatomicEntityCharacteristicNodeFromXsdAnatomicEntityCharacteristic(anatomicEntityCharacteristic)).ToList());
            }

            var imagingObservationCharacteristics = new List<AimTemplateTreeImagingObservationCharacteristicNode>();
            if (anatomicEntity.ImagingObservationCharacteristic != null)
            {
                imagingObservationCharacteristics.AddRange(anatomicEntity.ImagingObservationCharacteristic.Select(
                imagingObservationCharacteristic => AimTemplateTreeImagingObservationCharacteristicNodeFromXsdImagingObservationCharacteristic(imagingObservationCharacteristic)).ToList());
            }

            int itemNumber;
            int.TryParse(component.itemNumber, out itemNumber);

            int minCardinality;
            int.TryParse(component.minCardinality, out minCardinality);

            int maxCardinality;
            int.TryParse(component.maxCardinality, out maxCardinality);

            string label = component.label;
            if (component.QuestionType != null)
                label = component.QuestionType.codeMeaning;

            var node = new AimTemplateTreeAnatomicEntityNode(
                label,
                itemNumber,
                component.explanatoryText,
                minCardinality,
                maxCardinality,
                component.shouldDisplay,
                component.groupLabel,
                ValidTermFromXsdValidTerm(component.QuestionType),
                anatomicEntity.annotatorConfidence,
                allowedTerms,
                anatomicEntityCharacteristics,
                imagingObservationCharacteristics,
                component.id
                );
            return node;
        }
Ejemplo n.º 3
0
        public AnatomicEntityWpfControl(AimTemplateTreeAnatomicEntityNode anatomicEntity)
        {
            AnatomicEntity = anatomicEntity;
            InitializeComponent();

            ChildControls = new List <IValidTreeControl>();

            _originalBackground = Background;

            // Hide the allowed terms control that is not being used
            if (MaxNumberOfAnswers > 1)
            {
                _comboBox.Visibility = Visibility.Hidden;
                _comboBox.Height     = 0;

                var cardinalityString = String.Empty;

                if (AnatomicEntity.MinCardinality > 0 && AnatomicEntity.MaxCardinality >= AnatomicEntity.AllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + AnatomicEntity.MinCardinality;
                }
                else if (AnatomicEntity.MaxCardinality < AnatomicEntity.AllowedTerms.Count && AnatomicEntity.MinCardinality <= 0)
                {
                    cardinalityString = "Select less than " + (AnatomicEntity.MaxCardinality + 1);
                }
                else if (AnatomicEntity.MinCardinality > 0 && AnatomicEntity.MaxCardinality < AnatomicEntity.AllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + AnatomicEntity.MinCardinality + " and less than " +
                                        (AnatomicEntity.MaxCardinality + 1);
                }

                if (!String.IsNullOrEmpty(cardinalityString))
                {
                    ((TextBlock)_label.Content).Text += Environment.NewLine + cardinalityString;
                }
            }
            else
            {
                _itemsControl.Visibility = Visibility.Hidden;
                _itemsControl.Height     = 0;
            }

            // Add confidence control
            if (AnatomicEntity.ShouldDisplay && AnatomicEntity.HasConfidence)
            {
                NodeConfidenceWpfControl = new NodeConfidenceWpfControl(AnatomicEntity);
                _stackPanel.Children.Add(NodeConfidenceWpfControl);
            }

            var characteristicNodes = anatomicEntity.AnatomicEntityCharacteristicTreeNodes.Cast <AimTemplateTreeNode>().ToList();

            characteristicNodes.AddRange(anatomicEntity.ImagingObservationCharacteristicTreeNodes.Cast <AimTemplateTreeNode>().ToList());

            characteristicNodes.Sort(new TemplateTreeNodeOrderComparer());

            var groupedNodes = new List <AimTemplateTreeNode>();

            foreach (var characteristic in characteristicNodes)
            {
                // Start or add to group label control
                if (!String.IsNullOrEmpty(characteristic.GroupLabel))
                {
                    if (groupedNodes.Count > 0 && characteristic.GroupLabel == groupedNodes[0].GroupLabel)
                    {
                        groupedNodes.Add(characteristic);
                    }
                    else
                    {
                        // Finish and add the group label control
                        if (groupedNodes.Count > 0)
                        {
                            var groupLabel = new GroupLabelWpfControl(groupedNodes)
                            {
                                Header = groupedNodes[0].GroupLabel
                            };
                            _stackPanel.Children.Add(groupLabel);
                            ChildControls.Add(groupLabel);
                        }

                        groupedNodes = new List <AimTemplateTreeNode> {
                            characteristic
                        };
                    }
                }
                else
                {
                    // Finish and add the group label control
                    if (groupedNodes.Count > 0)
                    {
                        var groupLabel = new GroupLabelWpfControl(groupedNodes)
                        {
                            Header = groupedNodes[0].GroupLabel
                        };
                        groupedNodes.Clear();
                        _stackPanel.Children.Add(groupLabel);
                        ChildControls.Add(groupLabel);
                    }

                    if (characteristic is AimTemplateTreeAnatomicEntityCharacteristicNode)
                    {
                        var characteristicControl = new AnatomicEntityCharacteristicWpfControl(
                            (AimTemplateTreeAnatomicEntityCharacteristicNode)characteristic);
                        _stackPanel.Children.Add(characteristicControl);
                        ChildControls.Add(characteristicControl);
                    }

                    if (characteristic is AimTemplateTreeImagingObservationCharacteristicNode)
                    {
                        var characteristicControl = new ImagingObservationCharacteristicWpfControl(
                            (AimTemplateTreeImagingObservationCharacteristicNode)characteristic);
                        _stackPanel.Children.Add(characteristicControl);
                        ChildControls.Add(characteristicControl);
                    }
                }
            }

            // Finish and add the group label control
            if (groupedNodes.Count > 0)
            {
                var groupLabel = new GroupLabelWpfControl(groupedNodes)
                {
                    Header = groupedNodes[0].GroupLabel
                };
                _stackPanel.Children.Add(groupLabel);
                ChildControls.Add(groupLabel);
            }

            Loaded += AnatomicEntityWpfControlLoaded;

            AnatomicEntity.SelectedAllowedTermsChanged += SelectedAllowedTermsCollectionChanged;
            CheckBoxControls = new Dictionary <AimTemplateTreeAllowedTerm, CheckBox>();

            if (!AnatomicEntity.ShouldDisplay)
            {
                _label.Visibility        = Visibility.Hidden;
                _label.Height            = 0;
                _itemsControl.Visibility = Visibility.Hidden;
                _itemsControl.Height     = 0;
                _comboBox.Visibility     = Visibility.Hidden;
                _comboBox.Height         = 0;
                if (characteristicNodes.TrueForAll(item => !item.ShouldDisplay))
                {
                    Visibility = Visibility.Hidden;
                    Height     = 0;
                }
            }
        }