예제 #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);
            }
        }
예제 #2
0
        private bool processStratageneFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber)
        {
            isRightPositionNumber = true;
            OleDbConnectionStringBuilder connectionStringBuilder = new OleDbConnectionStringBuilder();

            connectionStringBuilder.Provider   = "Microsoft.Jet.OLEDB.4.0";
            connectionStringBuilder.DataSource = fileName;
            connectionStringBuilder.Add("Mode", "Read");
            connectionStringBuilder.Add("Extended Properties", "Excel 8.0;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text");
            bool isRightFormat = false;
            bool hasWellColumn = false;
            bool hasDyeColumn  = false;
            bool hasCtColumn   = false;

            using (OleDbConnection con = new OleDbConnection(connectionStringBuilder.ToString()))
            {
                con.Open();
                DataTable dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                string    Sheet1   = dtSchema.Rows[0].Field <string>("TABLE_NAME");

                DataTable sheetColumns = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, Sheet1, null });
                foreach (DataRow row in sheetColumns.Rows)
                {
                    string strColumnName = row["COLUMN_NAME"].ToString();
                    if (strColumnName == "Well")
                    {
                        hasWellColumn = true;
                    }
                    else if (strColumnName == "Dye")
                    {
                        hasDyeColumn = true;
                    }
                    if (strColumnName == "Ct (dR)")
                    {
                        hasCtColumn = true;
                    }
                }

                if (hasWellColumn && hasDyeColumn && hasCtColumn)
                {
                    isRightFormat = true;
                }

                if (!isRightFormat)
                {
                    return(isRightFormat);
                }

                OleDbDataAdapter da = new OleDbDataAdapter("select [Well],[Dye],[Ct (dR)] from [" + Sheet1 + "]", con);
                DataTable        dt = new DataTable();
                da.Fill(dt);
                Dictionary <int, DataRow> dc = controller.GetPCRPositionsByPlateID(plate.PlateID, currentExperimentId);
                System.Collections.Generic.Dictionary <string, StratagenePCRColumnData> dataList = new System.Collections.Generic.Dictionary <string, StratagenePCRColumnData>();

                foreach (DataRow row in dt.Rows)
                {
                    StratagenePCRColumnData sData = new StratagenePCRColumnData()
                    {
                        Well = row[0].ToString(), Dye = row[1].ToString(), Ct = row[2].ToString()
                    };
                    sData.XmlContent = "<Well>" + sData.Well + "</Well><Dye>" + sData.Dye + "</Dye><Ct>" + sData.Ct + "</Ct>";
                    if (!dataList.ContainsKey(sData.Well))
                    {
                        dataList.Add(sData.Well, sData);
                    }
                    else
                    {
                        StratagenePCRColumnData _sData = (StratagenePCRColumnData)dataList[sData.Well];
                        if (_sData.DataList == null)
                        {
                            _sData.DataList = new List <PCRColumnData>();
                            _sData.DataList.Add(sData);
                        }
                        else
                        {
                            _sData.DataList.Add(sData);
                        }
                    }
                }

                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 (StratagenePCRColumnData sData in dataList.Values)
                {
                    PCRTestResult info = new PCRTestResult();
                    info.ItemID     = WanTaiObjectService.NewSequentialGuid();
                    info.RotationID = rotationId;
                    info.Position   = controller.ChangeCharacterToPositionNumber(sData.Well);
                    info.CreateTime = DateTime.Now;

                    //calculate
                    if (dc.ContainsKey(info.Position))
                    {
                        DataRow  dcrow    = dc[info.Position];
                        bool     isSingle = (int)dcrow["TubeNumber"] == 1 ? true : false;
                        Tubetype tubeType = (Tubetype)((short)dcrow["TubeType"]);
                        info.Result = checkPCRResult(sData, dcrow["TestName"].ToString(), isSingle, tubeType);
                    }

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

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

            return(isRightFormat);
        }