Exemplo n.º 1
0
    /* IMPORT THE DATA */

    protected void ImportREDCapToDB()
    {
        string info;

        DateTime startupload = DateTime.Now;

        info = String.Format("Begin. {0}<br/>", startupload.ToString());

        string ID          = cboSubject.Value.ToString();
        int    studymeasID = Convert.ToInt32(cboStudymeas.Value.ToString());
        REDCap redcap      = new REDCap(Master.Master_studyID);

        if (redcap.IsREDCapMeasure(studymeasID))
        {
            DataTable     dt_forms  = DataImporter.LinkedREDCapForms(Master.Master_studyID, studymeasID, DbEntityType.studymeas);
            List <string> formnames = dt_forms.AsEnumerable().Select(f => f.Field <string>("form_name")).ToList();


            DataImporter importer = new DataImporter(ID, studymeasID, formnames);
            info += importer.ResultsToString();
        }

        double timeelapsed = Math.Round((DateTime.Now - startupload).TotalSeconds, 2);

        info += String.Format("<br/> End. {0} total seconds.", timeelapsed);

        DisplayImporterResults(info);
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Debug.WriteLine(String.Format("Page_Load  IsPostBack:{0}  IsCallback:{1}", IsPostBack, IsCallback));


        //LoadSubjects();
        LoadREDCapMeasures();

        LoadlinkedTables();

        redcap = new REDCap(Master.Master_studyID);

        //ASPxComboBox cbo = redcap.cboFormSelector();

        ASPxListBox lst = redcap.lstFormSelector();


        //if (lst != null)
        //{
        //	lst.EnableViewState = true;
        //	//placeholder_cboForms.Controls.Add(cbo);
        //	placeholder_cboForms.Controls.Add(lst);
        //	panelREDCap_controls.Visible = true;
        //}
        //else {
        //	panelREDCap_controls.Visible = false;
        //}

        LoadlinkedTables();
        //btnImportMeta.Visible = false;

        if (IsCallback)
        {
            //if (Session["redcap_metadata"] != null)
            //{
            //	gridREDCap.DataSource = (DataTable)Session["redcap_metadata"];
            //	gridREDCap.DataBind();
            //}
        }
        if (panel.IsCallback)
        {
            //LoadFormData();
        }

        //Load the comparison between selected measure and Redcap
        CompareLinkedRedcap();
    }
Exemplo n.º 3
0
    protected void btnShowREDCap_OnClick(object sender, EventArgs e)
    {
        string ID          = cboSubject.Value.ToString();
        int    studymeasID = Convert.ToInt32(cboStudymeas.Value.ToString());
        REDCap redcap      = new REDCap(Master.Master_studyID);

        if (redcap.IsREDCapMeasure(studymeasID))
        {
            DataTable     dt_forms  = DataImporter.LinkedREDCapForms(Master.Master_studyID, studymeasID, DbEntityType.studymeas);
            List <string> formnames = dt_forms.AsEnumerable().Select(f => f.Field <string>("form_name")).ToList();

            ASPxGridView grid = redcap.gridDataFromForm(formnames);
            if (grid != null)
            {
                placeholder_REDCap_data.Controls.Clear();
                placeholder_REDCap_data.Controls.Add(grid);
            }
        }
    }
Exemplo n.º 4
0
    protected void CompareLinkedRedcap()
    {
        if (cboMeas.Value != null)
        {
            int measureID = Convert.ToInt32(cboMeas.Value.ToString());

            Datadictionary dict = new Datadictionary(measureID);

            REDCap redcap = new REDCap(Master.Master_studyID);

            DataTable foo = redcap.dt_metadata;

            var x =
                from a in dict.dt_dict.AsEnumerable()
                join b in redcap.dt_metadata.AsEnumerable() on a.Field <string>("fldname_in_redcap").ToLower() equals b.Field <string>("field_name").ToLower()
                into ab
                from b in ab.DefaultIfEmpty()
                select new
            {
                ord_pos         = a.Field <double>("ord_pos"),
                fldname         = a.Field <string>("fldname").ToLower(),
                fldlabel        = a.Field <string>("fieldlabel"),
                redcap_formname = (b == null) ? null : b.Field <string>("form_name"),
                redcap_fldname  = (b == null) ? null : b.Field <string>("field_name"),
                redcap_fldlabel = (b == null) ? null : b.Field <string>("field_label")
            };

            DataTable dtMerged = x.CustomCopyToDataTable();



            if (dtMerged.HasRows())
            {
                gridMerged.DataSource             = dtMerged;
                gridMerged.SettingsPager.PageSize = 200;
                gridMerged.DataBind();
                gridMerged.Caption  = "Matched Fields between DB & REDCap: " + cboMeas.Text;
                panelMerged.Visible = true;
            }
        }
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Debug.WriteLine(String.Format("Page_Load  IsPostBack:{0}  IsCallback:{1}", IsPostBack, IsCallback));


        GridViewDataComboBoxColumn cbo = ((GridViewDataComboBoxColumn)gv_Redcap_FormEvent.Columns["studymeasid"]);

        cbo.PropertiesComboBox.DataSource = GetStudymeasids();


        //LoadSubjects();
        LoadREDCapMeasures();

        LoadlinkedTables();

        redcap = new REDCap(Master.Master_studyID);



        //ASPxComboBox cbo = redcap.cboFormSelector();

        ASPxListBox lst = redcap.lstFormSelector_with_studymeasID();

        ASPxComboBox cboForms = redcap.cboFormSelector();

        if (cboForms != null)
        {
            cboForms.SelectedIndexChanged += cboForm_OnSelectedIndexChanged;
            cboForms.ID = "cboForms";

            placeholder.Controls.Add(cboForms);
            //tab_import_fields.Controls.Add(cboForms);
        }

        if (lst != null)
        {
            lst.EnableViewState = true;
            //placeholder_cboForms.Controls.Add(cbo);
            placeholder_cboForms.Controls.Add(lst);
            panelREDCap_controls.Visible = true;
        }
        else
        {
            panelREDCap_controls.Visible = false;
        }

        LoadlinkedTables();

        if (IsCallback)
        {
            //if (Session["redcap_metadata"] != null)
            //{
            //	gridREDCap.DataSource = (DataTable)Session["redcap_metadata"];
            //	gridREDCap.DataBind();
            //}
        }
        if (panel.IsCallback)
        {
            //LoadFormData();
        }

        //Load the comparison between selected measure and Redcap
        CompareLinkedRedcap();
    }