protected void Page_Load(object sender, EventArgs e) { (Master.FindControl("levelOneNavigationUserControl1").FindControl("lblRoot") as Label).Text = "Services >> "; (Master.FindControl("levelOneNavigationUserControl1").FindControl("lblheader") as Label).Text = "Result Page"; (Master.FindControl("levelTwoNavigationUserControl1").FindControl("lblformname") as Label).Text = "Service Orders Result Page"; Master.ExecutePatientLevel = true; if (Application["AppCurrentDate"] != null) { hdappcurrentdate.Value = Application["AppCurrentDate"].ToString(); } if (!IsPostBack) { if (Session[SessionKey.SelectedLabTestOrder] == null) { string theUrl = string.Format("{0}", "~/Laboratory/Admin/LabTestMaster.aspx"); //Response.Redirect(theUrl); System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.Redirect(theUrl, true); } else { LabOrderTest selectedLab = (LabOrderTest)Session[SessionKey.SelectedLabTestOrder]; this.LabTestId = selectedLab.TestId; this.LabOrderTestId = selectedLab.Id; this.LabOrderTestId = selectedLab.LabOrderId; this.PopulateLabDetails(selectedLab); this.BindDropdownResultBy(); txtlabReportedbyDate.Text = DateTime.Now.ToString("dd-MMM-yyyy"); } } }
protected void gridTestRequested_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Remove") { string testId = (e.CommandArgument.ToString()); LabOrder orders = this.OrderedLabs; LabOrderTest orderedTest = orders.OrderedTest.FirstOrDefault(w => w.TestId.ToString() == testId); if (orderedTest != null) { if (orderedTest.Id > 0) { orders.OrderedTest.FirstOrDefault(w => w.TestId.ToString() == testId).DeleteFlag = true; } else { orders.OrderedTest.Remove(orderedTest); } } this.OrderedLabs = orders; this.BindLabTest(); } } catch (Exception ex) { this.ShowErrorMessage(ref ex); } }
/// <summary> /// Handles the ItemDataBound event of the repeaterLabTest control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param> protected void repeaterLabTest_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { LabOrderTest rowView = (LabOrderTest)e.Item.DataItem; string labOrderId = rowView.LabOrderId.ToString(); string labTestId = rowView.TestId.ToString(); int labOrdertestId = rowView.Id; Label labReportedbyDate = e.Item.FindControl("labReportedbyDate") as Label; // Label labelReportedbyName = e.Item.FindControl("labelReportedbyName") as Label; Button buttonResult = e.Item.FindControl("buttonResult") as Button; Label labelRequestNotes = e.Item.FindControl("labelRequestNotes") as Label; if (rowView.TestNotes != "") { if (rowView.TestNotes.Length <= 20) { labelRequestNotes.Text = rowView.TestNotes; } else { labelRequestNotes.Text = rowView.TestNotes.Substring(0, 19); } } DataTable _user = this.UserList; if (rowView.ResultBy.HasValue && rowView.ResultBy.HasValue) { // labelReportedbyName.Text = this.GetUserFullName(rowView.ResultBy.Value); labReportedbyDate.Text = rowView.ResultDate.Value.ToString("dd-MMM-yyyy hh:mm"); // buttonResult.Visible = false; buttonResult.Enabled = false; buttonResult.Text = this.GetUserFullName(rowView.ResultBy.Value); } else { //labelReportedbyName.Visible = false; buttonResult.Enabled = this.HasResultPermission; buttonResult.Text = "Enter Result"; //buttonResult.OnClientClick = "javascript:pageopen();return"// } Repeater repeater = e.Item.FindControl("repeaterResult") as Repeater; if (null != repeater) { List <LabTestParameterResult> paramResults = requestMgr.GetLabTestParameterResult(labOrdertestId); repeater.DataSource = paramResults; repeater.DataBind(); } } }
protected void repeaterLabTest_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (e.CommandName == "EnterResult") { int labtesOrderId = Convert.ToInt32(e.CommandArgument); //this.LabOrderId LabOrderTest thisTest = thisLabOrder.OrderedTest.DefaultIfEmpty(null).FirstOrDefault(t => t.Id == labtesOrderId); if (thisTest != null) { Guid g = Guid.NewGuid(); base.Session[SessionKey.SelectedLabTestOrder] = thisTest; HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.Redirect("~/Laboratory/EnterResultPage.aspx?key=" + g.ToString(), true); } } } }
protected void AddLabRecord(object sender, EventArgs e) { LabOrderTest thisTest = null; LabOrder _order = this.OrderedLabs; if (null != _order && null != _order.OrderedTest && _order.OrderedTest.Count > 0 && _order.OrderedTest.Exists(o => o.TestId == this.LabTestId)) { this.isDataEntry = false; return; } if (null == _order.OrderedTest) { _order.OrderedTest = new List <LabOrderTest>(); } thisTest = new LabOrderTest(); thisTest.Test = new LabTest() { Id = this.LabTestId, Name = this.LabTestName, Department = new TestDepartment() { Id = this.DepartmentId, Name = this.Department, DeleteFlag = false }, ParameterCount = this.ParameterCount, ReferenceId = this.TestReferenceId, IsGroup = this.IsGroup, DeleteFlag = false, UserId = this.UserId }; thisTest.Id = -1; thisTest.TestId = this.LabTestId; thisTest.TestNotes = txtTestNotes.Text; _order.OrderedTest.Add(thisTest); this.OrderedLabs = _order; hdCustID.Value = textSelectLab.Text = txtTestNotes.Text = ""; this.isDataEntry = false; this.BindLabTests(); }
void BindTests() { List <LabTestParameterResult> paramResults = new List <LabTestParameterResult>(); LabOrderTest order = this.thisTestOrder; if (null != order && null != order.ParameterResults && order.ParameterResults.Count > 0) { paramResults = order.ParameterResults.Where(o => o.DeleteFlag == false).ToList(); } else { paramResults = new List <LabTestParameterResult>(); paramResults.Add(new LabTestParameterResult() { DeleteFlag = true, Id = -1, Parameter = new TestParameter() } ); }; repeaterResult.DataSource = paramResults.Where(o => o.DeleteFlag == false); repeaterResult.DataBind(); }
private void PopulateLabDetails(LabOrderTest selectedLab) { try { List <LabOrderTest> orderTests = requestMgr.GetOrderedTests(selectedLab.LabOrderId, selectedLab.Id); thisTestOrder = orderTests.FirstOrDefault(); labelOrderNumber.Text = string.Format("Result for {0} ordered on {1:dd-MMM-yyyy} by {2} . Order number {3}", thisTestOrder.TestName, thisTestOrder.OrderDate, this.GetUserFullName(thisTestOrder.OrderedBy), thisTestOrder.OrderNumber); labelTestOrderStatus.Text = thisTestOrder.TestOrderStatus; labelTestNotes.Text = thisTestOrder.TestNotes; showNotes = !string.IsNullOrEmpty(thisTestOrder.TestNotes.Trim())? "" : "none"; this.LabTestId = thisTestOrder.TestId; this.LabOrderTestId = thisTestOrder.Id; this.LabOrderTestId = thisTestOrder.LabOrderId; this.BindTests(); } catch (Exception ex) { this.ShowErrorMessage(ref ex); } }
public LabOrder SaveLabOrder(LabOrder labOrder, int UserId, int LocationId) { // this.Connection = DataMgr.GetConnection(); // this.Transaction = DataMgr.BeginTransaction(this.Connection); ClsObject obj = new ClsObject(); // obj.Connection = this.Connection; // obj.Transaction = this.Transaction; ClsUtility.Init_Hashtable(); // Decimal? nullDecimal = null; if (labOrder.Id > -1) { ClsUtility.AddExtendedParameters("@LabOrderId", SqlDbType.Int, labOrder.Id); } ClsUtility.AddExtendedParameters("@UserId", SqlDbType.Int, UserId); ClsUtility.AddExtendedParameters("@PatientPk", SqlDbType.Int, labOrder.PatientPk); ClsUtility.AddExtendedParameters("@LocationId", SqlDbType.Int, LocationId); ClsUtility.AddExtendedParameters("@OrderedBy", SqlDbType.Int, labOrder.OrderedBy); ClsUtility.AddExtendedParameters("@OrderDate", SqlDbType.DateTime, labOrder.OrderDate); ClsUtility.AddParameters("@ClinicalNotes", SqlDbType.VarChar, labOrder.ClinicalNotes); ClsUtility.AddExtendedParameters("@ModuleId", SqlDbType.Int, labOrder.ModuleId); if (labOrder.PreClinicDate.HasValue) { ClsUtility.AddExtendedParameters("@PreClinicDate", SqlDbType.DateTime, labOrder.PreClinicDate); } XDocument docX = new XDocument( new XElement("root", (from test in labOrder.OrderedTest select new XElement("request", new XElement("testid", test.TestId), new XElement("testnotes", test.TestNotes), new XElement("isgroup", test.Test.IsGroup) )))); ClsUtility.AddParameters("@itemList", SqlDbType.VarChar, docX.ToString()); DataTable dt = (DataTable)obj.ReturnObject(ClsUtility.theParams, "Laboratory_SaveLabOrder", ClsUtility.ObjectEnum.DataTable); ClsUtility.Init_Hashtable(); obj = null; labOrder.Id = Convert.ToInt32(dt.Rows[0]["LabOrderId"]); labOrder.OrderNumber = dt.Rows[0]["OrderNumber"].ToString(); labOrder.VisitId = Convert.ToInt32(dt.Rows[0]["VisitId"]); labOrder.CreateDate = Convert.ToDateTime(dt.Rows[0]["CreateDate"]); labOrder.UserId = Convert.ToInt32(dt.Rows[0]["UserId"]);; labOrder.LocationId = Convert.ToInt32(dt.Rows[0]["LocationId"]); List <LabOrderTest> orderedTests = GetOrderedTests(labOrder.Id); foreach (LabOrderTest testSaved in orderedTests) { LabOrderTest submittedTest = labOrder.OrderedTest.Where(t => t.TestId == testSaved.TestId).FirstOrDefault(); if (null != submittedTest && null != submittedTest.ParameterResults && submittedTest.ResultBy.HasValue && submittedTest.ResultDate.HasValue && submittedTest.ParameterResults.Count > 0 && submittedTest.ParameterResults.Count(p => p.HasResult) > 0) { List <LabTestParameterResult> results = testSaved.ParameterResults; foreach (LabTestParameterResult result in results) { LabTestParameterResult submittedParam = submittedTest.ParameterResults.Where(p => p.ParameterId == result.ParameterId && p.HasResult).DefaultIfEmpty(null).FirstOrDefault(); if (null != submittedParam) { result.ResultOption = submittedParam.ResultOption; result.ResultOptionId = submittedParam.ResultOptionId; result.ResultText = submittedParam.ResultText; result.ResultValue = submittedParam.ResultValue; result.ResultUnit = submittedParam.ResultUnit; result.Config = submittedParam.Config; result.DetectionLimit = submittedParam.DetectionLimit; result.Undetectable = submittedParam.Undetectable; } } this.SaveLabResults(results, testSaved.Id, submittedTest.ResultNotes, UserId, submittedTest.ResultBy.Value, submittedTest.ResultDate.Value); } } return(labOrder); }
protected void AddLabRecord(object sender, EventArgs e) { LabOrderTest thisTest = null; LabOrder _order = this.OrderedLabs; if (null != _order && null != _order.OrderedTest && _order.OrderedTest.Count > 0 && _order.OrderedTest.Exists(o => o.TestId == this.LabTestId)) { this.isDataEntry = false; return; } if (null == _order.OrderedTest) { _order.OrderedTest = new List <LabOrderTest>(); } thisTest = new LabOrderTest() { TestId = this.LabTestId }; thisTest.Test = new LabTest() { Id = this.LabTestId, Name = this.LabTestName, Department = new TestDepartment() { Id = this.DepartmentId, Name = this.Department, DeleteFlag = false }, ParameterCount = this.ParameterCount, ReferenceId = this.TestReferenceId, IsGroup = false, DeleteFlag = false, UserId = this.UserId }; // List<ParameterResultConfig) _params thisTest.ParameterResults foreach (RepeaterItem dataItem in repeaterResult.Items) { string _dataType = ""; bool hasResult = false; int paramId; HiddenField hdataType = dataItem.FindControl("HResultDataType") as HiddenField; string resultId = (dataItem.FindControl("HResultId") as HiddenField).Value; _dataType = hdataType.Value.ToUpper(); paramId = Convert.ToInt32((dataItem.FindControl("hParameterId") as HiddenField).Value); string testOrderId = (dataItem.FindControl("hTestOrderId") as HiddenField).Value; RadComboBox ddlResultUnit = dataItem.FindControl("ddlResultUnit") as RadComboBox; DropDownList ddlResultList = dataItem.FindControl("ddlResultList") as DropDownList; TextBox txtResultText = dataItem.FindControl("textResultText") as TextBox; Label labelResultText = dataItem.FindControl("labelResultText") as Label; string parameterName = (dataItem.FindControl("labelParameterName") as Label).Text; CheckBox cBox = dataItem.FindControl("checkUndetectable") as CheckBox; TextBox txtLimit = dataItem.FindControl("textDetectionLimit") as TextBox; TextBox txtResultValue = dataItem.FindControl("textResultValue") as TextBox; hasResult = (cBox.Checked) || txtResultValue.Text.Trim() != "" || (ddlResultList.SelectedValue != "" && Convert.ToInt32(ddlResultList.SelectedValue) > 0) || txtResultText.Text.Trim() != ""; if (!hasResult) { this.isDataEntry = true; continue; } LabTestParameterResult _result = new LabTestParameterResult() { LabOrderId = this.LabOrderId, LabOrderTestId = this.LabOrderTestId, UserId = this.UserId, DeleteFlag = false, ParameterId = paramId }; _result.Parameter = new TestParameter() { Id = paramId, Name = parameterName, DataType = _dataType, LabTestId = this.LabTestId, DeleteFlag = false }; if (_dataType == "NUMERIC") { _result.ResultValue = string.IsNullOrEmpty(txtResultValue.Text) ? nullDecimal : Convert.ToDecimal(txtResultValue.Text.Trim()); _result.Undetectable = cBox.Checked; _result.DetectionLimit = string.IsNullOrEmpty(txtLimit.Text) ? nullDecimal : Convert.ToDecimal(txtLimit.Text.Trim()); try { if (ddlResultUnit.SelectedIndex > -1) { _result.ResultUnit = new ResultUnit() { Id = Convert.ToInt32(ddlResultUnit.SelectedValue), Text = ddlResultUnit.SelectedItem.Text }; } RadComboBoxItem item = ddlResultUnit.SelectedItem; string min_value = item.Attributes["min"].ToString(); string max_value = item.Attributes["max"].ToString(); string min_normal = item.Attributes["min_normal"].ToString(); string max_normal = item.Attributes["max_normal"].ToString(); string detection_limit = item.Attributes["detection_limit"].ToString(); _result.DetectionLimit = string.IsNullOrEmpty(txtLimit.Text) ? Convert.ToDecimal(detection_limit) : Convert.ToDecimal(txtLimit.Text.Trim()); string config_id = item.Attributes["config_id"].ToString(); _result.Config = new ParameterResultConfig() { Id = Convert.ToInt32(config_id), DetectionLimit = Convert.ToDecimal(detection_limit), MinBoundary = Convert.ToDecimal(min_value), MaxBoundary = Convert.ToDecimal(max_value), MinNormalRange = Convert.ToDecimal(min_normal), MaxNormalRange = Convert.ToDecimal(max_normal) }; //_result.ResultUnitId = _result.ResultUnit.Id; //_result.ResultOptionId = _result.ResultUnit.Id; } catch { } } else if (_dataType == "TEXT") { _result.ResultText = txtResultText.Text.Trim(); } else if (_dataType == "SELECTLIST") { _result.ResultOptionId = Convert.ToInt32(ddlResultList.SelectedValue); _result.ResultOption = ddlResultList.SelectedItem.Text; } if (null != thisTest.ParameterResults) { thisTest.ParameterResults.Add(_result); } else { thisTest.ParameterResults = new List <LabTestParameterResult>(); thisTest.ParameterResults.Add(_result); } } thisTest.TestNotes = txtTestNotes.Text; _order.OrderedTest.Add(thisTest); this.OrderedLabs = _order; hdCustID.Value = textSelectLab.Text = txtTestNotes.Text = ""; this.isDataEntry = false; //base.Session["LAB_REQTEST"] = null; //base.Session["OrderedLabs"] = null; this.BindLabTest(); }
protected void SaveResults(object sender, EventArgs e) { LabOrderTest thisTest = this.thisTestOrder; List <LabTestParameterResult> paramToSave = new List <LabTestParameterResult>(); // testToSave.ParameterResults = new List<LabTestParameterResult>(); string laborderResultBy = ddlLabReportedbyName.SelectedValue; string laborderResultdate = txtlabReportedbyDate.Text; string appcurrdate = hdappcurrentdate.Value; if (!this.FieldValidation(appcurrdate, laborderResultdate, laborderResultBy)) { return; } int withResult = 0; foreach (RepeaterItem dataItem in repeaterResult.Items) { string _dataType = ""; bool hasResult = false; int paramId; HiddenField hdataType = dataItem.FindControl("HResultDataType") as HiddenField; int resultId = Convert.ToInt32((dataItem.FindControl("HResultId") as HiddenField).Value); _dataType = hdataType.Value.ToUpper(); paramId = Convert.ToInt32((dataItem.FindControl("hParameterId") as HiddenField).Value); string testOrderId = (dataItem.FindControl("hTestOrderId") as HiddenField).Value; DropDownList ddlResultUnit = dataItem.FindControl("ddlResultUnit") as DropDownList; DropDownList ddlResultList = dataItem.FindControl("ddlResultList") as DropDownList; TextBox txtResultText = dataItem.FindControl("textResultText") as TextBox; Label labelResultText = dataItem.FindControl("labelResultText") as Label; // string parameterName = (dataItem.FindControl("labelParameterName") as Label).Text; CheckBox cBox = dataItem.FindControl("checkUndetectable") as CheckBox; TextBox txtLimit = dataItem.FindControl("textDetectionLimit") as TextBox; TextBox txtResultValue = dataItem.FindControl("textResultValue") as TextBox; switch (_dataType) { case "NUMERIC": hasResult = txtResultValue.Text.Trim() != "" || cBox.Checked; break; case "SELECTLIST": try { hasResult = Convert.ToInt32(ddlResultList.SelectedValue) > 0; } catch { } break; case "TEXT": hasResult = txtResultText.Text.Trim() != ""; break; } // hasResult = txtResultValue.Text.Trim() != "" || Convert.ToInt32(ddlResultList.SelectedValue) > 0 || txtResultText.Text.Trim() != ""; LabTestParameterResult thisParam = thisTest.ParameterResults.Where(pr => pr.Id == resultId).DefaultIfEmpty(null).FirstOrDefault(); if (!hasResult || null == thisParam) { //isDataEntry = true; continue; } withResult += 1; if (_dataType == "NUMERIC") { thisParam.ResultValue = string.IsNullOrEmpty(txtResultValue.Text) ? nullDecimal : Convert.ToDecimal(txtResultValue.Text.Trim()); thisParam.Undetectable = cBox.Checked; thisParam.DetectionLimit = string.IsNullOrEmpty(txtLimit.Text) ? nullDecimal : Convert.ToDecimal(txtLimit.Text.Trim()); try { thisParam.ResultUnit = new ResultUnit() { Id = Convert.ToInt32(ddlResultUnit.SelectedValue), Text = ddlResultUnit.SelectedItem.Text }; ListItem item = ddlResultUnit.SelectedItem; string min_value = item.Attributes["min"].ToString(); string max_value = item.Attributes["max"].ToString(); string min_normal = item.Attributes["min_normal"].ToString(); string max_normal = item.Attributes["max_normal"].ToString(); string detection_limit = item.Attributes["detection_limit"].ToString(); thisParam.DetectionLimit = string.IsNullOrEmpty(txtLimit.Text) ? Convert.ToDecimal(detection_limit) : Convert.ToDecimal(txtLimit.Text.Trim()); string config_id = item.Attributes["config_id"].ToString(); thisParam.Config = new ParameterResultConfig() { Id = Convert.ToInt32(config_id), DetectionLimit = detection_limit == "" ? nullDecimal : Convert.ToDecimal(detection_limit), MinBoundary = min_value == "" ? nullDecimal : Convert.ToDecimal(min_value), MaxBoundary = max_value == "" ? nullDecimal : Convert.ToDecimal(max_value), MinNormalRange = min_normal == "" ? nullDecimal : Convert.ToDecimal(min_normal), MaxNormalRange = max_normal == "" ? nullDecimal : Convert.ToDecimal(max_normal) }; } catch { thisParam.ResultUnit = null; } } else if (_dataType == "TEXT") { thisParam.ResultText = txtResultText.Text.Trim(); } else if (_dataType == "SELECTLIST") { thisParam.ResultOptionId = Convert.ToInt32(ddlResultList.SelectedValue); thisParam.ResultOption = ddlResultList.SelectedItem.Text; } paramToSave.Add(thisParam); } if (withResult > 0) { requestMgr.SaveLabResults( paramToSave, thisTest.Id, txtResultNotes.Text, this.UserId, Convert.ToInt32(ddlLabReportedbyName.SelectedValue), Convert.ToDateTime(txtlabReportedbyDate.Text)); base.Session["thisTestOrder"] = null; Session[SessionKey.SelectedLabTestOrder] = null; base.Session["LAB_REQTEST"] = null; IQCareMsgBox.NotifyAction("Result saved successfully", "Success", false, this, string.Format("javascript:window.location='{0}'; return false;", this.RedirectUrl)); } else { IQCareMsgBox.NotifyAction("Nothing was saved", "Failure", true, this, ""); } }