Пример #1
0
    protected string GetBookingText(Hashtable patientsPhoneNumbersCache, string callCenterPrefix, Booking curBooking, Hashtable patientsHasNotesCache, Hashtable patientsHasMedNotesCache, Hashtable patientsHasMedCondNotesCache, Hashtable patientsFlashingNotesCache, Hashtable patientsOwingCache, bool isShowable, bool isPatientLoggedIn, string bookingTypeText, bool bkHasChangeHistory, bool isfirstSlotOfBooking, bool incOrg, BookingSlot.Type bookingSlotType)
    {
        if (isPatientLoggedIn && !isShowable)
            return Utilities.IsDev() ? "  " : string.Empty;

        bool     IsMobileDevice = Utilities.IsMobileDevice(Request);
        UserView userView       = UserView.GetInstance();
        bool     isProviderViewAndOtherProviderBk = userView.IsProviderView && curBooking.Provider != null && Convert.ToInt32(Session["StaffID"]) != curBooking.Provider.StaffID;
        if (isProviderViewAndOtherProviderBk)
            isShowable = false;

        bool isCollapsed = false; //GetFormIsCollapsed();

        string blankText          = Utilities.IsDev() ? "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>" : "<br/><br/>";
        string blankTextCollapsed = Utilities.IsDev() ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "";

        string unavailableProvText = string.Empty;
        if (curBooking.BookingTypeID == 341 || curBooking.BookingTypeID == 342 || curBooking.BookingTypeID == 36)
        {
            unavailableProvText = (curBooking.IsRecurring) ?
                unavailableProvText = curBooking.RecurringDayOfWeek.ToString() + "'s this time <br /><b>" + curBooking.DateStart.Date.ToString("dd'/'MM'/'yy") + (curBooking.DateEnd == DateTime.MinValue ? " onwards" : " - " + curBooking.DateEnd.AddDays(-1).Date.ToString("dd'/'MM'/'yy")) + "</b>" + (curBooking.Organisation == null ? " <br />*<b>all orgs</b>*" : "") :
                unavailableProvText = "this time" + (curBooking.Organisation == null ? " *<b>all orgs</b>*" : "");
        }

        string unavailabilityReason = curBooking.BookingUnavailabilityReason == null ? "" : "<br /><i>[" + curBooking.BookingUnavailabilityReason.Descr + "]</i>";
        string addedByText = curBooking.AddedBy == null ? "" : "<a href=\"#\" onclick=\"$(this).tooltip().mouseover();return false;\" title=\"Added By " + curBooking.AddedBy.Person.FullnameWithoutMiddlename + " on " + curBooking.DateCreated.ToString("ddd d MMM, yyyy") + "\" style=\"text-decoration:none;\">*</a>";

        if (curBooking.BookingTypeID == 342)
        {
            if (curBooking.Provider != null)
                return isfirstSlotOfBooking && !isCollapsed ? curBooking.Provider.Person.FullnameWithoutMiddlename + " is unavailable " + unavailableProvText + unavailabilityReason + " " + addedByText : (isCollapsed ? blankTextCollapsed : blankText);
            else if (curBooking.Organisation != null)
                return isfirstSlotOfBooking && !isCollapsed ? curBooking.Organisation.Name + " is unavailable " + unavailableProvText + unavailabilityReason + " " + addedByText : (isCollapsed ? blankTextCollapsed : blankText);
            else
                return isfirstSlotOfBooking && !isCollapsed ? "All orgs/providers unavailable " + unavailableProvText + unavailabilityReason + " " + addedByText : (isCollapsed ? blankTextCollapsed : blankText);
        }
        else if (curBooking.BookingTypeID == 341)
            return isfirstSlotOfBooking && !isCollapsed ? curBooking.Provider.Person.FullnameWithoutMiddlename + " is unavailable " + unavailableProvText + unavailabilityReason + " " + addedByText : (isCollapsed ? blankTextCollapsed : blankText);
        else if (curBooking.BookingTypeID == 340)
            return isfirstSlotOfBooking && !isCollapsed ? curBooking.Organisation.Name + " is unavailable this day" : (isCollapsed ? blankTextCollapsed + unavailabilityReason + " " + addedByText : blankText);
        else if (curBooking.BookingTypeID == 36)
            return isfirstSlotOfBooking && !isCollapsed ? curBooking.Provider.Person.FullnameWithoutMiddlename + " is unavailable this time <a href=\"#\" onclick=\"$(this).tooltip().mouseover();return false;\" title=\"Paid Break - Counted In The Hours Worked Report\" style=\"color:inherit;\">(<u>P</u>)</a>" + unavailabilityReason + " " + addedByText : (isCollapsed ? blankTextCollapsed : blankText);
        else if (!isfirstSlotOfBooking)
            return (isCollapsed ? blankTextCollapsed : blankText);
        else
        {
            if (isCollapsed)
                return blankTextCollapsed;

            bool SiteIsClinic   = Convert.ToBoolean(Session["SiteIsClinic"]);
            bool SiteIsAgedCare = Convert.ToBoolean(Session["SiteIsAgedCare"]);
            bool SiteIsGP       = Convert.ToBoolean(Session["SiteIsGP"]);

            if (curBooking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 6 && curBooking.Patient == null) // aged care
            {
                ArrayList orgTreeBranch = new ArrayList();

                Organisation org = curBooking.Organisation;
                orgTreeBranch.Add(org);
                while (org.ParentOrganisation != null)
                {
                    org = org.ParentOrganisation;
                    orgTreeBranch.Add(org);
                }

                string text = string.Empty;
                for (int i = orgTreeBranch.Count - 1; i >= 0; i--)
                    text += (text.Length == 0 ? "" : "<br />") + "&nbsp;・ " + ((Organisation)orgTreeBranch[i]).Name;

                return text;
            }
            else if (curBooking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 6 && curBooking.Patient != null)
            {

                bool includeOrg = incOrg;
                bool incProvider = false;

                string notesText = string.Empty;
                if (curBooking.Patient != null)
                    notesText             = Note.GetBookingPopupLinkTextV2(curBooking.EntityID, curBooking.NoteCount > 0, true, 1425, 700, "images/notes-bw-24-Thin.png", "images/notes-24-Thin.png", null, !IsMobileDevice);
                //string notesText        = Note.GetPopupLinkTextV2(15, curBooking.EntityID, curBooking.NoteCount > 0, true, 980, 530, "images/notes-bw-24-Thin.png", "images/notes-24-Thin.png", null, !IsMobileDevice);
                bool   ptHasNotes         = patientsHasNotesCache[curBooking.Patient.Person.EntityID] != null;
                string ptNotesText        = Note.GetPopupLinkTextV2(16, curBooking.Patient.Person.EntityID, ptHasNotes, true, 1425, 640, "images/BC-24-Thin-bw.png", "images/BC-24-Thin.png", null, !IsMobileDevice);
                bool   ptHasMedsNotes     = patientsHasMedNotesCache[curBooking.Patient.Person.EntityID] != null;
                string ptMedsNotesText    = Note.GetPopupLinkTextV2(17, curBooking.Patient.Person.EntityID, ptHasMedsNotes, true, 1050, 530, "images/M-24-Thin-bw.png", "images/M-24-Thin.png", null, !IsMobileDevice);
                bool   ptHasMedCondNotes  = patientsHasMedCondNotesCache[curBooking.Patient.Person.EntityID] != null;
                string ptMedCondNotesText = Note.GetPopupLinkTextV2(18, curBooking.Patient.Person.EntityID, ptHasMedCondNotes, true, 1050, 530, "images/MC-24-Thin-bw.png", "images/MC-24-Thin.png", null, !IsMobileDevice);

                bool hasArrived = curBooking.ArrivalTime != DateTime.MinValue;
                string jsArrivedText = hasArrived ?
                                            "javascript:ajax_booking_confirm_delete_cancel('unarrived', '" + curBooking.BookingID.ToString() + "');" :
                                            "javascript:ajax_booking_confirm_delete_cancel('arrived', '" + curBooking.BookingID.ToString() + "');";
                string imgArrivedText = "images/person2colour-24.png";
                string setArrivedText = "<input type=\"image\" title=\"" + (hasArrived ? "Unset Arrived" : "Set Arrived") + "\" src=\"" + imgArrivedText + "\" alt=\"" + (hasArrived ? "Unset Arrived" : "Set Arrived") + "\" onclick=\"" + jsArrivedText + "\" />";
                if (curBooking.ArrivalTime != DateTime.MinValue)
                    setArrivedText += "&nbsp;<b>" + curBooking.ArrivalTime.ToString("HH:mm") + "</b>";

                bool isConfirmed = curBooking.DateConfirmed != DateTime.MinValue;
                string jsConfirmedText = isConfirmed ?
                                            "javascript:ajax_booking_confirm_delete_cancel('unconfirm', '" + curBooking.BookingID.ToString() + "');" :
                                            "javascript:ajax_booking_confirm_delete_cancel('confirm', '" + curBooking.BookingID.ToString() + "');";
                string imgConfirmedText = isConfirmed ? "images/tick2color-24.png" : "images/tick2bw-24.png";
                string setConfirmedText = "<input type=\"image\" title=\"" + (isConfirmed ? "Set Unconfirmed" : "Set Confirmed") + "\" src=\"" + imgConfirmedText + "\" alt=\"" + (isConfirmed ? "Set Unconfirmed" : "Set Confirmed") + "\" onclick=\"" + jsConfirmedText + "\" />";

                bool   hasFlashingNote = patientsFlashingNotesCache[curBooking.Patient.PatientID] != null;
                string flashingNote    = hasFlashingNote ? (string)patientsFlashingNotesCache[curBooking.Patient.PatientID] : string.Empty;
                string flasingTextIcon = Patient.GetFlashingTextLink(curBooking.Patient.PatientID, hasFlashingNote, flashingNote, true, 525, 275, "images/asterisk_bw_16.png", "images/asterisk_red_16.gif", null, !IsMobileDevice);

                bool   hasOwing  = patientsOwingCache[curBooking.Patient.PatientID] != null;
                string owingText = hasOwing ? "<b><font color=\"red\">Owes $" + Convert.ToDecimal(patientsOwingCache[curBooking.Patient.PatientID]).ToString("0.00") + "</font></b>" : string.Empty;

                //string printLetterJS = "javascript:window.location.href='Letters_PrintV2.aspx?booking="+curBooking.BookingID+"';return false;";
                //string printLetterImg = "images/printer_green-24.png";
                //string printLetterText = "<input type=\"image\" title=\"Print Letter\" src=\"" + printLetterImg + "\" alt=\"Print Letter\" onclick=\"" + printLetterJS + "\" />";

                string preferredNbr = string.Empty;
                if (curBooking.Patient != null)
                {
                    if (Utilities.GetAddressType().ToString() == "Contact")
                    {
                        Contact[] phoneNbrs = GetPatientsPhoneNumbersFromCache(patientsPhoneNumbersCache, curBooking.Patient.Person.EntityID);
                        if (phoneNbrs != null && phoneNbrs.Length > 0)
                        {
                            preferredNbr = phoneNbrs[0].PhoneNumberWithDashes;

                            bool curIsMobile = phoneNbrs[0].ContactType.ContactTypeID == 30;

                            for (int i = 1; i < phoneNbrs.Length; i++)
                            {
                                if (phoneNbrs[i].ContactType.ContactTypeID == 30 && !curIsMobile)
                                {
                                    curIsMobile = phoneNbrs[i].ContactType.ContactTypeID == 30;
                                    preferredNbr = phoneNbrs[i].PhoneNumberWithDashes;
                                }
                            }
                        }
                    }
                    else if (Utilities.GetAddressType().ToString() == "ContactAus")
                    {
                        ContactAus[] phoneNbrs = GetPatientsPhoneNumbersFromAusCache(patientsPhoneNumbersCache, curBooking.Patient.Person.EntityID);
                        if (phoneNbrs != null && phoneNbrs.Length > 0)
                        {
                            preferredNbr = phoneNbrs[0].PhoneNumberWithDashes;

                            bool curIsMobile = phoneNbrs[0].ContactType.ContactTypeID == 30;

                            for (int i = 1; i < phoneNbrs.Length; i++)
                            {
                                if (phoneNbrs[i].ContactType.ContactTypeID == 30 && !curIsMobile)
                                {
                                    curIsMobile = phoneNbrs[i].ContactType.ContactTypeID == 30;
                                    preferredNbr = phoneNbrs[i].PhoneNumberWithDashes;
                                }
                            }
                        }
                    }
                    else
                        throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                if (preferredNbr.Length > 0 && callCenterPrefix.Length > 0)
                    preferredNbr = callCenterPrefix + " " + preferredNbr;

                int      loggedInStaffID   = Session["StaffID"]       == null ? -1 : Convert.ToInt32(Session["StaffID"]);
                bool     canSeePatientLink = userView.IsAdminView || userView.IsPrincipal || (curBooking.Patient != null && curBooking.Provider != null && curBooking.Provider.StaffID == loggedInStaffID);

                string ptURL = "PatientDetailV2.aspx?type=view&id=" + curBooking.Patient.PatientID;
                //string patientLink = curBooking.Patient == null ? "" : (canSeePatientLink ? flasingTextIcon + " " + "<a href=\"#\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + curBooking.Patient.PatientID + "', 1750, 1000);return false;\">" + curBooking.Patient.Person.FullnameWithoutMiddlename + (curBooking.Patient.Person.Nickname.Trim().Length == 0 ? "" : " (" + curBooking.Patient.Person.Nickname.Trim() + ")") + "</a><br />" : "<b>" + curBooking.Patient.Person.FullnameWithoutMiddlename + "</b><br />");
                string patientLink = curBooking.Patient == null ? "" : (canSeePatientLink ? flasingTextIcon + " " + "<a href=\"" + ptURL + "\" onclick=\"var win=window.open('" + ptURL + "', '_blank'); win.focus();return false;\">" + curBooking.Patient.Person.FullnameWithoutMiddlename + (curBooking.Patient.Person.Nickname.Trim().Length == 0 ? "" : " (" + curBooking.Patient.Person.Nickname.Trim() + ")") + "</a><span style=\"color:transparent;\">-</span>" + (curBooking.Patient.Person.Dob == DateTime.MinValue ? "" : "(" + Utilities.GetAge(curBooking.Patient.Person.Dob) + ")") + "<br />" : "<b>" + curBooking.Patient.Person.FullnameWithoutMiddlename + "</b><br />");

                bool isCancelled = curBooking.BookingStatus.ID == 188;
                bool notYetCompleted = curBooking.BookingStatus.ID == 0;

                return
                    //(!isShowable || isPatientLoggedIn || userView.IsExternalView ? "" : (isShowable && !isPatientLoggedIn ? notesText + "&nbsp;" + ptNotesText + "&nbsp;" +  (SiteIsGP ? ptMedsNotesText + "&nbsp;" : "") : "") : "") + (notYetCompleted ? setConfirmedText + "&nbsp;" + setArrivedText : "") + "<br/>") +
                    //(bookingTypeText.Length > 0 ? bookingTypeText + "<br/>" : "") +

                    (isCancelled                                     ? "<b>[Cancelled" + (curBooking.InvoiceCount > 0 ? "" : " - No Inv") + "]</b><br/>" : "") +
                    (!includeOrg  || curBooking.Organisation == null ? "" : "<i>[" + curBooking.Organisation.Name + "]</i><br/>") +
                    (!incProvider || curBooking.Provider == null     ? "" : curBooking.Provider.Person.FullnameWithoutMiddlename + "<br/>") +
                    (curBooking.Patient == null || !curBooking.Patient.IsDiabetic || isPatientLoggedIn ? "" : "<font color=\"blue\"><b><i>PT is Diabetic</i></b></font><br/>") +
                    patientLink +
                    (preferredNbr        == string.Empty             ? "" : preferredNbr + "<br/>") +
                    (curBooking.Offering == null                     ? "" : curBooking.Offering.Name) +
                    (!isShowable || (!userView.IsProvider && !userView.IsAdminView) || !hasOwing  || curBooking.Offering == null ? "" : "<br />" + owingText);
            }
            else // clinics
            {
                bool includeOrg = incOrg;
                bool incProvider = false;

                string notesText          = String.Empty;
                string ptNotesText        = String.Empty;
                string ptMedsNotesText    = String.Empty;
                string ptMedCondNotesText = String.Empty;
                string ptFilesText        = String.Empty;

                notesText = Note.GetBookingPopupLinkTextV2(curBooking.EntityID, curBooking.NoteCount > 0, true, 1425, 700, "images/notes-bw-24-Thin.png", "images/notes-24-Thin.png", null, !IsMobileDevice);

                if (curBooking.Patient != null)
                {
                    //string notesText       = Note.GetPopupLinkTextV2(15, curBooking.EntityID, curBooking.NoteCount > 0, true, 980, 530, "images/notes-bw-24-Thin.png", "images/notes-24-Thin.png", null, !IsMobileDevice);
                    bool   ptHasNotes        = patientsHasNotesCache[curBooking.Patient.Person.EntityID] != null;
                    ptNotesText              = Note.GetPopupLinkTextV2(16, curBooking.Patient.Person.EntityID, ptHasNotes,        true, 1270, 640, "images/BC-24-Thin-bw.png", "images/BC-24-Thin.png", null, !IsMobileDevice);
                    bool   ptHasMedsNotes    = patientsHasMedNotesCache[curBooking.Patient.Person.EntityID] != null;
                    ptMedsNotesText          = Note.GetPopupLinkTextV2(17, curBooking.Patient.Person.EntityID, ptHasMedsNotes,    true, 1050,  530, "images/M-24-Thin-bw.png",  "images/M-24-Thin.png",  null, !IsMobileDevice);
                    bool   ptHasMedCondNotes = patientsHasMedCondNotesCache[curBooking.Patient.Person.EntityID] != null;
                    ptMedCondNotesText       = Note.GetPopupLinkTextV2(18, curBooking.Patient.Person.EntityID, ptHasMedCondNotes, true, 1050,  530, "images/MC-24-Thin-bw.png", "images/MC-24-Thin.png", null, !IsMobileDevice);
                    ptFilesText              = curBooking.GetScannedDocsImageLink();
                }

                bool hasArrived = curBooking.ArrivalTime != DateTime.MinValue;
                string jsArrivedText = hasArrived ?
                                            "javascript:ajax_booking_confirm_delete_cancel('unarrived', '" + curBooking.BookingID.ToString() + "');" :
                                            "javascript:ajax_booking_confirm_delete_cancel('arrived', '" + curBooking.BookingID.ToString() + "');";
                string imgArrivedText = "images/person2colour-24.png";
                string setArrivedText = "<input type=\"image\" title=\"" + (hasArrived ? "Unset Arrived" : "Set Arrived") + "\" src=\"" + imgArrivedText + "\" alt=\"" + (hasArrived ? "Unset Arrived" : "Set Arrived") + "\" onclick=\"" + jsArrivedText + "\" />";
                if (curBooking.ArrivalTime != DateTime.MinValue)
                    setArrivedText += "&nbsp;<b>" + curBooking.ArrivalTime.ToString("HH:mm") + "</b>";

                bool isConfirmed = curBooking.DateConfirmed != DateTime.MinValue;
                string jsConfirmedText = isConfirmed ?
                                            "javascript:ajax_booking_confirm_delete_cancel('unconfirm', '" + curBooking.BookingID.ToString() + "');" :
                                            "javascript:ajax_booking_confirm_delete_cancel('confirm', '" + curBooking.BookingID.ToString() + "');";
                string imgConfirmedText = isConfirmed ? "images/tick2color-24.png" : "images/tick2bw-24.png";
                string setConfirmedText = "<input type=\"image\" title=\"" + (isConfirmed ? "Set Unconfirmed" : "Set Confirmed") + "\" src=\"" + imgConfirmedText + "\" alt=\"" + (isConfirmed ? "Set Unconfirmed" : "Set Confirmed") + "\" onclick=\"" + jsConfirmedText + "\" />";

                string flashingNote = String.Empty;
                string flasingTextIcon = String.Empty;
                if (curBooking.Patient != null)
                {
                    bool hasFlashingNote = patientsFlashingNotesCache[curBooking.Patient.PatientID] != null;
                    flashingNote         = hasFlashingNote ? (string)patientsFlashingNotesCache[curBooking.Patient.PatientID] : "";
                    flasingTextIcon      = Patient.GetFlashingTextLink(curBooking.Patient.PatientID, hasFlashingNote, flashingNote, true, 525, 275, "images/asterisk_bw_16.png", "images/asterisk_red_16.gif", null, !IsMobileDevice);
                }

                bool   hasOwing  = false;
                string owingText = string.Empty;
                if (curBooking.Patient != null)
                {
                    hasOwing  = patientsOwingCache[curBooking.Patient.PatientID] != null;
                    owingText = hasOwing ? "<b><font color=\"red\">Owes $" + Convert.ToDecimal(patientsOwingCache[curBooking.Patient.PatientID]).ToString ("0.00") + "</font></b>" : string.Empty;
                }

                //string printLetterJS = "javascript:window.location.href='Letters_PrintV2.aspx?booking="+curBooking.BookingID+"';return false;";
                //string printLetterImg = "images/printer_green-24.png";
                //string printLetterText = "<input type=\"image\" title=\"Print Letter\" src=\"" + printLetterImg + "\" alt=\"Print Letter\" onclick=\"" + printLetterJS + "\" />";

                string preferredNbr = string.Empty;
                if (curBooking.Patient != null)
                {
                    if (Utilities.GetAddressType().ToString() == "Contact")
                    {
                        Contact[] phoneNbrs = GetPatientsPhoneNumbersFromCache(patientsPhoneNumbersCache, curBooking.Patient.Person.EntityID);
                        if (phoneNbrs != null && phoneNbrs.Length > 0)
                        {
                            preferredNbr = phoneNbrs[0].PhoneNumberWithDashes;

                            bool curIsMobile = phoneNbrs[0].ContactType.ContactTypeID == 30;

                            for (int i = 1; i < phoneNbrs.Length; i++)
                            {
                                if (phoneNbrs[i].ContactType.ContactTypeID == 30 && !curIsMobile)
                                {
                                    curIsMobile = phoneNbrs[i].ContactType.ContactTypeID == 30;
                                    preferredNbr = phoneNbrs[i].PhoneNumberWithDashes;
                                }
                            }
                        }
                    }
                    else if (Utilities.GetAddressType().ToString() == "ContactAus")
                    {
                        ContactAus[] phoneNbrs = GetPatientsPhoneNumbersFromAusCache(patientsPhoneNumbersCache, curBooking.Patient.Person.EntityID);
                        if (phoneNbrs != null && phoneNbrs.Length > 0)
                        {
                            preferredNbr = phoneNbrs[0].PhoneNumberWithDashes;

                            bool curIsMobile = phoneNbrs[0].ContactType.ContactTypeID == 30;

                            for (int i = 1; i < phoneNbrs.Length; i++)
                            {
                                if (phoneNbrs[i].ContactType.ContactTypeID == 30 && !curIsMobile)
                                {
                                    curIsMobile = phoneNbrs[i].ContactType.ContactTypeID == 30;
                                    preferredNbr = phoneNbrs[i].PhoneNumberWithDashes;
                                }
                            }
                        }
                    }
                    else
                        throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                if (preferredNbr.Length > 0 && callCenterPrefix.Length > 0)
                    preferredNbr = callCenterPrefix + " " + preferredNbr;

                int  loggedInStaffID   = Session["StaffID"]       == null ? -1 : Convert.ToInt32(Session["StaffID"]);
                bool canSeePatientLink = userView.IsAdminView || userView.IsPrincipal || userView.IsExternal|| (curBooking.Patient != null && curBooking.Provider != null && curBooking.Provider.StaffID == loggedInStaffID);

                string patientLink = string.Empty;
                if (curBooking.Patient != null)
                {
                    string ptURL  = "PatientDetailV2.aspx?type=view&id=" + curBooking.Patient.PatientID;
                    //patientLink = curBooking.Patient == null ? "" : (canSeePatientLink ? flasingTextIcon + " " + "<a href=\"#\" onclick=\"open_new_window('PatientDetailV2.aspx?type=view&id=" + curBooking.Patient.PatientID + "', 1750, 1000);return false;\">" + curBooking.Patient.Person.FullnameWithoutMiddlename + (curBooking.Patient.Person.Nickname.Trim().Length == 0 ? "" : " (" + curBooking.Patient.Person.Nickname.Trim() + ")") + "</a><br />" : "<b>" + curBooking.Patient.Person.FullnameWithoutMiddlename + "</b><br />");
                    patientLink   = curBooking.Patient == null ? "" : (canSeePatientLink ? flasingTextIcon + " " + "<a href=\"" + ptURL + "\" onclick=\"var win=window.open('" + ptURL + "', '_blank'); win.focus();return false;\">" + curBooking.Patient.Person.FullnameWithoutMiddlename + (curBooking.Patient.Person.Nickname.Trim().Length == 0 ? "" : " (" + curBooking.Patient.Person.Nickname.Trim() + ")") + "</a><span style=\"color:transparent;\">-</span>" + (curBooking.Patient.Person.Dob == DateTime.MinValue ? "" : "(" + Utilities.GetAge(curBooking.Patient.Person.Dob) + ")") + "<br />" : "<b>" + curBooking.Patient.Person.FullnameWithoutMiddlename + "</b><br />");
                }

                bool isCancelled = curBooking.BookingStatus.ID == 188;
                bool notYetCompleted = curBooking.BookingStatus.ID == 0;

                // "td_1751_76_2015_02_16_0930"//
                string id = "td_" + curBooking.Organisation.OrganisationID + "_" + curBooking.Provider.StaffID + "_" + curBooking.DateStart.ToString("yyyy_MM_dd_HHmm");

                string firstRow = string.Empty;
                if (isShowable && !isPatientLoggedIn && !userView.IsExternalView && curBooking.Patient != null)
                {
                    firstRow = (bkHasChangeHistory ? curBooking.GetBookingChangeHistoryPopupLinkImage(null, false, !IsMobileDevice) + "&nbsp;" : "") + notesText + "&nbsp;" + (SiteIsGP ? ptMedsNotesText + "&nbsp;" + ptMedCondNotesText + "&nbsp;" : "") + (ptFilesText + "&nbsp;") + (notYetCompleted ? setConfirmedText + "&nbsp;" + setArrivedText : "");
                }
                else // first row still blank
                {
                    if (notYetCompleted && (userView.IsExternalView || isProviderViewAndOtherProviderBk))
                        firstRow += setArrivedText;
                }
                if (firstRow.Length > 0) firstRow += "<br />";

                if (SiteIsAgedCare || SiteIsClinic)
                {
                    return

                        // don't put notes in because the note is not linked to which PT in the group booking, so at end of PT page, it can't show the note only for that PT
                        //(curBooking.Patient == null ? ((userView.IsAdminView || (userView.IsProviderView && !isProviderViewAndOtherProviderBk)) ? notesText + "&nbsp;" : "") + "<font color=\"blue\"><b><i>Group Booking</i></b></font><br/>" : "") +
                        (curBooking.Patient == null ?  "<font color=\"blue\"><b><i>Group Booking</i></b></font><br/>" : "") +
                        firstRow +
                        (bookingTypeText.Length <= 0                                 ? "" : bookingTypeText + "<br/>") +
                        (!isCancelled                                                ? "" : "<b>[Cancelled" + (curBooking.InvoiceCount > 0 ? "" : " - No Inv") + "]</b><br/>") +
                        (!includeOrg  || curBooking.Organisation == null             ? "" : "<i>[" + curBooking.Organisation.Name + "]</i><br/>") +
                        (!incProvider || curBooking.Provider == null                 ? "" : curBooking.Provider.Person.FullnameWithoutMiddlename + "<br/>") +
                        (curBooking.Patient == null || !curBooking.Patient.IsDiabetic || isPatientLoggedIn ? "" : "<font color=\"blue\"><b><i>PT is Diabetic</i></b></font><br/>") +
                        patientLink +
                        (preferredNbr == string.Empty                                ? "" : preferredNbr + "<br/>") +
                        (curBooking.Offering == null                                 ? "" : curBooking.Offering.Name) +
                        (!isShowable || (!userView.IsProvider && !userView.IsAdminView) || !hasOwing || curBooking.Offering == null ? "" : "<br />" + owingText) +
                        (isShowable && bookingSlotType != BookingSlot.Type.None ? "<a href='javascript:void(0)' title=\"Long Click To Show Menu\r\nFor Mouse Without A Right Click Button\" onclick=\"ShowMenu_" + GetContextMenuClass(bookingSlotType, curBooking) + "('" + id + "');return false;\" style=\"text-decoration:none;\">&nbsp;★&nbsp;</a>&nbsp;" : "");
                }
                else
                {
                    return

                        // don't put notes in because the note is not linked to which PT in the group booking, so at end of PT page, it can't show the note only for that PT
                        //(curBooking.Patient == null ? ((userView.IsAdminView || (userView.IsProviderView && !isProviderViewAndOtherProviderBk)) ? notesText + "&nbsp;" : "") + "<font color=\"blue\"><b><i>Group Booking</i></b></font><br/>" : "") +
                        (curBooking.Patient == null ? "<font color=\"blue\"><b><i>Group Booking</i></b></font><br/>" : "") +
                        firstRow +
                        (!isCancelled                                                ? "" : "<b>[Cancelled" + (curBooking.InvoiceCount > 0 ? "" : " - No Inv") + "]</b><br/>") +
                        (!includeOrg  || curBooking.Organisation == null             ? "" : "<i>[" + curBooking.Organisation.Name + "]</i><br/>") +
                        (!incProvider || curBooking.Provider     == null             ? "" : curBooking.Provider.Person.FullnameWithoutMiddlename + "<br/>") +
                        (curBooking.Patient == null || !curBooking.Patient.IsDiabetic || isPatientLoggedIn ? "" : "<font color=\"blue\"><b><i>PT is Diabetic</i></b></font><br/>") +
                        patientLink +
                        (preferredNbr == string.Empty                                ? "" : preferredNbr + "<br/>") +
                        (curBooking.Offering == null                                 ? "" : curBooking.Offering.Name) +
                        (!isShowable || (!userView.IsProvider && !userView.IsAdminView) || !hasOwing  || curBooking.Offering == null ? "" : "<br />" + owingText) +
                        (isShowable && bookingSlotType != BookingSlot.Type.None ? "<a href='javascript:void(0)' onclick=\"ShowMenu_Menu_" + GetContextMenuClass(bookingSlotType, curBooking) + "('" + id + "');return false;\" style=\"text-decoration:none;\">&nbsp;★&nbsp;</a>&nbsp;" : "");
                }

            }
        }
    }