protected void UpdateReferrersAtOrgList()
    {
        if (ddlOrgsList.SelectedIndex == -1)
        {
            return;
        }

        lblProvidersOf.Visible = true;

        lblSelectedOrg.Text = ddlOrgsList.Items[ddlOrgsList.SelectedIndex].Text;

        DataTable tbl = RegisterReferrerDB.GetDataTable_ReferrersOf(Convert.ToInt32(ddlOrgsList.Items[ddlOrgsList.SelectedIndex].Value));

        RegisterReferrer[] regRefs = new RegisterReferrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            regRefs[i]                       = RegisterReferrerDB.Load(tbl.Rows[i]);
            regRefs[i].Referrer              = ReferrerDB.Load(tbl.Rows[i]);
            regRefs[i].Referrer.Person       = PersonDB.Load(tbl.Rows[i], "", "person_entity_id");
            regRefs[i].Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr");
        }
        string list = tbl.Rows.Count == 0 ? string.Empty : @"<table cellpadding=""0"" cellspacing=""0"">";

        foreach (RegisterReferrer regRef in regRefs)
        {
            string url  = "ReferrerList_DoctorClinicV2.aspx?surname_search=" + regRef.Referrer.Person.Surname + @"&surname_starts_with=1" + (regRef.ProviderNumber.Length > 0 ? "&provider_nbr_search=" + regRef.ProviderNumber + "&provider_nbr_starts_with=1" : "");
            string href = @"<a href=""" + url + @""">" + regRef.Referrer.Person.FullnameWithoutMiddlename + "</a>";
            list += "<tr><td>" + href + @"</td><td style=""width:8px;"">&nbsp;</td><td> Prov Nbr: " + (regRef.ProviderNumber.Trim().Length == 0 ? "[None]" : regRef.ProviderNumber) + "</td></tr>";
        }
        list += tbl.Rows.Count == 0 ? string.Empty : "</table>";

        lblProvidersOfSelectedOrg.Text = list.Length > 0 ? list : "None";
    }
示例#2
0
    protected Tuple <Booking, PatientReferrer, bool, string, HealthCard> LoadRow(DataRow row)
    {
        Booking booking = BookingDB.Load(row, "booking_", true, false);

        booking.Offering = OfferingDB.Load(row, "offering_");

        PatientReferrer pr = PatientReferrerDB.Load(row, "pr_");

        pr.RegisterReferrer                       = RegisterReferrerDB.Load(row, "regref_");
        pr.RegisterReferrer.Referrer              = ReferrerDB.Load(row, "referrer_");
        pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "referrer_person_");
        pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr");
        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            pr.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_");
        }
        pr.Patient              = PatientDB.Load(row, "patient_");
        pr.Patient.Person       = PersonDB.Load(row, "patient_person_");
        pr.Patient.Person.Title = IDandDescrDB.Load(row, "patient_person_title_title_id", "patient_person_title_descr");

        bool   refHasEmail = Convert.ToInt32(row["ref_has_email"]) == 1;
        string refEmail    = row["ref_email"] == DBNull.Value ? null : Convert.ToString(row["ref_email"]);

        HealthCard hc = HealthCardDB.Load(row, "hc_");

        return(new Tuple <Booking, PatientReferrer, bool, string, HealthCard>(booking, pr, refHasEmail, refEmail, hc));
    }
    public static Hashtable GetHashtableByReferrer(bool incDeleted = false)
    {
        Hashtable hashtable = new Hashtable();

        DataTable tbl = DBBase.ExecuteQuery(JoinedSql(incDeleted, incDeleted, incDeleted)).Tables[0];

        foreach (DataRow row in tbl.Rows)
        {
            if (row["organisation_id"] == DBNull.Value)
            {
                continue;
            }

            Referrer r = ReferrerDB.Load(row);
            r.Person       = PersonDB.Load(row, "", "person_entity_id");
            r.Person.Title = IDandDescrDB.Load(row, "title_id", "descr");
            Organisation o = OrganisationDB.Load(row, "", "organisation_entity_id", "organisation_is_deleted");

            if (hashtable[r.ReferrerID] == null)
            {
                hashtable[r.ReferrerID] = new ArrayList();
            }
            ((ArrayList)hashtable[r.ReferrerID]).Add(o);
        }

        return(hashtable);
    }
    public static PatientReferrer GetByID(int patient_referrer_id)
    {
        //string sql = "SELECT patient_referrer_id,patient_id,register_referrer_id,patient_referrer_date_added,is_debtor,is_active FROM PatientReferrer WHERE patient_referrer_id = " + patient_referrer_id.ToString();
        string    sql = JoinedSQL() + " AND patient_referrer_id = " + patient_referrer_id.ToString();
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        if (tbl.Rows.Count == 0)
        {
            return(null);
        }
        else
        {
            PatientReferrer pr = Load(tbl.Rows[0]);
            pr.Patient              = PatientDB.Load(tbl.Rows[0]);
            pr.Patient.Person       = PersonDB.Load(tbl.Rows[0], "patient_person_");
            pr.Patient.Person.Title = IDandDescrDB.Load(tbl.Rows[0], "patient_person_title_title_id", "patient_person_title_descr");

            if (tbl.Rows[0]["pr_register_referrer_id"] != DBNull.Value)
            {
                pr.RegisterReferrer                       = RegisterReferrerDB.Load(tbl.Rows[0]);
                pr.RegisterReferrer.Referrer              = ReferrerDB.Load(tbl.Rows[0]);
                pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(tbl.Rows[0], "referrer_person_");
                pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[0], "referrer_person_title_title_id", "referrer_person_title_descr");
                pr.RegisterReferrer.Organisation          = OrganisationDB.Load(tbl.Rows[0], "organisation_");
            }
            if (tbl.Rows[0]["pr_organisation_id"] != DBNull.Value)
            {
                pr.Organisation = OrganisationDB.Load(tbl.Rows[0], "nonepcorg_");
            }

            return(pr);
        }
    }
    public static RegisterReferrer LoadAll(DataRow row)
    {
        RegisterReferrer rr = Load(row);

        rr.Referrer              = ReferrerDB.Load(row);
        rr.Referrer.Person       = PersonDB.Load(row, "", "person_entity_id");
        rr.Referrer.Person.Title = IDandDescrDB.Load(row, "title_id", "descr");
        if (row["organisation_id"] != DBNull.Value)
        {
            rr.Organisation = OrganisationDB.Load(row, "", "organisation_entity_id", "organisation_is_deleted");
        }
        return(rr);
    }
    public static Referrer[] GetReferrersOf(int organistion_id, bool showDeletedRefs = false, bool showDeletedRegRefs = false)
    {
        DataTable tbl = GetDataTable_ReferrersOf(organistion_id, showDeletedRefs, showDeletedRegRefs);

        Referrer[] list = new Referrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            list[i]              = ReferrerDB.Load(tbl.Rows[i]);
            list[i].Person       = PersonDB.Load(tbl.Rows[i], "", "person_entity_id");
            list[i].Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr");
        }
        return(list);
    }
示例#7
0
    public static Referrer[] GetAllNotInc(Referrer[] excList)
    {
        DataTable tbl = GetDataTable_AllNotInc(excList);

        Referrer[] list = new Referrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            list[i]              = ReferrerDB.Load(tbl.Rows[i]);
            list[i].Person       = PersonDB.Load(tbl.Rows[i]);
            list[i].Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr");
        }

        return(list);
    }
    private static RegisterReferrer[] _GetEPCReferrersOf(int patient_id, bool onlyActive)
    {
        DataTable tbl = onlyActive ? GetDataTable_ActiveEPCReferrersOf(patient_id) : GetDataTable_EPCReferrersOf(patient_id);

        RegisterReferrer[] list = new RegisterReferrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            RegisterReferrer rr = RegisterReferrerDB.Load(tbl.Rows[i], "regref_");
            rr.Referrer              = ReferrerDB.Load(tbl.Rows[i], "referrer_");
            rr.Referrer.Person       = PersonDB.Load(tbl.Rows[i], "referrer_person_");
            rr.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "referrer_person_title_title_id", "referrer_person_title_descr");
            rr.Organisation          = OrganisationDB.Load(tbl.Rows[i], "organisation_");
            list[i] = rr;
        }
        return(list);
    }
    protected void GrdReferrer_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId         = (Label)GrdReferrer.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlTitle      = (DropDownList)GrdReferrer.Rows[e.RowIndex].FindControl("ddlTitle");
        TextBox      txtFirstname  = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtFirstname");
        TextBox      txtMiddlename = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtMiddlename");
        TextBox      txtSurname    = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtSurname");
        DropDownList ddlGender     = (DropDownList)GrdReferrer.Rows[e.RowIndex].FindControl("ddlGender");

        TextBox txtName = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtName");
        TextBox txtABN  = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtABN");
        TextBox txtACN  = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtACN");

        TextBox      txtProviderNumber     = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtProviderNumber");
        DropDownList ddlIsClinic           = (DropDownList)GrdReferrer.Rows[e.RowIndex].FindControl("ddlIsClinic");
        CheckBox     chkIsReportEveryVisit = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsReportEveryVisit");
        CheckBox     chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsBatchSendAllPatientsTreatmentNotes");


        int registger_referrer_id = Convert.ToInt32(lblId.Text);

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

        DataRow[] foundRows = dt.Select("register_referrer_id=" + registger_referrer_id.ToString());
        DataRow   row       = foundRows[0];

        RegisterReferrer rr = RegisterReferrerDB.Load(row);

        rr.Referrer              = ReferrerDB.Load(row);
        rr.Referrer.Person       = PersonDB.Load(row, "", "person_entity_id");
        rr.Referrer.Person.Title = IDandDescrDB.Load(row, "title_id", "descr");
        if (row["organisation_id"] != DBNull.Value)
        {
            rr.Organisation = OrganisationDB.Load(row, "", "organisation_entity_id", "organisation_is_deleted");
        }

        PersonDB.Update(rr.Referrer.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), row["nickname"].ToString(), ddlGender.SelectedValue, row["dob"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(row["dob"]), DateTime.Now);
        OrganisationDB.UpdateExtOrg(rr.Organisation.OrganisationID, rr.Organisation.OrganisationType.OrganisationTypeID, txtName.Text, txtACN.Text, txtABN.Text, DateTime.Now, rr.Organisation.IsDebtor, rr.Organisation.IsCreditor, rr.Organisation.BpayAccount, rr.Organisation.Comment);
        RegisterReferrerDB.Update(rr.RegisterReferrerID, rr.Organisation.OrganisationID, rr.Referrer.ReferrerID, txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked, rr.DateLastBatchSendAllPatientsTreatmentNotes);

        GrdReferrer.EditIndex = -1;
        FillGrid();
    }
    // hashtable: patient_id => RegisterReferrer[]
    public static Hashtable GetEPCReferrersOf(int[] patient_ids, bool onlyActive)
    {
        string sql = JoinedSQL() + @" 
                        AND " + (patient_ids != null && patient_ids.Length > 0 ? " pat.patient_id IN (" + string.Join(",", patient_ids) + @")" : "1 <> 1") + @"
                        " + (onlyActive ? " AND pr.is_active = 1 " : "") + @"
                        ORDER BY patient_referrer_date_added";

        DataTable tbl  = DBBase.ExecuteQuery(sql).Tables[0];
        Hashtable hash = new Hashtable();

        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            RegisterReferrer rr = RegisterReferrerDB.Load(tbl.Rows[i], "regref_");
            rr.Referrer              = ReferrerDB.Load(tbl.Rows[i], "referrer_");
            rr.Referrer.Person       = PersonDB.Load(tbl.Rows[i], "referrer_person_");
            rr.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "referrer_person_title_title_id", "referrer_person_title_descr");
            rr.Organisation          = OrganisationDB.Load(tbl.Rows[i], "organisation_");

            int patient_id = Convert.ToInt32(tbl.Rows[i]["pr_patient_id"]);
            if (hash[patient_id] == null)
            {
                hash[patient_id] = new System.Collections.ArrayList();
            }
            ((System.Collections.ArrayList)hash[patient_id]).Add(rr);
        }


        // convert from arraylists to arrays
        ArrayList keys = new ArrayList();

        foreach (System.Collections.DictionaryEntry de in hash)
        {
            keys.Add(de.Key);
        }
        foreach (int key in keys)
        {
            hash[key] = (RegisterReferrer[])((ArrayList)hash[key]).ToArray(typeof(RegisterReferrer));
        }
        ;

        return(hash);
    }
示例#11
0
    public static Referral LoadAll(DataRow row)
    {
        Referral referral = Load(row);

        referral.HealthCard         = HealthCardDB.Load(row);
        referral.MedicalServiceType = IDandDescrDB.Load(row, "mct_medical_service_type_id", "mct_descr");


        referral.RegisterReferrer                       = RegisterReferrerDB.Load(row, "regref_");
        referral.RegisterReferrer.Referrer              = ReferrerDB.Load(row, "referrer_");
        referral.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "referrer_person_");
        referral.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr");
        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            referral.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_");
        }


        if (row["added_or_last_modified_by_staff_id"] != DBNull.Value)
        {
            referral.AddedOrLastModifiedBy = StaffDB.Load(row, "added_or_last_modified_by_");
        }
        if (row["person_added_or_last_modified_by_person_id"] != DBNull.Value)
        {
            referral.AddedOrLastModifiedBy.Person       = PersonDB.Load(row, "person_added_or_last_modified_by_");
            referral.AddedOrLastModifiedBy.Person.Title = IDandDescrDB.Load(row, "title_added_or_last_modified_by_title_id", "title_added_or_last_modified_by_descr");
        }

        if (row["deleted_by_staff_id"] != DBNull.Value)
        {
            referral.AddedOrLastModifiedBy = StaffDB.Load(row, "deleted_by_");
        }
        if (row["person_deleted_by_person_id"] != DBNull.Value)
        {
            referral.AddedOrLastModifiedBy.Person       = PersonDB.Load(row, "person_deleted_by_");
            referral.AddedOrLastModifiedBy.Person.Title = IDandDescrDB.Load(row, "title_deleted_by_title_id", "title_deleted_by_descr");
        }


        return(referral);
    }
    public static PatientReferrer LoadAll(DataRow row)
    {
        PatientReferrer pr = PatientReferrerDB.Load(row, "pr_");

        pr.RegisterReferrer                       = RegisterReferrerDB.Load(row, "regref_");
        pr.RegisterReferrer.Referrer              = ReferrerDB.Load(row, "referrer_");
        pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "referrer_person_");
        pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr");
        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            pr.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_");
        }
        pr.Patient              = PatientDB.Load(row, "patient_");
        pr.Patient.Person       = PersonDB.Load(row, "patient_person_");
        pr.Patient.Person.Title = IDandDescrDB.Load(row, "patient_person_title_title_id", "patient_person_title_descr");
        if (row["nonepcorg_entity_id"] != DBNull.Value)
        {
            pr.Organisation = OrganisationDB.Load(row, "nonepcorg_");
        }

        return(pr);
    }
    private static PatientReferrer[] _GetEPCPatientReferrersOf(int patient_id, bool onlyActive)
    {
        DataTable tbl = onlyActive ? GetDataTable_ActiveEPCReferrersOf(patient_id) : GetDataTable_EPCReferrersOf(patient_id);

        PatientReferrer[] list = new PatientReferrer[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            PatientReferrer pr = Load(tbl.Rows[i], "pr_");
            pr.RegisterReferrer                       = RegisterReferrerDB.Load(tbl.Rows[i], "regref_");
            pr.RegisterReferrer.Referrer              = ReferrerDB.Load(tbl.Rows[i], "referrer_");
            pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(tbl.Rows[i], "referrer_person_");
            pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "referrer_person_title_title_id", "referrer_person_title_descr");
            if (tbl.Rows[i]["organisation_organisation_id"] != DBNull.Value)
            {
                pr.RegisterReferrer.Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_");
            }
            pr.Patient              = PatientDB.Load(tbl.Rows[i], "patient_");
            pr.Patient.Person       = PersonDB.Load(tbl.Rows[i], "patient_person_");
            pr.Patient.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "patient_person_title_title_id", "patient_person_title_descr");
            list[i] = pr;
        }
        return(list);
    }
    public static string[] BulkGetAllTreatmentNotes(DateTime date_start, DateTime date_end, string newline = "\n", bool incNoteIDForDebug = false)
    {
        string recurring_condition     = string.Empty;
        string non_recurring_condition = string.Empty;

        if (date_start != DateTime.MinValue && date_end != DateTime.MinValue)
        {
            recurring_condition     = "AND (  booking.date_start >= '" + date_start.ToString("yyyy-MM-dd HH:mm:ss") + "' AND booking.date_end <= '" + date_end.ToString("yyyy-MM-dd HH:mm:ss") + @"' )";
            non_recurring_condition = "AND (  booking.date_end IS NULL OR booking.date_end > '" + date_start.Date.ToString("yyyy-MM-dd HH:mm:ss") + "') " + (date_end == DateTime.MinValue ? "" : " AND booking.date_start < '" + date_end.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss") + "'") + @"";
        }
        else if (date_start != DateTime.MinValue)
        {
            recurring_condition     = "AND (  booking.date_start >= '" + date_start.ToString("yyyy-MM-dd HH:mm:ss") + "')";
            non_recurring_condition = "AND (  booking.date_end IS NULL OR booking.date_end > '" + date_start.Date.ToString("yyyy-MM-dd HH:mm:ss") + "') " + @"";
        }
        else if (date_end != DateTime.MinValue)
        {
            recurring_condition     = "AND (  booking.date_end  <= '" + date_end.ToString("yyyy-MM-dd HH:mm:ss") + @"' )";
            non_recurring_condition = "AND (  booking.date_start < '" + date_end.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss") + @"' )";
        }
        else
        {
            recurring_condition     = "";
            non_recurring_condition = "";
        }


        string sql = @"

                SELECT 
                    note.note_id as note_note_id, note.entity_id as note_entity_id, note.note_type_id as note_note_type_id, note.body_part_id as note_body_part_id, note.text as note_text, note.date_added as note_date_added, note.date_modified as note_date_modified, note.added_by as note_added_by, note.modified_by as note_modified_by, note.site_id as note_site_id,


                    booking.booking_id as booking_booking_id,booking.entity_id as booking_entity_id,
                    booking.date_start as booking_date_start,booking.date_end as booking_date_end,booking.organisation_id as booking_organisation_id,
                    booking.provider as booking_provider,booking.patient_id as booking_patient_id,booking.offering_id as booking_offering_id,booking.booking_type_id as booking_booking_type_id,
                    booking.booking_status_id as booking_booking_status_id,booking.booking_unavailability_reason_id as booking_booking_unavailability_reason_id,booking.added_by as booking_added_by,booking.date_created as booking_date_created,
                    booking.booking_confirmed_by_type_id as booking_booking_confirmed_by_type_id,booking.confirmed_by as booking_confirmed_by,booking.date_confirmed as booking_date_confirmed,
                    booking.deleted_by as booking_deleted_by, booking.date_deleted as booking_date_deleted,
                    booking.cancelled_by as booking_cancelled_by, booking.date_cancelled as booking_date_cancelled,
                    booking.is_patient_missed_appt as booking_is_patient_missed_appt,booking.is_provider_missed_appt as booking_is_provider_missed_appt,
                    booking.is_emergency as booking_is_emergency,
                    booking.need_to_generate_first_letter as booking_need_to_generate_first_letter,booking.need_to_generate_last_letter as booking_need_to_generate_last_letter,booking.has_generated_system_letters as booking_has_generated_system_letters,
                    booking.arrival_time              as booking_arrival_time,
                    booking.sterilisation_code        as booking_sterilisation_code,
                    booking.informed_consent_added_by as booking_informed_consent_added_by, 
                    booking.informed_consent_date     as booking_informed_consent_date,
                    booking.is_recurring as booking_is_recurring,booking.recurring_weekday_id as booking_recurring_weekday_id,
                    booking.recurring_start_time as booking_recurring_start_time,booking.recurring_end_time as booking_recurring_end_time,
                    (SELECT 0) AS booking_note_count,
                    (SELECT 0) AS booking_inv_count,

                    patient.patient_id as patient_patient_id, patient.person_id as patient_person_id, patient.patient_date_added as patient_patient_date_added, 
                    patient.is_clinic_patient as patient_is_clinic_patient,patient.is_gp_patient as patient_is_gp_patient,patient.is_deleted as patient_is_deleted,patient.is_deceased as patient_is_deceased, 
                    patient.flashing_text as patient_flashing_text, patient.flashing_text_added_by as patient_flashing_text_added_by, patient.flashing_text_last_modified_date as patient_flashing_text_last_modified_date, 
                    patient.private_health_fund as patient_private_health_fund, patient.concession_card_number as patient_concession_card_number, patient.concession_card_expiry_date as patient_concession_card_expiry_date, patient.is_diabetic as patient_is_diabetic, patient.is_member_diabetes_australia as patient_is_member_diabetes_australia, patient.diabetic_assessment_review_date as patient_diabetic_assessment_review_date, patient.ac_inv_offering_id as patient_ac_inv_offering_id, patient.ac_pat_offering_id as patient_ac_pat_offering_id, patient.login as patient_login, patient.pwd as patient_pwd, patient.is_company as patient_is_company, patient.abn as patient_abn, 
                    patient.next_of_kin_name as patient_next_of_kin_name, patient.next_of_kin_relation as patient_next_of_kin_relation, patient.next_of_kin_contact_info as patient_next_of_kin_contact_info,

                    " + PersonDB.GetFields("person_patient_", "person_patient") + @", 
                    title_patient.title_id as title_patient_title_id, title_patient.descr as title_patient_descr,


                    rr.register_referrer_id as rr_register_referrer_id, rr.organisation_id as rr_organisation_id, rr.referrer_id as rr_referrer_id, 
                    rr.provider_number as rr_provider_number, rr.report_every_visit_to_referrer as rr_report_every_visit_to_referrer, 
                    rr.batch_send_all_patients_treatment_notes as rr_batch_send_all_patients_treatment_notes, 
                    rr.date_last_batch_send_all_patients_treatment_notes as rr_date_last_batch_send_all_patients_treatment_notes, 
                    rr.register_referrer_date_added as rr_register_referrer_date_added, rr.is_deleted as rr_is_deleted,

                    ref.referrer_id as ref_referrer_id, ref.person_id as ref_person_id, ref.referrer_date_added as ref_referrer_date_added, 
                    " + PersonDB.GetFields("p_", "p") + @", 
                    t.title_id as t_title_id, t.descr as t_descr

                FROM
                    Note note
                    INNER JOIN Booking          booking           ON booking.entity_id                      = note.entity_id
                    INNER JOIN Patient          patient           ON patient.patient_id                     = booking.patient_id
                    INNER JOIN Person           person_patient    ON person_patient.person_id               = patient.person_id
                    INNER JOIN Title            title_patient     ON title_patient.title_id                 = person_patient.title_id

                    INNER Join PatientReferrer  patient_referrer  ON patient_referrer.patient_id            = patient.patient_id
                    INNER Join RegisterReferrer rr                ON rr.register_referrer_id                = patient_referrer.register_referrer_id
                    INNER JOIN Referrer         ref               ON ref.referrer_id                        = rr.referrer_id 
                    INNER JOIN Person           p                 ON p.person_id                            = ref.person_id
                    INNER JOIN Title            t                 ON t.title_id                             = p.title_id

                WHERE
                    note.note_type_id = 252             -- only provider treatment notes
                    AND booking.booking_status_id = 187 -- only get completed bookings
                    AND booking.booking_type_id   = 34  -- only get bookings for patients (not blockout-prov/org-timeslot bookings)
                    AND (
                            (booking.is_recurring = 0 " + recurring_condition + @") OR  
                            (booking.is_recurring = 1 " + non_recurring_condition + @") 
                        )
                    AND rr.is_deleted = 0
                    AND rr.batch_send_all_patients_treatment_notes = 1

                ORDER BY 
                    rr.register_referrer_id, person_patient.surname, person_patient.firstname, booking.date_start, note.note_id
                    ";

        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        string[] notes = new string[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            Booking booking = BookingDB.Load(tbl.Rows[i], "booking_");
            booking.Patient              = PatientDB.Load(tbl.Rows[i], "patient_");
            booking.Patient.Person       = PersonDB.Load(tbl.Rows[i], "person_patient_");
            booking.Patient.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_patient_title_id", "title_patient_descr");

            Note note = NoteDB.Load(tbl.Rows[i], "note_");

            RegisterReferrer rr = RegisterReferrerDB.Load(tbl.Rows[i], "rr_");
            rr.Referrer              = ReferrerDB.Load(tbl.Rows[i], "ref_");
            rr.Referrer.Person       = PersonDB.Load(tbl.Rows[i], "p_");
            rr.Referrer.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "t_title_id", "t_descr");

            notes[i] = booking.GetNoteTextForTreatmentLetter(rr.Referrer, note, newline, incNoteIDForDebug);
        }

        return(notes);
    }
示例#15
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);
    }