protected void btnSave_Click(object sender, EventArgs e)
        {
            string labtobedone        = txtLabtobeDone.Text;
            string laborder           = ddlaborderedbyname.SelectedValue;
            string laborderdate       = txtlaborderedbydate.Text;
            string laborderResultBy   = ddlLabReportedbyName.SelectedValue;
            string laborderResultdate = txtlabReportedbyDate.Text;
            string appcurrdate        = hdappcurrentdate.Value;
            string strClinicalNotes   = txtClinicalNotes.Text;

            if (FieldValidation(labtobedone, laborderdate, laborder, appcurrdate, laborderResultdate, laborderResultBy) == false)
            {
                return;
            }
            ILabRequest requestMgr = (ILabRequest)ObjectFactory.CreateInstance("BusinessProcess.Laboratory.BLabRequest, BusinessProcess.Laboratory");

            if (LabOrderId > 0) //update
            {
                //
            }
            else
            {
                DateTime?nullDatetime = null;

                LabOrder order = this.OrderedLabs;
                order.LocationId    = this.LocationId;
                order.PatientPk     = this.PatientPk;
                order.ModuleId      = this.ModuleId;
                order.DeleteFlag    = false;
                order.CreateDate    = DateTime.Now;
                order.PreClinicDate = labtobedone == "" ? nullDatetime : Convert.ToDateTime(labtobedone);
                order.OrderDate     = Convert.ToDateTime(laborderdate);
                order.OrderedBy     = Convert.ToInt32(ddlaborderedbyname.SelectedValue);
                order.ClinicalNotes = strClinicalNotes;
                order.UserId        = this.UserId;

                order.OrderedTest.ForEach(o =>
                {
                    o.ResultBy   = Convert.ToInt32(ddlLabReportedbyName.SelectedValue);
                    o.ResultDate = Convert.ToDateTime(txtlabReportedbyDate.Text);
                    //o.ParameterResults.ForEach(p =>
                    //{

                    //});
                });


                LabOrder _saveOrder = requestMgr.SaveLabOrder(order, this.UserId, this.LocationId);
                this.OrderedLabs = _saveOrder;
                IQCareMsgBox.NotifyAction(string.Format("Lab Order number {0}, saved successfully", _saveOrder.OrderNumber), "Lab Order", false, this,
                                          string.Format("javascript:window.location='{0}'; return false;", this.RedirectUrl));
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string labtobedone      = txtLabtobeDone.Text;
            string laborder         = ddlaborderedbyname.SelectedValue;
            string laborderdate     = txtlaborderedbydate.Text;
            string appcurrdate      = hdappcurrentdate.Value;
            string strClinicalNotes = txtClinicalNotes.Text;

            if (FieldValidation(labtobedone, laborderdate, laborder, appcurrdate) == false)
            {
                return;
            }


            ILabRequest requestMgr = (ILabRequest)ObjectFactory.CreateInstance("BusinessProcess.Laboratory.BLabRequest, BusinessProcess.Laboratory");;

            if (LabOrderId > 0) //update
            {
                //
            }
            else
            {
                DateTime?nullDatetime = null;

                LabOrder order = this.OrderedLabs;

                order.PatientId     = this.PatientId;
                order.LocationId    = this.LocationId;
                order.ModuleId      = this.ModuleId;
                order.DeleteFlag    = false;
                order.OrderDate     = Convert.ToDateTime(laborderdate);
                order.CreateDate    = DateTime.Now;
                order.PreClinicDate = (labtobedone != null && String.IsNullOrEmpty(labtobedone)) ? nullDatetime : Convert.ToDateTime(labtobedone);
                order.OrderedBy     = Convert.ToInt32(ddlaborderedbyname.SelectedValue);
                order.UserId        = this.UserId;
                order.ClinicalNotes = strClinicalNotes;

                if (order.OrderedTest.Count == 0)
                {
                    IQCareMsgBox.NotifyAction("No lab test selected", "Error saving lab order", true, this, "");
                    return;
                }
                LabOrder _saveOrder = requestMgr.SaveLabOrder(order, this.UserId, this.LocationId);
                IQCareMsgBox.NotifyAction(string.Format("Lab Order number {0}, saved successfully", _saveOrder.OrderNumber), "Lab Order", false, this, string.Format("javascript:window.location='{0}'; return true;", this.RedirectUrl));
            }
        }