示例#1
0
    protected void GridView_Sorting(object sender, GridViewSortEventArgs e)
    {
        // dont allow sorting if in edit mode
        if (GrdPatient.EditIndex >= 0)
        {
            return;
        }

        DataTable dataTable = Session["bookingedithistory_data"] as DataTable;

        if (dataTable != null)
        {
            if (Session["bookingedithistory_sortexpression"] == null)
            {
                Session["bookingedithistory_sortexpression"] = "";
            }

            DataView dataView    = new DataView(dataTable);
            string[] sortData    = Session["bookingedithistory_sortexpression"].ToString().Trim().Split(' ');
            string   newSortExpr = (e.SortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC";
            dataView.Sort = e.SortExpression + " " + newSortExpr;
            Session["bookingedithistory_sortexpression"] = e.SortExpression + " " + newSortExpr;

            GrdPatient.DataSource = dataView;
            GrdPatient.DataBind();
        }
    }
示例#2
0
    protected void FillGrid()
    {
        Booking booking = GetFormBooking();

        if (booking == null)
        {
            SetErrorMessage("Invalid booking id");
            return;
        }

        lblHeadingDetail.Text =

            @"<table>
  <tr>
    <td>Date/Time</td>
    <td style=""min-width:10px;""></td>
    <td>" + booking.DateStart.ToString(@"dd MMM yyyy H:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + " - " + booking.DateEnd.ToString(@"H:mm") + (booking.DateEnd.Hour < 12 ? "am" : "pm") + @"</td>
  <tr>
  <tr>
    <td>Location</td>
    <td></td>
    <td>" + booking.Organisation.Name + @"</td>
  <tr>
"
            + (booking.Patient == null ? "" :
               @"<tr>
    <td>Patient</td>
    <td></td>
    <td>" + booking.Patient.Person.FullnameWithoutMiddlename + @"</td>
  <tr>
")

            + (booking.Offering == null ? "" :
               @"<tr>
    <td>Service</td>
    <td></td>
    <td>" + booking.Offering.Name + @"</td>
  <tr>
")

            + "</table>";

        DataTable dt = BookingChangeHistoryDB.GetDataTable_ByBookingID(booking.BookingID);

        Session["bookingedithistory_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["bookingedithistory_sortexpression"] != null && Session["bookingedithistory_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort         = Session["bookingedithistory_sortexpression"].ToString();
                GrdPatient.DataSource = dataView;
            }
            else
            {
                GrdPatient.DataSource = dt;
            }


            try
            {
                GrdPatient.DataBind();
                GrdPatient.PagerSettings.FirstPageText = "1";
                GrdPatient.PagerSettings.LastPageText  = GrdPatient.PageCount.ToString();
                GrdPatient.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdPatient.DataSource = dt;
            GrdPatient.DataBind();

            int TotalColumns = GrdPatient.Rows[0].Cells.Count;
            GrdPatient.Rows[0].Cells.Clear();
            GrdPatient.Rows[0].Cells.Add(new TableCell());
            GrdPatient.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdPatient.Rows[0].Cells[0].Text       = "No Changes Made";
        }
    }
    protected void FillGrid()
    {
        DateTime fromDate = DateTime.MinValue; // IsValidDate(txtStartDate.Text) ? GetDate(txtStartDate.Text) : DateTime.MinValue;
        DateTime toDate   = IsValidDate(txtEndDate.Text)   ? GetDate(txtEndDate.Text)   : DateTime.MinValue;
        DateTime nNoRecallLettersAfterDate = IsValidDate(txtNoRecallLettersAfterDate.Text) ? GetDate(txtNoRecallLettersAfterDate.Text) : DateTime.MinValue;


        //DataTable dt = PatientDB.GetRecallPatients(fromDate, toDate, chkOnlyShowIfHasEPCs.Checked, Convert.ToInt32(ddlClinics.SelectedValue));
        DataTable dt = PatientDB.GetRecallPatients(fromDate, toDate, false, Convert.ToInt32(ddlClinics.SelectedValue));



        int[] patientIDs = new int[dt.Rows.Count];
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            patientIDs[i] = Convert.ToInt32(dt.Rows[i]["patient_patient_id"]);
        }


        Hashtable mostRecentRecallHashByPatientID = LetterPrintHistoryDB.GetMostRecentRecallHashByPatients(patientIDs);


        Hashtable patientHealthCardCache        = PatientsHealthCardsCacheDB.GetBullkActive(patientIDs);
        Hashtable epcRemainingCache             = GetEPCRemainingCache(patientHealthCardCache);
        Hashtable patientsMedicareCountCache    = PatientsMedicareCardCountThisYearCacheDB.GetBullk(patientIDs, DateTime.Today.Year);
        Hashtable patientsEPCRemainingCache     = PatientsEPCRemainingCacheDB.GetBullk(patientIDs, DateTime.Today.AddYears(-1));
        int       MedicareMaxNbrServicesPerYear = Convert.ToInt32(SystemVariableDB.GetByDescr("MedicareMaxNbrServicesPerYear").Value);


        ArrayList remainingPatientIDs = new ArrayList();

        dt.Columns.Add("epc_expire_date", typeof(DateTime));
        dt.Columns.Add("has_valid_epc", typeof(Boolean));
        dt.Columns.Add("epc_count_remaining", typeof(Int32));

        dt.Columns.Add("most_recent_recall_sent", typeof(DateTime));
        for (int i = dt.Rows.Count - 1; i >= 0; i--)
        {
            int patientID = Convert.ToInt32(dt.Rows[i]["patient_patient_id"]);

            HealthCard hc     = GetHealthCardFromCache(patientHealthCardCache, patientID);
            bool       hasEPC = hc != null && hc.DateReferralSigned != DateTime.MinValue;
            HealthCardEPCRemaining[] epcsRemaining = !hasEPC ? new HealthCardEPCRemaining[] { } : GetEPCRemainingFromCache(epcRemainingCache, hc);
            int totalServicesAllowedLeft           = !hasEPC ? 0 : (MedicareMaxNbrServicesPerYear - (int)patientsMedicareCountCache[patientID]);

            int totalEpcsRemaining = 0;
            for (int j = 0; j < epcsRemaining.Length; j++)
            {
                totalEpcsRemaining += epcsRemaining[j].NumServicesRemaining;
            }

            DateTime referralSignedDate = !hasEPC ? DateTime.MinValue : hc.DateReferralSigned.Date;
            DateTime hcExpiredDate      = !hasEPC ? DateTime.MinValue : referralSignedDate.AddYears(1);
            bool     isExpired          = !hasEPC ? true              : hcExpiredDate <= DateTime.Today;

            int nServicesLeft = 0;
            if (hc != null && DateTime.Today >= referralSignedDate.Date && DateTime.Today < hcExpiredDate.Date)
            {
                nServicesLeft = totalEpcsRemaining;
            }
            if (hc != null && totalServicesAllowedLeft < nServicesLeft)
            {
                nServicesLeft = totalServicesAllowedLeft;
            }

            bool has_valid_epc       = hasEPC && !isExpired && (hc.Organisation.OrganisationID == -2 || (hc.Organisation.OrganisationID == -1 && nServicesLeft > 0));
            int  epc_count_remaining = hasEPC && hc.Organisation.OrganisationID == -1 ? nServicesLeft : -1;

            dt.Rows[i]["has_valid_epc"]       = has_valid_epc;
            dt.Rows[i]["epc_expire_date"]     = hasEPC ? hcExpiredDate : (object)DBNull.Value;
            dt.Rows[i]["epc_count_remaining"] = epc_count_remaining != -1 ? epc_count_remaining : (object)DBNull.Value;

            dt.Rows[i]["most_recent_recall_sent"] = mostRecentRecallHashByPatientID[patientID] == null ? (object)DBNull.Value : ((LetterPrintHistory)mostRecentRecallHashByPatientID[patientID]).Date;

            // remove if no valid epc and set to show only those with a valid EPC
            if (!chkShowWithEPC.Checked && has_valid_epc)
            {
                dt.Rows.RemoveAt(i);
            }
            else if (!chkShowWithNoEPC.Checked && !has_valid_epc)
            {
                dt.Rows.RemoveAt(i);
            }
            else if (nNoRecallLettersAfterDate != DateTime.MinValue && mostRecentRecallHashByPatientID[patientID] != null && ((LetterPrintHistory)mostRecentRecallHashByPatientID[patientID]).Date.Date > nNoRecallLettersAfterDate)
            {
                dt.Rows.RemoveAt(i);
            }
            else
            {
                remainingPatientIDs.Add(patientID);
            }
        }

        hiddenPatientIDs.Value = string.Join(",", (int[])remainingPatientIDs.ToArray(typeof(int)));

        Session["recallpatientinfo_data"] = dt;


        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["recallpatientinfo_sortexpression"] != null && Session["recallpatientinfo_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort         = Session["recallpatientinfo_sortexpression"].ToString();
                GrdPatient.DataSource = dataView;
            }
            else
            {
                GrdPatient.DataSource = dt;
            }


            try
            {
                GrdPatient.DataBind();
                GrdPatient.PagerSettings.FirstPageText = "1";
                GrdPatient.PagerSettings.LastPageText  = GrdPatient.PageCount.ToString();
                GrdPatient.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdPatient.DataSource = dt;
            GrdPatient.DataBind();

            int TotalColumns = GrdPatient.Rows[0].Cells.Count;
            GrdPatient.Rows[0].Cells.Clear();
            GrdPatient.Rows[0].Cells.Add(new TableCell());
            GrdPatient.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdPatient.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
    protected void FillPatientGrid()
    {
        UserView userView = UserView.GetInstance();

        lblHeading.Text = !userView.IsAgedCareView ? "Patients" : "Residents";


        int    regRefID = IsValidFormRef() ? GetFormRef(false) : -1;
        int    orgID    = IsValidFormOrg() ? GetFormOrg(false) : 0;
        string orgIDs   = orgID != 0 ? orgID.ToString() : (IsValidFormOrgs() ? GetFormOrgs(false) : string.Empty);


        DataTable dt = null;

        if (regRefID != -1)
        {
            dt = PatientReferrerDB.GetDataTable_PatientsOf(regRefID, false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked);
        }
        else if (orgIDs != string.Empty)
        {
            dt = RegisterPatientDB.GetDataTable_PatientsOf(false, orgIDs, false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked);
        }
        else
        {
            dt = PatientDB.GetDataTable(false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked);
        }

        // update AjaxLivePatientSurnameSearch and PatientListV2.aspx and PatientListPopup to disallow providers to see other patients.
        if (userView.IsProviderView)  // remove any patients who they haven't had bookings with before
        {
            Patient[] patients = BookingDB.GetPatientsOfBookingsWithProviderAtOrg(Convert.ToInt32(Session["StaffID"]), Convert.ToInt32(Session["OrgID"]));
            System.Collections.Hashtable hash = new System.Collections.Hashtable();
            foreach (Patient p in patients)
            {
                hash[p.PatientID] = 1;
            }

            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                if (hash[Convert.ToInt32(dt.Rows[i]["patient_id"])] == null)
                {
                    dt.Rows.RemoveAt(i);
                }
            }
        }

        Session["patientinfo_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["patientinfo_sortexpression"] != null && Session["patientinfo_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort         = Session["patientinfo_sortexpression"].ToString();
                GrdPatient.DataSource = dataView;
            }
            else
            {
                GrdPatient.DataSource = dt;
            }

            try
            {
                GrdPatient.DataBind();
                GrdPatient.PagerSettings.FirstPageText = "1";
                GrdPatient.PagerSettings.LastPageText  = GrdPatient.PageCount.ToString();
                GrdPatient.DataBind();
            }
            catch (Exception ex)
            {
                this.lblErrorMessage.Visible = true;
                this.lblErrorMessage.Text    = ex.ToString();
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdPatient.DataSource = dt;
            GrdPatient.DataBind();

            int TotalColumns = GrdPatient.Rows[0].Cells.Count;
            GrdPatient.Rows[0].Cells.Clear();
            GrdPatient.Rows[0].Cells.Add(new TableCell());
            GrdPatient.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdPatient.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
示例#5
0
    protected void FillGrid()
    {
        Patient patient = GetFormPatient();

        if (patient == null)
        {
            SetErrorMessage("Invalid patient id");
            return;
        }


        DataTable dt = PatientHistoryDB.GetDataTable_ByPatientID(patient.PatientID);


        Hashtable offeringsHash = OfferingDB.GetHashtable(true, -1, null, true);

        PatientDB.AddACOfferings(ref offeringsHash, ref dt, "ac_inv_offering_id", "ac_inv_offering_name", "ac_pat_offering_id", "ac_pat_offering_name",
                                 "ac_inv_aged_care_patient_type_id", "ac_inv_aged_care_patient_type_descr",
                                 "ac_pat_aged_care_patient_type_id", "ac_pat_aged_care_patient_type_descr"
                                 );

        //in display, have pt type
        //- if mcd/dva/emergency : Medicare (Low Care)
        //- if LC/HC/ETC         : Low Care
        dt.Columns.Add("ac_offering", typeof(String));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int    ac_inv_offering_id   = dt.Rows[i]["ac_inv_offering_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_inv_offering_id"]);
            int    ac_pat_offering_id   = dt.Rows[i]["ac_pat_offering_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_pat_offering_id"]);
            string ac_inv_offering_name = dt.Rows[i]["ac_inv_offering_name"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_inv_offering_name"]);
            string ac_pat_offering_name = dt.Rows[i]["ac_pat_offering_name"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_pat_offering_name"]);

            int    ac_inv_aged_care_patient_type_id    = dt.Rows[i]["ac_inv_aged_care_patient_type_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_inv_aged_care_patient_type_id"]);
            string ac_inv_aged_care_patient_type_descr = dt.Rows[i]["ac_inv_aged_care_patient_type_descr"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_inv_aged_care_patient_type_descr"]);
            int    ac_pat_aged_care_patient_type_id    = dt.Rows[i]["ac_pat_aged_care_patient_type_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_pat_aged_care_patient_type_id"]);
            string ac_pat_aged_care_patient_type_descr = dt.Rows[i]["ac_pat_aged_care_patient_type_descr"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_pat_aged_care_patient_type_descr"]);


            if (ac_inv_offering_id == -1)
            {
                dt.Rows[i]["ac_offering"] = string.Empty;
            }
            else if ((new List <int> {
                2, 3, 4, 5
            }).Contains(ac_inv_aged_care_patient_type_id))
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name;
            }
            else if ((new List <int> {
                6, 7, 8, 9, 10
            }).Contains(ac_inv_aged_care_patient_type_id))
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name + " (" + ac_pat_offering_name + ")";
            }
            else // (?)
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name;
            }
        }


        Session["patientedithistory_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["patientedithistory_sortexpression"] != null && Session["patientedithistory_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort         = Session["patientedithistory_sortexpression"].ToString();
                GrdPatient.DataSource = dataView;
            }
            else
            {
                GrdPatient.DataSource = dt;
            }


            try
            {
                GrdPatient.DataBind();
                GrdPatient.PagerSettings.FirstPageText = "1";
                GrdPatient.PagerSettings.LastPageText  = GrdPatient.PageCount.ToString();
                GrdPatient.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdPatient.DataSource = dt;
            GrdPatient.DataBind();

            int TotalColumns = GrdPatient.Rows[0].Cells.Count;
            GrdPatient.Rows[0].Cells.Clear();
            GrdPatient.Rows[0].Cells.Add(new TableCell());
            GrdPatient.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdPatient.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }