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

📄 medicationsform.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;
	using Caisis.UI.Core.Classes.CustomControls;


	/// <summary>
	///	THis form is used to update a patient's medications history.
	///	This form is an example of how all Forms that inherit from DataEntryControl are constructed.
	/// </summary>
	public abstract class Medications : DataEntryControl
	{

        protected HtmlInputHidden medicationId;

		//use MedicationFld, not Medication since class name is Medications
		protected HtmlSelect MedType, medRoute, medUnits, dataQuality;

		protected HtmlInputText medDateText, medDate, medStopDateText, medStopDate, medDose, medTotalDose;
		
		protected ComboBox MedicationFld, medDataSource, medIndication, medSchedule;

		protected HtmlTextArea medNotes;

		protected HtmlForm dataForm;
		
	
		protected HtmlImage medDateTextCal, medStopDateTextCal;

		/// <summary>
		/// Populates the DropDown lists and ComboBoxes with lookupCodes.  Also registers the Javascript necessary
		/// for ComboBox and Calendar Buttons functionality.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		override protected void Page_Load(object sender, System.EventArgs e)
		{	
			//populate select box options from db look up codes
			PageUtil.FillLkpDropDown(MedType, "MedType", ViewState);
			PageUtil.FillLkpDropDown(medRoute, "MedRoute", ViewState);
			PageUtil.FillLkpDropDown(medUnits, "MedUnits", ViewState);
			PageUtil.FillLkpDropDown(dataQuality, "DataQuality", ViewState);

			//array created for combo boxes. One for each ComboBox
			Page.RegisterClientScriptBlock("MedicationsArray", PageUtil.FillComboDropDown(MedicationFld.RefBy, "Medication"));
			Page.RegisterClientScriptBlock("medDataSource", PageUtil.FillComboDropDown(medDataSource.RefBy, "DataSource"));
			Page.RegisterClientScriptBlock("medIndication", PageUtil.FillComboDropDown(medIndication.RefBy, "Indication"));
			Page.RegisterClientScriptBlock("medSchedule", PageUtil.FillComboDropDown(medSchedule.RefBy, "MedSchedule"));

			//array created holding required fields
//			string reqFieldArray = PageUtil.CreateValidationScript("'"+MedType.ClientID+"'");
//			Page.RegisterClientScriptBlock("requiredFieldArray", reqFieldArray);

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


			PageUtil.AddCalendarFunction(medDateTextCal, medDateText);
			PageUtil.AddCalendarFunction(medStopDateTextCal, medStopDateText);

			PageUtil.AddFuzzyDateFunction(medDateText, medDate);
			PageUtil.AddFuzzyDateFunction(medStopDateText, medStopDate);

			// enforce stop date >= start date:
			medStopDateText.Attributes["onblur"] += " alertStartStopDate(dataForm." + medDateText.ClientID +",this,dataForm." + medStopDate.ClientID + ");";
			medDateText.Attributes["onblur"] += " alertStartStopDate(this,dataForm." + medStopDateText.ClientID + ",dataForm." + medStopDate.ClientID + ");";

			base.Page_Load(sender, e);
		}

	
		/// <summary>
		/// This code is no longer necessary now that the form values are selected from the database on 
		/// each page view.  Old Functionality:  Saves the selectedIndex of the dropdown lists (dropDowns have viewstate disabled to minimize
		/// size of page viewstate
		/// </summary>
		/// <returns></returns>
		override protected object SaveViewState()  
		{
			PageUtil.AddSelectToViewState(ViewState, MedType);
			PageUtil.AddSelectToViewState(ViewState, medRoute);
			PageUtil.AddSelectToViewState(ViewState, medUnits);
			PageUtil.AddSelectToViewState(ViewState, dataQuality);
			
			//Add Combo Boxes to the view state
			PageUtil.AddComboToViewState(ViewState, MedicationFld);
			PageUtil.AddComboToViewState(ViewState, medIndication);
			PageUtil.AddComboToViewState(ViewState, medDataSource);
			PageUtil.AddComboToViewState(ViewState, medSchedule);
			
			return base.SaveViewState();
		}

		/// <summary>
		/// Retrieves the medicationID field which is the primary Key for Medications.
		/// </summary>
		/// <returns></returns>
		override public HtmlInputHidden GetPrimKeyField()  
		{
			return medicationId;
		}


		/// <summary>
		/// Sets form level variable containing information about the source table and title of the form.
		/// THis information is used by the DataEntryContainer for display and processing.
		/// </summary>
		override protected void SetDataEntryInfo()  
		{
			this._tableInfo = "Medications";
			this._dataEntryTitle = "Medications";
			//this logic moved to DataEntryContainer because will be same for all forms for now
/*			this._permissions = new Hashtable();
			_permissions["Edit"] = "EditData";
			_permissions["Delete"] = "EditData";
			_permissions["New"] = "EditData";
			_permissions["Lock"] = "EditData";
			_permissions["Save"] = "EditData";  */
		}


		/// <summary>
		/// Creates a Medication BizObject to store all the data entered in the Medications Form.
		/// </summary>
		/// <returns></returns>
		override protected BizObject GetParams()  
		{
			Medication med = new Medication();
			DataRow dr = med.Tables[Medication.Table_Medications].NewRow();

			if (!medicationId.Value.Equals("")) 
			{
				dr[Medication.MedicationId] = medicationId.Value;
			}
			dr[Medication.PatientId] = this.patientID;
			dr[Medication.MedDateText] = medDateText.Value;
			dr[Medication.MedDate] = PageUtil.ObjToDateTime(medDate.Value);
			
			dr[Medication.MedType] = Request[MedType.UniqueID].ToString();
			dr[Medication.MedicationFld] = Request.Form[MedicationFld.UniqueID].ToString();
			dr[Medication.MedIndication] = Request.Form[medIndication.UniqueID].ToString();
			dr[Medication.MedDataSource] = Request.Form[medDataSource.UniqueID].ToString();
			dr[Medication.MedStopDateText] = medStopDateText.Value;
			dr[Medication.MedStopDate] = PageUtil.ObjToDateTime(medStopDate.Value);
			dr[Medication.MedDose] = medDose.Value;
			dr[Medication.MedTotalDose] = medTotalDose.Value;
			dr[Medication.MedUnits] = Request.Form[medUnits.UniqueID].ToString();
			dr[Medication.MedSchedule] = Request.Form[medSchedule.UniqueID].ToString();
			dr[Medication.MedRoute] = Request.Form[medRoute.UniqueID].ToString();
			dr[Medication.MedNotes] = medNotes.Value;
			dr[Medication.MedQuality] = Request.Form[dataQuality.UniqueID].ToString();
			//dr[Medication.MedDataSource] = medDataSource.Value;

			AddBaseParams(dr);

			med.Tables[Medication.Table_Medications].Rows.Add(dr);
			med.AcceptChanges();

			return med;
		}

		/// <summary>
		/// Retrieves a DataEntryController constructed with the information required for processing 
		/// Medications information.
		/// </summary>
		/// <returns></returns>
		override protected DataEntryController GetController()  
		{
			return new DataEntryController(new MedicationDa(), Medication.MedicationId);
		}

	    /// <summary>
	    /// Populates the fields of the Medications form with the values supplied by the Medications
	    /// BizObject.
	    /// </summary>
	    /// <param name="bz"></param>
		override protected void SetFields(BizObject bz)  
		{
			Medication dsMed = (Medication)bz;
			DataRow dr = dsMed.Tables[Medication.Table_Medications].Rows[0];

			this.medicationId.Value = dr[Medication.MedicationId].ToString();

			medDateText.Value = dr[Medication.MedDateText].ToString();
			medDate.Value = PageUtil.ObjToDateString(dr[Medication.MedDate]);
			medStopDateText.Value = dr[Medication.MedStopDateText].ToString();
			medStopDate.Value = PageUtil.ObjToDateString(dr[Medication.MedStopDate]);
			medDose.Value = dr[Medication.MedDose].ToString();
			medTotalDose.Value = dr[Medication.MedTotalDose].ToString();
			//medDataSource.Value = dr[Medication.MedDataSource].ToString();
			medNotes.Value = dr[Medication.MedNotes].ToString();

			PageUtil.SelectDropDownItem(MedType, dr[Medication.MedType]);
			//PageUtil.SelectDropDownItem(medIndication, dr[Medication.MedIndication]);
			PageUtil.SelectDropDownItem(medUnits, dr[Medication.MedUnits]);
			PageUtil.SelectDropDownItem(medRoute, dr[Medication.MedRoute]);	
			PageUtil.SelectDropDownItem(dataQuality, dr[Medication.MedQuality]);

			MedicationFld.Value = dr[Medication.MedicationFld].ToString();
			medIndication.Value = dr[Medication.MedIndication].ToString();
			medDataSource.Value = dr[Medication.MedDataSource].ToString();
			medSchedule.Value = dr[Medication.MedSchedule].ToString();
			
			SetBaseFields(dr);
		}
	}
}

⌨️ 快捷键说明

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