using BatchService.Framework.Utility; using PalGain.Core; using sbcLabSystem.Data.Domain.Backstage; using sbcLabSystem.Service.QC; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace sbcLabSystem.Models.Backstage { public class CountModel { public void Calculation(int QCid) { var service = PalGainEngine.Instance.Resolve(); var distInfo = service.GetQcDistributions().FirstOrDefault(p => p.Id == QCid); if (distInfo != null && distInfo.QCDistributionRegisters.Count > 0) { AnswerInfoViewModel standmodel = JsonHelper.JsonDeserialize(distInfo.AnswerJSON); var approvals = service.GetApprovals().Where(p => p.QCDistributionID == QCid); distInfo.QCDistributionRegisters.OrderBy(p => p.LabInfo.LabCode).ToList().ForEach(info => { Resultspercentage result = service.GetResultSpercentages() .FirstOrDefault(p => p.QCDistributionId == QCid && p.QcDistributionRegisterId == info.Id); if (result == null) { result = new Resultspercentage(); } var standResult = new Resultspercentage(); result.ABO_Score = 0; result.RH_Score = 0; result.KangtiIdentity_Score = 0; result.KangtiFilter_Score = 0; result.JiaoChaPeiXing_Score = 0; result.QCDistributionId = QCid; result.QcDistributionRegisterId = info.Id; #region 计算结果个数 if (info.AnswerJSON != null) { AnswerInfoViewModel model = JsonHelper.JsonDeserialize(info.AnswerJSON); this.SetValue(result, model); this.SetValue(standResult, standmodel); #region 算分 if (result.Abo1 != standResult.Abo1) { result.ABO_Score += approvals.FirstOrDefault(p => p.FieldName == "11" && p.FieldPatient == "1").Score; } if (result.Abo2 != standResult.Abo2) { result.ABO_Score += approvals.FirstOrDefault(p => p.FieldName == "11" && p.FieldPatient == "2").Score; } if (result.Abo3 != standResult.Abo3) { result.ABO_Score += approvals.FirstOrDefault(p => p.FieldName == "11" && p.FieldPatient == "3").Score; } if (result.RH1 != standResult.RH1) { result.RH_Score += approvals.FirstOrDefault(p => p.FieldName == "12" && p.FieldPatient == "1").Score; } if (result.RH2 != standResult.RH2) { result.RH_Score += approvals.FirstOrDefault(p => p.FieldName == "12" && p.FieldPatient == "2").Score; } if (result.RH3 != standResult.RH3) { result.RH_Score += approvals.FirstOrDefault(p => p.FieldName == "12" && p.FieldPatient == "3").Score; } double filter1_Score = 0, filter2_Score = 0, filter3_Score = 0; if (result.KangTiFilter1 != standResult.KangTiFilter1) { filter1_Score = approvals.FirstOrDefault(p => p.FieldName == "21" && p.FieldPatient == "1").Score; result.KangtiFilter_Score += filter1_Score; } if (result.KangTiFilter2 != standResult.KangTiFilter2) { filter2_Score = approvals.FirstOrDefault(p => p.FieldName == "21" && p.FieldPatient == "2").Score; result.KangtiFilter_Score += filter2_Score; } if (result.KangTiFilter3 != standResult.KangTiFilter3) { filter3_Score = approvals.FirstOrDefault(p => p.FieldName == "21" && p.FieldPatient == "3").Score; result.KangtiFilter_Score += filter3_Score; } var scoreIdentityTemp = 0.0; var scoreTemp = approvals.FirstOrDefault(p => p.FieldName == "22" && p.FieldPatient == "1").Score; if (filter1_Score == 0) { if (result.KangTiIdentity1 != standResult.KangTiIdentity1) { if (result.KangTiIdentity1.Contains(standResult.KangTiIdentity1) || result.KangTiIdentity1.IndexOf("UI") >= 0) { scoreIdentityTemp = scoreTemp / 2; result.KangtiIdentity_Score += scoreIdentityTemp; } else { scoreIdentityTemp = scoreTemp; result.KangtiIdentity_Score += scoreIdentityTemp; } } } scoreIdentityTemp = 0.0; scoreTemp = approvals.FirstOrDefault(p => p.FieldName == "22" && p.FieldPatient == "2").Score; if (filter1_Score == 0) { if (result.KangTiIdentity2 != standResult.KangTiIdentity2) { if (result.KangTiIdentity2.Contains(standResult.KangTiIdentity2) || result.KangTiIdentity2.IndexOf("UI") >= 0) { scoreIdentityTemp = scoreTemp / 2; result.KangtiIdentity_Score += scoreIdentityTemp; } else { scoreIdentityTemp = scoreTemp; result.KangtiIdentity_Score += scoreIdentityTemp; } } } scoreIdentityTemp = 0.0; scoreTemp = approvals.FirstOrDefault(p => p.FieldName == "22" && p.FieldPatient == "3").Score; if (filter1_Score == 0) { if (result.KangTiIdentity3 != standResult.KangTiIdentity3) { if (result.KangTiIdentity3.Contains(standResult.KangTiIdentity3) || result.KangTiIdentity3.IndexOf("UI") >= 0) { scoreIdentityTemp = scoreTemp / 2; result.KangtiIdentity_Score += scoreIdentityTemp; } else { scoreIdentityTemp = scoreTemp; result.KangtiIdentity_Score += scoreIdentityTemp; } } } if (result.JiaoChaPeiXing1W != standResult.JiaoChaPeiXing1W) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "31" && p.FieldPatient == "1").Score; } if (result.JiaoChaPeiXing1Y != standResult.JiaoChaPeiXing1Y) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "31" && p.FieldPatient == "2").Score; } if (result.JiaoChaPeiXing1Z != standResult.JiaoChaPeiXing1Z) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "31" && p.FieldPatient == "3").Score; } if (result.JiaoChaPeiXing2W != standResult.JiaoChaPeiXing2W) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "32" && p.FieldPatient == "1").Score; } if (result.JiaoChaPeiXing2Y != standResult.JiaoChaPeiXing2Y) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "32" && p.FieldPatient == "2").Score; } if (result.JiaoChaPeiXing2Z != standResult.JiaoChaPeiXing2Z) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "32" && p.FieldPatient == "3").Score; } if (result.JiaoChaPeiXing3W != standResult.JiaoChaPeiXing3W) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "33" && p.FieldPatient == "1").Score; } if (result.JiaoChaPeiXing3Y != standResult.JiaoChaPeiXing3Y) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "33" && p.FieldPatient == "2").Score; } if (result.JiaoChaPeiXing3Z != standResult.JiaoChaPeiXing3Z) { result.JiaoChaPeiXing_Score += approvals.FirstOrDefault(p => p.FieldName == "33" && p.FieldPatient == "3").Score; } #endregion if (result.Id > 0) { service.UpdateResultspercentage(result); } else { service.AddResultspercentage(result); } } #endregion }); } } public void SetValue(Resultspercentage result, AnswerInfoViewModel model) { result.Abo1 = new ScoreInfo("ABO1").GetValue(model.Result_11_1); result.RH1 = new ScoreInfo("RH1").GetValue(model.Result_12_1); result.Abo2 = new ScoreInfo("ABO2").GetValue(model.Result_11_2); result.RH2 = new ScoreInfo("RH2").GetValue(model.Result_12_2); result.Abo3 = new ScoreInfo("ABO3").GetValue(model.Result_11_3); result.RH3 = new ScoreInfo("RH3").GetValue(model.Result_12_3); // 抗体筛选实验 result.KangTiFilter1 = new ScoreInfo("Filter1").GetValue(model.Result_21_1); result.KangTiFilter2 = new ScoreInfo("Filter2").GetValue(model.Result_21_2); result.KangTiFilter3 = new ScoreInfo("Filter3").GetValue(model.Result_21_3); //交叉配型结果 result.JiaoChaPeiXing1W = new ScoreInfo("Patient1X").GetValue(model.Result_31_1); result.JiaoChaPeiXing1Y = new ScoreInfo("Patient1Y").GetValue(model.Result_32_1); result.JiaoChaPeiXing1Z = new ScoreInfo("Patient1Z").GetValue(model.Result_33_1); result.JiaoChaPeiXing2W = new ScoreInfo("Patient2X").GetValue(model.Result_31_2); result.JiaoChaPeiXing2Y = new ScoreInfo("Patient2Y").GetValue(model.Result_32_2); result.JiaoChaPeiXing2Z = new ScoreInfo("Patient2Z").GetValue(model.Result_33_2); result.JiaoChaPeiXing3W = new ScoreInfo("Patient3X").GetValue(model.Result_31_3); result.JiaoChaPeiXing3Y = new ScoreInfo("Patient3Y").GetValue(model.Result_32_3); result.JiaoChaPeiXing3Z = new ScoreInfo("Patient3Z").GetValue(model.Result_33_3); if (model.Part1 != null) { //题目1 result.RevDate = model.Part1.RevDate; //题目2 result.TestDate = model.Part1.TestDate; } //题目3 result.SampleQuality = GetValue("SampleQuality", model); //题目5实验方法 result.laboratoryMethod = GetValue("laboratoryMethod", model); //题目6试剂说明 result.Reagents = GetValue("Reagents", model); //题目11试剂红细胞数量 result.CellNumber = GetValue("CellNumber", model); if (model.Part4 != null) { result.ZhiKang1 = new ScoreInfo().GetZhiKangValue("ZhiKang1", model); result.ZhiKang2 = new ScoreInfo().GetZhiKangValue("ZhiKang2", model); result.ZhiKang3 = new ScoreInfo().GetZhiKangValue("ZhiKang3", model); } if (model.Part5 != null) { result.KangTiIdentity1 = new ScoreInfo().GetIdentityValue("Identity1", model.Part5); result.KangTiIdentity2 = new ScoreInfo().GetIdentityValue("Identity2", model.Part5); result.KangTiIdentity3 = new ScoreInfo().GetIdentityValue("Identity3", model.Part5); } } public string GetValue(string key, AnswerInfoViewModel model) { string ret = ""; #region 题目3 样本质量 if (key == "SampleQuality" && model.Part1!=null) { if (!string.IsNullOrEmpty(model.Part1.CB3_11)) { if (model.Part1.CB3_11 == "cb3_11") { ret += "患者血浆P1满意,"; } else { ret += "患者血浆P1不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_12)) { if (model.Part1.CB3_12 == "cb3_12") { ret += "患者血浆P2满意,"; } else { ret += "患者血浆P2不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_13)) { if (model.Part1.CB3_13 == "cb3_13") { ret += "患者血浆P3满意,"; } else { ret += "患者血浆P3不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_14)) { if (model.Part1.CB3_14 == "cb3_14") { ret += "患者细胞P1满意,"; } else { ret += "患者细胞P1不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_15)) { if (model.Part1.CB3_15 == "cb3_15") { ret += "患者细胞P2满意,"; } else { ret += "患者细胞P2不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_16)) { if (model.Part1.CB3_16 == "cb3_16") { ret += "患者细胞P3满意,"; } else { ret += "患者细胞P3不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_17)) { if (model.Part1.CB3_17 == "cb3_17") { ret += "献血者细胞Dw满意,"; } else { ret += "献血者细胞Dw不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_18)) { if (model.Part1.CB3_18 == "cb3_18") { ret += "献血者细胞Dy满意,"; } else { ret += "献血者细胞Dy不满意,"; } } if (!string.IsNullOrEmpty(model.Part1.CB3_19)) { if (model.Part1.CB3_19 == "cb3_19") { ret += "献血者细胞Dz满意,"; } else { ret += "献血者细胞Dz不满意,"; } } } #endregion #region 题目5 实验方法 if (key == "laboratoryMethod" && model.Part2!=null) { string abo = "ABO定型:"; string D = "D定型:"; string ktsx = "抗体筛选:"; string ktjd = "抗体鉴定:"; string jxpx = "交叉配血:"; #region ABO定型方法 if (!string.IsNullOrEmpty(model.Part2.CB5_11)) { if (model.Part2.CB5_11.ToLower() == "true") { abo += "盐水试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_21)) { if (model.Part2.CB5_21.ToLower() == "true") { abo += "抗人球试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_31)) { if (model.Part2.CB5_31.ToLower() == "true") { abo += "聚凝胺,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_41)) { if (model.Part2.CB5_41.ToLower() == "true") { abo += "柱凝集,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_51)) { if (model.Part2.CB5_51.ToLower() == "true") { abo += "酶法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_61)) { if (model.Part2.CB5_61.ToLower() == "true") { abo += "微量板法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_71)) { if (model.Part2.CB5_71.ToLower() == "true") { abo += "其他,"; } } #endregion #region D定型 if (!string.IsNullOrEmpty(model.Part2.CB5_12)) { if (model.Part2.CB5_12.ToLower() == "true") { D += "盐水试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_22)) { if (model.Part2.CB5_22.ToLower() == "true") { D += "抗人球试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_32)) { if (model.Part2.CB5_32.ToLower() == "true") { D += "聚凝胺,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_42)) { if (model.Part2.CB5_42.ToLower() == "true") { D += "柱凝集,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_52)) { if (model.Part2.CB5_52.ToLower() == "true") { D += "酶法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_62)) { if (model.Part2.CB5_62.ToLower() == "true") { D += "微量板法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_72)) { if (model.Part2.CB5_72.ToLower() == "true") { D += "其他,"; } } #endregion #region 抗体筛选 if (!string.IsNullOrEmpty(model.Part2.CB5_13)) { if (model.Part2.CB5_13.ToLower() == "true") { ktsx += "盐水试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_23)) { if (model.Part2.CB5_23.ToLower() == "true") { ktsx += "抗人球试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_33)) { if (model.Part2.CB5_33.ToLower() == "true") { ktsx += "聚凝胺,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_43)) { if (model.Part2.CB5_43.ToLower() == "true") { ktsx += "柱凝集,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_53)) { if (model.Part2.CB5_53.ToLower() == "true") { ktsx += "酶法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_63)) { if (model.Part2.CB5_63.ToLower() == "true") { ktsx += "微量板法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_73)) { if (model.Part2.CB5_73.ToLower() == "true") { ktsx += "其他,"; } } #endregion #region 抗体鉴定 if (!string.IsNullOrEmpty(model.Part2.CB5_14)) { if (model.Part2.CB5_14.ToLower() == "true") { ktjd += "盐水试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_24)) { if (model.Part2.CB5_24.ToLower() == "true") { ktjd += "抗人球试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_34)) { if (model.Part2.CB5_34.ToLower() == "true") { ktjd += "聚凝胺,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_44)) { if (model.Part2.CB5_44.ToLower() == "true") { ktjd += "柱凝集,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_54)) { if (model.Part2.CB5_54.ToLower() == "true") { ktjd += "酶法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_64)) { if (model.Part2.CB5_64.ToLower() == "true") { ktjd += "微量板法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_74)) { if (model.Part2.CB5_74.ToLower() == "true") { ktjd += "其他,"; } } #endregion #region 交叉配血 if (!string.IsNullOrEmpty(model.Part2.CB5_15)) { if (model.Part2.CB5_15.ToLower() == "true") { jxpx += "盐水试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_25)) { if (model.Part2.CB5_25.ToLower() == "true") { jxpx += "抗人球试管,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_35)) { if (model.Part2.CB5_35.ToLower() == "true") { jxpx += "聚凝胺,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_45)) { if (model.Part2.CB5_45.ToLower() == "true") { jxpx += "柱凝集,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_55)) { if (model.Part2.CB5_55.ToLower() == "true") { jxpx += "酶法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_65)) { if (model.Part2.CB5_65.ToLower() == "true") { jxpx += "微量板法,"; } } if (!string.IsNullOrEmpty(model.Part2.CB5_75)) { if (model.Part2.CB5_75.ToLower() == "true") { jxpx += "其他,"; } } #endregion ret = abo + D + ktsx + ktjd + jxpx; } #endregion #region 题目6试剂说明 if (key == "Reagents" && model.Part2!=null) { if (!string.IsNullOrEmpty(model.Part2.Factory1)) { ret += "抗-A,抗B:" + model.Part2.Factory1 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory2)) { ret += "抗-AB:" + model.Part2.Factory2 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory3)) { ret += "抗-D(1):" + model.Part2.Factory3 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory4)) { ret += "抗-D(2):" + model.Part2.Factory4 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory5)) { ret += "聚凝胺:" + model.Part2.Factory5 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory6)) { ret += "多特异性抗人球:" + model.Part2.Factory6 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory7)) { ret += "抗IgG:" + model.Part2.Factory7 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory8)) { ret += "柱凝集1:" + model.Part2.Factory8 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory9)) { ret += "柱凝集2:" + model.Part2.Factory9 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory10)) { ret += "其他:" + model.Part2.Factory10 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory11)) { ret += "筛选细胞:" + model.Part2.Factory11 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory12)) { ret += "谱细胞1:" + model.Part2.Factory12 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory13)) { ret += "谱细胞2:" + model.Part2.Factory13 + ","; } if (!string.IsNullOrEmpty(model.Part2.Factory14)) { ret += "酶处理谱细胞:" + model.Part2.Factory14 + ","; } } #endregion #region 题目11试剂红细胞数量 if (key == "CellNumber" && model.Part5!=null) { if (!string.IsNullOrEmpty(model.Part5.CB11_11)) { if (model.Part5.CB11_11.ToLower() == "cb11_11") { ret += "患者1:<=14,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_12)) { if (model.Part5.CB11_12.ToLower() == "cb11_12") { ret += "患者1:15-25,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_13)) { if (model.Part5.CB11_13.ToLower() == "cb11_13") { ret += "患者1:>25,"; } } // if (!string.IsNullOrEmpty(model.Part5.CB11_21)) { if (model.Part5.CB11_21.ToLower() == "cb11_21") { ret += "患者2:<=14,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_22)) { if (model.Part5.CB11_22.ToLower() == "cb11_22") { ret += "患者2:15-25,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_23)) { if (model.Part5.CB11_23.ToLower() == "cb11_23") { ret += "患者2:>25,"; } } // if (!string.IsNullOrEmpty(model.Part5.CB11_31)) { if (model.Part5.CB11_31.ToLower() == "cb11_31") { ret += "患者3:<=14,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_32)) { if (model.Part5.CB11_32.ToLower() == "cb11_32") { ret += "患者3:15-25,"; } } if (!string.IsNullOrEmpty(model.Part5.CB11_33)) { if (model.Part5.CB11_33.ToLower() == "cb11_33") { ret += "患者3:>25,"; } } } #endregion return ret; } } }