示例#1
0
 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));
     }
 }
示例#2
0
 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));
     }
 }