/// <summary> /// Gets the stock items. /// </summary> /// <param name="dbContext">The database context.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="pageNumber">The page number.</param> /// <returns></returns> public static IQueryable <Patient> GetPatientDetails(this PatientDbContext dbContext, int pageSize = 10, int pageNumber = 1) { // Get query from DbSet var query = dbContext.PatientDetails.AsQueryable(); return(query); }
public PatientRepository(PatientDbContext _context, Persistence.DAL.IDapper.IPatientDapperRepo _dapper) { context = _context; dapper = _dapper; Connection = context.Database.GetDbConnection(); dapper.Connection = Connection; }
public async Task PatientRepositroyAddPatientTest() { var testModel = new PatientModel() { Id = new Guid(), FirstName = "John", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { var dbContext = new PatientDbContext(dbOptionsBuilder.Options); var repo = new PatientRepository(dbContext); var result = await repo.AddPatientAsync(testModel); repo.SaveChanges(); Assert.AreNotEqual(0, context.Patients.Select(q => q.Id == testModel.Id).Count()); } }
public async Task PatientRepositroyUpdatePatientAsyncNullTest() { var testModel = new PatientModel() { Id = new Guid(), FirstName = "John", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { context.Patients.Add(testModel); context.SaveChanges(); var repo = new PatientRepository(context); var result = await repo.UpdatePatientAsync(new PatientModel() { Id = new Guid() }); Assert.IsNull(result); } }
public void InitContext() { var dbContextOptionsBuilder = TestConfigHelper.GetDbContextOptionsBuilder(); _dbContext = new PatientDbContext(dbContextOptionsBuilder.Options); _patientService = new PatientService(_dbContext); }
public PatientControl() { InitializeComponent(); patientDbContext = new PatientDbContext(); patient = new Patient(); patient.Id = -1; }
/// <summary> /// Seeds the specified patient database context. /// </summary> /// <param name="patientDbContext">The patient database context.</param> public static void Seed(this PatientDbContext patientDbContext) { patientDbContext.Add(new Patient { Forename = $"Arindam", Surname = $"Dhar", DateOfBirth = Convert.ToDateTime("23/10/1985"), Gender = true, TelephoneNumber = "{\"WorkNumber\" : \"123456789\"}" }); patientDbContext.Add(new Patient { Forename = $"User1", Surname = $"Surname1", DateOfBirth = Convert.ToDateTime("03/01/1989"), Gender = true, TelephoneNumber = "{\"MobileNumber\" : \"123456789\", \"WorkNumber\" : \"234567\" }" }); patientDbContext.Add(new Patient { Forename = $"User2", Surname = $"Surname2", DateOfBirth = Convert.ToDateTime("03/01/1999"), Gender = false, TelephoneNumber = "{\"MobileNumber\" : \"123456789\", \"HomeNumber\" : \"9998645\"}" }); patientDbContext.SaveChanges(); }
public void Initialise(HttpConfiguration config) { var builder = new ContainerBuilder(); builder.RegisterType(typeof(UnitOfWork)).As(typeof(IUnitOfWork)).InstancePerLifetimeScope(); builder.RegisterFilterProvider(); const string nameOrConnectionString = "name=PatientDbConnection"; builder.Register <IDbContext>(b => { var context = new PatientDbContext(nameOrConnectionString); return(context); }).InstancePerLifetimeScope(); builder.RegisterModule <RepositoryCapsuleModule>(); builder.RegisterModule <ServiceCapsuleModule>(); builder.RegisterModule <ControllerCapsuleModule>(); var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); var resolver = new AutofacWebApiDependencyResolver(container); config.DependencyResolver = resolver; }
public async Task PatientRepositroyGetPatientByIdNullTest() { using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { var repo = new PatientRepository(context); var result = await repo.GetPatientByIdAsync(Guid.Empty); Assert.IsNull(result); } }
public static void PopulateTestData(PatientDbContext dbContext) { dbContext.Patients.AddRange(new PatientEntity { Id = 1, Name = "TestPatient1" }, new PatientEntity { Id = 2, Name = "TestPatient2" }); dbContext.SaveChanges(); }
public async Task PatientRepositroyUpdatePatientAsyncSuccessTest() { var testModel = new PatientModel() { Id = new Guid(), FirstName = "John", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; var expected = new PatientModel() { Id = testModel.Id, FirstName = "Tee", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { context.Patients.Add(testModel); context.SaveChanges(); var entity = context.Patients.Single(p => p.Id == testModel.Id); //To Avoid tracking error context.Entry(entity).State = EntityState.Detached; var repo = new PatientRepository(context); var result = await repo.UpdatePatientAsync( new PatientModel() { Id = testModel.Id, FirstName = "Tee", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }); context.SaveChanges(); Assert.AreEqual("Tee", result.FirstName); } }
private static void SeedSampleData(PatientDbContext dbContext) { dbContext.Patients.Add(new Entities.Patient { FirstName = "Firstname", LastName = "Lastname", Address = "Address", DateOfBirth = DateTime.Today, Phone = "111-222-3333", Sex = "F" }); dbContext.SaveChanges(); }
public void PatientRepositroyGetQueryablePatientTest() { var testData = TestDataGenerateHelper.createPatientModelData(); using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { context.Patients.AddRange(testData); context.SaveChanges(); var repo = new PatientRepository(context); var result = repo.GetQueryablePatient(); Assert.IsNotNull(result); } }
public async Task PatientRepositroyGetPatientByIdSuccessTest() { var testData = TestDataGenerateHelper.createPatientModelData(); using (var context = new PatientDbContext(dbOptionsBuilder.Options)) { context.Patients.AddRange(testData); context.SaveChanges(); var repo = new PatientRepository(context); var result = await repo.GetPatientByIdAsync(testData[0].Id); Assert.IsNotNull(result); } }
/// <summary> /// Gets the patient database context. /// </summary> /// <param name="dbName">Name of the database.</param> /// <returns></returns> public static PatientDbContext GetPatientDbContext(string dbName) { // Create options for DbContext instance var options = new DbContextOptionsBuilder <PatientDbContext>() .UseInMemoryDatabase(databaseName: dbName) .Options; // Create instance of DbContext var dbContext = new PatientDbContext(options); // Add entities in memory dbContext.Seed(); return(dbContext); }
protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { ServiceDescriptor descriptor = services.SingleOrDefault( d => d.ServiceType == typeof(DbContextOptions <PatientDbContext>)); services.Remove(descriptor); services.AddDbContext <PatientDbContext>(options => { options.UseInMemoryDatabase("InMemoryDbForTesting"); }); ServiceProvider serviceProvider = services.BuildServiceProvider(); IConfiguration configuration = serviceProvider.GetRequiredService <IConfiguration>(); switch (configuration.GetValue <int>("PATIENTSERVICE_ORM")) { case 2: services.AddScoped <IPatientDbService, PatientDapperDbService>(); break; default: services.AddScoped <IPatientDbService, PatientEfCoreDbService>(); break; } using (IServiceScope scope = serviceProvider.CreateScope()) { IServiceProvider scopedProvider = scope.ServiceProvider; PatientDbContext patientDbContext = scopedProvider.GetRequiredService <PatientDbContext>(); IPatientDbService patientDbService = scopedProvider.GetRequiredService <IPatientDbService>(); ILogger <CustomWebApplicationFactory <TStartup> > logger = scopedProvider .GetRequiredService <ILogger <CustomWebApplicationFactory <TStartup> > >(); patientDbContext.Database.EnsureDeleted(); patientDbContext.Database.EnsureCreated(); try { TestUtilities.InitializeDb(patientDbService); } catch (Exception ex) { logger.LogError(ex, "An error occurred seeding the " + "database with test messages. Error: {Message}", ex.Message); } } }); }
public string GetAppointmentTypeList() { DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); try { PatientDbContext patientDb = new PatientDbContext(connString); var patientdetail = patientDb.Appointments.Select(s => s.AppointmentType).Distinct().ToList(); responseData.Status = "OK"; responseData.Results = patientdetail; } catch (Exception ex) { responseData.Status = "Failed"; responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString(); } return(DanpheJSONConvert.SerializeObject(responseData)); }
private void AppendFilter(object sender, RoutedEventArgs e) { PatientDbContext patientDbContext = new PatientDbContext(); string val = txtValue.Text; dataGrid.ItemsSource = patientDbContext .Patients .Where(i => i.FirstName.Contains(val) || i.LastName.Contains(val) || i.PatientId.Contains(val) || i.Title.Contains(val) && ( i.Created >= dtFromDate.DisplayDate && i.Created < dtFromDate.DisplayDate )).ToList(); patientDbContext.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="StartViewModel"/> class. /// </summary> public StartViewModel() { CreateDbCommand = new RelayCommand(() => { /* Following are few steps which will make easy to work with Sqlite... * 1. Install Sqlite provider for design time in visual studio * http://system.data.sqlite.org/downloads/1.0.99.0/sqlite-netFx46-setup-bundle-x86-2015-1.0.99.0.exe * 2. Install-Package System.Data.SQLite (This will install core,linq,EF6)... * 3. Install-Package SQLiteNetExtensions if required for mapping * 4. Install-Package SQLite.CodeFirst for code first approch if required */ MessageBox.Show("Hello !"); using (var footballDbCdontext = new PatientDbContext()) { foreach (var team in footballDbCdontext.Set <User>()) { var aa = team; } } //var footballDbContext = new FootballDbContext(); //foreach (var team in footballDbContext.Set<Team>()) //{ // var aa = team; //} //var myDbContext = new MyDbContext(); //foreach (var team in myDbContext.Set<AspNetUser>()) //{ // var aa = team; //} MessageBox.Show("DB creation done !"); //var dbFirstContext = new SqliteDbFirstConn(); //var teamPlayers = dbFirstContext.TeamPlayers.ToList(); }); }
public PatientEfCoreDbService(ILogger <PatientEfCoreDbService> logger, PatientDbContext patientServiceDbContext) { _logger = logger; _patientDbContext = patientServiceDbContext; }
public DoctorController(PatientDbContext context) { _context = context; }
public PatientController(PatientDbContext context) { _context = context; }
public UnitOfWork(PatientDbContext context, IHttpContextAccessor contextAccessor) { Context = context; _contextAccessor = contextAccessor; }
public string Get(string reqType, string searchText, DateTime toDate, DateTime fromDate) { DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); string ipDataString = this.ReadPostData(); responseData.Status = "OK";//by default status would be OK, hence assigning at the top try { BillingDbContext billingDbContext = new BillingDbContext(connString); if (reqType == "insurance-patients-list") { PatientDbContext patDbContext = new PatientDbContext(connString); var allPats = (from pat in patDbContext.Patients join ins in patDbContext.Insurances on pat.PatientId equals ins.PatientId join country in patDbContext.CountrySubdivisions on pat.CountrySubDivisionId equals country.CountrySubDivisionId where pat.IsActive == true select new { PatientId = pat.PatientId, PatientCode = pat.PatientCode, ShortName = pat.FirstName + " " + (string.IsNullOrEmpty(pat.MiddleName) ? "" : pat.MiddleName + " ") + pat.LastName, FirstName = pat.FirstName, LastName = pat.LastName, MiddleName = pat.MiddleName, PatientNameLocal = pat.PatientNameLocal, Age = pat.Age, Gender = pat.Gender, PhoneNumber = pat.PhoneNumber, DateOfBirth = pat.DateOfBirth, Address = pat.Address, IsOutdoorPat = pat.IsOutdoorPat, CreatedOn = pat.CreatedOn, CountryId = pat.CountryId, CountrySubDivisionId = pat.CountrySubDivisionId, CountrySubDivisionName = country.CountrySubDivisionName, pat.BloodGroup, CurrentBalance = ins.CurrentBalance, InsuranceProviderId = ins.InsuranceProviderId, IMISCode = ins.IMISCode, PatientInsuranceInfoId = ins.PatientInsuranceInfoId }).OrderByDescending(p => p.PatientInsuranceInfoId).ToList(); responseData.Results = allPats; } else if (reqType == "insurance-billing-items") { var itemList = (from item in billingDbContext.BillItemPrice join srv in billingDbContext.ServiceDepartment on item.ServiceDepartmentId equals srv.ServiceDepartmentId where item.IsActive == true && item.InsuranceApplicable == true select new { BillItemPriceId = item.BillItemPriceId, ServiceDepartmentId = srv.ServiceDepartmentId, ServiceDepartmentName = srv.ServiceDepartmentName, ServiceDepartmentShortName = srv.ServiceDepartmentShortName, ItemId = item.ItemId, ItemName = item.ItemName, ProcedureCode = item.ProcedureCode, Price = item.GovtInsurancePrice, TaxApplicable = item.TaxApplicable, DiscountApplicable = item.DiscountApplicable, Description = item.Description, IsDoctorMandatory = item.IsDoctorMandatory, item.IsInsurancePackage }).ToList().OrderBy(a => a.ServiceDepartmentId).ThenBy(a => a.ItemId); responseData.Status = "OK"; responseData.Results = itemList; } else if (reqType == "unclaimed-insurance-bills") { var unclaimedInvoicesList = (from txn in billingDbContext.BillingTransactions join pat in billingDbContext.Patient on txn.PatientId equals pat.PatientId join fis in billingDbContext.BillingFiscalYears on txn.FiscalYearId equals fis.FiscalYearId where txn.IsInsuranceBilling == true && txn.IsInsuranceClaimed == false && txn.ReturnStatus == false && (DbFunctions.TruncateTime(txn.CreatedOn) >= fromDate.Date && DbFunctions.TruncateTime(txn.CreatedOn) <= toDate.Date) select new { BillingTransactionId = txn.BillingTransactionId, BillingDate = txn.CreatedOn, InvoiceNo = txn.InvoiceNo, PatientFName = pat.FirstName, PatientMName = pat.MiddleName, PatientLName = pat.LastName, TotalAmount = txn.TotalAmount, FiscalYear = fis.FiscalYearName, IsInsuranceClaimed = txn.IsInsuranceClaimed //FiscalYearId= txn.FiscalYearId }).OrderByDescending(invoice => invoice.BillingDate).ToList(); responseData.Status = "OK"; responseData.Results = unclaimedInvoicesList; } else if (reqType == "insurance-packages") { List <BillingPackageModel> packageList = billingDbContext.BillingPackages.Where(a => a.IsActive == true && a.InsuranceApplicable == true) .OrderBy(a => a.BillingPackageName).ToList(); if (packageList.Count > 0) { foreach (var package in packageList) { string jsonValues = "[]";//by default it'll be empty json-array. if (!string.IsNullOrEmpty(package.BillingItemsXML)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(package.BillingItemsXML); jsonValues = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true); } package.BillingItemsXML = jsonValues; } } responseData.Status = "OK"; responseData.Results = packageList; } //Yubraj: 21st July '19 -- Getting All Patient which does not have Insurance... else if (reqType == "all-patients-for-insurance") { PatientDbContext patDbContext = new PatientDbContext(connString); if (string.IsNullOrEmpty(searchText)) { responseData.Results = new List <string>();//send empty string. } else { var allPats = (from pat in patDbContext.Patients join country in patDbContext.CountrySubdivisions on pat.CountrySubDivisionId equals country.CountrySubDivisionId //left join insurance information. from ins in patDbContext.Insurances.Where(a => a.PatientId == pat.PatientId).DefaultIfEmpty() where pat.IsActive == true && (pat.IsOutdoorPat == null || pat.IsOutdoorPat == false) //exclude Inactive and OutDoor patients. && ((pat.FirstName + " " + (string.IsNullOrEmpty(pat.MiddleName) ? "" : pat.MiddleName + " ") + pat.LastName + pat.PatientCode + pat.PhoneNumber).Contains(searchText)) select new { PatientId = pat.PatientId, PatientCode = pat.PatientCode, ShortName = pat.FirstName + " " + (string.IsNullOrEmpty(pat.MiddleName) ? "" : pat.MiddleName + " ") + pat.LastName, FirstName = pat.FirstName, LastName = pat.LastName, MiddleName = pat.MiddleName, Age = pat.Age, Gender = pat.Gender, PhoneNumber = pat.PhoneNumber, DateOfBirth = pat.DateOfBirth, Address = pat.Address, CreatedOn = pat.CreatedOn, CountryId = pat.CountryId, CountrySubDivisionId = pat.CountrySubDivisionId, CountrySubDivisionName = country.CountrySubDivisionName, CurrentBalance = ins != null ? ins.CurrentBalance : 0, InsuranceProviderId = ins != null ? ins.InsuranceProviderId : 0, IMISCode = ins != null ? ins.IMISCode : null }).OrderByDescending(p => p.PatientId).ToList(); responseData.Results = allPats; } responseData.Status = "OK"; } else { responseData.Status = "failed"; responseData.ErrorMessage = "Invalid request type."; } //responseData.Results = null; } catch (Exception ex) { responseData.Status = "Failed"; responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString(); } return(DanpheJSONConvert.SerializeObject(responseData, true)); }
public PatientRepository(PatientDbContext context) { _context = context; }
/// <summary> /// Gets the patient detail by name asynchronous. /// </summary> /// <param name="dbContext">The database context.</param> /// <param name="entity">The entity.</param> /// <returns></returns> public static async Task <Patient> GetPatientDetailByNameAsync(this PatientDbContext dbContext, Patient entity) => await dbContext.PatientDetails.FirstOrDefaultAsync(item => item.Forename == entity.Forename && item.Surname == entity.Surname);
/// <summary> /// Initializes a new instance of the <see cref="PatientsController"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="dbContext">The database context.</param> public PatientsController(ILogger <PatientsController> logger, PatientDbContext dbContext) { Logger = logger; DbContext = dbContext; }
public SqlServerDoctorDbService(PatientDbContext context) { this.context = context; }
public GetPatientQueryHandler(PatientDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public TreatmentsController(PatientDbContext context) { _context = context; }