Exemple #1
0
        public EchonetObject(byte classGroupCode, byte classCode)
        {
            ClassGroup = SpecificationMaster.GetInstance().プロファイル.Where(p => p.ClassGroupCode == classGroupCode).FirstOrDefault();
            if (ClassGroup == null)
            {
                ClassGroup = SpecificationMaster.GetInstance().機器.Where(p => p.ClassGroupCode == classGroupCode).FirstOrDefault();
            }
            if (ClassGroup != null)
            {
                //スーパークラスのプロパティを列挙

                var superClassFilePath = Path.Combine(Directory.GetCurrentDirectory(), "MasterData", $"{ClassGroup.SuperClass}.json");
                if (File.Exists(superClassFilePath))
                {
                    var superClassProperties = JsonConvert.DeserializeObject <PropertyMaster>(File.ReadAllText(superClassFilePath, new UTF8Encoding(false)));
                    Properties.AddRange(superClassProperties.Properties);
                }
                Class = ClassGroup.ClassList.Where(c => c.Status && c.ClassCode == classCode).FirstOrDefault();
                if (Class.Status)
                {
                    var classFilePath = Path.Combine(Directory.GetCurrentDirectory(), "MasterData", $"0x{ClassGroup.ClassGroupCode:X2}-{ClassGroup.ClassGroupName}", $"0x{Class.ClassCode:X2}-{Class.ClassName}.json");
                    if (File.Exists(classFilePath))
                    {
                        //クラスのプロパティを列挙
                        var classProperties = JsonConvert.DeserializeObject <PropertyMaster>(File.ReadAllText(classFilePath, new UTF8Encoding(false)));
                        Properties.AddRange(classProperties.Properties);
                    }
                }
            }
        }
        /// <summary>
        /// Make sure all available flight properties are represented in the view model
        /// </summary>
        /// <param name="availableProperties"></param>
        public void MergeProperties(List <FlightProperty> availableProperties)
        {
            // Identify the list of properties that don't already have values
            // associated with the flight and add entries to the properties list
            if (Properties != null)
            {
                IEnumerable <int>            associatedPropertyIds = Properties.Select(p => p.Property.Id);
                IEnumerable <FlightProperty> missing = availableProperties.Where(ap => !associatedPropertyIds.Contains(ap.Id)).ToList();

                // Add an empty value for available but not associated properties
                if (missing.Any())
                {
                    Properties.AddRange(missing.Select(m => new FlightPropertyValue {
                        Property = m
                    }));
                }
            }
            else
            {
                Properties = availableProperties.Select(m => new FlightPropertyValue {
                    Property = m
                }).ToList();
            }

            // Sort the properties by name
            Properties = Properties.OrderBy(p => p.Property.Name).ToList();
        }
Exemple #3
0
 public ModelDefinition(IModelDefinition copyFrom) : base(copyFrom)
 {
     if (copyFrom != null && copyFrom.Properties.Any())
     {
         Properties.AddRange(copyFrom.Properties.Select(x => new ModelPropertyDefinition(x)));
     }
 }
Exemple #4
0
        public void MergeProperties(BotConfiguration configuration)
        {
            var existingProperties = Properties.Select(x => x.Property).ToArray();
            var propertiesToAdd    = configuration.Properties.Where(x => !existingProperties.Contains(x.Property));

            Properties.AddRange(propertiesToAdd);
        }
        private async Task RefreshProperties()
        {
            var newItems = await AlexGuiDebuggerInteraction.Instance.GetElementTreeItemProperties(ElementTreeItem.Id);

            Properties.Clear();
            Properties.AddRange(newItems);
        }
 public EnumFile(Type type, TsDir rootDir) : base(type, rootDir)
 {
     Properties.AddRange(Enum.GetNames(type).Select(name =>
     {
         var stringValue = "";
         var val         = (Enum.Parse(type, name));
         var t           = val.GetType().GetEnumUnderlyingType();
         if (t.FullName == typeof(int).FullName)
         {
             stringValue = ((int)val).ToString();
         }
         else if (t.FullName == typeof(byte).FullName)
         {
             stringValue = ((byte)val).ToString();
         }
         else
         {
             Console.WriteLine("Unknown enum underlying type");
         }
         return(new EnumProperty
         {
             Name = name,
             Value = stringValue,
         });
     }));
 }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the PropertyTable class.
        /// </summary>
        public TestObjectPropertyBag(TestObjectNurse testNurse)
        {
            _testNurse = testNurse;

            PropertySpec[] specs = AddProperties();

            Properties.AddRange(specs);
        }
Exemple #8
0
        public void ReadXml(XmlReader reader)
        {
            reader.Read();

            XmlSerializer serializer = new XmlSerializer(typeof(List <CompilerProperty>), new XmlRootAttribute("CompilerProperties"));

            Properties.AddRange(serializer.Deserialize(reader) as List <CompilerProperty>);
        }
Exemple #9
0
        public InstanceInspector(INotifyPropertyChanged inpc)
        {
            _type = inpc.GetType();

            var properties = GetAllProperties(inpc);

            Properties.AddRange(properties.Select(pi => new PropertyInspector(pi, inpc)));
        }
 public InterfaceFile(TypeBuilder builder, Type type, TsDir rootDir, bool forceInterfaceForProperties = false) : base(type, rootDir)
 {
     if (!Export.StartsWith("I"))
     {
         Export = $"I{Export}";
     }
     Properties.AddRange(type.GetProperties().PropertyFilter()
                         .Select(prop => new TypedInterfaceProperty(builder, prop, forceInterfaceForProperties)));
     Fields.AddRange(type.GetFields().FieldFilter().Select(field => new TypedFieldProperty(builder, field)));
 }
Exemple #11
0
        public SGClass WithProperties(params SGClassProperty[] properties)
        {
            if (properties == null || properties.Any(x => x == null))
            {
                throw new ArgumentNullException("Properties cannot be null.");
            }

            Properties.AddRange(properties);
            return(this);
        }
Exemple #12
0
        internal void Inherit(List <IMappingConfig> parentMappingConfigs)
        {
            foreach (var m in parentMappingConfigs)
            {
                var notFoundProperties = m.Properties.FindAll(p => !PropertyNotFound(p.PropertyName));
                Properties.AddRange(notFoundProperties);
                Links.AddRange(m.Links);
            }

            SetLinksAlias();
        }
        public override void Init()
        {
            Config = Compiler.ApiConfig[RootNode];

            Functions.AddRange(RootNode.SearchByType <FunctionNode>().Select(f => new AbstractFunction(f)));

            Properties.AddRange(Compiler.CompilerExtension.GetProperties());

            Constructor = Compiler.CompilerExtension.GetConstructor(RootNode.Name, Config);

            TopOfClassExtra.AddRange(Compiler.CompilerExtension.GetTopOfClassExtra(Config));
        }
Exemple #14
0
        public WeProductBase(string[] categoryIds, WeProductProperty[] propertys, string name, SkuInfo[] skuInfos,
                             string mainImg, string[] imgs, WeProductDetail[] details)
            : this(name, mainImg)
        {
            TkDebug.AssertArgumentNull(categoryIds, "categoryIds", null);
            TkDebug.AssertArgumentNull(propertys, "propertys", null);
            TkDebug.AssertArgumentNull(skuInfos, "propertys", null);
            TkDebug.AssertArgumentNull(imgs, "img", null);
            TkDebug.AssertArgumentNull(details, "details", null);

            CategoryIds.AddRange(categoryIds);
            Properties.AddRange(propertys);
            SkuInfos.AddRange(skuInfos);
            Imgs.AddRange(imgs);
            Details.AddRange(details);
        }
        public NormalizationApiModel(NormalizationApiModel copyFrom) : base(copyFrom)
        {
            if (copyFrom == null)
            {
                return;
            }

            Description   = copyFrom.Description;
            Discriminator = copyFrom.Discriminator;
            Name          = copyFrom.Name;
            ResourceName  = copyFrom.ResourceName;
            ResourcePath  = copyFrom.ResourcePath;

            Properties.AddRange(copyFrom.Properties);

            SubTypes.AddRange(copyFrom.SubTypes);
        }
Exemple #16
0
        public TSInterface(Type type, Func <Type, string> mapType)
        {
            var ti = type.GetTypeInfo();

            _type      = type;
            _mapType   = mapType;
            ModuleName = type.Namespace;
            FullName   = ti.FullName;
            //Methods = new List<TSMethod>();
            var name = ti.IsGenericType
                            ? type.Name.Split(new[] { '`' }).First()
                            : type.Name;

            InterFaceName = ti.IsInterface
                            ? name
                            : string.Format(Settings.InterfaceFormat, name);

            //interfaces
            Interfaces = ti.GetInterfaces().Where(i => i.GetTypeInfo().Assembly == ti.Assembly && i.Name != InterFaceName).ToList();
            if (ti.BaseType != null && ti.BaseType != typeof(object))
            {
                Interfaces.Add(ti.BaseType);
            }

            //properties
            var props = ti.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            Properties = props.Select(p => new TSProperty(p, _mapType)).ToList();

            //fields, not properties
            var fields = ti.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            var addp   = fields.Select(f => new TSProperty(f, _mapType)).ToList();

            Properties.AddRange(addp);

            //generic
            //if (_type.IsGenericType)
            //{
            GenericParameters = ti.GetGenericArguments().Select(a => new TSGenericParameter(a, _mapType)).ToList();
            // }

            //methods
            var methods = ti.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => !x.IsSpecialName);

            Methods = methods.Select(m => new TSMethod(m, _mapType)).ToList();
        }
Exemple #17
0
        public ClassFile(TypeBuilder builder, Type type, TsDir rootDir) : base(type, rootDir)
        {
            Properties.AddRange(type.GetProperties().PropertyFilter()
                                .Select(prop =>
            {
                var tsProp = new TypedClassProperty(builder, prop);

                foreach (var decorator in builder.DefaultClassPropertyDecorators)
                {
                    tsProp.Decorators.Add(decorator);
                }

                return(tsProp);
            }));

            Fields.AddRange(type.GetFields().FieldFilter().Select(field => new TypedFieldProperty(builder, field)));
        }
        internal DllTypeData(TypeDefinition def, DllConfig config)
        {
            _config = config;
            foreach (var i in def.Interfaces)
            {
                ImplementingInterfaces.Add(DllTypeRef.From(i.InterfaceType));
            }

            This = DllTypeRef.From(def);
            Type = def.IsEnum ? TypeEnum.Enum : (def.IsInterface ? TypeEnum.Interface : (def.IsValueType ? TypeEnum.Struct : TypeEnum.Class));
            Info = new TypeInfo
            {
                Refness = def.IsValueType ? Refness.ValueType : Refness.ReferenceType
            };

            if (def.BaseType != null)
            {
                Parent = DllTypeRef.From(def.BaseType);
            }

            // TODO: Parse this eventually
            TypeDefIndex = -1;

            if (_config.ParseTypeAttributes && def.HasCustomAttributes)
            {
                Attributes.AddRange(def.CustomAttributes.Select(ca => new DllAttribute(ca)).Where(a => !string.IsNullOrEmpty(a.Name)));
            }
            Layout = (ITypeData.LayoutKind)(def.Attributes & TypeAttributes.LayoutMask);
            if (_config.ParseTypeFields)
            {
                InstanceFields.AddRange(def.Fields.Where(f => !f.IsStatic).Select(f => new DllField(f)));
                StaticFields.AddRange(def.Fields.Where(f => f.IsStatic).Select(f => new DllField(f)));
            }
            if (_config.ParseTypeProperties)
            {
                Properties.AddRange(def.Properties.Select(p => new DllProperty(p)));
            }
            if (_config.ParseTypeMethods)
            {
                var mappedBaseMethods = new HashSet <MethodDefinition>();
                var methods           = def.Methods.Select(m => DllMethod.From(m, ref mappedBaseMethods)).ToList();
                // It's important that Foo.IBar.func() goes after func() (if present)
                Methods.AddRange(methods.Where(m => m.ImplementedFrom is null));
                Methods.AddRange(methods.Where(m => m.ImplementedFrom != null));
            }
        }
Exemple #19
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        public void ParseImage(bool parseEverything = false)
        {
            if (Parsed)
            {
                return;
            }
            else if (Changed)
            {
                Parsed = true; return;
            }
            this.parseEverything       = parseEverything;
            reader.BaseStream.Position = offset;
            byte b = reader.ReadByte();

            if (b != 0x73 || reader.ReadString() != "Property" || reader.ReadUInt16() != 0)
            {
                return;
            }
            Properties.AddRange(WzImageProperty.ParsePropertyList(offset, reader, this, this));
            parsed = true;
        }
Exemple #20
0
        public void SetItemsSource(object itemsSource)
        {
            ClearCache();
            if (itemsSource == null)
            {
                return;
            }

            _itemsSource = itemsSource;

            Type itemsSourceType = ItemsSource.GetType();

            foreach (Type interfaceType in itemsSourceType.GetInterfaces())
            {
                if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IList <>))
                {
                    Type argumentType = itemsSourceType.GenericTypeArguments[0];
                    Properties.AddRange(argumentType.GetProperties());
                    break;
                }
            }
        }
    public EntityTypeMapping(IEntityType entityType)
    {
        Name       = entityType.Name;
        TableName  = entityType.GetTableName();
        PrimaryKey = entityType.FindPrimaryKey() !.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);

        Properties.AddRange(
            entityType.GetProperties()
            .Select(p => p.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        Indexes.AddRange(
            entityType.GetIndexes().Select(i => $"{i.Properties.Format()} {(i.IsUnique ? "Unique" : "")}"));

        FKs.AddRange(
            entityType.GetForeignKeys().Select(f => f.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        Navigations.AddRange(
            entityType.GetNavigations().Select(n => n.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        SkipNavigations.AddRange(
            entityType.GetSkipNavigations().Select(n => n.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));
    }
Exemple #22
0
 public ClassRepresentationBuilder WithProperties(params string[] properties)
 {
     Properties.AddRange(properties);
     return(this);
 }
        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not,
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            _loadedProperties = new Properties();

            if (ContentBase != null)
            {
                //NOTE: we will not load any properties where HasIdentity = false - this is because if properties are
                // added to the property collection that aren't persisted we'll get ysods
                _loadedProperties.AddRange(ContentBase.Properties.Where(x => x.HasIdentity).Select(x => new Property(x)));
                return;
            }

            if (this.ContentType == null)
            {
                return;
            }

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = _loadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where versionId=@versionId";

            using (var sqlHelper = Application.SqlHelper)
                using (IRecordsReader dr = sqlHelper.ExecuteReader(sql,
                                                                   sqlHelper.CreateParameter("@versionId", Version)))
                {
                    while (dr.Read())
                    {
                        //add the item to our list
                        propData.Add(new { Id = dr.Get <int>("id"), PropertyTypeId = dr.Get <int>("propertyTypeId") });
                    }
                }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                {
                    continue;
                }

                //get the propertyId
                var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
                if (property == null)
                {
                    continue;
                    //var prop = Property.MakeNew(pt, this, Version);
                    //property = new {Id = prop.Id, PropertyTypeId = pt.Id};
                }
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                _loadedProperties.Add(p);
            }
        }
Exemple #24
0
        public TypeDefinition AddProperties(IEnumerable <PropertyDefinition> properties)
        {
            Must.Assert(properties != null);

            return(WithProperties(Properties.AddRange(properties)));
        }
Exemple #25
0
        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not, 
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been 
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            m_LoadedProperties = new Properties();

            if (ContentBase != null)
            {
                m_LoadedProperties.AddRange(ContentBase.Properties.Select(x => new Property(x)));
                return;
            }

            if (this.ContentType == null)
                return;

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = m_LoadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where versionId=@versionId";

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql,
                SqlHelper.CreateParameter("@versionId", Version)))
            {
                while (dr.Read())
                {
                    //add the item to our list
                    propData.Add(new { Id = dr.Get<int>("id"), PropertyTypeId = dr.Get<int>("propertyTypeId") });
                }
            }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                    continue;

                //get the propertyId
                var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
                if (property == null)
                {
                    continue;
                    //var prop = Property.MakeNew(pt, this, Version);
                    //property = new {Id = prop.Id, PropertyTypeId = pt.Id};
                }
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                m_LoadedProperties.Add(p);
            }
        }
Exemple #26
0
        public TypeDefinition AddProperties(params PropertyDefinition[] properties)
        {
            Must.Assert(properties != null);

            return(WithProperties(Properties.AddRange(properties)));
        }
 /// <summary>
 /// Adds a collection of properties to an object
 /// </summary>
 /// <param name="prop"></param>
 public void AddRange(IEnumerable <Property> props)
 {
     Properties.AddRange(props);
 }
Exemple #28
0
 public ClassDescripter CreateProperty(params PropertyDescripter[] properties)
 {
     Properties.AddRange(properties);
     return(this);
 }
Exemple #29
0
        protected override void ApplyChanges(BinaryDataWriter bin)
        {
            AddNewProperties();

            bin.ByteOrder = order;
            bin.Write((ushort)(Properties.Count + AddedProperties.Count + UnknownPropertiesCount));
            bin.Write((ushort)0);
            bin.Write(new byte[0xC * AddedProperties.Count]);
            bin.Write(data, 4, data.Length - 4);             //write rest of entries, adding new elements first doesn't break relative offets in the struct
            foreach (var m in Properties)
            {
                if ((byte)m.type != 1 && (byte)m.type != 2)
                {
                    continue;
                }
                m.ValueOffset += +0xC * AddedProperties.Count;
                bin.Position   = m.ValueOffset;
                if (m.value.Length != m.ValueCount)
                {
                    throw new Exception("Can't change the number of values of an usd1 property");
                }
                for (int i = 0; i < m.ValueCount; i++)
                {
                    if (m.type == EditableProperty.ValueType.int32)
                    {
                        bin.Write(int.Parse(m.value[i]));
                    }
                    else
                    {
                        bin.Write(float.Parse(m.value[i]));
                    }
                }
            }
            for (int i = 0; i < AddedProperties.Count; i++)
            {
                bin.Position = bin.BaseStream.Length;
                uint DataOffset = (uint)bin.BaseStream.Position;
                AddedProperties[i].ValueOffset = DataOffset;
                AddedProperties[i].ValueCount  = (ushort)AddedProperties[i].value.Length;
                for (int j = 0; j < AddedProperties[i].value.Length; j++)
                {
                    if (AddedProperties[i].type == EditableProperty.ValueType.int32)
                    {
                        bin.Write(int.Parse(AddedProperties[i].value[j]));
                    }
                    else
                    {
                        bin.Write(float.Parse(AddedProperties[i].value[j]));
                    }
                }
                uint NameOffest = (uint)bin.BaseStream.Position;
                bin.Write(AddedProperties[i].Name, BinaryStringFormat.ZeroTerminated);
                bin.WriteAlign(4);
                uint entryStart = (uint)(4 + i * 0xC);
                bin.BaseStream.Position = entryStart;
                bin.Write(NameOffest - entryStart);
                bin.Write(DataOffset - entryStart);
                bin.Write((ushort)AddedProperties[i].ValueCount);
                bin.Write((byte)AddedProperties[i].type);
                bin.Write((byte)0);
                OriginalProperties.Add(AddedProperties[i].Name);
            }

            Properties.AddRange(AddedProperties);
            AddedProperties.Clear();
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            // try
            // {
            var invalidProperties = new List <string>();
            var instance          = value ?? validationContext.ObjectInstance;

#if DEBUG
            var timer = new Stopwatch();
            timer.Start();
#endif
            if (!Properties.Any())
            {
                Properties.AddRange(GetTypeProperties());
            }
#if DEBUG
            timer.Stop();
            var message = string.Format("IP/ED dataset imports - Time of Execution get all diagnosis and procedure codes for dataset row: {0}:{1}",
                                        timer.Elapsed.Seconds, timer.Elapsed.Milliseconds);

            Trace.WriteLine(message);
            timer.Reset();
#endif

            if (!Properties.Any())
            {
                return(ValidationResult.Success);
            }
#if DEBUG
            timer.Start();
#endif
            var diagnosisValues = Properties.Where(propertyInfo => propertyInfo.Name.ContainsIgnoreCase("Diagnosis") && propertyInfo.GetValue(instance, null) != null)
                                  .Select(propertyInfo => new KeyValuePair <string, object>(propertyInfo.Name, propertyInfo.GetValue(instance, null))).ToList();

            var isIcd9DiagnosisCodesValid = diagnosisValues.All(code =>
            {
                if (code.Key.ToString().Equals("PrincipalDiagnosis", StringComparison.InvariantCultureIgnoreCase) || code.Key.ToString().Equals("PrimaryDiagnosis", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (!SharedRegularExpressions.EVSpecialCodeRegex.IsMatch(code.Value.ToString()) && ICD9DiagnosticCheck(code.Value.ToString()))
                    {
                        return(true);
                    }

                    invalidProperties.Add(code.Key);
                    return(false);
                }
                else
                {
                    if (ICD9DiagnosticCheck(code.Value.ToString()))
                    {
                        return(true);
                    }

                    invalidProperties.Add(code.Key);
                    return(false);
                }
            });
            var isIcd10DiagnosisCodesValid = !isIcd9DiagnosisCodesValid && diagnosisValues.All(code =>
            {
                if (ICD10DiagnosticCheck(code.Value.ToString()))
                {
                    return(true);
                }
                // if (SharedRegularExpressions.ICD10Regex.IsMatch(code.Value.ToString())) return true;
                invalidProperties.Add(code.Key);
                return(false);
            });
#if DEBUG
            timer.Stop();
            message = string.Format("IP/ED dataset imports - Time of Execution process all diagnosis codes: {0}:{1}",
                                    timer.Elapsed.Seconds, timer.Elapsed.Milliseconds);

            Trace.WriteLine(message);
            timer.Reset();
#endif
            bool isIcd10ProcedureCodeValid = false, isIcd9ProcedureCodeValid = false;
            if (PerformProcedureCheck)
            {
#if DEBUG
                timer.Start();
#endif
                var procedureValues = Properties
                                      .Where(propertyInfo => propertyInfo.Name.ContainsIgnoreCase("Procedure") && propertyInfo.GetValue(instance, null) != null)
                                      .Select(propertyInfo => new KeyValuePair <string, object>(propertyInfo.Name, propertyInfo.GetValue(instance, null)))
                                      .ToList();

                isIcd9ProcedureCodeValid = !procedureValues.Any() || procedureValues.All(code =>
                {
                    if (ICD9ProcedureCheck(code.Value.ToString()))
                    {
                        return(true);
                    }
                    // if (SharedRegularExpressions.ICD9ProcedureRegex.IsMatch(code.Value.ToString())) return true;

                    invalidProperties.Add(code.Key);
                    return(false);
                });
                isIcd10ProcedureCodeValid = !procedureValues.Any() || (!isIcd9ProcedureCodeValid && procedureValues.All(
                                                                           code =>
                {
                    if (ICD10ProcedureCheck(code.Value.ToString()))
                    {
                        return(true);
                    }
                    // if (SharedRegularExpressions.ICD10ProcedureRegex.IsMatch(code.Value.ToString())) return true;

                    invalidProperties.Add(code.Key);
                    return(false);
                }));
#if DEBUG
                timer.Stop();
                message = string.Format("IP/ED dataset imports - Time of Execution process all procedure codes: {0}:{1}",
                                        timer.Elapsed.Seconds, timer.Elapsed.Milliseconds);

                Trace.WriteLine(message);
                timer.Reset();
#endif
            }

            if (PerformProcedureCheck)
            {
                if (isIcd9DiagnosisCodesValid && isIcd9ProcedureCodeValid)
                {
                    return(ValidationResult.Success);
                }

                if (isIcd10DiagnosisCodesValid && isIcd10ProcedureCodeValid)
                {
                    return(ValidationResult.Success);
                }
            }
            else
            {
                if (isIcd9DiagnosisCodesValid)
                {
                    return(ValidationResult.Success);
                }

                if (isIcd10DiagnosisCodesValid)
                {
                    return(ValidationResult.Success);
                }
            }

            //string errorMessage = GetFormattedMessage(PerformProcedureCheck, this._neededProperties, validationContext)
            return(new ValidationResult("Record deleted because it either contains a mix of ICD-9 and ICD-10 coded data or invalid codes.", /*invalidProperties.Any() ? invalidProperties.Distinct().Select(p => p).ToList() :*/ new List <string>())); //ValidationHelper.IcdCheckProperties.Distinct().Select(p => p.Name).ToList()
            // }
            // finally
            // {

            // }
        }
Exemple #31
0
 public override void Init()
 {
     Properties.AddRange(RootNode.Fields.Select(f => new AbstractProperty <EntityNode>(f, RootNode)));
 }