📄 summary.ascx.cs
字号:
namespace Caisis.UI.Modules.All.DataEntryForms
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections.Specialized;
using System.Collections;
using Caisis.Security;
using Caisis.Controller;
using Caisis.DataAccess;
using Caisis.BusinessObject;
using Caisis.UI.Core.Classes;
using Caisis.UI.Core.DataEntryForms;
/// <summary>
/// Summary description for Summary.
/// </summary>
public abstract class Summary : DataEntryControl
{
string userName;
protected HtmlInputHidden narrativeId;
protected HtmlSelect narrator;
protected HtmlTextArea narrative;
protected HtmlForm dataForm;
protected Label preRPNomo, preXRTNomo, preBrachyNomo, postRP2yrNomo, postRP5yrNomo, postRP7yrNomo;
protected Repeater hpi, rowCount, rptHPI, rptAllergies, rptMedications, rptComorbidities;
protected Literal HPIerrorMsg;
private int RowsAllowed;
protected HtmlTableRow NomogramErrorTableRow;
protected Label NomogramError;
override protected void Page_Load(object sender, System.EventArgs e)
{
Page.RegisterArrayDeclaration("requiredFieldArray","");
//From GU Form
BuildHPI();
//Allergies
AllergyDa allergyDa = new AllergyDa();
DataSet allergiesDs = allergyDa.GetRecords(this.patientID);
rptAllergies.DataSource = allergiesDs.Tables[0].DefaultView;
rptAllergies.DataBind();
//Medications
MedicationDa medDa = new MedicationDa();
DataSet medDs = medDa.GetRecords(this.patientID);
rptMedications.DataSource = medDs.Tables[0].DefaultView;
rptMedications.DataBind();
//Comorbidities
ComorbidityDa comDa = new ComorbidityDa();
DataSet comDs = comDa.GetRecords(this.patientID);
rptComorbidities.DataSource = comDs.Tables[0].DefaultView;
rptComorbidities.DataBind();
//PageUtil.DisableIsDirtyFunction((HtmlInputHidden)Parent.FindControl("IsDirtyPostBack"));
//function needed so is dirty function checks that if a value has been changed ONLY when the current user name is the selected option
string strJScript = "<SCRIPT LANGUAGE=javascript>\n";
strJScript += "<!-- \n";
strJScript += "function toggleIsDirtyFunction()\n";
strJScript += "{\n";
strJScript += "if(document.forms[0]." + narrator.ClientID + ".options[document.forms[0]." + narrator.ClientID + ".selectedIndex].text == '" + userName + "'){ \n";
strJScript += "this.document.forms[0].IsDirtyPostBack.value = 'true'; \n";
strJScript += "}else{ \n";
strJScript += "this.document.forms[0].IsDirtyPostBack.value = 'false'; \n";
strJScript += "} \n";
strJScript += "} \n";
strJScript += " \n//--></SCRIPT>";
Page.RegisterClientScriptBlock("toggleIDF", strJScript);
narrator.Attributes.Add("onChange", "toggleIsDirtyFunction();");
base.Page_Load(sender, e);
}
//Get HPI data; formatted OnItemBound
protected void BuildHPI()
{
try
{
if (patientID != 0)
{
// for stored procedures like hpi, which has the nomograms attached to it. the nomo's are referenced differently.
//
SqlCommand pcom = DataAccessHelper.CreateCommand("spGetPatientHPI");
DataAccessHelper.AddIntInputParam(pcom, "patientID", this.patientID);
// DataAccessHelper.AddStringInputParam(pcom, "charLineFeed", "<br>");
// DataAccessHelper.AddIntInputParam(pcom, "breakAtLine", 8);
DataAccessHelper.AddBitInputParam(pcom, "NomogramResults", 1);
DataAccessHelper.AddBitInputParam(pcom, "NomogramValues", 1);
DataSet hpiDs = DataAccessHelper.GetList(pcom);
//
//Set number of hpi rows before DataBind; rows divided by 2 used to create second column of output OnItemBound
//
int HpiRecordCount = hpiDs.Tables[0].Rows.Count;
if(HpiRecordCount > 6)
{
double rowsPerColumn = HpiRecordCount/2 ;
RowsAllowed = ((int)Math.Round(rowsPerColumn)) - 1;
}
else
{
RowsAllowed = HpiRecordCount;
}
hpi.DataSource = hpiDs.Tables[0].DefaultView;
hpi.DataBind();
//
//nomograms are in a second result set
//
preRPNomo.Text = hpiDs.Tables[1].Rows[0]["preRPNomo"].ToString();
preXRTNomo.Text = hpiDs.Tables[1].Rows[0]["preXRTNomo"].ToString();
preBrachyNomo.Text = hpiDs.Tables[1].Rows[0]["preBrachyNomo"].ToString();
postRP2yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP2yrNomo"].ToString();
postRP5yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP5yrNomo"].ToString();
postRP7yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP7yrNomo"].ToString();
string PreRPError, PreXRTError, PreBrachyError, PostRPError;
PreRPError = hpiDs.Tables[1].Rows[0]["PreRPError"].ToString();
PreXRTError = hpiDs.Tables[1].Rows[0]["PreXRTError"].ToString();
PreBrachyError = hpiDs.Tables[1].Rows[0]["PreBrachyError"].ToString();
PostRPError = hpiDs.Tables[1].Rows[0]["PostRPError"].ToString();
if (PreRPError != null && PreRPError.Length > 0)
{
preRPNomo.ToolTip = PreRPError;
preRPNomo.Attributes.Add("style", "cursor:hand;");
preRPNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
// old:with error displayed all the time
//NomogramError.Text += "<strong>* Cannot calculate PreRP:</strong> " + PreRPError + "<br/>";
//preRPNomo.Text += "*";
}
if (PreXRTError != null && PreXRTError.Length > 0)
{
if (PreXRTError == "No XRT noted.")
{
preXRTNomo.Text = "No XRT";
}
else
{
preXRTNomo.ToolTip = PreXRTError;
preXRTNomo.Attributes.Add("style", "cursor:hand;");
preXRTNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
// old:with error displayed all the time
//NomogramError.Text += "<strong>** Cannot calculate PreXRT:</strong> " + PreXRTError + "<br/>";
//preXRTNomo.Text += "**";
}
}
if (PreBrachyError != null && PreBrachyError.Length > 0)
{
preBrachyNomo.ToolTip = PreBrachyError;
preBrachyNomo.Attributes.Add("style", "cursor:hand;");
preBrachyNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
// old:with error displayed all the time
//NomogramError.Text += "<strong>*** Cannot calculate PreBrachy:</strong> " + PreBrachyError + "<br/>";
//preBrachyNomo.Text += "***";
}
if (PostRPError != null && PostRPError.Length > 0)
{
if (PostRPError == "No radical prostatectomy noted.")
{
postRP2yrNomo.Text = "No RP";
postRP5yrNomo.Text = "No RP";
postRP7yrNomo.Text = "No RP";
}
else
{
postRP2yrNomo.ToolTip = PostRPError;
postRP2yrNomo.Attributes.Add("style", "cursor:hand;");
postRP2yrNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
postRP5yrNomo.ToolTip = PostRPError;
postRP5yrNomo.Attributes.Add("style", "cursor:hand;");
postRP5yrNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
postRP7yrNomo.ToolTip = PostRPError;
postRP7yrNomo.Attributes.Add("style", "cursor:hand;");
postRP7yrNomo.Text += " <img src=\"../../Images/NomogramAlert.gif\" width=\"9\" height=\"9\">";
// old:with error displayed all the time
//NomogramError.Text += "<strong>**** Cannot calculate PostRP:</strong> " + PostRPError;
//postRP2yrNomo.Text += "****";
//postRP5yrNomo.Text += "****";
//postRP7yrNomo.Text += "****";
}
}
if (NomogramError.Text.Length < 1)
{
NomogramErrorTableRow.Visible = false;
}
}
}
catch(Exception ex)
{
HPIerrorMsg.Visible = true;
HPIerrorMsg.Text = "Error creating the hpi. The administrator has been notified.";
ExceptionHandler.Publish(ex);
}
}
protected void hpiItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
Literal StartNextHpiColumn;
StartNextHpiColumn = (Literal) e.Item.FindControl("StartNextHpiColumn");
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int rowNumber = e.Item.ItemIndex;
if(rowNumber == RowsAllowed)
{
StartNextHpiColumn.Text = "</td><td width=\"1\" height=\"95%\"><br><img src=\"../images/shimGray.gif\" width=\"1\" height=\"95%\" border=0></td><td class=\"HPITextExtraColumns\" valign=\"top\"><br>";
}
else
{
StartNextHpiColumn.Visible = false;
}
}
}
protected override DataEntryController GetController()
{
return new DataEntryController(new NarrativeDa(), Caisis.BusinessObject.Narrative.NarrativeId);
}
protected override BizObject GetRecord()
{
NarrativeDa da = new NarrativeDa();
BizObject bz = (BizObject)da.GetRecords(this.patientID);
return bz;
}
override protected BizObject GetRecord(DataRow dr)
{
NarrativeDa da = new NarrativeDa();
BizObject bz = (BizObject)da.GetRecords(this.patientID);
return bz;
}
protected override void SetFields(BizObject bz)
{
DataTable dt = bz.Tables[0];
dt.PrimaryKey = new DataColumn[] {dt.Columns[Narrative.NarratedBy]};
DataRow dr = dt.Rows.Find(userName);
if (dr != null)
{
narrativeId.Value = dr[Narrative.NarrativeId].ToString();
narrative.Value = dr[Narrative.NarrativeFld].ToString();
this.SetBaseFields(dr);
this._dataInfo = dr;
}
else
{
//put userName in list and set buttons to insert new narrativeDisp
narrator.Items.Insert(0, new ListItem(userName, "No narrative entered yet."));
narrative.Value = "No narrative entered yet.";
}
}
protected override BizObject GetParams()
{
Narrative nt = new Narrative();
DataRow dr = nt.Tables[0].NewRow();
dr[Narrative.NarrativeId] = PageUtil.ObjToInt(narrativeId.Value);
dr[Narrative.NarrativeFld] = narrative.Value;
dr[Narrative.NarratedBy] = Context.User.Identity.Name;
dr[Narrative.PatientId] = this.patientID;
this.AddBaseParams(dr);
nt.Tables[0].Rows.Add(dr);
return nt;
}
public override HtmlInputHidden GetPrimKeyField()
{
return narrativeId;
}
override protected void SetDataEntryInfo()
{
this._tableInfo = "Summary";
this._dataEntryTitle = "Summary";
}
override public void EditBtn_Click()
{
BizObject bz = this.GetRecord();
this.SetFields(bz);
if (narrator.Items.FindByText(userName) == null)
{
narrator.Items.Add(new ListItem(userName, ""));
}
narrator.Disabled = true;
}
public override void DeleteBtn_Click()
{
try
{
this.DeleteRecord();
this.ResetFormFields();
this.PopulateForm();
this.DisableFormFields();
}
catch (ClientException e)
{
this.commonFields.errMsg.Message= e.Message;
this._userError = true;
this.EditBtn_Click();
}
}
protected override void InsertRowAndPopulateForm()
{
BizObject bz = this.GetParams();
DataEntryController ct = GetController();
ct.InsertRecord(bz);
this.PopulateForm(bz);
}
/*no longer used
public override void UnlockBtn_Click()
{
try
{
DataEntryController ct = (DataEntryController)GetController();
ct.UnlockRecord(int.Parse(this.GetPrimKeyField().Value));
this.DisableFormFields();
this.PopulateForm();
}
catch (ClientException e)
{
this.commonFields.errMsg.Message= e.Message;
this.PopulateForm();
this._userError = true;
}
}*/
override public void PopulateForm(BizObject bz)
{
DataTable dt = bz.Tables[0];
if(dt.Rows.Count > 0)
{
//Narrator javascipt
string narJs = "<script language=javascript>";
narJs += "\n function setNarrative(){";
narJs += "\n document.dataForm."+narrative.ClientID+".value=document.dataForm."+narrator.ClientID+".options[document.dataForm."+narrator.ClientID+".selectedIndex].value;";
narJs += "\n }";
narJs += "\n </script>";
Page.RegisterClientScriptBlock("narJs", narJs);
narrator.Attributes.Add("onclick","setNarrative();");
narrator.DataSource = dt.DefaultView;
narrator.DataTextField = "NarratedBy";
narrator.DataValueField = "Narrative";
narrator.DataBind();
}
//check for EditNarrative permission
if(PermissionManager.HasPermission("EditNarrative"))
{
SetFields(bz);
if (narrator.Items.FindByText(userName) != null)
{
int index = narrator.Items.IndexOf(narrator.Items.FindByText(userName));
narrator.SelectedIndex = index;
}
}
else
{
PageUtil.TurnBtnOff(((DataEntryButtons)Parent.FindControl("entryButtons")).saveBtn);
PageUtil.TurnBtnOff(((DataEntryButtons)Parent.FindControl("entryButtons")).cancelBtn);
PageUtil.TurnBtnOff(((DataEntryButtons)Parent.FindControl("entryButtons")).deleteBtn);
PageUtil.HideContainerButton(((DataEntryButtons)Parent.FindControl("entryButtons")).editBtn);
}
}
public override void DisableFormFields()
{
//narrative.Disabled = true;
narrative.Attributes.Add("ReadOnly","Yes");
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
this.userName = Context.User.Identity.Name;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -