예제 #1
0
        //private void ListUnboxedSpecimens(int colId)
        //{
        //    SpecimenManagerDa da = new SpecimenManagerDa();
        //    DataTable dt = da.GetUnboxedSpecimensByCollectionId(colId);
        //    this.unboxedSpecList.DataSource = dt.DefaultView;
        //    this.unboxedSpecList.DataBind();
        //}

        private void BindOriginSelectBoxes()
        {
            if (QueryBoxId > 0)
            {
                SpecimenManagerDa da             = new SpecimenManagerDa();
                DataSet           resultsDataSet = da.GetBoxAndAncestors(QueryBoxId);

                SpecimenBox box = new SpecimenBox();
                box.Get(QueryBoxId);

                DataTable boxesDT = resultsDataSet.Tables[0];
                Boxes.DataSource = boxesDT;
                Boxes.DataBind();
                Boxes.Value = box[SpecimenBox.BoxId].ToString();

                DataTable containersDT = resultsDataSet.Tables[1];
                Containers.DataSource = containersDT;
                Containers.DataBind();
                Containers.Value = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString();

                DataTable storagesDT = resultsDataSet.Tables[2];
                Storages.DataSource = storagesDT;
                Storages.DataBind();
                Storages.Value = containersDT.Rows[0][SpecimenContainer.StorageId].ToString();

                string siteId = resultsDataSet.Tables[3].Rows[0][SpecimenSite.SiteId].ToString();
                Sites.Value = siteId;
            }
        }
예제 #2
0
        private static string[] GetAutoSpecimenIds(int ptProtocolId, string studyId, string type, string visit, int count)
        {
            int startSeqNum        = 1;
            SpecimenManagerDa da   = new SpecimenManagerDa();
            var specimens          = da.GetSpecimenReport(ptProtocolId, null, type);
            var allSpecimentRefNum = specimens.AsEnumerable().Select(r => r[Specimen.SpecimenReferenceNumber].ToString()).Distinct();
            int maxSeqNum          = allSpecimentRefNum.Count();

            // find start
            for (int seqNum = 1; seqNum <= maxSeqNum; seqNum++)
            {
                string calculatedStudyId = GetAutoSpecimenNumber(studyId, type, visit, seqNum + "");
                // if # exists, start after
                if (allSpecimentRefNum.Contains(calculatedStudyId))
                {
                    startSeqNum++;
                }
            }
            if (!string.IsNullOrEmpty(visit) && (type == PatientSpecimenBasePage.QUERY_BLOOD || type == PatientSpecimenBasePage.QUERY_TISSUE))
            {
                string[] results = new string[count];
                for (int i = 0, seqNum = startSeqNum; i < count; i++, seqNum++)
                {
                    results[i] = GetAutoSpecimenNumber(studyId, type, visit, seqNum + "");
                }
                return(results);
            }
            else
            {
                return(new string[count]);
            }
        }
예제 #3
0
        private void DetermineRequestStatus()
        {
            if (this.RequestId > 0)
            {
                SpecimenManagerDa da = new SpecimenManagerDa();
                DataTable         dt = new DataTable();
                dt = da.GetDistributionByRequestId(this.RequestId);

                if (dt.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["DispatchedDate"].ToString()))
                    {
                        if (!string.IsNullOrEmpty(dt.Rows[0]["ReceivedDate"].ToString()))
                        {
                            this._stage = 3; //received
                        }
                        else
                        {
                            this._stage = 2; //in transit ... dispatched
                        }
                    }
                }
                else
                {
                    this._stage = 1; //ready for dispatch
                }
            }
        }
예제 #4
0
        private void LoadCollectionsInTransfer()
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = da.GetCollectionsByRequestId(QueryTransferId);

            RptCollections.DataSource = dt.DefaultView;
            RptCollections.DataBind();
        }
예제 #5
0
        private void InitializeAvailableCollectionSelectBox()
        {
            SpecimenManagerDa da = new SpecimenManagerDa();

            this.AvailableCollectionSelectBox.DataSource     = da.GetAvailableCollections();
            this.AvailableCollectionSelectBox.DataTextField  = "CollectionName";
            this.AvailableCollectionSelectBox.DataValueField = "CollectionId";
            this.AvailableCollectionSelectBox.DataBind();
        }
예제 #6
0
        private void BindSpecimensGrid()
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            string            _identifierType = CaisisConfiguration.GetWebConfigValue("SpecimenModuleDefaultId");
            DataTable         dt = da.GetSpecimensInCollectionForPrint(colId, _identifierType);

            this.totalSpecimens.Text = dt.Rows.Count.ToString();

            this.SpecimenGridView.DataSource = dt;
            this.SpecimenGridView.DataBind();
        }
예제 #7
0
        private void RunSearch()
        {
            // need validation here too
            // because date is validated in the front-end but only when they leave the control
            if (ValidateDates())
            {
                this.errorMessage.Visible = false;

                DataTable         dt = null;
                SpecimenManagerDa da = new SpecimenManagerDa();
                dt = da.GetRequests(this.requestName.Value, this.ddlType.Value, this.ddlStatus.Value, this.dateFrom.Value, this.dateTo.Value, this.chkViewAll.Checked);

                this.lblTotalRequests.Text = dt.Rows.Count.ToString() + " transfer request record(s) matched your search criteria";

                string menuItem       = Request.QueryString["menu"];
                string isSingleSearch = Request.QueryString["isSingleResult"];
                string searchTerm     = this.requestName.Value;

                if (dt.Rows.Count == 1 && menuItem != "viewAll" && !string.IsNullOrEmpty(searchTerm))
                {
                    if (dt.Rows[0]["RequestIdentifier"].ToString().Equals(searchTerm))
                    {
                        // NOTE: try so it doesn't redirect when "view all transfer requests" (and there is only 1 entry in db)
                        Response.Redirect("TransferRequest.aspx?requestId=" + dt.Rows[0][SpecimenRequest.SpecimenRequestId].ToString() + "&isSingleResult=true" + BuildQuerySearch());
                    }
                }
                if (dt.Rows.Count > 0)
                {
                    this.noCollectionsRow.Visible = false;
                    this.pnlSearchBody.Visible    = true;
                    this.resultsMsg.Visible       = true;

                    this.rptCollection.DataSource = dt.DefaultView;
                    this.rptCollection.DataBind();
                }
                else
                {
                    this.noCollectionsRow.Visible = true;
                    this.pnlSearchBody.Visible    = true;
                    this.resultsMsg.Visible       = true;

                    this.rptCollection.DataSource = null;
                    this.rptCollection.DataBind();
                }
            }
            else
            {
                ShowMessage(this.errorMessage, "Please enter a valid date.", "red");

                this.errorMessage.Visible  = true;
                this.resultsMsg.Visible    = false;
                this.pnlSearchBody.Visible = false;
            }
        }
예제 #8
0
        override protected void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);
            base.SetTitle(ComponentTitle);

            // retrieve the specimen accessoins for this patient
            SpecimenManagerDa smDa = new SpecimenManagerDa();
            DataSet           smDs = smDa.GetAccessionsByPatientId(this._patientId);

            PathNumWithAccessDate.Style.Add("display", "none");
            NoAccessionsSPAN.Style.Add("display", "none");

            if (smDs.Tables.Count > 0)
            {
                DataView smDv = new DataView(smDs.Tables[0]);
                smDv.RowFilter = SpecimenAccession.PathologyReferenceNumber + " <> '' AND " + SpecimenAccession.PathologyReferenceNumber + " IS NOT NULL ";

                if (smDv.Count > 0)
                {
                    PathNumWithAccessDate.Style.Add("display", "");

                    //populate specimen drop down list
                    ListItem emptyLi = new ListItem("", "");
                    PathNumWithAccessDate.Items.Add(emptyLi);

                    foreach (DataRowView drv in smDv)
                    {
                        string listItemValue = drv[SpecimenAccession.PathologyReferenceNumber].ToString();
                        string listItemText  = String.Empty;
                        if (!String.IsNullOrEmpty(drv[SpecimenAccession.CollectDateText].ToString()))
                        {
                            listItemText = String.Concat(drv[SpecimenAccession.PathologyReferenceNumber].ToString(), " [Date:  ", drv[SpecimenAccession.CollectDateText].ToString(), "]");
                        }
                        else
                        {
                            listItemText = String.Concat(drv[SpecimenAccession.PathologyReferenceNumber].ToString(), " [Date Not Specified]");
                        }

                        ListItem li = new ListItem(listItemText, listItemValue);
                        PathNumWithAccessDate.Items.Add(li);
                    }
                    PathNumWithAccessDate.DataBind();
                }
                else
                {
                    NoAccessionsSPAN.Style.Add("display", "");
                }
            }
            else
            {
                NoAccessionsSPAN.Style.Add("display", "");
            }
        }
예제 #9
0
        protected void SaveDispatchDetails(object sender, ImageClickEventArgs e)
        {
            try
            {
                ControlCollection dispatchControls = Page.FindControl("DispatchDiv").Controls;

                CICHelper.ValidFieldValues(dispatchControls);

                SpecimenDistribution sDistribution = new SpecimenDistribution();

                CICHelper.SetBOValues(dispatchControls, sDistribution, 1);
                sDistribution[SpecimenDistribution.SpecimenRequestId] = this.RequestId;

                SecurityController sc   = new SecurityController();
                string             user = sc.GetUserName();
                sDistribution[SpecimenRequest.UpdatedBy]   = user;
                sDistribution[SpecimenRequest.UpdatedTime] = DateTime.Now;
                sDistribution[SpecimenRequest.EnteredBy]   = user;
                sDistribution[SpecimenRequest.EnteredTime] = DateTime.Now;

                sDistribution.Save();

                //DataTable dt = new DataTable();
                //dt = sDistribution.GetTable();
                //this.DistributionId.Value = dt.Rows[0][SpecimenDistribution.DistributionId].ToString();
                this.DistributionId.Value = sDistribution[SpecimenDistribution.DistributionId].ToString();

                SpecimenManagerDa da = new SpecimenManagerDa();
                da.UpdateRequestStatus(this.RequestId, "In-Transit");
                this.RequestStatus.Value = "In-Transit";

                // update the status for the collections in this transfer (saved to database)
                // to status of "In-Transit"
                DataTable dt = da.GetCollectionsByRequestId(this.RequestId);
                foreach (DataRow dr in dt.Rows)
                {
                    int colId = int.Parse(dr[SpecimenCollection.CollectionId].ToString());
                    UpdateCollectionStatus(colId, "In-Transit");
                }

                DetermineRequestStatus();
                EnableDisableDivsByStatus();

                UpdatePageTitle();
            }
            catch (RequiredValueException rve)
            {
                DispatchDateError.Text = "Please enter a dispatch date.";
            }
        }
예제 #10
0
        private void RunSearch()
        {
            // need validation here too
            // because date is validated in the front-end but only when they leave the control
            if (ValidateDates())
            {
                this.errorMessage.Visible = false;

                DataTable         dt = null;
                SpecimenManagerDa da = new SpecimenManagerDa();
                dt = da.GetCollectionByName(this.collectionName.Value);

                dt = da.GetCollections(this.collectionName.Value, this.ddlType.Value, this.ddlStatus.Value, this.dateFrom.Value, this.dateTo.Value, this.chkViewAll.Checked);
                //}

                this.lblTotalCollections.Text = dt.Rows.Count.ToString() + " collection record(s) matched your search criteria";

                if (dt.Rows.Count == 1)
                {
                    Response.Redirect("Collection.aspx?colId=" + dt.Rows[0][SpecimenCollection.CollectionId].ToString() + "&isSingleResult=true" + BuildQuerySearch());
                }
                if (dt.Rows.Count > 0)
                {
                    this.noCollectionsRow.Visible = false;
                    this.searchBody.Visible       = true;
                    this.resultsMsg.Visible       = true;

                    this.rptCollection.DataSource = dt.DefaultView;
                    this.rptCollection.DataBind();
                }
                else
                {
                    this.noCollectionsRow.Visible = true;
                    this.searchBody.Visible       = true;
                    this.resultsMsg.Visible       = false;

                    this.rptCollection.DataSource = null;
                    this.rptCollection.DataBind();
                }
            }
            else
            {
                ShowMessage(this.errorMessage, "Please enter a valid date.", "red");

                this.errorMessage.Visible = true;
                this.resultsMsg.Visible   = false;
                this.searchBody.Visible   = false;
            }
        }
예제 #11
0
        protected void OnCollectionChange(string colId)
        {
            if (PageUtil.IsInteger(colId))
            {
                int _colId           = int.Parse(colId);
                SpecimenManagerDa da = new SpecimenManagerDa();
                DataTable         dt = da.GetBoxesByCollectionId(_colId);
                RptBoxes.DataSource = dt.DefaultView;
                RptBoxes.DataBind();

                // change style of div for current collection
                string s = "highlightItem('Collection', '" + colId + "');";
                Page.RegisterStartupScript("xyz", "<script language=javascript>" + s + "</script>");
            }
        }
예제 #12
0
        protected void Delete_Click(object sender, CommandEventArgs e)
        {
            ReloadSpecimenStorageManager(this._boxId, true);

            // set BoxId and PositionId in Specimens to NULL for the deleting Box
            SpecimenManagerDa da = new SpecimenManagerDa();

            da.DeleteBoxReferenceFromSpecimens(this._boxId);

            SpecimenBox box = new SpecimenBox();

            box.Delete(this._boxId);

            CloseThisPage();
        }
        /// <summary>
        /// Get a list of pre-generated Blood Specimen #s based on Trial
        /// </summary>
        /// <param name="protocolNum"></param>
        /// <param name="ptProtocolId"></param>
        /// <param name="studyId"></param>
        /// <param name="visit"></param>
        /// <returns></returns>
        public static ProtocolSpecimenAutoNumber[] GetBloodAutoSpecimenIds(string protocolNum, int ptProtocolId, string studyId, string visit)
        {
            ProtocolMgmtSpecimenController sc = new ProtocolMgmtSpecimenController();
            var bloodSpecimenIds   = sc.GetDefaultBloodSpecimens(protocolNum);
            SpecimenManagerDa da   = new SpecimenManagerDa();
            var specimens          = da.GetSpecimenReport(ptProtocolId, null, "Blood");
            var allSpecimentRefNum = specimens.AsEnumerable().Select(r => r[Specimen.SpecimenReferenceNumber].ToString()).Distinct();
            int maxSeqNum          = allSpecimentRefNum.Count();

            List <ProtocolSpecimenAutoNumber> values = new List <ProtocolSpecimenAutoNumber>();
            int maxSearch = allSpecimentRefNum.Count() + bloodSpecimenIds.Length;

            for (int i = 0; i < bloodSpecimenIds.Length; i++)
            {
                var bloodSpecimen = bloodSpecimenIds[i];
                // sequence
                for (int seq = 1; seq <= maxSearch; seq++)
                {
                    string specimenReferenceFormat = "";
                    bool   containsNumber          = System.Text.RegularExpressions.Regex.IsMatch(bloodSpecimen.Suffix, "^[0-9A-Z]+(-[0-9A-Z]+)+$");
                    // includes static #, exclude sequence #
                    if (containsNumber)
                    {
                        if (!string.IsNullOrEmpty(visit))
                        {
                            specimenReferenceFormat = "{0}-{1}-{2}";
                        }
                        else
                        {
                            specimenReferenceFormat = "{0}-{2}";
                        }
                    }
                    else
                    {
                        specimenReferenceFormat = "{0}-{1}-{2}-{3}";
                    }
                    string autoRefNum = string.Format(specimenReferenceFormat, studyId, visit, bloodSpecimen.Suffix, seq);
                    if (!allSpecimentRefNum.Contains(autoRefNum))
                    {
                        ProtocolSpecimenAutoNumber auto = new ProtocolSpecimenAutoNumber(autoRefNum, bloodSpecimen.SubType, bloodSpecimen.VialType);
                        values.Add(auto);
                        break;
                    }
                }
            }
            return(values.ToArray());
        }
예제 #14
0
        protected void SetFieldValues(object sender, GridViewRowEventArgs e)
        {
            // Get SpecimenAccessionId and register Array of Specimens with child Speicmens
            if (specimensGrid.DataKeys.Count > 0)
            {
                object specKey = specimensGrid.DataKeys[0][Specimen.SpecimenId];
                if (specKey != null && !string.IsNullOrEmpty(specKey.ToString()))
                {
                    int specKeyId = int.Parse(specKey.ToString());
                    sa.Get(specKeyId);
                    string specAccKey = sa[Specimen.SpecimenAccessionId].ToString();
                    if (specAccKey != null && !string.IsNullOrEmpty(specAccKey.ToString()))
                    {
                        int specAccId             = int.Parse(specAccKey.ToString());
                        SpecimenManagerDa da      = new SpecimenManagerDa();
                        DataTable         dt      = da.GetSpecimenshavingChilds(specAccId);
                        List <string>     specIds = new List <string>();
                        foreach (DataRow row in dt.Rows)
                        {
                            string specIdWithChildren = row[Specimen.ParentSpecimenId].ToString();
                            if (!string.IsNullOrEmpty(specIdWithChildren))
                            {
                                specIds.Add(specIdWithChildren);
                            }
                        }
                        //Array of all specimenIds of specimens having children, create safe js array, instead of new Array();
                        string jsArray = "var SpecimensWithChildren = [" + string.Join(",", specIds.ToArray()) + "];";

                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SpecimensWithChildren", jsArray, true);
                    }

                    HtmlImage img = e.Row.FindControl("SpecimenPickerImg") as HtmlImage;
                    if (img != null)
                    {
                        Control siteName    = e.Row.FindControl("SiteName") as Control;
                        Control storageName = e.Row.FindControl("StorageName") as Control;
                        Control Contname    = e.Row.FindControl("ContainerName") as Control;
                        Control bid         = e.Row.FindControl("BoxId") as Control;
                        Control pid         = e.Row.FindControl("PositionId") as Control;
                        Control bname       = e.Row.FindControl("SpecBoxName") as Control;
                        Control pname       = e.Row.FindControl("SpecPositionName") as Control;

                        img.Attributes["onclick"] = "showSpecimenPicker('" + siteName.ClientID + "','" + storageName.ClientID + "','" + Contname.ClientID + "''" + bid.ClientID + "','" + pid.ClientID + "','" + bname.ClientID + "','" + pname.ClientID + "');";
                    }
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Dynamically adds hidden fields to the grid to keep track of which rows becomes dirty
        /// when normal grid dirty functionality isn't triggered
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void WireSpecimenTrackerTextBoxes(object sender, EventArgs e)
        {
            GridView myGrid = sender as GridView;

            // Get SpecimenAccessionId and register Array of Specimens with child Speicmens
            if (myGrid.DataKeys.Count > 0)
            {
                // Get SpecimenAccessionId from first row, since all rows share SpecimenAccessionId
                object specAccKey = myGrid.DataKeys[0][Specimen.SpecimenAccessionId];
                if (specAccKey != null && !string.IsNullOrEmpty(specAccKey.ToString()))
                {
                    int specAccId             = int.Parse(specAccKey.ToString());
                    SpecimenManagerDa da      = new SpecimenManagerDa();
                    DataTable         dt      = da.GetSpecimenshavingChilds(specAccId);
                    List <string>     specIds = new List <string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        string specIdWithChildren = row[Specimen.ParentSpecimenId].ToString();
                        if (!string.IsNullOrEmpty(specIdWithChildren))
                        {
                            specIds.Add(specIdWithChildren);
                        }
                    }
                    //Array of all specimenIds of specimens having children, create safe js array, insetad of new Array();
                    string jsArray = "var SpecimensWithChildren = [" + string.Join(",", specIds.ToArray()) + "];";

                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SpecimensWithChildren", jsArray, true);
                }
            }

            foreach (GridViewRow row in myGrid.Rows)
            {
                List <ICaisisInputControl> cicList = PageUtil.GetCaisisInputControlsInContainer(row);
                foreach (ICaisisInputControl iCIC in cicList)
                {
                    if (iCIC.Field == SpecimenPosition.BoxId)
                    {
                        HiddenField tracker = new HiddenField();
                        tracker.ValueChanged += GetRecordUpdatingHandler(myGrid);
                        // Tracker ID is determined by Ref BoxId field
                        tracker.ID = (iCIC as Control).ID + "Tracker";
                        row.Cells[0].Controls.Add(tracker);
                    }
                }
            }
        }
예제 #16
0
        private void LoadDisabledCollectionSelectBox(int requestId)
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = da.GetCollectionsByRequestId(requestId);

            this.AvailableCollectionSelectBox.DataSource = dt;

            this.AvailableCollectionSelectBox.DataTextField  = "CollectionName";
            this.AvailableCollectionSelectBox.DataValueField = "CollectionId";
            this.AvailableCollectionSelectBox.DataBind();

            /*foreach (ListItem li in this.AvailableCollectionSelectBox.Items)
             * {
             *  li.Selected = true;
             * }*/

            this.availableCollectionsLbl.InnerHtml = "Requested Collections";
        }
        protected void btnSearch_Click(object sender, CommandEventArgs e)
        {
            string strSearch = searchTxtBox.Value;

            string datasetSql = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);

            SpecimenManagerDa da = new SpecimenManagerDa();
            SearchController  sc = new SearchController();
            DataTable         dt;

            if (searchType == "LastNameMRN")
            {
                dt = sc.FindPatient(strSearch, datasetSql).Tables[0];;
            }
            else
            {
                dt = sc.FindPatientByIdentifier(strSearch, _identifierType, datasetSql).Tables[0];
            }

            int n = dt.Rows.Count;

            if (n > 0)
            {
                if (n == 1)
                {
                    patientId = Int32.Parse(dt.Rows[0]["PatientId"].ToString());
                    Response.Redirect("AccessionsContainer.aspx?patientId=" + EncryptPatientId(patientId.ToString()) + "&specimenaccessionId=0");
                }
                else
                {
                    PatientResults.DataSource = dt;
                    PatientResults.DataBind();

                    PDFormDiv.Style.Add("display", "block");
                    noRecordsFound.Visible = false;
                }
            }
            else
            {
                PDFormDiv.Style.Add("display", "none");
                noRecordsFound.Visible = true;
            }
        }
예제 #18
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();
        }
예제 #19
0
        private void BindSpecimensGrid()
        {
            int colId;

            if (!string.IsNullOrEmpty(this.CollectionId.Text))
            {
                colId = int.Parse(this.CollectionId.Text);

                SpecimenManagerDa da = new SpecimenManagerDa();
                DataTable         dt = da.GetSpecimensInCollection(colId, this._identifierType);
                rptSpecimenResults.DataSource = dt;
                rptSpecimenResults.DataBind();

                this.numOfSpecimens         = dt.Rows.Count;
                this.lblTotalSpecimens.Text = this.numOfSpecimens.ToString() + " specimen(s) in collection";
                ShowHideSpecimenGrid();
                ShowHidePrintIcon();
            }
        }
예제 #20
0
        /// <summary>
        /// Given a request id, finds the associated distribution. If found, populates the controls with the values.
        /// </summary>
        /// <param name="rId"></param>
        private void LoadDistributionByRequestId(int rId)
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = new DataTable();

            dt = da.GetDistributionByRequestId(rId);

            //if there is a distrbution, we populate the fields
            if (dt.Rows.Count > 0)
            {
                SpecimenDistribution sDistribution = new SpecimenDistribution();
                int dId = Int32.Parse(dt.Rows[0][SpecimenDistribution.DistributionId].ToString());
                sDistribution.Get(dId);

                CICHelper.SetFieldValues(this.DispatchDiv.Controls, sDistribution);
                CICHelper.SetFieldValues(this.ReceiveDiv.Controls, sDistribution);

                this.DispatchedDate.Value = GetValidDisplayDate(this.DispatchedDate.Value);
                this.ReceivedDate.Value   = GetValidDisplayDate(this.ReceivedDate.Value);
            }
        }
예제 #21
0
        private bool ValidateCollectionName(string colName)
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = da.GetCollectionByName(colName);

            if (dt.Rows.Count == 0)
            {
                return(true);
            }
            else
            {
                if (!string.IsNullOrEmpty(this.CollectionId.Value))
                {
                    if (dt.Rows[0][SpecimenCollection.CollectionId].ToString().Equals(this.CollectionId.Value))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }
예제 #22
0
        private void LoadModifiableCollectionSelectBox(int requestId)
        {
            SpecimenManagerDa da        = new SpecimenManagerDa();
            DataTable         dt        = da.GetCollectionsByRequestId(requestId);
            int numCollectionsInRequest = dt.Rows.Count;

            dt.Merge(da.GetAvailableCollections());
            this.AvailableCollectionSelectBox.DataSource = dt.DefaultView;

            this.AvailableCollectionSelectBox.DataTextField  = "CollectionName";
            this.AvailableCollectionSelectBox.DataValueField = "CollectionId";
            this.AvailableCollectionSelectBox.DataBind();

            this.collectionIdList.Clear();
            for (int i = 0; i < numCollectionsInRequest; i++)
            {
                this.AvailableCollectionSelectBox.Items[i].Selected = true;
                this.collectionIdList.Add(this.AvailableCollectionSelectBox.Items[i].Value);
            }

            this.CollectionIds.Value = String.Join(",", collectionIdList.ToArray());
        }
예제 #23
0
        private bool ValidateRequestName(string requestName)
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = da.GetRequestByName(requestName);

            if (dt.Rows.Count == 0)
            {
                return(true);
            }
            else
            {
                if (!string.IsNullOrEmpty(this.SpecimenRequestId.Value))
                {
                    // if comparing to itself, validate
                    if (dt.Rows[0][SpecimenRequest.RequestIdentifier].ToString().Equals(this.RequestIdentifier.Value))
                    {
                        return(true);
                    }
                }
                UserMessage.Text += "Request name is already in use, please use another name. ";
                return(false);
            }
        }
예제 #24
0
        protected void UpdateSpecimenLocation()
        {
            Response.ContentType = "text/html";

            int collectionId = int.Parse(Request.Form["collectionId"]);
            int srcBoxId     = int.Parse(Request.Form["srcBoxId"]);
            int srcPos       = int.Parse(Request.Form["srcPosition"]);
            int destBoxId    = int.Parse(Request.Form["destBoxId"]);
            int destPos      = int.Parse(Request.Form["destPosition"]);

            SpecimenManagerDa da  = new SpecimenManagerDa();
            DataTable         tmp = da.GetSpecimensByBoxId(srcBoxId, collectionId);

            // Trace back to specimen record
            DataRow[] rows = tmp.Select(SpecimenPosition.Position + " = '" + srcPos + "'");
            if (rows.Length > 0)
            {
                DataRow          row        = rows[0];
                SpecimenPosition specPosBiz = new SpecimenPosition();
                int positionId = int.Parse(row[Specimen.PositionId].ToString());
                specPosBiz.Get(positionId);
                specPosBiz[SpecimenPosition.BoxId]    = destBoxId;
                specPosBiz[SpecimenPosition.Position] = destPos;
                specPosBiz.Save();

                Specimen specBiz    = new Specimen();
                int      specimenId = int.Parse(row[Specimen.SpecimenId].ToString());
                specBiz.Get(specimenId);
                specBiz[Specimen.BoxId] = destBoxId;
                specBiz.Save();

                Response.Write("true");
                Response.End();
            }
            Response.Write("false");
            Response.End();
        }
예제 #25
0
        protected void SaveReceiveDetails(object sender, ImageClickEventArgs e)
        {
            try
            {
                ControlCollection receiveControls = Page.FindControl("ReceiveDiv").Controls;
                CICHelper.ValidFieldValues(receiveControls);

                SpecimenDistribution sDistribution = new SpecimenDistribution();
                sDistribution.Get(Int32.Parse(this.DistributionId.Value));

                CICHelper.SetBOValues(receiveControls, sDistribution, 1);

                sDistribution.Save();

                SpecimenManagerDa da = new SpecimenManagerDa();
                da.UpdateRequestStatus(this.RequestId, "Received");
                this.RequestStatus.Value = "Received";

                // update the status for the collections in this transfer
                // (saved to database ... is the same as the ones in showing up in the select box because user can't change them (w/o. saving) at this stage)
                // to status of "Received"
                foreach (ListItem li in this.AvailableCollectionSelectBox.Items)
                {
                    int colId = int.Parse(li.Value);
                    UpdateCollectionStatus(colId, "Received");
                }

                DetermineRequestStatus();
                EnableDisableDivsByStatus();

                UpdatePageTitle();
            }
            catch (RequiredValueException rve)
            {
                ReceiveDateError.Text = "Please enter a receive date.";
            }
        }
예제 #26
0
        private void BuildListings(string specimenType)
        {
            // generate column
            if (!string.IsNullOrEmpty(specimenType))
            {
                // set display columns
                var columns = QuerySpecimenType == QUERY_TISSUE ? TISSUE_COLUMNS : BLOOD_COLUMNS;
                // set columns based on tissue type
                SpecimensListing.Columns.Clear();
                foreach (var col in columns)
                {
                    string colName  = col[0];
                    string colLabel = col[1];
                    string conType  = col[2];
                    var    bf       = new BoundField();
                    bf.DataField        = col[0];
                    bf.HeaderText       = col[1];
                    bf.DataFormatString = colName.EndsWith("Date") ? "{0:d}" : "{0}";
                    SpecimensListing.Columns.Add(bf);
                }
                int patientId    = int.Parse(BaseDecryptedPatientId);
                int ptProtocolId = int.Parse(PatientProtocolId);

                Caisis.DataAccess.SpecimenManagerDa da = new SpecimenManagerDa();
                // optionally filter by specimen types (i.e., Blood, Tissue)
                List <string> types = new List <string>();
                if (!string.IsNullOrEmpty(QuerySpecimenType))
                {
                    types.Add(QuerySpecimenType);
                }
                // get specimens report
                DataView specimens = da.GetSpecimenReport(ptProtocolId, null, types.ToArray()).DefaultView;
                // sort: pri key ???
                specimens.Sort = Specimen.SpecimenId + " ASC";
                // restrict non null status ???
                specimens.RowFilter = Specimen.SpecimenStatus + " IS NOT NULL";

                // filter: checks for specimen num like current filter
                //if (!string.IsNullOrEmpty(QueryVisitType))
                //{
                //    string refNumMatch = base.GetSpecimenReferenceNumber("");
                //    specimens.RowFilter = Specimen.SpecimenReferenceNumber + " LIKE '" + PageUtil.EscapeSingleQuotesForSql(refNumMatch) + "%'";
                //}

                SpecimensListing.DataSource = specimens;
                SpecimensListing.DataBind();

                if (specimens.Count == 0)
                {
                    string message = "There are no";
                    if (!string.IsNullOrEmpty(QuerySpecimenType))
                    {
                        message += " " + QuerySpecimenType + " specimens";
                        if (!string.IsNullOrEmpty(QueryVisitType))
                        {
                            message += " on the selected visit";
                        }
                    }
                    else
                    {
                        message += " specimens";
                    }
                    NoRecordsText.Text    = message + ".";
                    NoRecordsText.Visible = true;
                }
                else
                {
                    NoRecordsText.Text    = "";
                    NoRecordsText.Visible = false;
                }
            }
            else
            {
                NoRecordsText.Text    = "";
                NoRecordsText.Visible = false;
            }
        }
예제 #27
0
        //to check the Type is not null, before Add/Update events in different RowTypes of gridview control
        protected void AddClickEventToButtons(object sender, GridViewRowEventArgs e)
        {
            //adding new event
            if (e.Row.RowType == DataControlRowType.EmptyDataRow)
            {
                ImageButton    emptyrowAddBtn  = e.Row.FindControl("EvtAdd") as ImageButton;
                CaisisComboBox emptyrowevtTest = e.Row.FindControl("EvtTest") as CaisisComboBox;
                if (emptyrowAddBtn != null && emptyrowevtTest != null)
                {
                    emptyrowAddBtn.Attributes["onclick"] = "return validateTest('" + emptyrowevtTest.ClientID + "');";
                }
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //delete existing event
                ImageButton deleteBtn = e.Row.FindControl("DeleteBtn") as ImageButton;
                if (deleteBtn != null)
                {
                    deleteBtn.Attributes["onclick"] = "return confirm('Are you sure you want to delete this event?');";
                }

                //updating existing event data in edit mode
                ImageButton    saveBtn = e.Row.FindControl("SaveRowBtn") as ImageButton;
                CaisisComboBox evtTest = e.Row.FindControl("EvtTest1") as CaisisComboBox;
                if (saveBtn != null && evtTest != null)
                {
                    saveBtn.Attributes["onclick"] = "return validateTest('" + evtTest.ClientID + "');";
                }

                //getting Specimen Reference # to view report
                DataRowView       drv        = (DataRowView)e.Row.DataItem;
                int               id         = int.Parse(drv["SpecimenId"].ToString());
                SpecimenManagerDa da         = new SpecimenManagerDa();
                string            datasetSQL = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
                DataTable         dt         = da.GetIdentifier(id, _identifierType, datasetSQL);
                string            str        = dt.Rows[0].ItemArray[3].ToString();
                string            refnum;

                //to get the substring of ReferenceNumber removing from first hyphen(-)
                if (str.Contains("-"))
                {
                    int index = str.IndexOf(@"-");
                    refnum = str.Substring(0, index);
                }
                else
                {
                    refnum = str;
                }

                //show URL button for only processed aCGH tests
                //commented this section temporarily

                /*
                 * string testValue = drv["EventType"].ToString();
                 * string testProcessedBy = drv["ProcessedBy"].ToString();
                 *
                 * Button urlBtn1 = e.Row.FindControl("EvtURL1") as Button;
                 * if (testValue == "aCGH" && testProcessedBy == "")
                 * {
                 *  SpecimenEventsGridViewTable.FindControl("hdrRpt").Visible = true;
                 *  SpecimenEventsGridView.Columns[11].Visible = true;
                 * }
                 * if (urlBtn1 != null)
                 * {
                 *  if (testValue == "aCGH" && testProcessedBy == "")
                 *  {
                 *      urlBtn1.Attributes["onclick"] = "window.open('http://aji.cbio.mskcc.org/btc/" + refnum + "/index.html','_new'); return false;";
                 *      urlBtn1.Style["visibility"] = "visible";
                 *      urlBtn1.NamingContainer.Visible = true;
                 *  }
                 * }
                 */

                // enable edit click
                ImageButton editBtn = e.Row.FindControl("EditImage") as ImageButton;
                editBtn.OnClientClick = "enableGridFields(" + e.Row.RowIndex + ");return false;";
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                //Adding new event, with some events already existing
                ImageButton    AddBtn        = e.Row.FindControl("EvntAdd1") as ImageButton;
                CaisisComboBox footerevtTest = e.Row.FindControl("EvtTest2") as CaisisComboBox;
                if (AddBtn != null && footerevtTest != null)
                {
                    AddBtn.Attributes["onclick"] = "return validateTest('" + footerevtTest.ClientID + "');";
                }
            }
        }
예제 #28
0
        protected void GetBoxMatrix()
        {
            string myBoxId = Request.Form["BoxId"];
            int    boxId;

            if (int.TryParse(myBoxId, out boxId))
            {
                SpecimenBox box = new SpecimenBox();
                box.Get(boxId);
                //SpecimenPosition pos = new SpecimenPosition();
                //pos.GetByParent(boxId);
                //// Build a string array of position indexes
                //DataTable positionDataTable = pos.DataSourceView.Table;
                DataTable positionDataTable   = BusinessObject.GetByParentAsDataView <SpecimenPosition>(boxId).Table;
                int       positionIndexCount  = positionDataTable.Rows.Count;
                string[]  posIndexes          = new string[positionIndexCount];
                string    posIndexStringArray = "[";
                for (int i = 0; i < positionIndexCount; i++)
                {
                    object val = positionDataTable.Rows[i][SpecimenPosition.Position];
                    if (val != null)
                    {
                        int index;
                        if (int.TryParse(val.ToString(), out index))
                        {
                            posIndexStringArray += index + ",";
                        }
                    }
                }
                posIndexStringArray  = posIndexStringArray.TrimEnd(",".ToCharArray());
                posIndexStringArray += "]";
                int rows = 20;
                if (box[SpecimenBox.NoOfRows] != null && !string.IsNullOrEmpty(box[SpecimenBox.NoOfRows].ToString()))
                {
                    rows = int.Parse(box[SpecimenBox.NoOfRows].ToString());
                }
                int cols = 20;
                if (box[SpecimenBox.NoOfColumns] != null && !string.IsNullOrEmpty(box[SpecimenBox.NoOfColumns].ToString()))
                {
                    cols = int.Parse(box[SpecimenBox.NoOfColumns].ToString());
                }

                string boxType = String.Empty;
                if (box[SpecimenBox.BoxType] != null && !string.IsNullOrEmpty(box[SpecimenBox.BoxType].ToString()))
                {
                    boxType = box[SpecimenBox.BoxType].ToString();
                }

                int maxPos = rows * cols;
                if (box[SpecimenBox.MaxPositionNo] != null && !string.IsNullOrEmpty(box[SpecimenBox.MaxPositionNo].ToString()))
                {
                    maxPos = int.Parse(box[SpecimenBox.MaxPositionNo].ToString());
                }
                // Check if calling for transfer
                SpecimenManagerDa da = new SpecimenManagerDa();
                string            transferPositionsArray = "";
                if (!string.IsNullOrEmpty(Request.Form["getTransfers"]) && !string.IsNullOrEmpty(Request.Form["collectionId"]))
                {
                    int       collectionId = int.Parse(Request.Form["collectionId"]);
                    DataTable specsInBoxDT = da.GetSpecimensByBoxId(boxId, collectionId);

                    ArrayList oBoxTransferPosArr = new ArrayList();
                    foreach (DataRow dr in specsInBoxDT.Rows)
                    {
                        if (dr["Transferable"].ToString() == "yes")
                        {
                            oBoxTransferPosArr.Add(dr[SpecimenPosition.Position].ToString());
                        }
                    }
                    string oBoxTransferPos = String.Join(", ", (string[])oBoxTransferPosArr.ToArray(typeof(string)));
                    transferPositionsArray = "[" + oBoxTransferPos + "]";
                }

                string clientTransferArray = !string.IsNullOrEmpty(transferPositionsArray) ? ("," + transferPositionsArray) : string.Empty;

                //if (!string.IsNullOrEmpty(Request.Form["NeedPath"]) || true)
                //{

                int       specimensInBox = da.GetSpecimensInBox(boxId).Rows.Count;
                DataSet   resultsDataSet = da.GetBoxAndAncestors(boxId);
                DataTable boxesDT        = resultsDataSet.Tables[0];
                string    boxIdStr       = boxId.ToString();
                DataRow   boxRow         = boxesDT.Select(SpecimenBox.BoxId + "=" + boxIdStr)[0];
                string    boxName        = PageUtil.EscapeSingleQuotes(boxRow[SpecimenBox.BoxName].ToString());

                DataTable containersDT   = resultsDataSet.Tables[1];
                string    containerIdStr = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString();
                DataRow   containerRow   = containersDT.Select(SpecimenContainer.ContainerId + " = " + containerIdStr)[0];
                string    containerName  = PageUtil.EscapeSingleQuotes(containerRow[SpecimenContainer.ContainerName].ToString());

                DataTable storagesDT    = resultsDataSet.Tables[2];
                string    storagesIdStr = containersDT.Rows[0][SpecimenContainer.StorageId].ToString();
                DataRow   specimenRow   = storagesDT.Select(SpecimenStorage.StorageId + " = " + storagesIdStr)[0];
                string    storageName   = PageUtil.EscapeSingleQuotes(specimenRow[SpecimenStorage.StorageName].ToString());

                DataTable siteDT   = resultsDataSet.Tables[3];
                string    siteId   = siteDT.Rows[0][SpecimenSite.SiteId].ToString();
                DataRow   siteRow  = siteDT.Select(SpecimenSite.SiteId + " = " + siteId)[0];
                string    siteName = PageUtil.EscapeSingleQuotes(siteRow[SpecimenSite.SiteName].ToString());

                BindDropDownList(StoragesDropDown, storagesDT, SpecimenStorage.StorageName, SpecimenStorage.StorageId, storagesIdStr);
                BindDropDownList(ContainersDropDown, containersDT, SpecimenContainer.ContainerName, SpecimenContainer.ContainerId, containerIdStr);
                BindDropDownList(BoxesDropDown, boxesDT, SpecimenBox.BoxName, SpecimenBox.BoxId, boxIdStr);
                SiteId.Text = siteId;
                //}

                string js = "new Array(" + rows + "," + cols + "," + maxPos + "," + posIndexStringArray + clientTransferArray + ",'" + siteName + "','" + storageName + "','" + containerName + "'," + specimensInBox + ",'" + boxName + "','" + boxType + "')";
                BoxMatrix.Text = js;
            }
        }
예제 #29
0
        /// <summary>
        /// Sorting Collection repeater using headers in ascending & descending order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptSort(object sender, CommandEventArgs e)
        {
            SpecimenManagerDa da = new SpecimenManagerDa();
            DataTable         dt = da.GetCollections(this.collectionName.Value, this.ddlType.Value, this.ddlStatus.Value, this.dateFrom.Value, this.dateTo.Value, this.chkViewAll.Checked);

            switch (e.CommandName)
            {
            case "Name":
                if (Name.ToolTip == "Click to sort descending")
                {
                    dt.DefaultView.Sort = "CollectionName Desc";
                    Name.ToolTip        = "Click to sort ascending";
                }
                else
                {
                    dt.DefaultView.Sort = "CollectionName Asc";
                    Name.ToolTip        = "Click to sort descending";
                }
                break;

            case "Type":
                if (ColType.ToolTip == "Type" || ColType.ToolTip == "Click to sort ascending")
                {
                    dt.DefaultView.Sort = "CollectionType";
                    ColType.ToolTip     = "Click to sort descending";
                }
                else if (ColType.ToolTip == "Click to sort descending")
                {
                    dt.DefaultView.Sort = "CollectionType Desc";
                    ColType.ToolTip     = "Click to sort ascending";
                }
                break;

            case "Status":
                if (Status.ToolTip == "Status" || Status.ToolTip == "Click to sort ascending")
                {
                    dt.DefaultView.Sort = "CollectionStatus";
                    Status.ToolTip      = "Click to sort descending";
                }
                else if (Status.ToolTip == "Click to sort descending")
                {
                    dt.DefaultView.Sort = "CollectionStatus Desc";
                    Status.ToolTip      = "Click to sort ascending";
                }
                break;

            case "Specimens":
                if (Specimens.ToolTip == "#Specimens" || Specimens.ToolTip == "Click to sort ascending")
                {
                    dt.DefaultView.Sort = "SpecimensInCollection";
                    Specimens.ToolTip   = "Click to sort descending";
                }
                else if (Specimens.ToolTip == "Click to sort descending")
                {
                    dt.DefaultView.Sort = "SpecimensInCollection Desc";
                    Specimens.ToolTip   = "Click to sort ascending";
                }
                break;

            case "DateCreated":
                if (DateCreated.ToolTip == "Date" || DateCreated.ToolTip == "Click to sort ascending")
                {
                    dt.DefaultView.Sort = "CollectionAssignDate" + " Asc";
                    DateCreated.ToolTip = "Click to sort descending";
                }
                else if (DateCreated.ToolTip == "Click to sort descending")
                {
                    dt.DefaultView.Sort = "CollectionAssignDate" + " Desc";
                    DateCreated.ToolTip = "Click to sort ascending";
                }
                break;
            }

            rptCollection.DataSource = dt;
            rptCollection.DataBind();
        }
예제 #30
0
        private void LoadSpecimenInfo()
        {
            Specimen specimen = new Specimen();

            specimen.Get(this.specimenId);

            string parentspecId = specimen[Specimen.ParentSpecimenId].ToString();

            pspecId.Value = parentspecId.ToString();

            //if (!string.IsNullOrEmpty(parentspecId))
            //{
            //    Specimen ParentSpecimen = new Specimen();
            //    ParentSpecimen.Get(Int32.Parse(parentspecId.ToString()));

            //    pRemQty.Value = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString();
            //}

            CICHelper.SetFieldValues(this.inputControlsRow.Controls, specimen);

            //getting patient identifier
            PtId.Text = _identifierType + " :";
            SpecimenManagerDa da         = new SpecimenManagerDa();
            string            datasetSql = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            DataTable         dt         = da.GetIdentifier(this.specimenId, _identifierType, datasetSql);
            string            identifier = dt.Rows[0].ItemArray[2].ToString();

            TumorBankNumber.Text = identifier.ToString();

            //load box and position from SpecimenBoxes and SpecimenPositions tables
            string sBoxId = specimen[Specimen.BoxId].ToString();

            if (!String.IsNullOrEmpty(sBoxId))
            {
                int         boxId = int.Parse(sBoxId);
                SpecimenBox box   = new SpecimenBox();
                box.Get(boxId);
                this.BoxId.Value   = box[SpecimenBox.BoxId].ToString();
                this.BoxName.Value = box[SpecimenBox.BoxName].ToString();

                DataSet hierarchySet = da.GetBoxAndAncestors(boxId);

                DataTable boxesDT      = hierarchySet.Tables[0];
                DataTable containersDT = hierarchySet.Tables[1];
                DataTable storagesDT   = hierarchySet.Tables[2];
                DataTable siteDT       = hierarchySet.Tables[3];

                if (boxesDT.Rows.Count >= 1)
                {
                    string  containerIdStr = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString();
                    DataRow containerRow   = containersDT.Select(SpecimenContainer.ContainerId + " = " + containerIdStr)[0];
                    this.ContainerName.Value = PageUtil.EscapeSingleQuotes(containerRow[SpecimenContainer.ContainerName].ToString());
                }
                if (containersDT.Rows.Count >= 1)
                {
                    string  storagesIdStr = containersDT.Rows[0][Caisis.BOL.SpecimenContainer.StorageId].ToString();
                    DataRow specimenRow   = storagesDT.Select(Caisis.BOL.SpecimenStorage.StorageId + " = " + storagesIdStr)[0];
                    this.StorageName.Value = PageUtil.EscapeSingleQuotes(specimenRow[Caisis.BOL.SpecimenStorage.StorageName].ToString());
                }
                if (siteDT.Rows.Count >= 1)
                {
                    string  siteId  = siteDT.Rows[0][SpecimenSite.SiteId].ToString();
                    DataRow siteRow = siteDT.Select(SpecimenSite.SiteId + " = " + siteId)[0];
                    this.SiteName.Value = PageUtil.EscapeSingleQuotes(siteRow[SpecimenSite.SiteName].ToString());
                }
            }

            string sPositionId = specimen[Specimen.PositionId].ToString();

            if (!String.IsNullOrEmpty(sPositionId))
            {
                int positionId       = int.Parse(sPositionId);
                SpecimenPosition pos = new SpecimenPosition();
                pos.Get(positionId);
                this.PositionName.Value = pos[SpecimenPosition.Position].ToString();
                this.PositionId.Value   = pos[SpecimenPosition.PositionId].ToString();
            }
        }