Esempio n. 1
0
        public async Task <IActionResult> AssignSample([FromBody] AssignSampleInput input)
        {
            var sheets = await _labRequestApp.GetFormByBarcode(input.Barcode);

            if (!sheets.Any())
            {
                return(Error("未查询到样本信息!"));
            }
            else if (sheets.Any(t => t.F_Status < 3))
            {
                return(Error("标本未采样,不能进行编号操作!"));
            }
            else if (sheets.Any(t => t.F_Status > 3))
            {
                return(Error("标本已编号!"));
            }
            else if (sheets.All(t => t.F_Status != 3))
            {
                return(Error("未查询到样本信息!"));
            }
            //校验是否在此仪器上处理 未完善
            //return Error("无此仪器上的处理项目");
            var findSheet = sheets.FirstOrDefault(t => t.F_Status == 3);
            var data      = await _labTestApp.AssignSample(input.InstrumentId, input.TestDate?.ToDate() ?? DateTime.Today, findSheet?.F_Id);

            return(Success("操作成功", data));
        }
Esempio n. 2
0
        public async Task <IActionResult> SampleConfirm([FromBody] SampleConfirmInput input)
        {
            var list = await _labRequestApp.GetFormByBarcode(input.Barcode);

            if (list.Count == 0)
            {
                return(Error("未查询到条码号为【" + input.Barcode + "】的检验申请记录!"));
            }
            var status = list[0].F_Status;

            if (status >= 3)
            {
                return(Error("条码号为【" + input.Barcode + "】的检验项目已采集!"));
            }
            var user = await _usersService.GetCurrentUserAsync();//

            var _samplingTime = input.SamplingTime?.ToDate() ?? DateTime.Now;

            foreach (var item in list)
            {
                item.F_Status       = 3;
                item.F_SamplingTime = _samplingTime;
                item.F_NurseId      = user.F_Id;
                item.F_NurseName    = user.F_RealName;
                await _labRequestApp.UpdateForm(item);
            }
            return(Success("操作成功"));
        }
Esempio n. 3
0
        public async Task <string> AuditTest(LabTestEntity entity)
        {
            var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity;

            claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity));
            var claim     = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier);
            var claimName = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.Name);
            var result    = string.Empty;
            //查询子项
            var items = GetReport(entity.F_TestId);

            if (items.Count == 0)
            {
                result = "无报告明细";
            }
            else
            {
                //保存质控数据
                var itemDict = _labInstrumentApp.GetItem(entity.F_InstrumentId)
                               .Where(t => t.F_IsQualityItem == true)
                               .Select(t => new
                {
                    t.F_Id,
                    t.F_IsQualityItem,
                    t.F_QualityItemId,
                    t.F_QualityItemName,
                    t.F_ConvertCoefficient,
                    t.F_KeepDecimal,
                    t.F_ResultType,
                    t.F_MachineId,
                    t.F_Code,
                    t.F_Name,
                    t.F_CnName,
                    t.F_EnName
                }).ToList();
                var list = items.Join(itemDict, m => m.F_ItemId, n => n.F_Id, (m, n) => new
                {
                    result = m,
                    dict   = n
                });
                if (list.Any())
                {
                    var sheet = (await _labRequestApp.GetFormByBarcode(entity.F_Barcode)).FirstOrDefault(t => t.F_RequestId == entity.F_RequestId);
                    if (sheet == null)
                    {
                        result = "申请单已删除";
                    }
                    else
                    {
                        //var LoginInfo = OperatorProvider.Provider.GetCurrent();
                        var currentTime = DateTime.Now;
                        foreach (var row in list)
                        {
                            var qualityItem = await _qualityItemService.FindEntityAsync(row.dict.F_QualityItemId);

                            if (qualityItem == null)
                            {
                                continue;
                            }
                            var quality = new QualityResultEntity
                            {
                                F_Id                 = Common.GuId(),
                                F_CreatorTime        = currentTime,
                                F_CreatorUserId      = claim?.Value,
                                F_EnabledMark        = true,
                                F_Flag               = row.result.F_Flag,
                                F_ItemCode           = qualityItem.F_ItemCode,
                                F_ItemName           = qualityItem.F_ItemName,
                                F_ItemId             = qualityItem.F_Id,
                                F_LowerCriticalValue = qualityItem.F_LowerCriticalValue,
                                F_LowerValue         = qualityItem.F_LowerValue,
                                F_Pid                = entity.F_PatientId,
                                F_ReportTime         = currentTime
                            };
                            if (row.dict.F_ResultType ?? true)
                            {
                                quality.F_ResultType = true;
                                var temp = row.result.F_Result;
                                if (!temp.HasValue)
                                {
                                    continue;
                                }
                                int keep = 2;
                                if (row.dict.F_KeepDecimal.HasValue)
                                {
                                    keep = row.dict.F_KeepDecimal.ToInt();
                                    if (keep == 0)
                                    {
                                        keep = 2;
                                    }
                                }
                                float convertCoefficient = 1;
                                if (row.dict.F_ConvertCoefficient.HasValue)
                                {
                                    convertCoefficient = row.dict.F_ConvertCoefficient.ToFloat(keep);
                                }
                                quality.F_Result = (temp * convertCoefficient).ToFloat(keep).ToString();
                            }
                            else
                            {
                                quality.F_Result = row.result.F_ResultText;
                            }
                            quality.F_Unit = qualityItem.F_Unit;
                            quality.F_UpperCriticalValue = qualityItem.F_UpperCriticalValue;
                            quality.F_UpperValue         = qualityItem.F_UpperValue;
                            await _qualityResultService.InsertAsync(quality);
                        }
                        entity.F_Status      = 3;
                        entity.F_AuditPerson = claim?.Value;
                        entity.F_AuditTime   = currentTime;
                        await _service.UpdatePartialAsync(entity);

                        sheet.F_AuditTime     = currentTime;
                        sheet.F_AuditUserId   = claim?.Value;
                        sheet.F_AuditUserName = claimName?.Value;
                        await _labSheetService.UpdatePartialAsync(sheet);
                    }
                }
            }
            return(result);
        }