Exemplo n.º 1
0
        protected override void PopulateAttributeValues()
        {
            dirtyRows.Clear();
            Caisis.Controller.PatientDataEntryController pdec = new Caisis.Controller.PatientDataEntryController(QueryDiseaseName);

            MetadataDa da = new MetadataDa();
            // step 1: get all tables (optionally filtered attributes by disease)
            var allTables = da.GetAllTableMetadata(null, QueryDiseaseId).AsEnumerable();

            // step 2: get all metadata tables
            var tableLookup = (from table in BOL.BusinessObject.GetAll <MetadataTable>()
                               select new
            {
                TableId = (int)table[MetadataTable.TableId],
                TableName = table[MetadataTable.TableName_Field].ToString()
            }).ToDictionary(a => a.TableName, a => a.TableId);

            // step 3: build lookup of metadata and disease specific mappings
            var metadataLookup = (from row in allTables
                                  let tableId = (int)row[MetadataTable.TableId]
                                                group row by tableId into tableMetadata
                                                let source = tableMetadata.First()
                                                             select new
            {
                TableName = source[MetadataTable.TableName_Field].ToString(),
                TableMetadata = tableMetadata,
                DiseaseAttributes = from record in tableMetadata
                                    where !record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId)
                                    select record
            }).ToDictionary(
                a => a.TableName,
                a => new KeyValuePair <IEnumerable <DataRow>, IEnumerable <DataRow> >
                    (a.TableMetadata,
                    a.DiseaseAttributes)
                );

            // step 4: get tree structure of tables
            var depthMap = Caisis.Controller.PatientDataEntryController.GetPatientDataEntryMapLookup(tableLookup.Keys);

            // step 5: build data grid data source
            var dataSource = from entry in depthMap
                             let table = entry.Key
                                         let tableId = tableLookup[table]
                                                       let tableMetadata = metadataLookup.ContainsKey(table) ? metadataLookup[table].Key : new DataRow[0]
                                                                           let diseaseAttributes = metadataLookup.ContainsKey(table) ? metadataLookup[table].Value : new DataRow[0]
                                                                                                   select new
            {
                TableId           = tableId,
                TableName         = table,
                TableLabel        = pdec.GetTableLabel(table),
                TableIcon         = pdec.GetTableIcon(table, true),
                TableDepth        = depthMap[table],
                Data              = tableMetadata,
                DiseaseAttributes = diseaseAttributes
            };

            //var tablesNames = allTables.Select(r => r[MetadataTable.TableName_Field].ToString()).Distinct();
            //var depthMap = Caisis.Controller.PatientDataEntryController.GetTableDepthMapLookup(tablesNames, true);
            //// build a list of unique metadata tables with there associated metadata
            //var tableToAttributes = from row in allTables
            //                        let tableId = (int)row[MetadataTable.TableId]
            //                        group row by tableId into groupByTable
            //                        let tableName = groupByTable.First()[MetadataTable.TableName_Field].ToString()
            //                        orderby tableName ascending
            //                        select new
            //                        {
            //                            TableId = groupByTable.Key,
            //                            TableName = tableName,
            //                            TableLabel = pdec.GetTableLabel(tableName),
            //                            TableIcon = pdec.GetTableIcon(tableName, true),
            //                            TableDepth = depthMap.ContainsKey(tableName) ? depthMap[tableName] : 0,
            //                            Data = groupByTable,
            //                            DiseaseAttributes = from record in groupByTable
            //                                                where !record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId)
            //                                                select record
            //                        };

            //var dbTables = BOL.BusinessObject.GetAllTableNames();
            //tableToAttributes = from table in dbTables
            //                    join meta in tableToAttributes on table equals meta.TableName
            //                    select meta;

            //// get tables in depth map
            //var hasDepthEntry = from d in depthMap
            //                    join t in tableToAttributes on d.Key equals t.TableName
            //                    select t;
            //// append tables not in depth map
            //var dataSource = hasDepthEntry.Concat(tableToAttributes.Except(hasDepthEntry));


            // bind table attributes data source
            MetadataGrid.DataSource = dataSource;
            MetadataGrid.DataBind();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the friendly table label
 /// </summary>
 /// <param name="table"></param>
 /// <returns></returns>
 protected string GetTableLabel(string table)
 {
     return(!string.IsNullOrEmpty(table) ? _dataEntryController.GetTableLabel(table) : string.Empty);
 }
Exemplo n.º 3
0
        private void BuildInterface(IBusinessObject bizo, string disease)
        {
            string mainFormTable = bizo.TableName;

            // get list of tables, top, down
            List <string> tableNames = _dataEntryController.EnumerateTableNames(mainFormTable, null);
            // append optional query string table names (more tables)
            string queryTableNames = Request.QueryString["tableNames"];

            if (!string.IsNullOrEmpty(queryTableNames))
            {
                var queryTables = queryTableNames.Split(',').Except(tableNames);
                tableNames.AddRange(queryTables);
            }
            // get main table
            string tableName = tableNames.First();
            // sub forms
            var subFormTableNames = tableNames.Where(t => t != tableName);

            // MAIN TABLE

            EditFormBox.Visible = true;
            var inputControls = CICHelper.GetCaisisInputControlsByTableName(tableName, disease);

            // build main data entry
            MainDataEntry.Controls.Clear();
            LoadDataEntryControl(tableName, MainDataEntry, inputControls);

            //SetTableLabel(MainLabel, mainFormTable);
            // build main label using full path of tables
            SetTableLabel(MainLabel, tableNames);
            SetTableIcon(MainTableSpecificIcon, tableName);

            MainLabel.ToolTip = biz.TableName;
            MainMetaTooltip.BuildTooltipTableMetadata(mainFormTable, QueryDiseaseName);

            // set button text
            string btnText = "Edit " + _dataEntryController.GetTableLabel(mainFormTable) + " Form";

            MainDataEntryEditBtn.InnerText           = btnText;
            MainDataEntryEditBtn.Attributes["title"] = btnText;

            // CHILD TABLES
            foreach (var childTable in subFormTableNames)
            {
                string title = GetTableLabel(childTable);

                Panel childContainer = new Panel();
                Tabs.AddTab(title, childContainer);
                var childControls = CICHelper.GetCaisisInputControlsByTableName(childTable);
                LoadDataEntryControl(childTable, childContainer, childControls);
            }

            // set child container visibility
            ChildTableContainer.Visible = subFormTableNames.Count() > 0;

            // set table desc
            string mainFormTableDesc = _dataEntryController.GetTableDescription(mainFormTable);

            TableDescLabel.Text = mainFormTableDesc;

            // set sub form label
            if (subFormTableNames.Count() > 0)
            {
                var    childLabels    = subFormTableNames.Select(t => GetTableLabel(t)).ToArray();
                string childFullLabel = string.Join(", ", childLabels);
                // trim long lists
                SubFormsLabel.Text = childFullLabel.Length > 25 ? childFullLabel.Substring(0, 25) + "..." : childFullLabel;
                // display full list on tooltip
                SubFormsLabel.ToolTip = childFullLabel;
            }
            else
            {
                SubFormsLabel.Text    = "N/A";
                SubFormsLabel.ToolTip = "N/A";
            }

            // MORE TABLES (comment section to supress adding more tabs)
            //var allChildTables = _dataEntryController.GetChildDataEntryForms(mainFormTable);
            //// children + not in current list
            //var moreTables = allChildTables.Except(tableNames);
            //if (moreTables.Count() > 0)
            //{
            //    string baseURL = "AdminEditDataEntry.aspx?diseaseId=" + QueryDiseaseId + "&tableId=" + QueryTableId + "&scrollX=" + ScrollX + "&tableNames=";
            //    foreach (string table in moreTables)
            //    {
            //        string tableLabel = _dataEntryController.GetTableLabel(table);
            //        string tabURL = baseURL + string.Join(",", tableNames.Concat(new string[] { table }).ToArray());
            //        LinkButton link = new LinkButton();
            //        link.Text = tableLabel;
            //        link.OnClientClick = "window.location = '" + tabURL + "'; return false;";
            //        Tabs.AddMoreTab(link);
            //    }
            //}

            // set layout text
            bool isGrid   = _dataEntryController.IsGridView(mainFormTable);
            int  colCount = _dataEntryController.GetNumDisplayColumns(mainFormTable);

            TableLayoutType.Text = isGrid ? "Grid" : (colCount + " Columns");
        }
        private void PreviewExportProtocolPatients(int protocolId)
        {
            string datasetSQL         = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            bool   canViewIdentifiers = new Caisis.Controller.UserController().CanViewPatientIdentifiers();
            bool   includeDeceased    = ExportProtocolIncludeDeceased.Checked;
            bool   unmaskedDates      = UnmaskedCheck.Checked;

            // get all patients on protocol
            var allPatients      = Caisis.DataAccess.ProtocolMgmtDa.GetPatientsByProtocol(protocolId, datasetSQL, canViewIdentifiers, includeDeceased);
            var eligiblePatients = ProtocolMgmtServices.GetEligibleProtocolExportPatients(datasetSQL, protocolId, unmaskedDates);
            // create view of data, validating exportable patients
            var exportPatientsView = from record in allPatients.AsEnumerable()
                                     let ptProtocolId = (int)record[PatientProtocol.PatientProtocolId]
                                                        let patientId                                                     = (int)record["PatientId"]
                                                                                             let name                     = record["Name"].ToString()
                                                                                                                  let mrn = record["PtMRN"].ToString()
                                                                                                                            let screeningId = record["PtProtocolScreeningId"].ToString()
                                                                                                                                              let studyId = record["PtProtocolStudyId"].ToString()
                                                                                                                                                            let schemaId = record["ProtocolSchemaId"].ToString()
                                                                                                                                                                           let schema = GetSchemaName(schemaId)
                                                                                                                                                                                        let eligibleRecord = eligiblePatients.Select(PatientProtocol.PatientProtocolId + " = " + ptProtocolId).FirstOrDefault()
                                                                                                                                                                                                             let isExportable                         = eligibleRecord != null
                                                                                                                                                                                                                                            let ptAge = isExportable ? eligibleRecord[PatientProtocolRegistration.PtRegistrationAge].ToString() : ""
                                                                                                                                                                                                                                                        let passedScreeningDate = isExportable ? (DateTime?)eligibleRecord["PassedScreeningDate"] : null
                                                                                                                                                                                                                                                                                  orderby name ascending// isExportable ? 0 : 1 ascending, studyId ascending
                                                                                                                                                                                                                                                                                  select new
            {
                Exportable          = isExportable ? "Yes" : "No",
                PatientId           = patientId,
                Arm                 = schema,
                Name                = name,
                MRN                 = mrn,
                RegistrationAge     = ptAge,
                ScreeningId         = screeningId,
                StudyId             = studyId,
                PassedScreeningDate = string.Format("{0:d}", passedScreeningDate)
            };

            ExportProtocolPatientsControls.Visible = true;
            ExportProtocolPatientsBtns.Visible     = true;

            // set count
            int totalPatientsCount    = exportPatientsView.Count();
            int eligiblePatientsCount = exportPatientsView.Where(p => p.Exportable == "Yes").Count();

            ExportPatientCount.Text = string.Format("<b>{0}</b> of <b>{1}</b> patients eligible for export.", eligiblePatientsCount, totalPatientsCount);

            // build patient export preview
            DataPreview.DataKeyNames = new string[] { Patient.PatientId };
            DataPreview.DataSource   = exportPatientsView;
            DataPreview.DataBind();
            DataPreview.Columns[0].Visible = true;

            // build patient export tables
            var exportTableNames = from table in ProtocolMgmtServices.GetPatientTableNames()
                                   let label = pdec.GetTableLabel(table)
                                               orderby table == "Patients" ? 0 : 1 ascending, label ascending
                select new
            {
                TableName  = table,
                TableLabel = string.Format("{0} [{1}]", label, table)
            };

            ExportTableNames.DataSource = exportTableNames;
            ExportTableNames.DataBind();

            // set header
            SetProtocolTitle(protocolId);

            // set dataset
            var dataset = new BOL.Dataset();

            dataset.Get(int.Parse(Session[SessionKey.DatasetId].ToString()));
            string datasetName = dataset[BOL.Dataset.DatasetName].ToString();

            CurrentDataset.Text = datasetName;

            // set filter text
            MaskedDatesPanel.Visible   = !unmaskedDates;
            UnmaskedDatesPanel.Visible = unmaskedDates;
        }
Exemplo n.º 5
0
        override protected void Page_Load(object sender, System.EventArgs e)
        {
            if (Request.QueryString["helpSection"] != null)
            {
                helpSection = Server.UrlDecode(Request.QueryString["helpSection"]);
                HelpDa hda = new HelpDa();


                // patient data section is a special section, the rest are in else statement
                if (helpSection.ToUpper() == "PATIENT DATA" || helpSection.ToUpper() == "WORKFLOWS")
                {
                    if (Session[SessionKey.CurrentPage] != null)
                    {
                        pageName = Session[SessionKey.CurrentPage].ToString();
                    }
                    else
                    {
                        pageName = "none";                         // no current Page
                    }


                    //pageTitle.Text = pageName;

                    //DataSet hds = hda.GetHelpTableDescription(pageName);
                    //DataTable PageHelpDt = hds.Tables[0];

                    //DataTable PageHelpDt = GetPageHelp(pageName);
                    //if (PageHelpDt.Rows.Count > 0)
                    //{
                    //    pageDescription.Text = PageHelpDt.Rows[0]["TableDescription"].ToString();
                    //}


                    //REPLACE HERE
//					DataTable FieldHelpDt = GetFieldHelp(pageName);

                    //DataSet FieldHelpDs = hda.GetHelpFieldDescriptionsWithLabels(pageName);
                    //DataTable FieldHelpDt = FieldHelpDs.Tables[0];

                    //if (FieldHelpDt.Rows.Count > 0)
                    //{
                    //    ItemsOnThisPage.Visible = true;
                    //    rptFieldDesciptions.DataSource = FieldHelpDt;
                    //    rptFieldDesciptions.DataBind();
                    //}

                    // v6
                    pageTitle.Text = pageName;

                    Caisis.Controller.PatientDataEntryController pdec = new Caisis.Controller.PatientDataEntryController();
                    if (pdec.IsTable(pageName))
                    {
                        // build table label and description
                        string tableName  = pageName;
                        string tableLabel = pdec.GetTableLabel(tableName);
                        pageTitle.Text = tableLabel;

                        string tableDescription = pdec.GetTableDescription(tableName);
                        if (!string.IsNullOrEmpty(tableDescription))
                        {
                            pageDescription.Text = tableDescription;
                        }

                        // build fields (match data entry fields)
                        var dataEntryFields = from field in CICHelper.GetCaisisInputControlsByTableName(tableName)
                                              select new
                        {
                            Field            = field.Field,
                            FieldLabel       = !string.IsNullOrEmpty(field.FieldLabel) ? field.FieldLabel : field.Field,
                            FieldDescription = !string.IsNullOrEmpty(field.HelpDescription) ? field.HelpDescription : "(No Description)"
                        };
                        rptFieldDesciptions.DataSource = dataEntryFields;
                        rptFieldDesciptions.DataBind();
                    }
                }
                else
                {
                    switch (Server.UrlDecode(Request.QueryString["helpSection"]).ToUpper())
                    {
                    case "PATIENT LISTS":
                        pageTitle.Text = "Patient List";
                        break;

                    case "PATIENT DATA":
                        pageTitle.Text = "Patient Data";
                        break;

                    case "SPLASH":
                        pageTitle.Text = "Caisis Home Page";
                        break;

                    case "FORMS":
                        pageTitle.Text = "Forms";
                        break;

                    case "REPORTS":
                        pageTitle.Text = "Reports";
                        break;

                    case "ADMIN":
                        pageTitle.Text = "Caisis Admin";
                        break;


                    case "NEWTOCAISIS":
                        pageTitle.Text             = "Getting Started";
                        ItemsOnThisPageRow.Visible = true;
                        ItemsOnThisPage.Visible    = true;
                        ItemsOnThisPage.Text       = "Caisis is a Cancer Database designed to bridge the gap between Clinical Research and Clinical Practice. The project was started with the goal of improving data quality and accuracy while reducing time and effort for clinicians trying to summarize and document patient histories. Currently, data is captured in the Caisis Database electronically then printed on to billing and compliant paper forms used for documentation purposes. A long term goal of the project is to replace these paper forms with wireless tablet PCs that reduce reliance on trained data management staff and decrease the turnaround time for data capture.<br><br>There are five major sections to this application, <a href=\"HelpPage.aspx?helpSection=PatientList\">Patient Lists</a>, <a href=\"HelpPage.aspx?helpSection=PatientDataSection\">Patient Data</a>, <a href=\"HelpPage.aspx?helpSection=Forms\">Forms</a>, <a href=\"HelpPage.aspx?helpSection=Reports\">Reports</a>, and the <a href=\"HelpPage.aspx?helpSection=Admin\">Admin</a>. Of these sections, the average user will have access to four of the sections. The fifth section, the Admin, will only be available if you have permissions to administer the application.";
                        break;

                    default:
                        pageTitle.Text = "Help Unavailable";
                        break;
                    }

                    //REPLACE HERE
//					pageDescription.Text = GetSectionHelp(Request.QueryString["helpSection"]);

                    //DataSet hsDs = hda.GetHelpSectionName(helpSection);
                    //DataTable SectionHelpDt = hsDs.Tables[0];
                    //DataTable PageHelpDt = GetPageHelp(pageName);
                    //if (SectionHelpDt.Rows.Count > 0)
                    //{
                    //    pageDescription.Text = SectionHelpDt.Rows[0]["HelpSectionDescription"].ToString();
                    //}

                    // v6
                    var sections = BOL.BusinessObject.GetByFields <BOL.HelpSection>(new Dictionary <string, object>
                    {
                        { BOL.HelpSection.HelpSectionName, helpSection }
                    });
                    if (sections.Count() > 0)
                    {
                        pageDescription.Text = sections.First()[BOL.HelpSection.HelpSectionDescription].ToString();
                    }
                }
            }
            else
            {
                pageTitle.Text = "Help Unavailable";
            }
        }