Ejemplo n.º 1
0
    protected void btnGenerateSystemLetters_Click(object sender, EventArgs e)
    {
        System.Collections.ArrayList fileContentsList = new System.Collections.ArrayList();

        Booking[] bookings = BookingDB.GetBookingsToGenerateSystemLetters(DateTime.MinValue, DateTime.MinValue, GetFormID());
        for (int i = 0; i < bookings.Length; i++)
        {
            // send referrer letters

            PatientReferrer[] patientReferrers = PatientReferrerDB.GetActiveEPCPatientReferrersOf(bookings[i].Patient.PatientID);
            if (patientReferrers.Length > 0)
            {
                HealthCard hc = HealthCardDB.GetActiveByPatientID(bookings[i].Patient.PatientID);
                bool       needToGenerateTreatmentLetter = patientReferrers[patientReferrers.Length - 1].RegisterReferrer.ReportEveryVisitToReferrer;

                Letter.FileContents[] bookingFileContentsList = bookings[i].GetSystemLettersList(Letter.FileFormat.Word, bookings[i].Patient, hc, bookings[i].Offering.Field.ID, patientReferrers[patientReferrers.Length - 1].RegisterReferrer.Referrer, true, bookings[i].NeedToGenerateFirstLetter, bookings[i].NeedToGenerateLastLetter, needToGenerateTreatmentLetter, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), 1);
                fileContentsList.AddRange(bookingFileContentsList);
                BookingDB.UpdateSetGeneratedSystemLetters(bookings[i].BookingID, bookings[i].NeedToGenerateFirstLetter, bookings[i].NeedToGenerateLastLetter, true);
            }
        }

        Letter.FileContents mergedFileContents = Letter.FileContents.Merge((Letter.FileContents[])fileContentsList.ToArray(typeof(Letter.FileContents)), "Treatment Letters.doc"); // .pdf
        if (mergedFileContents != null)
        {
            Session["downloadFile_Contents"] = mergedFileContents.Contents;
            Session["downloadFile_DocName"]  = mergedFileContents.DocName;
            Page.ClientScript.RegisterStartupScript(this.GetType(), "download", "<script language=javascript>window.open('DownloadFile.aspx','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=30,height=30');</script>");
        }

        UpdateGenerateSystemLetters();
    }
Ejemplo n.º 2
0
    protected void Add(int offeringID)
    {
        string areaTreated = string.Empty;

        if (InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance)
        {
            areaTreated = HealthCardDB.GetActiveByPatientID(Booking.Patient.PatientID).AreaTreated;
        }


        int index = -1;

        for (int i = 0; i < GrdOffering.Rows.Count; i++)
        {
            Label lbl = (Label)GrdOffering.Rows[i].FindControl("lblId");
            if (lbl != null && lbl.Text == offeringID.ToString())
            {
                index = i;
            }
        }

        if (index == -1)
        {
            return;
        }



        Label lblId           = (Label)GrdOffering.Rows[index].FindControl("lblId");
        Label lblShortName    = (Label)GrdOffering.Rows[index].FindControl("lblShortName");
        Label lblDefaultPrice = (Label)GrdOffering.Rows[index].FindControl("lblDefaultPrice");


        // see about medicare and dva code ...
        DataTable dt_offering = Session["data_offering"] as DataTable;

        DataRow[] foundRows = dt_offering.Select("o_offering_id=" + lblId.Text);
        DataRow   thisRow   = foundRows[0];

        string medicare_company_code = thisRow["o_medicare_company_code"].ToString();
        string dva_company_code      = thisRow["o_dva_company_code"].ToString();
        string tac_company_code      = thisRow["o_tac_company_code"].ToString();
        bool   hcPaid = (this.InvoiceType == Booking.InvoiceType.DVA && dva_company_code.Length > 0) || (this.InvoiceType == Booking.InvoiceType.Insurance && tac_company_code.Length > 0);


        DataTable dt_selected_list = GetSelectedList();

        foreach (DataRow curRow in dt_selected_list.Rows)
        {
            if (curRow["offering_id"].ToString() == lblId.Text)
            {
                return;
            }
        }

        DataRow row = dt_selected_list.NewRow();

        row["offering_id"]            = lblId.Text;
        row["hc_paid"]                = hcPaid;
        row["short_name"]             = lblShortName.Text;
        row["name"]                   = thisRow["o_name"].ToString();
        row["area_treated"]           = areaTreated;
        row["service_reference"]      = string.Empty;
        row["show_area_treated"]      = InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance;
        row["show_service_reference"] = InvoiceType == Booking.InvoiceType.Insurance;
        row["default_price"]          = thisRow["o_default_price"];
        row["pt_price"]               = thisRow["pt_price"];          // added
        row["hc_price"]               = thisRow["hc_price"];          // added
        row["pt_gst"]                 = thisRow["pt_gst"];            // added
        row["hc_gst"]                 = thisRow["hc_gst"];            // added
        row["quantity"]               = "1";
        row["total_line_price"]       = thisRow["o_default_price"];
        row["total_pt_price"]         = thisRow["pt_price"];          // added
        row["total_pt_gst"]           = thisRow["pt_gst"];            // added
        row["total_hc_price"]         = thisRow["hc_price"];          // added
        row["total_hc_gst"]           = thisRow["hc_gst"];            // added
        row["on_order"]               = false;

        dt_selected_list.Rows.Add(row);

        Session["data_selected"] = dt_selected_list;
        UpdateTotal(dt_selected_list);

        FillSelectedGrid();
    }
Ejemplo n.º 3
0
    public DataTable GetSelectedList()
    {
        DataTable dt_selected_list = Session["data_selected"] as DataTable;

        string areaTreated = string.Empty;

        if (InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance)
        {
            areaTreated = HealthCardDB.GetActiveByPatientID(Booking.Patient.PatientID).AreaTreated;
        }

        if (dt_selected_list == null)
        {
            dt_selected_list = new DataTable();
            dt_selected_list.Columns.Add(new DataColumn("offering_id"));
            dt_selected_list.Columns.Add(new DataColumn("hc_paid"));
            dt_selected_list.Columns.Add(new DataColumn("short_name"));
            dt_selected_list.Columns.Add(new DataColumn("name"));
            dt_selected_list.Columns.Add(new DataColumn("area_treated"));
            dt_selected_list.Columns.Add(new DataColumn("service_reference"));
            dt_selected_list.Columns.Add(new DataColumn("show_area_treated", typeof(Boolean)));
            dt_selected_list.Columns.Add(new DataColumn("show_service_reference", typeof(Boolean)));
            dt_selected_list.Columns.Add(new DataColumn("default_price"));
            dt_selected_list.Columns.Add(new DataColumn("pt_price"));                // added
            dt_selected_list.Columns.Add(new DataColumn("hc_price"));                // added
            dt_selected_list.Columns.Add(new DataColumn("pt_gst"));                  // added
            dt_selected_list.Columns.Add(new DataColumn("hc_gst"));                  // added
            dt_selected_list.Columns.Add(new DataColumn("quantity"));
            dt_selected_list.Columns.Add(new DataColumn("total_line_price"));
            dt_selected_list.Columns.Add(new DataColumn("total_line_gst"));
            dt_selected_list.Columns.Add(new DataColumn("total_pt_price"));          // added
            dt_selected_list.Columns.Add(new DataColumn("total_hc_price"));          // added
            dt_selected_list.Columns.Add(new DataColumn("total_pt_gst"));            // added
            dt_selected_list.Columns.Add(new DataColumn("total_hc_gst"));            // added
            dt_selected_list.Columns.Add(new DataColumn("on_order", typeof(Boolean)));


            if (this.booking != null)
            {
                Booking.InvoiceType invType = InvoiceType;

                Offering orgOffering = OrganisationOfferingsDB.GetOfferingByOrgAndOffering(this.booking.Organisation.OrganisationID, this.booking.Offering.OfferingID);
                if (orgOffering == null)
                {
                    orgOffering = this.booking.Offering;
                }

                bool    invoiceGapPayments = Convert.ToInt32(SystemVariableDB.GetByDescr("InvoiceGapPayments").Value) == 1;
                decimal GST_Percent        = Convert.ToDecimal(((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["GST_Percent"].Value);
                decimal GST_Modifier       = GST_Percent / (decimal)100;

                bool incGstOnPTInvoices = IncGstOnInvoices_Private && !orgOffering.IsGstExempt;
                bool incGstOnHCInvoices = (invType == Booking.InvoiceType.Medicare && IncGstOnInvoices_MC && !orgOffering.IsGstExempt) ||
                                          (invType == Booking.InvoiceType.DVA && IncGstOnInvoices_DVA && !orgOffering.IsGstExempt) ||
                                          (invType == Booking.InvoiceType.Insurance && IncGstOnInvoices_Insurance && !orgOffering.IsGstExempt);


                decimal pt_price = orgOffering.DefaultPrice;
                decimal hc_price = 0;
                decimal pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                decimal hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;

                if (invType == Booking.InvoiceType.Medicare)
                {
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > orgOffering.MedicareCharge ? orgOffering.DefaultPrice - orgOffering.MedicareCharge : 0;
                    hc_price = orgOffering.MedicareCharge;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }
                if (invType == Booking.InvoiceType.DVA)
                {
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > orgOffering.DvaCharge ? orgOffering.DefaultPrice - orgOffering.DvaCharge : 0;
                    hc_price = orgOffering.DvaCharge;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }
                if (invType == Booking.InvoiceType.Insurance)
                {
                    hc_price = orgOffering.TacCompanyCode.Length > 0 ? orgOffering.TacCharge : orgOffering.DefaultPrice;
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > hc_price ? orgOffering.DefaultPrice - hc_price : 0;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }


                DataRow row = dt_selected_list.NewRow();
                row["offering_id"]            = booking.Offering.OfferingID;
                row["hc_paid"]                = (this.InvoiceType == Booking.InvoiceType.DVA || this.InvoiceType == Booking.InvoiceType.Medicare);
                row["short_name"]             = booking.Offering.ShortName;
                row["name"]                   = booking.Offering.Name;
                row["area_treated"]           = areaTreated;
                row["service_reference"]      = "";
                row["show_area_treated"]      = InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance;
                row["show_service_reference"] = InvoiceType == Booking.InvoiceType.Insurance;
                row["default_price"]          = row["total_line_price"] = orgOffering.DefaultPrice;
                row["pt_price"]               = row["total_pt_price"] = pt_price;                      // added
                row["pt_gst"]                 = row["total_pt_gst"] = pt_tax;                          // added
                row["hc_price"]               = row["total_hc_price"] = hc_price;                      // added
                row["hc_gst"]                 = row["total_hc_gst"] = hc_tax;                          // added
                row["quantity"]               = "1";
                row["on_order"]               = false;
                dt_selected_list.Rows.Add(row);
            }

            Session["data_selected"] = dt_selected_list;
        }

        if (dt_selected_list.Rows.Count == 1 && dt_selected_list.Rows[0][0] == DBNull.Value)
        {
            dt_selected_list.Rows.RemoveAt(0);
        }

        return(dt_selected_list);
    }
    protected void InitForm(int patientID)
    {
        HideAllRows();

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

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


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

            displayHaveReferrerRow.Visible = true;

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

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

            string phNumTxt = string.Empty;

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

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

            lblReferrerRegisterID.Text = curRegReferrer.RegisterReferrerID.ToString();
        }
        else
        {
            displayNoReferrerRow.Visible = true;
        }
    }