private void ImportProtocol(XDocument xDoc, int?existingProtocolId) { try { // import data string[] validateFields = ValidationFields.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value).ToArray(); string error = ""; var importedData = BOL.ProtocolMgmtServices.ImportProtocol(xDoc, existingProtocolId, out error, validateFields); if (!string.IsNullOrEmpty(error)) { throw new ClientException(error); } DisplayResults(importedData); // register update script var protocols = importedData.OfType <Protocol>(); if (protocols.Count() > 0) { Protocol protocol = protocols.First(); int protocolId = (int)protocol[Protocol.ProtocolId]; string protocolTitle = PageUtil.EscapeSingleQuotes(protocol[Protocol.ProtocolTitle].ToString()); string protocolNum = PageUtil.EscapeSingleQuotes(protocol[Protocol.ProtocolNum].ToString()); string url = base.GetQueryString(Page.ResolveUrl("AdminProtocol.aspx"), protocolId.ToString(), "", "", false); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refreshMainList", "refreshMainList('" + url + "', '" + protocolTitle + "', '" + protocolNum + "')", true); } } catch (ClientException ex) { ErrorText.Text = ex.Message; } catch (Exception ex) { ErrorText.Text = "Error processing the file, please verify it is a valid Protocol XML Mapping."; } }
protected void Page_Load(object sender, EventArgs e) { // NOTE: this needs to be modified so it can handle profiles for "No Patient" string subTopicIdString = Request.Form["SubTopicId"]; if (!string.IsNullOrEmpty(subTopicIdString)) { int subTopicId = int.Parse(subTopicIdString); PatientEducationDa da = new PatientEducationDa(); DataRow dr = da.GetSubTopicProfileContent(subTopicId); string subTopicName = PageUtil.EscapeSingleQuotes(dr[PatientEdSubTopic.SubTopicName].ToString()); // Content is literal HTML, so any newlines must be stripped or replaces with <br /> string subTopicContent = PageUtil.EscapeSingleQuotes(dr[PatientEdSubTopic.SubTopicContent].ToString()); subTopicContent = subTopicContent.Replace("\r\n", " "); subTopicContent = subTopicContent.Replace("\n", " "); string topicId = PageUtil.EscapeSingleQuotes(dr[PatientEdTopic.TopicId].ToString()); string topicName = PageUtil.EscapeSingleQuotes(dr[PatientEdTopic.TopicName].ToString()); string topicContent = PageUtil.EscapeSingleQuotes(dr[PatientEdTopic.TopicDescription].ToString()); string sectionId = PageUtil.EscapeSingleQuotes(dr[PatientEdSection.SectionId].ToString()); string sectionName = PageUtil.EscapeSingleQuotes(dr[PatientEdSection.SectionName].ToString()); string sectionContent = PageUtil.EscapeSingleQuotes(dr[PatientEdSection.SectionDescription].ToString()); string jsString = "['" + subTopicName + "','" + subTopicContent + "','" + topicId + "','" + topicName + "','" + topicContent + "','" + sectionId + "','" + sectionName + "','" + sectionContent + "']"; Response.Write(jsString); } }
/// <summary> /// During binding, set text and link for common tasks if permission exists /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetTaskLink(object sender, RepeaterItemEventArgs e) { string page = DataBinder.Eval(e.Item.DataItem, "page").ToString(); string displayName = DataBinder.Eval(e.Item.DataItem, "displayName").ToString(); string permission = DataBinder.Eval(e.Item.DataItem, "permission").ToString(); HtmlAnchor taskLink = e.Item.FindControl("taskLink") as HtmlAnchor; bool enabled = false; object o = XPathBinder.Eval(e.Item.DataItem, "@enabled"); if (o != null) { enabled = bool.Parse(o.ToString()); } if (enabled && PermissionManager.HasPermission(permission)) { taskLink.Visible = true; string onClickEvent = "return showCommonTaskLink('" + PageUtil.EscapeSingleQuotes(page) + "', '" + PageUtil.EscapeSingleQuotes(displayName) + "');"; taskLink.Attributes.Add("onclick", onClickEvent); } else { taskLink.Visible = false; } }
/// <summary> /// Regitser a list of current lookup field names /// </summary> private void RegisterCurrentCodes() { string[] clientArray = LookupFieldNames.Select(f => PageUtil.EscapeSingleQuotes(f)).ToArray(); string clientScriptArray = "['" + string.Join("','", clientArray) + "'];"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CURRENT_LKPFIELDS", "var CURRENT_LKPFIELDS = " + clientScriptArray, true); }
/// <summary> /// Gets a javascript function to setting page titles /// </summary> /// <returns></returns> public static string GetFriendlyJavascriptTitle(string title, string sectionId, string sectionName, string topicId, string topicName, string subTopicId, string subTopicName, string type) { string output = "<span id=\""; string id = "Section" + sectionId; if (type == "Topic") { id = "Topic" + topicId; } else if (type == "SubTopic") { id = "SubTopic" + subTopicId; } output += id + "\" "; string[] argList = new string[] { sectionId, sectionName, topicId, topicName, subTopicId, subTopicName }; for (int i = 0; i < argList.Length; i++) { string argVal = argList[i]; // Need to escape single quotes for js string argVal = PageUtil.EscapeSingleQuotes(argVal); // HTML encode to escape unusually characters argVal = HttpContext.Current.Server.HtmlEncode(argVal); argList[i] = argVal; } string args = "'" + String.Join("','", argList) + "'"; output += "onclick=\"setHiddenTitles(" + args + ",event);\">"; output += title; output += "</span>"; return(output); }
/// <summary> /// Updates the node title in the parent tree. /// </summary> private void RegisterParentFormTitleUpdate(string contentType, string contentId, string newTitle) { newTitle = PageUtil.EscapeSingleQuotes(newTitle); newTitle = PageUtil.EscapeDoubleQuotes(newTitle); string updateNodeTitle = "parent.updateNodeTitle('" + contentType + "','" + contentId + "','" + newTitle + "');"; Page.ClientScript.RegisterStartupScript(typeof(Page), "updateNodeTitle", updateNodeTitle, true); }
protected void SetGradeSelection(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // add on click string grade = DataBinder.Eval(e.Row.DataItem, "AE_Grade").ToString(); e.Row.Attributes["onclick"] = "setGradeAndLoad('" + PageUtil.EscapeSingleQuotes(grade) + "');"; } }
protected string GetOutputArray(DataRow[] rows) { string returnString = "["; foreach (DataRow row in rows) { string lookupCodeId = row[LookupCode.LookupCodeId].ToString(); string lookupCode = PageUtil.EscapeSingleQuotes(row[LookupCode.LkpCode].ToString()); returnString += "[\"" + lookupCodeId + "\",\"" + lookupCode + "\"],"; } returnString = returnString.TrimEnd(",".ToCharArray()) + "]"; return(returnString); }
protected void UpdateClick(object sender, EventArgs e) { try { int?specimenAccessionId = SaveForm(querySpecimenAccessionId); LoadForm(specimenAccessionId); } catch (ClientException ex) { string message = PageUtil.EscapeSingleQuotes(ex.Message); Page.ClientScript.RegisterStartupScript(this.GetType(), "SpecimenValidation", "alert('" + message + "');", true); } }
private string GetOptionsString(DataTable dt, string priKeyName, string displayNameField) { StringBuilder output = new StringBuilder(); foreach (DataRow row in dt.Rows) { string priKey = row[priKeyName].ToString(); string fieldName = row[displayNameField].ToString(); string optText = fieldName.Trim(); // Here is where the text for the option is formatted optText = PageUtil.EscapeSingleQuotes(optText); string optValue = priKey.Trim(); output.Append(optValue + ":" + optText + "|"); } return(output.ToString()); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected void GetLatestItemStatuses(CaisisAjaxEventArgs e) { DataView navigation = GetFilteredNavigation(); if (navigation.Count > 0) { var itemToStatus = from item in GetFilteredNavigation().ToTable().AsEnumerable() let itemId = EncryptPatientId(item[PatientItem.PatientItemId].ToString()) let status = item[PatientItem.Status].ToString() select "['" + PageUtil.EscapeSingleQuotes(itemId) + "','" + PageUtil.EscapeSingleQuotes(status) + "']"; e.ReturnValue = "[" + string.Join(",", itemToStatus.ToArray()) + "]"; } else { e.ReturnValue = "[]"; } }
protected void rptClinicItemCreated(Object Sender, RepeaterItemEventArgs e) { // create a reference to the current tr System.Web.UI.HtmlControls.HtmlContainerControl clinicListRow; clinicListRow = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("clinicListRow"); Literal eformStatus; eformStatus = (System.Web.UI.WebControls.Literal)e.Item.FindControl("eformStatus"); // if the patient ID for this row is empty, clicking the row will cause a javascript alert. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string localApptPatientId = ((DataRowView)e.Item.DataItem)["ApptPatientId"].ToString(); if (localApptPatientId == "") { clinicListRow.Attributes.Add("onclick", "alert('This patient is not in the database. No information about this patient beyond the data listed on this page is currently available.');"); } else { string urlVars = "epid=" + CustomCryptoHelper.Encrypt(localApptPatientId) + "&patientList=yes&listType=" + Server.UrlEncode(this.listTitle); string url = PageUtil.EscapeSingleQuotes("../DataEntryForms/index.aspx?" + urlVars + "&verifyPatientId=true"); clinicListRow.Attributes.Add("onclick", "parent.location='" + url + "';"); } string currentStatus = ((DataRowView)e.Item.DataItem)["CurrentStatus"].ToString(); if (!currentStatus.Equals("")) { string summary = ((DataRowView)e.Item.DataItem)["EFormName"].ToString() + " last updated by " + ((DataRowView)e.Item.DataItem)["UpdatedBy"].ToString() + " on " + ((DataRowView)e.Item.DataItem)["UpdatedTime"].ToString(); string spanOpeningText = "<a span onmouseover=\"showToolTipMessage('" + summary + "')\" onmouseout=\"hideToolTip()\">"; string spanClosingText = "</span>"; if (currentStatus.Equals(EformStatusManager.Status_DataEntryComplete) || currentStatus.Equals(EformStatusManager.Status_DataEntryInProgress) || currentStatus.Equals(EformStatusManager.Status_Narrated)) { eformStatus.Text = spanOpeningText + "EForm Initiated" + spanClosingText; } else if (currentStatus.Equals(EformStatusManager.Status_Approved)) { eformStatus.Text = spanOpeningText + "EForm Approved" + spanClosingText; } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetDeleteMessage(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Button deleteBtn = e.Item.FindControl("DeleteBtn") as Button; Label ptLabel = e.Item.FindControl("PtLabel") as Label; string patientId = DataBinder.Eval(e.Item.DataItem, Patient.PatientId).ToString(); string ptLastName = _pc.GetPatientLastName(DataBinder.Eval(e.Item.DataItem, Patient.PtLastName).ToString()); string ptFirstName = _pc.GetPatientFirstName(DataBinder.Eval(e.Item.DataItem, Patient.PtFirstName).ToString()); string ptMrn = _pc.GetPatientMRN(DataBinder.Eval(e.Item.DataItem, Patient.PtMRN).ToString()); string ptFullName = string.Format("{0}, {1} ({2})", ptLastName, ptFirstName, ptMrn); string ptProtocolStudyId = DataBinder.Eval(e.Item.DataItem, PatientProtocol.PtProtocolStudyId).ToString(); string participantID = DataBinder.Eval(e.Item.DataItem, "ParticipantID").ToString(); string clientClick = "return confirmDeleteSchemaPatient('" + PageUtil.EscapeSingleQuotes(ptFullName) + "','" + PageUtil.EscapeSingleQuotes(ptProtocolStudyId) + "', '" + PageUtil.EscapeSingleQuotes(participantID) + "', '" + patientId + "');"; string[] identifiers = new string[] { "Study Id: " + ptProtocolStudyId, "Participant ID: " + participantID, "Caisis Patient Id: " + patientId }; deleteBtn.ToolTip = "Remove patient " + ptFullName + " \n(" + string.Join(",\n", identifiers) + ")\n from this Treatment Arm"; deleteBtn.OnClientClick = clientClick; } }
protected void AddLkpCode(object sender, EventArgs e) { bool isValid = ValidateLkpFieldName(LkpFieldName.Text); if (isValid) { LookupCode lkpCode = new LookupCode(); lkpCode[LookupCode.LkpFieldName] = LkpFieldName.Text; lkpCode[LookupCode.LkpSuppress] = 0; lkpCode[LookupCode.LkpCode] = "[enter]"; lkpCode.Save(); string lkpFieldName = PageUtil.EscapeSingleQuotes(LkpFieldName.Text); Page.ClientScript.RegisterStartupScript(this.GetType(), "Reload", "closeAndReloadLkpCode('" + lkpFieldName + "')", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "WarnDuplicateField", "alert('The " + LookupCode.LkpFieldName + " already exists, please enter a new value.')", true); } }
protected void rptInPatientItemCreated(Object Sender, RepeaterItemEventArgs e) { // create a reference to the current tr System.Web.UI.HtmlControls.HtmlContainerControl inPatientRow; inPatientRow = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("inPatientRow"); // if the patient ID for this row is empty, clicking the row will cause a javascript alert. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string currentPatientId = ((DataRowView)e.Item.DataItem)["PatientId"].ToString(); if (currentPatientId.Equals("")) { inPatientRow.Attributes.Add("onclick", "alert('This patient is not in the database. No information about this patient beyond the data listed on this page is currently available.');"); } else { string urlVars = "epid=" + CustomCryptoHelper.Encrypt(currentPatientId) + "&patientList=yes&listType=" + Server.UrlEncode(this.listTitle); string url = PageUtil.EscapeSingleQuotes("../DataEntryForms/index.aspx?" + urlVars + "&verifyPatientId=true"); inPatientRow.Attributes.Add("onclick", "parent.location='" + url + "';"); } } }
protected void SetCurrentTransferClick(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string requestId = DataBinder.Eval(e.Item.DataItem, SpecimenRequest.SpecimenRequestId).ToString(); int collectionId = (int)DataBinder.Eval(e.Item.DataItem, SpecimenCollection.CollectionId); string distributionId = DataBinder.Eval(e.Item.DataItem, SpecimenDistribution.DistributionId).ToString(); // build row onclick action to edit transfer string script = string.Format("return editExistingTransfer('{0}', '{1}', '{2}', '{3}', null, null, null, event);", "edit", requestId, distributionId, collectionId); // allow modification in collection mode Button receivedButton = e.Item.FindControl("ReceivedButton") as Button; string statusMode = "received"; string action = "edit"; string status = ""; string btnText = ""; //string transferStatus = DataBinder.Eval(e.Item.DataItem, Specimen.SpecimenStatus).ToString(); //string compareStatus = transferStatus.ToLower(); // TODO: search specimen status for special statuses int protocolId = int.Parse(BaseProtocolId); DataTable specimens = da.GetTransferSpecimensByProtocol(protocolId, collectionId, base.GetSpecimenPatientsDatasetSQL()); // determine button mode if (inventoryMode == SpecimenInventoryMode.Pathology && SearchStatus(specimens, "in transit to pathology")) { status = "Banked by Pathology"; btnText = "Received by Pathology"; } else if (inventoryMode == SpecimenInventoryMode.Sequencing && SearchStatus(specimens, "in transit to sequencing")) { status = "Pending Sequencing Review"; btnText = "Received By Sequencing"; } else if (inventoryMode == SpecimenInventoryMode.Analysis && SearchStatus(specimens, "in transit to analysis")) { status = "Pending Analysis"; btnText = "Received By Analysis"; } else if (inventoryMode == SpecimenInventoryMode.cBIO && SearchStatus(specimens, "in transit to cbio portal")) { status = "Pending cBIO Portal Review"; btnText = "Received By cBIO"; } else { action = "readonly"; status = "readonly"; statusMode = "readonly"; btnText = "View"; } if (!string.IsNullOrEmpty(status)) { string receivedScript = string.Format("return editExistingTransfer('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', event);", action, requestId, distributionId, collectionId, statusMode, PageUtil.EscapeSingleQuotes(status), PageUtil.EscapeSingleQuotes(btnText)); receivedButton.Attributes["onclick"] = receivedScript; receivedButton.Text = btnText; receivedButton.Visible = CanEditTransfer(status); } else { receivedButton.Visible = false; } if (inventoryMode == SpecimenInventoryMode.Collection) { receivedButton.Text = "Edit"; receivedButton.Attributes["onclick"] = script; // receivedButton.Visible = true; } } }
protected void PopulateTableAttributes() { dirtyTableAttributes.Clear(); // special cases if (tableId.HasValue && !Page.IsPostBack) { MetadataTable biz = new MetadataTable(); biz.Get(tableId.Value); string tableName = biz[MetadataTable.TableName_Field].ToString(); // display with children //var childTableNames = BOL.BusinessObject.GetChildTableNames(tableName); var childTableNames = _dataEntryController.GetDataEntryForms(); // only show picker if there are child tables if (childTableNames.Count() > 0) { DisplayWithChild.DataSource = childTableNames; DisplayWithChild.DataBind(); } else { DisplayWithChild.Visible = false; DisplayWithChild_Label.Visible = false; } // plugins Caisis.Controller.PluginsController pc = new Caisis.Controller.PluginsController(); var pluginNames = pc.GetPluginNames(); Plugins.DataSource = pluginNames; Plugins.DataBind(); } // special case: relevant tables if (tableId.HasValue && !Page.IsPostBack) { var allTableNames = _dataEntryController.GetDataEntryForms();// BOL.BusinessObject.GetAllTableNames(); MostRelevantTables.DataSource = allTableNames; MostRelevantTables.DataBind(); } // get list of table attribute names/description var namesAndDescriptions = BOL.BusinessObject.GetAll <MetadataTableAttribute>().ToDictionary(a => a[MetadataTableAttribute.TableAttributeName].ToString(), a => a[MetadataTableAttribute.TableAttributeDescription].ToString(), StringComparer.OrdinalIgnoreCase); // get all table metadata MetadataDa da = new MetadataDa(); var tableSpecificMetadata = da.GetAllTableMetadata(tableId, QueryDiseaseId).AsEnumerable(); var tableDataSource = from record in tableSpecificMetadata let dAttributeName = record[MetadataTableAttribute.TableAttributeName].ToString() let dAttributeValue = record[MetadataTableAttributeValue.TableAttributeValue].ToString() let dTableAttributeValueId = record[MetadataTableAttributeValue.TableAttributeValueId].ToString() let dAttributeValueId = record[DiseaseAttributeValue.DiseaseAttributeValueId].ToString() orderby(!record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId) ? 0 : 1) ascending let a = new { TableAttributeName = dAttributeName, TableAttributeValue = dAttributeValue, TableAttributeValueId = dTableAttributeValueId, DiseaseAttributeValueId = dAttributeValueId } group a by a.TableAttributeName into g select g.First(); var inputs = CICHelper.GetCaisisInputControls(TablePanel); // get a list of attributes var attributeFields = GetAttributeToHiddenFields(TableAttributesPanel); // populate attributes (i.e., "PageTitle", "MenuTile",...) PopulateAttributes(new MetadataTableAttribute().TableName, MetadataTableAttribute.TableAttributeName, attributeFields); // populate table attribute values foreach (var entry in attributeFields) { string attributeName = entry.Key; // i.e., "PageTitle" var attributeIdField = entry.Value; // i.e., "Encounter" > "PageTitle" var tableAttributeValueId = GetTableAttributeValueIdControl(TablePanel, attributeName); // i.e. "Prostate Encounter Form" var attributeValue = GetTableAttributeValueControl(TablePanel, attributeName); // i.e., "Prostate" > "Encounter" > "PageTitle" = "Prostate Encounter Form" var diseaseAttributeValueId = GetDiseaseAttributeValueId(TablePanel, attributeName); // locate table attribute values var found = tableDataSource.Where(a => a.TableAttributeName.Equals(attributeName, StringComparison.CurrentCultureIgnoreCase)); if (found.Count() > 0) { var dataSource = found.First(); // set field value SetInputControlValue(tableAttributeValueId, dataSource.TableAttributeValueId.ToString(), null); SetInputControlValue(attributeValue, dataSource.TableAttributeValue, null); SetInputControlValue(diseaseAttributeValueId, dataSource.DiseaseAttributeValueId.ToString(), null); } // set friendly tooltip for attribute if (namesAndDescriptions.ContainsKey(attributeName)) { string attributeDescription = namesAndDescriptions[attributeName]; var attributeLabel = TablePanel.FindControl(attributeName + "_Label") as Label; if (attributeLabel != null) { // set friendly tooltip attributeLabel.Attributes["onmouseover"] = "showToolTipMessage('" + PageUtil.EscapeSingleQuotes(attributeDescription) + "');"; attributeLabel.Attributes["onmouseout"] = "hideToolTip();"; attributeLabel.ToolTip = attributeDescription; } } } // SPECIAL CASE: handle columns and grid if (GridView.Checked) { NumDisplayColumns.SelectedIndex = 2; } }
protected void GetBoxMatrix() { string myBoxId = Request.Form["BoxId"]; int boxId; if (int.TryParse(myBoxId, out boxId)) { SpecimenBox box = new SpecimenBox(); box.Get(boxId); //SpecimenPosition pos = new SpecimenPosition(); //pos.GetByParent(boxId); //// Build a string array of position indexes //DataTable positionDataTable = pos.DataSourceView.Table; DataTable positionDataTable = BusinessObject.GetByParentAsDataView <SpecimenPosition>(boxId).Table; int positionIndexCount = positionDataTable.Rows.Count; string[] posIndexes = new string[positionIndexCount]; string posIndexStringArray = "["; for (int i = 0; i < positionIndexCount; i++) { object val = positionDataTable.Rows[i][SpecimenPosition.Position]; if (val != null) { int index; if (int.TryParse(val.ToString(), out index)) { posIndexStringArray += index + ","; } } } posIndexStringArray = posIndexStringArray.TrimEnd(",".ToCharArray()); posIndexStringArray += "]"; int rows = 20; if (box[SpecimenBox.NoOfRows] != null && !string.IsNullOrEmpty(box[SpecimenBox.NoOfRows].ToString())) { rows = int.Parse(box[SpecimenBox.NoOfRows].ToString()); } int cols = 20; if (box[SpecimenBox.NoOfColumns] != null && !string.IsNullOrEmpty(box[SpecimenBox.NoOfColumns].ToString())) { cols = int.Parse(box[SpecimenBox.NoOfColumns].ToString()); } string boxType = String.Empty; if (box[SpecimenBox.BoxType] != null && !string.IsNullOrEmpty(box[SpecimenBox.BoxType].ToString())) { boxType = box[SpecimenBox.BoxType].ToString(); } int maxPos = rows * cols; if (box[SpecimenBox.MaxPositionNo] != null && !string.IsNullOrEmpty(box[SpecimenBox.MaxPositionNo].ToString())) { maxPos = int.Parse(box[SpecimenBox.MaxPositionNo].ToString()); } // Check if calling for transfer SpecimenManagerDa da = new SpecimenManagerDa(); string transferPositionsArray = ""; if (!string.IsNullOrEmpty(Request.Form["getTransfers"]) && !string.IsNullOrEmpty(Request.Form["collectionId"])) { int collectionId = int.Parse(Request.Form["collectionId"]); DataTable specsInBoxDT = da.GetSpecimensByBoxId(boxId, collectionId); ArrayList oBoxTransferPosArr = new ArrayList(); foreach (DataRow dr in specsInBoxDT.Rows) { if (dr["Transferable"].ToString() == "yes") { oBoxTransferPosArr.Add(dr[SpecimenPosition.Position].ToString()); } } string oBoxTransferPos = String.Join(", ", (string[])oBoxTransferPosArr.ToArray(typeof(string))); transferPositionsArray = "[" + oBoxTransferPos + "]"; } string clientTransferArray = !string.IsNullOrEmpty(transferPositionsArray) ? ("," + transferPositionsArray) : string.Empty; //if (!string.IsNullOrEmpty(Request.Form["NeedPath"]) || true) //{ int specimensInBox = da.GetSpecimensInBox(boxId).Rows.Count; DataSet resultsDataSet = da.GetBoxAndAncestors(boxId); DataTable boxesDT = resultsDataSet.Tables[0]; string boxIdStr = boxId.ToString(); DataRow boxRow = boxesDT.Select(SpecimenBox.BoxId + "=" + boxIdStr)[0]; string boxName = PageUtil.EscapeSingleQuotes(boxRow[SpecimenBox.BoxName].ToString()); DataTable containersDT = resultsDataSet.Tables[1]; string containerIdStr = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString(); DataRow containerRow = containersDT.Select(SpecimenContainer.ContainerId + " = " + containerIdStr)[0]; string containerName = PageUtil.EscapeSingleQuotes(containerRow[SpecimenContainer.ContainerName].ToString()); DataTable storagesDT = resultsDataSet.Tables[2]; string storagesIdStr = containersDT.Rows[0][SpecimenContainer.StorageId].ToString(); DataRow specimenRow = storagesDT.Select(SpecimenStorage.StorageId + " = " + storagesIdStr)[0]; string storageName = PageUtil.EscapeSingleQuotes(specimenRow[SpecimenStorage.StorageName].ToString()); DataTable siteDT = resultsDataSet.Tables[3]; string siteId = siteDT.Rows[0][SpecimenSite.SiteId].ToString(); DataRow siteRow = siteDT.Select(SpecimenSite.SiteId + " = " + siteId)[0]; string siteName = PageUtil.EscapeSingleQuotes(siteRow[SpecimenSite.SiteName].ToString()); BindDropDownList(StoragesDropDown, storagesDT, SpecimenStorage.StorageName, SpecimenStorage.StorageId, storagesIdStr); BindDropDownList(ContainersDropDown, containersDT, SpecimenContainer.ContainerName, SpecimenContainer.ContainerId, containerIdStr); BindDropDownList(BoxesDropDown, boxesDT, SpecimenBox.BoxName, SpecimenBox.BoxId, boxIdStr); SiteId.Text = siteId; //} string js = "new Array(" + rows + "," + cols + "," + maxPos + "," + posIndexStringArray + clientTransferArray + ",'" + siteName + "','" + storageName + "','" + containerName + "'," + specimensInBox + ",'" + boxName + "','" + boxType + "')"; BoxMatrix.Text = js; } }
/// <summary> /// Escapes single quoted client string /// </summary> /// <param name="clientString"></param> protected string EscapeClientValue(string clientString) { return(PageUtil.EscapeSingleQuotes(clientString)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetQuestionnaireRadio(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // always need to set question number label string question = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.Question).ToString(); string questionNumber = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.QuestionNum).ToString(); Label questionLabel = e.Row.FindControl("QuestionLabel") as Label; Label questionNumLabel = e.Row.FindControl("QuestionNumLabel") as Label; questionLabel.Text = question; questionNumLabel.Text = questionNumber; // set QuestionIdField field string metaQuestionId = DataBinder.Eval(e.Row.DataItem, MetadataSurveyQuestion.MetadataSurveyQuestionId).ToString(); HiddenField metaQuestionIdField = e.Row.FindControl("MetaQuestionIdField") as HiddenField; metaQuestionIdField.Value = metaQuestionId; // Set RegQuestioId for updates string regQuestionId = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.PatientProtocolRegQuestionnaireId).ToString(); HiddenField regQuestionIdField = e.Row.FindControl("RegQuestionIdField") as HiddenField; regQuestionIdField.Value = regQuestionId; // Popualate hidden fields HiddenField regIneligibleOverride = e.Row.FindControl("InEligibleRadioHidden") as HiddenField; string overrideBit = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.IneligibleResponseOverride).ToString(); regIneligibleOverride.Value = !string.IsNullOrEmpty(overrideBit) ? (bool.Parse(overrideBit) ? "1" : "") : ""; HiddenField regIneligibleOverrideReason = e.Row.FindControl("InEligibleRadioReason") as HiddenField; regIneligibleOverrideReason.Value = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.IneligibleOverrideReason).ToString(); // v6.x bool isr = !string.IsNullOrEmpty(regQuestionId); // set response + add scripts string questionResponse = DataBinder.Eval(e.Row.DataItem, PatientProtocolRegQuestionnaire.Response).ToString(); CaisisRadioButtonList responseRadioBtns = e.Row.FindControl("ResponsesContainer").Controls[0] as CaisisRadioButtonList; bool responseFound = false; bool isCanned = responseRadioBtns.CssClass == "canned"; responseRadioBtns.Value = questionResponse; foreach (ListItem responseItem in responseRadioBtns.Items) { string responseValue = responseItem.Value; // if current response equal values, check if (!responseFound && !string.IsNullOrEmpty(responseValue) && questionResponse.Equals(responseValue, StringComparison.OrdinalIgnoreCase)) { // responseItem.Selected = true; //responseFound = true; } // add scripts: only in default cases if (isCanned) { responseItem.Attributes["onclick"] = "onResponseSelected(this, '" + PageUtil.EscapeSingleQuotes(responseValue) + "', event);"; } } } }
/// <summary> /// Build list of input controls by column /// </summary> /// <param name="controlMap"></param> /// <param name="commonDataElements">A list of fields which are common data elements</param> protected virtual void BuildLayout(Dictionary <int, List <ICaisisInputControl> > controlMap, IEnumerable <string> commonDataElements) { columnsToContorols = controlMap; bool checkCDE = commonDataElements.Count() > 0; // BUILD CONTORLS INLINE bool isSingleColumn = controlMap.Count() == 1; foreach (var entry in controlMap) { int colIndex = entry.Key; int colNumber = colIndex + 1; var inputControls = entry.Value; Panel columnPanel = new Panel(); columnPanel.CssClass = "EditDataEntryForm_Column" + colNumber; // SPECIAL CASE: adjust single col layout if (isSingleColumn) { columnPanel.CssClass = columnPanel.CssClass + " EditDataEntryForm_ColumnSingle"; } // add column to main control ColumnsAndControls.Controls.Add(columnPanel); // add controls to columns foreach (var inputControl in inputControls) { // create row container Control control = inputControl as Control; Panel inputContainer = new Panel(); inputContainer.CssClass = "EditDataEntryField_Container"; // create external label for input controls HtmlGenericControl inputLabel = new HtmlGenericControl("label"); inputLabel.Attributes["class"] = "EditDataEntryField_Label"; Image inputIcon = new Image(); inputIcon.ImageUrl = "~/Images/shim.gif"; inputIcon.CssClass = "EditDataEntryField_icon_standard"; // set late bound associated id inputControl.ShowLabel = false; //inputLabel.InnerText = !string.IsNullOrEmpty(inputControl.FieldLabel) ? inputControl.FieldLabel : " "; inputControl.PreRender += (iInputControl, e) => { Control iControl = iInputControl as Control; // supress built in label and set external label if (iControl is CaisisHidden) { inputLabel.InnerHtml = " "; } else { // set table inputLabel.InnerHtml = !string.IsNullOrEmpty(iInputControl.FieldLabel) ? iInputControl.FieldLabel : iInputControl.Field; // set associated for inputLabel.Attributes["for"] = iControl.ClientID; } // set label css on required fields if (iInputControl.Required) { inputLabel.Attributes["class"] = "requiredField"; } // set common data element if (checkCDE && commonDataElements.Contains(iInputControl.Field)) { inputContainer.CssClass = "EditDataEntryField_Container EditDataEntryField_Common"; } // set metadata tooltips //inputLabel.ToolTip = iControl.HelpDescription; // get client args for tooltip events string clientArgs = string.Join(",", new string[] { "'" + PageUtil.EscapeSingleQuotes(iInputControl.HelpDescription) + "'", "this", "'" + iInputControl.Table + "'", "'" + iInputControl.Field + "'", "event" }); // get tooltip script for standard tooltip and metadata tooltips string tooltipScriptOn = "if(window.showToolTipMessage) { showToolTipMessage(" + clientArgs + "); }"; string tooltipScriptOff = "if(window.hideToolTip) { hideToolTip(" + clientArgs + "); }"; string metaTooltipSciptOn = "if(window.showMetadataTooltip) { showMetadataTooltip(" + clientArgs + "); }"; string metaTooltipSciptOff = "if(window.hideMetadataTooltip) { hideMetadataTooltip(" + clientArgs + "); }"; // view metadata on field row inputContainer.Attributes["onclick"] = metaTooltipSciptOn; // inputContainer.Attributes["onmouseout"] = metaTooltipSciptOff; // view tooltip on field label inputLabel.Attributes["onmouseover"] = tooltipScriptOn; inputLabel.Attributes["onmouseout"] = tooltipScriptOff; }; // UI fixese if (inputControl is CaisisHidden) { (inputControl as CaisisHidden).ShowSpacer = false; } // add controls to container inputContainer.Controls.Add(inputIcon); inputContainer.Controls.Add(inputLabel); inputContainer.Controls.Add(control); columnPanel.Controls.Add(inputContainer); // dispatch events // set icon (if applicable) if (SetControlIcon != null) { SetControlIcon(inputControl, inputIcon); } // dispatch build event OnBuildControl(inputControl); } } }
/// <summary> /// Regitsers a client script giving the user a message about udpate, delete, etc... /// </summary> /// <param name="message"></param> private void SetUpdatedMessage(string message) { string messageScript = "setUserUpdateMessage('" + PageUtil.EscapeSingleQuotes(message) + "');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "setUserUpdateMessage", messageScript, true); }
private void LoadSpecimenInfo() { CurrentSpecimen = new Specimen(); CurrentSpecimen.Get(this.specimenId); string parentspecId = CurrentSpecimen[Specimen.ParentSpecimenId].ToString(); pspecId.Value = parentspecId.ToString(); //if (!string.IsNullOrEmpty(parentspecId)) //{ // Specimen ParentSpecimen = new Specimen(); // ParentSpecimen.Get(Int32.Parse(parentspecId.ToString())); // pRemQty.Value = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); //} //RemQty.Value = CurrentSpecimen[Specimen.SpecimenRemainingQty].ToString(); CICHelper.SetFieldValues(this.inputControlsRow.Controls, CurrentSpecimen); //load box and position from SpecimenBoxes and SpecimenPositions tables string sBoxId = CurrentSpecimen[Specimen.BoxId].ToString(); if (!String.IsNullOrEmpty(sBoxId)) { int boxId = int.Parse(sBoxId); SpecimenBox box = new SpecimenBox(); box.Get(boxId); this.BoxId.Value = box[SpecimenBox.BoxId].ToString(); this.BoxName.Value = box[SpecimenBox.BoxName].ToString(); DataSet hierarchySet = da.GetBoxAndAncestors(boxId); DataTable boxesDT = hierarchySet.Tables[0]; DataTable containersDT = hierarchySet.Tables[1]; DataTable storagesDT = hierarchySet.Tables[2]; DataTable siteDT = hierarchySet.Tables[3]; if (boxesDT.Rows.Count >= 1) { string containerIdStr = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString(); DataRow containerRow = containersDT.Select(SpecimenContainer.ContainerId + " = " + containerIdStr)[0]; this.ContainerName.Value = PageUtil.EscapeSingleQuotes(containerRow[SpecimenContainer.ContainerName].ToString()); } if (containersDT.Rows.Count >= 1) { string storagesIdStr = containersDT.Rows[0][Caisis.BOL.SpecimenContainer.StorageId].ToString(); DataRow specimenRow = storagesDT.Select(Caisis.BOL.SpecimenStorage.StorageId + " = " + storagesIdStr)[0]; this.StorageName.Value = PageUtil.EscapeSingleQuotes(specimenRow[Caisis.BOL.SpecimenStorage.StorageName].ToString()); } if (siteDT.Rows.Count >= 1) { string siteId = siteDT.Rows[0][SpecimenSite.SiteId].ToString(); DataRow siteRow = siteDT.Select(SpecimenSite.SiteId + " = " + siteId)[0]; this.SiteName.Value = PageUtil.EscapeSingleQuotes(siteRow[SpecimenSite.SiteName].ToString()); } } string sPositionId = CurrentSpecimen[Specimen.PositionId].ToString(); if (!String.IsNullOrEmpty(sPositionId)) { int positionId = int.Parse(sPositionId); pos.Get(positionId); this.PositionName.Value = pos[SpecimenPosition.Position].ToString(); this.PositionId.Value = pos[SpecimenPosition.PositionId].ToString(); } }
// TODO: MIGRATION - DELETE ME /// <summary> /// Main method for ensuring Patient in Session matches the Patient represented in the current Page. /// Places Patient (as specified by Patient Biz) in Session (if needed), Log's Patient View (if needed) and updates header via client script. /// </summary> /// <param name="page">The current Page which contains relevant Session</param> /// <param name="ptBiz">The Patient BusinessObject representing the current Patient</param> public void PutPatientInSession(Page page, Patient ptBiz) { int patientId = (int)ptBiz[Patient.PatientId]; // Get Current Session HttpSessionState _session = page.Session; // Load SessionHandler for setting/reseting SESSION varaibles SessionHandler sHandler = new SessionHandler(_session); // LOG PATIENT VIEW AND SET PATIENT IN SESSION (if needed) // If no patient in session or patient is session != current, then log view and update session if (!sHandler.VerifyPatientInSession(ptBiz)) { // get encrypted patient id string encPatientId = Security.CustomCryptoHelper.Encrypt(patientId.ToString()); // log that user is viewing Patient UserController uController = new UserController(_session); uController.ViewPatient(patientId); // update Patient in Session sHandler.UpdateSessionPatientInfo(ptBiz); // SET PATIENT IN HEADER (UI) - generate client script for syncing header info // Check if patient is Deceased string isDeceased = this.IsPatientDeceased(ptBiz).ToString().ToLower(); // HANDLE SPECIAL CASE for identifiers (default to mrn) string identifierField = string.Empty;// _session[SessionKey.PtMRN].ToString(); UserController uc = new UserController(page.Session); if (uc.HasDefaultIdentifierType()) { string idType = uc.GetDefaultIdentifierType(); if (!string.IsNullOrEmpty(idType)) { identifierField = GetPatientIdentifier(patientId, idType); } else { identifierField = GetPatientMRN(ptBiz); } } else { identifierField = GetPatientMRN(ptBiz); } // build a list of client arguments, with single quotes escaped string[] clientScriptArgumentsList = new string[] { GetPatientFirstName(ptBiz), GetPatientLastName(ptBiz), identifierField, GetPatientDateOfBirth(ptBiz), encPatientId }; for (int i = 0; i < clientScriptArgumentsList.Length; i++) { string identifier = clientScriptArgumentsList[i]; clientScriptArgumentsList[i] = PageUtil.EscapeSingleQuotes(identifier); } // generates 'a','b','c','d' string clientScriptArguments = "'" + string.Join("','", clientScriptArgumentsList) + "'"; // function which sets patient header string clientScriptName = "top.changePatientInHeader"; // full client script,i.e., if(f) { f(a,b,c..); } string fullClientScript = "if(" + clientScriptName + ") { " + clientScriptName + "(" + clientScriptArguments + "," + isDeceased + "); }"; page.ClientScript.RegisterStartupScript(page.GetType(), "RegsiterPatientInSession", fullClientScript, true); } }
/// <summary> /// /// </summary> private void BuildAdverseClientEventDataSource() { if (!string.IsNullOrEmpty(Versions.Value)) { int?currentCatId = null; if (!string.IsNullOrEmpty(Categories.Value)) { currentCatId = int.Parse(Categories.Value); } CTCAEDa da = new CTCAEDa(); int termId = int.Parse(Versions.Value); DataTable dt = da.DoToxAdverseEventSearch(termId, ""); var data = from row in dt.AsEnumerable() let catId = (int)row["AE_CategoryID"] let sae = PageUtil.EscapeSingleQuotes(row["ToxDesc"].ToString()) let saeId = (int)row["CTC_AE_Toxicity_TermID"] let filter = currentCatId.HasValue ? currentCatId == catId : true where filter select "{ value: '" + sae + "', value: '" + sae + "', saeId: '" + saeId + "', catId: '" + catId + "'}"; // create CSV, list of json objects string SAE_DATA = "var SAE_DATA = [" + string.Join(",", data.ToArray()) + "];"; // register client data source Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SAE_DATA", SAE_DATA, true); } }
protected override void Render(HtmlTextWriter writer) { RegisterPerformedDateFields(); // notify container to pass along status date to go back to calendar Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "GO_TO_DATE", "if(parent.GO_TO_DATE != null) { parent.GO_TO_DATE = '" + PageUtil.EscapeSingleQuotes(ScheduledDate.Text) + "'; } ", true); base.Render(writer); }
/// <summary> /// Returns a client string (single quotes escaped) representing the table title. /// </summary> /// <param name="table"></param> /// <param name="defaultTitle"></param> /// <returns></returns> protected string GetClientTableTitle(string table, string defaultTitle) { string tableLabel = BusinessObject.HasTableLabel(table) ? BusinessObject.GetTableLabel(table) : defaultTitle; return(PageUtil.EscapeSingleQuotes(tableLabel)); }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <returns></returns> protected string EscapeValue(object value) { return(PageUtil.EscapeSingleQuotes(value.ToString())); }
/// <summary> /// /// </summary> /// <param name="dataItem"></param> /// <param name="field"></param> /// <returns></returns> protected string EvalClientValue(object dataItem, string field) { string value = DataBinder.Eval(dataItem, field).ToString(); return(PageUtil.EscapeSingleQuotes(value)); }
private void LoadSpecimenInfo() { Specimen specimen = new Specimen(); specimen.Get(this.specimenId); string parentspecId = specimen[Specimen.ParentSpecimenId].ToString(); pspecId.Value = parentspecId.ToString(); //if (!string.IsNullOrEmpty(parentspecId)) //{ // Specimen ParentSpecimen = new Specimen(); // ParentSpecimen.Get(Int32.Parse(parentspecId.ToString())); // pRemQty.Value = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); //} CICHelper.SetFieldValues(this.inputControlsRow.Controls, specimen); //getting patient identifier PtId.Text = _identifierType + " :"; SpecimenManagerDa da = new SpecimenManagerDa(); string datasetSql = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]); DataTable dt = da.GetIdentifier(this.specimenId, _identifierType, datasetSql); string identifier = dt.Rows[0].ItemArray[2].ToString(); TumorBankNumber.Text = identifier.ToString(); //load box and position from SpecimenBoxes and SpecimenPositions tables string sBoxId = specimen[Specimen.BoxId].ToString(); if (!String.IsNullOrEmpty(sBoxId)) { int boxId = int.Parse(sBoxId); SpecimenBox box = new SpecimenBox(); box.Get(boxId); this.BoxId.Value = box[SpecimenBox.BoxId].ToString(); this.BoxName.Value = box[SpecimenBox.BoxName].ToString(); DataSet hierarchySet = da.GetBoxAndAncestors(boxId); DataTable boxesDT = hierarchySet.Tables[0]; DataTable containersDT = hierarchySet.Tables[1]; DataTable storagesDT = hierarchySet.Tables[2]; DataTable siteDT = hierarchySet.Tables[3]; if (boxesDT.Rows.Count >= 1) { string containerIdStr = boxesDT.Rows[0][SpecimenBox.ContainerId].ToString(); DataRow containerRow = containersDT.Select(SpecimenContainer.ContainerId + " = " + containerIdStr)[0]; this.ContainerName.Value = PageUtil.EscapeSingleQuotes(containerRow[SpecimenContainer.ContainerName].ToString()); } if (containersDT.Rows.Count >= 1) { string storagesIdStr = containersDT.Rows[0][Caisis.BOL.SpecimenContainer.StorageId].ToString(); DataRow specimenRow = storagesDT.Select(Caisis.BOL.SpecimenStorage.StorageId + " = " + storagesIdStr)[0]; this.StorageName.Value = PageUtil.EscapeSingleQuotes(specimenRow[Caisis.BOL.SpecimenStorage.StorageName].ToString()); } if (siteDT.Rows.Count >= 1) { string siteId = siteDT.Rows[0][SpecimenSite.SiteId].ToString(); DataRow siteRow = siteDT.Select(SpecimenSite.SiteId + " = " + siteId)[0]; this.SiteName.Value = PageUtil.EscapeSingleQuotes(siteRow[SpecimenSite.SiteName].ToString()); } } string sPositionId = specimen[Specimen.PositionId].ToString(); if (!String.IsNullOrEmpty(sPositionId)) { int positionId = int.Parse(sPositionId); SpecimenPosition pos = new SpecimenPosition(); pos.Get(positionId); this.PositionName.Value = pos[SpecimenPosition.Position].ToString(); this.PositionId.Value = pos[SpecimenPosition.PositionId].ToString(); } }