Beispiel #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);
                        }
                    }
                }
            }
        }
Beispiel #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));
            }
        }