示例#1
0
 protected DateTime GetEPCDateSigned(Hashtable bulkHealthCardActions, int patientID, DateTime bookingDate)
 {
     if (bulkHealthCardActions != null) // get from bulk cache of healthcardactions of all patients
     {
         HealthCardAction[] healthCardActions = (HealthCardAction[])bulkHealthCardActions[patientID];
         return(HealthCardActionDB.GetEPCDateSigned(healthCardActions, bookingDate));
     }
     else
     {
         return(HealthCardActionDB.GetEPCDateSigned(patientID, bookingDate));
     }
 }
 public static DateTime GetEPCDateSigned(int patient_id, DateTime booking_date)
 {
     HealthCardAction[] healthCardActions = HealthCardActionDB.GetReceivedActionsByPatientID(patient_id);
     return(HealthCardActionDB.GetEPCDateSigned(healthCardActions, booking_date));
 }
    public static BulkLetterSendingQueueAdditionalLetter GetFileInfo(Letter.FileFormat fileFormat, Booking booking, Patient patient, HealthCard hc, Letter.TreatmentLetterType treatmentLetterType, Booking.InvoiceType invType, int fieldID, int siteID, int staffID, Referrer referrer, bool keepInHistory, int letterPrintHistorySendMethodID)
    {
        // 1. Add to healthcardaction
        int healthCardActionID = -1;

        if (treatmentLetterType == Letter.TreatmentLetterType.First || treatmentLetterType == Letter.TreatmentLetterType.Last || treatmentLetterType == Letter.TreatmentLetterType.LastWhenReplacingEPC)
        {
            healthCardActionID = HealthCardActionDB.Insert(hc.HealthCardID, Letter.GetHealthCardActionTypeID(treatmentLetterType), DateTime.Now);
        }

        // 2.create document and put it in history
        int letterID = Letter.GetLetterIDByTreatmentLetterTypeAndInvoiceType(treatmentLetterType, invType, fieldID, siteID);

        if (letterID == -1)
        {
            return(null);
        }


        string lettersDir = Letter.GetLettersDirectory();

        if (!Directory.Exists(lettersDir))
        {
            throw new CustomMessageException("Letters directory doesn't exist");
        }

        Letter letter             = LetterDB.GetByID(letterID);
        bool   useDefaultDocs     = letter.Organisation == null ? true : !LetterDB.OrgHasdocs(letter.Organisation.OrganisationID);
        string sourceTemplatePath = lettersDir + (useDefaultDocs ? @"Default\" + letter.Site.SiteID + @"\" : letter.Organisation.OrganisationID + @"\") + letter.Docname;

        if (!File.Exists(sourceTemplatePath))
        {
            throw new CustomMessageException("File doesn't exist: " + Path.GetFileName(sourceTemplatePath));
        }

        // get temp directory
        string tmpLettersDirectory = Letter.GetTempLettersDirectory();

        if (!Directory.Exists(tmpLettersDirectory))
        {
            throw new CustomMessageException("Temp letters directory doesn't exist");
        }

        return(new BulkLetterSendingQueueAdditionalLetter(
                   -1,
                   -1,
                   letter.LetterID,
                   keepInHistory && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInDB"]),
                   keepInHistory && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInFlatFile"]),
                   letterPrintHistorySendMethodID,
                   Letter.GetLettersHistoryDirectory(booking.Organisation.OrganisationID),
                   letter.Docname.Replace(".dot", ".doc"),
                   siteID,
                   booking.Organisation.OrganisationID,
                   booking.BookingID,
                   patient.PatientID,
                   -1, // register_referrer_id_to_use_instead_of_patients_reg_ref
                   staffID,
                   healthCardActionID,
                   sourceTemplatePath,
                   tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"),
                   true,
                   "",
                   ""
                   ));
    }
示例#4
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);
        }
    }
示例#5
0
    public static LetterPrintHistory LoadAll(DataRow row)
    {
        LetterPrintHistory lph = Load(row, "lph_");

        lph.Letter = LetterDB.Load(row, "letter_");

        lph.SendMethod = new IDandDescr(Convert.ToInt32(row["lph_send_method_letter_print_history_send_method_id"]), Convert.ToString(row["lph_send_method_descr"]));

        lph.Letter.LetterType = IDandDescrDB.Load(row, "lettertype_letter_type_id", "lettertype_descr");
        if (row["letterorg_organisation_id"] != DBNull.Value)
        {
            lph.Letter.Organisation = OrganisationDB.Load(row, "letterorg_");
        }

        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            lph.Organisation = OrganisationDB.Load(row, "organisation_");
        }

        if (row["patient_patient_id"] != DBNull.Value)
        {
            lph.Patient = PatientDB.Load(row, "patient_");
        }
        if (row["patient_patient_id"] != DBNull.Value)
        {
            lph.Patient.Person       = PersonDB.Load(row, "person_patient_");
            lph.Patient.Person.Title = IDandDescrDB.Load(row, "title_patient_title_id", "title_patient_descr");
        }

        if (row["staff_staff_id"] != DBNull.Value)
        {
            lph.Staff = StaffDB.Load(row, "staff_");
        }
        if (row["staff_staff_id"] != DBNull.Value)
        {
            lph.Staff.Person       = PersonDB.Load(row, "person_staff_");
            lph.Staff.Person.Title = IDandDescrDB.Load(row, "title_staff_title_id", "title_staff_descr");
        }

        if (row["regref_register_referrer_id"] != DBNull.Value)
        {
            lph.RegisterReferrer = RegisterReferrerDB.Load(row, "regref_");
        }
        if (row["regreforg_organisation_id"] != DBNull.Value)
        {
            lph.RegisterReferrer.Organisation = OrganisationDB.Load(row, "regreforg_");
        }
        if (row["referrer_referrer_id"] != DBNull.Value)
        {
            lph.RegisterReferrer.Referrer = ReferrerDB.Load(row, "referrer_");
        }
        if (row["referrer_referrer_id"] != DBNull.Value)
        {
            lph.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "person_referrer_");
            lph.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "title_referrer_title_id", "title_referrer_descr");
        }

        if (row["lph_health_card_action_id"] != DBNull.Value)
        {
            lph.HealthCardAction = HealthCardActionDB.Load(row, "hca_");
            lph.HealthCardAction.healthCardActionType = IDandDescrDB.Load(row, "hcat_health_card_action_type_id", "hcat_descr");
            lph.HealthCardAction.HealthCard           = HealthCardDB.Load(row, "hc_");
        }

        if (row["lph_booking_id"] != DBNull.Value)
        {
            lph.Booking = BookingDB.Load(row, "booking_");
        }

        return(lph);
    }