Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Utilities.SetNoCache(Response);
        }

        try
        {
            if (Session == null || Session["DB"] == null)
            {
                throw new SessionTimedOutException();
            }

            string colSep = "|";
            string rowSep = "<>";

            string firstname = Request.QueryString["firstname"];
            string surname   = Request.QueryString["surname"];

            if (firstname == null ||
                surname == null)
            {
                throw new CustomMessageException();
            }

            if (firstname.Length == 0 || surname.Length == 0)
            {
                Response.Write("NONE");
                return;
            }


            if (GetUrlParamType() == UrlParamType.Staff)
            {
                Staff[] list = StaffDB.DuplicateSearch(firstname, "", surname);
                if (list.Length == 0)
                {
                    Response.Write("NONE");
                }
                else
                {
                    string result = "ID" + colSep + "Firstname" + colSep + "Middlename" + colSep + "Surname" + colSep + "D.O.B" + colSep + "Addresses" + colSep + "Phone Nbrs" + rowSep;
                    for (int i = 0; i < list.Length; i++)
                    {
                        result += GetLine(list[i].StaffID, list[i].Person, colSep, rowSep, i > 0, true, true, true, false);
                    }
                    Response.Write(result);
                }
            }
            else if (GetUrlParamType() == UrlParamType.Patient)
            {
                Patient[] list = PatientDB.DuplicateSearch(firstname, "", surname);
                if (list.Length == 0)
                {
                    Response.Write("NONE");
                }
                else
                {
                    string result = "ID" + colSep + "Firstname" + colSep + "Middlename" + colSep + "Surname" + colSep + "D.O.B" + colSep + "Addresses" + colSep + "Phone Nbrs" + rowSep;
                    for (int i = 0; i < list.Length; i++)
                    {
                        result += GetLine(list[i].PatientID, list[i].Person, colSep, rowSep, i > 0, true, true, true, false);
                    }
                    Response.Write(result);
                }
            }
            else if (GetUrlParamType() == UrlParamType.Referrer)
            {
                Referrer[] list = ReferrerDB.DuplicateSearch(firstname, "", surname);
                if (list.Length == 0)
                {
                    Response.Write("NONE");
                }
                else
                {
                    //string result = "ID" + colSep + "Firstname" + colSep + "Middlename" + colSep + "Surname" + colSep + "Addresses" + colSep + "Phone Nbrs" + rowSep;
                    //for (int i = 0; i < list.Length; i++)
                    //    result += GetLine(list[i].ReferrerID, list[i].Person, colSep, rowSep, i > 0, false);
                    //Response.Write(result);

                    string result = "ID" + colSep + "Firstname" + colSep + "Middlename" + colSep + "Surname" + colSep + "Clinics   " + colSep + "Provider Nbrs" + rowSep;
                    for (int i = 0; i < list.Length; i++)
                    {
                        result += GetLine(list[i].ReferrerID, list[i].Person, colSep, rowSep, i > 0, false, false, false, true);
                    }
                    Response.Write(result);
                }
            }
            else
            {
                throw new CustomMessageException();
            }
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write("Exception: " + (Utilities.IsDev() ? ex.ToString() : "Error - please contact system administrator."));
        }
    }