Example #1
0
    public static void UnsubscribeAll(int patientID, string DB)
    {
        SystemVariables sysVariables = SystemVariableDB.GetAll(DB);

        if (sysVariables["AddressType"].Value == "Contact")
        {
            Contact[] emails = ContactDB.GetByEntityID(-1, patientID, 27, false, DB);
            foreach (Contact email in emails)
            {
                ContactDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB);
            }
        }
        else if (sysVariables["AddressType"].Value == "ContactAus")
        {
            ContactAus[] emails = ContactAusDB.GetByEntityID(-1, patientID, 27, false, DB);
            foreach (ContactAus email in emails)
            {
                ContactAusDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB);
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + sysVariables["AddressType"].Value);
        }
    }
Example #2
0
 protected string GetPhoneNbrs(int entity_id)
 {
     if (Utilities.GetAddressType().ToString() == "Contact")
     {
         Contact[] list   = ContactDB.GetByEntityID(2, entity_id);
         string    result = string.Empty;
         for (int i = 0; i < list.Length; i++)
         {
             result += (i > 0 ? Environment.NewLine : "") + list[i].AddrLine1;
         }
         return(result);
     }
     else if (Utilities.GetAddressType().ToString() == "ContactAus")
     {
         ContactAus[] list   = ContactAusDB.GetByEntityID(2, entity_id);
         string       result = string.Empty;
         for (int i = 0; i < list.Length; i++)
         {
             result += (i > 0 ? Environment.NewLine : "") + list[i].AddrLine1;
         }
         return(result);
     }
     else
     {
         throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
     }
 }
Example #3
0
    protected string GetContactDetail(DataRow[] rows)
    {
        string output = string.Empty;

        for (int i = 0; i < rows.Length; i++)
        {
            ContactAus contact = ContactAusDB.LoadAll(rows[i]);

            bool isAddress = contact.ContactType.ContactTypeGroup.ID == 1;
            bool isPhone   = contact.ContactType.ContactTypeGroup.ID == 2;
            bool isBedroom = contact.ContactType.ContactTypeGroup.ID == 3;

            bool isEmail   = contact.ContactType.ContactTypeID == 27;
            bool isWebsite = contact.ContactType.ContactTypeID == 28;


            if (isAddress)
            {
                output += @"<tr><td style=""min-width:140px"">" + contact.ContactType.Descr + @"</td><td style=""min-width:10px;""></td><td>" + contact.GetFormattedAddress() + "<br>" + "</td></tr>";
            }
            else if (isPhone)
            {
                output += @"<tr><td style=""min-width:140px"">" + contact.ContactType.Descr + @"</td><td style=""min-width:10px;""></td><td>" + contact.GetFormattedPhoneNumber() + "</td></tr>";
            }
            else if (isEmail)
            {
                output += @"<tr><td style=""min-width:140px"">" + contact.ContactType.Descr + @"</td><td style=""min-width:10px;""></td><td>" + contact.AddrLine1 + "</td></tr>";
            }
        }

        return(output);
    }
    protected void UpdateTables()
    {
        DataTable dt = ContactAusDB.GetDataTable_ByEntityID(-1, this.EntityID);

        CreateTable(phAddresses, dt.Select("atg_contact_type_group_id=1"), 525, 500);
        CreateTable(phPhoneNums, dt.Select("atg_contact_type_group_id=2"), 450, 365);
        CreateTable(phBedrooms, dt.Select("atg_contact_type_group_id=3"), 450, 365);
        CreateTable(phEmails, dt.Select("atg_contact_type_group_id=4"), 450, 365);
        //this.CreateTableEmails   (dt.Select("ad_contact_type_id=27"));
    }
Example #5
0
    public static string GetEmailsCommaSepByEntityID(int entityID, bool forBilling, bool forNonBilling)
    {
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            Contact[] contacts = ContactDB.GetByEntityIDs(-1, new int[] { entityID }, 27, -1);
            if (contacts == null || contacts.Length == 0)
            {
                return(null);
            }

            ArrayList emails = new ArrayList();
            foreach (Contact c in contacts)
            {
                if (((forBilling && c.IsBilling) || (forNonBilling && c.IsNonBilling)) && c.AddrLine1.Trim().Length > 0 && Utilities.IsValidEmailAddress(c.AddrLine1.Trim()))
                {
                    emails.Add(c.AddrLine1.Trim());
                }
            }

            if (emails.Count > 0)
            {
                return(string.Join(",", ((string[])emails.ToArray(typeof(string)))));
            }
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAus[] contacts = ContactAusDB.GetByEntityIDs(-1, new int[] { entityID }, 27, -1);
            if (contacts == null || contacts.Length == 0)
            {
                return(null);
            }

            ArrayList emails = new ArrayList();
            foreach (ContactAus c in contacts)
            {
                if (((forBilling && c.IsBilling) || (forNonBilling && c.IsNonBilling)) && c.AddrLine1.Trim().Length > 0 && Utilities.IsValidEmailAddress(c.AddrLine1.Trim()))
                {
                    emails.Add(c.AddrLine1.Trim());
                }
            }

            if (emails.Count > 0)
            {
                return(string.Join(",", ((string[])emails.ToArray(typeof(string)))));
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(null);
    }
Example #6
0
    protected string GetContactInfo(int EntityID, int indentPX, string showHideID)
    {
        string output = string.Empty;

        DataTable dt = ContactAusDB.GetDataTable_ByEntityID(-1, EntityID);

        output += GetContactDetail(dt.Select("atg_contact_type_group_id=1"));
        output += GetContactDetail(dt.Select("atg_contact_type_group_id=2"));
        output += GetContactDetail(dt.Select("atg_contact_type_group_id=4"));

        return(output == string.Empty ? "" : @"<table id='" + showHideID + @"' style=""margin-left:" + indentPX + @"px; display:none;"">" + output + "</table>");
    }
Example #7
0
    public static ContactAus GetFirstByEntityID(string contact_type_group_id, int entity_id, string contact_type_id = null, bool orderByShippingBeforeBilling = false)
    {
        ContactAus[] contacts = ContactAusDB.GetByEntityID(contact_type_group_id, entity_id, contact_type_id, orderByShippingBeforeBilling);

        if (contacts.Length == 0)
        {
            return(null);
        }
        else
        {
            return(contacts[0]);
        }
    }
Example #8
0
    public static string[] GetEmailsByEntityID(int entityID) // clone from ContactAus.GetEmailsByEntityID(entityID)
    {
        string[] emails;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            emails = Contact.RemoveInvalidEmailAddresses(ContactDB.GetByEntityID(-1, entityID, 27)).Select(r => r.AddrLine1).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            emails = ContactAus.RemoveInvalidEmailAddresses(ContactAusDB.GetByEntityID(-1, entityID, 27)).Select(r => r.AddrLine1).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(emails);
    }
Example #9
0
    public static string[] GetFaxesByEntityID(int entityID) // clone from ContactAus.GetEmailsByEntityID(entityID)
    {
        string[] faxes;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            faxes = Contact.RemoveInvalidPhoneNumbers(ContactDB.GetByEntityID(-1, entityID, 29)).Select(r => Regex.Replace(r.AddrLine1, "[^0-9]", "")).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            faxes = ContactAus.RemoveInvalidPhoneNumbers(ContactAusDB.GetByEntityID(-1, entityID, 29)).Select(r => Regex.Replace(r.AddrLine1, "[^0-9]", "")).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(faxes);
    }
    void DeleteContact_Command(object sender, CommandEventArgs e)
    {
        int contactID = Convert.ToInt32(e.CommandArgument);

        ContactAusDB.UpdateInactive(contactID);

        //
        // the update causes the page with this control to validate to run and I can't find why ... just redirect
        //

        //UpdateTables();
        Response.Redirect(Request.RawUrl);


        // call the main page to redirect ??
        // pass in EventHandler like in InvoiceItemsControl.ascx.cs    ??
        // but need f*****g update code on all sites ffs
    }
    protected void CreateTable(PlaceHolder placeHolder, DataRow[] rows, int width, int height)
    {
        placeHolder.Controls.Clear();
        Table t = new Table();

        placeHolder.Controls.Add(t);
        for (int i = 0; i < rows.Length; i++)
        {
            ContactAus contact = ContactAusDB.LoadAll(rows[i]);
            if (contact.FreeText.Trim().Length > 0)
            {
                t.Rows.Add(CreateNewRow(contact, width, height, true, true));
                t.Rows.Add(CreateNewRow(contact, width, height, true, false));
            }
            else
            {
                t.Rows.Add(CreateNewRow(contact, width, height, false, false));
            }
        }
    }
Example #12
0
    public static void Delete(int entity_id, bool checkForeignKeys = true)
    {
        if (checkForeignKeys)
        {
            // do NOT delete the "entity" that this is for - that should be done "explicitly" elsewhere
            // but make sure there is no entity that it relies on
            if (SiteDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Site record depends on it ");
            }
            if (PersonDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Person record depends on it ");
            }
            if (OrganisationDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Organisation record depends on it ");
            }
            if (BookingDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Booking record depends on it ");
            }
            if (InvoiceDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Invoice record depends on it ");
            }
        }

        // delete all things associated with the entity
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            ContactDB.DeleteByEntityID(entity_id);
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAusDB.DeleteByEntityID(entity_id);
        }
        NoteDB.DeleteByEntityID(entity_id);

        DBBase.ExecuteNonResult("DELETE FROM Entity WHERE entity_id = " + entity_id.ToString() + "; DBCC CHECKIDENT(Entity,RESEED,1); DBCC CHECKIDENT(Entity);");
    }
Example #13
0
    protected void btnRegisterReferrerSelectionUpdate_Click(object sender, EventArgs e)
    {
        // can update info ... if needed...
        int newRegisterReferrerID = Convert.ToInt32(registerReferrerID.Value);

        if (newRegisterReferrerID == -1)
        {
            lblReferrerText.Text = "<b>All Referreres</b>";
        }
        else
        {
            RegisterReferrer regRef = RegisterReferrerDB.GetByID(newRegisterReferrerID);
            //lblReferrerText.Text = regRef.Referrer.Person.FullnameWithoutMiddlename;

            string phNumTxt = string.Empty;
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                Contact[] phNums = ContactDB.GetByEntityID(2, regRef.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                ContactAus[] phNums = ContactAusDB.GetByEntityID(2, regRef.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            lblReferrerText.Text = "<b>" + regRef.Referrer.Person.FullnameWithoutMiddlename + "</b> [" + regRef.Organisation.Name + "]" + "<br />" +
                                   (phNumTxt.Length == 0 ? "" : phNumTxt + "<br />"); // put in referrers fax and phone numbers
        }
    }
    protected void CreateNoteFile(string tmpFilename)
    {
        string header = string.Empty;

        Booking booking = BookingDB.GetByEntityID(GetFormID());

        if (booking != null)
        {
            Site site = SiteDB.GetByID(Convert.ToInt32(Session["SiteID"]));

            string[] phNums;
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                phNums = ContactDB.GetByEntityID(-1, booking.Organisation.EntityID, 34).Select(r => r.AddrLine1).ToArray();
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                phNums = ContactAusDB.GetByEntityID(-1, booking.Organisation.EntityID, 34).Select(r => r.AddrLine1).ToArray();
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            if (phNums.Length == 0)
            {
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    phNums = ContactDB.GetByEntityID(-1, site.EntityID, 34).Select(r => r.AddrLine1).ToArray();
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    phNums = ContactAusDB.GetByEntityID(-1, site.EntityID, 34).Select(r => r.AddrLine1).ToArray();
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }
            }

            string numbers = string.Empty;
            if (phNums.Length > 0)
            {
                numbers += " - TEL " + phNums[0];
            }
            if (phNums.Length > 1)
            {
                numbers += ", " + phNums[1];
            }

            header += site.Name + numbers + Environment.NewLine;
            header += "Clinic:  " + booking.Organisation.Name + Environment.NewLine;

            if (booking.Patient != null)
            {
                header += "Patient:  " + booking.Patient.Person.FullnameWithoutMiddlename + Environment.NewLine;
            }
            if (booking.Offering != null)
            {
                header += "Service:  " + booking.Offering.Name + Environment.NewLine;
            }

            header += "Provider:  " + booking.Provider.Person.FullnameWithoutMiddlename + Environment.NewLine;
            header += "Date of Consultation: " + booking.DateStart.ToString("d MMM yyyy") + Environment.NewLine + Environment.NewLine + "Treatment Note:" + Environment.NewLine;
        }


        System.Collections.ArrayList notesList = new System.Collections.ArrayList();
        foreach (GridViewRow row in GrdNote.Rows)
        {
            Label    lblId    = row.FindControl("lblId") as Label;
            Label    lblText  = row.FindControl("lblText") as Label;
            CheckBox chkPrint = row.FindControl("chkPrint") as CheckBox;

            if (lblId == null || lblText == null || chkPrint == null)
            {
                continue;
            }

            if (chkPrint.Checked)
            {
                notesList.Add(header + lblText.Text.Replace("<br/>", "\n"));
            }
        }

        if (notesList.Count == 0)
        {
            throw new CustomMessageException("Please select at least one note to print.");
        }

        UserView userView     = UserView.GetInstance();
        bool     isAgedCare   = booking != null && booking.Organisation != null ? booking.Organisation.IsAgedCare : userView.IsAgedCareView;
        string   filename     = isAgedCare ? "BlankTemplateAC.docx" : "BlankTemplate.docx";
        string   originalFile = Letter.GetLettersDirectory() + filename;

        if (!System.IO.File.Exists(originalFile))
        {
            throw new CustomMessageException("Template File '" + filename + "' does not exist.");
        }

        string errorString = string.Empty;

        if (!WordMailMerger.Merge(originalFile, tmpFilename, null, null, 0, false, true, (string[])notesList.ToArray(typeof(string)), false, null, out errorString))
        {
            throw new CustomMessageException("Error:" + errorString);
        }
    }
Example #15
0
    protected int AddEmailIfNotExists(Patient patient, int siteID, string email)
    {
        // add email if different from existing

        int email_id = -1;

        string[] emails = ContactDB.GetEmailsByEntityID(patient.Person.EntityID);

        bool emailAlreadyExists = false;

        foreach (string e in emails)
        {
            if (e == email)
            {
                emailAlreadyExists = true;
            }
        }

        if (!emailAlreadyExists)
        {
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                if (email.Length > 0)
                {
                    email_id = ContactDB.Insert(patient.Person.EntityID,
                                                27,
                                                "",
                                                email,
                                                string.Empty,
                                                -1,
                                                -1,
                                                -1,
                                                Convert.ToInt32(siteID),
                                                true,
                                                true);
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                if (email.Length > 0)
                {
                    email_id = ContactAusDB.Insert(patient.Person.EntityID,
                                                   27,
                                                   "",
                                                   email,
                                                   string.Empty,
                                                   string.Empty,
                                                   -1,
                                                   -1,
                                                   -1,
                                                   Convert.ToInt32(siteID),
                                                   true,
                                                   true);
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }
        }

        return(email_id);
    }
Example #16
0
    protected void MergeFile(bool isAgedCare, string originalFile, string outputFile)
    {
        Booking   booking = BookingDB.GetByID(GetFormBooking());
        DataTable dt      = Session["invoicelistac_data"] as DataTable;


        string orgAddressText, orgAddressTabbedText, orgPhoneText, orgFaxText, orgWebText, orgEmailText;

        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            Contact orgAddress = ContactDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1);
            Contact orgPhone   = ContactDB.GetFirstByEntityID(null, booking.Organisation != null ? booking.Organisation.EntityID : -1, "30,33,34");
            Contact orgFax     = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 29);
            Contact orgWeb     = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 28);
            Contact orgEmail   = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 27);

            orgAddressText       = orgAddress == null    ? "No address found"      : orgAddress.GetFormattedAddress("No address found");
            orgAddressTabbedText = orgAddress == null    ? "No address found"      : orgAddress.GetFormattedAddress("No address found", 1);
            orgPhoneText         = orgPhone == null    ? "No phone number found" : orgPhone.GetFormattedPhoneNumber("No phone number found");
            orgFaxText           = orgFax == null    ? "No fax number found"   : orgFax.GetFormattedPhoneNumber("No fax number found");
            orgWebText           = orgWeb == null    ? "No website found"      : orgWeb.AddrLine1;
            orgEmailText         = orgEmail == null    ? "No email found"        : orgEmail.AddrLine1;
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAus orgAddressAus = ContactAusDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1);
            ContactAus orgPhoneAus   = ContactAusDB.GetFirstByEntityID(null, booking.Organisation != null ? booking.Organisation.EntityID : -1, "30,33,34");
            ContactAus orgFaxAus     = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 29);
            ContactAus orgWebAus     = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 28);
            ContactAus orgEmailAus   = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 27);

            orgAddressText       = orgAddressAus == null ? "No address found"      : orgAddressAus.GetFormattedAddress("No address found");
            orgAddressTabbedText = orgAddressAus == null ? "No address found"      : orgAddressAus.GetFormattedAddress("No address found", 1);
            orgPhoneText         = orgPhoneAus == null ? "No phone number found" : orgPhoneAus.GetFormattedPhoneNumber("No phone number found");
            orgFaxText           = orgFaxAus == null ? "No fax number found"   : orgFaxAus.GetFormattedPhoneNumber("No fax number found");
            orgWebText           = orgWebAus == null ? "No website found"      : orgWebAus.AddrLine1;
            orgEmailText         = orgEmailAus == null ? "No email found"        : orgEmailAus.AddrLine1;
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }


        string providerNumber = booking.Provider.ProviderNumber;

        if (!isAgedCare)
        {
            RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(booking.Provider.StaffID, booking.Organisation.OrganisationID, true);
            if (regStaff != null)
            {
                providerNumber = regStaff.ProviderNumber;
            }
        }


        System.Data.DataSet sourceDataSet = new System.Data.DataSet();
        sourceDataSet.Tables.Add("MergeIt");


        sourceDataSet.Tables[0].Columns.Add("curr_date");

        sourceDataSet.Tables[0].Columns.Add("bk_prov_fullname");
        sourceDataSet.Tables[0].Columns.Add("bk_prov_number");
        sourceDataSet.Tables[0].Columns.Add("bk_date");

        sourceDataSet.Tables[0].Columns.Add("bk_org_name");
        sourceDataSet.Tables[0].Columns.Add("bk_org_abn");
        sourceDataSet.Tables[0].Columns.Add("bk_org_acn");
        sourceDataSet.Tables[0].Columns.Add("bk_org_bpay_account");
        sourceDataSet.Tables[0].Columns.Add("bk_org_addr");
        sourceDataSet.Tables[0].Columns.Add("bk_org_addr_tabbedx1");
        sourceDataSet.Tables[0].Columns.Add("bk_org_phone");
        sourceDataSet.Tables[0].Columns.Add("bk_org_office_fax");
        sourceDataSet.Tables[0].Columns.Add("bk_org_web");
        sourceDataSet.Tables[0].Columns.Add("bk_org_email");


        sourceDataSet.Tables[0].Rows.Add(
            DateTime.Now.ToString("d MMMM, yyyy"),

            booking.Provider.Person.FullnameWithoutMiddlename,
            providerNumber,
            booking.DateStart.ToString("d MMMM, yyyy"),

            booking.Organisation.Name,
            booking.Organisation.Abn,
            booking.Organisation.Acn,
            booking.Organisation.BpayAccount,
            orgAddressText,
            orgAddressTabbedText,
            orgPhoneText,
            orgFaxText,
            orgWebText,
            orgEmailText
            );



        string[,] tblInfo = new string[dt.Rows.Count, isAgedCare ? 5 : 4];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (isAgedCare)
            {
                /*
                 *  0 = i (row nbr)
                 *  1 = room (addr1 of patient)
                 *  2 = resident
                 *  3 = resident type
                 *  4 = debtor
                 */

                tblInfo[i, 0] = (i + 1).ToString();
                tblInfo[i, 1] = dt.Rows[i]["Room"].ToString();
                tblInfo[i, 2] = dt.Rows[i]["PatientName"].ToString();
                tblInfo[i, 3] = dt.Rows[i]["ItemDescr"].ToString();
                tblInfo[i, 4] = dt.Rows[i]["Debtor"].ToString();
            }
            else
            {
                /*
                 *  0 = i (row nbr)
                 *  1 = patient
                 *  2 = service
                 *  3 = debtor
                 */

                tblInfo[i, 0] = (i + 1).ToString();
                tblInfo[i, 1] = dt.Rows[i]["PatientName"].ToString();
                tblInfo[i, 2] = dt.Rows[i]["ItemDescr"].ToString();
                tblInfo[i, 3] = dt.Rows[i]["Debtor"].ToString();
            }
        }



        // merge

        string errorString = null;

        WordMailMerger.Merge(

            originalFile,
            outputFile,
            sourceDataSet,

            tblInfo,
            1,
            true,

            true,
            null,
            true,
            null,
            out errorString);

        if (errorString != string.Empty)
        {
            throw new Exception(errorString);
        }
    }
    public static Hashtable GetBullk(string contact_type_group_ids, string contact_type_ids, int[] entity_ids, int site_id)
    {
        if (entity_ids.Length == 0)
        {
            return(new Hashtable());
        }


        // remove duplicates
        ArrayList uniqueIDs = new ArrayList();

        for (int i = 0; i < entity_ids.Length; i++)
        {
            if (!uniqueIDs.Contains(entity_ids[i]))
            {
                uniqueIDs.Add(entity_ids[i]);
            }
        }
        entity_ids = (int[])uniqueIDs.ToArray(typeof(int));


        Hashtable phoneNumbers = new Hashtable();

        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            Contact[] phoneNbrs = ContactDB.GetByEntityIDs(contact_type_group_ids, entity_ids, contact_type_ids, site_id);
            for (int i = 0; i < phoneNbrs.Length; i++)
            {
                if (phoneNumbers[phoneNbrs[i].EntityID] == null)
                {
                    phoneNumbers[phoneNbrs[i].EntityID] = new ArrayList();
                }
                ((ArrayList)phoneNumbers[phoneNbrs[i].EntityID]).Add(phoneNbrs[i]);
            }
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAus[] phoneNbrs = ContactAusDB.GetByEntityIDs(contact_type_group_ids, entity_ids, contact_type_ids, site_id);
            for (int i = 0; i < phoneNbrs.Length; i++)
            {
                if (phoneNumbers[phoneNbrs[i].EntityID] == null)
                {
                    phoneNumbers[phoneNbrs[i].EntityID] = new ArrayList();
                }
                ((ArrayList)phoneNumbers[phoneNbrs[i].EntityID]).Add(phoneNbrs[i]);
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }


        // convert arraylists to arrays (and sort if necessary)
        ArrayList keys = new ArrayList();

        foreach (DictionaryEntry de in phoneNumbers)
        {
            keys.Add(de.Key);
        }
        foreach (int key in keys)
        {
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                phoneNumbers[key] = (Contact[])((ArrayList)phoneNumbers[key]).ToArray(typeof(Contact));
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                phoneNumbers[key] = (ContactAus[])((ArrayList)phoneNumbers[key]).ToArray(typeof(ContactAus));
            }
        }


        return(phoneNumbers);
    }
Example #18
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (GetUrlParamType() == UrlParamType.View)
        {
            maintable.Visible = false; // hide this so that we don't send all the page data (all suburbs, etc) to display before it redirects
            Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "edit"));
        }
        else if (GetUrlParamType() == UrlParamType.Edit)
        {
            if (!IsValidFormID())
            {
                HideTableAndSetErrorMessage();
                return;
            }
            ContactAus contact = ContactAusDB.GetByID(GetFormID());
            if (contact == null)
            {
                HideTableAndSetErrorMessage("Invalid contact ID");
                return;
            }

            bool isAddress  = contact.ContactType.ContactTypeGroup.ID == 1;
            bool isTelecoms = contact.ContactType.ContactTypeGroup.ID == 2;
            bool isBedroom  = contact.ContactType.ContactTypeGroup.ID == 3;
            bool isWeb      = contact.ContactType.ContactTypeGroup.ID == 4;
            bool isMobile   = Convert.ToInt32(ddlContactType.SelectedValue) == 30;
            bool isPOBox    = Convert.ToInt32(ddlContactType.SelectedValue) == 37 || Convert.ToInt32(ddlContactType.SelectedValue) == 262;

            bool isEmail   = Convert.ToInt32(ddlContactType.SelectedValue) == 27;
            bool isWebsite = Convert.ToInt32(ddlContactType.SelectedValue) == 28;

            txtAddrLine1.Text = txtAddrLine1.Text.Trim();
            if (isMobile && !System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "").StartsWith("0"))
            {
                SetErrorMessage("Mobile number must start with 0");
                return;
            }
            if (isTelecoms && System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "").Length > 13)
            {
                SetErrorMessage("Phone number can not be more than 13 digits");
                return;
            }
            if (isEmail && !Utilities.IsValidEmailAddress(txtAddrLine1.Text))
            {
                SetErrorMessage("Invalid email address");
                return;
            }
            if (isWebsite && !Utilities.IsValidWebURL(txtAddrLine1.Text))
            {
                SetErrorMessage("Invalid website");
                return;
            }
            if (isPOBox && !Regex.IsMatch(txtAddrLine1.Text, "PO Box", RegexOptions.IgnoreCase) && !Regex.IsMatch(txtAddrLine2.Text, "PO Box", RegexOptions.IgnoreCase))
            {
                SetErrorMessage("The address text must contain \"PO Box\"");
                return;
            }



            ContactAusDB.Update(Convert.ToInt32(lblId.Text),
                                Convert.ToInt32(ddlContactType.SelectedValue),
                                txtFreeText.Text,
                                isTelecoms ? System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "") : txtAddrLine1.Text,
                                txtAddrLine2.Text,
                                txtStreet.Text,
                                isAddress ? Convert.ToInt32(ddlAddressChannelType.SelectedValue) : (contact.AddressChannelType == null ? -1 : contact.AddressChannelType.ID),
                                //isAddress ? Convert.ToInt32(ddlSuburb.SelectedValue)             : (contact.Suburb             == null ? -1 : contact.Suburb.SuburbID),
                                isAddress ? Convert.ToInt32(suburbID.Value) : (contact.Suburb == null ? -1 : contact.Suburb.SuburbID),
                                isAddress ? Convert.ToInt32(ddlCountry.SelectedValue) : (contact.Country == null ? -1 : contact.Country.ID),
                                contact.Site == null ? Convert.ToInt32(Session["SiteID"]) : contact.Site.SiteID,
                                isAddress || isWeb ? chkIsBilling.Checked    : contact.IsBilling,
                                isAddress || isWeb ? chkIsNonBilling.Checked : contact.IsNonBilling);



            //close this window
            maintable.Visible = false; // hide this so that we don't send all the page data (all suburbs, etc) to display before it closes

            bool refresh_on_close = Request.QueryString["refresh_on_close"] != null && Request.QueryString["refresh_on_close"] == "1";

            if (refresh_on_close)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.opener.location.href=window.opener.location.href;self.close();</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
            }
        }
        else if (GetUrlParamType() == UrlParamType.Add)
        {
            if (!IsValidFormID())
            {
                HideTableAndSetErrorMessage();
                return;
            }

            int entityID = GetFormID();
            if (!EntityDB.IDExists(entityID))
            {
                HideTableAndSetErrorMessage("Invalid entity ID");
                return;
            }


            int contactTypeGroupID = -1;
            UrlParamContactTypeGroup urlParamContactTypeGroup = GetUrlParamContactTypeGroup();
            if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Mailing)
            {
                contactTypeGroupID = 1;
            }
            else if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Telecoms)
            {
                contactTypeGroupID = 2;
            }
            else if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Bedroom)
            {
                contactTypeGroupID = 3;
            }
            else if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Internet)
            {
                contactTypeGroupID = 4;
            }
            else
            {
                HideTableAndSetErrorMessage("Invalid contact_group_type ID");
                return;
            }


            bool isAddress  = contactTypeGroupID == 1;
            bool isTelecoms = contactTypeGroupID == 2;
            bool isBedroom  = contactTypeGroupID == 3;
            bool isWeb      = contactTypeGroupID == 4;
            bool isMobile   = Convert.ToInt32(ddlContactType.SelectedValue) == 30;
            bool isPOBox    = Convert.ToInt32(ddlContactType.SelectedValue) == 37 || Convert.ToInt32(ddlContactType.SelectedValue) == 262;

            bool isEmail   = Convert.ToInt32(ddlContactType.SelectedValue) == 27;
            bool isWebsite = Convert.ToInt32(ddlContactType.SelectedValue) == 28;

            txtAddrLine1.Text = txtAddrLine1.Text.Trim();
            if (isMobile && !System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "").StartsWith("0"))
            {
                SetErrorMessage("Mobile number must start with 0");
                return;
            }
            if (isTelecoms && System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "").Length > 13)
            {
                SetErrorMessage("Phone number can not be more than 13 digits");
                return;
            }
            if (isEmail && !Utilities.IsValidEmailAddress(txtAddrLine1.Text))
            {
                SetErrorMessage("Invalid email address");
                return;
            }
            if (isWebsite && !Utilities.IsValidWebURL(txtAddrLine1.Text))
            {
                SetErrorMessage("Invalid website");
                return;
            }
            if (isPOBox && !Regex.IsMatch(txtAddrLine1.Text, "PO Box", RegexOptions.IgnoreCase) && !Regex.IsMatch(txtAddrLine2.Text, "PO Box", RegexOptions.IgnoreCase))
            {
                SetErrorMessage("The address text must contain \"PO Box\"");
                return;
            }

            int contactID = ContactAusDB.Insert(entityID,
                                                Convert.ToInt32(ddlContactType.SelectedValue),
                                                txtFreeText.Text,
                                                isTelecoms ? System.Text.RegularExpressions.Regex.Replace(txtAddrLine1.Text, "[^0-9]", "") : txtAddrLine1.Text,
                                                txtAddrLine2.Text,
                                                txtStreet.Text,
                                                isAddress ? Convert.ToInt32(ddlAddressChannelType.SelectedValue) : -1,
                                                //isAddress ? Convert.ToInt32(ddlSuburb.SelectedValue)           : -1,
                                                isAddress ? Convert.ToInt32(suburbID.Value) : -1,
                                                isAddress ? Convert.ToInt32(ddlCountry.SelectedValue) : -1,
                                                Convert.ToInt32(Session["SiteID"]),
                                                isAddress || isWeb ? chkIsBilling.Checked    : true,
                                                isAddress || isWeb ? chkIsNonBilling.Checked : true);


            // close this window
            maintable.Visible = false; // hide this so that we don't send all the page data (all suburbs, etc) to display before it closes

            bool refresh_on_close = Request.QueryString["refresh_on_close"] != null && Request.QueryString["refresh_on_close"] == "1";

            if (refresh_on_close)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.opener.location.href=window.opener.location.href;self.close();</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
            }
        }
        else
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
        }
    }
    protected void InitForm(int patientID)
    {
        HideAllRows();

        string url     = "/PatientReferrerHistoryPopupV2.aspx?id=" + patientID;
        string text    = "History";
        string onclick = @"onclick=""open_new_tab('" + url + @"');return false;""";

        lblPatientReferrerHistoryPopup.Text = "<a " + onclick + " href=\"\">" + text + "</a>";


        PatientReferrer[] patientReferrer = PatientReferrerDB.GetActiveEPCPatientReferrersOf(patientID);  // = PatientReferrerDB.GetEPCPatientReferrersOf(patient.PatientID);
        if (patientReferrer.Length > 0)
        {
            PatientReferrer  currentPatRegReferrer = patientReferrer[patientReferrer.Length - 1]; // get latest
            RegisterReferrer curRegReferrer        = currentPatRegReferrer.RegisterReferrer;

            displayHaveReferrerRow.Visible = true;

            // only allow removing a referrer if no EPC set [ie no active healthcard, or healthcard with neither date set]
            HealthCard hc          = HealthCardDB.GetActiveByPatientID(patientID);
            bool       allowDelete = hc == null || !hc.HasEPC();
            btnDelete.Visible = allowDelete;
            lblDeleteRegistrationReferrerBtnSeperator.Visible = allowDelete;

            //lblReferrer.Text = curRegReferrer.Referrer.Person.Surname + ", " + curRegReferrer.Referrer.Person.Firstname + " [" + curRegReferrer.Organisation.Name + "]" + " [" + currentPatRegReferrer.PatientReferrerDateAdded.ToString("dd-MM-yyyy") + "]";

            string phNumTxt = string.Empty;

            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                Contact[] phNums = ContactDB.GetByEntityID(2, curRegReferrer.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                ContactAus[] phNums = ContactAusDB.GetByEntityID(2, curRegReferrer.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            lblReferrer.Text = curRegReferrer.Referrer.Person.Surname + ", " + curRegReferrer.Referrer.Person.Firstname + (curRegReferrer.Organisation.Name.Length == 0 ? "" : " [" + curRegReferrer.Organisation.Name + "]") + "<br />" + Environment.NewLine +
                               "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + Environment.NewLine +
                               "<tr><td>" + "Provider Nbr:" + "</td><td style=\"width:12px\"></td><td><font color=\"#A52A2A\">" + currentPatRegReferrer.RegisterReferrer.ProviderNumber + "</font></td></tr>" + Environment.NewLine +
                               "<tr><td>" + "Date Added:" + "</td><td style=\"width:12px\"></td><td><font color=\"#A52A2A\">" + currentPatRegReferrer.PatientReferrerDateAdded.ToString("dd-MM-yyyy") + "</font></td></tr>" + Environment.NewLine +
                               "</table>" + Environment.NewLine +
                               (phNumTxt.Length == 0 ? "" : phNumTxt + "<br />"); // put in referrers fax and phone numbers

            lblReferrerRegisterID.Text = curRegReferrer.RegisterReferrerID.ToString();
        }
        else
        {
            displayNoReferrerRow.Visible = true;
        }
    }
Example #20
0
    protected void FillGrdReferreralEmails()
    {
        try
        {
            GrdReferreralEmails.Visible = true;

            Patient patient = PatientDB.GetByID(GetFormPTID());
            lblHeading.Text = "Referrer Emails For " + patient.Person.FullnameWithoutMiddlename;

            DataTable dt = ReferralDB.GetDataTable(false, patient.PatientID);
            dt.Columns.Add("email", typeof(String));

            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                int      orgEntityID = dt.Rows[i]["organisation_entity_id"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[i]["organisation_entity_id"]);
                string[] emailsList  = ContactAusDB.GetEmailsByEntityID(orgEntityID);

                if (emailsList.Length > 0)
                {
                    dt.Rows[i]["email"] = string.Join(",", emailsList);
                }
                else
                {
                    dt.Rows.RemoveAt(i);
                }
            }

            ViewState["referreralemail_data"] = dt;


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


                GrdReferreralEmails.DataBind();
            }
            else
            {
                dt.Rows.Add(dt.NewRow());
                GrdReferreralEmails.DataSource = dt;
                GrdReferreralEmails.DataBind();

                int TotalColumns = GrdReferreralEmails.Rows[0].Cells.Count;
                GrdReferreralEmails.Rows[0].Cells.Clear();
                GrdReferreralEmails.Rows[0].Cells.Add(new TableCell());
                GrdReferreralEmails.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GrdReferreralEmails.Rows[0].Cells[0].Text       = "No Referrer Emails Exist";
            }
        }
        catch (CustomMessageException ex)
        {
            SetErrorMessage(ex.ToString());
        }
        catch (Exception ex)
        {
            SetErrorMessage("", Utilities.IsDev() ? ex.ToString() : ex.Message);
        }
    }
    protected void CreateLogin(string email)
    {
        email = email.Replace("'", "''");

        //string curDbName = Session["DB"].ToString();

        try
        {
            List <Tuple <string, Patient, bool> > list = new List <Tuple <string, Patient, bool> >();


            System.Data.DataTable tbl = DBBase.ExecuteQuery("EXEC sp_databases;", "master").Tables[0];
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                string databaseName = tbl.Rows[i][0].ToString();

                if (!Regex.IsMatch(databaseName, @"Mediclinic_\d{4}"))
                {
                    continue;
                }
                //if (databaseName == "Mediclinic_0001")
                //    continue;

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

                Session["DB"] = databaseName;
                Session["SystemVariables"] = SystemVariableDB.GetAll();


                bool allowPatientLogins            = ((SystemVariables)Session["SystemVariables"])["AllowPatientLogins"].Value == "1";
                bool allowPatientsToCreateOwnLogin = ((SystemVariables)Session["SystemVariables"])["AllowPatientsToCreateOwnLogin"].Value == "1";

                if (!allowPatientLogins || !allowPatientsToCreateOwnLogin)
                {
                    continue;
                }


                int[] entityIDs;
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    entityIDs = ContactDB.GetByAddrLine1(null, email, 27).Select(r => r.EntityID).ToArray();
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    entityIDs = ContactAusDB.GetByAddrLine1(null, email, 27).Select(r => r.EntityID).ToArray();
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }


                foreach (int entityID in entityIDs)
                {
                    Patient patient = PatientDB.GetByEntityID(entityID);
                    if (patient == null || patient.IsDeceased || patient.IsDeleted)
                    {
                        continue;
                    }

                    bool hasLoginDetails = patient.Login.Length > 0;
                    if (!hasLoginDetails)
                    {
                        string login    = Regex.Replace(patient.Person.Firstname, @"[^A-Za-z]+", "").ToLower() + Regex.Replace(patient.Person.Surname, @"[^A-Za-z]+", "").ToLower();
                        string loginTry = login;

                        Random rnd = new Random();
                        int    nbr = rnd.Next(11, 999);

                        do
                        {
                            bool loginUsed = (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && UserDatabaseMapperDB.UsernameExists(loginTry)) ||
                                             (PatientDB.LoginExists(loginTry));

                            if (!loginUsed)
                            {
                                patient.Login = loginTry;
                                patient.Pwd   = loginTry == login ? login + nbr : loginTry;

                                PatientDB.UpdateLoginPwd(patient.PatientID, patient.Login, patient.Pwd);
                                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                                {
                                    UserDatabaseMapperDB.Insert(loginTry, Session["DB"].ToString());
                                }

                                break;
                            }

                            nbr++;
                            loginTry = login + nbr;
                        } while (true);
                    }

                    SendPasswordRetrievalEmail(patient.Login, patient.Pwd, email);
                    list.Add(new Tuple <string, Patient, bool>(databaseName, patient, hasLoginDetails));
                }

                Session.Remove("DB");
                Session.Remove("SystemVariables");
            }


            System.Text.StringBuilder finalOutput = new System.Text.StringBuilder();
            foreach (Tuple <string, Patient, bool> item in list)
            {
                finalOutput.Append("<tr><td>" + item.Item1 + "</td><td>" + item.Item2.Person.FullnameWithoutMiddlename + "</td><td>" + item.Item3 + "</td><td>" + item.Item2.Login + " | " + item.Item2.Pwd + "</td></tr>");
            }


            //FailureText.Text = "Count: " + list.Count + "<br /><table border=\"1\" class=\"block_center padded-table-2px\">" + finalOutput.ToString() + "</table>";


            if (list.Count == 0)
            {
                throw new CustomMessageException("No patients found with this email");
            }

            this.FailureText.Text = "An email has been sent with new login details";
        }
        catch (CustomMessageException cmEx)
        {
            this.FailureText.Text = cmEx.Message;
        }
        finally
        {
            //Session["DB"] = curDbName;
            //Session["SystemVariables"] = SystemVariableDB.GetAll();
            Session.Remove("DB");
            Session.Remove("SystemVariables");
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // need to be able to roll back .. so keep id's same as invoice

        int  person_id      = -1;
        int  referrer_id    = -1;
        int  new_org_id     = 0;
        bool referrer_added = false;

        int  address_id     = -1;
        int  phone_id1      = -1;
        int  phone_id2      = -1;
        int  email_id       = -1;
        bool contacts_added = false;

        try
        {
            // add referrer
            if (lblId.Text == "-1") // add new referrer
            {
                Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"]));
                person_id   = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, new DateTime(1900, 1, 1));
                referrer_id = ReferrerDB.Insert(person_id);
            }
            else  // set existing referrer
            {
                referrer_id = Convert.ToInt32(lblId.Text);
            }


            // get org (or add new org)
            int org_id = 0;
            if (orgsListRow.Visible)
            {
                org_id = Convert.ToInt32(ddlOrgsList.SelectedValue);
            }
            else
            {
                org_id = new_org_id = OrganisationDB.InsertExtOrg(191, txtOrgName.Text, txtOrgACN.Text, txtOrgABN.Text, false, false, "", txtOrgComments.Text);

                // add contact info

                Organisation org = OrganisationDB.GetByID(org_id);

                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    if (txtAddressAddrLine1.Text.Trim().Length > 0 || txtAddressAddrLine2.Text.Trim().Length > 0)
                    {
                        address_id = ContactDB.Insert(org.EntityID,
                                                      Convert.ToInt32(ddlAddressContactType.SelectedValue),
                                                      txtAddressFreeText.Text,
                                                      txtAddressAddrLine1.Text,
                                                      txtAddressAddrLine2.Text,
                                                      Convert.ToInt32(ddlAddressAddressChannel.SelectedValue),
                                                      //Convert.ToInt32(ddlAddressSuburb.SelectedValue),
                                                      Convert.ToInt32(suburbID.Value),
                                                      Convert.ToInt32(ddlAddressCountry.SelectedValue),
                                                      Convert.ToInt32(Session["SiteID"]),
                                                      true,
                                                      true);
                    }

                    if (txtPhoneNumber1.Text.Trim().Length > 0)
                    {
                        phone_id1 = ContactDB.Insert(org.EntityID,
                                                     Convert.ToInt32(ddlPhoneNumber1.SelectedValue),
                                                     txtPhoneNumber1FreeText.Text,
                                                     System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber1.Text, "[^0-9]", ""),
                                                     string.Empty,
                                                     -1,
                                                     -1,
                                                     -1,
                                                     Convert.ToInt32(Session["SiteID"]),
                                                     true,
                                                     true);
                    }

                    if (txtPhoneNumber2.Text.Trim().Length > 0)
                    {
                        phone_id2 = ContactDB.Insert(org.EntityID,
                                                     Convert.ToInt32(ddlPhoneNumber2.SelectedValue),
                                                     txtPhoneNumber2FreeText.Text,
                                                     System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber2.Text, "[^0-9]", ""),
                                                     string.Empty,
                                                     -1,
                                                     -1,
                                                     -1,
                                                     Convert.ToInt32(Session["SiteID"]),
                                                     true,
                                                     true);
                    }

                    if (txtEmailAddrLine1.Text.Trim().Length > 0)
                    {
                        email_id = ContactDB.Insert(org.EntityID,
                                                    Convert.ToInt32(ddlEmailContactType.SelectedValue),
                                                    "",
                                                    txtEmailAddrLine1.Text,
                                                    string.Empty,
                                                    -1,
                                                    -1,
                                                    -1,
                                                    Convert.ToInt32(Session["SiteID"]),
                                                    true,
                                                    true);
                    }
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    if (txtAddressAddrLine1.Text.Trim().Length > 0 || txtAddressAddrLine2.Text.Trim().Length > 0)
                    {
                        address_id = ContactAusDB.Insert(org.EntityID,
                                                         Convert.ToInt32(ddlAddressContactType.SelectedValue),
                                                         txtAddressFreeText.Text,
                                                         txtAddressAddrLine1.Text,
                                                         txtAddressAddrLine2.Text,
                                                         txtStreet.Text,
                                                         Convert.ToInt32(ddlAddressAddressChannelType.SelectedValue),
                                                         //Convert.ToInt32(ddlAddressSuburb.SelctedValue),
                                                         Convert.ToInt32(suburbID.Value),
                                                         Convert.ToInt32(ddlAddressCountry.SelectedValue),
                                                         Convert.ToInt32(Session["SiteID"]),
                                                         true,
                                                         true);
                    }

                    if (txtPhoneNumber1.Text.Trim().Length > 0)
                    {
                        phone_id1 = ContactAusDB.Insert(org.EntityID,
                                                        Convert.ToInt32(ddlPhoneNumber1.SelectedValue),
                                                        txtPhoneNumber1FreeText.Text,
                                                        System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber1.Text, "[^0-9]", ""),
                                                        string.Empty,
                                                        string.Empty,
                                                        -1,
                                                        -1,
                                                        -1,
                                                        Convert.ToInt32(Session["SiteID"]),
                                                        true,
                                                        true);
                    }

                    if (txtPhoneNumber2.Text.Trim().Length > 0)
                    {
                        phone_id2 = ContactAusDB.Insert(org.EntityID,
                                                        Convert.ToInt32(ddlPhoneNumber2.SelectedValue),
                                                        txtPhoneNumber2FreeText.Text,
                                                        System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber2.Text, "[^0-9]", ""),
                                                        string.Empty,
                                                        string.Empty,
                                                        -1,
                                                        -1,
                                                        -1,
                                                        Convert.ToInt32(Session["SiteID"]),
                                                        true,
                                                        true);
                    }

                    if (txtEmailAddrLine1.Text.Trim().Length > 0)
                    {
                        email_id = ContactAusDB.Insert(org.EntityID,
                                                       Convert.ToInt32(ddlEmailContactType.SelectedValue),
                                                       "",
                                                       txtEmailAddrLine1.Text,
                                                       string.Empty,
                                                       string.Empty,
                                                       -1,
                                                       -1,
                                                       -1,
                                                       Convert.ToInt32(Session["SiteID"]),
                                                       true,
                                                       true);
                    }
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }
            }

            contacts_added = true;

            // join association
            RegisterReferrerDB.Insert(org_id, referrer_id, txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked);
            referrer_added = true;


            if (GetUrlIsPopup())
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
            }
            else
            {
                Response.Redirect("~/ReferrerList_DoctorClinicV2.aspx?surname_search=" + Utilities.FormatName(txtSurname.Text) + "&surname_starts_with=1", false);
                return;
            }
        }
        catch (Exception)
        {
            // roll back - backwards of creation order

            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                ContactDB.Delete(address_id);
                ContactDB.Delete(phone_id1);
                ContactDB.Delete(phone_id2);
                ContactDB.Delete(email_id);
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                ContactAusDB.Delete(address_id);
                ContactAusDB.Delete(phone_id1);
                ContactAusDB.Delete(phone_id2);
                ContactAusDB.Delete(email_id);
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            OrganisationDB.Delete(new_org_id);
            ReferrerDB.Delete(referrer_id);
            PersonDB.Delete(person_id);

            throw;
        }
    }
Example #23
0
    private void FillEditViewForm(bool isEditMode)
    {
        ContactAus contact = ContactAusDB.GetByID(GetFormID());

        if (contact == null)
        {
            HideTableAndSetErrorMessage("Invalid Contact ID");
            return;
        }

        DataTable addrTypes = ContactTypeDB.GetDataTable(contact.ContactType.ContactTypeGroup.ID);

        ddlContactType.DataSource = addrTypes;
        ddlContactType.DataBind();

        string type = "ContactAus";

        if (contact.ContactType.ContactTypeGroup.ID == 1)
        {
            type = "Address";
            lblLine1Descr.Text = "Line 1";
        }
        if (contact.ContactType.ContactTypeGroup.ID == 2)
        {
            type = "Phone Number";
            lblLine1Descr.Text = "Phone Number";
        }
        if (contact.ContactType.ContactTypeGroup.ID == 3)
        {
            type = "Bedroom";
            lblLine1Descr.Text = "Bedroom";
        }
        if (contact.ContactType.ContactTypeGroup.ID == 4)
        {
            type = "Email/Website";
            lblLine1Descr.Text = "Email/Website";
        }
        lblHeading.Text = isEditMode ? "Edit " + type : "View " + type;

        if (contact.ContactType.ContactTypeGroup.ID != 1)
        {
            line2Row.Visible   = false;
            streetRow.Visible  = false;
            suburbRow.Visible  = false;
            countryRow.Visible = false;
            if (contact.ContactType.ContactTypeGroup.ID != 4)
            {
                billingRow.Visible    = false;
                nonbillingRow.Visible = false;
            }
        }

        lblId.Text    = contact.ContactID.ToString();
        idRow.Visible = Utilities.IsDev();


        if (isEditMode)
        {
            ddlContactType.SelectedValue = contact.ContactType.ContactTypeID.ToString();
            txtFreeText.Text             = contact.FreeText;
            txtAddrLine1.Text            = contact.ContactType.ContactTypeGroup.ID == 2 ? Utilities.FormatPhoneNumber(contact.AddrLine1) : contact.AddrLine1;
            txtAddrLine2.Text            = contact.AddrLine2;

            txtStreet.Text = contact.StreetName;
            ddlAddressChannelType.SelectedValue = contact.AddressChannelType == null ? "-1" : contact.AddressChannelType.ID.ToString();
            suburbID.Value           = contact.Suburb == null ? "-1" : contact.Suburb.SuburbID.ToString();
            lblSuburbText.Text       = contact.Suburb == null ? "--" : contact.Suburb.Name + ", " + contact.Suburb.State + " (" + contact.Suburb.Postcode + ")";
            ddlCountry.SelectedValue = contact.Country == null ? "-1" : contact.Country.ID.ToString();
            chkIsBilling.Checked     = contact.IsBilling;
            chkIsNonBilling.Checked  = contact.IsNonBilling;

            lblContactType.Visible        = false;
            lblAddrLine1.Visible          = false;
            lblAddrLine2.Visible          = false;
            lblAddressChannelType.Visible = false;
            lblCountry.Visible            = false;
            lblIsBilling.Visible          = false;
            lblIsNonBilling.Visible       = false;
        }
        else
        {
            lblContactType.Text        = contact.ContactType.Descr;
            lblAddrLine1.Text          = contact.ContactType.ContactTypeGroup.ID == 2 ? Utilities.FormatPhoneNumber(contact.AddrLine1) : contact.AddrLine1;
            lblAddrLine2.Text          = contact.AddrLine2;
            lblStreet.Text             = contact.StreetName;
            lblAddressChannelType.Text = contact.AddressChannelType == null ? string.Empty : contact.AddressChannelType.Descr;
            suburbID.Value             = contact.Suburb == null ? "-1" : contact.Suburb.SuburbID.ToString();
            lblSuburbText.Text         = contact.Suburb == null ? "--" : contact.Suburb.Name + ", " + contact.Suburb.State + " (" + contact.Suburb.Postcode + ")";
            lblSuburbText.Font.Bold    = true;
            lblCountry.Text            = contact.Country == null ? string.Empty : contact.Country.Descr;
            lblIsBilling.Text          = contact.IsBilling ? "Yes" : "No";
            lblIsNonBilling.Text       = contact.IsNonBilling ? "Yes" : "No";

            lnkUpdateType.Visible = false;
            txtValidateAddrLine1Required.Visible = false;

            ddlContactType.Visible        = false;
            txtFreeText.Visible           = false;
            txtAddrLine1.Visible          = false;
            txtAddrLine2.Visible          = false;
            txtStreet.Visible             = false;
            ddlAddressChannelType.Visible = false;
            lnkGetSuburb.Visible          = false;
            lnkClearSuburb.Visible        = false;
            ddlCountry.Visible            = false;
            chkIsBilling.Visible          = false;
            chkIsNonBilling.Visible       = false;
        }



        if (isEditMode)
        {
            btnSubmit.Text = "Update Details";
        }
        else // is view mode
        {
            btnSubmit.Visible = false;
            btnCancel.Text    = "Close";
        }
    }
Example #24
0
    protected void CreatePatientButton_Click(object sender, EventArgs e)
    {
        if (!ddlDOBValidateAllSet.IsValid)
        {
            return;
        }

        int  person_id           = -1;
        int  patient_id          = -1;
        int  register_patient_id = -1;
        bool patient_added       = false;
        int  mainDbUserID        = -1;

        int  phone_id       = -1;
        int  email_id       = -1;
        bool contacts_added = false;

        try
        {
            string[] clinicInfo = ddlClinic.SelectedValue.Split(new string[] { "__" }, StringSplitOptions.None);
            string   dbID       = clinicInfo[0];
            int      siteID     = Convert.ToInt32(clinicInfo[1]);
            int      orgID      = Convert.ToInt32(clinicInfo[2]);

            Session["DB"] = dbID;
            Session["SystemVariables"] = SystemVariableDB.GetAll();

            txtEmailAddr.Text   = txtEmailAddr.Text.Trim();
            txtPhoneNumber.Text = txtPhoneNumber.Text.Trim();
            if (!Utilities.IsValidEmailAddress(txtEmailAddr.Text))
            {
                throw new CustomMessageException("Email must be in valid email format.");
            }

            txtLogin.Text = txtLogin.Text.Trim();
            txtPwd.Text   = txtPwd.Text.Trim();

            txtFirstname.Text = txtFirstname.Text.Trim();
            txtSurname.Text   = txtSurname.Text.Trim();



            // check if patient exists in the system, if so use existing patietn

            bool patientAlreadyExists = false;

            // check if email exists in the system
            if (!patientAlreadyExists)
            {
                if (ExistsAndCreatedLogin_FromEmail(orgID, txtPhoneNumber.Text, txtEmailAddr.Text, siteID, ref register_patient_id, ref phone_id, ref email_id))
                {
                    patientAlreadyExists      = true;
                    patient_added             = true;
                    contacts_added            = true;
                    this.lblErrorMessage.Text = "Your email alrady exist in this sytem.<br/>An email has been sent with new login details.<br/>When you receieve it, use the login link below.";
                }
            }

            // check if firstname / surname / DOB exists in the system
            if (!patientAlreadyExists)
            {
                if (ExistsAndCreatedLogin_FromNameAndDOB(orgID, txtPhoneNumber.Text, txtEmailAddr.Text, txtFirstname.Text, txtSurname.Text, GetDOBFromForm(), siteID, ref register_patient_id, ref phone_id, ref email_id))
                {
                    patientAlreadyExists      = true;
                    patient_added             = true;
                    contacts_added            = true;
                    this.lblErrorMessage.Text = "You alrady exist in this sytem.<br/>An email has been sent with new login details.<br/>When you receieve it, use the login link below.";
                }
            }



            if (!patientAlreadyExists)
            {
                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && UserDatabaseMapperDB.UsernameExists(txtLogin.Text))
                {
                    throw new CustomMessageException("Login name already in use. Please choose another");
                }
                if (PatientDB.LoginExists(txtLogin.Text))
                {
                    throw new CustomMessageException("Login name already in use. Please choose another");
                }


                // 1. Create Patient

                Staff loggedInStaff = StaffDB.GetByID(-6);
                person_id           = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), "", Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, GetDOBFromForm());
                patient_id          = PatientDB.Insert(person_id, true, false, false, "", -1, DateTime.MinValue, "", "", DateTime.MinValue, false, false, DateTime.MinValue, -1, -1, txtLogin.Text, txtPwd.Text, false, "", "", "", "");
                register_patient_id = RegisterPatientDB.Insert(orgID, patient_id);
                patient_added       = true;   // added this because was throwing a thread aborted exception after patient added before Response.Redirect


                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                {
                    if (txtLogin.Text.Length > 0)
                    {
                        mainDbUserID = UserDatabaseMapperDB.Insert(txtLogin.Text, Session["DB"].ToString());
                    }
                }


                // 2. Add Contact Info

                Patient patient = PatientDB.GetByID(patient_id);

                phone_id            = AddPhoneNbrIfNotExists(patient, siteID, txtPhoneNumber.Text);
                email_id            = AddEmailIfNotExists(patient, siteID, txtEmailAddr.Text);
                register_patient_id = AddOrgIfNotExists(patient, siteID, orgID);
                contacts_added      = true;


                SendInfoEmail(txtEmailAddr.Text, txtLogin.Text, txtPwd.Text);

                this.lblErrorMessage.Text = "An email has been sent with new login details.<br />When you receieve it, use the login link below.";
            }
        }
        catch (Exception ex)
        {
            if (!patient_added || !contacts_added)
            {
                // roll back - backwards of creation order

                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    ContactDB.Delete(phone_id);
                    ContactDB.Delete(email_id);
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    ContactAusDB.Delete(phone_id);
                    ContactAusDB.Delete(email_id);
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                RegisterPatientDB.Delete(register_patient_id);
                PatientDB.Delete(patient_id);
                PersonDB.Delete(person_id);

                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                {
                    UserDatabaseMapperDB.Delete(mainDbUserID);
                }

                if (ex is CustomMessageException)
                {
                    this.lblErrorMessage.Text = ex.Message;
                }
                else
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
        finally
        {
            //Session["DB"] = curDbName;
            //Session["SystemVariables"] = SystemVariableDB.GetAll();
            Session.Remove("DB");
            Session.Remove("SystemVariables");
        }
    }
Example #25
0
    protected bool ExistsAndCreatedLogin_FromEmail(int orgID, string phoneNumber, string email, int siteID, ref int register_patient_id, ref int phone_id, ref int email_id)
    {
        bool patientAlreadyExists = false;


        int[] entityIDs;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            entityIDs = ContactDB.GetByAddrLine1(null, email, 27).Select(r => r.EntityID).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            entityIDs = ContactAusDB.GetByAddrLine1(null, email, 27).Select(r => r.EntityID).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        foreach (int entityID in entityIDs)
        {
            Patient patient = PatientDB.GetByEntityID(entityID);
            if (patient == null || patient.IsDeceased || patient.IsDeleted)
            {
                continue;
            }

            // if no login set, create it

            bool hasLoginDetails = patient.Login.Length > 0;
            if (!hasLoginDetails)
            {
                string login    = txtLogin.Text;
                string loginTry = login;

                Random rnd = new Random();
                int    nbr = rnd.Next(11, 999);

                do
                {
                    bool loginUsed = (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && UserDatabaseMapperDB.UsernameExists(loginTry)) ||
                                     (PatientDB.LoginExists(loginTry));


                    if (loginUsed)
                    {
                        throw new CustomMessageException("Login name in use. Please choose another");
                    }

                    if (!loginUsed)
                    {
                        patient.Login = loginTry;
                        patient.Pwd   = txtPwd.Text;

                        PatientDB.UpdateLoginPwd(patient.PatientID, patient.Login, patient.Pwd);
                        if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                        {
                            UserDatabaseMapperDB.Insert(loginTry, Session["DB"].ToString());
                        }

                        break;
                    }

                    nbr++;
                    loginTry = login + nbr;
                } while (true);
            }


            // add phone number if different from existing
            phone_id = AddPhoneNbrIfNotExists(patient, siteID, phoneNumber);

            // add clinic if different from existing
            register_patient_id = AddOrgIfNotExists(patient, siteID, orgID);


            SendInfoEmail(email, patient.Login, patient.Pwd);
            patientAlreadyExists = true;
        }

        return(patientAlreadyExists);
    }
Example #26
0
    protected int AddPhoneNbrIfNotExists(Patient patient, int siteID, string phoneNumber)
    {
        // add phone number if different from existing

        int phone_id = -1;

        string[] phoneNumbers;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            phoneNumbers = ContactDB.GetByEntityID(2, patient.Person.EntityID, -1).Select(r => r.AddrLine1).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            phoneNumbers = ContactAusDB.GetByEntityID(2, patient.Person.EntityID, -1).Select(r => r.AddrLine1).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        bool phoneNumberAlreadyExists = false;

        foreach (string p in phoneNumbers)
        {
            if (Regex.Replace(p, "[^0-9]", "") == Regex.Replace(phoneNumber, "[^0-9]", ""))
            {
                phoneNumberAlreadyExists = true;
            }
        }

        if (!phoneNumberAlreadyExists)
        {
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                if (phoneNumber.Length > 0)
                {
                    phone_id = ContactDB.Insert(patient.Person.EntityID,
                                                Convert.ToInt32(ddlPhoneNumberType.SelectedValue),
                                                "",
                                                System.Text.RegularExpressions.Regex.Replace(phoneNumber, "[^0-9]", ""),
                                                string.Empty,
                                                -1,
                                                -1,
                                                -1,
                                                siteID,
                                                true,
                                                true);
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                if (phoneNumber.Length > 0)
                {
                    phone_id = ContactAusDB.Insert(patient.Person.EntityID,
                                                   Convert.ToInt32(ddlPhoneNumberType.SelectedValue),
                                                   "",
                                                   System.Text.RegularExpressions.Regex.Replace(phoneNumber, "[^0-9]", ""),
                                                   string.Empty,
                                                   string.Empty,
                                                   -1,
                                                   -1,
                                                   -1,
                                                   siteID,
                                                   true,
                                                   true);
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }
        }

        return(phone_id);
    }
Example #27
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 booking_id = Request.QueryString["booking_id"];

            if (booking_id == null || !Regex.IsMatch(booking_id, @"^\d+$"))
            {
                throw new CustomMessageException("Booking id does not exist or is not a number");
            }

            Booking booking = BookingDB.GetByID(Convert.ToInt32(booking_id));
            if (booking == null)
            {
                throw new CustomMessageException("Booking is null");
            }



            Patient patient = booking.Patient;
            if (booking.Patient == null)
            {
                Response.Write("NONE");
            }
            else
            {
                bool is_confirmed = booking.DateConfirmed != DateTime.MinValue;

                string ret = string.Empty;
                ret += booking.Patient.Person.FullnameWithoutMiddlename + "::";
                ret += (is_confirmed ? "1" : "0") + "::";


                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    Contact[] phNums = ContactDB.GetByEntityID(2, booking.Patient.Person.EntityID);
                    for (int i = 0; i < phNums.Length; i++)
                    {
                        if (i > 0)
                        {
                            ret += ",";
                        }
                        ret += phNums[i].AddrLine1;
                    }
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    ContactAus[] phNums = ContactAusDB.GetByEntityID(2, booking.Patient.Person.EntityID);
                    for (int i = 0; i < phNums.Length; i++)
                    {
                        if (i > 0)
                        {
                            ret += ",";
                        }
                        ret += phNums[i].AddrLine1;
                    }
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                Response.Write(ret);
            }
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write((Utilities.IsDev() ? "Exception: " + ex.ToString() : "Error - please contact system administrator."));
        }
    }
Example #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                Utilities.SetNoCache(Response);
            }
            HideErrorMessage();

            if (!IsPostBack)
            {
                PagePermissions.EnforcePermissions_RequireAny(Session, Response, true, true, true, true, true, false);
                Session.Remove("invoicelistac_sortexpression");
                Session.Remove("invoicelistac_data");

                if (!IsValidFormBooking())
                {
                    throw new CustomMessageException("No booking in url");
                }

                Booking booking = BookingDB.GetByID(GetFormBooking());


                string orgAddressText;
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    Contact orgAddress = ContactDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1);
                    orgAddressText = orgAddress == null    ? "No address found" : orgAddress.GetFormattedAddress("No address found");
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    ContactAus orgAddressAus = ContactAusDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1);
                    orgAddressText = orgAddressAus == null ? "No address found" : orgAddressAus.GetFormattedAddress("No address found");
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }


                lblTreatmentDate.Text = booking.DateStart.ToString("d MMM, yyyy") + "&nbsp;&nbsp;" + booking.DateStart.ToString("H:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm");
                lblOrgType.Text       = booking.Organisation.OrganisationType.Descr;
                lblOrgName.Text       = booking.Organisation.Name;
                lblOrgAddress.Text    = orgAddressText.Replace(Environment.NewLine, "<br />");
                lblProviderName.Text  = booking.Provider.Person.FullnameWithoutMiddlename;
                lblProviderNbr.Text   = booking.Provider.ProviderNumber;

                string link = @"http://localhost:2524/Invoice_ViewV2.aspx?booking_id=264225";
                lblInvLink.Text = "<a href=\"" + link + "\" onclick=\"open_new_tab('" + link + "');return false;\">View All Invoices</a>";


                if (!booking.Organisation.IsAgedCare)
                {
                    tr_address.Visible             = false;
                    btnEmailToFac.Visible          = false;
                    br_before_email_to_fac.Visible = false;

                    RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(booking.Provider.StaffID, booking.Organisation.OrganisationID, true);
                    if (regStaff != null)
                    {
                        lblProviderNbr.Text = regStaff.ProviderNumber;
                    }
                }


                FillGrid();
            }

            this.GrdBooking.EnableViewState = true;
        }
        catch (CustomMessageException ex)
        {
            if (IsPostBack)
            {
                SetErrorMessage(ex.Message);
            }
            else
            {
                HideTableAndSetErrorMessage(ex.Message);
            }
        }
        catch (Exception ex)
        {
            if (IsPostBack)
            {
                SetErrorMessage("", ex.ToString());
            }
            else
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
    }