Example #1
0
        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);
            }
        }
Example #2
0
        private bool processBIORADFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber)
        {
            isRightPositionNumber = true;
            string formatTitle   = "Well,Fluor,Target,Content,Sample,Cq,Starting Quantity (SQ)";
            bool   isRightFormat = false;

            System.Collections.Generic.Dictionary <string, BIORADPCRColumnData> dataList = new System.Collections.Generic.Dictionary <string, BIORADPCRColumnData>();

            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() < 6)
                            {
                                break;
                            }
                            BIORADPCRColumnData bioData = new BIORADPCRColumnData();
                            bioData.Well       = values[0];
                            bioData.Fluor      = values[1];
                            bioData.Cq         = values[5];
                            bioData.XmlContent = "<Well>" + values[0] + "</Well><Fluor>" + values[1] + "</Fluor><Cq>" + values[5] + "</Cq>";

                            if (!dataList.ContainsKey(bioData.Well))
                            {
                                dataList.Add(bioData.Well, bioData);
                            }
                            else
                            {
                                BIORADPCRColumnData _bioData = (BIORADPCRColumnData)dataList[bioData.Well];
                                if (_bioData.DataList == null)
                                {
                                    _bioData.DataList = new List <PCRColumnData>();
                                    _bioData.DataList.Add(bioData);
                                }
                                else
                                {
                                    _bioData.DataList.Add(bioData);
                                }
                            }
                        }

                        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 (BIORADPCRColumnData bioData in dataList.Values)
            {
                PCRTestResult info = new PCRTestResult();
                info.ItemID     = WanTaiObjectService.NewSequentialGuid();
                info.RotationID = rotationId;
                info.Position   = controller.ChangeCharacterToPositionNumber(bioData.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(bioData, row["TestName"].ToString(), isSingle, tubeType);
                }

                info.ExperimentID = currentExperimentId;
                if (plate.BarCode != null)
                {
                    info.BarCode = plate.BarCode;
                }

                info.PlateID = plate.PlateID;
                string xmlContent = bioData.XmlContent;
                if (bioData.DataList != null && bioData.DataList.Count > 0)
                {
                    foreach (BIORADPCRColumnData data in bioData.DataList)
                    {
                        xmlContent = xmlContent + data.XmlContent;
                    }
                }
                info.PCRContent = "<PCRContent>" + xmlContent + "</PCRContent>";
                pcrResultList.Add(info);
            }

            return(isRightFormat);
        }