/// <summary> /// Builds the data entry interface based on table /// </summary> protected void BuildUnplannedEvent() { // Build UI: build column layout based on default metadata var inputs = CICHelper.GetCaisisInputControlsByTableName(QueryTableName, null); int colCount = new Caisis.Controller.PatientDataEntryController(null).GetNumDisplayColumns(QueryTableName); DataEntryLayout.BuildLayout(inputs, colCount, new string[] { }); // Populate: populate exising record if (!string.IsNullOrEmpty(PriKeyField.Value)) { int priKey = int.Parse(PriKeyField.Value); // load record and populate form var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName); biz.Get(priKey); // populate section with biz base.PopulateForm(DataEntryLayout, biz); // set related record if exists if (!string.IsNullOrEmpty(PatientItemId.Value)) { int patientItemId = int.Parse(base.DecrypyValue(PatientItemId.Value)); RelatedRecord relatedRecord = Caisis.Controller.RelatedRecordController.GetRelatedRecords("ProtocolMgr_PatientItems", patientItemId, QueryTableName, priKey).FirstOrDefault(); if (relatedRecord != null) { RelatedRecordId.Value = relatedRecord[RelatedRecord.RelatedRecordId].ToString(); } } } }
public AdminEditDataEntry() : base() { this.Init += (a, b) => { // initalize the data entry controller in context of current disease, NOT session _dataEntryController = new Caisis.Controller.PatientDataEntryController(QueryDiseaseName); // defaults SetQueryDefaults(); }; }
/// <summary> /// Adds a grid based on the current table name /// </summary> /// <param name="tableName"></param> public virtual void BuildLayout(string tableName) { // validate table if (BusinessObjectFactory.CanBuildBusinessObject(tableName)) { // get config Caisis.Controller.PatientDataEntryController pdec = new Caisis.Controller.PatientDataEntryController(); int totalBlankRows = pdec.GetTotalBlankGridRows(tableName); int totalVisibleBlankRows = pdec.GetVisibleBlankGridRows(tableName); var tableFieldsMetadata = pdec.GetTableFieldsMetadata(tableName); BuildLayout(tableName, totalBlankRows, totalVisibleBlankRows, tableFieldsMetadata); } }
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(); }
protected void PublishTableAudit(object sender, EventArgs e) { bool onlyShowTables = AuditOptions.Items[0].Selected; bool onlyShowConflict = AuditOptions.Items[1].Selected; MetadataNewDa da = new MetadataNewDa(); var pdec = new Caisis.Controller.PatientDataEntryController(null); DataTable dt = da.GetAllTableAndColumns(); var db = from row in dt.AsEnumerable() let table = row["TABLE_NAME"].ToString() let field = row["COLUMN_NAME"].ToString() let pair = new { Table = table, Field = field } group pair by pair.Table into g select new { Table = g.Key, Fields = g.Select(t => t.Field) }; var dbTableNames = db.ToDictionary(a => a.Table, a => a.Fields); var biz = from table in BusinessObject.GetAllTableNames() from field in BusinessObject.GetFieldNames(table) group field by table into g select new { Table = g.Key, Fields = g }; var bizTableName = biz.ToDictionary(a => a.Table, a => a.Fields.Select(f => f)); var allTables = dbTableNames.Keys.Union(bizTableName.Keys).Distinct(); var tableAndFieldAudit = from table in allTables let indb = dbTableNames.ContainsKey(table) let inbiz = bizTableName.ContainsKey(table) let dbFields = indb ? dbTableNames[table] : new string[0] let bizFields = inbiz ? bizTableName[table] : new string[0] let allFields = dbFields.Union(bizFields).Distinct() from field in allFields orderby table, field let fieldInDB = indb && dbFields.Contains(field) let fieldInBiz = inbiz && bizFields.Contains(field) where !onlyShowConflict || fieldInDB != fieldInBiz || (fieldInDB == false && fieldInBiz == false) select new { Table = table, Field = field, InDB = fieldInDB, InBiz = fieldInBiz }; if (onlyShowTables) { tableAndFieldAudit = from t in tableAndFieldAudit group t by t.Table into g select new { Table = g.Key, Field = "", InDB = g.Where(b => b.InDB).Count() == g.Count(), InBiz = g.Where(b => b.InBiz).Count() == g.Count() }; } AuditTableGrid.DataSource = tableAndFieldAudit; AuditTableGrid.DataBind(); }
public AdminEditTableMetadata() : base(new MetadataTable().TableName, new MetadataTableAttribute().TableName, MetadataTableAttribute.TableAttributeName, new MetadataTableAttributeValue().TableName, MetadataTableAttributeValue.TableAttributeValue) { _dataEntryController = new Controller.PatientDataEntryController(QueryDiseaseName); }
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"; } }