Example #1
0
        public HttpResponseMessage addSpeciality(HttpRequestMessage request, int doctorid = 0, int specialityid = 0)
        {
            tbDoctor    UpdatedEntity = new tbDoctor();
            tbSpecialty specialty     = specialityRepo.Get().Where(s => s.ID == specialityid).FirstOrDefault();
            tbDoctor    doctor        = doctorRepo.Get().Where(d => d.ID == doctorid).FirstOrDefault();

            doctor.SpecialityID = specialty.ID;
            doctor.Specialty    = specialty.Specialty;
            UpdatedEntity       = doctorRepo.UpdatewithObj(doctor);
            return(request.CreateResponse <tbDoctor>(HttpStatusCode.OK, UpdatedEntity));
        }
        /// <summary>
        /// 同步医护人员(新增或修改)
        /// </summary>
        /// <param name="sync"></param>
        /// <returns>是否保存成功</returns>
        public async Task <OutputBase> AddOrUpdate(AddDoctorSync sync)
        {
            var doctor = await _repository.Get(sync.DialysisDoctorId, sync.HospitalId);

            if (doctor == null)
            {
                _repository.Add(Mapper.Map <AddDoctorSync, Doctor>(sync));
            }
            else
            {
                Mapper.Map <AddDoctorSync, Doctor>(sync, doctor);
                doctor.UpdateTime = DateTime.Now;
            }

            return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败"));
        }
        public IHttpActionResult Get(int id)
        {
            var doctor = doctorRepository.Get(id);

            if (doctor == null)
            {
                return(StatusCode(HttpStatusCode.NotFound));
            }
            return(Ok(doctor));
        }
Example #4
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int ID, int hospitalid = 0)
        {
            tbDoctor         UpdatedDoctorEntity         = new tbDoctor();
            tbDoctorHospital UpdatedDoctorHospitalEntity = new tbDoctorHospital();
            tbDoctor         doctor         = doctorRepo.Get().Where(a => a.ID == ID).FirstOrDefault();
            tbDoctorHospital doctorhospital = doctorhospitalRepo.Get().Where(a => a.DoctorID == doctor.ID && a.HospitalID == hospitalid).FirstOrDefault();

            doctor.IsDeleted            = true;
            doctorhospital.IsDeleted    = true;
            UpdatedDoctorEntity         = doctorRepo.UpdatewithObj(doctor);
            UpdatedDoctorHospitalEntity = doctorhospitalRepo.UpdatewithObj(doctorhospital);
            DoctorHospitalViewModel dhvm = new DoctorHospitalViewModel();

            dhvm.doctor   = UpdatedDoctorEntity;
            dhvm.hospital = UpdatedDoctorHospitalEntity;
            return(request.CreateResponse <DoctorHospitalViewModel>(HttpStatusCode.OK, dhvm));
        }
 public Doctor Get(int id)
 {
     return(_repository.Get(id));
 }
Example #6
0
        public IActionResult Get(string TypeName)
        {
            Doctor doctor = _doctorRepository.Get(TypeName);

            return(Ok(doctor));
        }
        public HttpResponseMessage Create(HttpRequestMessage request, PatientAppointmentViewModel patient)
        {
            PatientAppointmentViewModel pavm = new PatientAppointmentViewModel();

            tbPatient     UpdatedEntity      = null;
            tbAppointment UpdatedAppointment = null;

            if (iBookingService.checkBookingAvailable(patient.appointment.ScheduleDataID ?? 0) == true)
            {
                if (patient.patient.ID > 0)
                {
                    UpdatedEntity = patientRepo.UpdatewithObj(patient.patient);
                }
                else
                {
                    if (patient.patient.MsgrID != null)
                    {
                        tbPatient oldPatient = patientRepo.Get().Where(a => a.MsgrID == patient.patient.MsgrID && a.IsDeleted != true).FirstOrDefault();
                        if (oldPatient != null)
                        {
                            oldPatient.MsgrName = patient.patient.MsgrName;
                            oldPatient.Name     = patient.patient.Name;
                            oldPatient.Phone    = patient.patient.Phone;
                            oldPatient.Problem  = patient.patient.Problem;
                            oldPatient.Gender   = patient.patient.Gender;
                            oldPatient.Age      = patient.patient.Age;
                            oldPatient.Address  = patient.patient.Address;
                            UpdatedEntity       = patientRepo.UpdatewithObj(oldPatient);
                        }
                        else
                        {
                            // UpdatedEntity = new tbPatient();
                            patient.patient.IsDeleted  = false;
                            patient.patient.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow);
                            UpdatedEntity = patientRepo.AddWithGetObj(patient.patient);
                        }
                    }
                    else
                    {
                        // UpdatedEntity = new tbPatient();
                        patient.patient.IsDeleted  = false;
                        patient.patient.Accesstime = MyExtension.getLocalTime(DateTime.UtcNow);
                        UpdatedEntity = patientRepo.AddWithGetObj(patient.patient);
                    }
                }

                tbAppointment appointment = appRepo.GetWithoutTracking().Where(a => a.IsDeleted != true && a.PatientId == UpdatedEntity.ID).FirstOrDefault();
                if (appointment != null)
                {
                    appointment.PatientId   = UpdatedEntity.ID;
                    appointment.PatientName = UpdatedEntity.Name;
                    appointment.PatientAge  = UpdatedEntity.Age;
                    appointment.DoctorName  = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == patient.appointment.DoctorId).Select(a => a.Name).FirstOrDefault();
                    appointment             = appRepo.UpdatewithObj(appointment);
                }
                else
                {
                    var scheduledata = dbContext.tbScheduleDatas.Where(a => a.IsDeleted != true && a.ID == patient.appointment.ScheduleDataID).FirstOrDefault();

                    int counter  = dbContext.tbAppointments.Where(a => a.ScheduleDataID == scheduledata.ID).Count();
                    int?position = dbContext.tbAppointments.Where(a => a.ScheduleDataID == scheduledata.ID).Max(a => a.Position);
                    // patient.appointment = new tbAppointment();
                    patient.appointment.PatientId   = UpdatedEntity.ID;
                    patient.appointment.PatientName = UpdatedEntity.Name;
                    patient.appointment.PatientAge  = UpdatedEntity.Age;
                    patient.appointment.Status      = "BOOKED";
                    patient.appointment.Counter     = counter + 1;
                    if (position == null)
                    {
                        patient.appointment.Position = counter + 1;
                    }
                    else
                    {
                        patient.appointment.Position = position + 1;
                    }
                    //patient.appointment.HospitalId =
                    //patient.appointment.HospitalName =
                    //    patient.appointment.Day = patient.appointment.AppointmentDateTime.Value.DayOfWeek.ToString();
                    patient.appointment.IsDeleted    = false;
                    patient.appointment.Accesstime   = MyExtension.getLocalTime(DateTime.UtcNow);
                    patient.appointment.HospitalName = dbContext.tbHospitals.Where(a => a.IsDeleted != true && a.ID == patient.appointment.HospitalId).Select(a => a.Name).FirstOrDefault();
                    //   patient.appointment.DoctorName = dbContext.tbDoctors.Where(a => a.IsDeleted != true && a.ID == patient.appointment.DoctorId).Select(a => a.Name).FirstOrDefault();
                    UpdatedAppointment = appRepo.AddWithGetObj(patient.appointment);

                    var doc = docRepo.Get().Where(a => a.ID == patient.appointment.DoctorId && a.IsDeleted != true).FirstOrDefault();

                    FCMViewModel fcm = new FCMViewModel();
                    fcm.to = doc.UserToken;

                    fcmdata fcmdata = new fcmdata();
                    fcmdata.body     = "1 patient is waiting";
                    fcmdata.doctorId = doc.ID;
                    fcmdata.title    = "Booking notification";
                    fcmdata.type     = "1001";
                    fcm.data         = fcmdata;
                    FCMRequestHelper.sendTokenMessage(fcm);
                }
            }

            pavm.patient     = UpdatedEntity;
            pavm.appointment = UpdatedAppointment;

            return(request.CreateResponse <PatientAppointmentViewModel>(HttpStatusCode.OK, pavm));
        }
Example #8
0
 public Doctor Get(Doctor doctor)
 {
     return(doctorRepository.Get(doctor));
 }
Example #9
0
 public Doctor Get(int id)
 => _doctorRepository.Get(id);