<% Dim cnn set cnn = Server.CreateObject("ADODB.CONNECTION") cnn.ConnectionString = conn_shan cnn.Open Function GetRecords(sSQL) Dim rst Set rst = Server.CreateObject("ADODB.RECORDSET") set rst.ActiveConnection = cnn 'When Record is Open, adUseClient CursorLocation 'will check all records 'adUseServer allows to use CacheSize 'rst.CursorLocation = adUseServer 'When using AdUseServer£¬CacheSize 'limits the lines we are fetching. We only fetch what is 'needed to display - iRowsPerPage 'rst.CacheSize = iRowsPerPage rst.CursorType = 3 rst.CursorLocation = 3 rst.LockType = 3 rst.Open sSQL ',adOpenStatic, adLockReadOnly Set GetRecords = rst END Function Sub CleanUp(rst) If Not rst Is Nothing then If rst.state = 1 then rst.close end if set rst = nothing End If End Sub sub debug_output_icd9grp(rst) 'rst.absolutepage=1 rst.MoveFirst 'now doing output dim x, i Dim str_coln str_coln="" for each x in rst.fields str_coln = str_coln & "" & x.name & "" Next str_coln = "" & str_coln & "" response.write("") response.write(str_coln) i=0 Do Until rst.EOF i=i+1 response.write("") response.write("") for each x in rst.fields response.write("") 'response.write(x.name) 'response.write(" = ") 'response.write(x.value) 'response.write("
") Next response.write("") rst.movenext Loop response.write("
" & CStr(i) & "" & x.value & "
") end sub Response.Expires = 0 dim grplevel, parent_grpid parent_grpid=Server.HtmlEncode(Request.QueryString("parent_grpid")) grplevel=Server.HtmlEncode(Request.QueryString("grplevel")) if grplevel="" then grplevel=1 end if if parent_grpid="" then parent_grpid="NULL" 'for those top level groups end if %> TTD: disease icd9 <% 'response.write(parent_grpid & "
") Dim cmdPrep1 set cmdPrep1=Server.CreateObject("ADODB.Command") Dim prm1' As New ADODB.Parameter 'set prm1=Server.CreateObject("ADODB.Parameter") set cmdPrep1.ActiveConnection = cnn cmdPrep1.CommandType = 1'adCmdText if parent_grpid<>"NULL" then'select by group id '"select groupid, groupdesc, rnglow, rnghigh, level, parentid from ttd2013icd9grp where parentid=" & parent_grpid cmdPrep1.CommandText = "select groupid, groupdesc, rnglow, rnghigh, grplevel, parentid from ttd2013icd9grp where parentid=?"'do not double quote the ? even for string 'response.write(cmdPrep1.CommandText & "
") Set prm1 = cmdPrep1.CreateParameter(, 200, , 50, parent_grpid)'adVarChar cmdPrep1.Parameters.Append prm1 'response.write(cmdPrep1.CommandText & "
") 'response.end else'parent_grpid is NULL, select by level (default 1) '"select groupid, groupdesc, rnglow, rnghigh, level, parentid from ttd2013icd9grp where grplevel=" & grplevel cmdPrep1.CommandText = "select groupid, groupdesc, rnglow, rnghigh, grplevel, parentid from ttd2013icd9grp where grplevel=?" Set prm1 = cmdPrep1.CreateParameter(, 3, , , grplevel)'adInteger cmdPrep1.Parameters.Append prm1 end if cmdPrep1.Prepared = True dim rst Set rst = Server.CreateObject("ADODB.RECORDSET") 'no use setting them if rst is to be used with prepared statement ' rst.CursorType = 3 ' rst.CursorLocation = 3 ' rst.LockType = 3 set rst=cmdPrep1.Execute() 'response.write( "rst.Properties.Count=" & rst.Properties.Count & "
" ) 'dim x: for each x in rst.Properties: response.write( x.name & "=" & x.value & "
" ) :next ' response.write( "recordcount=" & rst.recordcount & "
" ) ' response.write( "cursortype=" & rst.CursorType & "
" ) ' response.write( "CursorLocation=" & rst.CursorLocation & "
" ) ' response.write( "LockType=" & rst.LockType & "
" ) 'debug_output_icd9grp(rst) 'now output the list with links 'rst.requery'due to the recordset type returned by prepared statement execution, it cannot be restarted 'rst.MoveFirst %> <% dim i if rst.EOF and rst.BOF then' ' 'output ICD entries for the query group ' ' 'now querying groups by parent group id returns no record, meaning that no subgroup under the query, ' need to query the entries by this group range. 'response.write("both EOF and BOF are true. Nothing found in database.
") ' 'query entries by group range ' 'get the group range first dim cmdprep_getrng set cmdprep_getrng=Server.CreateObject("ADODB.Command") set cmdprep_getrng.ActiveConnection = cnn cmdprep_getrng.CommandType = 1'adCmdText cmdprep_getrng.CommandText = "select groupid, groupdesc, rnglow, rnghigh, grplevel, parentid from ttd2013icd9grp where groupid=?" Dim prm_gid' As New ADODB.Parameter Set prm_gid = cmdprep_getrng.CreateParameter(, 200, , 50, parent_grpid)'adVarChar cmdprep_getrng.Parameters.Append prm_gid dim rst_rng Set rst_rng = Server.CreateObject("ADODB.RECORDSET") set rst_rng=cmdprep_getrng.Execute() if rst_rng.BOF and rst_rng.EOF then'the group id is not found response.write("Nothing found for group id " & parent_grpid & "
") response.end end if dim rnglow, rnghigh dim groupdesc rnglow=cint(rst_rng.Fields("rnglow")) rnghigh=cint(rst_rng.Fields("rnghigh")) groupdesc=rst_rng.Fields("groupdesc") 'response.write("to get entry: " & parent_grpid & " l=" & rnglow & " h=" & rnghigh & "
") 'response.write("listing ICD9 entries under group: " & groupdesc & " (" & rnglow & "-" & rnghigh & ")
") 'the query is as following ' select ICD9, diseasedesc from ttd2013icd9lv1 where cast(ICD9 as int )<3; 'clear and reuse dim cmdprep_getentry set cmdprep_getentry=Server.CreateObject("ADODB.Command") set cmdprep_getentry.ActiveConnection = cnn cmdprep_getentry.CommandType = 1'adCmdText cmdprep_getentry.CommandText = "select ICD9, diseasedesc from ttd2013icd9lv1 where cast(ICD9 as int)>=? and cast(ICD9 as int)<=?" Dim prm_low, prm_high Set prm_low = cmdprep_getentry.CreateParameter(, 3, , , rnglow)'adInteger Set prm_high = cmdprep_getentry.CreateParameter(, 3, , , rnghigh)'adInteger cmdprep_getentry.Parameters.Append prm_low cmdprep_getentry.Parameters.Append prm_high dim rst_entry Set rst_entry = Server.CreateObject("ADODB.RECORDSET") set rst_entry=cmdprep_getentry.Execute() 'response.write("
click on single ICD9 identifiers to add to search input box, click on description to enter next level.
") 'response.write("
") dim x dim icd9, dd Do Until rst_entry.EOF i=i+1 response.write("") 'response.write("") 'for each x in rst_entry.fields ' response.write("") 'Next '"x" icd9=rst_entry.Fields("ICD9") dd=rst_entry.Fields("diseasedesc") 'response.write("") 'response.write("") response.write("") response.write("") 'response.write("") response.write("") rst_entry.movenext Loop 'response.write("
" & CStr(i) & "" & x.value & "x" & icd9 & "" & icd9 & " " & icd9 & "" & dd & " " & dd & "
") else ' 'output subgroups for the query group ' ' 'response.write(rst.getstring()) 'response.write("") dim s_rnglow, s_rnghigh dim icd9rng Do Until rst.EOF i=i+1 response.write("") 'response.write("") ' for each x in rst.fields ' response.write("") ' Next 'groupdesc, rnglow, rnghigh s_rnglow=rst.Fields("rnglow") s_rnghigh=rst.Fields("rnghigh") icd9rng="" & s_rnglow & "-" & s_rnghigh & "" if cint(s_rnglow)=cint(s_rnghigh) then icd9rng= s_rnglow end if 'response.write("") response.write("") response.write("") response.write("") rst.movenext Loop 'response.write("
" & CStr(i) & "" & x.value & " " & icd9rng & "" & icd9rng & "" & rst.Fields("groupdesc") & " (" & rst.Fields("rnglow") & "-" & rst.Fields("rnghigh") & ") " & "
") end if %> <% %>