Пример #1
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        Booking booking    = BookingDB.GetByID(GetFormBooking());
        bool    isAgedCare = booking.Organisation.IsAgedCare;


        string tmpLettersDirectory = FileHelper.GetTempDirectoryName(Letter.GetTempLettersDirectory());

        Directory.CreateDirectory(tmpLettersDirectory);

        string templateFileName = isAgedCare ? "ACTreatmentList.docx" : "TreatmentList.docx";
        string originalFile     = Letter.GetLettersDirectory() + templateFileName;
        string tmpOutputFile    = tmpLettersDirectory + "TreatmentList.pdf"; // System.IO.Path.GetExtension(originalFile));

        if (!File.Exists(originalFile))
        {
            SetErrorMessage("Template File '" + templateFileName + "' does not exist.");
            return;
        }

        MergeFile(isAgedCare, originalFile, tmpOutputFile);

        Letter.FileContents fileContents = new Letter.FileContents(System.IO.File.ReadAllBytes(tmpOutputFile), "TreatmentList.pdf");
        File.Delete(tmpOutputFile);
        System.IO.File.SetAttributes(tmpLettersDirectory, FileAttributes.Normal);
        System.IO.Directory.Delete(tmpLettersDirectory, true);

        // Nothing gets past the "DownloadDocument" method because it outputs the file
        // which is writing a response to the client browser and calls Response.End()
        // So make sure any other code that functions goes before this
        Letter.DownloadDocument(Response, fileContents.Contents, fileContents.DocName);
    }
    protected void GrdBooking_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Reverse")
        {
            try
            {
                UserView userView = UserView.GetInstance();

                int     booking_id = Convert.ToInt32(e.CommandArgument);
                Booking booking    = BookingDB.GetByID(booking_id);

                string errorString = string.Empty;
                if (!booking.CanReverse(userView.IsAdminView, out errorString))
                {
                    throw new CustomMessageException(errorString);
                }

                booking.Reverse(UserView.GetInstance().IsAdminView, Convert.ToInt32(Session["StaffID"]));

                FillGrid();
            }
            catch (CustomMessageException ex)
            {
                SetErrorMessage(ex.Message);
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
    }
Пример #3
0
    public string GetDebtor(bool asLink = false)
    {
        string name = null;
        string url  = null;

        if (this.PayerOrganisation != null)
        {
            name = this.PayerOrganisation.Name;
            if (this.PayerOrganisation.OrganisationID != -1 && this.PayerOrganisation.OrganisationID != -2 || this.PayerOrganisation.OrganisationType.OrganisationTypeID != 150)
            {
                url = "OrganisationDetailV2.aspx?type=view&id=" + this.PayerOrganisation.OrganisationID;
            }
        }
        else if (this.PayerPatient != null)
        {
            name = this.PayerPatient.Person.FullnameWithoutMiddlename;
            url  = "PatientDetailV2.aspx?type=view&id=" + this.PayerPatient.PatientID;
        }
        else
        {
            if (this.Booking != null && this.Booking.Patient != null)
            {
                // can add this query each row because in the whole system there is only 32 invoices that get to here
                // since the rest keep the patient as the payer_patient
                // and doing this for only 32 rows avoids pulling all the extra data for all invoices so its faster doing this
                Booking booking = BookingDB.GetByID(this.Booking.BookingID);
                name = booking.Patient.Person.FullnameWithoutMiddlename;
                url  = "PatientDetailV2.aspx?type=view&id=" + booking.Patient.PatientID;
            }
            else // no debtor for some cash invoices
            {
                ;
            }
        }


        if (!asLink)
        {
            return(name == null ? string.Empty : name);
        }
        else
        {
            if (name == null)
            {
                return(string.Empty);
            }
            else if (url == null)
            {
                return(name);
            }
            else
            {
                return("<a href=\"#\" onclick=\"open_new_tab('" + url + "');return false;\">" + name + "</a>");
            }
        }
    }
Пример #4
0
    protected void FillGrid()
    {
        Booking booking = BookingDB.GetByID(GetFormBooking());

        DataTable dt = Letter.GenerateInvoiceLines_ByBookingID(GetFormBooking(chkIncAddOns.Checked), booking.Organisation.IsAgedCare);

        // add to sort on room correctly
        dt.Columns.Add("PaddedRoom", typeof(String));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["PaddedRoom"] = dt.Rows[i]["Room"] == DBNull.Value ? DBNull.Value : (object)PadRoomNbr(dt.Rows[i]["Room"].ToString().Trim(), true);
        }

        Session["invoicelistac_data"] = dt;

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


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

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

        if (!booking.Organisation.IsAgedCare)
        {
            GrdBooking.Columns[1].Visible = false;
        }
    }
Пример #5
0
 private Booking GetFormBooking()
 {
     try
     {
         string id = Request.QueryString["id"];
         return((id == null || !Regex.IsMatch(id, @"^\d+$")) ? null : BookingDB.GetByID(Convert.ToInt32(id)));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #6
0
    private Booking GetFormBooking()
    {
        if (!IsValidFormBooking())
        {
            throw new Exception("Invalid booking id");
        }

        int     id      = Convert.ToInt32(Request.QueryString["booking_id"]);
        Booking booking = BookingDB.GetByID(id);

        return(booking);
    }
    protected void GrdLetterPrintHistory_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable dt       = Session["letterprinthistory_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("lph_letter_print_history_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            LetterPrintHistory letterPrintHistory = LetterPrintHistoryDB.LoadAll(thisRow);

            Button btnRetrieveFlatFile = (Button)e.Row.FindControl("btnRetrieveFlatFile");
            if (btnRetrieveFlatFile != null && btnRetrieveFlatFile.CssClass != "hiddencol")
            {
                string historyDir  = Letter.GetLettersHistoryDirectory(thisRow["lph_organisation_id"] == DBNull.Value ? 0 : Convert.ToInt32(thisRow["lph_organisation_id"]));
                string filePath    = historyDir + letterPrintHistory.LetterPrintHistoryID + System.IO.Path.GetExtension(letterPrintHistory.DocName);
                string filePathPDF = historyDir + letterPrintHistory.LetterPrintHistoryID + ".pdf";

                btnRetrieveFlatFile.Visible = System.IO.File.Exists(filePath) || System.IO.File.Exists(filePathPDF);
            }


            HyperLink lnkBookingSheetForPatient = (HyperLink)e.Row.FindControl("lnkBookingSheetForPatient");
            if (lnkBookingSheetForPatient != null)
            {
                if (thisRow["lph_booking_id"] == DBNull.Value)
                {
                    lnkBookingSheetForPatient.Visible = false;
                }
                else
                {
                    int     booking_id = Convert.ToInt32(thisRow["lph_booking_id"]);
                    Booking booking    = BookingDB.GetByID(booking_id);
                    lnkBookingSheetForPatient.NavigateUrl = booking.GetBookingSheetLinkV2();
                }
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
        }
    }
    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("-1");
            }
            else
            {
                Response.Write(booking.Patient.PatientID.ToString());
            }
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write((Utilities.IsDev() ? "Exception: " + ex.ToString() : "Error - please contact system administrator."));
        }
    }
 private Booking GetFormBooking()
 {
     try
     {
         string bookingID = Request.QueryString["booking"];
         if (bookingID == null || !Regex.IsMatch(bookingID, @"^\d+$"))
         {
             throw new CustomMessageException("Invalid booking id");
         }
         return(BookingDB.GetByID(Convert.ToInt32(Request.QueryString["booking"])));
     }
     catch (CustomMessageException ex)
     {
         HideTableAndSetErrorMessage(Utilities.IsDev() ? ex.Message : "");
         return(null);
     }
 }
Пример #10
0
    protected void GetClashOneTimeBooking()
    {
        string org_id          = Request.QueryString["org"];
        string staff_id        = Request.QueryString["staff"];
        string booking_id      = Request.QueryString["edit_booking_id"];
        string booking_type_id = Request.QueryString["booking_type_id"];

        string start_datetime = Request.QueryString["start_datetime"];
        string end_datetime   = Request.QueryString["end_datetime"];


        if (start_datetime == null || !Regex.IsMatch(start_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            end_datetime == null || !Regex.IsMatch(end_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            org_id == null || !Regex.IsMatch(org_id, @"^\-?\d+$") ||
            staff_id == null || !Regex.IsMatch(staff_id, @"^\-?\d+$") ||
            booking_id == null || !Regex.IsMatch(booking_id, @"^\-?\d+$"))
        {
            throw new CustomMessageException();
        }

        Organisation org     = OrganisationDB.GetByID(Convert.ToInt32(org_id));
        Staff        staff   = StaffDB.GetByID(Convert.ToInt32(staff_id));
        Booking      booking = booking_id == "-1" ? null : BookingDB.GetByID(Convert.ToInt32(booking_id));

        if (booking != null && booking_type_id == "-1")
        {
            booking_type_id = booking.BookingTypeID.ToString();
        }

        if ((org_id != "0" && org == null) ||
            (staff_id != "-1" && staff == null) ||
            (booking_id != "-1" && booking == null) ||
            (booking_type_id == null || (booking_type_id != "34" && booking_type_id != "340" && booking_type_id != "341" && booking_type_id != "342")))
        {
            throw new CustomMessageException();
        }

        DateTime startDateTime = ConvertStringToDateTime(start_datetime);
        DateTime endDateTime   = ConvertStringToDateTime(end_datetime);

        Booking[] bookings            = BookingDB.GetToCheckOverlap_OneTime(startDateTime, endDateTime, staff, org, booking_type_id == "342", true, false);
        Booking[] overlappingBookings = Booking.GetOverlappingBookings(bookings, startDateTime, endDateTime, booking);
        Response.Write(GetLinks(overlappingBookings));
    }
Пример #11
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."));
        }
    }
Пример #12
0
    protected void SetBooking()
    {
        string booking_patient_id = Request.QueryString["bookingpatient"];
        string booking_id         = Request.QueryString["booking"];

        if (booking_patient_id != null)
        {
            if (!Regex.IsMatch(booking_patient_id, @"^\d+$"))
            {
                throw new CustomMessageException();
            }

            BookingPatient bookingPatient = BookingPatientDB.GetByID(Convert.ToInt32(booking_patient_id));
            if (bookingPatient == null)
            {
                throw new CustomMessageException();
            }
            if (bookingPatient.Booking.Organisation == null)
            {
                throw new CustomMessageException();
            }

            btnOtherEmail.OnClientClick = "javascript: get_referrer_additional_emails(" + bookingPatient.Patient.PatientID + ");return false;";

            // get selected id's
            ArrayList selectedIDs = new ArrayList();
            foreach (RepeaterItem item in lstNotes.Items)
            {
                CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote");
                Label    lblNoteID  = (Label)item.FindControl("lblNoteID");
                if (chkUseNote.Checked)
                {
                    selectedIDs.Add(lblNoteID.Text);
                }
            }

            txtUpdatePatientID.Text      = bookingPatient.Patient.PatientID.ToString();
            txtUpdatePatientName.Text    = bookingPatient.Patient.Person.FullnameWithoutMiddlename;
            txtUpdatePatientName.Visible = false;
            lblUpdatePatientName.Text    = "<a href=\"#=\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + bookingPatient.Patient.PatientID + "'); return false;\">" + bookingPatient.Patient.Person.FullnameWithoutMiddlename + "</a>";
            lblUpdatePatientName.Visible = true;

            txtUpdateOrganisationID.Text      = bookingPatient.Booking.Organisation.OrganisationID.ToString();
            txtUpdateOrganisationName.Text    = bookingPatient.Booking.Organisation.Name;
            txtUpdateOrganisationName.Visible = false;
            lblUpdateOrganisationName.Text    = "<a href=\"#=\" onclick=\"open_new_window('OrganisationDetailV2.aspx?type=view&id=" + bookingPatient.Booking.Organisation.OrganisationID + "'); return false;\">" + bookingPatient.Booking.Organisation.Name + "</a>";
            lblUpdateOrganisationName.Visible = true;



            // show booking info

            lnkBookingSheetForPatient.Text        = "Booking sheet for " + bookingPatient.Patient.Person.FullnameWithoutMiddlename;
            lnkBookingSheetForPatient.PostBackUrl = String.Format("~/BookingsV2.aspx?type=patient&patient={0}&org={1}&staff={2}&offering={3}&date={4}", bookingPatient.Patient.PatientID, bookingPatient.Booking.Organisation.OrganisationID, bookingPatient.Booking.Provider.StaffID, bookingPatient.Offering.OfferingID, bookingPatient.Booking.DateStart.ToString("yyyy_MM_dd"));

            lnkBookingListForPatient.Text        = "Booking list for " + bookingPatient.Patient.Person.FullnameWithoutMiddlename;
            lnkBookingListForPatient.PostBackUrl = String.Format("~/BookingsListV2.aspx?patient={0}", bookingPatient.Patient.PatientID);

            lblBooking_Provider.Text      = bookingPatient.Booking.Provider.Person.FullnameWithoutMiddlename;
            lblBooking_Offering.Text      = bookingPatient.Offering.Name;
            lblBooking_BookingStatus.Text = bookingPatient.Booking.BookingStatus.Descr.ToString();
            lblBooking_Time.Text          = bookingPatient.Booking.DateStart.Date.ToString("dd MMM yyyy") + " - " + bookingPatient.Booking.DateStart.ToString("hh:mm") + "-" + bookingPatient.Booking.DateEnd.ToString("hh:mm");
            lblBooking_Notes.Text         = Note.GetPopupLinkTextV2(15, bookingPatient.EntityID, bookingPatient.NoteCount > 0, true, 1050, 530, "images/notes-bw-24.jpg", "images/notes-24.png");


            // display list of notes in repeater
            DataTable notes = NoteDB.GetDataTable_ByEntityID(bookingPatient.EntityID);
            lstNotes.DataSource = notes;
            lstNotes.DataBind();

            // check id's that were previously checked
            foreach (RepeaterItem item in lstNotes.Items)
            {
                CheckBox chkUseNote      = (CheckBox)item.FindControl("chkUseNote");
                Label    lblNoteID       = (Label)item.FindControl("lblNoteID");
                Label    lblOriginalText = (Label)item.FindControl("lblOriginalText");
                chkUseNote.Checked = selectedIDs.Contains(lblNoteID.Text);
            }

            // hide if got from url ... no need to change it
            btnPatientListPopup.Visible      = false;
            btnClearPatient.Visible          = false;
            btnOrganisationListPopup.Visible = false;
            btnClearOrganisation.Visible     = false;
        }
        else if (booking_id != null)
        {
            if (!Regex.IsMatch(booking_id, @"^\d+$"))
            {
                throw new CustomMessageException();
            }

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

            if (booking.Patient != null)
            {
                btnOtherEmail.OnClientClick = "javascript: get_referrer_additional_emails(" + booking.Patient.PatientID + ");return false;";
            }

            if (booking.Patient == null)
            {
                DataTable dt = BookingPatientDB.GetDataTable_ByBookingID(booking.BookingID);
                lstBookingPatients.DataSource = dt;
                lstBookingPatients.DataBind();

                main_table.Visible = false;
                select_booking_patient_table.Visible = true;
                return;

                //throw new CustomMessageException();
            }
            if (booking.Organisation == null)
            {
                throw new CustomMessageException();
            }

            // get selected id's
            ArrayList selectedIDs = new ArrayList();
            foreach (RepeaterItem item in lstNotes.Items)
            {
                CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote");
                Label    lblNoteID  = (Label)item.FindControl("lblNoteID");
                if (chkUseNote.Checked)
                {
                    selectedIDs.Add(lblNoteID.Text);
                }
            }

            txtUpdatePatientID.Text      = booking.Patient.PatientID.ToString();
            txtUpdatePatientName.Text    = booking.Patient.Person.FullnameWithoutMiddlename;
            txtUpdatePatientName.Visible = false;
            lblUpdatePatientName.Text    = "<a href=\"#=\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + booking.Patient.PatientID + "'); return false;\">" + booking.Patient.Person.FullnameWithoutMiddlename + "</a>";
            lblUpdatePatientName.Visible = true;

            txtUpdateOrganisationID.Text      = booking.Organisation.OrganisationID.ToString();
            txtUpdateOrganisationName.Text    = booking.Organisation.Name;
            txtUpdateOrganisationName.Visible = false;
            lblUpdateOrganisationName.Text    = "<a href=\"#=\" onclick=\"open_new_window('OrganisationDetailV2.aspx?type=view&id=" + booking.Organisation.OrganisationID + "'); return false;\">" + booking.Organisation.Name + "</a>";
            lblUpdateOrganisationName.Visible = true;



            // show booking info

            lnkBookingSheetForPatient.Text        = "Booking sheet for " + booking.Patient.Person.FullnameWithoutMiddlename;
            lnkBookingSheetForPatient.PostBackUrl = String.Format("~/BookingsV2.aspx?type=patient&patient={0}&org={1}&staff={2}&offering={3}&date={4}", booking.Patient.PatientID, booking.Organisation.OrganisationID, booking.Provider.StaffID, booking.Offering.OfferingID, booking.DateStart.ToString("yyyy_MM_dd"));

            lnkBookingListForPatient.Text        = "Booking list for " + booking.Patient.Person.FullnameWithoutMiddlename;
            lnkBookingListForPatient.PostBackUrl = String.Format("~/BookingsListV2.aspx?patient={0}", booking.Patient.PatientID);

            lblBooking_Provider.Text      = booking.Provider.Person.FullnameWithoutMiddlename;
            lblBooking_Offering.Text      = booking.Offering.Name;
            lblBooking_BookingStatus.Text = booking.BookingStatus.Descr.ToString();
            lblBooking_Time.Text          = booking.DateStart.Date.ToString("dd MMM yyyy") + " - " + booking.DateStart.ToString("hh:mm") + "-" + booking.DateEnd.ToString("hh:mm");
            lblBooking_Notes.Text         = Note.GetPopupLinkTextV2(15, booking.EntityID, booking.NoteCount > 0, true, 1050, 530, "images/notes-bw-24.jpg", "images/notes-24.png");


            // display list of notes in repeater
            DataTable notes = NoteDB.GetDataTable_ByEntityID(booking.EntityID);
            lstNotes.DataSource = notes;
            lstNotes.DataBind();

            // check id's that were previously checked
            foreach (RepeaterItem item in lstNotes.Items)
            {
                CheckBox chkUseNote      = (CheckBox)item.FindControl("chkUseNote");
                Label    lblNoteID       = (Label)item.FindControl("lblNoteID");
                Label    lblOriginalText = (Label)item.FindControl("lblOriginalText");
                chkUseNote.Checked = selectedIDs.Contains(lblNoteID.Text);
            }

            // hide if got from url ... no need to change it
            btnPatientListPopup.Visible      = false;
            btnClearPatient.Visible          = false;
            btnOrganisationListPopup.Visible = false;
            btnClearOrganisation.Visible     = false;
        }
    }
Пример #13
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("\"" + "Date Added  " + "\"").Append(",");
        sb.Append("\"" + "Type" + "\"").Append(",");
        sb.Append("\"" + "Total" + "\"").Append(",");
        sb.Append("\"" + "Reconciled" + "\"").Append(",");
        sb.Append("\"" + "Added By" + "\"").Append(",");
        sb.Append("\"" + "Organisation" + "\"").Append(",");
        sb.Append("\"" + "Reversed" + "\"").Append(",");
        sb.Append("\"" + "Treatment Date" + "\"").Append(",");
        sb.Append("\"" + "Invoice #" + "\"").Append(",");
        sb.Append("\"" + "Inv Debtor" + "\"").Append(",");
        sb.Append("\"" + "Patient" + "\"").Append(",");
        sb.AppendLine();


        DataTable dt = Session["data_receiptsReport"] as DataTable;

        bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sb.Append("\"" + Convert.ToDateTime(dt.Rows[i]["receipt_date_added"]).ToString("dd MMM yyyy") + "\"").Append(",");
                sb.Append("\"" + dt.Rows[i]["receipt_payment_type_descr"].ToString() + "\"").Append(",");
                sb.Append("\"" + dt.Rows[i]["total"].ToString() + "\"").Append(",");
                sb.Append("\"" + dt.Rows[i]["amount_reconciled"].ToString() + "\"").Append(",");
                sb.Append("\"" + dt.Rows[i]["receipt_staff_person_firstname"].ToString() + (dt.Rows[i]["receipt_staff_person_firstname"] == DBNull.Value ? "" : " ") + dt.Rows[i]["receipt_staff_person_surname"].ToString() + "\"").Append(",");
                sb.Append("\"" + dt.Rows[i]["organisation_name"].ToString() + "\"").Append(",");

                if (dt.Rows[i]["reversed_date"] == DBNull.Value)
                {
                    sb.Append("\"" + "" + "\"").Append(",");
                }
                else
                {
                    sb.Append("\"" + Convert.ToDateTime(dt.Rows[i]["reversed_date"]).ToString("dd MMM yyyy") + Environment.NewLine + "By " + dt.Rows[i]["receipt_reversed_by_person_firstname"].ToString() + (dt.Rows[i]["receipt_reversed_by_person_firstname"] == DBNull.Value ? "" : " ") + dt.Rows[i]["receipt_reversed_by_person_surname"].ToString() + (dt.Rows[i]["receipt_reversed_by_person_firstname"].ToString().Length + dt.Rows[i]["receipt_reversed_by_person_surname"].ToString().Length == 0 ? "" : Environment.NewLine) + "Previously " + dt.Rows[i]["pre_reversed_amount"].ToString() + "\"").Append(",");
                }

                if (dt.Rows[i]["booking_date_start"] == DBNull.Value)
                {
                    sb.Append("\"" + "" + "\"").Append(",");
                }
                else
                {
                    sb.Append("\"" + Convert.ToDateTime(dt.Rows[i]["booking_date_start"]).ToString("dd MMM yyyy HH:mm") + "\"").Append(",");
                }

                sb.Append("\"" + dt.Rows[i]["invoice_id"].ToString() + "\"").Append(",");



                Booking booking = dt.Rows[i]["booking_booking_id"] != DBNull.Value ? BookingDB.Load(dt.Rows[i], "booking_", false, false) : null;

                string payer = string.Empty;
                if (dt.Rows[i]["inv_payer_organisation_id"] != DBNull.Value)
                {
                    payer = dt.Rows[i]["inv_payer_organisation_name"].ToString();
                }
                else if (dt.Rows[i]["inv_payer_patient_id"] != DBNull.Value)
                {
                    payer = dt.Rows[i]["inv_payer_patient_person_firstname"].ToString() + " " + dt.Rows[i]["inv_payer_patient_person_surname"].ToString();
                }
                else
                {
                    if (booking != null)
                    {
                        // can add this query each row because in the whole system there is only 32 invoices that get to here
                        // since the rest keep the patient as the payer_patient
                        // and doing this for only 32 rows avoids pulling all the extra data for all invoices so its faster doing this

                        payer = BookingDB.GetByID(booking.BookingID).Patient.Person.FullnameWithoutMiddlename;
                    }
                }

                string patient = string.Empty;
                if (booking != null)
                {
                    patient = dt.Rows[i]["booking_patient_firstname"] + " " + dt.Rows[i]["booking_patient_surname"];
                }
                else // for private invoices
                {
                    patient = dt.Rows[i]["non_booking_patient_firstname"] + " " + dt.Rows[i]["non_booking_patient_surname"];
                }


                sb.Append("\"" + payer + "\"").Append(",");
                sb.Append("\"" + patient + "\"").Append(",");

                sb.AppendLine();
            }
        }

        string Sum_Total = String.Format("{0:C}", dt.Compute("Sum(total)", ""));

        if (Sum_Total == "")
        {
            Sum_Total = System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol + "0.00";
        }

        string Sum_AmountReconciled = String.Format("{0:C}", dt.Compute("Sum(amount_reconciled)", ""));

        if (Sum_AmountReconciled == "")
        {
            Sum_AmountReconciled = System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol + "0.00";
        }


        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");

        sb.Append("\"" + Sum_Total + "\"").Append(",");
        sb.Append("\"" + Sum_AmountReconciled + "\"").Append(",");

        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");
        sb.Append("\"" + "" + "\"").Append(",");

        sb.AppendLine();

        ExportCSV(Response, sb.ToString(), "ReceiptsReport.csv");
    }
Пример #14
0
    protected void GrdSummaryReport_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable dt       = Session["data_receiptsReport"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("receipt_id =" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            Booking booking   = thisRow["booking_booking_id"] != DBNull.Value ? BookingDB.Load(thisRow, "booking_", false, false)  : null;
            int     invoiceID = Convert.ToInt32(thisRow["invoice_id"]);

            HyperLink lnkBookingSheetForPatient = (HyperLink)e.Row.FindControl("lnkBookingSheetForPatient");
            if (lnkBookingSheetForPatient != null)
            {
                lnkBookingSheetForPatient.NavigateUrl = booking != null?booking.GetBookingSheetLinkV2() : "";

                lnkBookingSheetForPatient.Visible = booking != null;
            }

            LinkButton lnkInvoiceID = (LinkButton)e.Row.FindControl("lnkInvoiceID");
            if (lnkInvoiceID != null)
            {
                lnkInvoiceID.OnClientClick = String.Format("javascript:window.showModalDialog('Invoice_ViewV2.aspx?invoice_id={0}', '', 'dialogWidth:775px;dialogHeight:" + (thisRow["booking_booking_id"] != DBNull.Value ? "900" : "650") + "px;center:yes;resizable:no; scroll:no');return false;", thisRow["invoice_id"]);
            }



            Label lblPayer = (Label)e.Row.FindControl("lblPayer");
            if (lblPayer != null)
            {
                if (thisRow["inv_payer_organisation_id"] != DBNull.Value)
                {
                    lblPayer.Text = thisRow["inv_payer_organisation_name"].ToString();
                }
                else if (thisRow["inv_payer_patient_id"] != DBNull.Value)
                {
                    lblPayer.Text = thisRow["inv_payer_patient_person_firstname"].ToString() + " " + thisRow["inv_payer_patient_person_surname"].ToString();
                }
                else
                {
                    if (booking != null)
                    {
                        // can add this query each row because in the whole system there is only 32 invoices that get to here
                        // since the rest keep the patient as the payer_patient
                        // and doing this for only 32 rows avoids pulling all the extra data for all invoices so its faster doing this

                        lblPayer.Text = BookingDB.GetByID(booking.BookingID).Patient.Person.FullnameWithoutMiddlename;
                    }
                }
            }

            Label lblPatient = (Label)e.Row.FindControl("lblPatient");
            if (lblPatient != null)
            {
                if (booking != null)
                {
                    lblPatient.Text = thisRow["booking_patient_firstname"] + " " + thisRow["booking_patient_surname"];
                }
                else // for private invoices
                {
                    lblPatient.Text = thisRow["non_booking_patient_firstname"] + " " + thisRow["non_booking_patient_surname"];
                }
            }



            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label lblSum_Total = (Label)e.Row.FindControl("lblSum_Total");
            lblSum_Total.Text = String.Format("{0:C}", dt.Compute("Sum(total)", ""));
            if (lblSum_Total.Text == "")
            {
                lblSum_Total.Text = System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol + "0.00";
            }

            Label lblSum_AmountReconciled = (Label)e.Row.FindControl("lblSum_AmountReconciled");
            lblSum_AmountReconciled.Text = String.Format("{0:C}", dt.Compute("Sum(amount_reconciled)", ""));
            if (lblSum_AmountReconciled.Text == "")
            {
                lblSum_AmountReconciled.Text = System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol + "0.00";
            }
        }
    }
Пример #15
0
    private void FillEmptyAddForm()
    {
        Invoice invoice = InvoiceDB.GetByID(GetFormID());

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

        lblInvoiceNbr.Text  = invoice.InvoiceID.ToString();
        lblAmountOwing.Text = "$" + invoice.TotalDue.ToString();


        DataTable dt = DBBase.GetGenericDataTable(null, "ReceiptPaymentType", "receipt_payment_type_id", "descr");

        // add column for displaying data in first few rows with invoice id and invoice amount owing
        dt.Columns.Add("text");
        dt.Columns.Add("tab_index");
        for (int i = dt.Rows.Count - 1; i >= 0; i--)
        {
            dt.Rows[i]["text"] = "";
            if (Convert.ToInt32(dt.Rows[i]["receipt_payment_type_id"]) == 363)
            {
                dt.Rows.RemoveAt(i);
            }
        }

        lstPayments.DataSource = dt;
        lstPayments.DataBind();

        for (int i = lstPayments.Items.Count - 1; i >= 0; i--)
        {
            Label   lblReceiptPaymentTypeID     = (Label)lstPayments.Items[i].FindControl("lblTypeID");
            TextBox txtReceiptPaymentTypeAmount = (TextBox)lstPayments.Items[i].FindControl("txtAmount");
            Button  btnWebPay = (Button)lstPayments.Items[i].FindControl("btnWebPay");

            if (lblReceiptPaymentTypeID.Text != "133" && lblReceiptPaymentTypeID.Text != "362")
            {
                btnWebPay.Visible = false;
            }

            if (((SystemVariables)Session["SystemVariables"])["EziDebit_Enabled"].Value != "1")
            {
                btnWebPay.Visible = false;
            }

            Utilities.SetEditControlBackColour(txtReceiptPaymentTypeAmount, true, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        }

        if (lstPayments.Items.Count > 0)
        {
            TextBox txtReceiptPaymentTypeAmount = (TextBox)lstPayments.Items[0].FindControl("txtAmount");
            SetFocus(txtReceiptPaymentTypeAmount);
        }



        int entityID = -1;

        if (invoice.PayerOrganisation != null)
        {
            entityID = invoice.PayerOrganisation.EntityID;
        }
        else if (invoice.PayerPatient != null)
        {
            entityID = invoice.PayerPatient.Person.EntityID;
        }
        else if (invoice.Booking != null && invoice.Booking.Patient != null)
        {
            entityID = BookingDB.GetByID(invoice.Booking.BookingID).Patient.Person.EntityID;
        }

        DataTable dt_vouchers = CreditDB.GetUnusedVouchers(entityID);

        lstVouchers.DataSource = dt_vouchers;
        lstVouchers.DataBind();

        for (int i = lstVouchers.Items.Count - 1; i >= 0; i--)
        {
            TextBox txtAmount = (TextBox)lstVouchers.Items[i].FindControl("txtAmount");
            Utilities.SetEditControlBackColour(txtAmount, true, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        }

        if (lstVouchers.Items.Count == 0)
        {
            divVouchers.Visible = false;
        }



        Utilities.SetEditControlBackColour(txtCreditNoteTotal, true, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtCreditCardReason, true, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);

        btnSubmit.Text    = "Add Payment(s)";
        btnCancel.Visible = true;
    }
    protected void EditBooking()
    {
        //UrlReturnPage returnPage    = GetUrlReturnPage();
        bool?checkClashAllOrgs = UrlCheckClashAllOrgs;

        Booking      booking       = UrlBooking;
        DateTime?    startDateTime = UrlStartDateTime;
        DateTime?    endDateTime   = UrlEndDateTime;
        Patient      patient       = UrlPatient;
        Organisation org           = UrlOrg;
        Staff        staff         = UrlStaff;
        Offering     offering      = UrlOffering;
        bool?        confirmed     = UrlIsConfirmed;
        int?         editReason    = UrlEditReasonID;

        if (booking == null)
        {
            throw new Exception("Invalid url field booking_id");
        }
        if (startDateTime == null)
        {
            throw new Exception("Invalid url field start_datetime");
        }
        if (endDateTime == null)
        {
            throw new Exception("Invalid url field end_datetime");
        }
        if (org == null)
        {
            throw new Exception("Invalid url field org_id");
        }
        if (staff == null)
        {
            throw new Exception("Invalid url field staff_id");
        }
        if (confirmed == null)
        {
            throw new Exception("Invalid url field is_confirmed");
        }
        if (editReason == null)
        {
            throw new Exception("Invalid url field edit_reason_id");
        }

        if (booking.AddedBy == null)
        {
            throw new CustomMessageException("Error - please contact system administrator.\r\n\r\nError Details:\r\nBooking 'Added By' is not set and must be set. BK ID: " + booking.BookingID);
        }

        // check booking is valid ie no overlapping with current bookings
        Booking[] bookings = BookingDB.GetToCheckOverlap_OneTime(startDateTime.Value, endDateTime.Value, staff, checkClashAllOrgs.Value ? null : org, booking.BookingTypeID == 342, true, false);
        if (Booking.HasOverlap(bookings, startDateTime.Value, endDateTime.Value, booking))
        {
            string fromTime = startDateTime.Value.Hour.ToString().PadLeft(2, '0') + ":" + startDateTime.Value.Minute.ToString().PadLeft(2, '0');
            string toTime   = endDateTime.Value.Hour.ToString().PadLeft(2, '0') + ":" + endDateTime.Value.Minute.ToString().PadLeft(2, '0');
            throw new CustomMessageException("Can not book " + startDateTime.Value.ToString(@"ddd MMM d") + " " + fromTime + "-" + toTime + " due to overlap with existing booking");
        }


        int      booking_confirmed_by_type_id = !confirmed.Value ? -1 : 1;
        int      confirmedBy   = !confirmed.Value ? -1                : (booking.ConfirmedBy == null ? GetStaffID() : booking.ConfirmedBy.StaffID);
        DateTime dateConfirmed = !confirmed.Value ? DateTime.MinValue : (booking.ConfirmedBy == null ? DateTime.Now : booking.DateConfirmed);

        if (patient != null && !RegisterPatientDB.IsPatientRegisteredToOrg(patient.PatientID, org.OrganisationID))
        {
            RegisterPatientDB.Insert(org.OrganisationID, patient.PatientID);
        }

        BookingChangeHistoryDB.Insert(booking.BookingID, GetStaffID(), Convert.ToInt32(editReason.Value), booking.DateStart);
        BookingDB.Update(booking.BookingID, startDateTime.Value, endDateTime.Value, org.OrganisationID, staff.StaffID, patient == null ? -1 : patient.PatientID, offering == null ? -1 : offering.OfferingID,
                         booking.BookingTypeID, booking.BookingStatus.ID, -1, booking.AddedBy.StaffID, booking_confirmed_by_type_id, confirmedBy, dateConfirmed,
                         booking.DeletedBy == null ? -1 : booking.DeletedBy.StaffID, booking.DateDeleted, booking.CancelledBy == null ? -1 : booking.CancelledBy.StaffID, booking.DateCancelled, booking.IsPatientMissedAppt, booking.IsProviderMissedAppt, booking.IsEmergency, booking.IsRecurring, booking.RecurringDayOfWeek, booking.RecurringStartTime, booking.RecurringEndTime);

        if (booking.BookingTypeID == 34)
        {
            Booking newBooking = BookingDB.GetByID(booking.BookingID);
            newBooking.SendReminderEmail(booking);
        }

        if (booking.ArrivalTime != DateTime.MinValue && booking.DateStart != startDateTime)
        {
            BookingDB.RemoveArrivalTime(booking.BookingID);
        }
    }
Пример #17
0
    protected void GetClashRecurringBooking()
    {
        string org_id          = Request.QueryString["org"];
        string staff_id        = Request.QueryString["staff"];
        string booking_id      = Request.QueryString["edit_booking_id"];
        string booking_type_id = Request.QueryString["booking_type_id"];

        string start_datetime = Request.QueryString["start_datetime"];
        string end_datetime   = Request.QueryString["end_datetime"];

        string days       = Request.QueryString["days"];
        string start_time = Request.QueryString["start_time"];
        string end_time   = Request.QueryString["end_time"];

        string every_n_weeks = Request.QueryString["every_n_weeks"];

        string inc_unavailable_bkgs = Request.QueryString["inc_unavailable_bkgs"];
        string inc_customer_bkgs    = Request.QueryString["inc_customer_bkgs"];


        if (org_id == null || !Regex.IsMatch(org_id, @"^\-?\d+$") ||
            staff_id == null || !Regex.IsMatch(staff_id, @"^\-?\d+$") ||
            booking_id == null || !Regex.IsMatch(booking_id, @"^\-?\d+$") ||
            start_datetime == null || !Regex.IsMatch(start_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            end_datetime == null || (end_datetime != "NULL" && !Regex.IsMatch(end_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$")) ||
            days == null || !Regex.IsMatch(days, @"^\d{7}$") ||
            start_time == null || !Regex.IsMatch(start_time, @"^\d{4}$") ||
            end_time == null || !Regex.IsMatch(end_time, @"^\d{4}$") ||
            every_n_weeks == null || !Regex.IsMatch(every_n_weeks, @"^\d+$") ||
            inc_unavailable_bkgs == null || (inc_unavailable_bkgs != "0" && inc_unavailable_bkgs != "1") ||
            inc_customer_bkgs == null || (inc_customer_bkgs != "0" && inc_customer_bkgs != "1"))
        {
            throw new CustomMessageException();
        }

        Organisation org     = OrganisationDB.GetByID(Convert.ToInt32(org_id));
        Staff        staff   = StaffDB.GetByID(Convert.ToInt32(staff_id));
        Booking      booking = booking_id == "-1" ? null : BookingDB.GetByID(Convert.ToInt32(booking_id));

        if (booking != null && booking_type_id == "-1")
        {
            booking_type_id = booking.BookingTypeID.ToString();
        }

        if ((org_id != "0" && org == null) ||
            (staff_id != "-1" && staff == null) ||
            (booking_id != "-1" && booking == null) ||
            (booking_type_id == null || (booking_type_id != "34" && booking_type_id != "340" && booking_type_id != "341" && booking_type_id != "342")))
        {
            throw new CustomMessageException();
        }

        DateTime startDateTime = ConvertStringToDateTime(start_datetime);
        DateTime endDateTime   = ConvertStringToDateTime(end_datetime);

        TimeSpan startTime = ConvertStringToTimeSpan(start_time);
        TimeSpan endTime   = ConvertStringToTimeSpan(end_time);

        if (endTime == new TimeSpan(23, 59, 0))
        {
            endTime = new TimeSpan(0, 23, 59, 59, 999);
        }

        int  everyNWeeks        = Convert.ToInt32(every_n_weeks);
        bool incUnavailableBkgs = inc_unavailable_bkgs == "1";
        bool incCustomerBkgs    = inc_customer_bkgs == "1";


        bool onlyThisOrg = booking_type_id == "342" || (org != null && booking_type_id == "341") || (incUnavailableBkgs && !incCustomerBkgs);

        Booking[] bookings            = BookingDB.GetToCheckOverlap_Recurring(startDateTime, endDateTime, startTime, endTime, days, staff, org, onlyThisOrg, true, incUnavailableBkgs, incCustomerBkgs);
        Booking[] overlappingBookings = Booking.GetOverlappingBookings(bookings, startDateTime, endDateTime, days, startTime, endTime, everyNWeeks, booking);
        Response.Write(GetLinks(overlappingBookings));
    }
Пример #18
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);
        }
    }
    protected void AddBooking()
    {
        //UrlReturnPage returnPage    = GetUrlReturnPage();
        bool?checkClashAllOrgs = UrlCheckClashAllOrgs;

        DateTime?    startDateTime = UrlStartDateTime;
        DateTime?    endDateTime   = UrlEndDateTime;
        int?         bookingTypeID = UrlBookingTypeID;
        Patient      patient       = UrlPatient;
        Organisation org           = UrlOrg;
        Staff        staff         = UrlStaff;
        Offering     offering      = UrlOffering;
        bool?        confirmed     = UrlIsConfirmed;

        if (startDateTime == null)
        {
            throw new Exception("Invalid url field start_datetime");
        }
        if (endDateTime == null)
        {
            throw new Exception("Invalid url field end_datetime");
        }
        if (bookingTypeID == null)
        {
            throw new Exception("Invalid url field booking_type_id");
        }
        if (org == null)
        {
            throw new Exception("Invalid url field org_id");
        }
        if (staff == null)
        {
            throw new Exception("Invalid url field staff_id");
        }
        if (confirmed == null)
        {
            throw new Exception("Invalid url field is_confirmed");
        }


        int      booking_confirmed_by_type_id = !confirmed.Value ? -1 : 1;
        int      confirmedBy   = !confirmed.Value ? -1                : GetStaffID();
        DateTime dateConfirmed = !confirmed.Value ? DateTime.MinValue : DateTime.Now;

        if (bookingTypeID.Value == 34)
        {
            // check booking is valid ie no overlapping with current bookings
            Booking[] bookings = BookingDB.GetToCheckOverlap_OneTime(startDateTime.Value, endDateTime.Value, staff, checkClashAllOrgs.Value ? null : org, bookingTypeID.Value == 342, true, false);
            if (Booking.HasOverlap(bookings, startDateTime.Value, endDateTime.Value))
            {
                string fromTime = startDateTime.Value.Hour.ToString().PadLeft(2, '0') + ":" + startDateTime.Value.Minute.ToString().PadLeft(2, '0');
                string toTime   = endDateTime.Value.Hour.ToString().PadLeft(2, '0') + ":" + endDateTime.Value.Minute.ToString().PadLeft(2, '0');
                throw new CustomMessageException("Can not book " + startDateTime.Value.ToString(@"ddd MMM d") + " " + fromTime + "-" + toTime + " due to overlap with existing booking");
            }


            // set prev for this pt/org inactive and put new one so that the most recent orgs for reg-pt items is the org with the most recent booking
            //if (!RegisterPatientDB.IsPatientRegisteredToOrg(patient.PatientID, org.OrganisationID))
            //    RegisterPatientDB.Insert(org.OrganisationID, patient.PatientID);
            if (patient != null && org != null)
            {
                RegisterPatientDB.UpdateInactive(patient.PatientID, org.OrganisationID, false);
                RegisterPatientDB.Insert(org.OrganisationID, patient.PatientID);
            }

            int newBookingID = BookingDB.Insert(startDateTime.Value, endDateTime.Value, org == null ? 0 : org.OrganisationID, staff == null ? 0 : staff.StaffID, patient == null ? -1 : patient.PatientID, offering == null ? -1 : offering.OfferingID,
                                                bookingTypeID.Value, 0, -1, GetStaffID(), booking_confirmed_by_type_id, confirmedBy, dateConfirmed, -1, DateTime.MinValue, -1, DateTime.MinValue, false, false, false, false, startDateTime.Value.DayOfWeek, TimeSpan.Zero, TimeSpan.Zero);

            Booking newBooking = BookingDB.GetByID(newBookingID);
            newBooking.SendReminderEmail();
        }
        else
        {
            // make sepertae booking for each day so that they can delete individual days
            int nDays = (int)endDateTime.Value.Subtract(startDateTime.Value).TotalHours / 24;
            for (int i = 0; i < nDays; i++)
            {
                // check if have booking for this day already
                Booking[] bookings = BookingDB.GetUnavailableDaysByStartEndDate(startDateTime.Value.AddDays(i), startDateTime.Value.AddDays(i + 1), staff, org);
                if (bookings.Length == 0)
                {
                    BookingDB.Insert(startDateTime.Value.AddDays(i), startDateTime.Value.AddDays(i).Date.AddHours(23).AddMinutes(59).AddSeconds(59), org == null ? 0 : org.OrganisationID, staff == null ? -1 : staff.StaffID, patient == null ? -1 : patient.PatientID, offering == null ? -1 : offering.OfferingID,
                                     bookingTypeID.Value, 0, -1, GetStaffID(), booking_confirmed_by_type_id, confirmedBy, dateConfirmed, -1, DateTime.MinValue, -1, DateTime.MinValue, false, false, false, false, startDateTime.Value.DayOfWeek, TimeSpan.Zero, TimeSpan.Zero);
                }
            }
        }
    }
    protected void CheckClashRecurringBooking()
    {
        string org_id          = Request.QueryString["org"];
        string staff_id        = Request.QueryString["staff"];
        string booking_id      = Request.QueryString["edit_booking_id"];
        string booking_type_id = Request.QueryString["booking_type_id"];

        string start_datetime = Request.QueryString["start_datetime"];
        string end_datetime   = Request.QueryString["end_datetime"];

        string days       = Request.QueryString["days"];
        string start_time = Request.QueryString["start_time"];
        string end_time   = Request.QueryString["end_time"];


        if (org_id == null || !Regex.IsMatch(org_id, @"^\-?\d+$") ||
            staff_id == null || !Regex.IsMatch(staff_id, @"^\-?\d+$") ||
            booking_id == null || !Regex.IsMatch(booking_id, @"^\-?\d+$") ||
            start_datetime == null || !Regex.IsMatch(start_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            end_datetime == null || (end_datetime != "NULL" && !Regex.IsMatch(end_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$")) ||
            days == null || !Regex.IsMatch(days, @"^\d{7}$") ||
            start_time == null || !Regex.IsMatch(start_time, @"^\d{4}$") ||
            end_time == null || !Regex.IsMatch(end_time, @"^\d{4}$"))
        {
            throw new CustomMessageException();
        }

        Organisation org     = OrganisationDB.GetByID(Convert.ToInt32(org_id));
        Staff        staff   = StaffDB.GetByID(Convert.ToInt32(staff_id));
        Booking      booking = booking_id == "-1" ? null : BookingDB.GetByID(Convert.ToInt32(booking_id));

        if (booking != null && booking_type_id == "-1")
        {
            booking_type_id = booking.BookingTypeID.ToString();
        }

        if ((org_id != "0" && org == null) ||
            (staff_id != "-1" && staff == null) ||
            (booking_id != "-1" && booking == null) ||
            (booking_type_id == null || (booking_type_id != "34" && booking_type_id != "340" && booking_type_id != "341" && booking_type_id != "342")))
        {
            throw new CustomMessageException();
        }

        DateTime startDateTime = ConvertStringToDateTime(start_datetime);
        DateTime endDateTime   = ConvertStringToDateTime(end_datetime);

        TimeSpan startTime = ConvertStringToTimeSpan(start_time);
        TimeSpan endTime   = ConvertStringToTimeSpan(end_time);

        if (endTime == new TimeSpan(23, 59, 0))
        {
            endTime = new TimeSpan(0, 23, 59, 59, 999);
        }

        //Response.Write("0"); return;
        Booking[] bookings = BookingDB.GetToCheckOverlap_Recurring(startDateTime, endDateTime, startTime, endTime, days, staff, org, booking_type_id == "342", true, false, true);
        Booking   clash    = Booking.HasOverlap(bookings, startDateTime, endDateTime, days, startTime, endTime, 1, booking);

        Response.Write(clash == null ? "0" : "1");
    }
Пример #21
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());
            }
        }
    }
    protected void CheckClashOneTimeBooking()
    {
        UserView userView = UserView.GetInstance();

        string org_id          = Request.QueryString["org"];
        string all_orgs        = Request.QueryString["all_orgs"];
        string staff_id        = Request.QueryString["staff"];
        string booking_id      = Request.QueryString["edit_booking_id"];
        string booking_type_id = Request.QueryString["booking_type_id"];

        string start_datetime = Request.QueryString["start_datetime"];
        string end_datetime   = Request.QueryString["end_datetime"];


        if (start_datetime == null || !Regex.IsMatch(start_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            end_datetime == null || !Regex.IsMatch(end_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            org_id == null || !Regex.IsMatch(org_id, @"^\-?\d+$") ||
            staff_id == null || !Regex.IsMatch(staff_id, @"^\-?\d+$") ||
            booking_id == null || !Regex.IsMatch(booking_id, @"^\-?\d+$"))
        {
            throw new CustomMessageException();
        }

        Organisation org     = OrganisationDB.GetByID(Convert.ToInt32(org_id));
        Staff        staff   = StaffDB.GetByID(Convert.ToInt32(staff_id));
        Booking      booking = booking_id == "-1" ? null : BookingDB.GetByID(Convert.ToInt32(booking_id));

        if (booking != null && booking_type_id == "-1")
        {
            booking_type_id = booking.BookingTypeID.ToString();
        }

        if ((org_id != "0" && org == null) ||
            (staff_id != "-1" && staff == null) ||
            (booking_id != "-1" && booking == null) ||
            (booking_type_id == null || (booking_type_id != "34" && booking_type_id != "340" && booking_type_id != "341" && booking_type_id != "342")))
        {
            throw new CustomMessageException();
        }

        DateTime startDateTime = ConvertStringToDateTime(start_datetime);
        DateTime endDateTime   = ConvertStringToDateTime(end_datetime);

        // if pt logged in, disallow booking over unavailabilities, otherwise allow it and ignore the check
        bool checkUnavailableDays = userView.IsPatient;

        Booking[] bookings = (all_orgs != null && all_orgs == "1") ?
                             BookingDB.GetToCheckOverlap_OneTime(startDateTime, endDateTime, staff, null, booking_type_id == "342", true, checkUnavailableDays) :
                             BookingDB.GetToCheckOverlap_OneTime(startDateTime, endDateTime, staff, org, booking_type_id == "342", true, checkUnavailableDays);

        if (bookings.Length > 0)
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            for (int i = 0; i < bookings.Length; i++)
            {
                if ((bookings[i].Organisation == null || (org != null && bookings[i].Organisation.OrganisationID == org.OrganisationID)) &&
                    (bookings[i].Provider == null || bookings[i].Provider.StaffID == staff.StaffID))
                {
                    list.Add(bookings[i]);
                }
            }
            bookings = (Booking[])list.ToArray(typeof(Booking));
        }

        // for patient, disallow booking over start/end times when clinic unavailable
        if (userView.IsPatient)
        {
            if (org == null)
            {
                org = booking.Organisation;
            }
            StartEndTime startEndTime      = org.GetStartEndTime(startDateTime.DayOfWeek);
            StartEndTime startEndLunchTime = org.GetStartEndLunchTime(startDateTime.DayOfWeek);
            if ((startEndTime.StartTime < startEndTime.EndTime && startDateTime.TimeOfDay < endDateTime.TimeOfDay && !(startDateTime.TimeOfDay >= startEndTime.StartTime && endDateTime.TimeOfDay <= startEndTime.EndTime)) ||
                (startEndLunchTime.StartTime < startEndLunchTime.EndTime && startDateTime.TimeOfDay < endDateTime.TimeOfDay && Booking.TimeIntersects(startEndLunchTime.StartTime, startEndLunchTime.EndTime, startDateTime.TimeOfDay, endDateTime.TimeOfDay)))
            {
                Response.Write("1");
                return;
            }
        }


        Response.Write(Booking.HasOverlap(bookings, startDateTime, endDateTime, booking) ? "1" : "0");
    }
Пример #23
0
    protected void btnEmailToFac_Click(object sender, EventArgs e)
    {
        Booking booking = BookingDB.GetByID(GetFormBooking());

        string[] emails = ContactDB.GetEmailsByEntityID(booking.Organisation.EntityID);

        if (emails.Length == 0)
        {
            SetErrorMessage("No email address set for '" + booking.Organisation.Name + "'. Please set one to email treatment list to them.");
            return;
        }
        else
        {
            string tmpLettersDirectory = FileHelper.GetTempDirectoryName(Letter.GetTempLettersDirectory());
            Directory.CreateDirectory(tmpLettersDirectory);

            string originalFile  = Letter.GetLettersDirectory() + @"ACTreatmentList.docx";
            string tmpOutputFile = tmpLettersDirectory + "TreatmentList.pdf";

            if (!File.Exists(originalFile))
            {
                SetErrorMessage("Template File 'ACTreatmentList.docx' does not exist.");
                return;
            }

            MergeFile(true, originalFile, tmpOutputFile);

            try
            {
                EmailerNew.SimpleEmail(
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    (Utilities.IsDev() ? "*****@*****.**" : string.Join(",", emails)),
                    "Treatement List",
                    "Pease find the <u>Residents Treated List</u> for " + booking.DateStart.ToString("d MMM, yyyy") + " at " + booking.Organisation.Name + "<br /><br />Regards,<br />" + ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    true,
                    new string[] { tmpOutputFile },
                    false,
                    null
                    );

                SetErrorMessage("Emailed to &nbsp;&nbsp;" + booking.Organisation.Name + " (" + string.Join(", ", emails) + ")");
            }
            catch (CustomMessageException cmEx)
            {
                SetErrorMessage(cmEx.Message);
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
            finally
            {
                try { if (System.IO.File.Exists(tmpOutputFile))
                      {
                          System.IO.File.Delete(tmpOutputFile);
                      }
                }
                catch (Exception) { }

                // delete temp dir
                if (tmpLettersDirectory != null)
                {
                    try { System.IO.Directory.Delete(tmpLettersDirectory, true); }
                    catch (Exception) { }
                }
            }
        }
    }
Пример #24
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 type = Request.QueryString["type"];
            if (type == null)
            {
                throw new CustomMessageException("No type in url");
            }
            if (type != "booking" && type != "patient")
            {
                throw new CustomMessageException("Parameter 'type' unknown: " + type);
            }

            string inc_completed = Request.QueryString["inc_completed"];
            if (inc_completed == null)
            {
                throw new CustomMessageException("No inc_completed in url");
            }
            if (inc_completed != "1" && inc_completed != "0")
            {
                throw new CustomMessageException("Parameter 'inc_completed' unknown: " + inc_completed);
            }


            Patient patient = null;

            if (type == "booking")
            {
                string booking_id = Request.QueryString["booking_id"];
                if (booking_id == null)
                {
                    throw new CustomMessageException("No booking_id in url");
                }
                if (!Regex.IsMatch(booking_id, @"^\d+$"))
                {
                    throw new CustomMessageException("Booking id is not a number");
                }
                Booking booking = BookingDB.GetByID(Convert.ToInt32(booking_id));
                if (booking == null)
                {
                    throw new CustomMessageException("Booking id does not exist");
                }

                if (booking.Organisation.OrganisationType.OrganisationTypeID != 218) // aged care - doesn't need to check this
                {
                    Response.Write("1");
                    return;
                }

                patient = booking.Patient;
                if (patient == null)
                {
                    throw new CustomMessageException("No patient set for booking ");
                }
            }
            else if (type == "patient")
            {
                string patient_id = Request.QueryString["patient_id"];
                if (patient_id == null)
                {
                    throw new CustomMessageException("No patient_id in url");
                }
                if (!Regex.IsMatch(patient_id, @"^\d+$"))
                {
                    throw new CustomMessageException("Patient id is not a number");
                }
                patient = PatientDB.GetByID(Convert.ToInt32(patient_id));
                if (patient == null)
                {
                    throw new CustomMessageException("Patient ID does not exist");
                }
            }


            Booking nextBooking = BookingDB.GetNextAfterToday(patient.PatientID, inc_completed == "1");

            Response.Write(nextBooking == null ? "0" : "1");
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write("Exception: " + (Utilities.IsDev() ? ex.ToString() : "Error - please contact system administrator."));
        }
    }