protected void SetBooking() { string booking_patient_id = Request.QueryString["bookingpatient"]; string booking_id = Request.QueryString["booking"]; if (booking_patient_id != null) { if (!Regex.IsMatch(booking_patient_id, @"^\d+$")) { throw new CustomMessageException(); } BookingPatient bookingPatient = BookingPatientDB.GetByID(Convert.ToInt32(booking_patient_id)); if (bookingPatient == null) { throw new CustomMessageException(); } if (bookingPatient.Booking.Organisation == null) { throw new CustomMessageException(); } btnOtherEmail.OnClientClick = "javascript: get_referrer_additional_emails(" + bookingPatient.Patient.PatientID + ");return false;"; // get selected id's ArrayList selectedIDs = new ArrayList(); foreach (RepeaterItem item in lstNotes.Items) { CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote"); Label lblNoteID = (Label)item.FindControl("lblNoteID"); if (chkUseNote.Checked) { selectedIDs.Add(lblNoteID.Text); } } txtUpdatePatientID.Text = bookingPatient.Patient.PatientID.ToString(); txtUpdatePatientName.Text = bookingPatient.Patient.Person.FullnameWithoutMiddlename; txtUpdatePatientName.Visible = false; lblUpdatePatientName.Text = "<a href=\"#=\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + bookingPatient.Patient.PatientID + "'); return false;\">" + bookingPatient.Patient.Person.FullnameWithoutMiddlename + "</a>"; lblUpdatePatientName.Visible = true; txtUpdateOrganisationID.Text = bookingPatient.Booking.Organisation.OrganisationID.ToString(); txtUpdateOrganisationName.Text = bookingPatient.Booking.Organisation.Name; txtUpdateOrganisationName.Visible = false; lblUpdateOrganisationName.Text = "<a href=\"#=\" onclick=\"open_new_window('OrganisationDetailV2.aspx?type=view&id=" + bookingPatient.Booking.Organisation.OrganisationID + "'); return false;\">" + bookingPatient.Booking.Organisation.Name + "</a>"; lblUpdateOrganisationName.Visible = true; // show booking info lnkBookingSheetForPatient.Text = "Booking sheet for " + bookingPatient.Patient.Person.FullnameWithoutMiddlename; lnkBookingSheetForPatient.PostBackUrl = String.Format("~/BookingsV2.aspx?type=patient&patient={0}&org={1}&staff={2}&offering={3}&date={4}", bookingPatient.Patient.PatientID, bookingPatient.Booking.Organisation.OrganisationID, bookingPatient.Booking.Provider.StaffID, bookingPatient.Offering.OfferingID, bookingPatient.Booking.DateStart.ToString("yyyy_MM_dd")); lnkBookingListForPatient.Text = "Booking list for " + bookingPatient.Patient.Person.FullnameWithoutMiddlename; lnkBookingListForPatient.PostBackUrl = String.Format("~/BookingsListV2.aspx?patient={0}", bookingPatient.Patient.PatientID); lblBooking_Provider.Text = bookingPatient.Booking.Provider.Person.FullnameWithoutMiddlename; lblBooking_Offering.Text = bookingPatient.Offering.Name; lblBooking_BookingStatus.Text = bookingPatient.Booking.BookingStatus.Descr.ToString(); lblBooking_Time.Text = bookingPatient.Booking.DateStart.Date.ToString("dd MMM yyyy") + " - " + bookingPatient.Booking.DateStart.ToString("hh:mm") + "-" + bookingPatient.Booking.DateEnd.ToString("hh:mm"); lblBooking_Notes.Text = Note.GetPopupLinkTextV2(15, bookingPatient.EntityID, bookingPatient.NoteCount > 0, true, 1050, 530, "images/notes-bw-24.jpg", "images/notes-24.png"); // display list of notes in repeater DataTable notes = NoteDB.GetDataTable_ByEntityID(bookingPatient.EntityID); lstNotes.DataSource = notes; lstNotes.DataBind(); // check id's that were previously checked foreach (RepeaterItem item in lstNotes.Items) { CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote"); Label lblNoteID = (Label)item.FindControl("lblNoteID"); Label lblOriginalText = (Label)item.FindControl("lblOriginalText"); chkUseNote.Checked = selectedIDs.Contains(lblNoteID.Text); } // hide if got from url ... no need to change it btnPatientListPopup.Visible = false; btnClearPatient.Visible = false; btnOrganisationListPopup.Visible = false; btnClearOrganisation.Visible = false; } else if (booking_id != null) { if (!Regex.IsMatch(booking_id, @"^\d+$")) { throw new CustomMessageException(); } Booking booking = BookingDB.GetByID(Convert.ToInt32(booking_id)); if (booking == null) { throw new CustomMessageException(); } if (booking.Patient != null) { btnOtherEmail.OnClientClick = "javascript: get_referrer_additional_emails(" + booking.Patient.PatientID + ");return false;"; } if (booking.Patient == null) { DataTable dt = BookingPatientDB.GetDataTable_ByBookingID(booking.BookingID); lstBookingPatients.DataSource = dt; lstBookingPatients.DataBind(); main_table.Visible = false; select_booking_patient_table.Visible = true; return; //throw new CustomMessageException(); } if (booking.Organisation == null) { throw new CustomMessageException(); } // get selected id's ArrayList selectedIDs = new ArrayList(); foreach (RepeaterItem item in lstNotes.Items) { CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote"); Label lblNoteID = (Label)item.FindControl("lblNoteID"); if (chkUseNote.Checked) { selectedIDs.Add(lblNoteID.Text); } } txtUpdatePatientID.Text = booking.Patient.PatientID.ToString(); txtUpdatePatientName.Text = booking.Patient.Person.FullnameWithoutMiddlename; txtUpdatePatientName.Visible = false; lblUpdatePatientName.Text = "<a href=\"#=\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + booking.Patient.PatientID + "'); return false;\">" + booking.Patient.Person.FullnameWithoutMiddlename + "</a>"; lblUpdatePatientName.Visible = true; txtUpdateOrganisationID.Text = booking.Organisation.OrganisationID.ToString(); txtUpdateOrganisationName.Text = booking.Organisation.Name; txtUpdateOrganisationName.Visible = false; lblUpdateOrganisationName.Text = "<a href=\"#=\" onclick=\"open_new_window('OrganisationDetailV2.aspx?type=view&id=" + booking.Organisation.OrganisationID + "'); return false;\">" + booking.Organisation.Name + "</a>"; lblUpdateOrganisationName.Visible = true; // show booking info lnkBookingSheetForPatient.Text = "Booking sheet for " + booking.Patient.Person.FullnameWithoutMiddlename; lnkBookingSheetForPatient.PostBackUrl = String.Format("~/BookingsV2.aspx?type=patient&patient={0}&org={1}&staff={2}&offering={3}&date={4}", booking.Patient.PatientID, booking.Organisation.OrganisationID, booking.Provider.StaffID, booking.Offering.OfferingID, booking.DateStart.ToString("yyyy_MM_dd")); lnkBookingListForPatient.Text = "Booking list for " + booking.Patient.Person.FullnameWithoutMiddlename; lnkBookingListForPatient.PostBackUrl = String.Format("~/BookingsListV2.aspx?patient={0}", booking.Patient.PatientID); lblBooking_Provider.Text = booking.Provider.Person.FullnameWithoutMiddlename; lblBooking_Offering.Text = booking.Offering.Name; lblBooking_BookingStatus.Text = booking.BookingStatus.Descr.ToString(); lblBooking_Time.Text = booking.DateStart.Date.ToString("dd MMM yyyy") + " - " + booking.DateStart.ToString("hh:mm") + "-" + booking.DateEnd.ToString("hh:mm"); lblBooking_Notes.Text = Note.GetPopupLinkTextV2(15, booking.EntityID, booking.NoteCount > 0, true, 1050, 530, "images/notes-bw-24.jpg", "images/notes-24.png"); // display list of notes in repeater DataTable notes = NoteDB.GetDataTable_ByEntityID(booking.EntityID); lstNotes.DataSource = notes; lstNotes.DataBind(); // check id's that were previously checked foreach (RepeaterItem item in lstNotes.Items) { CheckBox chkUseNote = (CheckBox)item.FindControl("chkUseNote"); Label lblNoteID = (Label)item.FindControl("lblNoteID"); Label lblOriginalText = (Label)item.FindControl("lblOriginalText"); chkUseNote.Checked = selectedIDs.Contains(lblNoteID.Text); } // hide if got from url ... no need to change it btnPatientListPopup.Visible = false; btnClearPatient.Visible = false; btnOrganisationListPopup.Visible = false; btnClearOrganisation.Visible = false; } }
protected void FillNoteGrid() { if (!IsValidFormID()) { if (!Utilities.IsDev() || Request.QueryString["id"] != null) { HideTableAndSetErrorMessage(); return; } // can still view all if dev and no id set .. but no insert/edit GrdNote.Columns[5].Visible = false; } if (!IsValidFormScreen() && !Utilities.IsDev()) { HideTableAndSetErrorMessage(); return; } DataTable dt = IsValidFormID() ? NoteDB.GetDataTable_ByEntityID(GetFormID(), null, true, true) : NoteDB.GetDataTable(true); if (IsValidFormScreen()) { Hashtable allowedNoteTypes = new Hashtable(); DataTable noteTypes = ScreenNoteTypesDB.GetDataTable_ByScreenID(GetFormScreen()); for (int i = 0; i < noteTypes.Rows.Count; i++) { allowedNoteTypes[Convert.ToInt32(noteTypes.Rows[i]["note_type_id"])] = 1; } for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (allowedNoteTypes[Convert.ToInt32(dt.Rows[i]["note_type_id"])] == null) { dt.Rows.RemoveAt(i); } } } UserView userView = UserView.GetInstance(); bool canSeeModifiedBy = userView.IsStakeholder || userView.IsMasterAdmin; dt.Columns.Add("last_modified_note_info_visible", typeof(Boolean)); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["last_modified_note_info_visible"] = canSeeModifiedBy; } ViewState["noteinfo_data"] = dt; // add note info to hidden field to use when emailing notes string emailBodyText = string.Empty; Booking booking = BookingDB.GetByEntityID(GetFormID()); if (booking != null) { emailBodyText += @"<br /><br /> <u>Treatment Information</u> <br /> <table border=""0"" cellpadding=""0"" cellspacing=""0"">" + (booking.Patient == null ? "" : @"<tr><td>Patient</td><td style=""width:10px;""></td><td>" + booking.Patient.Person.FullnameWithoutMiddlename + @"</td></tr>") + (booking.Offering == null ? "" : @"<tr><td>Service</td><td></td><td>" + booking.Offering.Name + @"</td></tr>") + @" <tr><td>Date</td><td></td><td>" + booking.DateStart.ToString("dd-MM-yyyy") + @"</td></tr> <tr><td>Provider</td><td></td><td>" + booking.Provider.Person.FullnameWithoutMiddlename + @"</td></tr> </table>"; } for (int i = 0; i < dt.Rows.Count; i++) { Note n = NoteDB.Load(dt.Rows[i]); emailBodyText += "<br /><br /><u>Note (" + n.DateAdded.ToString("dd-MM-yyyy") + ")</u><br />" + n.Text.Replace(Environment.NewLine, "<br />"); } emailText.Value = emailBodyText + "<br /><br />" + SystemVariableDB.GetByDescr("LettersEmailSignature").Value;; if (dt.Rows.Count > 0) { if (IsPostBack && ViewState["noteinfo_sortexpression"] != null && ViewState["noteinfo_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = ViewState["noteinfo_sortexpression"].ToString(); GrdNote.DataSource = dataView; } else { GrdNote.DataSource = dt; } try { GrdNote.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdNote.DataSource = dt; GrdNote.DataBind(); int TotalColumns = GrdNote.Rows[0].Cells.Count; GrdNote.Rows[0].Cells.Clear(); GrdNote.Rows[0].Cells.Add(new TableCell()); GrdNote.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdNote.Rows[0].Cells[0].Text = "No Record Found"; } Tuple <string, string, string, string> refsEmailInfo = GetReferrersEmail(); ImageButton btnEmail = GrdNote.HeaderRow.FindControl("btnEmail") as ImageButton; if (refsEmailInfo != null) { btnEmail.Visible = true; ((HiddenField)GrdNote.HeaderRow.FindControl("hiddenRefEmail")).Value = refsEmailInfo.Item1; ((HiddenField)GrdNote.HeaderRow.FindControl("hiddenRefName")).Value = refsEmailInfo.Item2; ((HiddenField)GrdNote.HeaderRow.FindControl("hiddenBookingOrg")).Value = refsEmailInfo.Item3; ((HiddenField)GrdNote.HeaderRow.FindControl("HiddenBookingPatientName")).Value = refsEmailInfo.Item4; } else { btnEmail.Visible = false; } DisallowAddEditIfNoPermissions(); // place this after databinding }