Exemplo n.º 1
0
        private void AddSpecimensToCollection(int colId, string specimenIds, bool isNewCollection)
        {
            if (!string.IsNullOrEmpty(specimenIds))
            {
                char[]   delimiters = { ',' };
                string[] ids        = specimenIds.Split(new char[] { ',' });
                this.numOfSpecimensAdded = ids.GetLength(0);

                //get each specimen by id and set its collectionId
                foreach (string sId in ids)
                {
                    Specimen biz = new Specimen();
                    Specimen_SpecimenCollections bizcol = new Specimen_SpecimenCollections();

                    biz.Get(int.Parse(sId));
                    //biz[Specimen.CollectionId] = colId;
                    //biz[Specimen.SpecimenStatus] = "Unavailable: Reserved"; //bug fix
                    //biz.Save();

                    if (!SpecimenCollectionExists(int.Parse(sId), colId))
                    {
                        bizcol[Specimen_SpecimenCollections.SpecimenId]   = sId;
                        bizcol[Specimen_SpecimenCollections.CollectionId] = colId;
                        bizcol.Save();
                    }
                    BindSpecimensGrid();
                }

                LoadExistingCollection(colId, isNewCollection);
            }
        }
Exemplo n.º 2
0
        protected Boolean SpecimenCollectionExists(int specimenId, int collectionId)
        {
            System.Collections.Generic.Dictionary <string, object> check = new System.Collections.Generic.Dictionary <string, object>();
            check.Add(Specimen_SpecimenCollections.SpecimenId, specimenId);
            check.Add(Specimen_SpecimenCollections.CollectionId, collectionId);
            bool exists = Specimen_SpecimenCollections.GetByFields <Specimen_SpecimenCollections>(check).Count() > 0;

            return(exists);
        }
Exemplo n.º 3
0
        protected void RemoveFromCollection(object sender, CommandEventArgs e)
        {
            int priKey = int.Parse(e.CommandArgument.ToString());

            Specimen biz = new Specimen();

            biz.Get(priKey);
            //biz[Specimen.CollectionId] = DBNull.Value;
            //biz[Specimen.SpecimenStatus] = "Available";
            //biz.Save();

            SpecimenManagerDa da = new SpecimenManagerDa();
            int specColId        = da.GetPrimKeybySpecId(priKey);
            Specimen_SpecimenCollections bizcol = new Specimen_SpecimenCollections();

            bizcol.Delete(specColId);

            BindSpecimensGrid();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Special logic for removing specimen and rolling back the status
        /// </summary>
        /// <param name="specimenCollectionId"></param>
        private void RemoveSpecimenFromCollection(int specimenCollectionId)
        {
            Specimen_SpecimenCollections biz = new Specimen_SpecimenCollections();

            biz.Get(specimenCollectionId);
            if (!biz.IsEmpty)
            {
                int      specimenId = (int)biz[Specimen_SpecimenCollections.SpecimenId];
                Specimen specimen   = new Specimen();
                specimen.Get(specimenId);
                string currentStatus  = specimen[Specimen.SpecimenStatus].ToString();
                string rollbackStatus = "";
                switch (currentStatus)
                {
                case "In Transit to Pathology":
                    rollbackStatus = "Collected";
                    break;

                case "In Transit to Sequencing":
                    rollbackStatus = "Pathology Review Completed";
                    break;

                case "In Transit to Analysis":
                    rollbackStatus = "Sequenced";
                    break;

                case "In Transit to cBIO Portal":
                    rollbackStatus = "Analysis Complete";
                    break;

                default:
                    break;
                }
                // rollback status
                if (!string.IsNullOrEmpty(currentStatus) && !string.IsNullOrEmpty(rollbackStatus))
                {
                    specimen[Specimen.SpecimenStatus] = rollbackStatus;
                    specimen.Save();
                }
                biz.Delete(specimenCollectionId);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="collectionId"></param>
        /// <returns></returns>
        private IEnumerable <int> SaveSpecimens(int collectionId)
        {
            List <int> specimensInCollection = new List <int>();

            foreach (GridViewRow row in SpecimensGrid.Rows)
            {
                int      specimenId           = (int)SpecimensGrid.DataKeys[row.RowIndex][Specimen.SpecimenId];
                string   specimenCollectionId = SpecimensGrid.DataKeys[row.RowIndex][Specimen_SpecimenCollections.SpecimenCollectionId] + "";
                CheckBox cb = row.FindControl("IncludeSpecimenCheck") as CheckBox;
                // add new
                if (cb.Checked && string.IsNullOrEmpty(specimenCollectionId))
                {
                    Specimen_SpecimenCollections newSpecimenCollection = new Specimen_SpecimenCollections();
                    newSpecimenCollection[Specimen_SpecimenCollections.SpecimenId]   = specimenId;
                    newSpecimenCollection[Specimen_SpecimenCollections.CollectionId] = collectionId;
                    newSpecimenCollection.Save();

                    // add entry
                    specimensInCollection.Add(specimenId);
                }
                // remove existing
                else if (!string.IsNullOrEmpty(specimenCollectionId))
                {
                    if (!cb.Checked)
                    {
                        int priKey = int.Parse(specimenCollectionId);
                        RemoveSpecimenFromCollection(priKey);
                    }
                    else
                    {
                        // add entry
                        specimensInCollection.Add(specimenId);
                    }
                }
            }
            return(specimensInCollection);
        }