Ejemplo n.º 1
0
        /// <summary>
        /// 添加干体重变化记录
        /// </summary>
        /// <param name="pid">患者ID</param>
        /// <returns></returns>
        private async Task AddIdeaWeightRecord(string pid)
        {
            var patientEntity = await _service.FindEntityAsync(pid);

            if (patientEntity.F_IdealWeight.HasValue)
            {
                var newValue             = patientEntity.F_IdealWeight.ToFloat(2);
                var ideaWeightRepository = _uow.GetRepository <IdeaWeightEntity>();
                var expression           = ExtLinq.True <IdeaWeightEntity>();
                expression = expression.And(t => t.F_Pid == patientEntity.F_Id)
                             .And(t => t.F_EnabledMark == true);
                var ideaWeightEntity = ideaWeightRepository.IQueryable(expression).OrderByDescending(t => t.F_CreatorTime)
                                       .FirstOrDefault();
                if (ideaWeightEntity == null)
                {
                    ideaWeightEntity = new IdeaWeightEntity
                    {
                        F_Pid         = patientEntity.F_Id,
                        F_Name        = patientEntity.F_Name,
                        F_EnabledMark = true,
                        F_DialysisNo  = patientEntity.F_DialysisNo,
                        F_IdealWeight = newValue
                    };
                    ideaWeightEntity.Create();
                    await ideaWeightRepository.InsertAsync(ideaWeightEntity);
                }
                else
                {
                    if (ideaWeightEntity.F_IdealWeight != null)
                    {
                        var oldValue = ideaWeightEntity.F_IdealWeight.ToFloat(2);
                        if (Math.Abs(oldValue - newValue) > 0.001f)
                        {
                            ideaWeightEntity = new IdeaWeightEntity
                            {
                                F_Pid            = patientEntity.F_Id,
                                F_Name           = patientEntity.F_Name,
                                F_EnabledMark    = true,
                                F_DialysisNo     = patientEntity.F_DialysisNo,
                                F_IdealWeight    = newValue,
                                F_OldIdealWeight = oldValue
                            };
                            ideaWeightEntity.Create();
                            await ideaWeightRepository.InsertAsync(ideaWeightEntity);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Task <int> SubmitForm(IdeaWeightEntity entity, string keyValue)
        {
            var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity;

            claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity));
            var claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier);

            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
                entity.F_LastModifyUserId = claim?.Value;
                return(_service.UpdateAsync(entity));
            }
            else
            {
                entity.Create();
                entity.F_CreatorUserId = claim?.Value;
                return(_service.InsertAsync(entity));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 因App新增
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="userId"></param>
        /// <param name="value"></param>
        public Task <int> UpdateWeight(string pid, string userId, float value)
        {
            var patient = _service.FindEntity(pid);

            if (patient == null)
            {
                return(Task.FromResult(0));
            }
            patient.F_IdealWeight = value;
            _service.Update(patient, true);
            //查询体重修改记录
            var ideaWeightRepository = _uow.GetRepository <IdeaWeightEntity>();
            var expression           = ExtLinq.True <IdeaWeightEntity>();

            expression = expression.And(t => t.F_Pid == pid).And(t => t.F_EnabledMark == true);
            var query  = ideaWeightRepository.IQueryable(expression);
            var entity = query.OrderByDescending(t => t.F_CreatorTime).FirstOrDefault();

            if (entity != null && Math.Abs(entity.F_IdealWeight.ToFloat(2) - value) < 0.01)
            {
                return(Task.FromResult(0));
            }
            var newentity = new IdeaWeightEntity
            {
                F_Id            = Common.GuId(),
                F_Pid           = patient.F_Id,
                F_Name          = patient.F_Name,
                F_DialysisNo    = patient.F_DialysisNo,
                F_IdealWeight   = value,
                F_EnabledMark   = true,
                F_CreatorUserId = userId,
                F_CreatorTime   = DateTime.Now
            };

            if (entity != null)
            {
                newentity.F_OldIdealWeight = entity.F_IdealWeight;
            }
            return(ideaWeightRepository.InsertAsync(newentity));
        }
Ejemplo n.º 4
0
 public Task <int> UpdateForm(IdeaWeightEntity entity)
 {
     return(_service.UpdateAsync(entity));
 }