예제 #1
0
        public async Task <int> AssignSample(string instrumentId, DateTime testDate, string sheetId)
        {
            var sampleNo = 0;
            var sheet    = await _labSheetService.FindEntityAsync(sheetId);

            var testEntity = new LabTestEntity();

            testEntity.Create();
            testEntity.F_Barcode      = sheet.F_Barcode;
            testEntity.F_InstrumentId = instrumentId;
            testEntity.F_PatientId    = sheet.F_Pid;
            testEntity.F_RequestId    = sheet.F_RequestId;
            testEntity.F_SampleType   = sheet.F_SampleType;
            testEntity.F_SignInPerson = testEntity.F_CreatorUserId;
            testEntity.F_SignInTime   = testEntity.F_CreatorTime;
            testEntity.F_Status       = 0;
            testEntity.F_TestDate     = testDate;
            sampleNo = await CreateSampleNo(instrumentId, testDate);

            testEntity.F_TestNo = sampleNo;
            testEntity.F_TestId = long.Parse(Common.CreateNo());
            await _service.InsertAsync(testEntity);

            sheet.F_Status = 4;
            await _labSheetService.UpdatePartialAsync(sheet);

            return(sampleNo);
        }
예제 #2
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);
        }