private void ConfirmCurrentSample()
        {
            FlowTube currentSample = GetCurrentSample();

            currentSample.Confirmed = true;
            this.Refresh();
            int currentIndex = GetCurrentSampleLinearIndex();

            if (currentIndex < this.gridSamples.Rows.Count - 1)
            {
                SetCurrentSampleIndex(currentIndex + 1);
                ClearError();
            }
            else
            if (AllSamplesConfirmed())
            {
                CurrentStatus = Status.ManifestComplete;
                gridSamples.Selected.Rows.Clear();
                ShowMessage("All tubes scanned correctly.  Rescan last tube to complete/submit manifest.");
            }
            Sound.PlayWaveResource("Match.wav");
        }
Beispiel #2
0
    public BindingList <FlowTube> GetFlowTubes(int flow_tube_list_id)
    {
        BindingList <FlowTube> output = new BindingList <FlowTube>();

        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
            using (SqlCommand command = new SqlCommand
            {
                Connection = connection,
                CommandText = "GetFlowTubes",
                CommandType = CommandType.StoredProcedure
            })
            {
                command.Parameters.AddWithValue("@flow_tube_list_id", flow_tube_list_id);
                DataSet        dataSet = new DataSet();
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                connection.Open();
                adapter.Fill(dataSet);
                connection.Close();


                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    FlowTube tube = new FlowTube();
                    tube.AccessionNumber = row["accession_number"].ToString();
                    tube.SeqNbr          = Convert.ToInt32(row["sequence_number"]);
                    if (this.LimitTubeCount && tube.SeqNbr > this.LimitTubeMax)
                    {
                        break;
                    }
                    tube.TubeLabel = row["label"].ToString();
                    tube.MRN       = row["MRN"].ToString();
                    tube.Name      = row["name"].ToString();
                    output.Add(tube);
                }
            }
        return(output);
    }
        private void ConfirmTube(string barcode)
        {
            if (CurrentStatus == Status.ErrorState)
            {
                ShowError("Error state - scanning is disabled until manifest is cleared");
                return;
            }
            CurrencyManager cm            = (CurrencyManager)this.BindingContext[gridSamples.DataSource];
            FlowTube        currentSample = GetCurrentSample();

            if (AllSamplesConfirmed() && currentSample != null && barcode == currentSample.AccessionNumberUnformatted)
            {
                if (this.SubmitManifest != null)
                {
                    this.SubmitManifest();
                }
                return;
            }

            if (AllSamplesConfirmed())
            {
                CurrentStatus = Status.ManifestComplete;
                ShowError("All samples have been confirmed.  You can scan the last sample again to complete the manifest.");
                return;
            }

            if (currentSample != null && barcode == currentSample.AccessionNumberUnformatted)
            {
                ConfirmCurrentSample();
            }
            else
            {
                ShowError("Out of order scan. Review field & samples, and clear/restart manifest generation", true);
            }
            return;
        }
    public static BindingList <FlowTube> Parse(string filename)
    {
        int       failureCount  = 0;
        int       sleepTime     = 2000;
        bool      success       = false;
        Exception lastException = null;
        XDocument x             = null;

        do
        {
            try
            {
                x       = XDocument.Load(filename);
                success = true;
            }
            catch (Exception ex)
            {
                lastException = ex;
                System.Threading.Thread.Sleep(sleepTime);
                failureCount++;
            }
        }while (!success && failureCount < 10);


        if (!success)
        {
            throw lastException;
        }

        XNamespace ns      = x.Root.GetDefaultNamespace();
        var        persons = from data in x.Descendants(ns + "Person")
                             select new
        {
            PersonID = (string)data.Element(ns + "PersonId"),
            MRN      = (string)data.Element(ns + "MRN"),
            Name     = (string)data.Element(ns + "NameFullFormatted"),
        };

        foreach (var p in persons)
        {
            System.Diagnostics.Debug.WriteLine(p.ToString());
        }

        var Persons = persons.ToDictionary(o => o.PersonID, o => o);

        var containers = from data in x.Descendants(ns + "Container")
                         select new
        {
            ContainerId     = (string)data.Element(ns + "ContainerId"),
            ContainerSuffix = (string)data.Element(ns + "ContainerSuffix"),
            ContainerAccessionNumberFormatted   = (string)data.Element(ns + "ContainerAccessionNumber").Element(ns + "Formatted"),
            ContainerAccessionNumberUnformatted = (string)data.Element(ns + "ContainerAccessionNumber").Element(ns + "Unformatted"),
            TubeLabel = (string)data.Element(ns + "SpecimenType").Element(ns + "Display"),
        };

        var Containers = containers.ToDictionary(o => o.ContainerId, o => o);

        foreach (var c in containers)
        {
            System.Diagnostics.Debug.WriteLine(c.ToString());
        }

        var tubes = from data in x.Descendants(ns + "Cell")
                    select new
        {
            SeqNbr      = (int)data.Element(ns + "SeqNbr"),
            BatchItemId = (string)data.Element(ns + "BatchItemId"),
        };

        foreach (var t in tubes)
        {
            System.Diagnostics.Debug.WriteLine(t.ToString());
        }

        var Tubes = tubes.ToDictionary(o => o.SeqNbr, o => o);

        var batches = from data in x.Descendants(ns + "BatchItem")
                      select new
        {
            BatchItemId = (string)data.Element(ns + "BatchItemId"),
            ContainerId = (string)data.Element(ns + "ContainerId"),
            OrderId     = (string)data.Element(ns + "OrderId"),
        };

        foreach (var b in batches)
        {
            System.Diagnostics.Debug.WriteLine(b.ToString());
        }

        var Batches = batches.ToDictionary(o => o.BatchItemId, o => o);

        var orders = from data in x.Descendants(ns + "Order")
                     select new
        {
            OrderId  = (string)data.Element(ns + "OrderId"),
            PersonId = (string)data.Element(ns + "PersonId"),
        };

        foreach (var o in orders)
        {
            System.Diagnostics.Debug.WriteLine(o.ToString());
        }

        var Orders = orders.ToDictionary(o => o.OrderId, o => o);

        List <int> sequenceNumbers = Tubes.Keys.ToList();

        sequenceNumbers.Sort();
        BindingList <FlowTube> items = new BindingList <FlowTube>();


        foreach (int sequenceNumber in sequenceNumbers)
        {
            FlowTube item = new FlowTube();
            item.SeqNbr          = sequenceNumber;
            item.MRN             = Persons[Orders[Batches[Tubes[sequenceNumber].BatchItemId].OrderId].PersonId].MRN;
            item.Name            = Persons[Orders[Batches[Tubes[sequenceNumber].BatchItemId].OrderId].PersonId].Name;
            item.AccessionNumber = Containers[Batches[Tubes[sequenceNumber].BatchItemId].ContainerId].ContainerAccessionNumberFormatted +
                                   Containers[Batches[Tubes[sequenceNumber].BatchItemId].ContainerId].ContainerSuffix;
            item.TubeLabel = Containers[Batches[Tubes[sequenceNumber].BatchItemId].ContainerId].TubeLabel;
            items.Add(item);
        }

        return(items);
    }