public static void Main(string[] args) { if (args.Length > 0 && args[0] == "test") { System.Console.WriteLine("testing..."); //load config file var config = new ConfigurationBuilder() .SetBasePath(System.IO.Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true) .Build(); //setup db var optionsBuilder = new DbContextOptionsBuilder <PatientContext>(); optionsBuilder.UseSqlServer( config.GetConnectionString("test") ); try { //connect to db PatientContext dbc = new PatientContext(optionsBuilder.Options); MasterPatientIndex.Repo.PatientRepo.testRepo(dbc); } catch (Exception ex) { System.Console.WriteLine("caught error: " + ex.Message + " inner: " + ex.InnerException?.Message); } return; } CreateHostBuilder(args).Build().Run(); }
public async Task <List <PatientDto> > GetAll() { using (var db = new PatientContext()) { db.Configuration.LazyLoadingEnabled = false; try { var patients = new List <PatientDto>(); foreach (var item in await db.Patients.ToListAsync()) { patients.Add(new PatientDto { Patient = item }); } return(patients); } catch (Exception ex) { Console.WriteLine(ex); throw; } } }
public ClaimViewModelController(ClaimContext claimContext, PatientContext patientContext, OrganizationContext organizationContext, IMapper mapper) { _claimContext = claimContext; _patientContext = patientContext; _organizationContext = organizationContext; _mapper = mapper; }
private void luePTN_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Index == 1) { frmPatient frm = new frmPatient(); if (frm.ShowDialog() == DialogResult.OK) { Patient p = new Patient(); p.ID = frm.ID; p.PatientName = frm.PatientName; p.Sex = frm.Sex; p.DateOfBirth = frm.DateOfBirth; p.PhoneNo = frm.PhoneNo; p.Address = frm.Address; p.Comments = frm.Comments; p.MedicalHistory = frm.MedicalHistory; ServerToClient sc = new ServerToClient(); PatientContext px = new PatientContext(); sc = px.AddPatient(p); if (sc.Message == null) { LoadPatients(); luePTN.EditValue = sc.Count; } else { XtraMessageBox.Show(sc.Message); } } } }
public async Task <PatientDto> Post(PatientDto patient) { using (var db = new PatientContext()) { using (var transaction = db.Database.BeginTransaction(System.Data.IsolationLevel.Serializable)) { try { db.Patients.AddOrUpdate(patient.Patient); db.PatientAilmentLookups.AddOrUpdate(patient.PatientAilmentLookups.ToArray()); await db.SaveChangesAsync(); transaction.Commit(); return(patient); } catch (Exception ex) { transaction.Rollback(); Console.WriteLine(ex); throw; } } } }
// // GET: /Patient/ public ActionResult DetailsPage() { using (var db = new PatientContext()) { return(View(db.Items.Count())); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var PatientOptions = new DbContextOptionsBuilder <PatientContext>() .UseInMemoryDatabase("Patients").Options; var DrugOptions = new DbContextOptionsBuilder <DrugContext>() .UseInMemoryDatabase("Drugs").Options; var DosagesOptions = new DbContextOptionsBuilder <DosageContext>() .UseInMemoryDatabase("Dosage").Options; var PatientCont = new PatientContext(PatientOptions); var DrugCont = new DrugContext(DrugOptions); var DosageCont = new DosageContext(DosagesOptions); IRelationshipService Relationship = new RelationshipService(PatientCont, DrugCont, DosageCont); services.AddSingleton(Relationship); services.AddDbContext <PatientContext>(opt => opt.UseInMemoryDatabase("Patients")); services.AddDbContext <DrugContext>(opt => opt.UseInMemoryDatabase("Drugs")); services.AddDbContext <DosageContext>(opt => opt.UseInMemoryDatabase("Dosage")); services.AddControllers(); }
public ActionResult Registration_Post(Patient patient) { string message = ""; bool status = false; if (ModelState.IsValid) { if (isEmailExist(patient.EmailID)) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(patient)); } else { patient.Password = Crypto.Hash(patient.Password); // patient.ConfirmPassword = Crypto.Hash(patient.ConfirmPassword); using (PatientContext db = new PatientContext()) { db.Patients.Add(patient); db.SaveChanges(); status = true; message = "Registration successfully done."; } } } else { message = "Invalid Request"; } ViewBag.status = status; ViewBag.message = message; return(View(patient)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PatientContext context) { context.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "patient_api v1"); }); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHealthChecksUI(); endpoints.MapHealthChecks("api/health", new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); }); }
public PatientController(PatientContext context) { _context = context; if (_context.Patients.Count() == 0) { _context.Patients.Add(new Patient { FirstName = "John", LastName = "Smith", Age = 21 }); _context.Patients.Add(new Patient { FirstName = "Mary", LastName = "Jane", Age = 28 }); _context.Patients.Add(new Patient { FirstName = "Elizabeth", LastName = "Stone", Age = 22 }); _context.Patients.Add(new Patient { FirstName = "Jimmy", LastName = "Brown", Age = 27 }); _context.Patients.Add(new Patient { FirstName = "Rose", LastName = "Hamilton", Age = 23 }); _context.Patients.Add(new Patient { FirstName = "Lewis", LastName = "Martin", Age = 26 }); _context.Patients.Add(new Patient { FirstName = "Ian", LastName = "Wayne", Age = 24 }); _context.Patients.Add(new Patient { FirstName = "Samantha", LastName = "Picoult", Age = 25 }); _context.SaveChanges(); } }
private void UpdateRecentPatientContexts() { var patientContext = new PatientContext(); patientContext.PatientId = _patientId; patientContext.ActivePlanSetup = MapPlanningItemViewModelToData(SelectedPlanSetup); foreach (var planningItemsInScope in PlanningItems.Where(p => p.IsChecked)) { patientContext.PlanningItemsInScope .Add(MapPlanningItemViewModelToData(planningItemsInScope)); } if (RecentPatientContexts.Contains(patientContext)) { var index = RecentPatientContexts.IndexOf(patientContext); RecentPatientContexts.Move(index, 0); } else { RecentPatientContexts.Insert(0, patientContext); if (RecentPatientContexts.Count > MaximumNumberOfRecentPatientContexts) { RecentPatientContexts.Remove(RecentPatientContexts.Last()); } } }
public List <Patient> GetAll() { using (var db = new PatientContext()) { return(db.Patients.Include("Referrals").Where(x => x.UserProfileId.Equals(WebSecurity.CurrentUserId)).ToList()); } }
public IActionResult Index() { PatientContext context = HttpContext.RequestServices.GetService(typeof(ConnectString.Models.PatientContext)) as PatientContext; return(View(context.GetAllPatient())); }
public ActionResult Login(UserAccount model, string returnUrl) { using (PatientContext db = new PatientContext()) { var usr = db.UserAccount.Single(u => u.UserName == model.UserName && u.Password == model.Password); if (usr != null) { FormsAuthentication.SetAuthCookie(usr.UserName, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/||")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Patients")); //return RedirectToAction("Login"); } //Session["UserID"] = usr.UserId.ToString(); //Session["UserName"] = usr.UserName.ToString(); //Session["Users"] = usr.UserName.ToString(); //return RedirectToAction("LoggedIn"); //return RedirectToAction("Index", "Patients"); } else { ModelState.AddModelError("", "Username or Password is incorrect."); return(View()); } } }
public static void Initialize(PatientContext context) { context.Database.EnsureCreated(); if (context.Patients.Any()) { return; } var patients = new Patient[] { new Patient { GivenName = "Ali", FamilyName = "Zaib", ContactNumber = "334512xxxx", DoB = new DateTime(1984, 3, 24), PasNumber = "1", SexCode = "M", NextOfKin = new Kin { Name = "Amir Zaib", RelationshopCode = "Brother", Address = "Full Address here" } }, new Patient { GivenName = "Imran", FamilyName = "Zaib", ContactNumber = "334512xxxx", DoB = new DateTime(1992, 3, 24), PasNumber = "2", SexCode = "M", NextOfKin = new Kin { Name = "Jehan Zaib", RelationshopCode = "Brother", Address = "Full Address here" } }, new Patient { GivenName = "Diya", FamilyName = "Ali", ContactNumber = "334512xxxx", DoB = new DateTime(1984, 3, 24), PasNumber = "1", SexCode = "F", NextOfKin = new Kin { Name = "Ali Zaib", RelationshopCode = "Husband", Address = "Full Address here" } }, }; context.Patients.AddRange(patients); context.SaveChanges(); }
public void Equals_GivenNullObject_ReturnsFalse() { PatientContext patientContext = TestUtilities.GetPatientContext(); Assert.IsFalse(patientContext.Equals(null)); Assert.IsNotNull(patientContext); }
private void bNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { frmPatient frm = new frmPatient(); if (frm.ShowDialog() == DialogResult.OK) { Patient p = new Patient(); p.ID = frm.ID; p.PatientName = frm.PatientName; p.Sex = frm.Sex; p.DateOfBirth = frm.DateOfBirth; p.PhoneNo = frm.PhoneNo; p.Address = frm.Address; p.Comments = frm.Comments; p.MedicalHistory = frm.MedicalHistory; ServerToClient sc = new ServerToClient(); PatientContext px = new PatientContext(); sc = px.AddPatient(p); if (sc.Message == null) { //LoadPatients(); //luePTN.EditValue = sc.Count; XtraMessageBox.Show("New patient added successfully!"); } else { XtraMessageBox.Show(sc.Message); } } }
public void Equals_GivenDifferentObject_ReturnsFalse() { var patientContext = new PatientContext(_guYear, _guNumber); var patientContext1 = new PatientContext(_guYear, _guNumber + 1); Assert.IsFalse(patientContext.Equals(patientContext1)); }
public void EqualityOperator_GivenDifferntObjects_ReturnsTrue() { PatientContext patientContext = TestUtilities.GetPatientContext(); PatientContext pateintContext1 = TestUtilities.GetPatientContext(_guYear, _guNumber + 1); Assert.IsTrue(patientContext != pateintContext1); }
public void GetHashCode_WhenCalled_ReturnsNonZero() { PatientContext patientContext = TestUtilities.GetPatientContext(); int code = patientContext.GetHashCode(); Assert.AreNotEqual(0, code); }
public void Equals_GivenDifferentGuYear_ReturnsFalse() { var patientContext = new PatientContext(_guYear, _guNumber); var patientContext1 = new PatientContext(_guYear + 1, _guNumber); Assert.IsFalse(patientContext == patientContext1); }
public void Equals_GivenDifferentGuNumber_ReturnsFalse() { var patientContext = new PatientContext(_guYear, _guNumber); PatientContext patientContext1 = TestUtilities.GetPatientContext(_guYear, _guNumber + 1); Assert.IsFalse(patientContext == patientContext1); }
public void Equals_GivenSameGuYearAndGuNumber_ReturnsTrue() { var patientContext = new PatientContext(_guYear, _guNumber); var patientContext1 = new PatientContext(_guYear, _guNumber); Assert.IsTrue(patientContext == patientContext1); }
public void SetDirty_WhenCalled_SetsIsDirtyToTrue() { var patientContext = new PatientContext(_guYear, _guNumber); Assert.IsFalse(patientContext.IsDirty); patientContext.SetDirty(); Assert.IsTrue(patientContext.IsDirty); }
public async Task TestGetByConditionEagerLoading() { // Arrange var options = new DbContextOptionsBuilder <PatientContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString(), new InMemoryDatabaseRoot()) .Options; IEnumerable <Patient> results; await using (var context = new PatientContext(options)) { await context.Database.EnsureCreatedAsync(); var repository = new Repository <Patient>(context); // Act results = await repository.GetByConditionAsync(_ => true, eager : true); await context.Database.EnsureDeletedAsync(); } // Assert Assert.NotNull(results); Assert.IsAssignableFrom <IEnumerable <Patient> >(results); Assert.Equal(10, results.Count()); Assert.NotNull(results.First().Gender); }
public ActionResult Details(int id) { PatientContext patientContext = new PatientContext(); Patient patient = patientContext.Patients.Single(pat => pat.ID == id); return(View(patient)); }
public IEnumerable <Patient> GetPatients() { using (PatientContext ctx = new PatientContext()) { return(ctx.Patients.ToList <Patient>()); } }
public void Add(Patient p) { using (PatientContext ctx = new PatientContext()) { ctx.Patients.Add(p); ctx.SaveChanges(); } }
public static PatientList SafeFetchData(string name) { PatientContext db = new PatientContext(); PatientList patientList = new PatientList(); patientList.Patients = db.Patients.Where(p => p.PatientName == name && (!p.IsSensitive)).ToList(); return(patientList); }
public void Constructor_GivenValues_InitializesValues() { const string testValue = "TestValue"; var patientContext = new PatientContext(_guYear, _guNumber, testValue); Assert.AreEqual(_guYear, patientContext.GuYear); Assert.AreEqual(_guNumber, patientContext.GuNumber); Assert.AreEqual(testValue, patientContext.Description); }
public void IsDirty_GivenNewObject_ReturnsFalse() { var patientContext = new PatientContext(_guYear, _guNumber); Assert.IsFalse(patientContext.IsDirty); }
public void Equals_GivenSameObject_ReturnsTrue() { var patientContext = new PatientContext(_guYear, _guNumber); Assert.IsTrue(patientContext.Equals(patientContext)); }