Ejemplo n.º 1
0
    protected DataTable GetPatientDataTable(int staff_id)
    {
        Staff staff = StaffDB.GetByID(staff_id);

        Hashtable staffHashOriginal = StaffDB.GetAllInHashtable(true, true, true, false);
        Hashtable staffHash         = new Hashtable();

        foreach (Staff s in staffHashOriginal.Values)
        {
            staffHash[s.Person.PersonID] = s;
        }

        DataTable tbl = PatientDB.GetPatientsAddedByStaff(staff_id, GetFromDate(), GetToDate());


        // sort by most common referrer
        tbl.Columns.Add("referrer_count", typeof(int));
        tbl.Columns.Add("added_by_name", typeof(String));
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            int refCount = 0;
            if (tbl.Rows[i]["referrer_info_referrer_id"] != DBNull.Value)
            {
                for (int j = 0; j < tbl.Rows.Count; j++)
                {
                    if (tbl.Rows[j]["referrer_info_referrer_id"] != DBNull.Value && Convert.ToInt32(tbl.Rows[j]["referrer_info_referrer_id"]) == Convert.ToInt32(tbl.Rows[i]["referrer_info_referrer_id"]))
                    {
                        refCount++;
                    }
                }
            }

            tbl.Rows[i]["referrer_count"] = refCount;
            tbl.Rows[i]["added_by_name"]  = staff.Person.FullnameWithoutMiddlename;
        }
        tbl.DefaultView.Sort = "referrer_count DESC, referrer_info_surname, referrer_info_firstname, surname, firstname, middlename";
        tbl = tbl.DefaultView.ToTable();

        return(tbl);
    }
    protected DataTable SetBookingsList(Staff staff = null)
    {
        if (txtStartDate.Text.Length > 0 && !Utilities.IsValidDate(txtStartDate.Text, "dd-mm-yyyy"))
        {
            SetErrorMessage("Start date must be empty or valid and of the format dd-mm-yyyy");
            return(null);
        }
        if (txtEndDate.Text.Length > 0 && !Utilities.IsValidDate(txtEndDate.Text, "dd-mm-yyyy"))
        {
            SetErrorMessage("End date must be empty or valid and of the format dd-mm-yyyy");
            return(null);
        }
        DateTime startDate = txtStartDate.Text.Length == 0 ? DateTime.MinValue : Utilities.GetDate(txtStartDate.Text, "dd-mm-yyyy");
        DateTime endDate   = txtEndDate.Text.Length == 0 ? DateTime.MinValue : Utilities.GetDate(txtEndDate.Text, "dd-mm-yyyy");

        UserView userView        = UserView.GetInstance();
        int      loggedInStaffID = Session["StaffID"] == null ? -1 : Convert.ToInt32(Session["StaffID"]);

        if (staff == null)
        {
            staff = StaffDB.GetByID(GetFormID());
        }



        DataTable tblBookingList = BookingDB.GetDataTable_Between(startDate, endDate, null, null, null, staff, true);

        int[] booking_ids = new int[tblBookingList.Rows.Count];
        for (int i = 0; i < tblBookingList.Rows.Count; i++)
        {
            booking_ids[i] = Convert.ToInt32(tblBookingList.Rows[i]["booking_booking_id"]);
        }
        Hashtable changeHistoryHash = BookingDB.GetChangeHistoryCountHash(booking_ids);

        lblBookingListCount.Text = "(" + tblBookingList.Rows.Count + ")";
        if (tblBookingList.Rows.Count == 0)
        {
            lblBookingsList_NoRowsMessage.Visible = true;
            pnlBookingsList.Visible = false;
        }
        else
        {
            lblBookingsList_NoRowsMessage.Visible = false;
            pnlBookingsList.Visible = true;


            System.Collections.Hashtable staffHash            = StaffDB.GetAllInHashtable(true, true, true, false);
            System.Collections.ArrayList bookingsWithInvoices = new System.Collections.ArrayList();


            tblBookingList.Columns.Add("notes_text", typeof(string));
            tblBookingList.Columns.Add("invoice_text", typeof(string));
            tblBookingList.Columns.Add("booking_url", typeof(string));
            tblBookingList.Columns.Add("hide_booking_link", typeof(Boolean));
            tblBookingList.Columns.Add("show_invoice_row", typeof(int));
            tblBookingList.Columns.Add("show_notes_row", typeof(int));
            tblBookingList.Columns.Add("show_printletter_row", typeof(int));
            tblBookingList.Columns.Add("show_bookingsheet_row", typeof(int));
            tblBookingList.Columns.Add("inv_type_text", typeof(string));
            tblBookingList.Columns.Add("inv_outstanding_text", typeof(string));
            tblBookingList.Columns.Add("added_by_deleted_by_row", typeof(string));
            tblBookingList.Columns.Add("booking_change_history_link", typeof(string));
            tblBookingList.Columns.Add("hide_change_history_link", typeof(Boolean));
            tblBookingList.Columns.Add("show_change_history_row", typeof(string));
            bool hasInvoiceRows      = false;
            bool hasNotesRows        = false;
            bool hasPrintLetterRows  = false;
            bool hasBookingSheetRows = false;
            for (int i = 0; i < tblBookingList.Rows.Count; i++)
            {
                Booking curBooking = BookingDB.LoadFull(tblBookingList.Rows[i]);

                tblBookingList.Rows[i]["notes_text"] = Note.GetPopupLinkTextV2(15, curBooking.EntityID, curBooking.NoteCount > 0, true, 1050, 530, "images/notes-bw-24.jpg", "images/notes-24.png", "btnUpdateBookingList.click()");

                bool canSeeInvoiceInfo = userView.IsAdminView || userView.IsPrincipal || (curBooking.Provider != null && curBooking.Provider.StaffID == loggedInStaffID && curBooking.DateStart > DateTime.Today.AddMonths(-2));
                if (canSeeInvoiceInfo && Convert.ToInt32(tblBookingList.Rows[i]["booking_inv_count"]) > 0)
                {
                    string onclick = @"onclick=""javascript:window.showModalDialog('Invoice_ViewV2.aspx?booking_id=" + curBooking.BookingID + @"', '', 'dialogWidth:820px;dialogHeight:860px;center:yes;resizable:no; scroll:no');return false;""";
                    tblBookingList.Rows[i]["invoice_text"] = "<a " + onclick + " href=\"\">View Inv.</a>";

                    if (curBooking.DateDeleted == DateTime.MinValue && curBooking.DeletedBy == null)
                    {
                        hasInvoiceRows = true;
                    }

                    bookingsWithInvoices.Add(curBooking.BookingID);
                }
                else
                {
                    tblBookingList.Rows[i]["invoice_text"] = "";
                }

                tblBookingList.Rows[i]["hide_booking_link"] = !((userView.IsClinicView && curBooking.Organisation.OrganisationType.OrganisationTypeID == 218) ||
                                                                (userView.IsAgedCareView && (new List <int> {
                    139, 367, 372
                }).Contains(curBooking.Organisation.OrganisationType.OrganisationTypeID)));

                if (curBooking.DateDeleted == DateTime.MinValue && curBooking.DeletedBy == null)
                {
                    hasNotesRows       = true;
                    hasPrintLetterRows = true;
                    if (!Convert.ToBoolean(tblBookingList.Rows[i]["hide_booking_link"]))
                    {
                        hasBookingSheetRows = true;
                    }
                }

                string urlParams = string.Empty;
                if (curBooking.Organisation != null)
                {
                    urlParams += (urlParams.Length == 0 ? "?" : "&") + "orgs=" + curBooking.Organisation.OrganisationID;
                }
                if (curBooking.Patient != null)
                {
                    urlParams += (urlParams.Length == 0 ? "?" : "&") + "patient=" + curBooking.Patient.PatientID;
                }
                urlParams += (urlParams.Length == 0 ? "?" : "&") + "scroll_to_cell=" + "td_" + (curBooking.Organisation != null ? "" : curBooking.Organisation.OrganisationID.ToString()) + "_" + curBooking.Provider.StaffID + "_" + curBooking.DateStart.ToString("yyyy_MM_dd_HHmm");
                urlParams += (urlParams.Length == 0 ? "?" : "&") + "date=" + curBooking.DateStart.ToString("yyyy_MM_dd");
                tblBookingList.Rows[i]["booking_url"] = curBooking.GetBookingSheetLinkV2();



                string addedBy                 = curBooking.AddedBy == null || staffHash[curBooking.AddedBy.StaffID] == null ? "" : (((Staff)staffHash[curBooking.AddedBy.StaffID]).IsExternal ? "[External Staff] " : "") + ((Staff)staffHash[curBooking.AddedBy.StaffID]).Person.FullnameWithoutMiddlename;
                string addedDate               = curBooking.DateCreated == DateTime.MinValue                                       ? "" : curBooking.DateCreated.ToString("MMM d, yyyy");
                string deletedBy               = curBooking.DeletedBy == null || staffHash[curBooking.DeletedBy.StaffID] == null ? "" : ((Staff)staffHash[curBooking.DeletedBy.StaffID]).Person.FullnameWithoutMiddlename;
                string deletedDate             = curBooking.DateDeleted == DateTime.MinValue                                       ? "" : curBooking.DateDeleted.ToString("MMM d, yyyy");
                string added_by_deleted_by_row = string.Empty;
                added_by_deleted_by_row += "Added By: " + addedBy + " (" + addedDate + ")";
                if (deletedBy.Length > 0 || deletedDate.Length > 0)
                {
                    added_by_deleted_by_row += "\r\nDeleted By: " + deletedBy + " (" + deletedDate + ")";
                }
                tblBookingList.Rows[i]["added_by_deleted_by_row"] = added_by_deleted_by_row;

                tblBookingList.Rows[i]["booking_change_history_link"] = curBooking.GetBookingChangeHistoryPopupLinkImage();
                tblBookingList.Rows[i]["hide_change_history_link"]    = changeHistoryHash[curBooking.BookingID] == null;
            }

            System.Collections.Hashtable hashHasMedicareOrDVAInvoices = BookingDB.GetHashHasMedicareDVA((int[])bookingsWithInvoices.ToArray(typeof(int)));

            for (int i = 0; i < tblBookingList.Rows.Count; i++)
            {
                tblBookingList.Rows[i]["show_invoice_row"]        = hasInvoiceRows              ? 1 : 0;
                tblBookingList.Rows[i]["show_notes_row"]          = hasNotesRows                ? 1 : 0;
                tblBookingList.Rows[i]["show_printletter_row"]    = hasPrintLetterRows          ? 1 : 0;
                tblBookingList.Rows[i]["show_bookingsheet_row"]   = hasBookingSheetRows         ? 1 : 0;
                tblBookingList.Rows[i]["show_change_history_row"] = changeHistoryHash.Count > 0 ? 1 : 0;

                int  booking_id   = Convert.ToInt32(tblBookingList.Rows[i]["booking_booking_id"]);
                bool has_medicare = hashHasMedicareOrDVAInvoices[new Hashtable2D.Key(booking_id, -1)] != null && Convert.ToBoolean(hashHasMedicareOrDVAInvoices[new Hashtable2D.Key(booking_id, -1)]);
                bool has_dva      = hashHasMedicareOrDVAInvoices[new Hashtable2D.Key(booking_id, -2)] != null && Convert.ToBoolean(hashHasMedicareOrDVAInvoices[new Hashtable2D.Key(booking_id, -2)]);
                if (has_medicare)
                {
                    tblBookingList.Rows[i]["inv_type_text"] = "Medicare";
                }
                else if (has_dva)
                {
                    tblBookingList.Rows[i]["inv_type_text"] = "DVA";
                }
                else
                {
                    tblBookingList.Rows[i]["inv_type_text"] = string.Empty;
                }
            }
            tblBookingList.DefaultView.Sort = "booking_date_start DESC";
            tblBookingList            = tblBookingList.DefaultView.ToTable();
            lstBookingList.DataSource = tblBookingList;
            lstBookingList.DataBind();
        }

        return(tblBookingList);
    }
Ejemplo n.º 3
0
    protected DataTable GetPatientDataTable(int organisation_id)
    {
        Organisation org = OrganisationDB.GetByID(organisation_id);

        Hashtable staffHashOriginal = StaffDB.GetAllInHashtable(true, true, true, false);
        Hashtable staffHash         = new Hashtable();

        foreach (Staff s in staffHashOriginal.Values)
        {
            staffHash[s.Person.PersonID] = s;
        }

        DataTable tbl = RegisterPatientDB.GetPatientsAddedByOrg(organisation_id, GetFromDate(), GetToDate());

        tbl.Columns.Add("organisation_name");
        tbl.Columns.Add("organisation_id");
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            tbl.Rows[i]["organisation_name"] = org.Name;
            tbl.Rows[i]["organisation_id"]   = org.OrganisationID;
        }

        // sort by most common referrer
        tbl.Columns.Add("referrer_count", typeof(int));
        tbl.Columns.Add("added_by_count", typeof(int));
        tbl.Columns.Add("added_by", typeof(String));
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            int refCount = 0;
            if (tbl.Rows[i]["referrer_info_referrer_id"] != DBNull.Value)
            {
                for (int j = 0; j < tbl.Rows.Count; j++)
                {
                    if (tbl.Rows[j]["referrer_info_referrer_id"] != DBNull.Value && Convert.ToInt32(tbl.Rows[j]["referrer_info_referrer_id"]) == Convert.ToInt32(tbl.Rows[i]["referrer_info_referrer_id"]))
                    {
                        refCount++;
                    }
                }
            }

            tbl.Rows[i]["referrer_count"] = refCount;

            int addedByCount = 0;
            if (tbl.Rows[i]["patient_person_added_by"] != DBNull.Value)
            {
                for (int j = 0; j < tbl.Rows.Count; j++)
                {
                    if (tbl.Rows[j]["patient_person_added_by"] != DBNull.Value && Convert.ToInt32(tbl.Rows[j]["patient_person_added_by"]) == Convert.ToInt32(tbl.Rows[i]["patient_person_added_by"]))
                    {
                        addedByCount++;
                    }
                }
            }

            tbl.Rows[i]["added_by_count"] = addedByCount;


            if (tbl.Rows[i]["patient_person_added_by"] != DBNull.Value)
            {
                int    staffID = Convert.ToInt32(tbl.Rows[i]["patient_person_added_by"]);
                Staff  s1      = (Staff)staffHash[staffID];
                string s2      = s1.Person.FullnameWithoutMiddlename;
            }


            tbl.Rows[i]["added_by"] = tbl.Rows[i]["patient_person_added_by"] == DBNull.Value ? (object)DBNull.Value : ((Staff)staffHash[Convert.ToInt32(tbl.Rows[i]["patient_person_added_by"])]).Person.FullnameWithoutMiddlename;
        }
        tbl.DefaultView.Sort = "referrer_count DESC, referrer_info_surname, referrer_info_firstname, patient_person_surname, patient_person_firstname, patient_person_middlename";
        tbl = tbl.DefaultView.ToTable();

        return(tbl);
    }
    protected void FillGrid()
    {
        int       bulk_letter_sending_queue_batch_id = IsValidFormBatchID() ? GetFormBatchID() : -1;
        DataTable dt = BulkLetterSendingQueueDB.GetDataTable(bulk_letter_sending_queue_batch_id);


        // send method hashtable
        DataTable sendMethodTbl  = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "LetterPrintHistorySendMethod", "", "", "letter_print_history_send_method_id", "descr");
        Hashtable sendMethodHash = new Hashtable();

        for (int i = 0; i < sendMethodTbl.Rows.Count; i++)
        {
            sendMethodHash[Convert.ToInt32(sendMethodTbl.Rows[i]["letter_print_history_send_method_id"])] = (string)sendMethodTbl.Rows[i]["descr"];
        }

        // patient hashtable
        ArrayList ptIDs = new ArrayList();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["patient_id"] != DBNull.Value)
            {
                ptIDs.Add((int)dt.Rows[i]["patient_id"]);
            }
        }
        Hashtable patientHash = PatientDB.GetByIDsInHashtable((int[])ptIDs.ToArray(typeof(int)));

        // staff hashtable
        Hashtable staffHash = StaffDB.GetAllInHashtable(true, true, true, false);

        // referrersHash
        Hashtable referrersHash = ReferrerDB.GetHashtableByReferrer();

        // letters hashtable
        Hashtable letterHash = LetterDB.GetHashTable();


        // add from hashtable
        dt.Columns.Add("letter_print_history_send_method_descr", typeof(String));
        dt.Columns.Add("added_by_name", typeof(String));
        dt.Columns.Add("patient_name", typeof(String));
        dt.Columns.Add("referrer_name", typeof(String));
        dt.Columns.Add("letter_doc_name", typeof(String));

        int SMSSent     = 0;
        int SMSUnSent   = 0;
        int EmailSent   = 0;
        int EmailUnSent = 0;
        int PrintSent   = 0;
        int PrintUnSent = 0;

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int  letter_print_history_send_method_id = Convert.ToInt32(dt.Rows[i]["letter_print_history_send_method_id"]);
            bool sent = dt.Rows[i]["datetime_sent"] != DBNull.Value;

            dt.Rows[i]["letter_print_history_send_method_descr"] = (string)sendMethodHash[letter_print_history_send_method_id];
            dt.Rows[i]["added_by_name"] = dt.Rows[i]["added_by"] == DBNull.Value ? "" : ((Staff)staffHash[Convert.ToInt32(dt.Rows[i]["added_by"])]).Person.FullnameWithoutMiddlename;
            dt.Rows[i]["patient_name"]  = dt.Rows[i]["patient_id"] == DBNull.Value ? "" : ((Patient)patientHash[Convert.ToInt32(dt.Rows[i]["patient_id"])]).Person.FullnameWithoutMiddlename;

            dt.Rows[i]["referrer_name"] = dt.Rows[i]["referrer_id"] == DBNull.Value ? "" : ((Referrer)referrersHash[Convert.ToInt32(dt.Rows[i]["referrer_id"])]).Person.FullnameWithoutMiddlename;

            string source_template_path = dt.Rows[i]["email_letter_source_template_path"].ToString();
            string letter_doc_name      = source_template_path.Length == 0 ? "" : System.IO.Path.GetFileName(source_template_path);
            dt.Rows[i]["letter_doc_name"] = letter_doc_name;

            if (letter_print_history_send_method_id == 3 && sent)
            {
                SMSSent++;
            }
            if (letter_print_history_send_method_id == 3 && !sent)
            {
                SMSUnSent++;
            }
            if (letter_print_history_send_method_id == 2 && sent)
            {
                EmailSent++;
            }
            if (letter_print_history_send_method_id == 2 && !sent)
            {
                EmailUnSent++;
            }
            if (letter_print_history_send_method_id == 1 && sent)
            {
                PrintSent++;
            }
            if (letter_print_history_send_method_id == 1 && !sent)
            {
                PrintUnSent++;
            }
        }

        lblSMSSent.Text     = SMSSent.ToString();
        lblSMSUnSent.Text   = SMSUnSent.ToString();
        lblEmailSent.Text   = EmailSent.ToString();
        lblEmailUnSent.Text = EmailUnSent.ToString();
        lblPrintSent.Text   = PrintSent.ToString();
        lblPrintUnSent.Text = PrintUnSent.ToString();
        lblTotalSent.Text   = (SMSSent + EmailSent + PrintSent).ToString();
        lblTotalUnSent.Text = (SMSUnSent + EmailUnSent + PrintUnSent).ToString();


        DataView dv = new DataView(dt);

        dv.Sort = "letter_print_history_send_method_id";
        dt      = dv.ToTable();


        Session["lettersprintbatchstatus_data"] = dt;

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

            GrdBulkLetterSendingQueue.AllowPaging = false;

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

            int TotalColumns = GrdBulkLetterSendingQueue.Rows[0].Cells.Count;
            GrdBulkLetterSendingQueue.Rows[0].Cells.Clear();
            GrdBulkLetterSendingQueue.Rows[0].Cells.Add(new TableCell());
            GrdBulkLetterSendingQueue.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdBulkLetterSendingQueue.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Ejemplo n.º 5
0
    public void CreateXML(Invoice[] invoices, bool validate = true)
    {
        if (validate)
        {
            Invoice[] tooOldList = GetInvoicesTooOldToClaim(invoices);
            if (tooOldList.Length > 0)
            {
                string invalids = string.Empty;
                foreach (Invoice i in tooOldList)
                {
                    invalids += (invalids.Length == 0 ? "" : ",") + i.InvoiceID.ToString();
                }
                throw new Exception("The following invoices are too old to claim: " + "<br />" + invalids);
            }
        }

        // get bulk invoice lines for less db calls in individual invoice create xml method  [invoiceID => list of invoicelines]
        Hashtable bulkInvoiceLineHash = InvoiceLineDB.GetBulkInvoiceLinesByInvoiceID(invoices);

        ArrayList allInvoiceLines = new ArrayList();

        foreach (DictionaryEntry pair in bulkInvoiceLineHash)
        {
            allInvoiceLines.AddRange((InvoiceLine[])pair.Value);
        }

        // get bluk health cards  [patientID=>healthcard]
        //
        // NB:
        // A DVA invoice can only use a DVA card
        // A Medicare invoice can only use a Medicare card
        // The system can only create a DVA invoice is if DVA is set as the active card (vice versa for Medicare)
        // So when a DVA invoice is created the DVA card was active, and then someone switches it to be the Medicare card thatis active.
        // So, it's correct to get only the DVA cards for DVA invoices (and Medicare cards for Medicare invoices), and also would be correct to ignore the active flag and just get the most recent.
        int[]     allPatientIDs      = GetAllPatientIDs((InvoiceLine[])allInvoiceLines.ToArray(typeof(InvoiceLine)));
        Hashtable bulkHealthCardHash = PatientsHealthCardsCacheDB.GetBullkMostRecent(allPatientIDs, claimType == ClaimType.Medicare ? -1 : -2);

        // get bluk staff provider numbers from registerstaff table
        int[]     allProviderStaffIDs   = GetAllProviderStaffIDs(invoices);
        Hashtable bulkRegisterStaffHash = RegisterStaffDB.Get2DHashByStaffIDOrgID(allProviderStaffIDs);
        Hashtable bulkStaffHash         = StaffDB.GetAllInHashtable(false, true, false, false);

        // get bluk healthcard actions to get EPC signed dates
        Hashtable bulkHealthCardActionsHash = HealthCardActionDB.GetReceivedActionsByPatientIDs(allPatientIDs);

        // get bluk epcreferrers
        Hashtable bulkEPCReferrersHash = PatientReferrerDB.GetEPCReferrersOf(allPatientIDs, false);

        // get all sites in one call
        Hashtable bulkSites = SiteDB.GetAllInHashtable();


        Hashtable claimNumberInvoiceGroups = new Hashtable();

        for (int i = 0; i < invoices.Length; i++)
        {
            if (claimNumberInvoiceGroups[(invoices[i]).HealthcareClaimNumber] == null)
            {
                claimNumberInvoiceGroups[(invoices[i]).HealthcareClaimNumber] = new ArrayList();
            }

            ((ArrayList)claimNumberInvoiceGroups[(invoices[i]).HealthcareClaimNumber]).Add(invoices[i]);
        }


        string noPatientFailures    = string.Empty;
        string noHealthcardFailures = string.Empty;

        foreach (string claimNbr in claimNumberInvoiceGroups.Keys)
        {
            Invoice[] invoiceList = (Invoice[])((ArrayList)claimNumberInvoiceGroups[claimNbr]).ToArray(typeof(Invoice));

            try
            {
                CreateXML(invoiceList, bulkInvoiceLineHash, bulkHealthCardHash, bulkRegisterStaffHash, bulkStaffHash, bulkSites, bulkHealthCardActionsHash, bulkEPCReferrersHash);
            }
            catch (HINXNoPatientOnInvoiceLineException ex)
            {
                noPatientFailures += (noPatientFailures.Length == 0 ? "" : "<br />") + ex.Message;
            }
            catch (HINXNoHealthcardException ex)
            {
                noHealthcardFailures += (noHealthcardFailures.Length == 0 ? "" : "<br />") + ex.Message;
            }
        }



        string errors = string.Empty;

        if (noPatientFailures.Length > 0)
        {
            errors += (errors.Length == 0 ? "" : "<br /><br />") + "The following invoices have invoices lines with no patient set (Fix this and re-generate): <br />" + noPatientFailures;
        }
        if (noHealthcardFailures.Length > 0)
        {
            errors += (errors.Length == 0 ? "" : "<br /><br />") + "The following invoices have patients with no " + (claimType == ClaimType.Medicare ? "Medicare" : "DVA") + " card set (Fix this and re-generate): <br />" + noHealthcardFailures;
        }
        if (errors.Length > 0)
        {
            throw new HINXUnsuccessfulItemsException(errors);
        }
    }