/// <summary> /// Copies end date to start date if no start date /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetBlurEvent(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Get start and end date fields CaisisTextBox startDate = e.Row.FindControl("EventStartDate") as CaisisTextBox; CaisisTextBox endDate = e.Row.FindControl("EventEndDate") as CaisisTextBox; // Manually set date's to friendly short date string string sDate = DataBinder.Eval(e.Row.DataItem, ProjectStageEvent.EventStartDate).ToString(); string eDate = DataBinder.Eval(e.Row.DataItem, ProjectStageEvent.EventEndDate).ToString(); if (!string.IsNullOrEmpty(sDate)) { startDate.Value = DateTime.Parse(sDate).ToShortDateString(); } if (!string.IsNullOrEmpty(eDate)) { endDate.Value = DateTime.Parse(eDate).ToShortDateString(); } // Add blur,focus, and click event to enddate control string script = "handleEndDateEntered('" + startDate.ClientID + "','" + endDate.ClientID + "');"; PageUtil.AttachClientEventToControl(endDate as WebControl, "onclick", script); PageUtil.AttachClientEventToControl(endDate as WebControl, "onfocus", script); PageUtil.AttachClientEventToControl(endDate as WebControl, "onblur", script); } }
/// <summary> /// Adds a new instance of controlBase (a CaisisInputControl) to the row's cell /// </summary> /// <param name="cell"></param> /// <param name="rowState"></param> protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState) { ICaisisInputControl iCIC = new CaisisTextBox(); if (BaseCaisisInputControl == null) { if (!string.IsNullOrEmpty(CaisisControlTypeName)) { //// Create Control, set Field, then set MetaData values //iCIC = CICHelper.InvokeInputControl(CaisisControlTypeName); //iCIC.Field = cicFieldName; //CICHelper.SetCICAttributes(iCIC, CaisisControlMetaTable); } } else { iCIC = CICHelper.CloneCIC(controlBase); } // Supress FieldLabel iCIC.ShowLabel = false; // handle binding BindControl(this, new CaisisControlEventArgs(iCIC)); // Add control to cell cell.Controls.Add(iCIC as Control); }
/// <summary> /// Attributes which have the word date, show date picker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandleDateAttributes(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { string attName = DataBinder.Eval(e.Row.DataItem, ProjectEventAttribute.AttributeName).ToString(); string attValue = DataBinder.Eval(e.Row.DataItem, ProjectEventAttribute.AttributeValue).ToString(); string[] words = attName.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string word in words) { if (word.ToLower().Equals("date")) { CaisisTextBox attValueField = e.Row.FindControl("AttributeValue") as CaisisTextBox; attValueField.ShowCalendar = true; if (!string.IsNullOrEmpty(attValue)) { DateTime properDate = new DateTime(); DateTime.TryParse(attValue, out properDate); if (properDate != DateTime.MinValue) { attValueField.Value = properDate.ToShortDateString(); } } } } } }
/// <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> /// Adds a new lookup code record, footer. If adding stage lookup code, extract color value /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void AddLookupCode(object sender, EventArgs e) { CaisisTextBox lkpBox = sender as CaisisTextBox; if (lkpBox != null) { string lkpFieldName = lkpBox.FieldLabel; string lkpCode = lkpBox.Text; string lkpOrderServerId = lkpFieldName + LookupCode.LkpOrder; CaisisTextBox lkpOrderBox = lkpBox.NamingContainer.FindControl(lkpOrderServerId) as CaisisTextBox; string lkpOrder = lkpOrderBox.Value; if (!string.IsNullOrEmpty(lkpCode)) { int newLkpCodeId = AddLookupCodeValue(lkpFieldName, lkpCode, lkpOrder); lkpBox.Value = string.Empty; // Save a color atttibute for the new record for stage lookup code if (lkpBox == StageLkpCode && !string.IsNullOrEmpty(ColorAttributeId.Value) && !string.IsNullOrEmpty(NewColorCode.Value)) { LookupCodeAttribute colorAttributeValue = new LookupCodeAttribute(); colorAttributeValue[LookupCodeAttribute.LookupCodeId] = newLkpCodeId; colorAttributeValue[LookupCodeAttribute.AttributeId] = ColorAttributeId.Value; colorAttributeValue[LookupCodeAttribute.AttributeValue] = NewColorCode.Value; colorAttributeValue[LookupCodeAttribute.AttributeSuppress] = 0; colorAttributeValue.Save(); NewColorCode.Value = string.Empty; } } } }
/// <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(); }
/// <summary> /// Adds client script to copy ResponseText to Response Value (if empty) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetResponseCopyEvent(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { CaisisTextBox responseText = e.Row.FindControl("ResponseTextField") as CaisisTextBox; CaisisTextBox responseValue = e.Row.FindControl("ResponseValueField") as CaisisTextBox; string jsOnBlur = "if(document.getElementById('" + responseValue.ClientID + "').value=='') { document.getElementById('" + responseValue.ClientID + "').value = document.getElementById('" + responseText.ClientID + "').value; }"; responseText.Attributes["onblur"] = jsOnBlur; } }
/// <summary> /// Dynamically set columns /// </summary> private void InitSpecimensGrid() { SpecimenAccession accession = new SpecimenAccession(); Specimen specimen = new Specimen(); var accessionFields = accession.FieldNames; var specimenFields = specimen.FieldNames; var specimenMetadata = CICHelper.GetCaisisInputControlsByTableName(specimen.TableName, "").ToDictionary(f => f.Field, f => f); //SpecimenInventory.Columns.Clear(); foreach (var column in GetSpecimenColumns()) { string fieldName = column.Key; string fieldLabel = column.Value; // get input CaisisTextBox defaultInput = new CaisisTextBox(); ICaisisInputControl fieldInput = defaultInput; // special case: lookup controls map to distinct combo values if (specimenFields.Contains(fieldName) && specimenMetadata.ContainsKey(fieldName)) { fieldInput = specimenMetadata[fieldName]; // select, radio list, check list => combo box if (fieldInput is ICaisisLookupControl && !(fieldInput is CaisisComboBox)) fieldInput = new CaisisComboBox(); fieldInput.Table = specimen.TableName; } // global fieldInput.Field = fieldName; fieldInput.FieldLabel = fieldLabel; fieldInput.ShowLabel = false; CaisisDataBoundField boundField = new CaisisDataBoundField(fieldInput); SpecimenInventory.Columns.Add(boundField); } // only enable specimen fields for edit SpecimenInventory.RowCreated += (o, e) => { var inputs = CICHelper.GetCaisisInputControls(e.Row); foreach (var fieldInput in inputs) { if (fieldInput.Table == specimen.TableName) { fieldInput.Enabled = true; // special lookup distinct if (fieldInput is ICaisisLookupControl) (fieldInput as ICaisisLookupControl).LookupDistinct = string.Format("{0};{1};{2}", specimen.TableName, fieldInput.Field, fieldInput.Field); } else { fieldInput.Enabled = false; } } }; }
/// <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); }
/// <summary> /// Automatically assigns a SortNumber to all rows if not there. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetSortNumber(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { CaisisTextBox sortNum = e.Row.FindControl("SortNumber") as CaisisTextBox; string num = DataBinder.Eval(e.Row.DataItem, "SortNumber").ToString(); if (string.IsNullOrEmpty(num)) { sortNum.Value = max.ToString(); max++; } else { max = int.Parse(num) + 1; } } }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveDiseases(object sender, EventArgs e) { // manually update foreach (GridViewRow dirtyRow in DiseaseGrid.DirtyGridRows) { Disease biz = new Disease(); // get pri key on existing rows object did = DiseaseGrid.DataKeys[dirtyRow.RowIndex][Disease.DiseaseId]; if (did != null & did.ToString() != "") { biz.Get((int)did); } // get user disease name CaisisTextBox diseaseName = dirtyRow.FindControl("DiseaseNameField") as CaisisTextBox; if (!string.IsNullOrEmpty(diseaseName.Value)) { biz[Disease.DiseaseName] = diseaseName.Value; biz.Save(); } } BuildDiseases(); }
private void PopulateSpecimenDetailsRow(Control row, int specimenId) { // Core HiddenField SpecimenNumField = row.FindControl("SpecimenNumField") as HiddenField; HiddenField SpecimenSubTypeField = row.FindControl("SpecimenSubTypeField") as HiddenField; CaisisTextBox StatusDate = row.FindControl("StatusDate") as CaisisTextBox; // Sequencing CaisisSelect Sequencing_Failed_Reason = row.FindControl("Sequencing_Failed_Reason") as CaisisSelect; CaisisRadioButtonList Extraction_Radio = row.FindControl("Extraction_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Library_Radio = row.FindControl("Library_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Sequenced_Radio = row.FindControl("Sequenced_Radio") as CaisisRadioButtonList; // Analysis CaisisRadioButtonList Analysis_Radio = row.FindControl("Analysis_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Pathology_Radio = row.FindControl("Pathology_Radio") as CaisisRadioButtonList; // Pathology CaisisSelect Analysis_Failed_Reason = row.FindControl("Analysis_Failed_Reason") as CaisisSelect; CaisisComboBox SpecimenConditionNotes = row.FindControl("SpecimenConditionNotes") as CaisisComboBox; Specimen specimen = new Specimen(); specimen.Get(specimenId); string num = specimen[BOL.Specimen.SpecimenReferenceNumber].ToString(); string status = specimen[BOL.Specimen.SpecimenStatus].ToString(); string notes = specimen[BOL.Specimen.SpecimenNotes].ToString(); SpecimenNumField.Value = num; SpecimenSubTypeField.Value = specimen[BOL.Specimen.SpecimenSubType].ToString(); SpecimenEvents specimenEvent = GetSequencingEvent(specimenId); // applies to all if (specimenEvent != null) { StatusDate.Value = string.Format("{0:d}", specimenEvent[SpecimenEvents.EventDate]); } // set relevant radios if (InventoryMode == SpecimenInventoryMode.Sequencing) { switch (status) { case "Tissue Extraction Successful": Extraction_Radio.Value = ANSWER_YES; break; case "Tissue Extraction Unsuccessful": Extraction_Radio.Value = ANSWER_NO; if (specimenEvent != null && !specimenEvent.IsNull(SpecimenEvents.EventResult)) { Sequencing_Failed_Reason.Value = specimenEvent[SpecimenEvents.EventResult].ToString(); } break; case "Library Construction Successful": Extraction_Radio.Value = ANSWER_YES; Library_Radio.Value = ANSWER_YES; break; case "Library Construction Unsuccessful": Extraction_Radio.Value = ANSWER_YES; Library_Radio.Value = ANSWER_NO; if (specimenEvent != null && !specimenEvent.IsNull(SpecimenEvents.EventResult)) { Sequencing_Failed_Reason.Value = specimenEvent[SpecimenEvents.EventResult].ToString(); } break; case "Sequenced": Extraction_Radio.Value = ANSWER_YES; Library_Radio.Value = ANSWER_YES; Sequenced_Radio.Value = ANSWER_YES; break; case "Sequencing Unsuccessful": Extraction_Radio.Value = ANSWER_YES; Library_Radio.Value = ANSWER_YES; Sequenced_Radio.Value = ANSWER_NO; if (specimenEvent != null && !specimenEvent.IsNull(SpecimenEvents.EventResult)) { Sequencing_Failed_Reason.Value = specimenEvent[SpecimenEvents.EventResult].ToString(); } break; default: Extraction_Radio.ClearSelection(); Library_Radio.ClearSelection(); Sequenced_Radio.ClearSelection(); break; } } else if (InventoryMode == SpecimenInventoryMode.Analysis) { switch (status) { case "Analysis Complete": Analysis_Radio.Value = ANSWER_YES; break; case "Analysis Unsuccessul": Analysis_Radio.Value = ANSWER_NO; if (specimenEvent != null && !specimenEvent.IsNull(SpecimenEvents.EventResult)) { Analysis_Failed_Reason.Value = specimenEvent[SpecimenEvents.EventResult].ToString(); } break; default: Analysis_Radio.ClearSelection(); break; } } else if (InventoryMode == SpecimenInventoryMode.Pathology) { switch (status) { case "Pathology Review Completed": Pathology_Radio.Value = ANSWER_YES; break; case "Banked by Pathology": Pathology_Radio.Value = ANSWER_NO; break; default: Pathology_Radio.ClearSelection(); break; } // build condition list, fill into notes field DataTable conditions = new DataTable(); conditions.Columns.Add("Condition"); string foundCondition = ""; foreach (string condition in specimenController.GetConditions()) { // find selected if (specimenController.GetSpecimenCondition(notes) == condition) { foundCondition = condition; } // add data conditions.Rows.Add(new object[] { condition }); } SpecimenConditionNotes.BuildComboData(conditions, "Condition", "Condition"); SpecimenConditionNotes.Value = notes; } }
private void UpdateSpecimenDetailsRow(Control row, int specimenId) { // Core HiddenField SpecimenNumField = row.FindControl("SpecimenNumField") as HiddenField; HiddenField SpecimenSubTypeField = row.FindControl("SpecimenSubTypeField") as HiddenField; CaisisTextBox StatusDate = row.FindControl("StatusDate") as CaisisTextBox; // Sequencing CaisisSelect Sequencing_Failed_Reason = row.FindControl("Sequencing_Failed_Reason") as CaisisSelect; CaisisRadioButtonList Extraction_Radio = row.FindControl("Extraction_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Library_Radio = row.FindControl("Library_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Sequenced_Radio = row.FindControl("Sequenced_Radio") as CaisisRadioButtonList; // Analysis CaisisRadioButtonList Analysis_Radio = row.FindControl("Analysis_Radio") as CaisisRadioButtonList; CaisisRadioButtonList Pathology_Radio = row.FindControl("Pathology_Radio") as CaisisRadioButtonList; // Pathology CaisisSelect Analysis_Failed_Reason = row.FindControl("Analysis_Failed_Reason") as CaisisSelect; CaisisComboBox SpecimenConditionNotes = row.FindControl("SpecimenConditionNotes") as CaisisComboBox; // shared variables string status = ""; DateTime?statusDate = null; if (!string.IsNullOrEmpty(StatusDate.Value)) { statusDate = DateTime.Parse(StatusDate.Value); } if (InventoryMode == SpecimenInventoryMode.Sequencing) { string failedReason = Sequencing_Failed_Reason.Value; string statusResult = ""; // determine new status, top down if (Extraction_Radio.Value == ANSWER_NO) { status = "Tissue Extraction Unsuccessful"; statusResult = failedReason; } else if (Extraction_Radio.Value == ANSWER_YES) { if (Library_Radio.Value == ANSWER_NO) { status = "Library Construction Unsuccessful"; statusResult = failedReason; } else if (Library_Radio.Value == ANSWER_YES) { if (Sequenced_Radio.Value == ANSWER_NO) { status = "Sequencing Unsuccessful"; statusResult = failedReason; } else if (Sequenced_Radio.Value == ANSWER_YES) { status = "Sequenced"; } else { status = "Library Construction Successful"; } } else { status = "Tissue Extraction Successful"; } } // update event if (!string.IsNullOrEmpty(status) || statusDate.HasValue || !string.IsNullOrEmpty(statusResult)) { UpdateSequencingEvent(specimenId, status, statusDate, statusResult); } } else if (InventoryMode == SpecimenInventoryMode.Pathology) { if (Pathology_Radio.Value == ANSWER_YES) { status = "Pathology Review Completed"; } else if (Analysis_Radio.Value == ANSWER_NO) { status = "Banked by Pathology"; } // update event if (!string.IsNullOrEmpty(status) || statusDate.HasValue) { UpdateSequencingEvent(specimenId, status, statusDate, ""); } } else if (InventoryMode == SpecimenInventoryMode.Analysis) { string failedReason = Analysis_Failed_Reason.Value; if (Analysis_Radio.Value == ANSWER_YES) { status = "Analysis Complete"; // on successful analysis, update event UpdateSequencingEvent(specimenId, status, statusDate, ""); } else if (Analysis_Radio.Value == ANSWER_NO) { status = "Analysis Unsuccessul"; UpdateSequencingEvent(specimenId, status, statusDate, failedReason); } } // update specimen status if (!string.IsNullOrEmpty(status)) { Specimen specimen = new Specimen(); specimen.Get(specimenId); specimen[Specimen.SpecimenStatus] = status; // special case if (InventoryMode == SpecimenInventoryMode.Pathology) { specimen[Specimen.SpecimenNotes] = SpecimenConditionNotes.Value; } specimen.Save(); } }
/// <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"); } }
protected void PopulateRowValues(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // get procedure Procedure procedure = e.Item.DataItem as Procedure; // key controls HiddenField procIdField = e.Item.FindControl("ProcedureId") as HiddenField; HiddenField pathIdField = e.Item.FindControl("PathologyId") as HiddenField; // static controls Control clearBtn = e.Item.FindControl("ClearBtn"); Control lockImg = e.Item.FindControl("LockImage"); clearBtn.Visible = false; lockImg.Visible = false; // validate real row if (procedure.PrimaryKeyHasValue) { int procedureId = (int)procedure[Procedure.ProcedureId]; CICHelper.SetFieldValues(e.Item.Controls, procedure); procIdField.Value = procedureId + ""; // set button states bool isLocked = (procedure[Procedure.LockedBy] + "") != ""; lockImg.Visible = isLocked; // get pathology Pathology pathology = BusinessObject.GetByFields <Pathology>(new Dictionary <string, object> { { Patient.PatientId, base.patientId }, { Pathology.ProcedureId, procedureId } }).FirstOrDefault(); if (pathology != null && pathology.PrimaryKeyHasValue) { // populate pathology int pathologyId = (int)pathology[Pathology.PathologyId]; CICHelper.SetFieldValues(e.Item.Controls, pathology); pathIdField.Value = pathologyId + ""; // populate path BiopsyProstatePathology biopsyPath = BusinessObject.GetByParent <BiopsyProstatePathology>(pathologyId).FirstOrDefault(); if (biopsyPath != null && biopsyPath.PrimaryKeyHasValue) { CICHelper.SetFieldValues(e.Item.Controls, biopsyPath); } } // no path: hide else { e.Item.Visible = false; } } // blank row else { clearBtn.Visible = true; } // set script CaisisTextBox gg1 = e.Item.FindControl("PathGG1") as CaisisTextBox; CaisisTextBox gg2 = e.Item.FindControl("PathGG2") as CaisisTextBox; CaisisTextBox ggs = e.Item.FindControl("PathGGS") as CaisisTextBox; string script = string.Format("calculateBxResult('{0}', '{1}', '{2}');", gg1.ClientID, gg2.ClientID, ggs.ClientID); gg1.Attributes["onchange"] = script; gg2.Attributes["onchange"] = script; } }
protected void SetEformFields(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemIndex > -1) { int patientId = (int)DataBinder.Eval(e.Item.DataItem, Patient.PatientId); string mrn = DataBinder.Eval(e.Item.DataItem, Patient.PtMRN).ToString(); string name = DataBinder.Eval(e.Item.DataItem, "Name").ToString().Replace(",", ", "); string currentStatus = DataBinder.Eval(e.Item.DataItem, "CurrentStatus").ToString(); string currentEFormApptPhysician = DataBinder.Eval(e.Item.DataItem, "EFormApptPhysician").ToString(); CaisisSelect statusList = e.Item.FindControl("StatusField") as CaisisSelect; CaisisSelect EFormApptPhysicianField = e.Item.FindControl("EFormApptPhysicianField") as CaisisSelect; Label mrnLabel = e.Item.FindControl("PtMRN") as Label; Label ptLabel = e.Item.FindControl("PtLabel") as Label; statusList.DataSource = EFormStatuses; // EformStatusManager.GetEformStatuses(); statusList.DataBind(); statusList.Value = currentStatus; //AppointmentDa aptDa = new AppointmentDa(); //EFormApptPhysicianField.DataSource = aptDa.GetDistinctAppointmentPhysicians().Tables[0].DefaultView; //EFormApptPhysicianField.DataTextField = "ApptPhysician"; //EFormApptPhysicianField.DataValueField = "ApptPhysician"; //EFormApptPhysicianField.DataBind(); EFormApptPhysicianField.Value = currentEFormApptPhysician; if (DataBinder.Eval(e.Item.DataItem, "EFormApptTime").ToString().Length > 0) { CaisisTextBox EFormApptTimeField = e.Item.FindControl("EFormApptTimeField") as CaisisTextBox; EFormApptTimeField.Value = ((DateTime)(DataBinder.Eval(e.Item.DataItem, "EFormApptTime"))).ToShortDateString(); } // set identified fields mrnLabel.Text = pc.GetPatientMRN(mrn); ptLabel.Text = canViewIdentifiers ? name : pc.GetPatientName(" ", " ", true); // set identifier string selectedIdType = IdTypeSelection.Value + ""; bool displayIdentifier = selectedIdType != PatientController.LAST_NAME_MRN_IDENTIFIER; Label idTypeLabel = e.Item.FindControl("IdType") as Label; Label idValueLabel = e.Item.FindControl("IdTypeValue") as Label; if (displayIdentifier) { idTypeLabel.Text = selectedIdType + ":"; idValueLabel.Text = pc.GetPatientIdentifier(patientId, selectedIdType); idTypeLabel.Visible = true; idValueLabel.Visible = true; } else { idTypeLabel.Visible = false; idValueLabel.Visible = false; } } }
/// <summary> /// During databinding, dynamically insert ICaisisInputControls into placeholder /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BuildControlsAndLabel(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { EformField field = (EformField)e.Item.DataItem; // supress DATE FIELDS if (field.Field.EndsWith("Date")) { e.Item.Visible = false; } else { ICaisisInputControl iCIC = CICHelper.InvokeInputControl(field.ControlType); if (iCIC is CaisisTextArea) { iCIC = new CaisisTextBox(); (iCIC as CaisisTextBox).ShowTextEditor = true; } iCIC.ShowLabel = false; iCIC.Table = field.Table; iCIC.Field = field.Field; PlaceHolder dynamicHolder = e.Item.FindControl("DynamicControlPlaceHolder") as PlaceHolder; dynamicHolder.Controls.Add(iCIC as Control); if (!(iCIC is CaisisHidden)) { CICHelper.SetStaticFieldAttributes(dynamicHolder.Controls, field.Table); } // FIX?? needs to be centralized if (iCIC is CaisisSelect) { CaisisSelect cs = iCIC as CaisisSelect; string lookupCode = cs.LookupCode; if (!string.IsNullOrEmpty(cs.LookupDistinct) && cs.LookupDistinct.IndexOf(SessionKey.PatientId) > -1) { if (Session[SessionKey.PatientId] != null | Session[SessionKey.PatientId].ToString() != string.Empty) { CICHelper.HandleLookupDistinctAttribute(cs, cs.LookupDistinct, this.Page.Session); this.EnableViewState = true; } } else if (lookupCode != null && lookupCode.Length > 0) { cs.DataSource = CacheManager.GetLookupCodeList(lookupCode).DefaultView; cs.DataTextField = "LkpCode"; cs.DataValueField = "LkpCode"; cs.DataBind(); } } if (Caisis.BOL.BusinessObject.HasLabel(field.Table, field.Field)) { iCIC.FieldLabel = Caisis.BOL.BusinessObject.GetLabel(field.Table, field.Field); } else { iCIC.FieldLabel = field.Field; } Label fieldLabel = e.Item.FindControl("FieldLabel") as Label; fieldLabel.Text = iCIC.FieldLabel; if (BusinessObject.IsRequired(iCIC.Table, iCIC.Field)) { fieldLabel.CssClass = fieldLabel.CssClass + " RequiredField"; fieldLabel.ToolTip = "Required Field"; } if (iCIC is CaisisTextBox) { //(iCIC as CaisisTextBox).ShowCalendar = false; } } } }
/// <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); }