Exemple #1
0
        /// <summary>
        /// 添加一个挂号
        /// </summary>
        public vwCHIS_Register AddOneRegister(int custId, int departId, int employeeId, int stationId,
                                              DateTime reservationDate, int reservationSlot,
                                              RegistFrom regFrom, out bool haveRegisted,
                                              RegisterTreatType regTreatType = RegisterTreatType.Normal,
                                              string remark = "", int?opId = null, string opMan = null, string propName = null, string propValue = null
                                              )
        {
            if (opId == null)
            {
                opId  = DbData.SystemMachineId;
                opMan = "SYSTEM";
            }

            haveRegisted = false;
            var find = MainDbContext.CHIS_Register.FirstOrDefault(m => m.EmployeeID == employeeId && m.RegisterSlot == reservationSlot &&
                                                                  m.CustomerID == custId &&
                                                                  (reservationDate - m.RegisterDate.Value).Days == 0);

            long regid = 0;

            if (find == null)
            {
                var add = MainDbContext.Add(new CHIS_Register
                {
                    CustomerID        = custId,
                    Department        = departId,
                    EmployeeID        = employeeId,
                    StationID         = stationId,
                    RegisterDate      = reservationDate.Date,
                    RegisterSlot      = reservationSlot,
                    RegisterTreatType = (int)regTreatType,
                    RegisterFrom      = (int)regFrom,
                    PropName          = propName,
                    PropValue         = propValue,
                    OpID  = opId,
                    OpMan = opMan
                }).Entity;
                MainDbContext.SaveChanges();
                regid = add.RegisterID;
            }
            if (find != null)
            {
                haveRegisted = true; regid = find.RegisterID;
            }

            return(MainDbContext.vwCHIS_Register.AsNoTracking().FirstOrDefault(m => m.RegisterID == regid));
        }
Exemple #2
0
        /// <summary>
        /// 添加一个挂号
        /// </summary>
        public async Task <Models.CHIS_Register> AddOneRegister(int custId, int departId, int doctorId, int stationId,
                                                                DateTime reservationDate, int reservationSlot,
                                                                RegistFrom regFrom,
                                                                RegisterTreatType regTreatType = RegisterTreatType.Normal,
                                                                string remark  = "", bool useSysUser = false,
                                                                int?opId       = 0, string opMan     = "",
                                                                int?rxDoctorId = null
                                                                )
        {
            //var u = controller.GetUserLoginData(true);
            bool haveRegisted = false;
            var  find         = _db.CHIS_Register.FirstOrDefault(m => m.EmployeeID == doctorId && m.RegisterSlot == reservationSlot &&
                                                                 m.CustomerID == custId &&
                                                                 (reservationDate - m.RegisterDate.Value).Days == 0);

            //如果是药店则可以多次预约
            var station = _db.CHIS_Code_WorkStation.FirstOrDefault(m => m.StationID == stationId);

            if (station == null)
            {
                throw new Exception("没有工作站");
            }
            if (station.StationTypeId == DictValues.StationType.k_StationType_DrugStore ||
                station.StationTypeId == DictValues.StationType.k_StationType_drugstoreS ||
                station.StationTypeId == DictValues.StationType.k_StationType_drugstore2)
            {
                //3分钟内不可重复预约
                if (find != null)
                {
                    if ((_db.GetDBTime() - find.OpTime.Value).TotalMinutes < 3)
                    {
                        throw new Exception("3分钟内不可重复预约!");
                    }
                }
            }
            else
            {
                if (find != null)
                {
                    haveRegisted = true; return(find);
                }
            }

            var et = new Models.CHIS_Register
            {
                CustomerID        = custId,
                Department        = departId,
                EmployeeID        = doctorId,
                RxDoctorId        = rxDoctorId,
                StationID         = stationId,
                RegisterDate      = reservationDate.Date,
                RegisterSlot      = reservationSlot,
                RegisterTreatType = (int)regTreatType,
                RegisterFrom      = (int)regFrom,
                OpID          = opId,
                OpMan         = opMan,
                IsEnable      = true,
                OpTime        = DateTime.Now,
                IsAppointment = (reservationDate.Date - DateTime.Today).Days >= 1,
                TreatStatus   = "waiting",
                RegisterSeq   = (_db.CHIS_Register.AsNoTracking().Where(m => m.StationID == stationId && m.EmployeeID == doctorId && m.RegisterDate == reservationDate.Date).Max(m => m.RegisterSeq) ?? 0) + 1
            };
            var addEntry = _db.CHIS_Register.Add(et);
            await _db.SaveChangesAsync();

            var rlt = addEntry.Entity;

            //异步执行
            _notifySvr.NotifyDoctorReservatedAsync(doctorId, custId, rlt.RegisterID);
            return(rlt);
        }