示例#1
0
        /// <summary>
        /// used to retrieve patient info for edit patient
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public PatientAppUserVm GetRegisteredPatient(int patientId)
        {
            var registeredPatient = new PatientAppUserVm();
            var patient           = _repo.Query <Patient>().Where(p => p.Id == patientId).Include(p => p.ApplicationUser).FirstOrDefault();

            patient.CheckInDate  = patient.CheckInDate.ToLocalTime();
            patient.CheckOutDate = patient.CheckOutDate.ToLocalTime();

            var nurse = _repo.Query <Nurse>().Where(n => n.Id == patient.NurseId).Include(n => n.ApplicationUser).FirstOrDefault();

            if (nurse == null)
            {
                registeredPatient.Patient         = patient;
                registeredPatient.ApplicationUser = patient.ApplicationUser;
            }
            else
            {
                registeredPatient.Patient              = patient;
                registeredPatient.Patient.Dependency   = patient.Dependency;
                registeredPatient.AssignedNurseId      = patient.NurseId;
                registeredPatient.PrimaryNurseFullName = nurse.ApplicationUser.FirstName + " " + nurse.ApplicationUser.LastName;
                registeredPatient.ApplicationUser      = patient.ApplicationUser;
            }
            return(registeredPatient);
        }
        public IActionResult Post([FromBody] PatientAppUserVm vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }
            var patient = _service.SavePatient(vm.AssignedNurseId, vm.ApplicationUser, vm.Patient);

            return(Ok(patient));
        }