Esempio n. 1
0
        public ImportMedicFile(MedicContext medicContext)
        {
            MedicContext = medicContext ?? throw new ArgumentNullException(nameof(medicContext));

            _providers               = new HashSet <Provider>(new ProviderComparer());
            _therapyTypes            = new HashSet <TherapyType>(new TherapyTypeComparer());
            _patientBranches         = new HashSet <PatientBranch>(new PatientBranchComparer());
            _patients                = new HashSet <Patient>();
            _healthcarePractitioners = new HashSet <HealthcarePractitioner>(new HealthcarePractitionerComparer());
            _practices               = new HashSet <Practice>(new PracticeComparer());
            _fileTypes               = new HashSet <FileType>(new FileTypeComparer());
            _senderTypes             = new HashSet <SenderType>(new SenderTypeComparer());
            _sexes          = new HashSet <Sex>(new SexComparer());
            _healthRegions  = new HashSet <HealthRegion>(new HealthRegionComparer());
            _specialtyTypes = new HashSet <SpecialtyType>(new SpecialtyTypeComparer());
            _mkbs           = new HashSet <MKB>(new MKBComparer());
        }
Esempio n. 2
0
        private static void ReadCLPRFiles(IMappable mapper, DbContextOptionsBuilder <MedicContext> builder, string directoryPath)
        {
            string invalidCLPRFileMessage = "Invalid CLPR file.";


            string[]        files          = Directory.GetFiles(directoryPath, "*.xml");
            IMedicXmlParser medicXmlParser = new DefaultMedicXmlParser(new GetXmlParameters());

            int counter = 1;

            foreach (string file in files)
            {
                using FileStream sr = new FileStream(file, FileMode.Open, FileAccess.Read);

                CLPR.HospitalPractice clprFile = medicXmlParser.ParseXML <CLPR.HospitalPractice>(sr);

                if (clprFile != default)
                {
                    HospitalPractice hospitalPracticeEntity = mapper.Map <HospitalPractice, CLPR.HospitalPractice>(clprFile);

                    if (hospitalPracticeEntity != default)
                    {
                        using MedicContext medicContext        = new MedicContext(builder.Options);
                        using IImportMedicFile importMedicFile = new ImportMedicFile(medicContext);

                        importMedicFile.ImportHospitalPractice(hospitalPracticeEntity);

                        consoleWriter.Notify($"{file} - imported, ({counter++}/{files.Length}).");
                    }
                    else
                    {
                        consoleWriter.Notify(invalidCLPRFileMessage);
                    }
                }
                else
                {
                    consoleWriter.Notify(invalidCLPRFileMessage);
                }
            }
        }
Esempio n. 3
0
 public PacientesController(MedicContext context)
 {
     _context = context;
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            try
            {
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

                ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
                configurationBuilder.AddUserSecrets <Program>();
                configurationBuilder.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"));

                IConfigurationRoot configuration = configurationBuilder.Build();

                DbContextOptionsBuilder <MedicContext> builder = new DbContextOptionsBuilder <MedicContext>();
                builder.UseSqlServer(configuration[Constants.ConnectionString]);
                builder.EnableSensitiveDataLogging();

                using MedicContext context = new MedicContext(builder.Options);
                IMedicContextSeeder medicContextSeeder = new MedicContextSeeder(context);
                medicContextSeeder.Seed();

                AMapperConfiguration mapConfiguration = new AMapperConfiguration();
                IMappable            mapper           = new AMapper(mapConfiguration.CreateConfiguration());

                string cpDirectory, clprDirectory;
                bool   doesCpDirectoryExist = true, doesCLPRDirectoryExist = true;

                while (true)
                {
                    consoleWriter.Notify("Enter directory for CP files");
                    cpDirectory = consoleReader.Read();
                    consoleWriter.Notify("Enter directory for CLPR files");
                    clprDirectory = consoleReader.Read();

                    if (!string.IsNullOrWhiteSpace(cpDirectory))
                    {
                        doesCpDirectoryExist = Directory.Exists(cpDirectory);
                    }

                    if (!string.IsNullOrWhiteSpace(clprDirectory))
                    {
                        doesCLPRDirectoryExist = Directory.Exists(clprDirectory);
                    }

                    if (doesCpDirectoryExist && doesCLPRDirectoryExist)
                    {
                        break;
                    }
                    else
                    {
                        if (!doesCpDirectoryExist)
                        {
                            consoleWriter.Notify("CP directory does not exist.");
                        }

                        if (!doesCLPRDirectoryExist)
                        {
                            consoleWriter.Notify("CLPR directory does not exist.");
                        }
                    }

                    doesCpDirectoryExist   = true;
                    doesCLPRDirectoryExist = true;
                }

                if (!string.IsNullOrWhiteSpace(cpDirectory))
                {
                    ReadCpFiles(mapper, builder, cpDirectory);
                }

                if (!string.IsNullOrWhiteSpace(clprDirectory))
                {
                    ReadCLPRFiles(mapper, builder, clprDirectory);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            consoleWriter.Notify("Press any key to exit.");
            Console.ReadKey();
        }
Esempio n. 5
0
 public MedicosController(MedicContext context)
 {
     _context = context;
 }
Esempio n. 6
0
 public ConsultasController(MedicContext context, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Esempio n. 7
0
 public MedicContextSeeder(MedicContext medicContext)
 {
     MedicContext = medicContext ?? throw new ArgumentNullException(nameof(medicContext));
 }