using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class controls_module_medicalPatientSignin : System.Web.UI.UserControl { #region events /// /// Page Load /// /// /// protected void Page_Load(object sender, EventArgs e) { } /// /// login button click /// /// /// protected void btnLogin_Click(object sender, EventArgs e) { try { string patientNumber = string.Empty, doB = string.Empty; int surfaceId = 0; patientNumber = txtMobileNumber.Text; //doB = utils.stripSpecialCharacters(txtDoB.Text); DateTime dateOfBirth = utils.formatStringToDate(txtDoB.Text); doB = dateOfBirth.ToString("yyyy/MM/dd"); foreach (oSurface surface in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "name,isActive", "PatientProfile,1")) { surfaceId = surface.recId; //CVH 2018-06-05 Get data from query table, otherwise it times out //DataTable surfaceData = xData.GetSurfaceDataAll(surfaceId, true); int maxRows = 1; string filter = "PatientInformation_PatientDetails_MobileNumber = '" + patientNumber + "' AND PatientInformation_PatientDetails_DateofBirth = '" + doB + "'"; DataTable surfaceData = xData.GetSurfaceQueryDataPaged(surface.recId, 0, maxRows, "", "", handler.ReturnUser().recId, 0, filter, true, false); if (surfaceData != null && surfaceData.Rows.Count > 0) SurfaceItemId = int.Parse(surfaceData.Rows[0]["itemID"].ToString()); else SurfaceItemId = 0; //if (surfaceData.Columns.Contains("PatientInformation_PatientDetails_MobileNumber") && // surfaceData.Columns.Contains("PatientInformation_PatientDetails_DateofBirth") && // surfaceData.Columns.Contains("itemID")) //{ // foreach (DataRow row in surfaceData.Rows) // { // if (row["PatientInformation_PatientDetails_MobileNumber"].ToString().Equals(patientNumber)) // { // string dbDoB = row["PatientInformation_PatientDetails_DateofBirth"].ToString(); // dbDoB = utils.stripSpecialCharacters(dbDoB); // if (dbDoB.Equals(doB)) // { // SurfaceItemId = Convert.ToInt32(row["itemID"].ToString()); // break; // } // } // } //} } if (SurfaceItemId > 0) { BindGrid(); pnlSubjectives.Visible = true; pnlSignIn.Visible = false; //txtPatientNumber.Text = ""; //txtDoB.Text = ""; divResult.Visible = false; lblResult.Text = ""; } else { divResult.Visible = true; lblResult.Text = "Patient not found"; txtMobileNumber.Focus(); } } catch (Exception ex) { exception.HandleException("Login:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save button click /// /// /// protected void btnSave_Click(object sender, EventArgs e) { try { if (validateGrid()) { oMedicalPatientVisitLog visitLog = new oMedicalPatientVisitLog(); visitLog.surfaceItemId = SurfaceItemId; visitLog.signInDate = DateTime.Now; visitLog.note = txtNote.Value; int visitId = xData.SaveTyped("recId", typeof(oMedicalPatientVisitLog), visitLog); foreach (oSurface examNoteSurface in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "name,isActive", "ExamNotes,1")) { oSurfaceItem newExamNoteItem = new oSurfaceItem(); newExamNoteItem.surfaceId = examNoteSurface.recId; newExamNoteItem.dateCreated = DateTime.Now; newExamNoteItem.isActive = true; foreach (oSurfaceItem item in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceItem), "recId", SurfaceItemId.ToString())) { newExamNoteItem.createdBy = item.userLink > 0 ? item.userLink : item.createdBy; } int newExamNoteId = xData.SaveTyped("recId", typeof(oSurfaceItem), newExamNoteItem); foreach (oSurfaceField examNoteField in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,isActive", examNoteSurface.recId.ToString() + ",1")) { if (examNoteField.surfaceFieldTypeId > 2) { oSurfaceFieldData newExamNoteData = new oSurfaceFieldData(); newExamNoteData.surfaceId = examNoteSurface.recId; newExamNoteData.surfaceItemId = newExamNoteId; newExamNoteData.surfaceFieldID = examNoteField.recId; switch (examNoteField.surfaceFieldName) { case "ExamNotes_ExamNotes_ExamNotes": newExamNoteData.surfaceFieldValueChar = txtNote.Value; break; case "ParentSurfaceItemId": newExamNoteData.surfaceFieldValueNum = SurfaceItemId; break; default: break; } xData.SaveTyped("recId", typeof(oSurfaceFieldData), newExamNoteData); } } } oMedicalPatientSubjectivesLog subjectivesLog = new oMedicalPatientSubjectivesLog(); foreach (GridViewRow row in grdSubjectives.Rows) { if (row.RowType == DataControlRowType.DataRow) { DataRowView rowView = (DataRowView)row.DataItem; Label lblId = (Label)row.FindControl("lblId"); RadioButtonList rblPainLevel = (RadioButtonList)row.FindControl("rblPainLevel"); subjectivesLog = new oMedicalPatientSubjectivesLog(); subjectivesLog.visitLogId = visitId; subjectivesLog.complaintId = Convert.ToInt32(lblId.Text); subjectivesLog.score = Convert.ToInt32(rblPainLevel.SelectedValue); xData.SaveTyped("recId", typeof(oMedicalPatientSubjectivesLog), subjectivesLog); } } ClearValues(); pnlSubjectives.Visible = false; pnlSignIn.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Pop", "function ShowModal(){$('#modFinal').modal('show');} ShowModal();", true); } } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private bool validateGrid() { bool returnResult = true; try { foreach (GridViewRow row in grdSubjectives.Rows) { if (row.RowType == DataControlRowType.DataRow) { RadioButtonList rblPainLevel = (RadioButtonList)row.FindControl("rblPainLevel"); if (rblPainLevel.SelectedValue == null || rblPainLevel.SelectedValue == "") { divInValidGrid.Visible = true; lblInvalidGrid.Text = "Please Score All Complaints"; returnResult = false; } } } } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } return returnResult; } /// /// grid row databound /// /// /// protected void grdSubjectives_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { oMedicalPatientComplaints complaintRow = (oMedicalPatientComplaints)e.Row.DataItem; Label lblId = (Label)e.Row.FindControl("lblId"); lblId.Text = complaintRow.recId.ToString(); } } #endregion #region methods private void ClearValues() { txtMobileNumber.Text = ""; txtDoB.Text = ""; txtNote.Value = ""; } /// /// Bind Complaints Grid /// private void BindGrid() { grdSubjectives.DataSource = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalPatientComplaints), "surfaceItemId,isActive", SurfaceItemId.ToString() + ",1"); grdSubjectives.DataBind(); } #endregion #region properties public int SurfaceItemId { get { if (ViewState["surfaceItemId"] == null) return 0; else return (int)ViewState["surfaceItemId"]; } set { ViewState["surfaceItemId"] = value; } } #endregion }