Example #1
0
        public IActionResult SaveEmr([FromBody] EmrSystem entity)
        {
            if (null == entity)
            {
                return(BadRequest());
            }

            if (entity.Id.IsNullOrEmpty())
            {
                entity.Id = LiveGuid.NewGuid();
            }

            try
            {
                _emrManagerService.SaveEmr(entity);
                return(Ok(entity));
            }
            catch (Exception e)
            {
                var msg = $"Error saving {nameof(EmrSystem)}";
                Log.Error(msg);
                Log.Error($"{e}");
                return(StatusCode(500, msg));
            }
        }
Example #2
0
        public static void InitDb()
        {
            var settingsContext = ServiceProvider.GetService <SettingsContext>();
            var extractsContext = ServiceProvider.GetService <ExtractsContext>();

            settingsContext.Database.Migrate();
            settingsContext.EnsureSeeded();


            extractsContext.Database.Migrate();
            extractsContext.EnsureSeeded();


            Iqtools = settingsContext.EmrSystems
                      .Include(x => x.DatabaseProtocols)
                      .Include(x => x.Extracts)
                      .First(x => x.Id == new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"));

            Validator = extractsContext.Validator.First();


            var dbmanager = ServiceProvider.GetService <IAppDatabaseManager>();

            IqToolsDatabase = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString,
                                                       DatabaseProvider.MsSql);

            IQtoolsDbProtocol =
                Iqtools.DatabaseProtocols.First(x => x.DatabaseName.ToLower().Contains("iqtools".ToLower()));
            IQtoolsDbProtocol.Host     = IqToolsDatabase.Server;
            IQtoolsDbProtocol.Username = IqToolsDatabase.User;
            IQtoolsDbProtocol.Password = IqToolsDatabase.Password;
        }
Example #3
0
        public static void InitMysQLDb()
        {
            var settingsContextMysql = ServiceProviderMysql.GetService <SettingsContext>();
            var extractsContextMysql = ServiceProviderMysql.GetService <ExtractsContext>();

            settingsContextMysql.Database.Migrate();
            settingsContextMysql.EnsureSeeded();

            extractsContextMysql.Database.Migrate();
            extractsContextMysql.EnsureSeeded();

            KenyaEmr = settingsContextMysql.EmrSystems
                       .Include(x => x.DatabaseProtocols)
                       .Include(x => x.Extracts)
                       .First(x => x.Id == new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"));

            Validator = extractsContextMysql.Validator.First();


            var dbmanager = ServiceProvider.GetService <IAppDatabaseManager>();

            KenyaEmrDatabase = dbmanager.ReadConnection(settingsContextMysql.Database.GetDbConnection().ConnectionString, DatabaseProvider.MySql);


            KenyaEmrDbProtocol          = KenyaEmr.DatabaseProtocols.First();
            KenyaEmrDbProtocol.Host     = KenyaEmrDatabase.Server;
            KenyaEmrDbProtocol.Username = KenyaEmrDatabase.User;
            KenyaEmrDbProtocol.Password = KenyaEmrDatabase.Password;
        }
Example #4
0
        public void Init()
        {
            _options = TestDbOptions.GetInMemoryOptions <SettingsContext>();
            var context = new SettingsContext(_options);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            _iqcareEmr = new EmrSystem("IQCare", "v1");
            _iqcareEmr.AddProtocol(new DatabaseProtocol(DatabaseType.MicrosoftSQL, @".\koske14", "sa", "maun", "iqcare"));
            _iqcareEmr.AddRestProtocol(new RestProtocol("http://192.168.1.10/api", "xys"));
            context.Add(_iqcareEmr);
            context.SaveChanges();
        }
Example #5
0
        public static void InitDbMySql()
        {
            var settingsContext = ServiceProviderMysql.GetService <SettingsContext>();
            var dbmanager       = ServiceProviderMysql.GetService <IAppDatabaseManager>();

            KenyaEmr         = settingsContext.EmrSystems.Include(x => x.DatabaseProtocols).FirstOrDefault(x => x.Name == "KenyaEMR");
            KenyaEmrDatabase = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString,
                                                        DatabaseProvider.MySql);

            KenyaEmrDbProtocol          = KenyaEmr.DatabaseProtocols.First();
            KenyaEmrDbProtocol.Host     = KenyaEmrDatabase.Server;
            KenyaEmrDbProtocol.Username = KenyaEmrDatabase.User;
            KenyaEmrDbProtocol.Password = KenyaEmrDatabase.Password;
        }
        public void should_Post_Emr()
        {
            var emr      = new EmrSystem("Test", "v3");
            var response = _emrManagerController.SaveEmr(emr);

            var result = response as OkObjectResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(200, result.StatusCode);

            var emrSystem = _emrSystemRepository.Get(emr.Id);

            Assert.NotNull(emrSystem);
            Console.WriteLine(emrSystem);
        }
Example #7
0
        public static void InitDbMsSql()
        {
            var settingsContext = ServiceProvider.GetService <SettingsContext>();
            var dbmanager       = ServiceProvider.GetService <IAppDatabaseManager>();

            Iqtools = settingsContext.EmrSystems.Include(x => x.DatabaseProtocols).FirstOrDefault(x => x.Name == "IQCare");

            IqToolsDatabase = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString,
                                                       DatabaseProvider.MsSql);

            IQtoolsDbProtocol =
                Iqtools.DatabaseProtocols.First(x => x.DatabaseName.ToLower().Contains("iqtools".ToLower()));
            IQtoolsDbProtocol.Host     = IqToolsDatabase.Server;
            IQtoolsDbProtocol.Username = IqToolsDatabase.User;
            IQtoolsDbProtocol.Password = IqToolsDatabase.Password;
        }
        public void Init()
        {
            _options = TestDbOptions.GetInMemoryOptions <SettingsContext>();
            var context = new SettingsContext(_options);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            _iqcareEmr = new EmrSystem("IQCare", "v1");
            _iqcareEmr.AddProtocol(new DatabaseProtocol(DatabaseType.MicrosoftSQL, @".\koske14", "sa", "maun", "iqcare"));
            _kenyaEmr = new EmrSystem("KenyaEMR", "v1");
            _kenyaEmr.AddProtocol(new DatabaseProtocol(DatabaseType.MySQL, @"localhost", "root", "root", "openmrs"));
            _otherEmr = new EmrSystem("xEmr", "1");
            _otherEmr.AddProtocol(new DatabaseProtocol(DatabaseType.MySQL, @"localhost", "root", "root", "otheropenmrs"));
            context.AddRange(new List <EmrSystem> {
                _iqcareEmr, _kenyaEmr, _otherEmr
            });
            context.SaveChanges();
        }
Example #9
0
        public IActionResult SetDefault([FromBody] EmrSystem emrSystem)
        {
            try
            {
                if (emrSystem == null)
                {
                    return(BadRequest());
                }

                _emrManagerService.SetDefault(emrSystem.Id);
                return(Ok(true));
            }

            catch (Exception ex)
            {
                var msg = $"Error setting Emr {emrSystem.Name} as default";
                Log.Error(msg);
                Log.Error($"{ex}");
                return(StatusCode(500, msg));
            }
        }
Example #10
0
        public async Task <IActionResult> LoadMetric([FromBody] EmrSystem entity)
        {
            if (null == entity)
            {
                return(BadRequest());
            }

            var restProtocol = entity.RestProtocols.FirstOrDefault();

            if (null == restProtocol)
            {
                return(BadRequest());
            }

            if (null == restProtocol.Metric)
            {
                return(BadRequest());
            }

            try
            {
                var metric = await _metricsService.Read(restProtocol, restProtocol.Metric.EndPoint);

                if (null == metric)
                {
                    throw new Exception("could not load EMR metrics");
                }

                return(Ok(metric));
            }
            catch (Exception e)
            {
                var msg = $"Error loading {nameof(EmrMetric)}";
                Log.Error(msg);
                Log.Error($"{e}");
                return(StatusCode(500, msg));
            }
        }
Example #11
0
        public void Setup()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            var mysqlConfig = new ConfigurationBuilder()
                              .AddJsonFile("appsettings.mysql.json")
                              .Build();


            var serviceProvider = new ServiceCollection()
                                  .AddDbContext <ExtractsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddDbContext <SettingsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()
                                  .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                  .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()
                                  .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                  .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                  .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()
                                  .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                  .AddTransient <IExtractSourceReader, ExtractSourceReader>()
                                  .AddTransient <IAppDatabaseManager, AppDatabaseManager>()
                                  .BuildServiceProvider();

            var serviceProviderMysql = new ServiceCollection()
                                       .AddDbContext <ExtractsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddDbContext <SettingsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()
                                       .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                       .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()
                                       .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                       .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                       .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()
                                       .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                       .AddTransient <IExtractSourceReader, ExtractSourceReader>()
                                       .AddTransient <IAppDatabaseManager, AppDatabaseManager>()
                                       .BuildServiceProvider();

            ServiceProvider      = serviceProvider;
            ServiceProviderMysql = serviceProviderMysql;

            var settingsContext      = serviceProvider.GetService <SettingsContext>();
            var settingsContextMysql = serviceProviderMysql.GetService <SettingsContext>();
            var extractsContext      = serviceProvider.GetService <ExtractsContext>();
            var extractsContextMysql = serviceProviderMysql.GetService <ExtractsContext>();

            settingsContext.Database.Migrate();
            settingsContext.EnsureSeeded();

            settingsContextMysql.Database.Migrate();
            settingsContextMysql.EnsureSeeded();

            extractsContext.Database.Migrate();
            extractsContext.EnsureSeeded();

            extractsContextMysql.Database.Migrate();
            extractsContextMysql.EnsureSeeded();

            Iqtools = settingsContextMysql.EmrSystems
                      .Include(x => x.DatabaseProtocols)
                      .Include(x => x.Extracts)
                      .First(x => x.Id == new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"));

            KenyaEmr = settingsContextMysql.EmrSystems
                       .Include(x => x.DatabaseProtocols)
                       .Include(x => x.Extracts)
                       .First(x => x.Id == new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"));

            Validator = extractsContext.Validator.First();


            var dbmanager = serviceProvider.GetService <IAppDatabaseManager>();

            IqToolsDatabase  = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString, DatabaseProvider.MsSql);
            KenyaEmrDatabase = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString, DatabaseProvider.MySql);

            IQtoolsDbProtocol          = Iqtools.DatabaseProtocols.First(x => x.DatabaseName.ToLower().Contains("iqtools".ToLower()));
            IQtoolsDbProtocol.Host     = IqToolsDatabase.Server;
            IQtoolsDbProtocol.Username = IqToolsDatabase.User;
            IQtoolsDbProtocol.Password = IqToolsDatabase.Password;
            //_iQtoolsDb.Password = TestInitializer.IqToolsDatabase.Database;

            KenyaEmrDbProtocol              = KenyaEmr.DatabaseProtocols.First();
            KenyaEmrDbProtocol.Host         = KenyaEmrDatabase.Server;
            KenyaEmrDbProtocol.Username     = KenyaEmrDatabase.User;
            KenyaEmrDbProtocol.Password     = KenyaEmrDatabase.Password;
            KenyaEmrDbProtocol.DatabaseName = KenyaEmrDatabase.Database;
        }
Example #12
0
        public void Setup()
        {
            // return;

            RegisterLicence();

            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            var mysqlConfig = new ConfigurationBuilder()
                              .AddJsonFile("appsettings.mysql.json")
                              .Build();


            var serviceProvider = new ServiceCollection()
                                  .AddDbContext <ExtractsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddDbContext <SettingsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()
                                  .AddTransient <IValidatorRepository, ValidatorRepository>()
                                  .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                  .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()

                                  .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                  .AddTransient <ITempPatientArtExtractRepository, TempPatientArtExtractRepository>()
                                  .AddTransient <ITempPatientBaselinesExtractRepository, TempPatientBaselinesExtractRepository>()
                                  .AddTransient <ITempPatientLaboratoryExtractRepository, TempPatientLaboratoryExtractRepository>()
                                  .AddTransient <ITempPatientPharmacyExtractRepository, TempPatientPharmacyExtractRepository>()
                                  .AddTransient <ITempPatientStatusExtractRepository, TempPatientStatusExtractRepository>()
                                  .AddTransient <ITempPatientVisitExtractRepository, TempPatientVisitExtractRepository>()

                                  .AddTransient <IPatientExtractRepository, PatientExtractRepository>()
                                  .AddTransient <IPatientArtExtractRepository, PatientArtExtractRepository>()
                                  .AddTransient <IPatientBaselinesExtractRepository, PatientBaselinesExtractRepository>()
                                  .AddTransient <IPatientLaboratoryExtractRepository, PatientLaboratoryExtractRepository>()
                                  .AddTransient <IPatientPharmacyExtractRepository, PatientPharmacyExtractRepository>()
                                  .AddTransient <IPatientStatusExtractRepository, PatientStatusExtractRepository>()
                                  .AddTransient <IPatientVisitExtractRepository, PatientVisitExtractRepository>()

                                  .AddTransient <ITempHTSClientExtractRepository, TempHTSClientExtractRepository>()
                                  .AddTransient <ITempHTSClientLinkageExtractRepository, TempHTSClientLinkageExtractRepository>()
                                  .AddTransient <ITempHTSClientPartnerExtractRepository, TempHTSClientPartnerExtractRepository>()

                                  .AddTransient <IHTSClientExtractRepository, HTSClientExtractRepository>()
                                  .AddTransient <IHTSClientLinkageExtractRepository, HTSClientLinkageExtractRepository>()
                                  .AddTransient <IHTSClientPartnerExtractRepository, HTSClientPartnerExtractRepository>()

                                  .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                  .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()
                                  .AddTransient <ICleanHtsExtracts, CleanHtsExtracts>()

                                  .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                  .AddTransient <IExtractSourceReader, ExtractSourceReader>()
                                  .AddTransient <IHTSExtractSourceReader, HTSExtractSourceReader>()

                                  .AddTransient <IPatientSourceExtractor, PatientSourceExtractor>()
                                  .AddTransient <IPatientStatusSourceExtractor, PatientStatusSourceExtractor>()
                                  .AddTransient <IPatientArtSourceExtractor, PatientArtSourceExtractor>()
                                  .AddTransient <IPatientBaselinesSourceExtractor, PatientBaselinesSourceExtractor>()
                                  .AddTransient <IPatientPharmacySourceExtractor, PatientPharmacySourceExtractor>()
                                  .AddTransient <IPatientVisitSourceExtractor, PatientVisitSourceExtractor>()
                                  .AddTransient <IPatientLaboratorySourceExtractor, PatientLaboratorySourceExtractor>()

                                  .AddTransient <IHTSClientSourceExtractor, HTSClientSourceExtractor>()
                                  .AddTransient <IHTSClientLinkageSourceExtractor, HTSClientLinkageSourceExtractor>()
                                  .AddTransient <IHTSClientPartnerSourceExtractor, HTSClientPartnerSourceExtractor>()

                                  .AddTransient <IMasterPatientIndexSourceExtractor, MasterPatientIndexSourceExtractor>()
                                  .AddTransient <IMasterPatientIndexLoader, MasterPatientIndexLoader>()

                                  .AddTransient <IPatientLoader, PatientLoader>()
                                  .AddTransient <IPatientArtLoader, PatientArtLoader>()
                                  .AddTransient <IPatientBaselinesLoader, PatientBaselinesLoader>()
                                  .AddTransient <IPatientLaboratoryLoader, PatientLaboratoryLoader>()
                                  .AddTransient <IPatientPharmacyLoader, PatientPharmacyLoader>()
                                  .AddTransient <IPatientStatusLoader, PatientStatusLoader>()
                                  .AddTransient <IPatientVisitLoader, PatientVisitLoader>()


                                  .AddTransient <IHTSClientLoader, HTSClientLoader>()
                                  .AddTransient <IHTSClientLinkageLoader, HTSClientLinkageLoader>()
                                  .AddTransient <IHTSClientPartnerLoader, HTSClientPartnerLoader>()

                                  .AddTransient <IEmrMetricRepository, EmrMetricRepository>()
                                  .AddTransient <IEmrMetricsService, EmrMetricsService>()
                                  .AddTransient <IAppDatabaseManager, AppDatabaseManager>()

                                  .AddMediatR(typeof(ExtractMasterPatientIndexHandler))
                                  .BuildServiceProvider();

            var serviceProviderMysql = new ServiceCollection()
                                       .AddDbContext <ExtractsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddDbContext <SettingsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddTransient <ExtractsContext>()
                                       .AddTransient <SettingsContext>()
                                       .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()
                                       .AddTransient <IValidatorRepository, ValidatorRepository>()
                                       .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                       .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()

                                       .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                       .AddTransient <ITempPatientArtExtractRepository, TempPatientArtExtractRepository>()
                                       .AddTransient <ITempPatientBaselinesExtractRepository, TempPatientBaselinesExtractRepository>()
                                       .AddTransient <ITempPatientLaboratoryExtractRepository, TempPatientLaboratoryExtractRepository>()
                                       .AddTransient <ITempPatientPharmacyExtractRepository, TempPatientPharmacyExtractRepository>()
                                       .AddTransient <ITempPatientStatusExtractRepository, TempPatientStatusExtractRepository>()
                                       .AddTransient <ITempPatientVisitExtractRepository, TempPatientVisitExtractRepository>()

                                       .AddTransient <IPatientExtractRepository, PatientExtractRepository>()
                                       .AddTransient <IPatientArtExtractRepository, PatientArtExtractRepository>()
                                       .AddTransient <IPatientBaselinesExtractRepository, PatientBaselinesExtractRepository>()
                                       .AddTransient <IPatientLaboratoryExtractRepository, PatientLaboratoryExtractRepository>()
                                       .AddTransient <IPatientPharmacyExtractRepository, PatientPharmacyExtractRepository>()
                                       .AddTransient <IPatientStatusExtractRepository, PatientStatusExtractRepository>()
                                       .AddTransient <IPatientVisitExtractRepository, PatientVisitExtractRepository>()


                                       .AddTransient <ITempHTSClientExtractRepository, TempHTSClientExtractRepository>()
                                       .AddTransient <ITempHTSClientLinkageExtractRepository, TempHTSClientLinkageExtractRepository>()
                                       .AddTransient <ITempHTSClientPartnerExtractRepository, TempHTSClientPartnerExtractRepository>()

                                       .AddTransient <IHTSClientExtractRepository, HTSClientExtractRepository>()
                                       .AddTransient <IHTSClientLinkageExtractRepository, HTSClientLinkageExtractRepository>()
                                       .AddTransient <IHTSClientPartnerExtractRepository, HTSClientPartnerExtractRepository>()

                                       .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                       .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()
                                       .AddTransient <ICleanHtsExtracts, CleanHtsExtracts>()

                                       .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                       .AddTransient <IExtractSourceReader, ExtractSourceReader>()
                                       .AddTransient <IHTSExtractSourceReader, HTSExtractSourceReader>()

                                       .AddTransient <IPatientSourceExtractor, PatientSourceExtractor>()
                                       .AddTransient <IPatientStatusSourceExtractor, PatientStatusSourceExtractor>()
                                       .AddTransient <IPatientArtSourceExtractor, PatientArtSourceExtractor>()
                                       .AddTransient <IPatientBaselinesSourceExtractor, PatientBaselinesSourceExtractor>()
                                       .AddTransient <IPatientPharmacySourceExtractor, PatientPharmacySourceExtractor>()
                                       .AddTransient <IPatientVisitSourceExtractor, PatientVisitSourceExtractor>()
                                       .AddTransient <IPatientLaboratorySourceExtractor, PatientLaboratorySourceExtractor>()

                                       .AddTransient <IHTSClientSourceExtractor, HTSClientSourceExtractor>()
                                       .AddTransient <IHTSClientLinkageSourceExtractor, HTSClientLinkageSourceExtractor>()
                                       .AddTransient <IHTSClientPartnerSourceExtractor, HTSClientPartnerSourceExtractor>()

                                       .AddMediatR(typeof(ExtractMasterPatientIndexHandler))
                                       .AddTransient <IMasterPatientIndexSourceExtractor, MasterPatientIndexSourceExtractor>()
                                       .AddTransient <IMasterPatientIndexLoader, MasterPatientIndexLoader>()

                                       .AddTransient <IPatientLoader, PatientLoader>()
                                       .AddTransient <IPatientArtLoader, PatientArtLoader>()
                                       .AddTransient <IPatientBaselinesLoader, PatientBaselinesLoader>()
                                       .AddTransient <IPatientLaboratoryLoader, PatientLaboratoryLoader>()
                                       .AddTransient <IPatientPharmacyLoader, PatientPharmacyLoader>()
                                       .AddTransient <IPatientStatusLoader, PatientStatusLoader>()
                                       .AddTransient <IPatientVisitLoader, PatientVisitLoader>()

                                       .AddTransient <IHTSClientLoader, HTSClientLoader>()
                                       .AddTransient <IHTSClientLinkageLoader, HTSClientLinkageLoader>()
                                       .AddTransient <IHTSClientPartnerLoader, HTSClientPartnerLoader>()

                                       .AddTransient <IEmrMetricRepository, EmrMetricRepository>()
                                       .AddTransient <IEmrMetricsService, EmrMetricsService>()
                                       .AddTransient <IAppDatabaseManager, AppDatabaseManager>()


                                       .BuildServiceProvider();

            ServiceProvider      = serviceProvider;
            ServiceProviderMysql = serviceProviderMysql;

            var settingsContext      = serviceProvider.GetService <SettingsContext>();
            var settingsContextMysql = serviceProviderMysql.GetService <SettingsContext>();
            var extractsContext      = serviceProvider.GetService <ExtractsContext>();
            var extractsContextMysql = serviceProviderMysql.GetService <ExtractsContext>();

            Iqtools = settingsContext.EmrSystems
                      .Include(x => x.DatabaseProtocols)
                      .Include(x => x.Extracts)
                      .First(x => x.Id == new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"));

            KenyaEmr = settingsContextMysql.EmrSystems
                       .Include(x => x.DatabaseProtocols)
                       .Include(x => x.Extracts)
                       .First(x => x.Id == new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"));

            Validator = extractsContext.Validator.First();

            var dbmanager = ServiceProvider.GetService <IAppDatabaseManager>();

            IqToolsDatabase = dbmanager.ReadConnection(settingsContext.Database.GetDbConnection().ConnectionString,
                                                       DatabaseProvider.MsSql);

            IQtoolsDbProtocol =
                Iqtools.DatabaseProtocols.First(x => x.DatabaseName.ToLower().Contains("iqtools".ToLower()));
            IQtoolsDbProtocol.Host     = IqToolsDatabase.Server;
            IQtoolsDbProtocol.Username = IqToolsDatabase.User;
            IQtoolsDbProtocol.Password = IqToolsDatabase.Password;

            KenyaEmrDatabase = dbmanager.ReadConnection(settingsContextMysql.Database.GetDbConnection().ConnectionString, DatabaseProvider.MySql);


            KenyaEmrDbProtocol          = KenyaEmr.DatabaseProtocols.First();
            KenyaEmrDbProtocol.Host     = KenyaEmrDatabase.Server;
            KenyaEmrDbProtocol.Username = KenyaEmrDatabase.User;
            KenyaEmrDbProtocol.Password = KenyaEmrDatabase.Password;

            /*try
             * {
             *  settingsContext.Database.Migrate();
             *  settingsContext.EnsureSeeded();
             *
             *  settingsContextMysql.Database.Migrate();
             *  settingsContextMysql.EnsureSeeded();
             *
             *  extractsContext.Database.Migrate();
             *  extractsContext.EnsureSeeded();
             *
             *  extractsContextMysql.Database.Migrate();
             *  extractsContextMysql.EnsureSeeded();
             *
             *  Iqtools = settingsContext.EmrSystems
             *      .Include(x => x.DatabaseProtocols)
             *      .Include(x => x.Extracts)
             *      .First(x => x.Id == new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"));
             *
             *  KenyaEmr = settingsContextMysql.EmrSystems
             *      .Include(x => x.DatabaseProtocols)
             *      .Include(x => x.Extracts)
             *      .First(x => x.Id == new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"));
             *
             *  Validator = extractsContext.Validator.First();
             * }
             * catch (Exception e)
             * {
             *  Console.WriteLine(e);
             * }*/


            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
                cfg.AddProfile <TempMasterPatientIndexProfile>();
                cfg.AddProfile <TempExtractProfile>();
                cfg.AddProfile <TempHtsExtractProfile>();
                cfg.AddProfile <EmrProfiles>();
            }
                              );
        }
Example #13
0
 public void SaveEmr(EmrSystem emrSystem)
 {
     _emrSystemRepository.CreateOrUpdate(emrSystem);
     _emrSystemRepository.SaveChanges();
 }
Example #14
0
        public void Setup()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            var mysqlConfig = new ConfigurationBuilder()
                              .AddJsonFile("appsettings.mysql.json")
                              .Build();


            var serviceProvider = new ServiceCollection()
                                  .AddDbContext <ExtractsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddDbContext <SettingsContext>(x => x.UseSqlServer(config["ConnectionStrings:DwapiConnection"]))
                                  .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()

                                  .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                  .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()

                                  .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                  .AddTransient <ITempPatientArtExtractRepository, TempPatientArtExtractRepository>()
                                  .AddTransient <ITempPatientBaselinesExtractRepository, TempPatientBaselinesExtractRepository>()
                                  .AddTransient <ITempPatientLaboratoryExtractRepository, TempPatientLaboratoryExtractRepository>()
                                  .AddTransient <ITempPatientPharmacyExtractRepository, TempPatientPharmacyExtractRepository>()
                                  .AddTransient <ITempPatientStatusExtractRepository, TempPatientStatusExtractRepository>()
                                  .AddTransient <ITempPatientVisitExtractRepository, TempPatientVisitExtractRepository>()

                                  .AddTransient <IPatientExtractRepository, PatientExtractRepository>()
                                  .AddTransient <IPatientArtExtractRepository, PatientArtExtractRepository>()
                                  .AddTransient <IPatientBaselinesExtractRepository, PatientBaselinesExtractRepository>()
                                  .AddTransient <IPatientLaboratoryExtractRepository, PatientLaboratoryExtractRepository>()
                                  .AddTransient <IPatientPharmacyExtractRepository, PatientPharmacyExtractRepository>()
                                  .AddTransient <IPatientStatusExtractRepository, PatientStatusExtractRepository>()
                                  .AddTransient <IPatientVisitExtractRepository, PatientVisitExtractRepository>()

                                  .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                  .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()

                                  .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                  .AddTransient <IExtractSourceReader, ExtractSourceReader>()

                                  .AddTransient <IPatientSourceExtractor, PatientSourceExtractor>()
                                  .AddTransient <IPatientStatusSourceExtractor, PatientStatusSourceExtractor>()
                                  .AddTransient <IPatientArtSourceExtractor, PatientArtSourceExtractor>()
                                  .AddTransient <IPatientBaselinesSourceExtractor, PatientBaselinesSourceExtractor>()
                                  .AddTransient <IPatientPharmacySourceExtractor, PatientPharmacySourceExtractor>()
                                  .AddTransient <IPatientVisitSourceExtractor, PatientVisitSourceExtractor>()
                                  .AddTransient <IPatientLaboratorySourceExtractor, PatientLaboratorySourceExtractor>()

                                  .AddTransient <IMasterPatientIndexSourceExtractor, MasterPatientIndexSourceExtractor>()
                                  .AddTransient <IMasterPatientIndexLoader, MasterPatientIndexLoader>()

                                  .AddTransient <IPatientLoader, PatientLoader>()
                                  .AddTransient <IPatientArtLoader, PatientArtLoader>()
                                  .AddTransient <IPatientBaselinesLoader, PatientBaselinesLoader>()
                                  .AddTransient <IPatientLaboratoryLoader, PatientLaboratoryLoader>()
                                  .AddTransient <IPatientPharmacyLoader, PatientPharmacyLoader>()
                                  .AddTransient <IPatientStatusLoader, PatientStatusLoader>()
                                  .AddTransient <IPatientVisitLoader, PatientVisitLoader>()

                                  .AddMediatR(typeof(ExtractMasterPatientIndexHandler))
                                  .BuildServiceProvider();

            var serviceProviderMysql = new ServiceCollection()
                                       .AddDbContext <ExtractsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddDbContext <SettingsContext>(x => x.UseMySql(mysqlConfig["ConnectionStrings:DwapiConnection"]))
                                       .AddTransient <ExtractsContext>()
                                       .AddTransient <SettingsContext>()
                                       .AddTransient <IExtractHistoryRepository, ExtractHistoryRepository>()

                                       .AddTransient <ITempMasterPatientIndexRepository, TempMasterPatientIndexRepository>()
                                       .AddTransient <IMasterPatientIndexRepository, MasterPatientIndexRepository>()

                                       .AddTransient <ITempPatientExtractRepository, TempPatientExtractRepository>()
                                       .AddTransient <ITempPatientArtExtractRepository, TempPatientArtExtractRepository>()
                                       .AddTransient <ITempPatientBaselinesExtractRepository, TempPatientBaselinesExtractRepository>()
                                       .AddTransient <ITempPatientLaboratoryExtractRepository, TempPatientLaboratoryExtractRepository>()
                                       .AddTransient <ITempPatientPharmacyExtractRepository, TempPatientPharmacyExtractRepository>()
                                       .AddTransient <ITempPatientStatusExtractRepository, TempPatientStatusExtractRepository>()
                                       .AddTransient <ITempPatientVisitExtractRepository, TempPatientVisitExtractRepository>()

                                       .AddTransient <IPatientExtractRepository, PatientExtractRepository>()
                                       .AddTransient <IPatientArtExtractRepository, PatientArtExtractRepository>()
                                       .AddTransient <IPatientBaselinesExtractRepository, PatientBaselinesExtractRepository>()
                                       .AddTransient <IPatientLaboratoryExtractRepository, PatientLaboratoryExtractRepository>()
                                       .AddTransient <IPatientPharmacyExtractRepository, PatientPharmacyExtractRepository>()
                                       .AddTransient <IPatientStatusExtractRepository, PatientStatusExtractRepository>()
                                       .AddTransient <IPatientVisitExtractRepository, PatientVisitExtractRepository>()

                                       .AddTransient <ICleanCbsExtracts, CleanCbsExtracts>()
                                       .AddTransient <IClearDwhExtracts, ClearDwhExtracts>()

                                       .AddTransient <IMasterPatientIndexReader, MasterPatientIndexReader>()
                                       .AddTransient <IExtractSourceReader, ExtractSourceReader>()

                                       .AddTransient <IPatientSourceExtractor, PatientSourceExtractor>()
                                       .AddTransient <IPatientStatusSourceExtractor, PatientStatusSourceExtractor>()
                                       .AddTransient <IPatientArtSourceExtractor, PatientArtSourceExtractor>()
                                       .AddTransient <IPatientBaselinesSourceExtractor, PatientBaselinesSourceExtractor>()
                                       .AddTransient <IPatientPharmacySourceExtractor, PatientPharmacySourceExtractor>()
                                       .AddTransient <IPatientVisitSourceExtractor, PatientVisitSourceExtractor>()
                                       .AddTransient <IPatientLaboratorySourceExtractor, PatientLaboratorySourceExtractor>()

                                       .AddMediatR(typeof(ExtractMasterPatientIndexHandler))
                                       .AddTransient <IMasterPatientIndexSourceExtractor, MasterPatientIndexSourceExtractor>()
                                       .AddTransient <IMasterPatientIndexLoader, MasterPatientIndexLoader>()

                                       .AddTransient <IPatientLoader, PatientLoader>()
                                       .AddTransient <IPatientArtLoader, PatientArtLoader>()
                                       .AddTransient <IPatientBaselinesLoader, PatientBaselinesLoader>()
                                       .AddTransient <IPatientLaboratoryLoader, PatientLaboratoryLoader>()
                                       .AddTransient <IPatientPharmacyLoader, PatientPharmacyLoader>()
                                       .AddTransient <IPatientStatusLoader, PatientStatusLoader>()
                                       .AddTransient <IPatientVisitLoader, PatientVisitLoader>()


                                       .BuildServiceProvider();

            ServiceProvider      = serviceProvider;
            ServiceProviderMysql = serviceProviderMysql;

            var settingsContext      = serviceProvider.GetService <SettingsContext>();
            var settingsContextMysql = serviceProviderMysql.GetService <SettingsContext>();
            var extractsContext      = serviceProvider.GetService <ExtractsContext>();
            var extractsContextMysql = serviceProviderMysql.GetService <ExtractsContext>();

            settingsContext.Database.Migrate();
            settingsContext.EnsureSeeded();

            settingsContextMysql.Database.Migrate();
            settingsContextMysql.EnsureSeeded();

            extractsContext.Database.Migrate();
            extractsContext.EnsureSeeded();

            extractsContextMysql.Database.Migrate();
            extractsContextMysql.EnsureSeeded();

            Iqtools = settingsContext.EmrSystems
                      .Include(x => x.DatabaseProtocols)
                      .Include(x => x.Extracts)
                      .First(x => x.Id == new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"));

            KenyaEmr = settingsContextMysql.EmrSystems
                       .Include(x => x.DatabaseProtocols)
                       .Include(x => x.Extracts)
                       .First(x => x.Id == new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"));

            Validator = extractsContext.Validator.First();

            Mapper.Initialize(cfg =>
            {
                cfg.AddDataReaderMapping();
                cfg.AddProfile <TempMasterPatientIndexProfile>();
                cfg.AddProfile <TempExtractProfile>();
            }
                              );
        }