private string checkPCRResult(PCRColumnData data, string testItemName, bool isSingle, Tubetype tubeType) { string rox = null; string hex = null; string fam = null; if (data is ABIPCRColumnData) { ABIPCRColumnData aiData = (ABIPCRColumnData)data; if ("ROX" == aiData.Detector) { rox = aiData.Ct; } else if ("FAM" == aiData.Detector) { fam = aiData.Ct; } else if ("HEX" == aiData.Detector) { hex = aiData.Ct; } if (aiData.DataList != null) { foreach (ABIPCRColumnData subAiData in aiData.DataList) { if ("ROX" == subAiData.Detector) { rox = subAiData.Ct; } else if ("FAM" == subAiData.Detector) { fam = subAiData.Ct; } else if ("HEX" == subAiData.Detector) { hex = subAiData.Ct; } } } } else if (data is BIORADPCRColumnData) { BIORADPCRColumnData bioData = (BIORADPCRColumnData)data; if ("FAM" == bioData.Fluor) { fam = bioData.Cq; } else if ("HEX" == bioData.Fluor) { hex = bioData.Cq; } else if ("ROX" == bioData.Fluor) { rox = bioData.Cq; } if (bioData.DataList != null) { foreach (BIORADPCRColumnData subBioData in bioData.DataList) { if ("FAM" == subBioData.Fluor) { fam = subBioData.Cq; } else if ("HEX" == subBioData.Fluor) { hex = subBioData.Cq; } else if ("ROX" == subBioData.Fluor) { rox = subBioData.Cq; } } } } else if (data is StratagenePCRColumnData) { StratagenePCRColumnData sData = (StratagenePCRColumnData)data; if ("FAM" == sData.Dye) { fam = sData.Ct; } else if ("HEX" == sData.Dye) { hex = sData.Ct; } else if ("ROX" == sData.Dye) { rox = sData.Ct; } if (sData.DataList != null) { foreach (StratagenePCRColumnData subSata in sData.DataList) { if ("FAM" == subSata.Dye) { fam = subSata.Ct; } else if ("HEX" == subSata.Dye) { hex = subSata.Ct; } else if ("ROX" == subSata.Dye) { rox = subSata.Ct; } } } } if (!string.IsNullOrEmpty(fam) && (fam == "Undetermined" || fam == "No Ct" || fam == "N/A")) { fam = "45"; } if (!string.IsNullOrEmpty(hex) && (hex == "Undetermined" || hex == "No Ct" || hex == "N/A")) { hex = "45"; } if (!string.IsNullOrEmpty(rox) && (rox == "Undetermined" || rox == "No Ct" || rox == "N/A")) { rox = "45"; } float outNumber = 0; //阴性对照 if (tubeType == Tubetype.NegativeControl) { if (testItemName == "HBV") { if (!string.IsNullOrEmpty(hex) && float.TryParse(hex, out outNumber)) { float hexNumber = float.Parse(hex); if (hexNumber > 37 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } } return(PCRTest.InvalidResult); } else if (testItemName == "HCV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber > 42 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } } return(PCRTest.InvalidResult); } else if (testItemName == "HIV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber > 42 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } } return(PCRTest.InvalidResult); } else { return(PCRTest.NoResult); } } else if (tubeType == Tubetype.PositiveControl) { if (testItemName == "HBV") { if (!string.IsNullOrEmpty(hex) && float.TryParse(hex, out outNumber)) { float hexNumber = float.Parse(hex); if (hexNumber <= 33 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.PositiveResult); } } return(PCRTest.InvalidResult); } else if (testItemName == "HCV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber <= 37 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.PositiveResult); } } return(PCRTest.InvalidResult); } else if (testItemName == "HIV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber <= 37 && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.PositiveResult); } } return(PCRTest.InvalidResult); } else { return(PCRTest.NoResult); } } float HBVValue = 0; float HCVValue = 0; float HIVValue = 0; if (isSingle) { HBVValue = 35; HCVValue = 42; HIVValue = 40; } else { HBVValue = 37; HCVValue = 42; HIVValue = 42; } if (testItemName == "HBV") { if (!string.IsNullOrEmpty(hex) && float.TryParse(hex, out outNumber)) { float hexNumber = float.Parse(hex); if (hexNumber > HBVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } else if (hexNumber <= HBVValue) { return(PCRTest.PositiveResult); } else if (hexNumber > HBVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) >= 36) { return(PCRTest.InvalidResult); } else { return(PCRTest.NoResult); } } else { return(PCRTest.NoResult); } } else if (testItemName == "HCV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber > HCVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } else if (famNumber <= HCVValue) { return(PCRTest.PositiveResult); } else if (famNumber > HCVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) >= 36) { return(PCRTest.InvalidResult); } else { return(PCRTest.NoResult); } } else { return(PCRTest.NoResult); } } else if (testItemName == "HIV") { if (!string.IsNullOrEmpty(fam) && float.TryParse(fam, out outNumber)) { float famNumber = float.Parse(fam); if (famNumber > HIVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) < 36) { return(PCRTest.NegativeResult); } else if (famNumber <= HIVValue) { return(PCRTest.PositiveResult); } else if (famNumber > HIVValue && !string.IsNullOrEmpty(rox) && float.TryParse(rox, out outNumber) && float.Parse(rox) >= 36) { return(PCRTest.InvalidResult); } else { return(PCRTest.NoResult); } } else { return(PCRTest.NoResult); } } else { return(PCRTest.NoResult); } }
private bool processABIFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber) { isRightPositionNumber = true; string formatTitle = "Well,Sample Name,Detector,Task,Ct,StdDev Ct,Qty,Mean Qty,StdDev Qty,Filtered,Tm"; bool isRightFormat = false; ABIPCRColumnData previousMainAbiData = null; List <ABIPCRColumnData> dataList = new List <ABIPCRColumnData>(); using (FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string content = reader.ReadLine(); if (isRightFormat) { string[] values = content.Split(','); if (values.Count() < 5) { break; } ABIPCRColumnData abiData = new ABIPCRColumnData(); abiData.Well = values[0]; abiData.Detector = values[2]; abiData.Ct = values[4]; abiData.XmlContent = "<Well>" + values[0] + "</Well><Detector>" + values[2] + "</Detector><Ct>" + values[4] + "</Ct>"; if (string.IsNullOrEmpty(abiData.Well)) { if (previousMainAbiData.DataList == null) { previousMainAbiData.DataList = new List <PCRColumnData>(); } previousMainAbiData.DataList.Add(abiData); } else { previousMainAbiData = abiData; dataList.Add(previousMainAbiData); } } if (!isRightFormat && content.StartsWith(formatTitle)) { isRightFormat = true; } } } } if (!isRightFormat) { return(isRightFormat); } Dictionary <int, DataRow> dc = controller.GetPCRPositionsByPlateID(plate.PlateID, currentExperimentId); if (dc.Count != dataList.Count) { isRightPositionNumber = false; if (!isRightPositionNumber) { MessageBoxResult selectResult = MessageBox.Show("PCR仪检测结果和混样数不一致,请检查操作是否正确?“是”将按现有规则导入", "系统提示", MessageBoxButton.YesNo); if (selectResult == MessageBoxResult.No) { return(isRightFormat); } else { isRightPositionNumber = true; } } } foreach (ABIPCRColumnData abiData in dataList) { PCRTestResult info = new PCRTestResult(); info.ItemID = WanTaiObjectService.NewSequentialGuid(); info.RotationID = rotationId; info.Position = controller.ChangeCharacterToPositionNumber(abiData.Well); info.CreateTime = DateTime.Now; //calculate if (dc.ContainsKey(info.Position)) { DataRow row = dc[info.Position]; bool isSingle = (int)row["TubeNumber"] == 1 ? true : false; Tubetype tubeType = (Tubetype)((short)row["TubeType"]); info.Result = checkPCRResult(abiData, row["TestName"].ToString(), isSingle, tubeType); } info.ExperimentID = currentExperimentId; if (plate.BarCode != null) { info.BarCode = plate.BarCode; } info.PlateID = plate.PlateID; string xmlContent = abiData.XmlContent; if (abiData.DataList != null) { foreach (ABIPCRColumnData data in abiData.DataList) { xmlContent = xmlContent + data.XmlContent; } } info.PCRContent = "<PCRContent>" + xmlContent + "</PCRContent>"; pcrResultList.Add(info); } return(isRightFormat); }