protected void Page_Load(object sender, EventArgs e)
        {
            var pm = Request.QueryString["pm"];
            pageMode.Value = pm;
            EncounterService service = new EncounterService();
            if (pm == "edit")
            {
                var medId = Request.QueryString["medId"];
                mId.Value = medId;
                medication = service.GetMedication(Convert.ToInt64(medId)); 
                medications.Text = medication.Medicine;
                dosage.Text = medication.Dosage;
                var atv = medication.IsActive;
                radioMedications.Items[0].Selected = atv;
                radioMedications.Items[1].Selected = !atv;

                startDate.Text = medication.StartDate == SqlDateTime.MinValue ? string.Empty : medication.StartDate.ToString(Utility.GlobalDateFormat);  
                medicationStop.Text = medication.StopDate == SqlDateTime.MinValue ? string.Empty : medication.StartDate.ToString(Utility.GlobalDateFormat);
            }
            else if (pm == "add")
            {
                var aId = Request.QueryString["aId"];
                asId.Value = aId;

            }
        }
        public Medication EditMedication(string id, string medication, string isActive, string dosage, string type, string startDate, string stopDate)
        {
            List<SqlParameter> sqlParms = new List<SqlParameter>();

            CreateMedicationParams(id, medication, isActive, dosage, type, startDate, stopDate, sqlParms);

            var robj = new Medication();
            using (SqlDataReader sqlobj = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, "Encounters_EditMedication", sqlParms.ToArray()))
            {
                while (sqlobj.Read())
                {
                    robj = GetMedicationData(sqlobj);
                }
            }
            return robj;
        }
 private static Medication GetMedicationData(SqlDataReader sqlobj)
 {
     var robj = new Medication();
     robj.Id = DBHelper.getInt64(sqlobj, "Id");
     robj.AssessmentId = DBHelper.getInt64(sqlobj, "AssessmentId");
     robj.Medicine = DBHelper.getString(sqlobj, "Medication");
     robj.IsActive = DBHelper.getBool(sqlobj, "IsActive");
     robj.Dosage = DBHelper.getString(sqlobj, "Dosage");
     robj.Type = DBHelper.getString(sqlobj, "Type");
     var sDate = DBHelper.getDateTime(sqlobj, "StartDate");
     robj.StartDate = sDate;
     robj.StopDate = DBHelper.getDateTime(sqlobj, "StopDate");
     robj.StartDateString = sDate == SqlDateTime.MinValue ? string.Empty : sDate.ToString(Utility.GlobalDateFormat);
     return robj;
 }
        public Medication GetMedication(long medicationId)
        {
            SqlParameter[] sqlParms = new SqlParameter[]{
                new SqlParameter("MedicationId",medicationId)
            };

            var robj = new Medication();
            using (SqlDataReader sqlobj = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, "Encounters_GetMedication", sqlParms))
            {
                while (sqlobj.Read())
                {
                    robj = GetMedicationData(sqlobj);
                }
            }
            return robj;
        }