protected void GrdRegistration_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { DropDownList ddlReferrer = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewReferrer"); TextBox txtProviderNumber = (TextBox)GrdRegistration.FooterRow.FindControl("txtNewProviderNumber"); DropDownList ddlIsClinic = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewIsClinic"); CheckBox chkIsReportEveryVisit = (CheckBox)GrdRegistration.FooterRow.FindControl("chkNewIsReportEveryVisit"); CheckBox chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdRegistration.FooterRow.FindControl("chkNewIsBatchSendAllPatientsTreatmentNotes"); Organisation org = OrganisationDB.GetByID(GetFormID()); if (org == null) { HideTableAndSetErrorMessage(""); return; } try { RegisterReferrerDB.Insert(org.OrganisationID, Convert.ToInt32(ddlReferrer.SelectedValue), txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked); } catch (UniqueConstraintException) { // happens when 2 forms allow adding - do nothing and let form re-update } FillGrid(); } }
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); } }
protected void GrdReferrer_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblId = (Label)GrdReferrer.Rows[e.RowIndex].FindControl("lblId"); DropDownList ddlRefs = (DropDownList)GrdReferrer.Rows[e.RowIndex].FindControl("ddlRefs"); TextBox txtProviderNumber = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtProviderNumber"); CheckBox chkIsReportEveryVisit = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsReportEveryVisit"); CheckBox chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsBatchSendAllPatientsTreatmentNotes"); RegisterReferrer regRef = RegisterReferrerDB.GetByID(Convert.ToInt32(lblId.Text)); if (RegisterReferrerDB.Exists(regRef.Organisation.OrganisationID, Convert.ToInt32(ddlRefs.SelectedValue), regRef.RegisterReferrerID)) { SetErrorMessage("Clinic is already linked to " + ddlRefs.SelectedItem.Text + ". If it is not visible, use the 'show deleted' checkbox and un-delete it."); GrdReferrer.EditIndex = -1; FillGrid(); return; } RegisterReferrerDB.Update( regRef.RegisterReferrerID, regRef.Organisation.OrganisationID, Convert.ToInt32(ddlRefs.SelectedValue), txtProviderNumber.Text.Trim(), chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked, regRef.DateLastBatchSendAllPatientsTreatmentNotes); GrdReferrer.EditIndex = -1; FillGrid(); }
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)); }
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;""> </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"; }
/* * * protected void btnRunBatchSendTreatmentNotes_AllReferrers_SinceLast_Click(object sender, EventArgs e) * { * try * { * DateTime startDate = GetStartDate(6, GetLastDateBatchSendTreatmentNotesAllReferrers()); * DateTime endDate = DateTime.Now; * * RunBatchSendTreatmentNotes_AllReferrers(startDate, endDate); * } * catch (CustomMessageException cmEx) * { * SetErrorMessage(cmEx.Message); * } * } * protected void btnRunBatchSendTreatmentNotes_AllReferrers_Last6Months_Click(object sender, EventArgs e) * { * try * { * DateTime startDate = DateTime.Now.AddMonths(-6); * DateTime endDate = DateTime.Now; * * RunBatchSendTreatmentNotes_AllReferrers(startDate, endDate); * } * catch (CustomMessageException cmEx) * { * SetErrorMessage(cmEx.Message); * } * } * protected void RunBatchSendTreatmentNotes_AllReferrers(DateTime startDate, DateTime endDate) * { * ArrayList noteFileList = new ArrayList(); * * try * { * * // TODO: Send Letter By Email * * * string tmpLettersDirectory = Letter.GetTempLettersDirectory(); * if (!Directory.Exists(tmpLettersDirectory)) * throw new CustomMessageException("Temp letters directory doesn't exist"); * * * // get all notes of all patients of this referrer * foreach (RegisterReferrer regReferrer in RegisterReferrerDB.GetAllByBatchSendAllTreatmentNotes(true)) * { * foreach (Patient patient in PatientReferrerDB.GetActivePatientsOf(regReferrer.RegisterReferrerID)) * { * HealthCard[] hcs = HealthCardDB.GetAllByPatientID(patient.PatientID); * HealthCard hc = hcs[0]; * * Booking[] completedBookings = BookingDB.GetBetween(startDate.Date, endDate, null, null, patient, false, "187"); * foreach (Booking booking in completedBookings) * { * if (booking.NoteCount == 0) * continue; * * Letter.FileContents fileContentsStandardTreatment = booking.GetTreatmentLetter(-1, hc, regReferrer.Referrer, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), false, 1); * string tmpFileName_EPCTreatment = FileHelper.GetTempFileName(tmpLettersDirectory + fileContentsStandardTreatment.DocName); * File.WriteAllBytes(tmpFileName_EPCTreatment, fileContentsStandardTreatment.Contents); * noteFileList.Add(tmpFileName_EPCTreatment); * } * } * } * * * SetErrorMessage("Generated " + noteFileList.Count + " Notes"); * if (noteFileList.Count > 0) // merge * { * string docName = "TreatmentNotes.doc"; * * string tmpFinalFileName = Letter.MergeMultipleDocuments((string[])noteFileList.ToArray(typeof(string)), tmpLettersDirectory + docName); * byte[] fileContents = System.IO.File.ReadAllBytes(tmpFinalFileName); * * for (int i = noteFileList.Count - 1; i >= 0; i--) * { * File.Delete(noteFileList[i].ToString()); * noteFileList.RemoveAt(i); * } * File.Delete(tmpFinalFileName); * * Session["downloadFile_Contents"] = fileContents; * Session["downloadFile_DocName"] = 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>"); * * RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes_All(endDate); * SetLastDateBatchSendTreatmentNotesAllReferrers(endDate); * FillGrid(); // because each referrers date that has send=true should have been updated * } * * * // don't allow this to be in production: * // * bool resetGlobalLastPrintedDate = false; * bool resetAllRegReferrersLastPrintedDate = false; * * if (resetGlobalLastPrintedDate) * SetLastDateBatchSendTreatmentNotesAllReferrers(DateTime.MinValue); * if (resetAllRegReferrersLastPrintedDate) * { * RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes_All(DateTime.MinValue); * FillGrid(); * } * * } * catch (CustomMessageException cmEx) * { * for(int i=noteFileList.Count-1; i>= 0; i--) * { * File.Delete(noteFileList[i].ToString()); * noteFileList.RemoveAt(i); * } * SetErrorMessage(cmEx.Message); * } * } * * protected void btnRunBatchSendTreatmentNotes_Click(object sender, EventArgs e) * { * try * { * object argument = ((Button)sender).CommandArgument; * int register_referrer_id = Convert.ToInt32(argument); * RegisterReferrer regReferrer = RegisterReferrerDB.GetByID(register_referrer_id); * if (regReferrer == null) * throw new CustomMessageException(""); * * DateTime startDate = DateTime.Now.AddMonths(-6); // GetStartDate(6, regReferrer.DateLastBatchSendAllPatientsTreatmentNotes); * DateTime endDate = DateTime.Now; * * RunBatchSendTreatmentNotes(regReferrer, startDate, endDate); * } * catch (CustomMessageException cmEx) * { * SetErrorMessage(cmEx.Message); * } * * } * protected void RunBatchSendTreatmentNotes(RegisterReferrer regReferrer, DateTime startDate, DateTime endDate) * { * ArrayList noteFileList = new ArrayList(); * * try * { * * // TODO: Send Letter By Email * * * * string tmpLettersDirectory = Letter.GetTempLettersDirectory(); * if (!Directory.Exists(tmpLettersDirectory)) * throw new CustomMessageException("Temp letters directory doesn't exist"); * * * // get all notes of all patients of this referrer * foreach (Patient patient in PatientReferrerDB.GetActivePatientsOf(regReferrer.RegisterReferrerID)) * { * HealthCard[] hcs = HealthCardDB.GetAllByPatientID(patient.PatientID); * HealthCard hc = hcs[0]; * * Booking[] completedBookings = BookingDB.GetBetween(startDate.Date, endDate, null, null, patient, false, "187"); * foreach (Booking booking in completedBookings) * { * if (booking.NoteCount == 0) * continue; * * Letter.FileContents fileContentsStandardTreatment = booking.GetTreatmentLetter(-1, hc, regReferrer.Referrer, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), false, 1); * string tmpFileName_EPCTreatment = FileHelper.GetTempFileName(tmpLettersDirectory + fileContentsStandardTreatment.DocName); * File.WriteAllBytes(tmpFileName_EPCTreatment, fileContentsStandardTreatment.Contents); * noteFileList.Add(tmpFileName_EPCTreatment); * } * } * * if (noteFileList.Count == 0) * { * SetErrorMessage("No treatment notes for: " + regReferrer.Referrer.Person.Fullname); * return; * } * else // merge * { * SetErrorMessage("Treatment notes created for: " + regReferrer.Referrer.Person.Fullname); * * string docName = "TreatmentNotes.doc"; * * string tmpFinalFileName = Letter.MergeMultipleDocuments((string[])noteFileList.ToArray(typeof(string)), tmpLettersDirectory + docName); * byte[] fileContents = System.IO.File.ReadAllBytes(tmpFinalFileName); * * for (int i = noteFileList.Count - 1; i >= 0; i--) * { * File.Delete(noteFileList[i].ToString()); * noteFileList.RemoveAt(i); * } * File.Delete(tmpFinalFileName); * * Session["downloadFile_Contents"] = fileContents; * Session["downloadFile_DocName"] = 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>"); * * } * * RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes(regReferrer.RegisterReferrerID, endDate); * FillGrid(); * } * catch (CustomMessageException cmEx) * { * for (int i = noteFileList.Count - 1; i >= 0; i--) * { * File.Delete(noteFileList[i].ToString()); * noteFileList.RemoveAt(i); * } * SetErrorMessage(cmEx.Message); * } * } * * protected DateTime GetStartDate(int maxMonths, DateTime lastSendDate) * { * bool hasLastSendDateAndNotOverMaxMonthsAgo = (lastSendDate != DateTime.MinValue && lastSendDate > DateTime.Now.AddMonths(-1 * maxMonths)); * return hasLastSendDateAndNotOverMaxMonthsAgo ? lastSendDate : DateTime.Now.AddMonths(-1 * maxMonths); * } * */ #endregion protected void btnMovePatients_Click(object sender, EventArgs e) { RegisterReferrer regRefFrom = RegisterReferrerDB.GetByID(Convert.ToInt32(hiddenMovePatientFrom.Value)); RegisterReferrer regRefTo = RegisterReferrerDB.GetByID(Convert.ToInt32(hiddenMovePatientTo.Value)); PatientReferrerDB.UpdateMoveAllPatients(regRefFrom.RegisterReferrerID, regRefTo.RegisterReferrerID); FillGrid(); SetErrorMessage("<font color=\"black\">Patients Moved From</font> " + regRefFrom.Referrer.Person.Firstname + " " + regRefFrom.Referrer.Person.Surname + "[" + regRefFrom.Organisation.Name + "] <font color=\"black\">to</font> " + regRefTo.Referrer.Person.Firstname + " " + regRefTo.Referrer.Person.Surname + "[" + regRefTo.Organisation.Name + "]"); }
protected void UpdateOrgsFromJavascriptChanges() { string referrerIDs = hiddenReferrerIDsList.Value; // comma seperated Hashtable referrerIDsHash = new Hashtable(); if (referrerIDs.Length > 0) { foreach (string referrerID in referrerIDs.Split(',')) { referrerIDsHash[Convert.ToInt32(referrerID)] = 1; } } DataTable referrers = RegisterReferrerDB.GetDataTable(0, -1, true); RegisterReferrer[] regRefs = new RegisterReferrer[referrers.Rows.Count]; for (int i = 0; i < referrers.Rows.Count; i++) { regRefs[i] = RegisterReferrerDB.LoadAll(referrers.Rows[i]); } ArrayList referrersAdded = new ArrayList(); lstReferrers.Items.Clear(); for (int i = 0; i < regRefs.Length; i++) { if (referrerIDsHash[regRefs[i].RegisterReferrerID] != null) { string text = regRefs[i].Referrer.Person.FullnameWithoutMiddlename + " [" + regRefs[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, regRefs[i].RegisterReferrerID.ToString())); referrersAdded.Add(regRefs[i]); } } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( (RegisterReferrer[])referrersAdded.ToArray(typeof(RegisterReferrer)), ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); }
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 AddAllReferrers() { // clear and re-set all (in alphabetical order) ArrayList newList = new ArrayList(); DataTable referrers = RegisterReferrerDB.GetDataTable(); for (int i = 0; i < referrers.Rows.Count; i++) { newList.Add(RegisterReferrerDB.LoadAll(referrers.Rows[i])); } RegisterReferrer[] allReferrers = (RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer)); lstReferrers.Items.Clear(); string items = string.Empty; for (int i = 0; i < allReferrers.Length; i++) { string text = allReferrers[i].Referrer.Person.FullnameWithoutMiddlename + " [" + allReferrers[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, allReferrers[i].RegisterReferrerID.ToString())); // add to hidden list items += (items.Length == 0 ? "" : ",") + allReferrers[i].RegisterReferrerID.ToString(); } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( allReferrers, ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); hiddenReferrerIDsList.Value = items; }
/* * protected bool IsValidFormOrg() * { * string orgID = Request.QueryString["org"]; * return orgID != null && Regex.IsMatch(orgID, @"^\d+$") && OrganisationDB.Exists(Convert.ToInt32(orgID)); * } * protected int GetFormOrg(bool checkIsValid = true) * { * if (checkIsValid && !IsValidFormOrg()) * throw new Exception("Invalid url org"); * return Convert.ToInt32(Request.QueryString["org"]); * } * * protected bool IsValidFormOrgs() * { * string orgIDs = Request.QueryString["orgs"]; * return orgIDs != null && Regex.IsMatch(orgIDs, @"^[\d,]+$") && OrganisationDB.Exists(orgIDs); * } * protected string GetFormOrgs(bool checkIsValid = true) * { * if (checkIsValid && !IsValidFormOrgs()) * throw new Exception("Invalid url orgs"); * return Request.QueryString["orgs"]; * } */ #endregion #region GrdReferrer protected void FillReferrerGrid() { DataTable dt = RegisterReferrerDB.GetDataTable(0, -1, false, new int[] { 191 }, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked, txtSearchSuburb.Text, txtSearchPostcode.Text); Session["referrerlistmultiplepopup_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerlistmultiplepopup_sortexpression"] != null && Session["referrerlistmultiplepopup_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerlistmultiplepopup_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } }
protected string GetLine(int id, Person p, string colSep, string rowSep, bool incRowSep, bool incDOB, bool incAddresses, bool incPhoneNbrs, bool incRefInfo) { string result = string.Empty; if (incRowSep) { result += rowSep; } result += id.ToString() + colSep + p.Firstname + colSep + p.Middlename + colSep + p.Surname; if (incDOB) { result += colSep + (p.Dob == DateTime.MinValue ? "" : p.Dob.ToString("dd-MM-yyyy")); } if (incAddresses) { result += colSep + GetAddresses(p.EntityID); } if (incPhoneNbrs) { result += colSep + GetPhoneNbrs(p.EntityID); } if (incRefInfo) { string orgNames = string.Empty; string provNbrs = string.Empty; System.Data.DataTable tbl = RegisterReferrerDB.GetDataTable_OrganisationsOf(id); RegisterReferrer[] list = new RegisterReferrer[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = RegisterReferrerDB.Load(tbl.Rows[i]); list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted"); orgNames += (orgNames.Length == 0 ? "" : "\r\n") + list[i].Organisation.Name; provNbrs += (provNbrs.Length == 0 ? "" : "\r\n") + list[i].ProviderNumber; } result += colSep + orgNames; result += colSep + provNbrs; } return(result); }
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(); }
public static void GetCountsByEmailMobile( RegisterReferrer[] regRefs, ref int hasBothMobileEmail, ref int hasMobileNoEmail, ref int hasEmailNoMobile, ref int hasNeitherMobileEmail) { int[] regRefIDs = regRefs.Select(r => r.RegisterReferrerID).ToArray(); int[] entityIDs = regRefs.Select(r => r.Organisation.EntityID).ToArray(); Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs); Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs); Hashtable emailHash = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1); Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30"); hasBothMobileEmail = 0; hasMobileNoEmail = 0; hasEmailNoMobile = 0; hasNeitherMobileEmail = 0; for (int i = 0; i < regRefs.Length; i++) { bool hasEmail = emailHash[regRefs[i].Organisation.EntityID] != null; bool hasMobile = mobileHash[regRefs[i].Organisation.EntityID] != null; if (hasEmail && hasMobile) { hasBothMobileEmail++; } if (!hasEmail && hasMobile) { hasMobileNoEmail++; } if (hasEmail && !hasMobile) { hasEmailNoMobile++; } if (!hasEmail && !hasMobile) { hasNeitherMobileEmail++; } } }
public static RegisterReferrer[] RemoveRegisterReferrersByEmailMobile( RegisterReferrer[] regRefs, bool incHasBothMobileEmail, bool incHasMobileNoEmail, bool incHasEmailNoMobile, bool incHasNeitherMobileEmail) { if (incHasBothMobileEmail && incHasMobileNoEmail && incHasEmailNoMobile && incHasNeitherMobileEmail) { return(regRefs); } if (!incHasBothMobileEmail && !incHasMobileNoEmail && !incHasEmailNoMobile && !incHasNeitherMobileEmail) { return new RegisterReferrer[] { } } ; int[] regRefIDs = regRefs.Select(r => r.RegisterReferrerID).ToArray(); int[] entityIDs = regRefs.Select(r => r.Organisation.EntityID).ToArray(); Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs); Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs); Hashtable emailHash = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1); Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30"); ArrayList newList = new ArrayList(); for (int i = 0; i < regRefs.Length; i++) { bool hasEmail = emailHash[regRefs[i].Organisation.EntityID] != null; bool hasMobile = mobileHash[regRefs[i].Organisation.EntityID] != null; if ((incHasBothMobileEmail && hasEmail && hasMobile) || (incHasMobileNoEmail && !hasEmail && hasMobile) || (incHasEmailNoMobile && hasEmail && !hasMobile) || (incHasNeitherMobileEmail && !hasEmail && !hasMobile)) { newList.Add(regRefs[i]); } } return((RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer))); }
// 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); }
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); }
protected void btnRegisterReferrerSelectionUpdate_Click(object sender, EventArgs e) { // can update info ... if needed... int newRegisterReferrerID = Convert.ToInt32(registerReferrerID.Value); if (newRegisterReferrerID == -1) { lblReferrerText.Text = "<b>All Referreres</b>"; } else { RegisterReferrer regRef = RegisterReferrerDB.GetByID(newRegisterReferrerID); //lblReferrerText.Text = regRef.Referrer.Person.FullnameWithoutMiddlename; string phNumTxt = string.Empty; if (Utilities.GetAddressType().ToString() == "Contact") { Contact[] phNums = ContactDB.GetByEntityID(2, regRef.Organisation.EntityID); for (int i = 0; i < phNums.Length; i++) { phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " (" + phNums[i].ContactType.Descr + ")"; } } else if (Utilities.GetAddressType().ToString() == "ContactAus") { ContactAus[] phNums = ContactAusDB.GetByEntityID(2, regRef.Organisation.EntityID); for (int i = 0; i < phNums.Length; i++) { phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " (" + phNums[i].ContactType.Descr + ")"; } } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } lblReferrerText.Text = "<b>" + regRef.Referrer.Person.FullnameWithoutMiddlename + "</b> [" + regRef.Organisation.Name + "]" + "<br />" + (phNumTxt.Length == 0 ? "" : phNumTxt + "<br />"); // put in referrers fax and phone numbers } }
protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId"); try { RegisterReferrerDB.UpdateInactive(Convert.ToInt32(lblId.Text)); } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { HideTableAndSetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); }
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); }
protected void btnChangeToAddMode_Click(object sender, EventArgs e) { displayNoReferrerRow.Visible = false; addRow.Visible = true; newReferrersLinkRow.Visible = true; int nItems = ddlNewReferrer.Items.Count; for (int i = 0; i < nItems; i++) { ddlNewReferrer.Items.RemoveAt(0); } DataTable rr = RegisterReferrerDB.GetDataTable(0, -1, false, new int[] { 191 }); foreach (DataRowView row in rr.DefaultView) { ddlNewReferrer.Items.Add(new ListItem(row["surname"].ToString() + ", " + row["firstname"].ToString() + " [" + row["name"].ToString() + "]", row["register_referrer_id"].ToString())); } }
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); }
protected void GrdRegistration_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblId = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId"); DropDownList ddlReferrer = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlReferrer"); TextBox txtProviderNumber = (TextBox)GrdRegistration.Rows[e.RowIndex].FindControl("txtProviderNumber"); DropDownList ddlIsClinic = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlIsClinic"); CheckBox chkIsReportEveryVisit = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIsReportEveryVisit"); CheckBox chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdRegistration.Rows[e.RowIndex].FindControl("chkIsBatchSendAllPatientsTreatmentNotes"); Organisation org = OrganisationDB.GetByID(GetFormID()); if (org == null) { HideTableAndSetErrorMessage(""); return; } RegisterReferrer registerReferrer = RegisterReferrerDB.GetByID(Convert.ToInt32(lblId.Text)); RegisterReferrerDB.Update(Convert.ToInt32(lblId.Text), org.OrganisationID, Convert.ToInt32(ddlReferrer.SelectedValue), txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked, registerReferrer.DateLastBatchSendAllPatientsTreatmentNotes); GrdRegistration.EditIndex = -1; FillGrid(); }
protected Letter.FileContents[] ProcessReferrersLetters(bool viewListOnly, ArrayList bookingsForCurrentReferrer, ref string debugOutput) { if (bookingsForCurrentReferrer.Count == 0) { return(new Letter.FileContents[0]); } // to return - only files to print, as emailing will have been completed ArrayList filesToPrint = new ArrayList(); // an email belongs to the regRef.Org ... so one referrer can have multiple. // keep in hash to avoid continued lookups. Hashtable refEmailHash = new Hashtable(); ArrayList regRefIDsToUpdateDateTimeOfLastBatchSend = new ArrayList(); Site[] sites = SiteDB.GetAll(); for (int i = 0; i < bookingsForCurrentReferrer.Count; i++) { Tuple <Booking, PatientReferrer, bool, string, HealthCard> curTuple = (Tuple <Booking, PatientReferrer, bool, string, HealthCard>)bookingsForCurrentReferrer[i]; Booking curBooking = curTuple.Item1; PatientReferrer curPR = curTuple.Item2; bool curRefHasEmail = curTuple.Item3; string curRefEmail = curTuple.Item4; HealthCard curHC = curTuple.Item5; bool needToGenerateLetters = curBooking.NeedToGenerateFirstLetter || curBooking.NeedToGenerateLastLetter || (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0); if (needToGenerateLetters) { SendMethod sendMethod = (curRefHasEmail && this.SelectedSendMethod == SendMethod.Email ? SendMethod.Email : SendMethod.Print); if (!viewListOnly) { if (curRefHasEmail && this.SelectedSendMethod == SendMethod.Email) { Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.PDF, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), sendMethod == SendMethod.Email ? 2 : 1); if (fileContentsList != null && fileContentsList.Length > 0) { if (ReferrerEPCLettersSendingV2.LogDebugEmailInfo) { Logger.LogQuery("C ReferrerEPCLetters_GenerateUnsent -- Email Send Item Starting [" + curRefEmail + "]", false, false, true); } Site site = SiteDB.GetSiteByType(curBooking.Organisation.IsAgedCare ? SiteDB.SiteType.AgedCare : SiteDB.SiteType.Clinic, sites); Letter.EmailSystemLetter(site.Name, curRefEmail, fileContentsList, "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename), "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name); if (ReferrerEPCLettersSendingV2.LogDebugEmailInfo) { Logger.LogQuery("C ReferrerEPCLetters_GenerateUnsent -- Email Send Item Done!", false, false, true); } } } else { Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.Word, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), sendMethod == SendMethod.Email ? 2 : 1); if (fileContentsList != null && fileContentsList.Length > 0) { filesToPrint.AddRange(fileContentsList); } } BookingDB.UpdateSetGeneratedSystemLetters(curBooking.BookingID, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, true); } ArrayList toGenerateList = new ArrayList(); if (curBooking.NeedToGenerateFirstLetter) { toGenerateList.Add("First"); } if (curBooking.NeedToGenerateLastLetter) { toGenerateList.Add("Last"); } if (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0) { toGenerateList.Add("Notes"); } string toGenerate = string.Join(",", (string[])toGenerateList.ToArray(typeof(string))); string addEditContactListPage; if (Utilities.GetAddressType().ToString() == "Contact") { addEditContactListPage = "AddEditContactList.aspx"; } else if (Utilities.GetAddressType().ToString() == "ContactAus") { addEditContactListPage = "ContactAusListV2.aspx"; } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } string allFeatures = "dialogWidth:525px;dialogHeight:430px;center:yes;resizable:no; scroll:no"; string onclick = "onclick=\"javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + curPR.RegisterReferrer.Organisation.EntityID.ToString() + "', '', '" + allFeatures + "');document.getElementById('" + btnViewList.ClientID + "').click();return false;\""; string hrefUpdateEmail = "<u><a style=\"text-decoration: none\" title=\"Edit\" AlternateText=\"Edit\" " + onclick + " href=\"\">Update Clinic Email</a></u>"; debugOutput += @"<tr> <td>" + sendMethod + @"</td> <td style=""white-space:nowrap;"">" + curBooking.BookingID + " [" + curBooking.DateStart.ToString("dd-MM-yyyy") + " " + curBooking.DateStart.ToString("HH:mm") + "-" + curBooking.DateEnd.ToString("HH:mm") + "]" + @"</td> <td>" + toGenerate + @"</td> <td>" + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + @"</td> <td style=""white-space:nowrap;"">" + (curRefHasEmail ? curRefEmail : "Has No Email") + " (" + hrefUpdateEmail + ")" + @"</td> <td>" + curPR.Patient.Person.FullnameWithoutMiddlename + @"</td> </tr>"; } if (curPR.RegisterReferrer.BatchSendAllPatientsTreatmentNotes) { regRefIDsToUpdateDateTimeOfLastBatchSend.Add(curPR.RegisterReferrer.RegisterReferrerID); } } RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes((int[])regRefIDsToUpdateDateTimeOfLastBatchSend.ToArray(typeof(int)), DateTime.Now); return((Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents))); }
protected void FillGrid() { string searchName = ""; if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0) { searchName = Request.QueryString["name_search"]; txtSearchName.Text = Request.QueryString["name_search"]; } bool searchNameOnlyStartsWith = true; if (Request.QueryString["name_starts_with"] != null && Request.QueryString["name_starts_with"].Length > 0) { searchNameOnlyStartsWith = Request.QueryString["name_starts_with"] == "0" ? false : true; chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } else { chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } int orgID = 0; if (Request.QueryString["org"] != null && Regex.IsMatch(Request.QueryString["org"], @"\d{1,10}") && OrganisationDB.Exists(Convert.ToInt32(Request.QueryString["org"]))) { orgID = Convert.ToInt32(Request.QueryString["org"]); } // get count Hashtable countHash = new Hashtable(); Hashtable countDeletedHash = new Hashtable(); DataTable dt_reg_refs = RegisterReferrerDB.GetDataTable(orgID, -1, true, new int[] { 191 }, "", false, "", "", "", false); foreach (DataRow row in dt_reg_refs.Rows) { int org_id = Convert.ToInt32(row["organisation_id"]); if (!Convert.ToBoolean(row["is_deleted"])) { countHash[org_id] = (countHash[org_id] == null) ? 1 : ((int)countHash[org_id]) + 1; } else { countDeletedHash[org_id] = (countDeletedHash[org_id] == null) ? 1 : ((int)countDeletedHash[org_id]) + 1; } } DataTable dt = null; if (Request.QueryString["referrer"] == null) { dt = OrganisationDB.GetDataTable(orgID, chkShowDeleted.Checked, true, true, true, true, false, searchName, searchNameOnlyStartsWith, "191"); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]); dt.Rows[i]["count"] = countHash[org_id] == null ? 0 : (int)countHash[org_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id]; } } else { if (!Regex.IsMatch(Request.QueryString["referrer"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url referrer"); return; } Referrer referrer = ReferrerDB.GetByID(Convert.ToInt32(Request.QueryString["referrer"])); if (referrer == null) { HideTableAndSetErrorMessage("Invalid url referrer"); return; } lblHeading.Text = "Referrer Clinics of " + referrer.Person.FullnameWithoutMiddlename; dt = RegisterReferrerDB.GetDataTable_OrganisationsOf(referrer.ReferrerID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); dt.Columns.Add("is_deleted", typeof(Boolean)); dt.Columns.Add("entity_id", typeof(Int32)); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]); dt.Rows[i]["count"] = countHash[org_id] == null ? 0 : (int)countHash[org_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id]; // update these so when delete/undelete - it removes the connection, not the org dt.Rows[i]["organisation_id"] = dt.Rows[i]["register_referrer_id"]; dt.Rows[i]["is_deleted"] = dt.Rows[i]["register_referrer_is_deleted"]; dt.Rows[i]["entity_id"] = dt.Rows[i]["organisation_entity_id"]; } } // add suburb_name Hashtable entityIDsHash = new Hashtable(); for (int i = 0; i < dt.Rows.Count; i++) { entityIDsHash[Convert.ToInt32(dt.Rows[i]["entity_id"])] = 1; } int[] entityIDs = new int[entityIDsHash.Keys.Count]; entityIDsHash.Keys.CopyTo(entityIDs, 0); Hashtable emailHash = PatientsContactCacheDB.GetBullkAddress(entityIDs, -1); dt.Columns.Add("suburb_name", typeof(string)); for (int i = 0; i < dt.Rows.Count; i++) { int entityID = Convert.ToInt32(dt.Rows[i]["entity_id"]); string suburbName = GetSuburb(emailHash, entityID); dt.Rows[i]["suburb_name"] = suburbName == null ? "" : suburbName; } Session["referrerinfoclinic_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfoclinic_sortexpression"] != null && Session["referrerinfoclinic_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfoclinic_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } if (Request.QueryString["referrer"] != null) { GrdReferrer.FooterRow.Visible = false; GrdReferrer.Columns[GrdReferrer.Columns.Count - 2].Visible = false; } }
protected void FillGrid_Patients(Type type, int id) { UserView userView = UserView.GetInstance(); DataTable dt = null; if (type == typeof(Organisation)) { Organisation org = OrganisationDB.GetByID(id); lblPatientsHeading.Text = "Patients of <big><b>All Referrers</b></big> at <big><b>" + org.Name + "</b></big>"; if (userView.IsAdminView && userView.IsClinicView) { dt = PatientDB.GetDataTable(false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", "", "", id.ToString(), false, false, false); } if (userView.IsAdminView && !userView.IsClinicView) { dt = RegisterPatientDB.GetDataTable_PatientsOfOrgGroupType(false, "6", false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", "", "", id.ToString(), false, false, false); } if (!userView.IsAdminView) { dt = RegisterPatientDB.GetDataTable_PatientsOf(false, Convert.ToInt32(Session["OrgID"]), false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", "", "", id.ToString(), false, false, false); } } else if (type == typeof(RegisterReferrer)) { RegisterReferrer regRef = RegisterReferrerDB.GetByID(id); lblPatientsHeading.Text = "Patients of <big><b>" + regRef.Referrer.Person.FullnameWithoutMiddlename + "</b></big> at <big><b>" + regRef.Organisation.Name + "</b></big>"; if (userView.IsAdminView && userView.IsClinicView) { dt = PatientDB.GetDataTable(false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", id.ToString(), "", "", false, false, false); } if (userView.IsAdminView && !userView.IsClinicView) { dt = RegisterPatientDB.GetDataTable_PatientsOfOrgGroupType(false, "6", false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", id.ToString(), "", "", false, false, false); } if (!userView.IsAdminView) { dt = RegisterPatientDB.GetDataTable_PatientsOf(false, Convert.ToInt32(Session["OrgID"]), false, false, userView.IsClinicView, false, "", false, "", false, "", "", "", "", "", false, -1, -1, -1, "", "", id.ToString(), "", "", false, false, false); } } else { SetErrorMessage("Unknown type: " + type.ToString()); return; } lblPatientsHeading.Visible = true; GrdPatients.Visible = true; // put in epc info into the table in a bulk call // epc exp date, if valid, how many epc's remaining... int[] patientIDs = new int[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { patientIDs[i] = Convert.ToInt32(dt.Rows[i]["patient_id"]); } int MedicareMaxNbrServicesPerYear = Convert.ToInt32(SystemVariableDB.GetByDescr("MedicareMaxNbrServicesPerYear").Value); Hashtable patientsMedicareCountThisYearCache = PatientsMedicareCardCountThisYearCacheDB.GetBullk(patientIDs, DateTime.Today.Year); Hashtable patientsMedicareCountNextYearCache = PatientsMedicareCardCountThisYearCacheDB.GetBullk(patientIDs, DateTime.Today.Year + 1); Hashtable patientsEPCRemainingCache = PatientsEPCRemainingCacheDB.GetBullk(patientIDs, DateTime.MinValue); dt.Columns.Add("epc_signed_date", typeof(DateTime)); dt.Columns.Add("epc_expiry_date", typeof(DateTime)); dt.Columns.Add("epc_n_services_left", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int patientID = Convert.ToInt32(dt.Rows[i]["patient_id"]); int totalServicesAllowedLeft = (MedicareMaxNbrServicesPerYear - (int)patientsMedicareCountThisYearCache[patientID]); Pair totalEPCRemaining = patientsEPCRemainingCache[patientID] as Pair; int nServicesLeft = 0; if (totalEPCRemaining != null) { DateTime referralSignedDate = (DateTime)totalEPCRemaining.Second; DateTime hcExpiredDate = referralSignedDate.AddYears(1); if (DateTime.Today >= referralSignedDate.Date && DateTime.Today < hcExpiredDate.Date) { nServicesLeft = (int)totalEPCRemaining.First; } if (totalServicesAllowedLeft < nServicesLeft) { nServicesLeft = totalServicesAllowedLeft; } dt.Rows[i]["epc_signed_date"] = referralSignedDate; dt.Rows[i]["epc_expiry_date"] = hcExpiredDate; dt.Rows[i]["epc_n_services_left"] = nServicesLeft; } else { dt.Rows[i]["epc_signed_date"] = DBNull.Value; dt.Rows[i]["epc_expiry_date"] = DBNull.Value; dt.Rows[i]["epc_n_services_left"] = DBNull.Value; } } Session["referrerinfoclinic_patients_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfoclinic_patients_sortexpression"] != null && Session["referrerinfoclinic_patients_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfoclinic_patients_sortexpression"].ToString(); GrdPatients.DataSource = dataView; } else { GrdPatients.DataSource = dt; } try { GrdPatients.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdPatients.DataSource = dt; GrdPatients.DataBind(); int TotalColumns = GrdPatients.Rows[0].Cells.Count; GrdPatients.Rows[0].Cells.Clear(); GrdPatients.Rows[0].Cells.Add(new TableCell()); GrdPatients.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdPatients.Rows[0].Cells[0].Text = "No Patients"; } }
protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { DropDownList ddlTitle = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewTitle"); TextBox txtName = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewName"); TextBox txtABN = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewABN"); TextBox txtACN = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewACN"); OrganisationDB.InsertExtOrg(191, txtName.Text, txtACN.Text, txtABN.Text, false, false, "", ""); FillGrid(); } if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete")) { try { // if getting orgs of a referer, set the reg-ref relationship as active/inactive if (Request.QueryString["referrer"] != null) { int reg_ref_id = Convert.ToInt32(e.CommandArgument); if (e.CommandName.Equals("_Delete")) { RegisterReferrerDB.UpdateInactive(reg_ref_id); } else { RegisterReferrerDB.UpdateActive(reg_ref_id); } } // if getting all orgs, set the org as active/inactive else { int org_id = Convert.ToInt32(e.CommandArgument); if (e.CommandName.Equals("_Delete")) { OrganisationDB.UpdateInactive(org_id); } else { OrganisationDB.UpdateActive(org_id); } } } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { SetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); } if (e.CommandName.Equals("ViewPatients")) { int id = Convert.ToInt32(e.CommandArgument); if (Request.QueryString["referrer"] == null) { FillGrid_Patients(typeof(Organisation), id); } else { FillGrid_Patients(typeof(RegisterReferrer), id); } } }
protected void btnPrint_Click(object sender, EventArgs e) { try { decimal smsBalance = SMSCreditDataDB.GetTotal() - SMSHistoryDataDB.GetTotal(); decimal smsCost = Convert.ToDecimal(SystemVariableDB.GetByDescr("SMSPrice").Value); int maxSMSCountCanAfford = smsCost == 0 ? 1000000 : (int)(smsBalance / smsCost); int smsCountSending = 0; // // Start Validation // txtEmailSubject.Text = txtEmailSubject.Text.Trim(); txtEmailForPrinting.Text = txtEmailForPrinting.Text.Trim(); txtSMSText.Text = txtSMSText.Text.Trim(); bool printSelected = (ddlBothMobileAndEmail.SelectedValue == "1" || ddlEmailNoMobile.SelectedValue == "1" || ddlMobileNoEmail.SelectedValue == "1" || ddlNeitherMobileOrEmail.SelectedValue == "1"); bool emailSelected = (ddlBothMobileAndEmail.SelectedValue == "2" || ddlEmailNoMobile.SelectedValue == "2" || ddlMobileNoEmail.SelectedValue == "2" || ddlNeitherMobileOrEmail.SelectedValue == "2"); bool smsSelected = (ddlBothMobileAndEmail.SelectedValue == "3" || ddlEmailNoMobile.SelectedValue == "3" || ddlMobileNoEmail.SelectedValue == "3" || ddlNeitherMobileOrEmail.SelectedValue == "3"); string validationErrors = string.Empty; if (printSelected) { if (txtEmailForPrinting.Text.Length == 0) { validationErrors += "<li>Printed Batch Letters Email Address To Send To can not be empty.</li>"; } else if (!Utilities.IsValidEmailAddress(txtEmailForPrinting.Text)) { validationErrors += "<li>Printed Batch Letters Email Address To Send To must look like a valid email address.</li>"; } } if (emailSelected) { if (txtEmailSubject.Text.Length == 0) { validationErrors += "<li>Email Subject can not be empty.</li>"; } if (FreeTextBox1.Text.Length == 0) { validationErrors += "<li>Email Text can not be empty.</li>"; } } if (smsSelected) { if (smsCost > 0 && smsBalance == 0) { validationErrors += "<li>Can not send SMS's - your SMS balance is empty. Please topup or unselect sending by SMS.</li>"; } else if (txtSMSText.Text.Length == 0) { validationErrors += "<li>SMS Text can not be empty.</li>"; } } if (validationErrors.Length > 0) { throw new CustomMessageException("<ul>" + validationErrors + "</ul>"); } // // End Validation // // // get hashtables of those with mobiles and emails // ArrayList regRefIDsArr = new ArrayList(); foreach (ListItem referrerItem in lstReferrers.Items) // regrefid { if (referrerItem.Selected) { regRefIDsArr.Add(Convert.ToInt32(referrerItem.Value)); } } int[] regRefIDs = (int[])regRefIDsArr.ToArray(typeof(int)); int[] entityIDs = RegisterReferrerDB.GetOrgEntityIDs(regRefIDs); Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs); Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs); Hashtable emailHash = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1); Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30"); string email_from_address = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value; string email_from_name = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value; //bool StoreLettersHistoryInDB = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInDB"]); //bool StoreLettersHistoryInFlatFile = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInFlatFile"]); bool StoreLettersHistoryInDB = false; // don't store bulk marketing letters bool StoreLettersHistoryInFlatFile = false; // don't store bulk marketing letters // // ok start the sending process // int bulkLetterSendingQueueBatchID = UseBulkLetterSender ? BulkLetterSendingQueueBatchDB.Insert(txtEmailForPrinting.Text, false) : -1; // TODO: Send Letter By Email int letterPrintHistorySendMethodID = 1; // send by mail // make sure at least one referrer selected if (lstReferrers.GetSelectedIndices().Length == 0) { throw new CustomMessageException("Please select at least one referrer."); } // make sure at least one letter selected if (lstLetters.GetSelectedIndices().Length == 0) { throw new CustomMessageException("Please select a letter."); } // get letter and make sure it exists Letter letter = LetterDB.GetByID(Convert.ToInt32(lstLetters.SelectedValue)); string sourchTemplatePath = letter.GetFullPath(Convert.ToInt32(Session["SiteID"])); if (!File.Exists(sourchTemplatePath)) { throw new CustomMessageException("File doesn't exist."); } // get temp directory string tmpLettersDirectory = Letter.GetTempLettersDirectory(); if (!Directory.Exists(tmpLettersDirectory)) { throw new CustomMessageException("Temp letters directory doesn't exist"); } // delete old tmp files FileHelper.DeleteOldFiles(tmpLettersDirectory, new TimeSpan(1, 0, 0)); // create individual merged docs and put into list of docsToMerge - only if there is an org-patient relationship ArrayList docsToMerge = new ArrayList(); Site site = SiteDB.GetByID(Convert.ToInt32(Session["SiteID"])); int StaffID = Convert.ToInt32(Session["StaffID"]); foreach (ListItem referrerItem in lstReferrers.Items) { if (!referrerItem.Selected) { continue; } if (UseBulkLetterSender) { int refEntityID = (int)entityIDHash[Convert.ToInt32(referrerItem.Value)]; string refPhoneNumber = GetPhoneNbr(mobileHash, refEntityID, true); string refEmail = GetEmail(emailHash, refEntityID); SendMethod sendMethod = GetSendMethod(refEmail != null, refPhoneNumber != null); RegisterReferrer regRef = RegisterReferrerDB.GetByID(Convert.ToInt32(referrerItem.Value)); if (sendMethod != SendMethod.None) { string text = string.Empty; if (sendMethod == SendMethod.SMS) { text = txtSMSText.Text; } if (sendMethod == SendMethod.Email) { text = FreeTextBox1.Text; } text = ReplaceMergeFields(text, regRefIDHash, Convert.ToInt32(referrerItem.Value)); bool generateLetter = false; if (sendMethod == SendMethod.SMS) { generateLetter = false; } if (sendMethod == SendMethod.Email) { generateLetter = lstLetters.GetSelectedIndices().Length != 0; } if (sendMethod == SendMethod.Print) { generateLetter = true; } if (sendMethod == SendMethod.SMS) // copy to other methods!! { smsCountSending++; } BulkLetterSendingQueueDB.Insert ( bulkLetterSendingQueueBatchID, (int)sendMethod, // bulk_letter_sending_queue_method_id StaffID, // added_by -1, // patient_id regRef.Referrer.ReferrerID, // referrer_id -1, // booking_id (sendMethod == SendMethod.SMS) ? refPhoneNumber : "", // phone_number (sendMethod == SendMethod.Email) ? refEmail : "", // email_to_address "", // email_to_name (sendMethod == SendMethod.Email) ? email_from_address : "", // email_from_address (sendMethod == SendMethod.Email) ? email_from_name : "", // email_from_name text, // text (sendMethod == SendMethod.Email) ? txtEmailSubject.Text : "", // email_subject "", // email_attachment_location false, // email_attachment_delete_after_sending false, // email_attachment_folder_delete_after_sending !generateLetter ? -1 : letter.LetterID, !generateLetter ? false : chkKeepInHistory.Checked && StoreLettersHistoryInDB, !generateLetter ? false : chkKeepInHistory.Checked && StoreLettersHistoryInFlatFile, !generateLetter ? -1 : letterPrintHistorySendMethodID, !generateLetter ? "" : Letter.GetLettersHistoryDirectory(0), !generateLetter ? "" : letter.Docname.Replace(".dot", ".doc"), !generateLetter ? -1 : site.SiteID, 0, // organisation_id -1, // booking id -1, // patient_id !generateLetter ? -1 : Convert.ToInt32(referrerItem.Value), // register_referrer_id_to_use_instead_of_patients_reg_ref !generateLetter ? -1 : StaffID, -1, //healthcardactionid !generateLetter ? "" : sourchTemplatePath, !generateLetter ? "" : tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"), !generateLetter ? false : true, "", // email_letter_extra_pages "", // email_letter_item_seperator "", // sql_to_run_on_completion "" // sql_to_run_on_failure ); } } else { // create doc string tmpSingleFileName = Letter.CreateMergedDocument( letter.LetterID, chkKeepInHistory.Checked && StoreLettersHistoryInDB, chkKeepInHistory.Checked && StoreLettersHistoryInFlatFile, letterPrintHistorySendMethodID, Letter.GetLettersHistoryDirectory(0), letter.Docname.Replace(".dot", ".doc"), site, 0, // org id -1, // booking id -1, // patient id Convert.ToInt32(referrerItem.Value), StaffID, -1, //healthcardactionid sourchTemplatePath, tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"), true); // record name of merged doc docsToMerge.Add(tmpSingleFileName); } } if (UseBulkLetterSender) { if ((smsCountSending * smsCost) > smsBalance) { BulkLetterSendingQueueDB.DeleteByBatchID(bulkLetterSendingQueueBatchID); BulkLetterSendingQueueBatchDB.Delete(bulkLetterSendingQueueBatchID); SetErrorMessage("Not Enough Credit To Send SMS's. Please Top Up You SMS Credit or Choose Methods Other Than SMS."); return; } BulkLetterSendingQueueBatchDB.UpdateReadyToProcess(bulkLetterSendingQueueBatchID, true); SetErrorMessage("Items Added To Sending Queue. View Details <a href='/Letters_PrintBatch_StatusV2.aspx?batch_id=" + bulkLetterSendingQueueBatchID + "'>Here</a>"); } else { // merge all tmp files string tmpFinalFileName = Letter.MergeMultipleDocuments( ((string[])docsToMerge.ToArray(typeof(string))), tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc")); // delete all single tmp files foreach (string file in docsToMerge) { File.Delete(file); } // download the document byte[] fileContents = File.ReadAllBytes(tmpFinalFileName); System.IO.File.Delete(tmpFinalFileName); // 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, letter.Docname.Replace(".dot", ".doc")); } } catch (CustomMessageException cmEx) { SetErrorMessage(cmEx.Message); return; } }
protected void btnUpdateReferrersFromClinic_Click(object sender, EventArgs e) { int orgID = Convert.ToInt32(hiddenUpdateReferrersFromClinic_OrgID.Value); Organisation org = OrganisationDB.GetByID(orgID); if (org != null) { string referrerIDs = hiddenReferrerIDsList.Value; // comma seperated Hashtable referrerIDsHash = new Hashtable(); if (referrerIDs.Length > 0) { foreach (string referrerID in referrerIDs.Split(',')) { referrerIDsHash[Convert.ToInt32(referrerID)] = 1; } } // add all new ones (not including those already in there) RegisterReferrer[] refs = RegisterReferrerDB.GetAllActiveRegRefByPatientsOfInternalOrg(orgID); for (int i = 0; i < refs.Length; i++) { if (referrerIDsHash[refs[i].RegisterReferrerID] == null) { hiddenReferrerIDsList.Value += (hiddenReferrerIDsList.Value.Length == 0 ? "" : ",") + refs[i].RegisterReferrerID; // add to hiddenfield list of id's referrerIDsHash[refs[i].RegisterReferrerID] = 1; // add to hash } } // clear and re-set all (in alphabetical order) ArrayList newList = new ArrayList(); DataTable referrers = RegisterReferrerDB.GetDataTable(); for (int i = 0; i < referrers.Rows.Count; i++) { newList.Add(RegisterReferrerDB.LoadAll(referrers.Rows[i])); } RegisterReferrer[] allReferrers = (RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer)); ArrayList referrersAdded = new ArrayList(); lstReferrers.Items.Clear(); for (int i = 0; i < allReferrers.Length; i++) { if (referrerIDsHash[allReferrers[i].RegisterReferrerID] != null) { string text = allReferrers[i].Referrer.Person.FullnameWithoutMiddlename + " [" + allReferrers[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, allReferrers[i].RegisterReferrerID.ToString())); referrersAdded.Add(allReferrers[i]); } } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( (RegisterReferrer[])referrersAdded.ToArray(typeof(RegisterReferrer)), ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); // ----------------------------------------------- } hiddenUpdateReferrersFromClinic_OrgID.Value = string.Empty; }
protected void FillGrid() { string searchName = ""; if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0) { searchName = Request.QueryString["name_search"]; txtSearchName.Text = Request.QueryString["name_search"]; } bool searchNameOnlyStartsWith = true; if (Request.QueryString["name_starts_with"] != null && Request.QueryString["name_starts_with"].Length > 0) { searchNameOnlyStartsWith = Request.QueryString["name_starts_with"] == "0" ? false : true; chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } else { chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } int referrerID = -1; if (Request.QueryString["referrer"] != null && Regex.IsMatch(Request.QueryString["referrer"], @"\d{1,10}") && ReferrerDB.Exists(Convert.ToInt32(Request.QueryString["referrer"]))) { referrerID = Convert.ToInt32(Request.QueryString["referrer"]); } // get the counts Hashtable countHash = new Hashtable(); Hashtable countDeletedHash = new Hashtable(); DataTable dt_reg_refs = RegisterReferrerDB.GetDataTable(0, referrerID, true, new int[] { 191 }, "", false, "", "", "", false); foreach (DataRow row in dt_reg_refs.Rows) { int referrer_id = Convert.ToInt32(row["referrer_id"]); if (!Convert.ToBoolean(row["is_deleted"])) { countHash[referrer_id] = (countHash[referrer_id] == null) ? 1 : ((int)countHash[referrer_id]) + 1; } else { countDeletedHash[referrer_id] = (countDeletedHash[referrer_id] == null) ? 1 : ((int)countDeletedHash[referrer_id]) + 1; } } DataTable dt = null; if (Request.QueryString["org"] == null) { dt = ReferrerDB.GetDataTable(referrerID, searchName, searchNameOnlyStartsWith, chkShowDeleted.Checked); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int referrer_id = Convert.ToInt32(dt.Rows[i]["referrer_id"]); dt.Rows[i]["count"] = countHash[referrer_id] == null ? 0 : (int)countHash[referrer_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[referrer_id] == null ? 0 : (int)countDeletedHash[referrer_id]; } } else { if (!Regex.IsMatch(Request.QueryString["org"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url org"); return; } Organisation org = OrganisationDB.GetByID(Convert.ToInt32(Request.QueryString["org"])); if (org == null) { HideTableAndSetErrorMessage("Invalid url org"); return; } lblHeading.Text = "Referrers at " + org.Name; dt = RegisterReferrerDB.GetDataTable_ReferrersOf(org.OrganisationID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); dt.Columns.Add("is_deleted", typeof(Boolean)); for (int i = 0; i < dt.Rows.Count; i++) { int referrer_id = Convert.ToInt32(dt.Rows[i]["referrer_id"]); dt.Rows[i]["count"] = countHash[referrer_id] == null ? 0 : (int)countHash[referrer_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[referrer_id] == null ? 0 : (int)countDeletedHash[referrer_id]; // update these so when delete/undelete - it removes the connection, not the referrer dt.Rows[i]["referrer_id"] = dt.Rows[i]["register_referrer_id"]; dt.Rows[i]["is_deleted"] = dt.Rows[i]["register_referrer_is_deleted"]; } } Session["referrerinfoperson_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfoperson_sortexpression"] != null && Session["referrerinfoperson_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfoperson_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } if (Request.QueryString["org"] != null) { GrdReferrer.FooterRow.Visible = false; GrdReferrer.Columns[GrdReferrer.Columns.Count - 2].Visible = false; } }
protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { DropDownList ddlTitle = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewTitle"); TextBox txtFirstname = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewFirstname"); TextBox txtMiddlename = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewMiddlename"); TextBox txtSurname = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewSurname"); DropDownList ddlGender = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewGender"); txtFirstname.Text = txtFirstname.Text.Trim(); txtMiddlename.Text = txtMiddlename.Text.Trim(); txtSurname.Text = txtSurname.Text.Trim(); if (txtSurname.Text.Length == 0) { SetErrorMessage("Surname can not be empty"); return; } if (txtSurname.Text.Length == 0) { SetErrorMessage("Firstname can not be empty"); return; } Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"])); int person_id = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, new DateTime(1900, 1, 1)); ReferrerDB.Insert(person_id); FillGrid(); SetErrorMessage("Added."); } if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete")) { try { // if getting referers of an org, set the reg-ref relationship as active/inactive if (Request.QueryString["org"] != null) { int reg_ref_id = Convert.ToInt32(e.CommandArgument); if (e.CommandName.Equals("_Delete")) { RegisterReferrerDB.UpdateInactive(reg_ref_id); } else { RegisterReferrerDB.UpdateActive(reg_ref_id); } } // if getting all referrers, set the ref as active/inactive else { int referrer_id = Convert.ToInt32(e.CommandArgument); if (e.CommandName.Equals("_Delete")) { ReferrerDB.UpdateInactive(referrer_id); } else { ReferrerDB.UpdateActive(referrer_id); } } } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { SetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); } if (e.CommandName.Equals("ViewPatients")) { int id = Convert.ToInt32(e.CommandArgument); if (Request.QueryString["org"] == null) { FillGrid_Patients(typeof(Referrer), id); } else { FillGrid_Patients(typeof(RegisterReferrer), id); } } }