protected void Select(int orgID)
    {
        Organisation org = OrganisationDB.GetByID(orgID);

        Session["OrgID"]   = org.OrganisationID.ToString();
        Session["OrgName"] = org.Name;

        if (Request.QueryString["from_url"] != null)
        {
            Response.Redirect(Server.UrlDecode(Request.RawUrl.Substring(Request.RawUrl.IndexOf("from_url=") + 9)));
        }
        else if (Session["PatientID"] != null)
        {
            Response.Redirect("~/BookingNextAvailableV2.aspx");
        }
        else
        {
            //Response.Redirect("~/Default.aspx");

            string ndays          = Session["PatientId"] == null ? "1" : "3"; // provider login shows just today, patient iew 3 days
            bool   isExternalView = Session["IsExternal"] != null && Convert.ToBoolean(Session["IsExternal"]);
            if (isExternalView)
            {
                ndays = (int)Session["StaffID"] != -5 ? "3" : "4";  // external login shows 3 days (less days looks better), but 4 days for call center (for more functionality)
            }
            Response.Redirect("~/BookingsV2.aspx?orgs=" + Session["OrgID"] + "&ndays=" + ndays);
        }
    }
Exemple #2
0
    protected Tuple <Booking, PatientReferrer, bool, string, HealthCard> LoadRow(DataRow row)
    {
        Booking booking = BookingDB.Load(row, "booking_", true, false);

        booking.Offering = OfferingDB.Load(row, "offering_");

        PatientReferrer pr = PatientReferrerDB.Load(row, "pr_");

        pr.RegisterReferrer                       = RegisterReferrerDB.Load(row, "regref_");
        pr.RegisterReferrer.Referrer              = ReferrerDB.Load(row, "referrer_");
        pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "referrer_person_");
        pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr");
        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            pr.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_");
        }
        pr.Patient              = PatientDB.Load(row, "patient_");
        pr.Patient.Person       = PersonDB.Load(row, "patient_person_");
        pr.Patient.Person.Title = IDandDescrDB.Load(row, "patient_person_title_title_id", "patient_person_title_descr");

        bool   refHasEmail = Convert.ToInt32(row["ref_has_email"]) == 1;
        string refEmail    = row["ref_email"] == DBNull.Value ? null : Convert.ToString(row["ref_email"]);

        HealthCard hc = HealthCardDB.Load(row, "hc_");

        return(new Tuple <Booking, PatientReferrer, bool, string, HealthCard>(booking, pr, refHasEmail, refEmail, hc));
    }
    protected void GrdRegistration_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlReferrer           = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewReferrer");
            TextBox      txtProviderNumber     = (TextBox)GrdRegistration.FooterRow.FindControl("txtNewProviderNumber");
            DropDownList ddlIsClinic           = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewIsClinic");
            CheckBox     chkIsReportEveryVisit = (CheckBox)GrdRegistration.FooterRow.FindControl("chkNewIsReportEveryVisit");
            CheckBox     chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdRegistration.FooterRow.FindControl("chkNewIsBatchSendAllPatientsTreatmentNotes");

            Organisation org = OrganisationDB.GetByID(GetFormID());
            if (org == null)
            {
                HideTableAndSetErrorMessage("");
                return;
            }

            try
            {
                RegisterReferrerDB.Insert(org.OrganisationID, Convert.ToInt32(ddlReferrer.SelectedValue), txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked);
            }
            catch (UniqueConstraintException)
            {
                // happens when 2 forms allow adding - do nothing and let form re-update
            }
            FillGrid();
        }
    }
    public static Hashtable GetHashtableByReferrer(bool incDeleted = false)
    {
        Hashtable hashtable = new Hashtable();

        DataTable tbl = DBBase.ExecuteQuery(JoinedSql(incDeleted, incDeleted, incDeleted)).Tables[0];

        foreach (DataRow row in tbl.Rows)
        {
            if (row["organisation_id"] == DBNull.Value)
            {
                continue;
            }

            Referrer r = ReferrerDB.Load(row);
            r.Person       = PersonDB.Load(row, "", "person_entity_id");
            r.Person.Title = IDandDescrDB.Load(row, "title_id", "descr");
            Organisation o = OrganisationDB.Load(row, "", "organisation_entity_id", "organisation_is_deleted");

            if (hashtable[r.ReferrerID] == null)
            {
                hashtable[r.ReferrerID] = new ArrayList();
            }
            ((ArrayList)hashtable[r.ReferrerID]).Add(o);
        }

        return(hashtable);
    }
Exemple #5
0
    protected static Hashtable GetPatientRegOrgCache(Patient[] patients)
    {
        ArrayList patientIDArrayList = new ArrayList();

        foreach (Patient patient in patients)
        {
            patientIDArrayList.Add(patient.PatientID);
        }
        int[] patientIDs = (int[])patientIDArrayList.ToArray(typeof(int));

        Hashtable regOrgHash = new Hashtable();

        System.Data.DataTable tbl = RegisterPatientDB.GetDataTable_OrganisationsOf(patientIDs, true, false, false, true, true);
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            int          patientID = Convert.ToInt32(tbl.Rows[i]["patient_id"]);
            Organisation org       = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted");

            if (regOrgHash[patientID] == null)
            {
                regOrgHash[patientID] = new System.Collections.ArrayList();
            }
            ((System.Collections.ArrayList)regOrgHash[patientID]).Add(org);
        }

        return(regOrgHash);
    }
Exemple #6
0
    protected List <Tuple <string, Organisation> > GetClinicList()
    {
        try
        {
            List <Tuple <string, Organisation> > list = new List <Tuple <string, Organisation> >();

            bool allowPatientsToCreateOwnRecords = ((SystemVariables)Session["SystemVariables"])["AllowPatientsToCreateOwnRecords"].Value == "1";
            if (allowPatientsToCreateOwnRecords)
            {
                Organisation[] orgs = OrganisationDB.GetAll(false, true, false, false, true, true);
                if (orgs.Length > 0)
                {
                    for (int j = 0; j < orgs.Length; j++)
                    {
                        if (orgs[j].IsClinic)
                        {
                            list.Add(new Tuple <string, Organisation>(((SystemVariables)Session["SystemVariables"])["Site"].Value, orgs[j]));
                        }
                    }
                }
            }

            return(list);
        }
        catch (CustomMessageException cmEx)
        {
            this.lblErrorMessage.Text = cmEx.Message;
            return(null);
        }
    }
    protected void UpdateList()
    {
        Staff        staff = IsValidFormStaffID() ? StaffDB.GetByID(GetFormStaffID()) : null;
        Organisation org   = IsValidFormOrgID()   ? OrganisationDB.GetByID(GetFormOrgID()) : null;

        UpdateList(org, staff);
    }
Exemple #8
0
 public static void Delete(int organisation_id)
 {
     try
     {
         Organisation o = OrganisationDB.GetByID(organisation_id);
         if (o != null)
         {
             DBBase.ExecuteNonResult("DELETE FROM Organisation WHERE organisation_id = " + organisation_id.ToString());
             if (EntityDB.NumForeignKeyDependencies(o.EntityID) == 0)
             {
                 EntityDB.Delete(o.EntityID, false);
             }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         if (sqlEx.Errors.Count > 0 && sqlEx.Errors[0].Number == 547) // Assume the interesting stuff is in the first error
         {
             throw new ForeignKeyConstraintException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, sqlEx);
         }
         else
         {
             throw;
         }
     }
 }
    protected void SetOrgsDDL()
    {
        DataTable dt   = null;
        string    type = null;

        if (!UserView.GetInstance().IsAgedCareView)
        {
            dt              = OrganisationDB.GetDataTable_Clinics();
            type            = "Clinics";
            lblOrgType.Text = "Clinic";
        }
        else
        {
            dt              = OrganisationDB.GetDataTable_AgedCareFacs();
            type            = "Facilities";
            lblOrgType.Text = "Facility";
        }

        ddlOrgs.Items.Clear();
        ddlOrgs.Items.Add(new ListItem("All " + type, "0"));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ddlOrgs.Items.Add(new ListItem(dt.Rows[i]["name"].ToString(), dt.Rows[i]["organisation_id"].ToString()));
        }

        if (IsValidFormID())
        {
            ddlOrgs.SelectedValue    = GetFormID().ToString();
            lblHowToAddItems.Visible = false;
        }
    }
Exemple #10
0
    protected void GrdReferrer_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label   lblId   = (Label)GrdReferrer.Rows[e.RowIndex].FindControl("lblId");
        TextBox txtName = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtName");
        TextBox txtABN  = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtABN");
        TextBox txtACN  = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtACN");


        Organisation org = OrganisationDB.GetByID(Convert.ToInt32(lblId.Text));

        OrganisationDB.UpdateExtOrg(
            org.OrganisationID,
            org.OrganisationType.OrganisationTypeID,
            txtName.Text,
            txtACN.Text,
            txtABN.Text,
            DateTime.Now,
            org.IsDebtor,
            org.IsCreditor,
            org.BpayAccount,
            org.Comment);


        GrdReferrer.EditIndex = -1;
        FillGrid();
    }
Exemple #11
0
    protected void GrdRegistration_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId             = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlStaff          = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlStaff");
        TextBox      txtProviderNumber = (TextBox)GrdRegistration.Rows[e.RowIndex].FindControl("txtProviderNumber");
        CheckBox     chkMainProvider   = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkMainProvider");
        CheckBox     chkIncMondays     = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncMondays");
        CheckBox     chkIncTuesdays    = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncTuesdays");
        CheckBox     chkIncWednesdays  = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncWednesdays");
        CheckBox     chkIncThursdays   = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncThursdays");
        CheckBox     chkIncFridays     = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncFridays");
        CheckBox     chkIncSaturdays   = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncSaturdays");
        CheckBox     chkIncSundays     = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIncSundays");

        Organisation org = OrganisationDB.GetByID(GetFormID());

        if (org == null)
        {
            HideTableAndSetErrorMessage("");
            return;
        }

        RegisterStaffDB.Update(Convert.ToInt32(lblId.Text), org.OrganisationID, Convert.ToInt32(ddlStaff.SelectedValue), txtProviderNumber.Text, chkMainProvider.Checked,
                               !chkIncSundays.Checked, !chkIncMondays.Checked, !chkIncTuesdays.Checked, !chkIncWednesdays.Checked, !chkIncThursdays.Checked, !chkIncFridays.Checked, !chkIncSaturdays.Checked);
        if (chkMainProvider.Checked)
        {
            RegisterStaffDB.UpdateAllOtherStaffAsNotMainProviders(org.OrganisationID, Convert.ToInt32(ddlStaff.SelectedValue));
        }

        GrdRegistration.EditIndex = -1;
        FillGrid();
    }
    public static PatientReferrer GetByID(int patient_referrer_id)
    {
        //string sql = "SELECT patient_referrer_id,patient_id,register_referrer_id,patient_referrer_date_added,is_debtor,is_active FROM PatientReferrer WHERE patient_referrer_id = " + patient_referrer_id.ToString();
        string    sql = JoinedSQL() + " AND patient_referrer_id = " + patient_referrer_id.ToString();
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        if (tbl.Rows.Count == 0)
        {
            return(null);
        }
        else
        {
            PatientReferrer pr = Load(tbl.Rows[0]);
            pr.Patient              = PatientDB.Load(tbl.Rows[0]);
            pr.Patient.Person       = PersonDB.Load(tbl.Rows[0], "patient_person_");
            pr.Patient.Person.Title = IDandDescrDB.Load(tbl.Rows[0], "patient_person_title_title_id", "patient_person_title_descr");

            if (tbl.Rows[0]["pr_register_referrer_id"] != DBNull.Value)
            {
                pr.RegisterReferrer                       = RegisterReferrerDB.Load(tbl.Rows[0]);
                pr.RegisterReferrer.Referrer              = ReferrerDB.Load(tbl.Rows[0]);
                pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(tbl.Rows[0], "referrer_person_");
                pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[0], "referrer_person_title_title_id", "referrer_person_title_descr");
                pr.RegisterReferrer.Organisation          = OrganisationDB.Load(tbl.Rows[0], "organisation_");
            }
            if (tbl.Rows[0]["pr_organisation_id"] != DBNull.Value)
            {
                pr.Organisation = OrganisationDB.Load(tbl.Rows[0], "nonepcorg_");
            }

            return(pr);
        }
    }
Exemple #13
0
    protected void FillGrid()
    {
        Organisation org = IsValidFormOrgID() ? OrganisationDB.GetByID(GetFormOrgID()) : null;

        if (!IsValidFormOrgID())
        {
            lblHeading.Text = "Maintain Letters";
        }
        else if (org == null)
        {
            lblHeading.Text = "Maintain Default Letters";
        }
        else
        {
            lblHeading.Text         = "Maintain Letters For ";
            lnkToEntity.Text        = org.Name;
            lnkToEntity.NavigateUrl = "OrganisationDetailV2.aspx?type=view&id=" + org.OrganisationID;
        }

        DataTable dt = IsValidFormOrgID() ? LetterDB.GetDataTable_ByOrg(GetFormOrgID(), GetFormOrgID() == 0 ? Convert.ToInt32(Session["SiteID"]) : -1) : LetterDB.GetDataTable(Convert.ToInt32(Session["SiteID"]));

        Session["letter_data"] = dt;

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


            try
            {
                GrdLetter.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdLetter.DataSource = dt;
            GrdLetter.DataBind();

            int TotalColumns = GrdLetter.Rows[0].Cells.Count;
            GrdLetter.Rows[0].Cells.Clear();
            GrdLetter.Rows[0].Cells.Add(new TableCell());
            GrdLetter.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdLetter.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemple #14
0
 public static int NumForeignKeyDependencies(int entity_id)
 {
     return(SiteDB.GetCountByEntityID(entity_id) +
            PersonDB.GetCountByEntityID(entity_id) +
            OrganisationDB.GetCountByEntityID(entity_id) +
            BookingDB.GetCountByEntityID(entity_id) +
            InvoiceDB.GetCountByEntityID(entity_id));
 }
    protected void FillGrid()
    {
        Organisation org = null;

        if (IsValidFormID())
        {
            org = OrganisationDB.GetByID(GetFormID());
        }


        DataTable dt = org == null ? dt = StockDB.GetDataTable(!UserView.GetInstance().IsAgedCareView ? 5 : 6) : dt = StockDB.GetDataTable_ByOrg(org.OrganisationID);

        Session["registerstocktoorg_data"] = dt;

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


            try
            {
                GrdRegistration.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdRegistration.DataSource = dt;
            GrdRegistration.DataBind();

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

        if (org == null || hideFotter)
        {
            GrdRegistration.FooterRow.Visible = false;
        }
    }
Exemple #16
0
    public static Organisation[] GetOrganisationsOf(int staff_id)
    {
        DataTable tbl = GetDataTable_OrganisationsOf(staff_id);

        Organisation[] list = new Organisation[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            list[i] = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted");
        }
        return(list);
    }
Exemple #17
0
 protected void ResetOrgName()
 {
     if (txtUpdateOrganisationID.Text.Length == 0)
     {
         txtUpdateOrganisationName.Text = "";
     }
     else
     {
         Organisation org = OrganisationDB.GetByID(Convert.ToInt32(txtUpdateOrganisationID.Text));
         txtUpdateOrganisationName.Text = org.Name;
     }
 }
    protected void FillOrganisationGrid()
    {
        UserView userView = UserView.GetInstance();

        lblHeading.Text = !userView.IsAgedCareView ? "Facilitys" : "Clinics";

        int       patientID = IsValidFormPatient() ? GetFormPatient(false) : -1;
        DataTable dt        = patientID == -1 ?
                              OrganisationDB.GetDataTable(0, false, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked) :
                              RegisterPatientDB.GetDataTable_OrganisationsOf(patientID, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked);

        Session["organisationlist_data"] = dt;

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


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

            int TotalColumns = GrdOrganisation.Rows[0].Cells.Count;
            GrdOrganisation.Rows[0].Cells.Clear();
            GrdOrganisation.Rows[0].Cells.Add(new TableCell());
            GrdOrganisation.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdOrganisation.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemple #19
0
    public static Organisation[] GetAllNotInc(Organisation[] excList, bool exclGroupOrg = true, bool exclIns = true)
    {
        DataTable tbl = GetDataTable_AllNotInc(excList, exclGroupOrg, false, false, exclIns);

        Organisation[] list = new Organisation[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            list[i] = OrganisationDB.Load(tbl.Rows[i]);
        }

        return(list);
    }
Exemple #20
0
    public static Letter LoadAll(DataRow row)
    {
        Letter letter = Load(row, "letter_");

        letter.LetterType = IDandDescrDB.Load(row, "lettertype_letter_type_id", "lettertype_descr");
        letter.Site       = SiteDB.Load(row, "site_");
        if (row["letterorg_organisation_id"] != DBNull.Value)
        {
            letter.Organisation = OrganisationDB.Load(row, "letterorg_");
        }
        return(letter);
    }
    protected void FillGridUpdateHistory()
    {
        Organisation org = null;

        if (IsValidFormID())
        {
            org = OrganisationDB.GetByID(GetFormID());
        }

        DataTable dt = org == null?StockUpdateHistoryDB.GetDataTable() : StockUpdateHistoryDB.GetDataTable_ByOrg(org.OrganisationID);

        Session["registerstockupdatehistory_data"] = dt;

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


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

            int TotalColumns = GrdUpdateHistory.Rows[0].Cells.Count;
            GrdUpdateHistory.Rows[0].Cells.Clear();
            GrdUpdateHistory.Rows[0].Cells.Add(new TableCell());
            GrdUpdateHistory.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdUpdateHistory.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
    public static RegisterReferrer LoadAll(DataRow row)
    {
        RegisterReferrer rr = Load(row);

        rr.Referrer              = ReferrerDB.Load(row);
        rr.Referrer.Person       = PersonDB.Load(row, "", "person_entity_id");
        rr.Referrer.Person.Title = IDandDescrDB.Load(row, "title_id", "descr");
        if (row["organisation_id"] != DBNull.Value)
        {
            rr.Organisation = OrganisationDB.Load(row, "", "organisation_entity_id", "organisation_is_deleted");
        }
        return(rr);
    }
Exemple #23
0
    public static Organisation[] GetChildrenOf(int parent_organisation_id)
    {
        string    sql = JoinedSql + @"  WHERE o.is_deleted = 0 AND o.parent_organisation_id = " + parent_organisation_id.ToString() + " ORDER BY o.name";
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        Organisation[] list = new Organisation[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            list[i] = OrganisationDB.Load(tbl.Rows[i]);
        }

        return(list);
    }
Exemple #24
0
    protected void FillForm()
    {
        try
        {
            if (!CheckIsValidStartEndDates())
            {
                return;
            }

            DataTable tblStats = OrganisationDB.GetStats(GetFromDate(), GetToDate(), UserView.GetInstance().IsClinicView ? 5 : 6, chkIncDeleted.Checked);
            lstOrgStats.DataSource = tblStats;
            lstOrgStats.DataBind();

            // get from footer

            Label lblSum_TotalBookings  = (Label)lstOrgStats.Controls[lstOrgStats.Controls.Count - 1].Controls[0].FindControl("lblSum_TotalBookings");
            Label lblSum_AvgConsultTime = (Label)lstOrgStats.Controls[lstOrgStats.Controls.Count - 1].Controls[0].FindControl("lblSum_AvgConsultTime");
            Label lblSum_Bookings       = (Label)lstOrgStats.Controls[lstOrgStats.Controls.Count - 1].Controls[0].FindControl("lblSum_Bookings");
            Label lblSum_Patients       = (Label)lstOrgStats.Controls[lstOrgStats.Controls.Count - 1].Controls[0].FindControl("lblSum_Patients");

            lblSum_TotalBookings.Text = String.Format("{0:n0}", tblStats.Compute("Sum(total_bookings)", ""));

            decimal total = 0;
            int     count = 0;
            for (int i = 0; i < tblStats.Rows.Count; i++)
            {
                if (tblStats.Rows[i]["avg_minutes"] == DBNull.Value)
                {
                    continue;
                }
                total += Convert.ToDecimal(tblStats.Rows[i]["avg_minutes"]);
                count++;
            }
            if (count > 0)
            {
                lblSum_AvgConsultTime.Text = String.Format("{0:n0}", total / count);
            }

            lblSum_Bookings.Text = String.Format("{0:n0}", tblStats.Compute("Sum(n_bookings)", ""));
            lblSum_Patients.Text = String.Format("{0:n0}", tblStats.Compute("Sum(n_patients)", ""));
        }
        catch (CustomMessageException cmEx)
        {
            HideTableAndSetErrorMessage(cmEx.Message);
        }
        catch (Exception ex)
        {
            HideTableAndSetErrorMessage(Utilities.IsDev() ? ex.ToString() : string.Empty);
        }
    }
    public static LetterTreatmentTemplate LoadAll(DataRow row)
    {
        LetterTreatmentTemplate letters = Load(row, "lettertreatmenttemplate_");

        letters.Field = IDandDescrDB.Load(row, "field_field_id", "field_descr");

        letters.FirstLetter            = LetterDB.Load(row, "firstletter_");
        letters.FirstLetter.LetterType = IDandDescrDB.Load(row, "firstlettertype_letter_type_id", "firstlettertype_descr");
        letters.FirstLetter.Site       = SiteDB.Load(row, "firstsite_");
        if (row["firstletterorg_organisation_id"] != DBNull.Value)
        {
            letters.FirstLetter.Organisation = OrganisationDB.Load(row, "firstletterorg_");
        }

        letters.TreatmentNotesLetter            = LetterDB.Load(row, "treatmentnotesletter_");
        letters.TreatmentNotesLetter.LetterType = IDandDescrDB.Load(row, "treatmentnoteslettertype_letter_type_id", "treatmentnoteslettertype_descr");
        letters.TreatmentNotesLetter.Site       = SiteDB.Load(row, "treatmentnotessite_");
        if (row["treatmentnotesletterorg_organisation_id"] != DBNull.Value)
        {
            letters.TreatmentNotesLetter.Organisation = OrganisationDB.Load(row, "treatmentnotesletterorg_");
        }

        letters.LastLetter            = LetterDB.Load(row, "lastletter_");
        letters.LastLetter.LetterType = IDandDescrDB.Load(row, "lastlettertype_letter_type_id", "lastlettertype_descr");
        letters.LastLetter.Site       = SiteDB.Load(row, "lastsite_");
        if (row["lastletterorg_organisation_id"] != DBNull.Value)
        {
            letters.LastLetter.Organisation = OrganisationDB.Load(row, "lastletterorg_");
        }

        letters.LastLetterPT            = LetterDB.Load(row, "lastletterpt_");
        letters.LastLetterPT.LetterType = IDandDescrDB.Load(row, "lastlettertypept_letter_type_id", "lastlettertypept_descr");
        letters.LastLetterPT.Site       = SiteDB.Load(row, "lastsitept_");
        if (row["lastletterorgpt_organisation_id"] != DBNull.Value)
        {
            letters.LastLetterPT.Organisation = OrganisationDB.Load(row, "lastletterorgpt_");
        }

        letters.LastLetterWhenReplacingEPC            = LetterDB.Load(row, "lastletterwhenreplacingepc_");
        letters.LastLetterWhenReplacingEPC.LetterType = IDandDescrDB.Load(row, "lastletterwhenreplacingepctype_letter_type_id", "lastletterwhenreplacingepctype_descr");
        letters.LastLetterWhenReplacingEPC.Site       = SiteDB.Load(row, "lastwhenreplacingepcsite_");
        if (row["lastletterorg_organisation_id"] != DBNull.Value)
        {
            letters.LastLetterWhenReplacingEPC.Organisation = OrganisationDB.Load(row, "lastletterwhenreplacingepcorg_");
        }

        letters.Site = SiteDB.Load(row, "site_");

        return(letters);
    }
    protected static Organisation[] GetChildren(ref DataTable dt, string query, int level)
    {
        DataRow[]      foundRows = dt.Select(query, "name");
        Organisation[] children  = new Organisation[foundRows.Length];
        for (int i = 0; i < foundRows.Length; i++)
        {
            Organisation org = OrganisationDB.LoadAll(foundRows[i]);
            org.TreeDataRow  = foundRows[i];
            org.TreeLevel    = level;
            org.TreeChildren = GetChildren(ref dt, "parent_organisation_id = " + org.OrganisationID.ToString(), level + 1);
            children[i]      = org;
        }

        return(children);
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        Organisation org = OrganisationDB.GetByID(GetFormID());

        if (org == null)
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
            return;
        }

        DataTable dt       = Session["registerpatienttoorg_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (tblEmpty)
        {
            dt.Rows.RemoveAt(0);
        }


        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("ID").Append(",");
        sb.Append("Clinic/Fac").Append(",");
        sb.Append("Patient").Append(",");
        sb.Append("Date Added To Clinic/Fac").Append(",");
        sb.Append("Last Booking").Append(",");
        sb.Append("Next Booking").Append(",");
        sb.Append("EPC Expires").Append(",");
        sb.Append("EPC's Remaining").Append(",");
        sb.Append("Last Recall Letter Sent");
        sb.AppendLine();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append(dt.Rows[i]["patient_id"].ToString()).Append(",");
            sb.Append(org.Name).Append(",");
            sb.Append(dt.Rows[i]["firstname"].ToString() + " " + dt.Rows[i]["surname"].ToString()).Append(",");
            sb.Append(((DateTime)dt.Rows[i]["register_patient_date_added"]).ToString("dd-MM-yyyy")).Append(",");
            sb.Append(dt.Rows[i]["last_booking_date"] == DBNull.Value ? "" : ((DateTime)dt.Rows[i]["last_booking_date"]).ToString("dd-MM-yyyy")).Append(",");
            sb.Append(dt.Rows[i]["next_booking_date"] == DBNull.Value ? "" : ((DateTime)dt.Rows[i]["next_booking_date"]).ToString("dd-MM-yyyy")).Append(",");
            sb.Append(dt.Rows[i]["epc_expire_date"] == DBNull.Value ? "" : ((DateTime)dt.Rows[i]["epc_expire_date"]).ToString("dd-MM-yyyy")).Append(",");
            sb.Append(dt.Rows[i]["epc_count_remaining"].ToString()).Append(",");
            sb.Append(dt.Rows[i]["most_recent_recall_sent"] == DBNull.Value ? "" : ((DateTime)dt.Rows[i]["most_recent_recall_sent"]).ToString("dd-MM-yyyy"));
            sb.AppendLine();
        }

        ExportCSV(Response, sb.ToString(), "Patients of " + org.Name + ".csv");
    }
    private static RegisterReferrer[] _GetEPCReferrersOf(int patient_id, bool onlyActive)
    {
        DataTable tbl = onlyActive ? GetDataTable_ActiveEPCReferrersOf(patient_id) : GetDataTable_EPCReferrersOf(patient_id);

        RegisterReferrer[] list = new RegisterReferrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            RegisterReferrer rr = RegisterReferrerDB.Load(tbl.Rows[i], "regref_");
            rr.Referrer              = ReferrerDB.Load(tbl.Rows[i], "referrer_");
            rr.Referrer.Person       = PersonDB.Load(tbl.Rows[i], "referrer_person_");
            rr.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "referrer_person_title_title_id", "referrer_person_title_descr");
            rr.Organisation          = OrganisationDB.Load(tbl.Rows[i], "organisation_");
            list[i] = rr;
        }
        return(list);
    }
Exemple #29
0
    /*
     * protected bool IsValidFormOrg()
     * {
     *  string orgID = Request.QueryString["org"];
     *  return orgID != null && Regex.IsMatch(orgID, @"^\d+$") && OrganisationDB.Exists(Convert.ToInt32(orgID));
     * }
     * protected int GetFormOrg(bool checkIsValid = true)
     * {
     *  if (checkIsValid && !IsValidFormOrg())
     *      throw new Exception("Invalid url org");
     *  return Convert.ToInt32(Request.QueryString["org"]);
     * }
     *
     * protected bool IsValidFormOrgs()
     * {
     *  string orgIDs = Request.QueryString["orgs"];
     *  return orgIDs != null && Regex.IsMatch(orgIDs, @"^[\d,]+$") && OrganisationDB.Exists(orgIDs);
     * }
     * protected string GetFormOrgs(bool checkIsValid = true)
     * {
     *  if (checkIsValid && !IsValidFormOrgs())
     *      throw new Exception("Invalid url orgs");
     *  return Request.QueryString["orgs"];
     * }
     */

    #endregion

    #region GrdReferrer

    protected void FillReferrerGrid()
    {
        //DataTable dt = RegisterReferrerDB.GetDataTable(false, new int[] { 191 }, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked);
        DataTable dt = OrganisationDB.GetDataTable(0, false, true, true, true, true, false, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked, "191");

        Session["referrerorglistpopup_data"] = dt;

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

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

            int TotalColumns = GrdReferrer.Rows[0].Cells.Count;
            GrdReferrer.Rows[0].Cells.Clear();
            GrdReferrer.Rows[0].Cells.Add(new TableCell());
            GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdReferrer.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemple #30
0
    // returns 2d hashtable
    // get by:  hash[new Hashtable2D.Key(staffID, (int)DayOfWeek.Sunday)]
    public static Hashtable Get2DHashByStaffIDDayID(int[] staff_ids = null)
    {
        string    sql = JoinedSql + (staff_ids != null && staff_ids.Length > 0 ? @" AND r.staff_id IN(" + string.Join(",", staff_ids) + ")" : "");
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        Hashtable hash = new Hashtable();

        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            RegisterStaff rr = Load(tbl.Rows[i], "registration_provider_number");
            rr.Staff        = StaffDB.Load(tbl.Rows[i], "staff_");
            rr.Staff.Person = PersonDB.Load(tbl.Rows[i], "", "person_entity_id");
            rr.Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_");

            if (!rr.ExclSun)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Sunday);
            }
            if (!rr.ExclMon)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Monday);
            }
            if (!rr.ExclTue)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Tuesday);
            }
            if (!rr.ExclWed)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Wednesday);
            }
            if (!rr.ExclThu)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Thursday);
            }
            if (!rr.ExclFri)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Friday);
            }
            if (!rr.ExclSat)
            {
                AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Saturday);
            }
        }

        return(hash);
    }