public async Task <IActionResult> Edit(long id, [Bind("BedAllotmentId,PatientName,BedName,BedCategory,HospitalizationDate,DischargeDate,Notes")] BedAllotment bedAllotment) { if (id != bedAllotment.BedAllotmentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bedAllotment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BedAllotmentExists(bedAllotment.BedAllotmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bedAllotment)); }
public IActionResult AddPatientInfo([FromBody] Patients patient) { try { BedAllotment bedAllotment = new BedAllotment(); List <Beds> availableBeds = bedAllotment.GetAvailableBeds(); bool validInfo = false; string message = ""; PatientInfoValidator.ValidateInfoAndCheckForAvailability(patient, availableBeds.Count, ref validInfo, ref message); if (!validInfo) { return(BadRequest(message)); } else { patient.BedId = availableBeds[0].BedId; _context.Patients.Add(patient); _context.SaveChanges(); bedAllotment.AllotBedToPatient(patient); return(Ok()); } } catch (Exception) { return(StatusCode(500)); } }
public async Task <IActionResult> Edit(int id, BedAllotment bedAllotment) { if (id != bedAllotment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bedAllotment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BedAllotmentExists(bedAllotment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BedCategoryId"] = new SelectList(_context.BedCategory, "Id", "BedName", bedAllotment.BedCategoryId); ViewData["PatientId"] = new SelectList(_context.Patients, "Id", "Fullname", bedAllotment.PatientId); return(View(bedAllotment)); }
public async Task <IActionResult> Create([Bind("BedAllotmentId,PatientName,BedName,BedCategory,HospitalizationDate,DischargeDate,Notes")] BedAllotment bedAllotment) { if (ModelState.IsValid) { _context.Add(bedAllotment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bedAllotment)); }
public void GetAvailabilityOfBeds_ReturnsAListOfAvailaibleBeds() { int beds = 0; var _bedAllotment = new BedAllotment(); var _availableListOfBeds = _bedAllotment.GetAvailableBeds(); beds += (from bed in _availableListOfBeds where !bed.OccupancyStatus select bed).Count(); Assert.True(beds == _availableListOfBeds.Count()); }
public ActionResult <IEnumerable <Beds> > GetBedsAvailability() { try { BedAllotment bedAllotment = new BedAllotment(); return(Ok(bedAllotment.GetAvailableBeds())); } catch (Exception) { return(StatusCode(500)); } }
public async Task <IActionResult> Create(BedAllotment bedAllotment) { if (ModelState.IsValid) { _context.Add(bedAllotment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BedCategoryId"] = new SelectList(_context.BedCategory, "Id", "BedName", bedAllotment.BedCategoryId); ViewData["PatientId"] = new SelectList(_context.Patients, "Id", "Fullname", bedAllotment.PatientId); return(View(bedAllotment)); }
public void EmptyTheBed_ShouldUpdateOccupancyStatusToFalse() { Patients _patient = new Patients() { PatientName = "Nikita Kumari", Age = 23, BedId = 1, ContactNo = "9826376268", MonitoringStatus = 0, PatientId = 1 }; var _bedAllotment = new BedAllotment(); _bedAllotment.EmptyTheBed(_patient); var _allBeds = _bedAllotment.GetAvailableBeds(); foreach (var bed in _allBeds) { Assert.True(bed.BedId == 1); break; } }
public IActionResult DischargingPatient(int patientId) { try { BedAllotment bedAllotment = new BedAllotment(); var patientStore = _context.Patients.ToList(); var patientToBeDischarged = patientStore.FirstOrDefault(item => item.PatientId == patientId); if (patientToBeDischarged == null) { return(BadRequest("No Patient With The Given Patient Id Exists")); } bedAllotment.EmptyTheBed(patientToBeDischarged); PatientInfoValidator.DeleteVitalLogsForDischargedPatient(patientId); _context.Remove(patientToBeDischarged); _context.SaveChanges(); return(Ok()); } catch (Exception) { return(StatusCode(500)); } }