コード例 #1
0
        private bool SearchStatus(DataTable table, string status)
        {
            DataView view = table.DefaultView;

            view.RowFilter = Specimen.SpecimenStatus + " = '" + PageUtil.EscapeSingleQuotesForSql(status) + "'";
            return(view.Count > 0);
        }
コード例 #2
0
        /// <summary>
        /// Builds a lookup for CTCAE caregories, toxicities and grades
        /// </summary>
        private void BuildCTCAELookup()
        {
            string ctcaeVersion = CTCAEVersion.Value;

            if (!string.IsNullOrEmpty(ctcaeVersion))
            {
                CTCAEDa da       = new CTCAEDa();
                var     versions = da.GetCTCAETerminlogyVersions().Tables[0].DefaultView;
                // locate version by name
                versions.RowFilter = "AE_Terminology_ShortDesc = '" + PageUtil.EscapeSingleQuotesForSql(ctcaeVersion) + "'";
                if (versions.Count > 0)
                {
                    int termId = (int)versions[0]["AE_TerminologyID"];
                    // get a list of categories, toxicities, and grades by version
                    var dt = da.GetCTCLookup(termId);
                    // get a list of radio button groups on page, verify field names
                    var radioButtonGroup = from rg in CICHelper.GetCaisisInputControls(this).OfType <EformRadioButtonGroup>()
                                           where rg.Table == "Toxicities" && rg.Field1 == "ToxCategory" && rg.Field2 == "ToxName" && rg.Field3 == "ToxScale"
                                           let category                     = rg.Value1
                                                                    let tox = rg.Value2
                                                                              select rg;

                    // get a lookup of grades for each radio button group
                    var radioGroupToCTC = from rg in radioButtonGroup
                                          let rgTox                         = rg.Value2
                                                                  let rgCat = rg.Value1
                                                                              // check if this toxicity and category has grade entries
                                                                              let foundGrades                                                   = from row in dt.AsEnumerable()
                                                                                                                    let tox                     = row["CTC_AE_Toxicity_ShortDesc"].ToString()
                                                                                                                                        let cat = row["AE_Category_Description"].ToString()
                                                                                                                                                  where tox.Contains(rg.Value2) && cat.Contains(rg.Value1)
                                                                                                                                                  select new
                    {
                        Grade     = Server.HtmlEncode(row["AE_Grade"].ToString()),
                        GradeDesc = Server.HtmlEncode(row["AE_Grade_Description"].ToString())
                    }
                    where foundGrades.Count() > 0
                    select new
                    {
                        ToxName = rgTox,
                        // get normalized client lookup name (only alpha characters)
                        //ToxNameLookupKey = new String(rgTox.Replace(" ", "").ToCharArray().Where(c => (c >= 'a' || c <= 'z') || (c >= 'A' || c <= 'Z')).ToArray()),
                        ToxNameLookupKey = rgTox.Replace(" ", "").Replace("-", ""),
                        ClientId         = rg.ClientID,
                        Grades           = foundGrades
                    };
                    // build outer rptr with tooltip for each radio group
                    CTCAERptr.DataSource = radioGroupToCTC;
                    CTCAERptr.DataBind();

                    // register a list of client ids used for mapping tooltip content
                    var CTC_GRADE_LOOKUP = "var CTC_GRADE_LOOKUP = { " + string.Join(",", radioGroupToCTC.Select(c => "'" + c.ToxNameLookupKey + "': '" + c.ClientId + "'").ToArray()) + "};";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CTC_GRADE_LOOKUP", CTC_GRADE_LOOKUP, true);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns true if the selected ProjectType needs an approval record, else false.
        /// </summary>
        /// <param name="projectType"></param>
        /// <returns></returns>
        private bool FormNeedsApprovalStep(string projectType)
        {
            LookupCodeDa da = new LookupCodeDa();
            // LookupCode ProjectApprovalType should contain a single lookup value
            // used to link child codes as needing approval step.
            DataTable dt = da.GetLookupsByFieldName("ProjectApprovalType").Tables[0];

            DataRow[] singleType = dt.Select("LkpCode = 'ProjectApprovalType'");
            if (singleType.Length > 0)
            {
                int parentCodeId = int.Parse(singleType[0]["LookupCodeId"].ToString());
                // Get all the ProjectTypes which need approval
                DataTable childCodes = da.GetChildCodesByLookupIdAndChildLookupName(parentCodeId, "ProjectType");
                // If projectType is in this list, we need an approval step
                if (childCodes.Select("LkpCode = '" + PageUtil.EscapeSingleQuotesForSql(projectType) + "'").Length > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #4
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            string parentCodeId    = Request.QueryString["lookupCodeId"];
            string childLookupType = Request.QueryString["childLookupType"];

            if (!string.IsNullOrEmpty(parentCodeId) && !string.IsNullOrEmpty(childLookupType))
            {
                LookupCodeDa da            = new LookupCodeDa();
                DataTable    myChildCodes  = da.GetChildCodesByLookupIdAndChildLookupName(int.Parse(parentCodeId), childLookupType);
                DataTable    allChildCodes = da.GetLookupsByFieldName(childLookupType).Tables[0];


                foreach (DataRow row in myChildCodes.Rows)
                {
                    string lkpCode = row["LkpCode"].ToString();
                    if (myChildCodes.Select("LkpCode = '" + PageUtil.EscapeSingleQuotesForSql(lkpCode) + "'").Length == 0)
                    {
                        Response.Write(lkpCode + ",");
                    }
                }
            }
        }
コード例 #5
0
        protected void dgEtFieldsAttributes_ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            int    attributeId;
            int    tableId   = int.Parse(ddlTableDefs.SelectedValue);
            string tableName = lblEtTableName.Text;

            MetadataNewDa MNDa = new MetadataNewDa();

            switch (e.CommandName)
            {
            case "Delete":

                attributeId = int.Parse(e.Item.Cells[0].Text);
                MNDa.DeleteAttribute(attributeId);

                break;

            case "SaveAttributes":
                DataGrid dgAttributes = (DataGrid)source;
                foreach (DataGridItem dgi in dgAttributes.Items)
                {
                    if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
                    {
                        int          fieldAttributeId = int.Parse(dgi.Cells[0].Text);
                        DropDownList ddl = (DropDownList)dgi.FindControl("attDdlAttributeValue");
                        TextBox      txt = (TextBox)dgi.FindControl("attTxtAttributeValue");
                        string       theValue;
                        if (((TextBox)dgi.FindControl("attTxtAttributeValueCtrlUsed")).Text == "txt")
                        {
                            theValue = txt.Text;
                        }
                        else
                        {
                            theValue = ddl.SelectedValue;
                        }

                        theValue = PageUtil.EscapeSingleQuotesForSql(theValue);
                        MNDa.UpdateAttribute(fieldAttributeId, theValue);
                    }
                }
                TextBox txtNewAttributesList = (TextBox)Page.FindControl("attTxtNewAttributesList");

                string[] atts = txtNewAttributesList.Text.Split(char.Parse("@"));
                for (int k = 0; k < atts.Length; k++)
                {
                    string[] anAtt = atts[k].Split(char.Parse(";"));
                    if (anAtt.Length == 3 && PageUtil.IsInteger(anAtt[0]) && PageUtil.IsInteger(anAtt[1]))
                    {
                        string attValue = PageUtil.EscapeSingleQuotesForSql(anAtt[2]);

                        MNDa.DeleteAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1]));
                        MNDa.AddAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1]), attValue);
                    }
                }
                txtNewAttributesList.Text = "";
                break;
            }
            viewMode = "editTable";
            setViewMode();
            updateEditTableView(tableId, tableName);
        }
コード例 #6
0
        private void PopulateForm(int?specimenAccessionId)
        {
            bool isNewAccession = !specimenAccessionId.HasValue;
            int  patientId      = int.Parse(BaseDecryptedPatientId);
            int  ptProtocolId   = int.Parse(PatientProtocolId);

            // set study id
            PatientProtocol ptProtocol = new PatientProtocol();

            if (!string.IsNullOrEmpty(PatientProtocolId))
            {
                ptProtocol.Get(int.Parse(PatientProtocolId));
                PtProtocolStudyId.Value = ptProtocol[PatientProtocol.PtProtocolStudyId].ToString();
            }

            // populate SpecimenAccessions
            SpecimenAccession sa = new SpecimenAccession();

            if (specimenAccessionId.HasValue)
            {
                sa.Get(specimenAccessionId.Value);
                base.PopulateForm(sa);
                // special case: needle
                PopulateNeedleUIField(sa);
                // special case: diagnostics for tissue
                if (QuerySpecimenType == QUERY_TISSUE) // && !string.IsNullOrEmpty(AccessionProcName.Text) && AccessionProcName.Text.StartsWith("Image-Guided", StringComparison.OrdinalIgnoreCase))
                {
                    PopulateDiagnostic(specimenAccessionId.Value);
                }
            }

            // populate Specimens grid
            DataView specimens;

            // STEP 1: get all accessions of this type, will filter later on
            specimens = da.GetSpecimenReport(ptProtocolId, null, QuerySpecimenType).DefaultView;
            var allSpecimentRefNum = specimens.Table.AsEnumerable().Select(r => r[Specimen.SpecimenReferenceNumber].ToString()).Distinct();

            // STEP 2: generate an auto-calculated spec ref num for the patient (exclude currently assigned)
            autoGeneratedSpecimenRefNum.Clear();
            // only auto-generate spec # if filtering by type + visit
            if (!string.IsNullOrEmpty(QuerySpecimenType) && !string.IsNullOrEmpty(QueryVisitType))
            {
                int totalSpecimens = SpecimensGrid.BlankRows + specimens.Count;
                int start          = 1;
                // find the max currently assigned reference num
                for (int seqNum = 1; seqNum <= totalSpecimens; seqNum++)
                {
                    // check if currently assigned, else add to available bucket
                    if (allSpecimentRefNum.Contains(GetSpecimenReferenceNumber(seqNum + "")))
                    {
                        start += 1;
                    }
                }
                // fill auto ref num
                autoGeneratedSpecimenRefNum.AddRange(Enumerable.Range(start, totalSpecimens).Select(seqNum => GetSpecimenReferenceNumber(seqNum + "")));
            }
            // when no parent record specified, build estimated reference num, but do not popualte with exisiting data
            if (!specimenAccessionId.HasValue)
            {
                specimens.Table.Clear();
            }

            // build restrictions
            List <string> restrictions = new List <string>();

            // restrict to this accession
            if (specimenAccessionId.HasValue)
            {
                restrictions.Add(Specimen.SpecimenAccessionId + " = " + specimenAccessionId.Value);
            }
            // restrict to this type
            if (!string.IsNullOrEmpty(QuerySpecimenType))
            {
                restrictions.Add(Specimen.SpecimenType + " = '" + QuerySpecimenType + "'");
                // restrict to visit (requires specimen type)
                if (!string.IsNullOrEmpty(QueryVisitType))
                {
                    string refNumMatch = GetSpecimenReferenceNumber("");
                    restrictions.Add(Specimen.SpecimenReferenceNumber + " LIKE '" + PageUtil.EscapeSingleQuotesForSql(refNumMatch) + "%'");
                }
            }


            if (restrictions.Count() > 0)
            {
                specimens.RowFilter = string.Join(" AND ", restrictions.ToArray());
                specimens           = new DataView(specimens.ToTable());
            }
            else
            {
                specimens.RowFilter = "";
            }

            // data binding

            // adjust subType heading
            DataControlField subTypeColumn          = SpecimensGrid.Columns[1];
            DataControlField vialTypeColumn         = SpecimensGrid.Columns[2];
            DataControlField processingMethodColumn = SpecimensGrid.Columns[3];
            DataControlField specimenStatusColumn   = SpecimensGrid.Columns[6];

            if (QuerySpecimenType == QUERY_TISSUE)
            {
                // custom visits ??
                bool customVisits = BuildSpecimenVisitTypes(QUERY_TISSUE, sa);

                subTypeColumn.HeaderText = "Sample Type";
                // hide columns from UI
                foreach (DataControlField column in new DataControlField[] { subTypeColumn, subTypeColumn, vialTypeColumn })
                {
                    column.HeaderStyle.CssClass = "hidden";
                    column.ItemStyle.CssClass   = "hidden";
                }

                // set selection in parent
                Tissue_SpecimenSubType.Value = specimens.Count > 0 ? specimens[0][Specimen.SpecimenSubType].ToString() : "";

                // blank rows
                SpecimensGrid.BlankRows        = Math.Max(0, 6 - specimens.Count);
                SpecimensGrid.VisibleBlankRows = 1;
                if (SpecimensGrid.BlankRows == 0)
                {
                    AddBtn.Visible = false;
                }
                if (specimens.Count != 0)
                {
                    SpecimensGrid.VisibleBlankRows = 0;
                }
            }
            else if (QuerySpecimenType == QUERY_BLOOD)
            {
                // custom visits ??
                bool customVisits = BuildSpecimenVisitTypes(QUERY_BLOOD, sa);
                // static visits
                if (!customVisits)
                {
                    // default accession visit
                    AccessionVisit.Value   = "A";
                    AccessionVisit.Enabled = false;
                }

                AddBtn.Visible           = true;
                subTypeColumn.HeaderText = "Tube Use";

                // hide columns from UI
                foreach (DataControlField column in new DataControlField[] { processingMethodColumn })
                {
                    column.HeaderStyle.CssClass = "hidden";
                    column.ItemStyle.CssClass   = "hidden";
                }
                // update default blood specimens
                bloodAutoSpecimens = ProtocolMgmtSpecimenController.GetBloodAutoSpecimenIds(base.ProtocolNumber, (int)ptProtocol[PatientProtocol.PatientProtocolId], PtProtocolStudyId.Value, AccessionVisit.Enabled ? AccessionVisit.Value : "");

                SpecimensGrid.BlankRows        = Math.Max(0, 15 - specimens.Count);
                SpecimensGrid.VisibleBlankRows = specimens.Count > 0 ? 0 : (bloodAutoSpecimens.Length > 0 ? bloodAutoSpecimens.Length : 3);
                AddBtn.Visible = SpecimensGrid.BlankRows > 0;
            }

            SpecimensGrid.DataSource = specimens;
            SpecimensGrid.DataBind();
        }