⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patientphysiciansform.ascx.cs

📁 医疗决策支持系统
💻 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.Controller;

	using Caisis.DataAccess;
	using Caisis.BusinessObject;

	using Caisis.UI.Core.Classes;

	public abstract class PatientPhysiciansForm : DataEntryControl
	{

		protected HtmlSelect PhysicianId;
		protected HtmlSelect PtPhRole;
		protected HtmlSelect PtPhContactStatus;
		protected HtmlTextArea PtPhNotes;
		protected HtmlInputHidden PatientPhysicianId;


		protected Label PhysicianName, PhysicianSpecialty, PhysicianAddress1, PhysicianAddress2, PhysicianCity, PhysicianState, PhysicianPostalCode, PhysicianPhone, PhysicianFax, PhysicianInstitution;

		protected System.Web.UI.HtmlControls.HtmlTable PhysicianInfoTable;


		protected System.Web.UI.HtmlControls.HtmlAnchor EditPhysicianLink;

		protected HtmlImage EditExistingPhysicianButton;




		override protected void Page_Load(object sender, System.EventArgs e)
		{
			if (!(Request.QueryString["primKey"] != null && Request.QueryString["primKey"].Length > 0))
			{
				PhysicianInfoTable.Visible = false;
			}



			//populate protocols from distinct values
			PhysicianDa da = new PhysicianDa();
			DataSet ds = da.GetDistinctPhysicians();
			
			PhysicianId.DataSource		= ds.Tables[0].DefaultView;
			PhysicianId.DataValueField	= "PhysicianId";
			PhysicianId.DataTextField	= "PhName"; 
			PhysicianId.DataBind();
			PhysicianId.Items.Insert(0,new ListItem(""));
			
			//populate look up and distinct value select boxes
			PageUtil.SelectDropDownItem(PhysicianId, ViewState[PhysicianId.UniqueID]);
			PageUtil.FillLkpDropDown(PtPhRole, "PtPhRole", ViewState);
			PageUtil.FillLkpDropDown(PtPhContactStatus, "PtPhContactStatus", ViewState);

			//create arrays that populate combo boxes
			

//			string reqFieldArray = PageUtil.CreateValidationScript("");
//			Page.RegisterArrayDeclaration("requiredFieldArray","'"+PhysicianId.UniqueID+"', '"+PtPhRole.UniqueID+"'");


			string reqFieldArray = PageUtil.CreateValidationScript("'"+PhysicianId.ClientID+"', '"+PtPhRole.ClientID+"'");
			Page.RegisterClientScriptBlock("requiredFieldArray", reqFieldArray);


			base.Page_Load(sender, e);

		}


		override public HtmlInputHidden GetPrimKeyField()
		{
			return PatientPhysicianId;
		}


		override protected object SaveViewState()
		{
			//add select and combo boxes to view state
			PageUtil.AddSelectToViewState(ViewState,PhysicianId);
			PageUtil.AddSelectToViewState(ViewState,PtPhRole);
			PageUtil.AddSelectToViewState(ViewState,PtPhContactStatus);
			

			return base.SaveViewState();
		}

		// Just use PhysicianId in method even though physicianId and patientId make up primary key
		// If physicianId exists
		/* NEED TO FIX - physicianId is currently a select
		override public HtmlInputHidden GetPrimKeyField()
		{
			return (HtmlSelect)PhysicianId.;
		}
		*/

		/* old one 
		override protected DataEntryController GetController()
		{
			return new TwoPKEntryController(new PatientPhysicianDa(), PatientPhysician.PatientId, PatientPhysician.PhysicianId); //NOTE: fix args
		}
		*/

		override protected DataEntryController GetController()
		{
			return new PatientPhysicianController(new PatientPhysicianDa()); //NOTE: fix args
		}


		override protected void SetDataEntryInfo()
		{
			this._tableInfo = "PatientPhysicians";
			this._dataEntryTitle = "Patient Physicians";
		}

		override protected BizObject GetParams()
		{
			PatientPhysician biz = new PatientPhysician();
			DataRow dr = biz.Tables[PatientPhysician.Table_PatientPhysicians].NewRow();


			if (!PatientPhysicianId.Value.Equals(""))
			{
				dr[PatientPhysician.PatientPhysicianId] = PatientPhysicianId.Value;
			}

			//selects use: Request.Form[FieldName.UniqueID].ToString();
			//dates use: PageUtil.ObjToDateTime(FieldName.Value);
			//checkbox use: if(FieldName.Checked){dr[BizObject.FieldName] = 1;}
			//Patient ID should = this.patientID
			
			dr[PatientPhysician.PatientId] = this.patientID;
			dr[PatientPhysician.PhysicianId] = Request.Form[PhysicianId.UniqueID].ToString();
			dr[PatientPhysician.PtPhRole] = Request.Form[PtPhRole.UniqueID].ToString();
			dr[PatientPhysician.PtPhContactStatus] = Request.Form[PtPhContactStatus.UniqueID].ToString();
			dr[PatientPhysician.PtPhNotes] = PtPhNotes.Value;

			AddBaseParams(dr);
			biz.Tables[PatientPhysician.Table_PatientPhysicians].Rows.Add(dr);
			biz.AcceptChanges();
			return biz;

		}

		protected override void SetFields(BizObject bz)
		{
			PatientPhysician biz = (PatientPhysician)bz;
			DataRow dr = biz.Tables[PatientPhysician.Table_PatientPhysicians].Rows[0];

			//selects use: PageUtil.SelectDropDownItem(fieldIdName, dr[Object.FieldName]);
			
			PatientPhysicianId.Value = dr[PatientPhysician.PatientPhysicianId].ToString();
			PageUtil.SelectDropDownItem(PhysicianId, dr[PatientPhysician.PhysicianId]);
			PageUtil.SelectDropDownItem(PtPhRole, dr[PatientPhysician.PtPhRole]);
			PageUtil.SelectDropDownItem(PtPhContactStatus, dr[PatientPhysician.PtPhContactStatus]);
			PtPhNotes.Value = dr[PatientPhysician.PtPhNotes].ToString();

			SetBaseFields(dr);



			if (dr[PatientPhysician.PhysicianId] != null && dr[PatientPhysician.PhysicianId].ToString().Length > 0)
			{
				int physPrimKey = int.Parse(dr[PatientPhysician.PhysicianId].ToString());
				SetPhysicianInfo(physPrimKey);
			}
		}

		protected void SetPhysicianSelect (Object sender, EventArgs e)
		{
			maintainFieldValues();

			
			if (Request.Form[PhysicianId.UniqueID] != null && Request.Form[PhysicianId.UniqueID].Length > 0)
			{
				int physPrimKey = int.Parse(Request.Form[PhysicianId.UniqueID]);
				PhysicianInfoTable.Visible = true;
				SetPhysicianInfo(physPrimKey);
			}

		}


		protected void SetPhysicianInfo(int physKeyValue)
		{
			PhysicianDa pDa = new PhysicianDa();
			DataSet pDs = pDa.GetRecord(physKeyValue);
				
			PhysicianName.Text = pDs.Tables[0].Rows[0]["PhTitle"].ToString() + " " + pDs.Tables[0].Rows[0]["PhFirstName"].ToString() + " " + pDs.Tables[0].Rows[0]["PhLastName"].ToString();
			if (pDs.Tables[0].Rows[0]["PhSuffix"].ToString().Length > 0)
			{
				PhysicianName.Text += " " + pDs.Tables[0].Rows[0]["PhSuffix"].ToString();
			}
			if (pDs.Tables[0].Rows[0]["PhSpecialty"].ToString().Length > 0)
			{
				PhysicianSpecialty.Text = pDs.Tables[0].Rows[0]["PhSpecialty"].ToString();
			}
			if (pDs.Tables[0].Rows[0]["PhAddress1"].ToString().Length > 0 )
			{
				PhysicianAddress1.Text = pDs.Tables[0].Rows[0]["PhAddress1"].ToString() + "<br/>";
			}
			if (pDs.Tables[0].Rows[0]["PhAddress2"].ToString().Length > 0 )
			{
				PhysicianAddress2.Text = pDs.Tables[0].Rows[0]["PhAddress2"].ToString() + "<br/>";
			}
			if (pDs.Tables[0].Rows[0]["PhCity"].ToString().Length > 0 )
			{
				PhysicianCity.Text = pDs.Tables[0].Rows[0]["PhCity"].ToString() + ", ";
			}
			if (pDs.Tables[0].Rows[0]["PhState"].ToString().Length > 0 )
			{
				PhysicianState.Text = pDs.Tables[0].Rows[0]["PhState"].ToString() + " ";
			}
			if (pDs.Tables[0].Rows[0]["PhPostalCode"].ToString().Length > 0 )
			{
				PhysicianPostalCode.Text = pDs.Tables[0].Rows[0]["PhPostalCode"].ToString();
			}
			if (pDs.Tables[0].Rows[0]["PhWorkPhone"].ToString().Length > 0 )
			{
				PhysicianPhone.Text = pDs.Tables[0].Rows[0]["PhWorkPhone"].ToString();
			}
			if (pDs.Tables[0].Rows[0]["PhFax"].ToString().Length > 0 )
			{
				PhysicianFax.Text = pDs.Tables[0].Rows[0]["PhFax"].ToString();
			}
			if (pDs.Tables[0].Rows[0]["PhInstitution"].ToString().Length > 0 )
			{
				PhysicianInstitution.Text = pDs.Tables[0].Rows[0]["PhInstitution"].ToString();
			}



			EditPhysicianLink.Attributes.Add("onclick", "popupAddEditPhysician('../../Core/Utilities/EditAPhysician.aspx?newWindow=true&splash=false&primKey=" + pDs.Tables[0].Rows[0]["PhysicianId"].ToString() + "');");
//old		EditPhysicianLink.Attributes.Add("onclick", "top.location = '../../Core/Utilities/EmptyContainer.aspx?TaskPage=EditAPhysician.aspx&splash=false&primKey=" + pDs.Tables[0].Rows[0]["PhysicianId"].ToString() + "';");

			
			
			EditExistingPhysicianButton.Src = "../../../Images/ViewEditAnotherPhysicianButton.gif";

		}



		override public void PopulateForm(BizObject bz)  
		{
			//only setFields if GetRecords actually returns at least one row, primKey may exist because passed down from parent record in one to one relationship
			if (bz != null && bz.Tables[0].Rows.Count != 0)
			{
				base.PopulateForm(bz);
			}
			else
			{
				ResetFormFields();
				PhysicianInfoTable.Visible = false;
				EditExistingPhysicianButton.Src = "../../../images/ViewEditExistingPhysicianButton.gif";
			}

		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -