Example #1
0
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);

            Session["SearchComplete"] = true;

            if (Session["mode"] == null)
            {
                if (Session["PatientID"] == null)
                {
                    Response.Redirect("SessionTimedOut.aspx");
                }
            }

            if (!IsPostBack)
            {
                LoadTips();

                // Get the patient information from session.
                TrinityClassLibrary_BL.Patient patient = (TrinityClassLibrary_BL.Patient)Session["Patient"];

                // Get the patient's rig information from session.
                TrinityClassLibrary_BL.Rig rig = null;
                if (patient.RigID.HasValue)
                {
                    rig = (TrinityClassLibrary_BL.Rig)Session["PatientRig"];
                }

                // Display the patient information to the screen.
                if (rig != null)
                {
                    litPatientData.Text = rig.Name + ": ";
                }
                litPatientData.Text += patient.LastName + ", " + patient.FirstName + " (" + Convert.ToDateTime(patient.EncounterDate).ToShortDateString() + ")";

                // Get all medic records from data.
                List <TrinityClassLibrary_BL.Medic> allMedics = TrinityClassLibrary_DAL.MedicProvider.FetchList();

                // Get all notes for this encounter that are not marked as deleted.
                List <TrinityClassLibrary_BL.AdditionalPatientNote> notes = TrinityClassLibrary_DAL.AdditionalPatientNoteProvider.FetchList(patient.PatientID, false);

                // Get the user's medic information.
                TrinityClassLibrary_BL.Medic currentUser = allMedics.Find(delegate(TrinityClassLibrary_BL.Medic currentMedic)
                {
                    if (currentMedic.MedicID == Convert.ToInt32(Session["MedicPK"]))
                    {
                        return(true);
                    }
                    return(false);
                });
                //ViewState["CurrentMedicSecurity"] = currentUser.SecurityLevel.Value.ToString();

                // Filters out notes the user does not have rights to view.
                notes = FilterNotes(notes, currentUser);

                // Displays the additional notes at the bottom of the screen.
                DisplayNotes(allMedics, notes, currentUser);
            }
            //DataUtility clsData = new DataUtility();

            //StringBuilder strSQL = new StringBuilder();

            if (Session["mode"] != null)
            {
                if (Session["mode"].ToString() == "view")
                {
                    btnContinue.Visible = false;
                    btnReset.Visible    = false;

                    DataTool  dbTool         = new DataTool();
                    DataTable dtPatientNotes = dbTool.getPatientNotes(Session["PatientID"].ToString());
                    // add the javascript onload event that will initialize the span tables
                    bodyMain.Attributes.Add("onLoad", "initSpan()");

                    // disable the input boxes and show the data from the database
                    enterData();

                    //clsData.doIncompletes(strSQL.ToString(), Page);
                    //Filling Spans with datatable
                    if (dtPatientNotes.Rows.Count > 0)
                    {
                        if (dtPatientNotes.Rows[0][1] != null)
                        {
                            txtImpressionNotes.Text = dtPatientNotes.Rows[0][1].ToString();
                        }
                        if (dtPatientNotes.Rows[0][3] != null)
                        {
                            txtInstructionNotes.Text = dtPatientNotes.Rows[0][3].ToString();
                        }
                        if (dtPatientNotes.Rows[0][0] != null)
                        {
                            txtPhysicalNotes.Text = dtPatientNotes.Rows[0][0].ToString();
                        }
                        if (dtPatientNotes.Rows[0][2] != null)
                        {
                            txtRecommendationNotes.Text = dtPatientNotes.Rows[0][2].ToString();
                        }
                        if (dtPatientNotes.Rows[0][1] != null)
                        {
                            spantxtImpressionNotes.InnerHtml = dtPatientNotes.Rows[0][1].ToString();
                        }
                        if (dtPatientNotes.Rows[0][3] != null)
                        {
                            spantxtInstructionNotes.InnerHtml = dtPatientNotes.Rows[0][3].ToString();
                        }
                        if (dtPatientNotes.Rows[0][0] != null)
                        {
                            spantxtPhysicalNotes.InnerHtml = dtPatientNotes.Rows[0][0].ToString();
                        }
                        if (dtPatientNotes.Rows[0][2] != null)
                        {
                            spantxtRecommendationNotes.InnerHtml = dtPatientNotes.Rows[0][2].ToString();
                        }
                    }

                    // Set the visibility of the header panels.
                    pnlAddEditHeader.Visible = false;
                    pnlViewHeader.Visible    = true;
                }
                else if (Session["mode"].ToString() == "edit")
                {
                    DataTool  dbTool         = new DataTool();
                    DataTable dtPatientNotes = dbTool.getPatientNotes(Session["PatientID"].ToString());

                    if (!Page.IsPostBack)
                    {
                        if (dtPatientNotes.Rows.Count > 0)
                        {
                            //Filling Textboxes with datatable
                            txtImpressionNotes.Text              = dtPatientNotes.Rows[0][1].ToString();
                            txtInstructionNotes.Text             = dtPatientNotes.Rows[0][3].ToString();
                            txtPhysicalNotes.Text                = dtPatientNotes.Rows[0][0].ToString();
                            txtRecommendationNotes.Text          = dtPatientNotes.Rows[0][2].ToString();
                            spantxtImpressionNotes.InnerHtml     = dtPatientNotes.Rows[0][1].ToString();
                            spantxtInstructionNotes.InnerHtml    = dtPatientNotes.Rows[0][3].ToString();
                            spantxtPhysicalNotes.InnerHtml       = dtPatientNotes.Rows[0][0].ToString();
                            spantxtRecommendationNotes.InnerHtml = dtPatientNotes.Rows[0][2].ToString();
                        }
                    }
                    // enter the data into the fields

                    // Set the visibility of the header panels.
                    pnlAddEditHeader.Visible = true;
                    pnlViewHeader.Visible    = false;
                }
                else
                {
                }
                ShowHideEditButtons();
            }
        }         // Done... Tested