Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging Links not carrying over query results

Status
Not open for further replies.

bberrios

Programmer
Jun 18, 2002
18
US
This is the code on the page.

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<% 'Option Explicit %>
<% Response.Buffer=TRUE 'Turn Buffering on
Response.Expires = -1 'Page expires immediately

'Constants
Const MIN_PAGESIZE = 5 'Minimum pagesize
Const MAX_PAGESIZE = 20 'Maximum pagesize
Const DEF_PAGESIZE = 10 'Default pagesize

'Variables
Dim intRecord 'Current record for paging recordset
Dim intPage 'Requested page
Dim intPageSize 'Requested pagesize

'set/initialize variables
intRecord = 1
blnWhere = False

'Get/set requested page
intPage = MakeLong(Request(&quot;page&quot;))
If intPage < 1 Then intPage = 1

'Get/set requested pagesize
If IsEmpty(Request(&quot;pagesize&quot;)) Then 'Set to default
intPageSize = DEF_PAGESIZE
Else
intPageSize = MakeLong(Request(&quot;pagesize&quot;))
'Make sure it fits our min/max requirements
If intPageSize < MIN_PAGESIZE Then
intPageSize = MIN_PAGESIZE
ElseIf intPageSize > MAX_PAGESIZE Then
intPageSize = MAX_PAGESIZE
End If
End If
%>

<!--#include FILE=&quot;Security_Check.inc&quot; -->
<!-- #include FILE=&quot;URLDecode.inc&quot; -->

<%
'-----------------------------------------------------------
'-- The SELECT statement used for this report is comprised
'-- of a union, with the following 2 parts:
'-- 1) the agency_standard_id field is NOT NULL, in the
'-- standards_cited table (which is the recommendation)
'-- In this case, a link is made to agency_standards
'-- in order to retrieve the primary and secondary codes.
'--
'-- 2) the agency_standard_is field is NULL
'-- The primary and secondary codes are pulled directly
'-- FROM the standards_cited table.
'-----------------------------------------------------------
Dim cbx_visn
Dim cbx_facility
Dim cbx_agency
Dim cbx_primary_issue
Dim cbx_secondary_issue
Dim cbx_standard_number
Dim cbx_standard_description
Dim cbx_recommendation
Dim cbx_recommend_date
Dim cbx_visit_date
Dim cbx_days_to_resolve
Dim cbx_grid_score
Dim cbx_resolution_summary
Dim issue_type_counter
Dim primary_issue_code_criteria_selected_flag
Dim secondary_issue_code_criteria_selected_flag



'----------------------------------------------------------------------
' The checkbox values have been passed to this page.
' Additionally, save the &quot;configuration,&quot; of the
' headings they selected in a cookie.
'----------------------------------------------------------------------
If Request(&quot;cbx_visn&quot;)=&quot;on&quot; Then
cbx_visn=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_visn&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_visn&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_facility&quot;)=&quot;on&quot; Then
cbx_facility=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_facility&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_facility&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_agency&quot;)=&quot;on&quot; Then
cbx_agency=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_agency&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_agency&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_primary_issue&quot;)=&quot;on&quot; Then
cbx_primary_issue=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_primary_issue&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_primary_issue&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_secondary_issue&quot;)=&quot;on&quot; Then
cbx_secondary_issue=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_secondary_issue&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_secondary_issue&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_standard_number&quot;)=&quot;on&quot; Then
cbx_standard_number=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_standard_number&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_standard_number&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_standard_description&quot;)=&quot;on&quot; Then
cbx_standard_description=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_standard_description&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_standard_description&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_recommendation&quot;)=&quot;on&quot; Then
cbx_recommendation=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_recommendation&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_recommendation&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_recommend_date&quot;)=&quot;on&quot; Then
cbx_recommend_date=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_recommend_date&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_recommend_date&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_visit_date&quot;)=&quot;on&quot; Then
cbx_visit_date=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_visit_date&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_visit_date&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_days_to_resolve&quot;)=&quot;on&quot; Then
cbx_days_to_resolve=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_days_to_resolve&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_days_to_resolve&quot;)=&quot;false&quot;
End If

If Request(&quot;cbx_grid_Score&quot;)=&quot;on&quot; Then
cbx_grid_Score=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_grid_score&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_grid_score&quot;)=&quot;false&quot;
End If


If Request(&quot;cbx_resolution_summary&quot;)=&quot;on&quot; Then
cbx_resolution_summary=&quot;on&quot;
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_resolution_summary&quot;)=&quot;true&quot;
Else
Response.Cookies(&quot;report_configuration&quot;)(&quot;cbx_resolution_summary&quot;)=&quot;false&quot;
End If


Response.Cookies(&quot;report_configuration&quot;).Path=&quot;/&quot;
Response.Cookies(&quot;report_configuration&quot;).Expires = DateAdd(&quot;m&quot;, 12, Now)
%>

<!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>

<head>
<!-- #include FILE=&quot;menu_style.inc&quot; -->
<title>Health Care Improvement Registry</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;intranet_styles.css&quot;>
</head>

<!-- This page is constructed using a table to divide the menu FROM the contents. -->
<!-- The table definition is defined in a file which is included here. -->

<body class=&quot;report&quot;>

<!--#include FILE=&quot;Adovbs.inc&quot; -->
<%
Dim rs, rs1, rs2, rs3, rs4, rs5, rs_keyword
Dim SQLStr_select1
Dim SQLStr_where1A
Dim SQLStr_where1B
Dim SQLStr_select2
Dim SQLStr_where2
Dim SQL_final
Dim SQLStr_lookup

Dim primary_issue_name, secondary_issue_name, agency_id, agency_short_name
Dim agency_standard_number, agency_standard, comptime, agency
Dim va_facility_name, va_city, va_state, va_facility_id
Dim survey_id, visit_date, survey_acronym, visn_id, visn_name, report_date
Dim standard_id, primary_iss_id, secondary_iss_id, VA_Fac_IDs, VISN
Dim StartDt, EndDt, recommendation
Dim s_agency_id, s_agency_short_name, s_primary_issue_id, s_primary_issue_name, s_secondary_issue_id
Dim s_secondary_issue_name, s_VISN_id, s_VISN_name, s_VA_Facility_id, s_VA_Facility_name
Dim grid_score
Dim ls_search_word_clause, search_word, synonym
Dim li_counter
Dim tmp_array, i

'Set Session(&quot;HCIR&quot;) = Nothing
standard_id = Request.form(&quot;Standard&quot;)
primary_iss_id = Request.form(&quot;PrimIss&quot;)
secondary_iss_id = Request.form(&quot;SecondIss&quot;)
VISN = Request.form(&quot;Visn&quot;)
agency = Request.form(&quot;Agency&quot;)
StartDt = Request.form(&quot;StartDt&quot;)
EndDt = Request.form(&quot;EndDt&quot;)
visit_date = Request.form(&quot;visit_date&quot;)
search_word = Request.form(&quot;Primary_Keyword&quot;)



' VA_Fac_IDs is coming from a MULTIPLE SELECT. It has the following values:
' - Null if ALL was selected
' - single ID if one option was selected; e.g., 500
' - comma-delimited text if multiple options were selected; e.g., 500, 501

VA_Fac_IDs = Request.form(&quot;VAFac&quot;)

If not isNull(VA_Fac_IDs) and VA_Fac_IDs <> &quot;&quot; and VA_Fac_IDs <> &quot;0&quot; then
tmp_array = split(VA_Fac_IDs, &quot;,&quot;)

For i=0 To UBound(tmp_array)
tmp_array(i) = &quot;'&quot; & Trim(tmp_array(i)) & &quot;'&quot;
Next

VA_Fac_IDs = join(tmp_array, &quot;,&quot;)

'response.write(VA_Fac_IDs)
'response.End()
End If



%>
<!--#include FILE=&quot;main_ODBC.inc&quot; -->
<%
'------------------------------------------------------------------------
' Adding keyword search funcationality. This will pull a list of
' synonyms, based on a master word. A lengthy piece of the where
' clause will then be constructed to look for a match, with each one
' of the synonyms, in the resolution summary field from the
' recommendation screen.
'------------------------------------------------------------------------

IF not IsNull(search_word) and search_word <> &quot;&quot; THEN
set rs_keyword = Server.CreateObject(&quot;ADODB.recordset&quot;)
SQLStr_lookup = &quot;SELECT DISTINCT synonym FROM synonym &quot; & _
&quot; WHERE primary_word ='&quot; & search_word & &quot;' &quot; & _
&quot; UNION &quot; & _
&quot;SELECT DISTINCT primary_word FROM synonym &quot; & _
&quot; WHERE primary_word ='&quot; & search_word & &quot;' &quot;

rs_keyword.open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

If (Not rs_keyword.EOF) Then
NoRecordsFound = false
set synonym = rs_keyword(&quot;synonym&quot;)
ls_search_word_clause = &quot; AND (&quot;

DO until rs_keyword.EOF
li_counter = li_counter + 1

IF li_counter > 1 THEN
ls_search_word_clause = ls_search_word_clause & &quot; OR &quot;
END IF

ls_search_word_clause = ls_search_word_clause & &quot;sc.recommendation LIKE &quot;
ls_search_word_clause = ls_search_word_clause & &quot; ('%&quot; & synonym & &quot;%')&quot;
rs_keyword.movenext
Loop

ls_search_word_clause = ls_search_word_clause & &quot;) &quot;

Else
NoRecordsFound = true
End If

rs_keyword.close


'Added for getting a list of synonyms separate from keywords

if (Not NoRecordsFound) Then
Set rs_synonyms_only = Server.CreateObject(&quot;ADODB.recordset&quot;)
SQLStr_lookup = &quot; SELECT DISTINCT synonym FROM synonym &quot; & _
&quot; WHERE primary_word ='&quot; & search_word & &quot;' &quot;

rs_synonyms_only.open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

If (Not rs_synonyms_only.EOF) Then
Set synonyms_only = rs_synonyms_only(&quot;synonym&quot;)

Do While Not rs_synonyms_only.EOF
ls_synonym_list = ls_synonym_list & trim(synonyms_only) & &quot;, &quot;
rs_synonyms_only.movenext
Loop

If (Not IsNull(ls_synonym_list) and ls_synonym_list <> &quot;&quot;) Then
ls_synonym_list = Mid(ls_synonym_list, 1, Len(ls_synonym_list) - 2)
End If
End If

rs_synonyms_only.close

End If


END IF

SQLStr_select1 = &quot; SELECT r.report_id, r.agency_id, r.va_facility_id, r.visn_id, &quot; & _
&quot; r.report_type, sc.standard_cited_id, &quot; &_
&quot; convert(varchar, r.report_date,101) report_date, &quot; & _
&quot; convert(varchar, r.visit_date,101) visit_date, &quot; & _
&quot; r.report_type, &quot; & _
&quot; DATEDIFF(day, r.report_date, sc.final_resolution_date) completion_timeframe, &quot; &_
&quot; substring(sc.recommendation,1,900) recommendation, &quot; & _
&quot; sc.agency_standard_id, ags.agency_standard_number, &quot; & _
&quot; ags.agency_standard, pi.primary_issue_name, &quot; & _
&quot; si.secondary_issue_name, vf.va_facility_name, &quot; & _
&quot; vf.city_address, vf.state_address, ag.agency_short_name, &quot; &_
&quot; r.grid_score, sc.resolution_summary &quot;

SQLStr_where1A = &quot; FROM report r, standards_cited sc, agency_standard ags, agency ag,&quot; & _
&quot; primary_issue pi, secondary_issue si, va_facility vf &quot; & _
&quot; WHERE r.report_id = sc.report_id &quot; & _
&quot; and r.agency_id = ag.agency_id &quot; & _
&quot; and r.va_facility_id = vf.va_facility_id &quot; & _
&quot; and (sc.agency_standard_id = ags.agency_standard_id &quot; & _
&quot; and ags.primary_issue_id = pi.primary_issue_id &quot; & _
&quot; and ags.secondary_issue_id = si.secondary_issue_id) &quot;

if not isNull(agency) and agency <> &quot;&quot; and agency <> 0 then
SQLStr_where1B = SQLStr_where1B & &quot; and r.agency_id = &quot; & agency
end if

if not isNull(standard_id) and standard_id <> &quot;&quot; and standard_id <> 0 then
SQLStr_where1B = SQLStr_where1B & &quot; and sc.agency_standard_id <> &quot; & standard_id
end if

if not isNull(primary_iss_id) and primary_iss_id <> &quot;&quot; and primary_iss_id <> 0 then
SQLStr_where1B = SQLStr_where1B & &quot; and pi.primary_issue_id = &quot; & primary_iss_id
primary_issue_code_criteria_selected_flag = 1
end if

if not isNull(secondary_iss_id) and secondary_iss_id <> &quot;&quot; and secondary_iss_id <> 0 then
SQLStr_where1B = SQLStr_where1B & &quot; and si.secondary_issue_id = &quot; & secondary_iss_id
secondary_issue_code_criteria_selected_flag = 1
end if

if not isNull(VISN) and VISN <> &quot;&quot; and VISN <> 0 then
SQLStr_where1B = SQLStr_where1B & &quot; and r.VISN_id = &quot; & VISN
end if

if not isNull(VA_Fac_IDs) and VA_Fac_IDs <> &quot;&quot; and VA_Fac_IDs <> &quot;0&quot; then
SQLStr_where1B = SQLStr_where1B & &quot; and r.VA_Facility_id IN (&quot; & VA_Fac_IDs & &quot;) &quot;
end if

if not isNull(StartDt) and StartDt <> &quot;&quot; then
SQLStr_where1B = SQLStr_where1B & &quot; and r.report_date > '&quot; & StartDt & &quot;' &quot;
end if

if not isNull(EndDt) and EndDt <> &quot;&quot; then
SQLStr_where1B = SQLStr_where1B & &quot; and r.report_date < '&quot; & EndDt & &quot;' &quot;
end if

IF ls_search_word_clause <> &quot;&quot; THEN
SQLStr_where1B = SQLStr_where1B & ls_search_word_clause
END IF

SQLStr_select2 = &quot; SELECT r.report_id, r.agency_id, r.va_facility_id, r.visn_id, &quot; & _
&quot; r.report_type, sc.standard_cited_id, &quot; &_
&quot; convert(varchar, r.report_date,101) report_date, &quot; & _
&quot; convert(varchar, r.visit_date,101) visit_date, &quot; &_
&quot; r.report_type, &quot; & _
&quot; DATEDIFF(day, r.report_date, sc.final_resolution_date) completion_timeframe, &quot; &_
&quot; substring(sc.recommendation,1,900) recommendation, &quot; & _
&quot; sc.agency_standard_id, sc.agency_standard_number, sc.agency_standard, &quot; & _
&quot; pi.primary_issue_name, si.secondary_issue_name, vf.va_facility_name, &quot; & _
&quot; vf.city_address, vf.state_address, ag.agency_short_name, &quot; &_
&quot; r.grid_score, sc.resolution_summary &quot;

SQLStr_where2 = &quot; FROM report r, standards_cited sc, agency ag,&quot; & _
&quot; primary_issue pi, secondary_issue si, va_facility vf &quot; & _
&quot; WHERE r.report_id = sc.report_id&quot; & _
&quot; and r.agency_id = ag.agency_id&quot; & _
&quot; and r.va_facility_id = vf.va_facility_id&quot; & _
&quot; and (sc.agency_standard_id is null &quot; & _
&quot; and sc.primary_issue_id = pi.primary_issue_id&quot; & _
&quot; and sc.secondary_issue_id = si.secondary_issue_id) &quot;

SQLStr_final = SQLStr_select1 & &quot; &quot; & SQLStr_where1A & &quot; &quot; & SQLStr_where1B & _
&quot; UNION &quot; & SQLStr_select2 & &quot; &quot; & SQLStr_where2 & &quot; &quot; & SQLStr_where1B

'Response.write(&quot;<HTML><HEAD></HEAD><BODY>&quot; & SQLStr_final & &quot;</BODY></HTML>&quot;)
'Response.end()

set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)
rs.Open SQLStr_final, conn, adOpenStatic, adLockOptimistic

Set report_id = rs(&quot;report_id&quot;)
Set agency_id = rs(&quot;agency_id&quot;)
Set report_type = rs(&quot;report_type&quot;)
Set standard_cited_id = rs(&quot;standard_cited_id&quot;)
Set agency_short_name = rs(&quot;agency_short_name&quot;)
Set va_facility_id = rs(&quot;va_facility_id&quot;)
Set va_facility_name = rs(&quot;va_facility_name&quot;)
Set va_city = rs(&quot;city_address&quot;)
Set va_state = rs(&quot;state_address&quot;)
Set visn_id = rs(&quot;visn_id&quot;)
Set primary_issue_name = rs(&quot;primary_issue_name&quot;)
Set secondary_issue_name = rs(&quot;secondary_issue_name&quot;)
Set agency_standard_id = rs(&quot;agency_standard_id&quot;)
Set agency_standard_number = rs(&quot;agency_standard_number&quot;)
Set agency_standard = rs(&quot;agency_standard&quot;)
Set report_date = rs(&quot;report_date&quot;)
Set visit_date = rs(&quot;visit_date&quot;)
Set comptime = rs(&quot;completion_timeframe&quot;)
Set recommendation = rs(&quot;recommendation&quot;)
Set grid_score = rs(&quot;grid_score&quot;)
Set resolution_summary = rs(&quot;resolution_summary&quot;)

if not isNull(agency) and agency <> &quot;&quot; and agency <> 0 then
set rs1 = Server.CreateObject(&quot;ADODB.recordset&quot;)

SQLStr_lookup = &quot; SELECT agency_id, agency_short_name FROM agency &quot; & _
&quot; WHERE agency_id = &quot; & agency

rs1.Open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

Set s_agency_id = rs1(&quot;agency_id&quot;)
Set s_agency_short_name = rs1(&quot;agency_short_name&quot;)

end if


if not isNull(primary_iss_id) and primary_iss_id <> &quot;&quot; and primary_iss_id <> 0 then
set rs2 = Server.CreateObject(&quot;ADODB.recordset&quot;)

SQLStr_lookup = &quot; SELECT primary_issue_id, primary_issue_name FROM primary_issue &quot; & _
&quot; WHERE primary_issue_id = &quot; & primary_iss_id

rs2.Open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

Set s_primary_issue_id = rs2(&quot;primary_issue_id&quot;)
Set s_primary_issue_name = rs2(&quot;primary_issue_name&quot;)

end if

if not isNull(secondary_iss_id) and secondary_iss_id <> &quot;&quot; and secondary_iss_id <> 0then
set rs3 = Server.CreateObject(&quot;ADODB.recordset&quot;)

SQLStr_lookup = &quot; SELECT secondary_issue_id, secondary_issue_name FROM secondary_issue &quot; & _
&quot; WHERE secondary_issue_id = &quot; & secondary_iss_id

rs3.Open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

Set s_secondary_issue_id = rs3(&quot;secondary_issue_id&quot;)
Set s_secondary_issue_name = rs3(&quot;secondary_issue_name&quot;)

end if

if not isNull(VISN) and VISN <> &quot;&quot; and VISN <> 0 then
set rs4 = Server.CreateObject(&quot;ADODB.recordset&quot;)

SQLStr_lookup = &quot;SELECT VISN_id, VISN_name FROM VISN WHERE VISN_id = &quot; & VISN

rs4.Open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

Set s_VISN_id = rs4(&quot;VISN_id&quot;)
Set s_VISN_name = rs4(&quot;VISN_name&quot;)

end if

if not isNull(VA_Fac_IDs) and VA_Fac_IDs <> &quot;&quot; and VA_Fac_IDs <> &quot;0&quot; then
set rs5 = Server.CreateObject(&quot;ADODB.recordset&quot;)

SQLStr_lookup = &quot; SELECT VA_Facility_id, VA_Facility_name FROM VA_Facility &quot; & _
&quot; WHERE VA_Facility_id IN (&quot; & VA_Fac_IDs & &quot;) &quot;

rs5.Open SQLStr_lookup, conn, adOpenStatic, adLockOptimistic

Set s_VA_Facility_id = rs5(&quot;VA_Facility_id&quot;)
Set s_VA_Facility_name = rs5(&quot;VA_Facility_name&quot;)


rs.close
rs2.close
rs3.close
rs4.close
rs5.close
end if


'Creates a long value from a variant, invalid always set to zero
Function MakeLong(ByVal varValue)
If IsNumeric(varValue) Then
MakeLong = CLng(varValue)
Else
MakeLong = 0
End If
End Function

'Returns a neatly made paging string, automatically configuring for request
'variables, regardless of in querystring or from form.

Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
Dim strQueryString
Dim strScript
Dim intStart
Dim intEnd
Dim strRet
Dim i

'Setting the initial page
If intPage > intPageCount Then
intPage = intPageCount
ElseIf intPage < 1 Then
intPage = 1
End If

'Checking the record count for possible output
If intRecordCount = 0 Then
strRet = &quot;No Records Found&quot;
ElseIf intPageCount = 1 Then
strRet = &quot;End Of Hits&quot;
Else

For i = 1 To Request.QueryString.Count
If LCase(Request.QueryString.Key(i)) <> &quot;page&quot; Then
strQueryString = strQueryString & &quot;&&quot;
strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & &quot;=&quot;
strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
End If
Next

For i = 1 To Request.Form.Count
If LCase(Request.Form.Key(i)) <> &quot;page&quot; Then
strQueryString = strQueryString & &quot;&&quot;
strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & &quot;=&quot;
strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))

End If
Next

If Len(strQueryString) <> 0 Then
strQueryString = &quot;?&quot; & &quot;records=&quot; & intPageSize & &quot;&&quot;
Else
strQueryString = &quot;?&quot;
End If

strScript = Request.ServerVariables(&quot;SCRIPT_NAME&quot;) & strQueryString

If intPage <= 10 Then
intStart = 1
Else
If (intPage Mod 10) = 0 Then
intStart = intPage - 9
Else
intStart = intPage - (intPage Mod 10) + 1
End If
End If


Response.write(&quot;<HTML><HEAD></HEAD><BODY>&quot; & strScript & &quot;</BODY></HTML>&quot;)
Response.write(&quot;<p>&quot;)

intEnd = intStart + 9
If intEnd > intPageCount Then intEnd = intPageCount

strRet = &quot;Page &quot; & intPage & &quot; of &quot; & intPageCount & &quot;: &quot;

If intPage <> 1 Then
strRet = strRet & &quot;<a href=&quot;&quot;&quot; & strScript
strRet = strRet & &quot;page=&quot; & intPage - 1
strRet = strRet & &quot;&quot;&quot;>&lt;&lt;Prev</a> &quot;
End If

For i = intStart To intEnd
If i = intPage Then
strRet = strRet & &quot;<b>&quot; & i & &quot;</b> &quot;
Else
strRet = strRet & &quot;<a href=&quot;&quot;&quot; & strScript
strRet = strRet & &quot;page=&quot; & i
strRet = strRet & &quot;&quot;&quot;>&quot; & i & &quot;</a>&quot;
if i <> intEnd Then strRet = strRet & &quot; &quot;
End If
Next
If intPage <> intPageCount Then
strRet = strRet & &quot; <a href=&quot;&quot;&quot; & strScript
strRet = strRet & &quot;page=&quot; & intPage + 1
strRet = strRet & &quot;&quot;&quot;>Next&gt;&gt;</a> &quot;
End If
End If

Paging = strRet
End Function
%>




<table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr>
<td width=&quot;100%&quot; align=&quot;center&quot;>
<h1 class=&quot;report&quot;>Health Care Improvement Registry</h1><BR>
</td>
</tr>

<tr>
<td width=&quot;100%&quot; align=&quot;center&quot;>

<table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>

<%
if not isNull(agency) and agency <> &quot;&quot; and agency <> 0 then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Agency: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & s_agency_short_name & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(standard_id) and standard_id <> &quot;&quot; and standard_id <> 0 then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Standard:</strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & standard_id & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(primary_iss_id) and primary_iss_id <> &quot;&quot; and primary_iss_id <> 0 then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Primary Issue: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & s_primary_issue_id & &quot;-&quot; & s_primary_issue_name & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(secondary_iss_id) and secondary_iss_id <> &quot;&quot; and secondary_iss_id <> 0 then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Secondary Issue: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & s_secondary_issue_id & &quot;-&quot; & s_secondary_issue_name & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(VISN) and VISN <> &quot;&quot; and VISN <> 0 then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>VISN: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & s_VISN_id & &quot;-&quot; & s_VISN_name & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(VA_Fac_IDs) and VA_Fac_IDs <> &quot;&quot; and VA_Fac_IDs <> &quot;0&quot; then

Dim label_text

If (rs5.RecordCount > 1) Then
label_text = &quot;VA Facilities:&quot; & &quot;&nbsp;&quot;
Else
label_text = &quot;VA Facility:&quot; & &quot;&nbsp;&quot;
End If

Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>&quot; & label_text & &quot;</strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot;)
Response.Write(s_VA_Facility_id & &quot;-&quot; & s_VA_Facility_name)
Response.Write(&quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
rs5.MoveNext

Do While Not rs5.EOF
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td>&quot; & &quot;&nbsp;&quot; & &quot;</td>&quot;)
Response.Write(&quot;<td align='left' width='100%'>&quot;)
Response.Write(s_VA_Facility_id & &quot;-&quot; & s_VA_Facility_name)
Response.Write(&quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
rs5.MoveNext
Loop

end if


if not isNull(StartDt) and StartDt <> &quot;&quot; then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Start of Date Range: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & StartDt & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if


if not isNull(EndDt) and EndDt <> &quot;&quot; then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>End of Date Range: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & EndDt & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if

if not isNull(visit_date) and visit_date <> &quot;&quot; then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Survey Date: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & visit_date & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)
end if

if not isNull(search_word) and search_word <> &quot;&quot; and search_word <> &quot;0&quot; then
Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Summary Keyword: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & search_word & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)

Response.Write(&quot;<tr>&quot;)
Response.Write(&quot;<td align='right' width='30%'><strong>Keyword Synonyms: </strong></td>&quot;)
Response.Write(&quot;<td align='left' width='70%'>&quot; & ls_synonym_list & &quot;</td>&quot;)
Response.Write(&quot;</tr>&quot;)

end if %>

</table>

<BR>
<table>


<tr>
<td width=&quot;100%&quot; align=&quot;center&quot;>

<div>
<%
'-----------------------------------------------------------------------
'This table shows all the headings that were selected on the first screen
'of the report section
'-----------------------------------------------------------------------
%>

<table border=&quot;1&quot; width=&quot;100%&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
<tr>

<% if cbx_visn=&quot;on&quot; then
Response.Write(&quot;<th class='report' align='center'>VISN</th>&quot;)
end if

If cbx_facility=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Facility</th>&quot;)
End If

If cbx_agency=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Agency</th>&quot;)
End If

If cbx_primary_issue = &quot;on&quot; Then
Response.Write(&quot;<th class='report'>Primary Issue</th>&quot;)
End If

If cbx_secondary_issue = &quot;on&quot; Then
Response.Write(&quot;<th class='report'>Secondary Issue</th>&quot;)
End If

If cbx_standard_number =&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Standard Nbr</th>&quot;)
End If

If cbx_standard_description=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Standard</th>&quot;)
End If

If cbx_recommendation=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Recommendation*</th>&quot;)
End If

If cbx_recommend_date = &quot;on&quot; Then
Response.Write(&quot;<th class='report'>Recommend Date</th>&quot;)
End If

If cbx_visit_date = &quot;on&quot; Then
Response.Write(&quot;<th class='report'>Survey Date</th>&quot;)
End If

If cbx_days_to_resolve=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Days to Resolve</th>&quot;)
End If

If cbx_grid_score=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Grid Score</th>&quot;)
End If

If cbx_resolution_summary=&quot;on&quot; Then
Response.Write(&quot;<th class='report'>Resolution Summary</th>&quot;)
End If %>

</tr>
<%
'-----------------------------------------------------------------------
'This is the search information results, starting with the amount of
'records found and then how many pages are to follow, with 10 records
'per page.
'-----------------------------------------------------------------------
%>


<%If rs.EOF Then%>
<!--No Records Found-->
<p align=&quot;center&quot;>No records found!</p><br>
<%Else%>
<!--Records Found-->

<p align=&quot;center&quot;>Records Found: <%=rs.RecordCount%></p><p>


<tr>
<td colspan=&quot;12&quot; align=&quot;center&quot;><strong>CONFIDENTIAL INFORMATION - Not for Release</strong></td>
</tr>

<p><p>
<%=Paging(intPage, rs.PageCount, rs.RecordCount)%>

<%

'Display 'Edit' links only if user security level allows that
Dim ls_security_level, allow_edit

ls_security_level = Request.Cookies(&quot;security&quot;)(&quot;user_type&quot;)
ls_security_level = UCase(Trim(ls_security_level))

If (ls_security_level = &quot;ADMIN&quot; or ls_security_level = &quot;READWRITE&quot;) Then
allow_edit = true
Else
allow_edit = false
End If



If rs.PageCount < intPage Then intPage = rs.PageCount
rs.AbsolutePage = intPage

Do While Not rs.EOF and intRecord <= intPageSize

If (allow_edit) then

If UCase(report_type) = &quot;SURVEY&quot; Then
file_name = &quot;UpdSurvey_&quot; & agency_short_name & &quot;.asp&quot;
ElseIf UCase(report_type) = &quot;SITE VISIT&quot; Then
file_name = &quot;UpdInspect_&quot; & agency_short_name & &quot;.asp&quot;
ElseIf UCase(report_type) = &quot;ISSUE&quot; Then
file_name = &quot;UpdIssue.asp&quot;
End If

file_name_link1 = file_name & &quot;?recid=&quot; & report_id
file_name_link2 = &quot;UpdRecmd.asp?RecmndID=&quot; & standard_cited_id
file_name_link3 = &quot;ViewStandard.asp?AgencyID=&quot; & agency_id & &quot;&StandardID=&quot; & agency_standard_id
End If

response.write(&quot;<TR>&quot;)

If cbx_visn=&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='1%'><br><br>&quot;)
response.write(&quot;<font size='-1'>&quot; & visn &&quot; &nbsp </font></TD>&quot;)
End If

If cbx_facility=&quot;on&quot; Then
Response.write(&quot;<TD align=left valign='top' width ='4%'><br><br>&quot;)
response.write(&quot;<font size='-2'>&quot; & va_facility_name & &quot;, &quot; & va_city & &quot; &quot; & va_state &&quot; &nbsp </font></TD>&quot;)
End If

If cbx_agency=&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width ='2%'><br><br>&quot;)
response.write(&quot;<font size='-1'>&quot; & agency_short_name &&quot; &nbsp </font></TD>&quot;)
End If

If cbx_primary_issue=&quot;on&quot; Then
response.write(&quot;<TD align=left valign='top' width='7%'><br><br>&quot;)
response.write(&quot;<font size='-2'>&quot; & Primary_Issue_name & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_secondary_issue=&quot;on&quot; Then
response.write(&quot;<TD align=left valign='top' width='7%'><br><br>&quot;)
response.write(&quot;<font size='-2'>&quot; & secondary_Issue_name & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_standard_number=&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='1%'>&quot;)
If (allow_edit) AND not IsNull(agency_standard_id) and agency_standard_id <> &quot;&quot; Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link3 & &quot;'>[View]</a></font><br><br>&quot;)
End If
response.write(&quot;<font size='-1'>&quot; & agency_standard_number & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_standard_description =&quot;on&quot; Then
response.write(&quot;<TD align=left valign='top' width='16%'><br><br>&quot;)
response.write(&quot;<font size='-2'>&quot; & URLDecode(Agency_standard) & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_recommendation=&quot;on&quot; Then
response.write(&quot;<TD align=left valign='top' width='25%'>&quot;)

If (allow_edit) Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link1 & &quot;'>[View Detail]</a></font><br><br>&quot;)
End If

response.write(&quot;<font size='-2'>&quot; & URLDecode(recommendation) & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_recommend_date =&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='2%'>&quot;)

If (allow_edit) Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link1 & &quot;'>[View Detail]</a></font><br><br>&quot;)
End If

response.write(&quot;<font size='-2'>&quot; &report_date & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_visit_date =&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='2%'>&quot;)

If (allow_edit) Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link1 & &quot;'>[View Detail]</a></font><br><br>&quot;)
End If

response.write(&quot;<font size='-2'>&quot; &visit_date & &quot; &nbsp </font></TD>&quot;)
End If

If cbx_days_to_resolve=&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='3%'><br><br>&quot;)
response.write(&quot;<font size='-1'>&quot; & Comptime & &quot;&nbsp </font></TD>&quot;)
End If

If cbx_grid_score=&quot;on&quot; Then

response.write(&quot;<TD align=center valign='top' width='2%'>&quot;)

If (allow_edit) Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link1 & &quot;'>[View Detail]</a></font><br><br>&quot;)
End If

response.write(&quot;<font size='-1'>&quot; & grid_score & &quot;&nbsp </font></TD>&quot;)
End If

If cbx_resolution_summary=&quot;on&quot; Then
response.write(&quot;<TD align=center valign='top' width='31%'>&quot;)

If (allow_edit) Then
response.write(&quot;<font size='-2' valign='top' color='blue'>&quot;)
response.write(&quot;<a href='&quot; & file_name_link2 & &quot;'>[View Detail]</a></font><br><br>&quot;)
End If

response.write(&quot;<font size='-3'>&quot; & resolution_summary & &quot;&nbsp </font></TD>&quot;)
End If
response.write(&quot;</TR>&quot;)
%>
<%
rs.MoveNext
intRecord = intRecord + 1
Loop
%>
<%End If%>



<tr>
<td colspan=&quot;12&quot; align=&quot;center&quot;><strong>CONFIDENTIAL INFORMATION - Not for Release</strong></td>
</tr>
<tr>
<td colspan=&quot;12&quot; align=&quot;center&quot;><%=Paging(intPage, rs.PageCount, rs.RecordCount)%> </td>
</tr>
</table>
<%

rs.close
set rs = nothing
conn.close
set conn = nothing
%>

</div>

<p align=&quot;left&quot;>* For Recommendation Definitions - see home page</p><br>
</td>
</tr>


<p>

<!-- #INCLUDE FILE=&quot;footer.inc&quot; --></p>
</body>
 
When I click on the links for any of the pages, instead of going to the next recordset, it requeries the entire database which is over 15000 records. It does not carry over to teh next 10 results. bb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top