Пример #1
0
        public void AddElement(DatasetElement datasetElement)
        {
            if (datasetElement == null)
            {
                throw new ArgumentNullException(nameof(datasetElement));
            }
            ;

            if (DatasetCategoryElements.Any(dce => dce.DatasetElement.Id == datasetElement.Id))
            {
                throw new Exception("Element has already been added");
            }

            var datasetCategoryElement = new DatasetCategoryElement()
            {
                DatasetCategory = this,
                Acute           = false,
                Chronic         = false,
                DatasetElement  = datasetElement,
                FieldOrder      = 1,
                FriendlyName    = string.Empty,
                Help            = string.Empty,
                Public          = false,
                System          = false
            };

            DatasetCategoryElements.Add(datasetCategoryElement);
        }
Пример #2
0
        public DatasetInstanceValue SetInstanceValue(DatasetElement datasetElement, string instanceValue)
        {
            datasetElement.Validate(instanceValue);
            var datasetInstanceValue = DatasetInstanceValues.SingleOrDefault(div => div.DatasetElement.Id == datasetElement.Id);

            if (datasetInstanceValue == null)
            {
                if (!string.IsNullOrWhiteSpace(instanceValue))
                {
                    datasetInstanceValue = AddInstanceValue(datasetElement, instanceValue);
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(instanceValue))
                {
                    DatasetInstanceValues.Remove(datasetInstanceValue);
                    datasetInstanceValue = null;
                }
                else
                {
                    datasetInstanceValue.InstanceValue = instanceValue;
                }
            }

            return(datasetInstanceValue);
        }
Пример #3
0
        public DatasetInstanceValue AddInstanceValue(DatasetElement datasetElement, string instanceValue)
        {
            var datasetInstanceValue = new DatasetInstanceValue(datasetElement, this, instanceValue);

            DatasetInstanceValues.Add(datasetInstanceValue);

            return(datasetInstanceValue);
        }
Пример #4
0
        public DatasetInstanceSubValue[] GetInstanceSubValues(DatasetElement datasetElement, Guid context)
        {
            var datasetInstanceValue = DatasetInstanceValues.SingleOrDefault(div => div.DatasetElement.Id == datasetElement.Id);

            if (datasetInstanceValue != null && datasetInstanceValue.DatasetInstanceSubValues.Any())
            {
                return(datasetInstanceValue.DatasetInstanceSubValues.Where(disv => disv.ContextValue == context).ToArray());
            }

            return(new DatasetInstanceSubValue[0]);
        }
Пример #5
0
        public Guid?GetContextForInstanceSubValue(DatasetElement datasetElement, DatasetElementSub datasetSubElement, string instanceValue)
        {
            var datasetInstanceValue = DatasetInstanceValues.SingleOrDefault(div => div.DatasetElement.Id == datasetElement.Id);

            if (datasetInstanceValue != null && datasetInstanceValue.DatasetInstanceSubValues.Any())
            {
                return(datasetInstanceValue.DatasetInstanceSubValues.Where(disv => disv.DatasetElementSub.Id == datasetSubElement.Id && disv.InstanceValue.Trim() == instanceValue.Trim()).Select(disv => disv.ContextValue).First());
            }

            return(null);
        }
Пример #6
0
        public Guid[] GetInstanceSubValuesContext(DatasetElement datasetElement)
        {
            var datasetInstanceValue = DatasetInstanceValues.SingleOrDefault(div => div.DatasetElement.Id == datasetElement.Id);

            if (datasetInstanceValue != null && datasetInstanceValue.DatasetInstanceSubValues.Any())
            {
                return(datasetInstanceValue.DatasetInstanceSubValues.Select(disv => disv.ContextValue).Distinct().ToArray());
            }

            return(new Guid[0]);
        }
Пример #7
0
        public string GetInstanceValue(DatasetElement datasetElement)
        {
            if (datasetElement == null)
            {
                return(string.Empty);
            }
            ;
            var instanceValue = DatasetInstanceValues.SingleOrDefault(div => div.DatasetElement.Id == datasetElement.Id);

            return(instanceValue != null ? instanceValue.InstanceValue : string.Empty);
        }
Пример #8
0
 public DatasetInstanceValue(DatasetElement datasetElement, DatasetInstance datasetInstance, string instanceValue)
     : this()
 {
     this.DatasetElement = datasetElement;
     this.InstanceValue  = instanceValue;
 }