/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (this.thisLabOrder == null) { int labOrderId = Convert.ToInt32(Session["PatientVisitId"]); if (labOrderId > 0) { this.thisLabOrder = requestMgr.GetLabOrder(this.LocationId, labOrderId); } else { System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.Redirect("~/frmFacilityHome.aspx", true); } } this.GenerateReport(); }
/// <summary> /// Populates the request. /// </summary> /// <param name="labVisitId">The lab visit identifier.</param> private void PopulateRequest() { if (LabOrderId > 0) // an existing lab order { this.OrderedLabs = requestMgr.GetLabOrder(this.LocationId, this.LabOrderId); labelClinicalNotes.Text = txtClinicalNotes.Text = this.OrderedLabs.ClinicalNotes; labellaborderedbydate.Text = txtlaborderedbydate.Text = this.OrderedLabs.OrderDate.ToString("dd-MMM-yyyy"); labelOrderStatus.Text = this.OrderedLabs.OrderStatus; labelOrderNumber.Text = this.OrderedLabs.OrderNumber; DataTable _user = this.UserList; DataRow thisRow = _user.AsEnumerable().Where(r => r["UserId"].ToString() == this.OrderedLabs.OrderedBy.ToString()).DefaultIfEmpty(null).FirstOrDefault(); if (null != thisRow) { labelOrderedBy.Text = thisRow["Name"].ToString(); } } }
/// <summary> /// Populates the request. /// </summary> /// <param name="labOrderId">The lab order identifier.</param> private void PopulateRequest(int labOrderId) { if (null == Session["PatientInformation"]) { IPatientHome PatientManager; PatientManager = (IPatientHome)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientHome, BusinessProcess.Clinical"); DataSet theDS = PatientManager.GetPatientDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["SystemId"]), Convert.ToInt32(Session["TechnicalAreaId"])); PatientManager = null; Session["PatientInformation"] = theDS.Tables[0]; } int patientId = Convert.ToInt32(HttpContext.Current.Session["patientId"]); this.thisLabOrder = requestMgr.GetLabOrder(this.LocationId, labOrderId); if (this.thisLabOrder.ModuleId <= 0) { EnrollmentService es = new EnrollmentService(PatientId); List <PatientEnrollment> pe = es.GetPatientEnrollment(CurrentSession.Current); if (pe != null) { Session["TechnicalAreaId"] = this.thisLabOrder.ModuleId = pe.FirstOrDefault().ServiceAreaId; base.Session["TechnicalAreaName"] = pe.FirstOrDefault().ServiceArea.Name; } } else { Session["TechnicalAreaId"] = this.thisLabOrder.ModuleId; } CurrentSession session = CurrentSession.Current.ResetCurrentModule(); PatientService service = new PatientService(session, this.PatientId, this.ModuleId); // CurrentSession.Current.SetCurrentModule(this.ModuleId); CurrentSession.Current.SetCurrentPatient(this.PatientId, this.ModuleId); this.LabOrderId = this.thisLabOrder.Id; labelClinicalNotes.Text = this.thisLabOrder.ClinicalNotes; //dt.Rows[0]["ClinicalNotes"].ToString(); // labellaborderedbydate.Text = this.thisLabOrder.OrderDate.ToString("dd-MMM-yyyy"); labelLabtobeDone.Text = this.thisLabOrder.PreClinicDate.HasValue ? this.thisLabOrder.PreClinicDate.Value.ToString("dd-MMM-yyyy") : ""; labelOrderNumber.Text = string.Format("Order Number : {0} | Status : {1} | Ordered by {2} on {3}", thisLabOrder.OrderNumber, thisLabOrder.OrderStatus, this.GetUserFullName(this.thisLabOrder.OrderedBy), this.thisLabOrder.OrderDate.ToString("dd-MMM-yyyy")); // labelOrderedbyname.Text = this.GetEmployeeName(this.thisLabOrder.OrderedBy); LabOrder order = this.thisLabOrder; List <LabOrderTest> _test = new List <LabOrderTest>(); if (null != order && null != order.OrderedTest && order.OrderedTest.Count > 0) { _test = order.OrderedTest.Where(o => o.DeleteFlag == false).ToList(); } else { _test = new List <LabOrderTest>(); _test.Add(new LabOrderTest() { DeleteFlag = true, Id = -1, TestNotes = "", Test = new LabTest() } ); }; repeaterLabTest.DataSource = _test.Where(o => o.DeleteFlag == false && o.Test.IsGroup == false); repeaterLabTest.DataBind(); }
/// <summary> /// Populates the request. /// </summary> /// <param name="labOrderId">The lab order identifier.</param> private void PopulateRequest(int labOrderId) { if (null == Session["PatientInformation"]) { IPatientHome PatientManager; PatientManager = (IPatientHome)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientHome, BusinessProcess.Clinical"); DataSet theDS = PatientManager.GetPatientDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["SystemId"]), Convert.ToInt32(Session["TechnicalAreaId"])); PatientManager = null; Session["PatientInformation"] = theDS.Tables[0]; } this.thisLabOrder = requestMgr.GetLabOrder(this.LocationId, labOrderId); if (this.thisLabOrder.ModuleId <= 0) { EnrollmentService es = new EnrollmentService(PatientId); List <PatientEnrollment> pe = es.GetPatientEnrollment(CurrentSession.Current); if (pe != null) { Session["TechnicalAreaId"] = this.thisLabOrder.ModuleId = pe.FirstOrDefault().ServiceAreaId; base.Session["TechnicalAreaName"] = pe.FirstOrDefault().ServiceArea.Name; } } else { Session["TechnicalAreaId"] = this.thisLabOrder.ModuleId; } CurrentSession session = CurrentSession.Current.ResetCurrentModule(); PatientService service = new PatientService(session, this.PatientId, this.ModuleId); // CurrentSession.Current.SetCurrentModule(this.ModuleId); CurrentSession.Current.SetCurrentPatient(this.PatientId, this.ModuleId); this.LabOrderId = this.thisLabOrder.Id; labelClinicalNotes.Text = this.thisLabOrder.ClinicalNotes; //dt.Rows[0]["ClinicalNotes"].ToString(); // labellaborderedbydate.Text = this.thisLabOrder.OrderDate.ToString("dd-MMM-yyyy"); labelLabtobeDone.Text = this.thisLabOrder.PreClinicDate.HasValue ? this.thisLabOrder.PreClinicDate.Value.ToString("dd-MMM-yyyy") : ""; labelOrderNumber.Text = string.Format("Order Number : {0} | Status : {1} | Ordered by {2} on {3}", thisLabOrder.OrderNumber, thisLabOrder.OrderStatus, this.GetUserFullName(this.thisLabOrder.OrderedBy), this.thisLabOrder.OrderDate.ToString("dd-MMM-yyyy")); // labelOrderedbyname.Text = this.GetEmployeeName(this.thisLabOrder.OrderedBy); LabOrder order = this.thisLabOrder; List <LabOrderTest> _test = new List <LabOrderTest>(); if (null != order && null != order.OrderedTest && order.OrderedTest.Count > 0) { _test = order.OrderedTest.Where(o => o.DeleteFlag == false).ToList(); } else { _test = new List <LabOrderTest>(); _test.Add(new LabOrderTest() { DeleteFlag = true, Id = -1, TestNotes = "", Test = new LabTest() } ); }; /* * XmlDocument reportXML = new XmlDocument(); * XmlDeclaration newChild = reportXML.CreateXmlDeclaration("1.0", "UTF-8", null); * reportXML.AppendChild(newChild); * XmlElement element = reportXML.CreateElement("Root"); * reportXML.AppendChild(element); * XmlElement rootElement = reportXML.DocumentElement; * * //XmlNode reportNode = reportXML.CreateNode(XmlNodeType.Element, "Order", string.Empty); * //reportNode.InnerXml = * // new XElement("orderid", this.thisLabOrder.Id).ToString() + * // new XElement("ordernumber", this.thisLabOrder.OrderNumber).ToString() + * // new XElement("orderdate", thisLabOrder.OrderDate.ToString("o")).ToString() + * // new XElement("orderby", this.GetUserFullName(thisLabOrder.OrderedBy)).ToString() + * // new XElement("servicearea", this.GetModuleName(thisLabOrder.ModuleId)).ToString() + * // new XElement("patientname", string.Format("{0} {1}", thisLabOrder.Client.FirstName, thisLabOrder.Client.LastName)).ToString() + * // new XElement("patientgender", thisLabOrder.Client.Sex).ToString() + * // new XElement("patientdob", thisLabOrder.Client.DateOfBirth.ToString("o")) + * // new XElement("patientnumber", thisLabOrder.Client.UniqueFacilityId).ToString(); * //rootElement.AppendChild(reportNode); * DateTime? nulldate = null; * bool? nullBit = null; * Double? nullDouble = null; * XElement orderE = new XElement("Order", * new XElement("orderid", this.thisLabOrder.Id), * new XElement("ordernumber", this.thisLabOrder.OrderNumber), * new XElement("orderstatus", this.thisLabOrder.OrderStatus), * new XElement("orderdate", thisLabOrder.OrderDate.ToString("o")), * new XElement("ordernotes", thisLabOrder.ClinicalNotes), * new XElement("orderby", this.GetUserFullName(thisLabOrder.OrderedBy)), * new XElement("servicearea", this.GetModuleName(thisLabOrder.ModuleId)), * new XElement("patientname", string.Format("{0} {1}", thisLabOrder.Client.FirstName, thisLabOrder.Client.LastName)), * new XElement("patientgender", thisLabOrder.Client.Sex), * new XElement("patientdob", thisLabOrder.Client.DateOfBirth.ToString("o")) , * new XElement("patientnumber", thisLabOrder.Client.UniqueFacilityId).ToString()); * XmlDocumentFragment orderNode = reportXML.CreateDocumentFragment(); * orderNode.InnerXml = orderE.ToString(); * rootElement.AppendChild(orderNode); * * * foreach (LabOrderTest orderedTest in thisLabOrder.OrderedTest.Where(o => o.ParentLabTestId == null)) * { * //XElement c = new XElement("Test", * // new XElement("ordertestid", orderedTest.Id), * // new XElement("testid", orderedTest.Test.Id), * // new XElement("testname", orderedTest.Test.Name), * // new XElement("department", orderedTest.Test.DepartmentName), * // new XElement("testnote", orderedTest.TestNotes), * // new XElement("resultnote", orderedTest.ResultNotes), * // new XElement("orderstatus", orderedTest.TestOrderStatus), * // new XElement("resultdate", orderedTest.ResultDate.HasValue ? orderedTest.ResultDate.Value.ToString("o") : ""), * //new XElement("resultby", orderedTest.ResultBy.HasValue ? this.GetUserFullName(orderedTest.ResultBy.Value) : "")); * foreach (LabTestParameterResult result in orderedTest.ParameterResults) * { * XElement r = new XElement("Result", * new XElement("id", result.LabOrderTestId), * new XElement("orderedtestid", orderedTest.Id), * new XElement("orderid", result.LabOrderId), * new XElement("testid", orderedTest.Id), * new XElement("testname", orderedTest.TestName), * new XElement("department", orderedTest.Test.DepartmentName), * new XElement("testnote", orderedTest.TestNotes), * new XElement("resultnote", orderedTest.ResultNotes), * new XElement("teststatus", orderedTest.TestOrderStatus), * new XElement("parameterid", result.ParameterId), * new XElement("parametername", result.ParameterName), * new XElement("datatype", result.ResultDataType), * new XElement("hasresult", result.HasResult), * new XElement("resultdate", orderedTest.ResultDate.HasValue ? orderedTest.ResultDate.Value : nulldate), * new XElement("resultby", orderedTest.ResultBy.HasValue ? this.GetUserFullName(orderedTest.ResultBy.Value) : ""), * new XElement("unit", result.ResultUnitName), * new XElement("undetectable", result.Undetectable.HasValue ? result.Undetectable.Value : nullBit), * new XElement("detectionlimit", result.DetectionLimit.HasValue ? result.DetectionLimit.Value : nullDouble), * new XElement("resultvalue", result.ResultDataType == "NUMERIC" ? (result.ResultValue.HasValue? result.ResultValue.Value.ToString(): "") : (result.ResultDataType == "SELECTLIST" ? result.ResultOption : result.ResultText)) , * new XElement("maxboundary", (result.Config != null && result.Config.MaxBoundary.HasValue) ? result.Config.MaxBoundary.Value.ToString() : ""), * new XElement("minboundary", (result.Config != null && result.Config.MinBoundary.HasValue) ? result.Config.MinBoundary.Value.ToString() : ""), * new XElement("maxnormalboundary", (result.Config != null && result.Config.MaxNormalRange.HasValue) ? result.Config.MaxNormalRange.Value.ToString() : ""), * new XElement("minnormalboundary", (result.Config != null && result.Config.MinNormalRange.HasValue) ? result.Config.MinNormalRange.Value.ToString() : "") * * ); * XmlDocumentFragment resultNode = reportXML.CreateDocumentFragment(); * resultNode.InnerXml = r.ToString(); * rootElement.AppendChild(resultNode); * } * * //XmlDocumentFragment testNode = reportXML.CreateDocumentFragment(); * //testNode.InnerXml = c.ToString(); * //rootElement.AppendChild(testNode); * } * * reportXML.Save(@"C:\apps\labresult.xml"); * * DataSet ds = new DataSet("Report"); * using (System.IO.TextReader txR = new System.IO.StringReader(reportXML.InnerXml)) * { * ds.ReadXml(txR); * txR.Close(); * } * ds.WriteXml(@"C:\apps\labresultschema.xml", XmlWriteMode.WriteSchema);*/ repeaterLabTest.DataSource = _test.Where(o => o.DeleteFlag == false && o.Test.IsGroup == false); repeaterLabTest.DataBind(); }