public ICDMappingService(ICD10DbContext context)
        {
            _context          = context;
            _icd10ToIcd9codes = _context.ICD10TOICD9Mappings
                                .Include(c => c.ICD9CodeWithMappings)
                                .ThenInclude(m => m.ICD9Code)
                                .ToList();

            _icd9ToIcd10codes = _context.ICD9TOICD10Mappings
                                .Include(c => c.ICD10CodeWithMappings)
                                .ThenInclude(m => m.ICD10Code)
                                .ThenInclude(cw => cw.Category)
                                .ToList();
        }
        public static void ReadCsvIntoDatabase(IHostingEnvironment appEnvironment,
                                               ICD10DbContext dbContext)
        {
            if (dbContext.Codes.Any())
            {
                return;
            }
            var        rootDirectory = appEnvironment.ContentRootPath;
            var        csvFile       = File.OpenRead(Path.Join(rootDirectory, "Data/CSV/codes.csv"));
            TextReader textReader    = new StreamReader(csvFile);
            var        csv           = new CsvReader(textReader);

            ConfigureCSVReader(csv);
            try
            {
                var records = csv.GetRecords <dynamic>().ToList();


                foreach (var r in records)
                {
                    if ((records.IndexOf(r)) == 0)
                    {
                        continue;
                    }
                    var    record       = new Dictionary <string, object>(r);
                    var    code         = new ICD10Code();
                    string categoryCode = (string)record["Category Code"];


                    var dbCategory = dbContext.Categories.FirstOrDefault(c => c.Code.Equals(categoryCode));
                    code.Category               = dbCategory;
                    code.DiagnosisCode          = (string)record["Diagnosis Code"];
                    code.AbbreviatedDescription = (string)record["Abbreviated Description"];
                    code.FullDescription        = (string)record["Full Description"];
                    dbContext.Codes.Add(code);
                }
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void ReadCsvIntoDatabase(IHostingEnvironment appEnvironment,
                                               ICD10DbContext dbContext)
        {
            if (dbContext.ICD9Codes.Any())
            {
                return;
            }
            var        rootDirectory = appEnvironment.ContentRootPath;
            var        csvFile       = File.OpenRead(Path.Join(rootDirectory, "Data/CSV/icd9dx2015.csv"));
            TextReader textReader    = new StreamReader(csvFile);
            var        csv           = new CsvReader(textReader);

            ConfigureCSVReader(csv);
            try
            {
                var records = csv.GetRecords <dynamic>().ToList();


                foreach (var r in records)
                {
                    if ((records.IndexOf(r)) == 0)
                    {
                        continue;
                    }
                    var    record = new Dictionary <string, object>(r);
                    var    code   = new ICD9Code();
                    string dxCode = record["dgns_cd"] as string;

                    code.Code             = dxCode;
                    code.LongDescription  = record["longdesc"] as string;
                    code.ShortDescription = record["shortdesc"] as string;
                    code.Version          = Int32.Parse(record["version"] as string);
                    dbContext.ICD9Codes.Add(code);
                }
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #4
0
        public static void ReadCsvIntoDatabase(IHostingEnvironment appEnvironment,
                                               ICD10DbContext dbContext)
        {
            if (dbContext.ICD9TOICD10Mappings.Any())
            {
                return;
            }
            var        rootDirectory = appEnvironment.ContentRootPath;
            var        csvFile       = File.OpenRead(Path.Join(rootDirectory, "Data/CSV/icd9toicd10cmgem.csv"));
            TextReader textReader    = new StreamReader(csvFile);
            var        csv           = new CsvReader(textReader);

            ConfigureCSVReader(csv);
            try
            {
                var records = csv.GetRecords <dynamic>().ToList();

                foreach (var r in records)
                {
                    if ((records.IndexOf(r)) == 0)
                    {
                        continue;
                    }
                    var    record = new Dictionary <string, object>(r);
                    var    code   = new ICD9TOICD10Mapping();
                    string dxCode = record["icd9cm"] as string;

                    code.ICD9Code  = dxCode;
                    code.ICD10Code = record["icd10cm"] as string;
                    code.Flags     = record["flags"] as string;
                    dbContext.ICD9TOICD10Mappings.Add(code);
                }
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #5
0
        public static void ReadCsvIntoDatabase(IHostingEnvironment appEnvironment,
                                               ICD10DbContext dbContext)
        {
            if (dbContext.Categories.Any())
            {
                return;
            }
            var        rootDirectory = appEnvironment.ContentRootPath;
            var        csvFile       = File.OpenRead(Path.Join(rootDirectory, "Data/CSV/categories.csv"));
            TextReader textReader    = new StreamReader(csvFile);
            var        csv           = new CsvReader(textReader);

            ConfigureCSVReader(csv);
            try
            {
                var records = csv.GetRecords <dynamic>().ToList();


                foreach (var r in records)
                {
                    if ((records.IndexOf(r)) == 0)
                    {
                        continue;
                    }
                    var record   = new Dictionary <string, object>(r);
                    var category = new ICD10Category();
                    category.Code  = (string)record["Field1"];
                    category.Title = (string)record["Field2"];
                    dbContext.Categories.Add(category);
                }
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run(ICD10DbContext dbContext)
        {
            if (dbContext.ICD9CodeWithMappings.Any())
            {
                return;
            }
            var icd9Codes = dbContext.ICD9Codes.ToList();

            foreach (var mapping in dbContext.ICD10TOICD9Mappings)
            {
                var icd9code = icd9Codes.Where(c => c.Code == mapping.ICD9Code)
                               .FirstOrDefault();

                if (icd9code == null)
                {
                    continue;
                }
                var codeWithMapping = new ICD9CodeWithMapping();
                codeWithMapping.ICD10TOICD9Mapping = mapping;
                codeWithMapping.ICD9Code           = icd9code;
                dbContext.ICD9CodeWithMappings.Add(codeWithMapping);
            }
            dbContext.SaveChanges();
        }
Example #7
0
 public ICD9CodeService(ICD10DbContext context)
 {
     _context = context;
     _codes   = _context.ICD9Codes;
 }
Example #8
0
 public CategoryService(ICD10DbContext context)
 {
     _context    = context;
     _categories = _context.Categories.Include(c => c.ICD10Codes).ToList();
 }
Example #9
0
 public CodeService(ICD10DbContext context)
 {
     _context = context;
     _codes   = _context.Codes.Include(c => c.Category).ToList();
 }
Example #10
0
 public ValuesController(ICD10DbContext context)
 {
     _context = context;
 }