/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveClick(object sender, EventArgs e) { // if editing last dirty row, show more bool rebindToEdit = dirtyRows.Contains(ReadOnlyLogRptr.Items.Count - 1); // update/insert "dirty" records foreach (int dirtyRowIndex in dirtyRows) { RepeaterItem item = ReadOnlyLogRptr.Items[dirtyRowIndex]; // get pri key CaisisHidden priKeyField = item.FindControl("CommunicationLogIdField") as CaisisHidden; ProjectCommunicationLog biz = new ProjectCommunicationLog(); // update if (!string.IsNullOrEmpty(priKeyField.Value)) { int priKey = int.Parse(priKeyField.Value); biz.Get(priKey); } // fill Biz with field values CICHelper.SetBOValues(item.Controls, biz, projectId); // update/insert biz.Save(); } dirtyRows.Clear(); SetEditState(rebindToEdit); // rebind to reflect changes BindCommunicationLog(); }
private void AddDynamicAttributes() { // FIELD ATTRIBUTES var excludedFieldAttributes = GetExcludedAttributes(); var missingFieldAttributes = from b in BOL.BusinessObject.GetAll <MetadataFieldAttribute>() let attribute = b[MetadataFieldAttribute.AttributeName].ToString() let attributeId = (int)b[MetadataFieldAttribute.AttributeId] // exclude attributes in list where !excludedFieldAttributes.Contains(attribute, StringComparer.OrdinalIgnoreCase) orderby attribute ascending select new { Attribute = attribute, AttributeOptions = BOL.BusinessObject.GetByParent <MetadataFieldAttributeValueOption>(attributeId).Select(option => option[BOL.MetadataFieldAttributeValueOption.AttributeOptionValue].ToString()) }; // set list of misc attributes miscFieldAttributes = missingFieldAttributes.ToDictionary(a => a.Attribute, a => a.AttributeOptions); // dynamically add to attribute id container foreach (string miscAttribute in miscFieldAttributes.Keys) { CaisisHidden attributeField = new CaisisHidden(); attributeField.Table = "MetadataFieldAttributes"; attributeField.Field = miscAttribute; attributeField.ID = miscAttribute + "_FieldAttributeId"; MetadataAttributesContainer.Controls.Add(attributeField); } }
/// <summary> /// For the specified table, return a list of input fields /// </summary> /// <param name="table"></param> /// <returns></returns> protected List <ICaisisInputControl> GetInputControls(string table) { // get a list of controls by table List <ICaisisInputControl> inputs = CICHelper.GetCaisisInputControlsByTableName(table); // cleanup foreach (ICaisisInputControl input in inputs) { // supress labels input.ShowLabel = false; // trigger calc date on text fields if (input is CaisisTextBox && input.Field.EndsWith("DateText")) { CaisisTextBox ctb = input as CaisisTextBox; ctb.Attributes["onblur"] = "UpdateDate(this);"; } // cleanup spacer on date fields if (input is CaisisHidden) { CaisisHidden hiddenInput = input as CaisisHidden; if (hiddenInput.DisplayCalculatedDate) { hiddenInput.ShowSpacer = false; } } } return(inputs); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UpdateStatusClick(object sender, EventArgs e) { foreach (int dirtyRow in dirtyVisits) { GridViewRow row = PatientVisitsGrid.Rows[dirtyRow]; CaisisHidden pItemStatus = row.FindControl(PatientItem.Status) as CaisisHidden; CaisisTextBox pItemSDate = row.FindControl(PatientItem.ScheduledDate) as CaisisTextBox; CaisisHidden deviationId = row.FindControl(PatientDeviation.PatientDeviationId) as CaisisHidden; int patientItemId = int.Parse(PatientVisitsGrid.DataKeys[dirtyRow][PatientItem.PatientItemId].ToString()); string patientItemStatus = pItemStatus.Value; string scheduledDate = pItemSDate.Value; PatientItem biz = new PatientItem(); biz.Get(patientItemId); biz[PatientItem.Status] = patientItemStatus; biz[PatientItem.ScheduledDate] = scheduledDate; // needs deviation ??? if (patientItemStatus == "Missed") { // do not create deviation /* * PatientDeviation deviation = new PatientDeviation(); * if (!string.IsNullOrEmpty(deviationId.Value)) * { * deviation.Get(int.Parse(deviationId.Value)); * } * // otherwise set required foreign key * else * { * deviation[PatientDeviation.PatientItemId] = patientItemId.ToString(); * } * deviation[PatientDeviation.DeviationType] = "Missed Visit"; * deviation.Save(); * * // update hidden deviation field * deviationId.Value = deviation[PatientDeviation.PatientDeviationId].ToString(); */ } // if status isn't missed, remove deviation if exists else if (!string.IsNullOrEmpty(deviationId.Value)) { PatientDeviation deviation = new PatientDeviation(); deviation.Delete(int.Parse(deviationId.Value)); deviationId.Value = string.Empty; } biz.Save(); // trigger scheduling for dependent items PatientProtocolController.ScheduleDependentItemsByItemStatus(patientItemId, patientItemStatus); } dirtyVisits.Clear(); SetVisit(sender, e); RegisterReloadPatientLists(); }
protected void SetStatusValue(object sender, EventArgs e) { CheckBox statusCheck = sender as CheckBox; CaisisHidden statusField = statusCheck.NamingContainer.FindControl(statusCheck.ID.Replace("_Check", "")) as CaisisHidden; if (statusCheck.Checked && string.IsNullOrEmpty(statusField.Value)) { statusField.Value = "Collected"; } }
protected void SetSpecimenDisplay(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ICaisisInputControl specimenRefNumInput = e.Row.FindControl(Specimen.SpecimenReferenceNumber) as ICaisisInputControl; ICaisisInputControl specimenTypeInput = e.Row.FindControl(Specimen.SpecimenType) as ICaisisInputControl; ICaisisInputControl specimenSubTypeInput = e.Row.FindControl(Specimen.SpecimenSubType) as ICaisisInputControl; ICaisisInputControl specimenVialTypeInput = e.Row.FindControl(Specimen.SpecimenVialType) as ICaisisInputControl; ICaisisInputControl processingMethodInput = e.Row.FindControl(Specimen.SpecimenPreservationType) as ICaisisInputControl; bool isBlankRow = DataBinder.Eval(e.Row.DataItem, Specimen.SpecimenId).ToString() == ""; string specimenRefNum = DataBinder.Eval(e.Row.DataItem, Specimen.SpecimenReferenceNumber).ToString(); // format Specimen Type if (string.IsNullOrEmpty(specimenTypeInput.Value)) { specimenTypeInput.Value = QuerySpecimenType; } // special: lookup codes if (QuerySpecimenType == QUERY_BLOOD) { (processingMethodInput as ICaisisLookupControl).LookupCode = "Specimen_PreservationType_Blood"; (specimenSubTypeInput as ICaisisLookupControl).LookupCode = "Specimen_SubType_Blood"; // special default values bool setPreGeneratedBloodSpecimens = !AccessionVisit.Enabled; if (isBlankRow && setPreGeneratedBloodSpecimens) { int index = e.Row.RowIndex; if (index + 1 <= bloodAutoSpecimens.Length) { var specimenDefault = bloodAutoSpecimens[index]; specimenRefNumInput.Value = specimenDefault.SpecimenReferenceNumber; specimenSubTypeInput.Value = specimenDefault.SubType; specimenVialTypeInput.Value = specimenDefault.VialType; } } } else if (QuerySpecimenType == QUERY_TISSUE) { (processingMethodInput as ICaisisLookupControl).LookupCode = "Specimen_PreservationType_Tissue"; (specimenSubTypeInput as ICaisisLookupControl).LookupCode = "Specimen_SubType_Tissue"; } // set collected checkbox string status = DataBinder.Eval(e.Row.DataItem, BOL.Specimen.SpecimenStatus).ToString(); CheckBox statusCheck = e.Row.FindControl("SpecimenStatus_Check") as CheckBox; CaisisHidden statusField = e.Row.FindControl("SpecimenStatus") as CaisisHidden; statusField.Value = status; if (!string.IsNullOrEmpty(status)) { statusCheck.Checked = true; } } }
/// <summary> /// Add missing table and field attributes to the interface /// </summary> private void AddDynamicAttributes() { // TABLE ATTRIBUTES var allTableAttributes = BOL.BusinessObject.GetAll <MetadataTableAttribute>().ToDictionary(b => b[MetadataTableAttribute.TableAttributeName].ToString(), b => (int)b[MetadataTableAttribute.TableAttributeId]); var staticTableAttributes = GetAttributeToHiddenFields(TableAttributesPanel).Keys; miscTableAttributes = from attribute in allTableAttributes.Keys.Except(staticTableAttributes, StringComparer.OrdinalIgnoreCase) orderby attribute ascending select attribute; foreach (string attribute in miscTableAttributes) { // add attributes CaisisHidden attributeField = new CaisisHidden(); attributeField.Table = "MetadataTableAttributes"; attributeField.Field = attribute; attributeField.ID = attribute + "_Id"; TableAttributesPanel.Controls.Add(attributeField); // add attribute values DynamicallyAddAttribute(TableMiscAttributesPanel, attribute, "MetadataTableAttributeValues", new string[0]); } // FIELD ATTRIBUTES //var staticFieldAttributes = GetAttributeToHiddenFields(MetadataAttributesContainer).Keys; //// field attributes not defined (i.e., misc) //var missingFieldAttributes = from b in BOL.BusinessObject.GetAll<MetadataFieldAttribute>() // let attribute = b[MetadataFieldAttribute.AttributeName].ToString() // let attributeId = (int)b[MetadataFieldAttribute.AttributeId] // where !staticFieldAttributes.Contains(attribute) // orderby attribute ascending // select new // { // Attribute = attribute, // AttributeOptions = BOL.BusinessObject.GetByParent<MetadataFieldAttributeValueOption>(attributeId).Select(option => option[BOL.MetadataFieldAttributeValueOption.AttributeOptionValue].ToString()) // }; //miscFieldAttributes = missingFieldAttributes.ToDictionary(a => a.Attribute, a => a.AttributeOptions); //// dynamically add to attribute id container //foreach (string miscAttribute in miscFieldAttributes.Keys) //{ // CaisisHidden attributeField = new CaisisHidden(); // attributeField.Table = "MetadataFieldAttributes"; // attributeField.Field = miscAttribute; // attributeField.ID = miscAttribute + "_FieldAttributeId"; // MetadataAttributesContainer.Controls.Add(attributeField); //} }
/// <summary> /// /// </summary> /// <param name="container"></param> /// <param name="attributeName"></param> /// <param name="attributeValueTable"></param> /// <param name="attributeValueOptions"></param> private void DynamicallyAddAttribute(Control container, string attributeName, string attributeValueTable, IEnumerable <string> attributeValueOptions) { HtmlGenericControl attributeWrapper = new HtmlGenericControl("div"); Label attributeValueLabel = new Label(); CaisisHidden valueIdField = new CaisisHidden(); CaisisHidden diseaseAttributeValueId = new CaisisHidden(); ICaisisInputControl attributeValue; // if attribute options assigned, build options if (attributeValueOptions.Count() > 0) { CaisisSelect attributeValuesInput = new CaisisSelect(); attributeValue = attributeValuesInput; attributeValuesInput.DataSource = attributeValueOptions; attributeValuesInput.DataBind(); } else { attributeValue = new CaisisTextBox(); } attributeWrapper.Attributes["class"] = "attributeFieldWrapper"; attributeValueLabel.ID = attributeName + "_Label"; attributeValueLabel.Text = attributeName; valueIdField.ID = attributeName + "_ValueId"; valueIdField.Table = attributeValueTable; valueIdField.Field = attributeName; diseaseAttributeValueId.ID = attributeName + "_DiseaseAttributeValueId"; diseaseAttributeValueId.Table = "DiseaseAttributeValues"; diseaseAttributeValueId.Field = attributeName; Control inputAttributeValue = attributeValue as Control; inputAttributeValue.ID = attributeName; attributeValue.ShowLabel = false; attributeValue.Table = attributeValueTable; attributeValue.Field = attributeName; attributeValueLabel.AssociatedControlID = inputAttributeValue.ID; container.Controls.Add(attributeWrapper); attributeWrapper.Controls.Add(attributeValueLabel); attributeWrapper.Controls.Add(valueIdField); attributeWrapper.Controls.Add(diseaseAttributeValueId); attributeWrapper.Controls.Add(inputAttributeValue); }
protected void AddDynamicControls(object sender, RepeaterItemEventArgs e) { RepeaterItem ItemRow = e.Item; if (ItemRow.ItemType == ListItemType.Item || ItemRow.ItemType == ListItemType.AlternatingItem) { PlaceHolder cicControlHolder = ItemRow.FindControl("cicControlHolder") as PlaceHolder; // Get Hidden Value contained in the parent row RepeaterItem parentRepeaterItem = ((Repeater)sender).Parent as RepeaterItem; if (parentRepeaterItem != null) { CaisisHidden fieldRowIndex = parentRepeaterItem.FindControl("FieldRowIndex") as CaisisHidden; CaisisHidden schemaItemFieldId = ItemRow.FindControl("SchemaItemFieldId") as CaisisHidden; if (cicControlHolder != null) { cicControlHolder.Controls.Add(ItemRow.DataItem as Control); ICaisisInputControl cic = ItemRow.DataItem as ICaisisInputControl; if (cic != null) { if (existingData.ContainsKey(fieldRowIndex.Value)) { Dictionary <string, DataRow> rowData = existingData[fieldRowIndex.Value]; if (rowData.ContainsKey(cic.Field)) { if (!IsPostBack) { cic.Value = rowData[cic.Field]["DestValue"].ToString(); } // Set hidden field with SchemaitemFieldId if (schemaItemFieldId != null) { schemaItemFieldId.Value = rowData[cic.Field][SchemaItemField.SchemaItemFieldId].ToString(); } } } AdjustFieldValueLoad(cic); } } } } }
/// <summary> /// Updates an existing LookupAttribute record, or inserts new record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UpdateAttribute(object sender, EventArgs e) { CaisisTextBox attributeNameField = sender as CaisisTextBox; CaisisHidden attributeIdField = attributeNameField.NamingContainer.FindControl("AttributeId") as CaisisHidden; if (!string.IsNullOrEmpty(attributeNameField.Value)) { // don't inesrt empty attribut names LookupAttribute biz = new LookupAttribute(); // determine if updating or inserting if (attributeIdField != null && !string.IsNullOrEmpty(attributeIdField.Value)) { biz.Get(int.Parse(attributeIdField.Value)); } biz[LookupAttribute.AttributeName] = attributeNameField.Value; biz.Save(); } }
/// <summary> /// Updates all "dirty" DxImageFinding Rptr items. /// </summary> private void UpdateDxImageFindings() { // Iterate through each "dirty" image finding record foreach (RepeaterItem item in dirtyDxImageFindings) { // Locate PriKey Field for ImageFinding CaisisHidden imageFindingId = item.FindControl("ImageFindingId") as CaisisHidden; // dirtyItems index is same as Diganostic column index, to find diagnosticid CaisisHidden diagnosticId = DiagnosticsHeaderRptr.Items[item.ItemIndex].FindControl("DiagnosticIdField") as CaisisHidden; // Main Data Entry Field Control petFields = item.FindControl("PET_Fields"); Control ctMRIFields = item.FindControl("CTMRI_Fields"); Control shareFields = item.FindControl("SHARED_Fields"); Control mainFields = ImageType == "PET" ? petFields : ctMRIFields; CaisisTextBox mainDataEntryField = FindInputControl(mainFields, MainDataEntryField) as CaisisTextBox; ImageFinding biz = new ImageFinding(); // determine if updating if (!string.IsNullOrEmpty(imageFindingId.Value)) { int priKey = int.Parse(imageFindingId.Value); // deleting and go to next item if (string.IsNullOrEmpty(mainDataEntryField.Value)) { biz.Delete(priKey); continue; } // updating else { biz.Get(priKey); } } // Get Parent Key int parKey = int.Parse(diagnosticId.Value); // Set BusinessObject fields based on controls in data entry cell CICHelper.SetBOValues(shareFields.Controls, biz, parKey); CICHelper.SetBOValues(mainFields.Controls, biz, parKey); // save Image Finding biz.Save(); } dirtyDxImageFindings.Clear(); }
protected void BindOrganizationsAndContacts(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Get the org drop down, contact drop down and contactid hidden field CaisisSelect organizationIdField = e.Row.FindControl("OrganizationEdit") as CaisisSelect; HtmlSelect contactDropDown = e.Row.FindControl("ContactNameEdit") as HtmlSelect; CaisisHidden contactIdField = e.Row.FindControl("ContactId") as CaisisHidden; // Attach change events to the dropdowns to handle respective client events string onOrgChange = "onOrgChange(this,'" + organizationIdField.ClientID + "','" + contactDropDown.ClientID + "');"; PageUtil.AttachClientEventToControl(organizationIdField as WebControl, "onchange", onOrgChange); string onContactSelChange = "copyToContactId(this,'" + contactIdField.ClientID + "');"; contactDropDown.Attributes["onchange"] = onContactSelChange; // Populate Organizations and Contacts organizationIdField.DataSource = orgList; organizationIdField.DataBind(); string orgId = DataBinder.Eval(e.Row.DataItem, "OrganizationId").ToString(); // Set selected orgid organizationIdField.Value = orgId; // Populate Contacts if (!string.IsNullOrEmpty(orgId)) { ProjectManagementDa da = new ProjectManagementDa(); DataTable contacts = da.GetAllContactsByOrgId(int.Parse(orgId)); contactDropDown.DataSource = contacts; contactDropDown.DataBind(); // Add blank item at beginning contactDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty)); // Set value of associated contact string contactId = DataBinder.Eval(e.Row.DataItem, "ContactId").ToString(); if (!string.IsNullOrEmpty(contactId)) { contactDropDown.Value = contactId; contactIdField.Value = contactId; } } } }
public override void SaveControl(int schemaItemId, bool bParentTable, bool bCreateNew) { Panel pnl = Page.FindControl(TableName + "Holder") as Panel; if (pnl != null) { // primary key for already saved values int nPrimaryKey = -1; int nFieldRowIndex = -1; // if FieldRowIndex hidden field is set to -1 then delete the record // otherwise, insert the record bool bSkipRow = true; Row_Actions action = Row_Actions.Update; int DisplayOrder = 0; foreach (ICaisisInputControl c in ExtractCaisisInputControls(pnl)) { if (c is CaisisHidden && (c.Field == null || !c.Field.EndsWith("Date"))) { CaisisHidden csHidden = c as CaisisHidden; if (csHidden.ID == "SchemaItemFieldId") { Int32.TryParse(csHidden.Value, out nPrimaryKey); if (bCreateNew) { nPrimaryKey = -1; } } else if (csHidden.ID == "FieldRowIndex") { DisplayOrder = 0; // Adjust FieldRowIndex so they are sequential if (!String.IsNullOrEmpty(csHidden.Value)) { bSkipRow = false; if (csHidden.Value == "-1") { action = Row_Actions.Delete; } else { action = Row_Actions.Update; nFieldRowIndex++; } } else { bSkipRow = true; } } } else if (!bSkipRow) { // if no check boxes checked and a new record, don't save if (!OptionsSelected() && nPrimaryKey <= 0) { continue; } SchemaItemField field = new SchemaItemField(); field.Get(nPrimaryKey); // If csHidden.Value == -1 then delete if (action == Row_Actions.Update) { AdjustFieldValueSave(c); if (!String.IsNullOrEmpty(c.Value)) { field[SchemaItemField.FieldRowIndex] = nFieldRowIndex; field[SchemaItemField.SchemaItemId] = schemaItemId; field[SchemaItemField.DestTable] = c.Table; field[SchemaItemField.DestField] = c.Field; field[SchemaItemField.DestValue] = c.Value; field[SchemaItemField.DisplayOrder] = DisplayOrder++; field.Save(); } else { if (!field.IsNull(SchemaItemField.SchemaItemFieldId)) { int schemaItemFieldId = (int)field[SchemaItemField.SchemaItemFieldId]; ProtocolMgmtDa.DeleteSchemaItemField(schemaItemFieldId); } } } else if (action == Row_Actions.Delete) { if (!field.IsNull(SchemaItemField.SchemaItemFieldId)) { int schemaItemFieldId = (int)field[SchemaItemField.SchemaItemFieldId]; ProtocolMgmtDa.DeleteSchemaItemField(schemaItemFieldId); } } } } } }
/// <summary> /// During initalization, set control values and attach change handler to updates schedule date and status on change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void WireUpdateEvent(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Locate controls needed to be updates CaisisHidden deviationId = e.Row.FindControl(PatientDeviation.PatientDeviationId) as CaisisHidden; CaisisHidden pItemStatus = e.Row.FindControl(PatientItem.Status) as CaisisHidden; CaisisTextBox pItemSDate = e.Row.FindControl(PatientItem.ScheduledDate) as CaisisTextBox; Image dataEntered = e.Row.FindControl("DataEntered") as Image; Label dataEntry = e.Row.FindControl("DataEntry") as Label; // during data-binding, set values and UI elements (images, etc...) and realted deviation e.Row.DataBinding += new EventHandler(delegate(object o, EventArgs eArg) { int patientItemId = int.Parse(PatientVisitsGrid.DataKeys[e.Row.RowIndex][PatientItem.PatientItemId].ToString()); string status = DataBinder.Eval(e.Row.DataItem, PatientItem.Status).ToString(); string scheduledDate = DataBinder.Eval(e.Row.DataItem, PatientItem.ScheduledDate, "{0:d}").ToString(); // set ICaisisInputControls Values pItemStatus.Value = status; pItemSDate.Value = scheduledDate; // determine if checkbox marks are visible string dataEntryCount = DataBinder.Eval(e.Row.DataItem, "DataEntryCount").ToString(); int EntryCount; if (Int32.TryParse(dataEntryCount, out EntryCount) && EntryCount > 0) { dataEntry.Text = "Entered"; dataEntry.CssClass = "DataEntered"; dataEntered.Visible = true; } else { dataEntry.Text = "Not Done"; dataEntry.CssClass = "DataNotDone"; dataEntered.Visible = false; } // for current patient item, find related deviation record var foundDeviations = PatientDeviation.GetByFields <PatientDeviation>(new Dictionary <string, object> { { PatientDeviation.PatientItemId, patientItemId }, { PatientDeviation.DeviationType, "Missed Visit" } }); if (foundDeviations.Count() > 0) { deviationId.Value = foundDeviations.First()[PatientDeviation.PatientDeviationId].ToString(); } // add date range validation string clientDateFormatString = "new Date('{0}')"; object firstDate = DataBinder.Eval(e.Row.DataItem, PatientItem.FirstAnticipatedDate); object lastDate = DataBinder.Eval(e.Row.DataItem, PatientItem.LastAnticipatedDate); string clientFirstDate = "null"; string clientLastDate = "null"; if (firstDate != null && !string.IsNullOrEmpty(firstDate.ToString())) { DateTime date = (DateTime)firstDate; clientFirstDate = string.Format(clientDateFormatString, date); } if (lastDate != null && !string.IsNullOrEmpty(lastDate.ToString())) { DateTime date = (DateTime)lastDate; clientLastDate = string.Format(clientDateFormatString, date); } // add client script to validate date range pItemSDate.Attributes["onfocus"] = string.Format("validateScheduledDate(this, {0}, {1}, true, event);", clientFirstDate, clientLastDate); }); e.Row.PreRender += new EventHandler(delegate(object a, EventArgs b) { ReadOnlyDates.Add(pItemSDate.ClientID); }); } }
public void CustomizeControl(ICaisisInputControl control, string tablename, string fieldname) { if (Caisis.BOL.BusinessObject.HasLabel(tablename, fieldname)) { string label = Caisis.BOL.BusinessObject.GetLabel(tablename, fieldname); if (string.IsNullOrEmpty(label) && !fieldname.Contains("Date")) { control.FieldLabel = fieldname; } else { control.FieldLabel = Caisis.BOL.BusinessObject.GetLabel(tablename, fieldname); } } // description if (Caisis.BOL.BusinessObject.HasDescription(tablename, fieldname)) { control.HelpDescription = Caisis.BOL.BusinessObject.GetDescription(tablename, fieldname); } // required control.Required = Caisis.BOL.BusinessObject.IsRequired(tablename, fieldname); Action <string, Action <string> > setProp = (att, setter) => { if (Caisis.BOL.BusinessObject.HasMetadataFieldAttribute(tablename, fieldname, att)) { setter(Caisis.BOL.BusinessObject.GetMetadataFieldAttribute(tablename, fieldname, att)); } }; // javascript Action <string, string> handleJs = (att, eventName) => { setProp(att, s => CICHelper.HandleJsEventAttribute(control as WebControl, eventName, s)); }; if (control is WebControl) { handleJs("jsOnBlur", "onblur"); handleJs("jsOnClick", "onclick"); handleJs("jsOnSelectedIndexChanged", "onselectedindexchanged"); setProp("FieldWidth", s => (control as WebControl).Style.Add("width", s + "px")); } // lookup controls if (control is ICaisisLookupControl) { ICaisisLookupControl c = control as ICaisisLookupControl; setProp("LookupDistinct", s => c.LookupDistinct = s); setProp("LookupCode", s => c.LookupCode = s); setProp("CascadeValuesBasedOn", s => c.CascadeValuesBasedOn = s); setProp("CascadeFormatString", s => c.CascadeFormatString = s); } // text box MaxLength if (control is TextBox) { setProp("MaxLength", s => { int maxLength = 0; if (int.TryParse(s, out maxLength)) { (control as TextBox).MaxLength = maxLength; } }); } Func <string, bool> isSet = s => { string val = ""; bool parsed; setProp(s, x => val = x); return(bool.TryParse(val, out parsed) && parsed); }; // CaisisTextBox if (control is CaisisTextBox) { CaisisTextBox tb = control as CaisisTextBox; tb.ShowCalendar = isSet("ShowCalendar"); tb.CalcDate = isSet("CalcDate"); tb.ShowNumberPad = isSet("ShowNumberPad"); tb.ReadOnly = isSet("ReadOnly"); tb.ShowTextEditor = isSet("ShowTextEditor"); tb.ShowICDWizard = isSet("ShowICDWizard"); } // CaisisTextArea if (control is CaisisTextArea) { (control as CaisisTextArea).ShowTextEditor = isSet("ShowTextEditor"); } // CaisisHidden if (control is CaisisHidden) { CaisisHidden h = control as CaisisHidden; h.DisplayCalculatedDate = isSet("DisplayCalculatedDate"); h.DisplayHiddenValue = isSet("DisplayHiddenValue"); h.ShowICDWizard = isSet("ShowICDWizard"); } }
/// <summary> /// Initalizes variables and attaches event handlers for populating/updating DxImageFindingFields /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitEvents(object sender, EventArgs e) { List <CaisisCheckBox> checkBoxList = new List <CaisisCheckBox>(IMG_FIND_SUBSITES.Length); // setup event handlers foreach (string bodyPart in IMG_FIND_SUBSITES) { // Main Checkbox for each body part CaisisCheckBox subSiteCheckBox = this.FindControl(bodyPart + "_Check") as CaisisCheckBox; checkBoxList.Add(subSiteCheckBox); CaisisHidden basicSubSiteId = this.FindControl(bodyPart + "_BasicId") as CaisisHidden; string basicFindSubSite = bodyPart; // Populate basic basic image finding by subsite this.PopulateDxImagingField += new DxImageFindingEvent(delegate(int diagnosticId) { // Check if a basic record is found for subsite and set prikey and check box DataRow basicFind = FindDxBoneRecordBasic(diagnosticId, basicFindSubSite); if (basicFind != null) { basicSubSiteId.Value = basicFind[ImageFinding.DxImageFindingId].ToString(); subSiteCheckBox.Checked = true; } }); // Update event for basic image finding by subsite, no ImgFindNew,ImgFindSide or ImgFindAP DxImageFindingEvent basicSubSiteUpdateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { ImageFinding biz = new ImageFinding(); if (subSiteCheckBox.Checked) { if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { biz.Get(int.Parse(basicSubSiteId.Value)); } else { biz[ImageFinding.DiagnosticId] = diagnosticId; } biz[ImageFinding.ImgFindSite] = ImageTypes[0]; biz[ImageFinding.ImgFindSubsite] = basicFindSubSite; biz.Save(); // update prikey field basicSubSiteId.Value = biz[ImageFinding.DxImageFindingId].ToString(); } else { if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { biz.Delete(int.Parse(basicSubSiteId.Value)); // update prikey field basicSubSiteId.Value = string.Empty; } } }); // When subsite checkbox changed, mark as dirty subSiteCheckBox.ValueChanged += GetValueChangeEventHandler(subSiteCheckBox, basicSubSiteUpdateEvent); // DETAIL ORIENTED FIELDS // iterate through specific subsite fields and set update and populate events foreach (string view in IMG_FIND_AP) { foreach (string side in IMG_FIND_SIDES) { CaisisTextBox bodyPartViewSide = this.FindControl(view + "_" + bodyPart + "_" + side) as CaisisTextBox; CaisisHidden bodyPartViewSideId = this.FindControl(view + "_" + bodyPart + "_" + side + "_Id") as CaisisHidden; // Static Values string imgFindAP = view; string imgFindSide = side; string imgFindSubsite = bodyPart; // EVENT HANDLER which populates fields DxImageFindingEvent populateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { // Populate when not posting back DataRow foundBodyPartViewSide = FindDxBoneRecord(diagnosticId, imgFindAP, imgFindSide, imgFindSubsite); if (bodyPartViewSideId != null && foundBodyPartViewSide != null) { // set pri key bodyPartViewSideId.Value = foundBodyPartViewSide[ImageFinding.DxImageFindingId].ToString(); // set textbox value bodyPartViewSide.Value = foundBodyPartViewSide[ImageFinding.ImgFindNew].ToString(); // check box to indicate record found and has value subSiteCheckBox.Checked = true; // COLLECT MORE ACTIVATED CollectMore.Checked = true; } }); // EVENT HANDLER which updates the DxImageFindings table DxImageFindingEvent updateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { // Create new Biz ImageFinding biz = new ImageFinding(); // load record if exists if (!string.IsNullOrEmpty(bodyPartViewSideId.Value)) { int priKey = int.Parse(bodyPartViewSideId.Value); if (!string.IsNullOrEmpty(bodyPartViewSide.Value)) { biz.Get(priKey); } // otherwise, do not save empty ImgFindNew, remove record else { biz.Delete(priKey); return; } } else { // set par key field biz[ImageFinding.DiagnosticId] = diagnosticId; } // set ImgFindNew from text field biz[ImageFinding.ImgFindNew] = bodyPartViewSide.Value; // Get static values from dictionary biz[ImageFinding.ImgFindSite] = ImageTypes[0]; biz[ImageFinding.ImgFindAP] = imgFindAP; biz[ImageFinding.ImgFindSide] = imgFindSide; biz[ImageFinding.ImgFindSubsite] = imgFindSubsite; // save/update record biz.Save(); // update prikeyfield bodyPartViewSideId.Value = biz[ImageFinding.DxImageFindingId].ToString(); // Since we're creating a specific subsite find location, we need to remove generic subsite find record if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { ImageFinding basicFinding = new ImageFinding(); biz.Delete(int.Parse(basicSubSiteId.Value)); // update basic finding field basicSubSiteId.Value = string.Empty; } }); // Attach event for tracking dirty fields bodyPartViewSide.ValueChanged += GetValueChangeEventHandler(bodyPartViewSide, updateEvent);; // Attach events for populating fields this.PopulateDxImagingField += new DxImageFindingEvent(populateEvent); } } } // EVENTS for Total Lesions compared to BASELINE SCAN //// Create populating event which will set hidden field and radio button value if an image finding found //DxImageFindingEvent totalNewLesionsUpdate = new DxImageFindingEvent(delegate(int diagnosticId) // { // DataRow found = FindDxBoneRecord(diagnosticId); // if (found != null) // { // DxTotalNumNewTumors.Value = found[ImageFinding.ImgFindNew].ToString(); // TotalNewLesionsId.Value = found[ImageFinding.DxImageFindingId].ToString(); // } // }); //this.PopulateDxImagingField += new DxImageFindingEvent(totalNewLesionsUpdate); //// Create an update event which is used for updating the total number of lesions //DxImageFindingEvent basicBareUpdate = new DxImageFindingEvent(delegate(int diagnosticId) //{ // ImageFinding biz = new ImageFinding(); // if (!string.IsNullOrEmpty(TotalNewLesionsId.Value)) // { // biz.Get(int.Parse(TotalNewLesionsId.Value)); // } // else // { // biz[ImageFinding.DiagnosticId] = diagnosticId; // } // //biz[ImageFinding.ImgFindNew] = DxTotalNumNewTumors.Value; // biz[ImageFinding.ImgFindNotes] = "New total findings compared to BASELINE SCAN."; // biz[ImageFinding.ImgFindSite] = ImageTypes[0]; // // var q = // //from c in checkBoxList // //let v = c.Value // //where c.Checked // //select v; // //string checkedValues = string.Join(",", checkBoxList.Where(c => c.Checked).Select(c => c.Value).ToArray()); // biz.Save(); //}); //// When chnaging total lesion, trigger dirty field //DxTotalNumNewTumors.ValueChanged += GetValueChangeEventHandler(DxTotalNumNewTumors, basicBareUpdate); }
/// <summary> /// Inserts/Updates the Diagnostic record in the specific container, i.e., RepeaterItem, Control, etc... /// </summary> /// <param name="fieldsContainer"></param> /// <param name="patientId"></param> /// <returns></returns> private Diagnostic UpdateDiagnosticsByContainer(Control fieldsContainer, int patientId) { Control petFields = fieldsContainer.FindControl("PET_Fields"); Control ctMRIFields = fieldsContainer.FindControl("CTMRI_Fields"); Control shareFields = fieldsContainer.FindControl("SHARED_Fields"); Control mainFields = ImageType == "PET" ? petFields : ctMRIFields; CaisisHidden diagIdField = fieldsContainer.FindControl("DiagnosticIdField") as CaisisHidden; Diagnostic biz = new Diagnostic(); int? diagnosticId = null; if (!string.IsNullOrEmpty(diagIdField.Value)) { diagnosticId = int.Parse(diagIdField.Value); biz.Get(diagnosticId.Value); } // set main fields CICHelper.SetBOValues(shareFields.Controls, biz, patientId); CICHelper.SetBOValues(mainFields.Controls, biz, patientId); biz.Save(); // update key diagnosticId = (int)biz[Diagnostic.DiagnosticId]; diagIdField.Value = diagnosticId.ToString(); // special case: updated/insert PET image findings if (mainFields == petFields && diagnosticId.HasValue) { // containers are named by index Control boneFields = petFields.FindControl("PET_Fields_Finding0"); Control softTissueFields = petFields.FindControl("PET_Fields_Finding1"); Control lymphNodeFields = petFields.FindControl("PET_Fields_Finding2"); // generic insert/update logic foreach (Control petFindingContainer in new Control[] { boneFields, softTissueFields, lymphNodeFields }) { ImageFinding findingBiz = new ImageFinding(); ICaisisInputControl findingKeyField = FindInputControl(petFindingContainer, ImageFinding.DxImageFindingId); // only continue if fields have values bool fieldsHaveData = (from input in CICHelper.GetCaisisInputControls(petFindingContainer) where input != findingKeyField && !string.IsNullOrEmpty(input.Value) select input).Count() > 0; // update if (!string.IsNullOrEmpty(findingKeyField.Value)) { int dxImageFindingId = int.Parse(findingKeyField.Value); findingBiz.Get(dxImageFindingId); } // insert else if (fieldsHaveData) { // !important, mark special DxImageFinding status for later retrieval (bone/soft tissue) if (petFindingContainer == boneFields) { findingBiz[ImageFinding.ImgFindStatus] = PET_SCAN_LOCATION_BONE; } else if (petFindingContainer == softTissueFields) { findingBiz[ImageFinding.ImgFindStatus] = PET_SCAN_LOCATION_SOFT_TISSUE; } else if (petFindingContainer == lymphNodeFields) { findingBiz[ImageFinding.ImgFindStatus] = PET_SCAN_LOCATION_NYMPH_NODE; } } // if field have no data on new records, ignore, do not insert else { continue; } // set fields and update CICHelper.SetBOValues(petFindingContainer.Controls, findingBiz, diagnosticId.Value); findingBiz.Save(); findingKeyField.Value = findingBiz[ImageFinding.DxImageFindingId].ToString(); } // udpate/insert special findings datagrids ExtendedGridView hottestGrid = petFields.FindControl("DxGrid1") as ExtendedGridView; ExtendedGridView newGrid = petFields.FindControl("DxGrid2") as ExtendedGridView; if (hottestGrid != null && newGrid != null) { string type = Request.Form["NewLesionsGroup_Type"]; // update grids foreach (ExtendedGridView grid in new ExtendedGridView[] { hottestGrid, newGrid }) { // special fix, set ImgFindGroupNum foreach (GridViewRow row in grid.Rows) { int groupNum = row.RowIndex + 1; var imgFindGroupField = FindInputControl(row, ImageFinding.ImgFindGroupNum); imgFindGroupField.Value = groupNum.ToString(); } if ((grid == hottestGrid && type == "Hottest") || (grid == newGrid && type == "New")) { grid.Save(diagnosticId.Value); } } } } return(biz); }
/// <summary> /// Populates each cell of the matrix with relevent DxImaging record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PopulateImagingCell(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { // get coordinates of data entry cell int colIndex = e.Item.ItemIndex; int rowIndex = (e.Item.NamingContainer.NamingContainer as RepeaterItem).ItemIndex; // determine which set of DxImageFinding fields to display Control petFields = e.Item.FindControl("PET_Fields"); Control ctMRIFields = e.Item.FindControl("CTMRI_Fields"); Control dataEntryFields; if (ImageType == "PET") { dataEntryFields = petFields; petFields.Visible = true; ctMRIFields.Visible = false; } else { dataEntryFields = ctMRIFields; petFields.Visible = false; ctMRIFields.Visible = true; } // determine if cell maps to existing record List <ICaisisInputControl> iCICList = CICHelper.GetCaisisInputControls(dataEntryFields); //PageUtil.GetCaisisInputControlsInContainer(e.Item); string diagnosticId = DataBinder.Eval(e.Item.DataItem, ImageFinding.DiagnosticId).ToString(); string imgFindGroupNum = DataBinder.Eval((e.Item.NamingContainer.NamingContainer as RepeaterItem).DataItem, ImageFinding.ImgFindGroupNum).ToString(); CaisisHidden imageFindingId = e.Item.FindControl("ImageFindingId") as CaisisHidden; CaisisHidden diagnosticIdField = DiagnosticsHeaderRptr.Items[colIndex].FindControl("DiagnosticIdField") as CaisisHidden; CaisisHidden imgFindGroupNumField = e.Item.FindControl("ImgFindGroupNum") as CaisisHidden; imgFindGroupNumField.Value = imgFindGroupNum; PlaceHolder ctMRIHeader = e.Item.FindControl("CTMRI_TimelineHeader") as PlaceHolder; TextBox mainDataEntryFieldLabel = e.Item.FindControl("MainDataEntryFieldLabel") as TextBox; TextBox secondaryDataEntryFieldLabel = e.Item.FindControl("SecondaryDataEntryFieldLabel") as TextBox; // set special header: sd/ld bool hasSpecialHeader = !string.IsNullOrEmpty(SecondaryDataEntryField); ctMRIHeader.Visible = hasSpecialHeader; secondaryDataEntryFieldLabel.Visible = hasSpecialHeader; string searchForImage = Diagnostic.DiagnosticId + " = " + diagnosticId + " AND " + ImageFinding.ImgFindGroupNum + " = " + imgFindGroupNum; DataRow[] foundRecords = DxImagingRows.Table.Select(searchForImage); // if a record is found, set imaging id for update if (foundRecords.Length > 0) { DataRow foundRecord = foundRecords[0]; // set pri key fields for tracking updates imageFindingId.Value = foundRecord[ImageFinding.DxImageFindingId].ToString(); // set displayable field value string mainDataEntryFieldValue = foundRecord[MainDataEntryField].ToString(); if (!string.IsNullOrEmpty(mainDataEntryFieldValue)) { mainDataEntryFieldLabel.Text = mainDataEntryFieldValue; } if (!string.IsNullOrEmpty(SecondaryDataEntryField) && secondaryDataEntryFieldLabel != null) { string secondaryDataEntryFieldValue = foundRecord[SecondaryDataEntryField].ToString(); if (!string.IsNullOrEmpty(secondaryDataEntryFieldValue)) { secondaryDataEntryFieldLabel.Text = secondaryDataEntryFieldValue; } } // set data entry fields from db record foreach (ICaisisInputControl iCIC in iCICList) { iCIC.Value = foundRecord[iCIC.Field].ToString(); } } // if no record found for dximagefinding, new record, and default fields to groupnum defaults else { DxImagingRows.RowFilter = ImageFinding.ImgFindGroupNum + " = " + imgFindGroupNum; if (DxImagingRows.Count > 0) { List <string> defaultFields = new List <string>(new string[] { ImageFinding.ImgFindTarget, ImageFinding.ImgFindSite, ImageFinding.ImgFindSubsite }); foreach (ICaisisInputControl iCIC in iCICList) { // only default values for these fields if (defaultFields.Contains(iCIC.Field)) { iCIC.Value = DxImagingRows[0][iCIC.Field].ToString(); } } } } foreach (ICaisisInputControl iCIC in iCICList) { if (iCIC.Field == MainDataEntryField) { iCIC.CssClass = "MainDataEntryField"; } else if (iCIC.Field == SecondaryDataEntryField) { iCIC.CssClass = "SecondaryDataEntryField"; } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BindStudyItems(object sender, RepeaterItemEventArgs schemaItemArg) { RepeaterItem schemaItemRow = schemaItemArg.Item; if (schemaItemRow.ItemType == ListItemType.Header || schemaItemRow.ItemType == ListItemType.Item || schemaItemRow.ItemType == ListItemType.AlternatingItem) { // Locate child PreStudy and OnStudy Repeaters Repeater preStudyItems = schemaItemRow.FindControl(PRE_STUDY_RPTR_ID) as Repeater; Repeater onStudyItems = schemaItemRow.FindControl(ON_STUDY_RPTR_ID) as Repeater; CaisisHidden schemaItemIdField = schemaItemRow.FindControl("SchemaItemIdField") as CaisisHidden; // Set Schema-Item Field if (schemaItemIdField != null) { schemaItemIdField.Value = DataBinder.Eval(schemaItemRow.DataItem, SchemaItem.SchemaItemId).ToString(); } // When SchemaItem is binding, bind child PreStudy and OnStudy Repeaters // These columns will be the assciation between a SchemaItem (row) and Timeline (col) schemaItemRow.DataBinding += new EventHandler(delegate(object schemaItemRptr, EventArgs schemaItemArgs) { preStudyItems.DataSource = PreStudyTimeline; preStudyItems.DataBind(); onStudyItems.DataSource = OnStudyTimeline; onStudyItems.DataBind(); }); // CLOSURES // A method which returns and RepeaterItemEventHandler used for handling the creation // of each column/checkbox, containing logic for updating/populating the ItemTimeline table ProtocolRptrCreator GetCreator = new ProtocolRptrCreator(delegate(Repeater mirrorRptr) { // Create a new instance of the OnItemCreate Handler RepeaterItemEventHandler creationHandler = new RepeaterItemEventHandler(delegate(object o, RepeaterItemEventArgs timelineItemEventArg) { if (timelineItemEventArg.Item.ItemType == ListItemType.Item || timelineItemEventArg.Item.ItemType == ListItemType.AlternatingItem) { // Repeater item repsents a ItemTimline columns in current SchemaItem row RepeaterItem itemTimelineCol = timelineItemEventArg.Item; // This Timeline data entry layer will contain the foreign TimelineId record // During inserts and update of ItemTime records, foreign key will come from this RepeaterItem timelineDataEntryCol = mirrorRptr.Items[itemTimelineCol.ItemIndex]; // Current Timeline Index int colIndex = timelineDataEntryCol.ItemIndex; // Current SchemaItem int rowIndex = schemaItemRow.ItemIndex; bool isRowColumnDirty = false; PlaceHolder colCheckBoxHolder = itemTimelineCol.FindControl("CheckBoxHolder") as PlaceHolder; // Create anonmous EventHandler to determine checkbox state when binding to data itemTimelineCol.DataBinding += new EventHandler(delegate(object oo, EventArgs ee) { string timelineId = DataBinder.Eval(itemTimelineCol.DataItem, Timeline.TimelineId).ToString(); string schemaItemId = schemaItemIdField.Value; if (!string.IsNullOrEmpty(schemaItemId) && !string.IsNullOrEmpty(timelineId)) { // If ItemTimeline records are found based, check check-box DataRow[] foundRecords = FindItemTimelineRecords(schemaItemId, timelineId); if (foundRecords.Length > 0) { // checkbox chcked Image img = new Image(); img.ID = "ColCheckBox"; img.ImageUrl = "Images/Review_Check.PNG"; colCheckBoxHolder.Controls.Add(img); } else { //colCheckBox.Checked = false; } } else { //colCheckBox.Checked = false; } }); } }); return(creationHandler); }); // During ItemCreation of TimelineItems if (schemaItemRow.ItemType == ListItemType.Item || schemaItemRow.ItemType == ListItemType.AlternatingItem) { // Attach Handlers preStudyItems.ItemCreated += GetCreator(PreStudyItemsLayerRptr); onStudyItems.ItemCreated += GetCreator(OnStudyItemsLayerRptr); } } }