Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.08 KB | None | 0 0
  1. <%@ LANGUAGE = "VBSCRIPT" %>
  2. <!--#INCLUDE FILE = includes/hasrights.asp -->
  3. <!--#INCLUDE FILE = includes/audit.asp -->
  4.  
  5. <%
  6.  
  7. Function TableExists(sWhichTable)
  8. q = "select RDB$FIELD_NAME from RDB$RELATION_FIELDS where "&_
  9. "RDB$RELATION_NAME = '"&sWhichTable&"' "
  10. myRS.Open q, MyConn
  11. TableExists = not myRS.eof
  12. myRS.Close
  13. End Function
  14.  
  15. Function cleanValue (measValue)
  16. If (measValue <> "") then
  17. measValue = Replace(measValue, " mm3", "")
  18. measValue = Replace(measValue, " mm", "")
  19. End If
  20. cleanValue = measValue
  21. End Function
  22.  
  23. Function GetLine
  24. If InStr(sDatalinkData, chr(13)&chr(10)) <> 0 then
  25. GetLine = mid(sDatalinkData, 1, InStr(sDatalinkData, chr(13)&chr(10))-1)
  26. sDatalinkData = mid(sDatalinkData, InStr(sDatalinkData, chr(13)&chr(10))+2, len(sDatalinkData) )
  27. else
  28. GetLine = sDatalinkData
  29. sDatalinkData = ""
  30. End If
  31. End Function
  32.  
  33. Function recordValue(x)
  34. measVal = Abs(cleanValue(Split(x," ",-1,1)(1)))
  35. If(CINT(measVal) > -50000) then
  36. recordValue = measVal
  37. else
  38. recordValue = "null"
  39. End If
  40. End Function
  41.  
  42. Function insertOrganMeasurements(examNo, location, x1,x2,x3,x4)
  43. q = "UPDATE T_ORGAN_MEASUREMENTS SET TR="&x1&",AP="&x2&",CC="&x3&",VOLUME ="&x4&" WHERE PAT_ID ='"&Request.QueryString("PatID")&"' AND EPISODE = "&Request.QueryString("EP")&" AND EXAM_NO ="&examNo&" AND LOCATION ='"&location&"';"
  44. myConn.Execute(q)
  45. End Function
  46.  
  47. Function insertNodules(examNo, noduleNO, location, TR, AP, CC, VOLUME2)
  48. q = "SELECT DISTINCT NODULE_NO from T_SURVEILLANCE_NODULES WHERE PAT_ID = '"&Request.QueryString("PatID")&"' AND EPISODE = "&Request.QueryString("EP")&_
  49. " AND EXAM_NO = "&examNo&" AND LOCATION ='"&location&"'"
  50. myRS.Open q, myConn
  51. isNew = 1
  52. If location = "Right Lymph Node" Then
  53. nodLocation = "RLN"
  54. ElseIf location = "Right Lobe" Then
  55. nodLocation = "R"
  56. ElseIf location = "Right Isthmus" Then
  57. nodLocation = "RI"
  58. ElseIf location = "Left Isthmus" Then
  59. nodLocation = "LI"
  60. ElseIf location = "Left Lobe" Then
  61. nodLocation = "L"
  62. ElseIf location = "Left Lymph Node" Then
  63. nodLocation = "LLN"
  64. End If
  65.  
  66. nodCount = 1
  67. nodID = 0
  68. If not myRS.EOF Then
  69. do while not myRS.EOF
  70. If StrComp(nodLocation&nodCount, noduleNO) = 0 Then
  71. isNew = 0
  72. nodID = CINT(myRS("NODULE_NO"))
  73. exit do
  74. End If
  75. myRS.MoveNext
  76. nodCount = nodCount + 1
  77. Loop
  78. End If
  79. myRS.Close
  80.  
  81. If nodID = 0 Then
  82. q = "SELECT MAX(NODULE_NO) from T_SURVEILLANCE_NODULES "&_
  83. "WHERE PAT_ID = '"&Request.QueryString("PatID")&"' AND EPISODE = "&Request.QueryString("EP") &" AND TRACKING_DATE ='"&sDate&"' AND "&_
  84. " PREV_EXAM_REF = '"&examNo&"';"
  85. myRS.Open q, myConn
  86. If not myRS.EOF and myRS("MAX") <>"NULL" Then
  87. nodID = CINT(myRS("MAX")) + 1
  88. Else
  89. nodID = 1
  90. End If
  91. myRS.Close
  92. End If
  93.  
  94.  
  95. if TR = "" Then
  96. TR = "Null"
  97. End If
  98. if AP = "" Then
  99. AP = "Null"
  100. End If
  101. if CC = "" Then
  102. CC = "Null"
  103. End If
  104. if TR = "Null" or AP="Null" or CC="Null" Then
  105. VOLUME1 = "Null"
  106. Else
  107. VOLUME1 = CDBL(FormatNumber(CDBL(TR*AP*CC*0.523),2))
  108. End If
  109. if VOLUME2 = "" Then
  110. VOLUME2 = "Null"
  111. End If
  112. if isNew = 1 Then
  113. q = "INSERT INTO T_SURVEILLANCE_NODULES (PAT_ID, EPISODE, EXAM_NO, NODULE_NO, TRACKING_DATE, CURRENTLY_TRACKING, LOCATION, TR,AP,CC,VOLUME1,VOLUME2, PREV_EXAM_REF ) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&examNo&", "&nodID&", '"&sDate&"', 'Y', '"&location&"',"&TR&","&AP&","&CC&","&VOLUME1&","&VOLUME2&","&examNo&") "
  114. else
  115. q = "UPDATE T_SURVEILLANCE_NODULES SET TR="&TR&",AP="&AP&",CC="&CC&",VOLUME1 ="&VOLUME1&",VOLUME2 ="&VOLUME2&_
  116. " WHERE PAT_ID ='"&Request.QueryString("PatID")&"' AND EPISODE = "&Request.QueryString("EP")&" AND EXAM_NO ="&examNo&" AND NODULE_NO ='"&nodID&"' AND TRACKING_DATE ='"&sDate&"' AND "&_
  117. " PREV_EXAM_REF = '"&examNo&"';"
  118. end If
  119. ' response.Write q&"<br/>"
  120. myConn.Execute(q)
  121. End Function
  122.  
  123.  
  124. Function ConvertTowd (n)
  125. If isNull(n) then n = "" end If
  126. If n = "" then
  127. ConvertTowd = ""
  128. elseif n = 0 then
  129. ConvertTowd = ""
  130. else
  131. NumWeeks = Fix(n)
  132. NumDays = Round((n-Fix(n))*7)
  133. If NumDays = 7 then
  134. NumWeeks = NumWeeks + 1
  135. NumDays = 0
  136. end if
  137. ConvertTowd = NumWeeks&"w"& NumDays&"d"
  138. end if
  139. end function
  140.  
  141. Set myConn = Server.CreateObject("ADODB.Connection")
  142. set fso = Server.CreateObject("Scripting.FileSystemObject")
  143. If not fso.FileExists(Server.MapPath("wpbi.txt")) then
  144. sPassword = "masterkey"
  145. else
  146. set ts = fso.OpenTextFile(Server.MapPath("wpbi.txt"))
  147. If not ts.AtEndOfStream then
  148. sPassword = ts.ReadLine
  149. end if
  150. ts.close
  151. set ts = nothing
  152. end if
  153. set fso = nothing
  154. If sPassword = "" then
  155. sPassword = "masterkey"
  156. end if
  157. myConn.open "DSN=ultrasound_odbc;Username=SYSDBA;Password="&sPassword
  158. Set myRS = Server.CreateObject("ADODB.Recordset")
  159. Set myRS2 = Server.CreateObject("ADODB.Recordset")
  160. Set myRS3 = Server.CreateObject("ADODB.Recordset")
  161.  
  162. ' Check for dup Accession Number
  163. q = "select ACCESSION_UNIQUE FROM OPTIONS where OPTION_INDEX = '1'"
  164. myRS.Open q, myConn
  165. If not myRS.eof then
  166. sAccessionUnique = myRS("ACCESSION_UNIQUE")
  167. end if
  168. myRS.Close
  169.  
  170. If (Request.QueryString("AccessionNo") <> "") and (sAccessionUnique = "Y") then
  171. q = "select PAT_ID, EPISODE, EXAM_NO from LONG_SHORT_EXAM where ACCESSION_NO = '"&Request.QueryString("AccessionNo")&"'"
  172. myRS.Open q,myConn
  173. AccessionExists = not myRS.eof
  174. If not myRS.eof then
  175. sPatID = myRS("PAT_ID")
  176. sEpisode = myRS("EPISODE")
  177. sExamNo = myRS("EXAM_NO")
  178. end if
  179. myRS.Close
  180. If AccessionExists then
  181. ' Go to Warning Page
  182. set myRS = nothing
  183. set myRS2 = nothing
  184. set myRS3 = nothing
  185. myConn.Close
  186. set myConn = nothing
  187. Response.Redirect "AccessionDuplicate.asp?AccessionNo="&Request.QueryString("AccessionNo")&"&PatID="&sPatID&"&EP="&sEpisode&"&ExamNo="&sExamNo
  188. end if
  189. end if
  190.  
  191.  
  192. q = "select ACCESSION, STUDY_UID, MULTIPLE_LOCATIONS, WORKLIST_ENABLED, FTPPATH, DATALINKBYDATABASE FROM OPTIONS where OPTION_INDEX = '1'"
  193. myRS.Open q, MyConn
  194. If not myRS.eof then
  195. sMultipleLocations = myRS("MULTIPLE_LOCATIONS")
  196. sAccession = myRS("ACCESSION")
  197. sStudyUIDEnabled = myRS("STUDY_UID")
  198. sWorklistEnabled = myRS("WORKLIST_ENABLED")
  199. sFTPPath = myRS("FTPPATH")
  200. sDatalinkByDatabase = myRS("DATALINKBYDATABASE")
  201. end if
  202. myRS.Close
  203.  
  204. sDatalinkData = ""
  205. If sDatalinkByDatabase = "Y" then
  206. Set myConn2 = Server.CreateObject("ADODB.Connection")
  207. set fso = Server.CreateObject("Scripting.FileSystemObject")
  208. If not fso.FileExists(Server.MapPath("wpbi.txt")) then
  209. sPassword = "masterkey"
  210. Else
  211. set ts = fso.OpenTextFile(Server.MapPath("wpbi.txt"))
  212. If not ts.AtEndOfStream then
  213. sPassword = ts.ReadLine
  214. End if
  215. ts.close
  216. set ts = nothing
  217. End if
  218. set fso = nothing
  219. If sPassword = "" then
  220. sPassword = "masterkey"
  221. end if
  222. myConn2.Open "DSN=Clickview_DatalinkServer;Username=SYSDBA;Password="&sPassword
  223.  
  224. q = "select DATALINK_DATA from DATALINK where PAT_ID = '"&Request.QueryString("PatID")&"' "
  225. myRS.Open q, MyConn2
  226. If not myRS.eof then
  227. sDatalinkData = myRS("DATALINK_DATA")
  228. If isNull(sDatalinkData) then
  229. sDatalinkData = ""
  230. end if
  231. end if
  232. If InStr(sDatalinkData, chr(13)&chr(10)) = 0 then
  233. sUpperLimit = 0
  234. else
  235. arDatalinkData = Split(sDatalinkData, chr(13)&chr(10))
  236. sUpperLimit = UBound(arDatalinkData)
  237. End If
  238. myRS.Close
  239. myConn2.Close
  240. set myConn2 = nothing
  241. End if
  242.  
  243. If not HasRights("Add/Edit Exams") then
  244. set myRS = nothing
  245. myConn.Close
  246. set myConn = nothing
  247. Response.Redirect "accessdeniedsignout.asp"
  248. end if
  249.  
  250. q = "Select Max(EXAM_NO) as MAX_EXAM_NO from LONG_SHORT_EXAM "&_
  251. "where PAT_ID = '"&Request.QueryString("PatID")&"'"&_
  252. "and EPISODE = "&Request.QueryString("EP")
  253. myRS.Open q, MyConn
  254.  
  255. If isNull(myRS("MAX_EXAM_NO")) then
  256. NewExamNo = 1
  257. else
  258. NewExamNo = myRS("MAX_EXAM_NO") + 1
  259. end if
  260.  
  261. myRS.Close
  262.  
  263.  
  264. q = "Select REFBY, PATIENT_DOB from DEMOGRAPHICS "&_
  265. "where PAT_ID = '"&Request.QueryString("PatID")&"'"
  266. myRS.Open q, MyConn
  267. sPatDOB = myRS("PATIENT_DOB")
  268. sRefBy = myRS("REFBY")
  269. myRS.Close
  270.  
  271. If sRefBy = "**iSite**" then
  272. sReferringPhysician = Request.QueryString("RefName")
  273. else
  274. q = "select LAST_NAME, FIRST_NAME, MI, TITLE, SITE from REFER where REFKEY = '"&sRefBy&"'"
  275. myRS.Open q, MyConn
  276. If not myRS.eof then
  277. If myRS("LAST_NAME") <> "" or myRS("FIRST_NAME") <> "" then
  278. sReferringPhysician = myRS("LAST_NAME") & ", " & myRS("FIRST_NAME")
  279. If myRS("MI") <> "" then
  280. sReferringPhysician = sReferringPhysician & " " & myRS("MI") & "."
  281. end if
  282. If myRS("TITLE") <> "" then
  283. sReferringPhysician = sReferringPhysician & " "& myRS("TITLE")
  284. end if
  285. else
  286. sReferringPhysician = myRS("SITE")
  287. end if
  288. else
  289. sReferringPhysician = ""
  290. end if
  291. myRS.Close
  292. end if
  293.  
  294.  
  295. If sReferringPhysician <> "" then
  296. sReferringPhysician = Replace(sReferringPhysician, "'", "''")
  297. end if
  298.  
  299. If Request.QueryString("ExamDate") <> "" then
  300. sDate = Request.QueryString("ExamDate")
  301. else
  302. sDate = Date
  303. end if
  304.  
  305. q = "Insert into long_short_exam (PAT_ID, EPISODE, EXAM_NO, VISIT_DATETIME, PLURALITY, FORMAT, REFER_PHYS"
  306. If Request.QueryString("Procedure") <> "" then
  307. q = q & ", REASON"
  308. end if
  309. If sPatDOB <> "" then
  310. q = q & ", MATERNAL_AGE"
  311. sPatAge = Fix(DateDiff("D", sPatDOB, Date)/365.25)
  312. end if
  313. If (Session("Usersite") <> "") and (Request.QueryString("ExamSite") = "") then
  314. q = q & ",EXAM_SITE"
  315. end if
  316. If Request.QueryString("Examsite") <> "" then
  317. q = q & ",EXAM_SITE"
  318. end if
  319. If (sAccession = "Y") and (Request.QueryString("AccessionNo") <> "") then
  320. q = q & ", ACCESSION_NO"
  321. end if
  322.  
  323. If (sStudyUIDEnabled = "Y") and (Request.QueryString("StudyUID") <> "") then
  324. q = q & ", STUDY_UID"
  325. end if
  326.  
  327. If (Request.QueryString("Sonographer") <> "") then
  328. q = q & ", VALIDATED_PASSWORD"
  329. end if
  330.  
  331. If Request.QueryString("ProcedureDesc") <> "" then
  332. q = q & ", REASON"
  333. end if
  334.  
  335. If Request.QueryString("ProcedureCode") <> "" then
  336. q = q & ", PROCEDURE_CODE"
  337. end if
  338.  
  339. If Request.QueryString("ExamDateTime") <> "" then
  340. q = q & ", EXAM_DATE_TIME"
  341. end if
  342.  
  343. If Request.QueryString("ReferringPhysicianCode") <> "" then
  344. q = q & ", REFER_PHYS_CODE"
  345. end if
  346.  
  347.  
  348. q = q & ", WHO_CHANGED, WHEN_CHANGED"
  349.  
  350.  
  351.  
  352. q = q & ") values ('"&Request.QueryString("PatID")& "', "&Request.QueryString("EP")&", "&NewExamNo&", '"&sDate&"', null, 'X', "&_
  353. " '"&sReferringPhysician&"'"
  354.  
  355. If Request.QueryString("Procedure") <> "" then
  356. q = q & ", '"&Request.QueryString("Procedure")&"'"
  357. end if
  358.  
  359. If sPatDOB <> "" then
  360. q = q & ", '"&sPatAge&"'"
  361. end if
  362.  
  363.  
  364. If (Session("Usersite") <> "") and (Request.QueryString("ExamSite") = "") then
  365. q = q & ",'"&Replace(Session("Usersite"), "'", "''")&"'"
  366. end if
  367.  
  368. If (Request.QueryString("ExamSite") <> "") then
  369. q = q & ", '"&Replace(Request.QueryString("ExamSite"), "'", "''")&"'"
  370. end if
  371.  
  372. If (sAccession = "Y") and (Request.QueryString("AccessionNo") <> "") then
  373. q = q & ", '"&Request.QueryString("AccessionNo")&"'"
  374. end if
  375.  
  376. If (sStudyUIDEnabled = "Y") and (Request.QueryString("StudyUID") <> "") then
  377. q = q & ", '"&Request.QueryString("StudyUID")&"'"
  378. end if
  379.  
  380. If (Request.QueryString("Sonographer") <> "") then
  381. q = q & ", '"&Replace(Request.QueryString("Sonographer"), "'", "''")&"'"
  382. end if
  383.  
  384.  
  385. If Request.QueryString("ProcedureDesc") <> "" then
  386. q = q & ", '"&Request.QueryString("ProcedureDesc")&"'"
  387. end if
  388.  
  389. If Request.QueryString("ProcedureCode") <> "" then
  390. q = q & ", '"&Request.QueryString("ProcedureCode")&"'"
  391. end if
  392.  
  393. If Request.QueryString("ExamDateTime") <> "" then
  394. q = q & ", '"&Request.QueryString("ExamDateTime")&"'"
  395. end if
  396.  
  397. If Request.QueryString("ReferringPhysicianCode") <> "" then
  398. q = q & ", '"&Replace(Request.QueryString("ReferringPhysicianCode"), "'", "''")&"'"
  399. end if
  400.  
  401. q = q & ", '"&Session("Username")&"', '"&date&" "&Hour(time)&":"&Minute(time)&":"&Second(time)&"' "
  402. q = q & ")"
  403. myConn.Execute(q)
  404.  
  405.  
  406. sAssignedTo = Replace("["&Session("Username")&"]", "'", "''")
  407.  
  408. q = "update long_short_exam set SURVEILLANCE_NEW_EXAM ='Y', ASSIGNED_TO = '"&sAssignedTo&"', "&_
  409. "EXAM_STARTED = '"&date&" "&Hour(time)&":"&Minute(time)&":"&Second(time)&"' "&_
  410. "where PAT_ID = '"&Request.QueryString("PatID")&"' "&_
  411. "and EPISODE = "& Request.QueryString("EP") & " "&_
  412. "and EXAM_NO = "&newExamNo
  413. myConn.Execute(q)
  414.  
  415.  
  416. q = "Insert into CT_EXAM (PAT_ID, EPISODE, EXAM_NO, DISCIPLINE, EXAM_TYPE, HISTORY) "&_
  417. "values ('"&Request.QueryString("PatID")& "', "&Request.QueryString("EP")&", "&NewExamNo&", "&_
  418. "'"&Replace(Request.QueryString("Disc"), "'", "''")&"', '"&Replace(Request.QueryString("ExamType"), "'", "''")&"', "&_
  419. "'"&Replace(Request.QueryString("ReasonForStudy"), "'", "''")&"')"
  420. myConn.Execute(q)
  421.  
  422. ' Set to Normal Template
  423.  
  424. sDiscipline = Request.QueryString("Disc")
  425. sExamType = Request.QueryString("ExamType")
  426.  
  427. ' Insert into Exam Type
  428.  
  429. ' insert into CT_EXAM
  430. sExamTypeComments = ""
  431.  
  432. q = "select COMMENT from X_EXAM_TYPE_COMMENT "&_
  433. "where DISCIPLINE_NAME = '"&Replace(sDiscipline, "'", "''") &"' and EXAM_TYPE = '"&Replace(sExamType, "'", "''")&"' "&_
  434. "and COMMENT_TYPE = 'Normal' "&_
  435. "order by SEQ_NO"
  436. myRS2.Open q, myConn
  437. do while not myRS2.eof
  438.  
  439. sExamTypeComments = sExamTypeComments & myRS2("COMMENT") & "<br>"
  440.  
  441. myRS2.MoveNext
  442. loop
  443. myRS2.Close
  444.  
  445. ' Add Normal Impressions If available
  446.  
  447. sImpressionsComments = ""
  448.  
  449. q = "select IMPRESSION from X_EXAM_TYPE_IMPRESSION "&_
  450. "where DISCIPLINE_NAME = '"&Replace(sDiscipline, "'", "''") &"' and EXAM_TYPE = '"&Replace(sExamType, "'", "''")&"' "&_
  451. "and IMPRESSION_TYPE = 'Normal' "&_
  452. "order by SEQ_NO"
  453. myRS2.Open q, myConn
  454. do while not myRS2.eof
  455.  
  456. sImpressionsComments = sImpressionsComments & myRS2("IMPRESSION") & " "
  457.  
  458. myRS2.MoveNext
  459. loop
  460. myRS2.Close
  461.  
  462. If sImpressionsComments <> "" then
  463. sImpressionsComments = "<ul><li>"&sImpressionsComments&"</ul>"
  464. end if
  465.  
  466. Set rsFetusData = Server.CreateObject("ADODB.Recordset")
  467.  
  468. q = "select * from CT_EXAM where "&_
  469. "PAT_ID='"&Request.Querystring("PatID")&"' and EPISODE = "&Request.Querystring("EP")&" and "&_
  470. "EXAM_NO = "&NewExamNo &" "
  471.  
  472. rsFetusData.Source = q
  473. rsFetusData.ActiveConnection = myConn
  474. rsFetusData.CursorType = adOpenKeySet
  475. rsFetusData.LockType = 2
  476. rsFetusData.open
  477. If sExamTypeComments <> "" then
  478. rsFetusData.Fields("COMMENT_TYPE") = "Normal"
  479. rsFetusData.Fields("COMMENT") = sExamTypeComments
  480. end if
  481. rsFetusData.Fields("IMPRESSIONS_TYPE") = "Normal"
  482. rsFetusData.Fields("IMPRESSIONS") = sImpressionsComments
  483. rsFetusData.Update
  484. rsFetusData.Close
  485. set rsFetusData = nothing
  486.  
  487.  
  488.  
  489. ' Insert into Section
  490.  
  491. ' If no Details Available then don't add Section Normals
  492. ' but add If Exam Type Comments are blank.
  493.  
  494. q = "select EXAM_SECTION_DETAIL from X_EXAM_SECTION_DETAIL "&_
  495. "where DISCIPLINE_NAME = '"&sDiscipline&"' and EXAM_TYPE = '"&sExamType&"' "
  496. myRS.Open q, myConn
  497. sDetailsAvailable = not myRS.eof
  498. myRS.Close
  499.  
  500. q = "select EXAM_TYPE from X_EXAM_TYPE_COMMENT "&_
  501. "where DISCIPLINE_NAME = '"&sDiscipline&"' and EXAM_TYPE = '"&sExamType&"' "
  502. myRS.Open q, myConn
  503. sExamTypeCommentsAvailable = not myRS.eof
  504. myRS.Close
  505.  
  506.  
  507. If not (not sDetailsAvailable and sExamTypeCommentsAvailable) then
  508.  
  509. sSectionRadioNo = 1
  510. sDetailRadioNo = 1
  511.  
  512. q = "select EXAM_SECTION, SEQ_NO from X_EXAM_SECTION "&_
  513. "where DISCIPLINE_NAME = '"&Replace(sDiscipline, "'", "''") &"' and EXAM_TYPE = '"&Replace(sExamType, "'", "''")&"' "&_
  514. "order by SEQ_NO"
  515. myRS.Open q, myConn
  516. do while not myRS.eof
  517.  
  518. q = "insert into CT_EXAM_SECTION (PAT_ID, EPISODE, EXAM_NO, SECTION_SEQ, SECTION, COMMENT_TYPE) values ("&_
  519. "'"&Request.Querystring("PatID")&"', "&Request.Querystring("EP")&", "&NewExamNo&", "&_
  520. ""&myRS("SEQ_NO")&", "&_
  521. "'"&Replace(myRS("EXAM_SECTION"), "'", "''") &_
  522. "', 'Normal')"
  523. myConn.execute(q)
  524.  
  525.  
  526. ' insert into CT_EXAM_SECTION_COMMENTS
  527. sSectionComments = ""
  528.  
  529. q = "select COMMENT from X_EXAM_SECTION_COMMENT "&_
  530. "where DISCIPLINE_NAME = '"&Replace(sDiscipline, "'", "''") &"' and EXAM_TYPE = '"&Replace(sExamType, "'", "''")&"' "&_
  531. "and EXAM_SECTION = '"&Replace(myRS("EXAM_SECTION"), "'", "''")&"' "&_
  532. "and COMMENT_TYPE = 'Normal' "&_
  533. "order by SEQ_NO"
  534. myRS2.Open q, myConn
  535. do while not myRS2.eof
  536.  
  537. sSectionComments = sSectionComments & myRS2("COMMENT") & "<br>"
  538.  
  539. myRS2.MoveNext
  540. loop
  541. myRS2.Close
  542.  
  543. If sSectionComments <> "" then
  544. ' Check for Datalink Information
  545. sSectionComments = Replace(sSectionComments, "«", "&laquo;")
  546. sSectionComments = Replace(sSectionComments, "»", "&raquo;")
  547. ' Get Datalink Data Here
  548. sWhichLabel = ""
  549. If sDatalinkData <> "" then
  550. do while (InStr(sSectionComments, "&laquo;") <> 0) and (InStr(sSectionComments, "&raquo;") <> 0)
  551. sThisMeas = ""
  552. sWhichLabel = sSectionComments
  553. sWhichLabel = Mid(sWhichLabel, InStr(sWhichLabel, "&laquo;") + len("&laquo;"), len(sWhichLabel))
  554. sWhichLabel = Mid(sWhichLabel, 1, InStr(sWhichLabel, "&raquo;")-1)
  555.  
  556. If InStr(sDatalinkData, sWhichLabel & ": ") <> 0 then
  557. sThisMeas = sDatalinkData
  558. sThisMeas = Mid(sThisMeas, InStr(sThisMeas, sWhichLabel & ": ") + len(sWhichLabel & ": "), len(sThisMeas))
  559. If InStr(sThisMeas, chr(13)&chr(10)) <> 0 then
  560. sThisMeas = Mid(sThisMeas, 1, InStr(sThisMeas, chr(13)&chr(10))-1)
  561. end if
  562. end if
  563. If sThisMeas <> "" then
  564. sSectionComments = Replace(sSectionComments, "&laquo;"&sWhichLabel&"&raquo;", sThisMeas)
  565. else
  566. sSectionComments = Replace(sSectionComments, "&laquo;"&sWhichLabel&"&raquo;", "")
  567. end if
  568. loop
  569. 'sSectionComments = sSectionComments & "<br>" & sWhichLabel & ": " & sThisMeas & "<br>"
  570. End if
  571.  
  572. ' Get rid of unused measurements
  573. i = 0
  574. do while (InStr(sSectionComments, "&laquo;") <> 0 and InStr(sSectionComments, "&raquo;") and InStr(sSectionComments, "&laquo;") < InStr(sSectionComments, "&raquo;")) and (i < 5000)
  575. i = i + 1
  576. sSectionComments = mid(sSectionComments, 1, InStr(sSectionComments, "&laquo;")-1) & mid(sSectionComments, InStr(sSectionComments, "&raquo;") + 7)
  577. loop
  578.  
  579. Set rsFetusData = Server.CreateObject("ADODB.Recordset")
  580.  
  581. q = "select PAT_ID, EPISODE, EXAM_NO, SECTION_SEQ, SECTION, COMMENT_TYPE, COMMENT from CT_EXAM_SECTION where "&_
  582. "PAT_ID='"&Request.Querystring("PatID")&"' and EPISODE = "&Request.Querystring("EP")&" and "&_
  583. "EXAM_NO = "&NewExamNo &" and "&_
  584. "SECTION = '"&Replace(myRS("EXAM_SECTION"), "'", "''")&"' "
  585.  
  586. rsFetusData.Source = q
  587. rsFetusData.ActiveConnection = myConn
  588. rsFetusData.CursorType = adOpenKeySet
  589. rsFetusData.LockType = 2
  590. rsFetusData.open
  591. rsFetusData.Fields("COMMENT") = sSectionComments
  592. rsFetusData.Update
  593. rsFetusData.Close
  594. set rsFetusData = nothing
  595. end if
  596.  
  597.  
  598. ' insert into the Details
  599.  
  600.  
  601. 'q = "select EXAM_SECTION_DETAIL, SEQ_NO from X_EXAM_SECTION_DETAIL "&_
  602. ' "where DISCIPLINE_NAME = '"&sDiscipline&"' and EXAM_TYPE = '"&sExamType&"' "&_
  603. ' "and EXAM_SECTION = '"&Replace(myRS("EXAM_SECTION"), "'", "''")&"' "&_
  604. ' "order by SEQ_NO"
  605. 'myRS2.Open q, myConn
  606. 'do while not myRS2.eof
  607. '
  608. '
  609. 'q = "insert into CT_EXAM_DETAIL (PAT_ID, EPISODE, EXAM_NO, SECTION_SEQ, DETAIL_SEQ, SECTION, DETAIL, COMMENT_TYPE) values ("&_
  610. ' "'"&Request.Querystring("PatID")&"', "&Request.Querystring("EP")&", "&NewExamNo&", "&_
  611. ' ""&myRS("SEQ_NO")&", "&myRS2("SEQ_NO")&", "&_
  612. ' "'"&Replace(myRS("EXAM_SECTION"), "'", "''") & "', '" & Replace(myRS2("EXAM_SECTION_DETAIL"), "'", "''") & "', 'Normal')"
  613. 'myConn.execute(q)
  614. '
  615. 'sDetailComments = ""
  616. '
  617. 'q = "select COMMENT from X_EXAM_SECTION_DETAIL_COMMENT "&_
  618. ' "where DISCIPLINE_NAME = '"&Replace(sDiscipline, "'", "''") &"' and EXAM_TYPE = '"&Replace(sExamType, "'", "''")&"' "&_
  619. ' "and EXAM_SECTION = '"&Replace(myRS("EXAM_SECTION"), "'", "''")&"' "&_
  620. ' "and EXAM_SECTION_DETAIL = '"&Replace(myRS2("EXAM_SECTION_DETAIL"), "'", "''")&"' "&_
  621. ' "and COMMENT_TYPE = 'Normal' "&_
  622. ' "order by SEQ_NO"
  623. 'myRS3.Open q, myConn
  624. 'do while not myRS3.eof
  625. '
  626. '
  627. 'sDetailComments = sDetailComments & myRS3("COMMENT") & " "
  628. '
  629. 'myRS3.MoveNext
  630. 'loop
  631. 'myRS3.Close
  632. '
  633. '
  634. 'If sDetailComments <> "" then
  635. ' Set rsFetusData = Server.CreateObject("ADODB.Recordset")
  636. '
  637. 'q = "select PAT_ID, EPISODE, EXAM_NO, SECTION_SEQ, DETAIL_SEQ, SECTION, DETAIL, COMMENT_TYPE, COMMENT from CT_EXAM_DETAIL where "&_
  638. ' "PAT_ID='"&Request.Querystring("PatID")&"' and EPISODE = "&Request.Querystring("EP")&" and "&_
  639. ' "EXAM_NO = "&NewExamNo &" and "&_
  640. ' "SECTION = '"&Replace(myRS("EXAM_SECTION"), "'", "''")&"' and "&_
  641. ' "DETAIL = '"&Replace(myRS2("EXAM_SECTION_DETAIL"), "'", "''")&"' "
  642. '
  643. ' rsFetusData.Source = q
  644. ' rsFetusData.ActiveConnection = myConn
  645. ' rsFetusData.CursorType = adOpenKeySet
  646. ' rsFetusData.LockType = 2
  647. ' rsFetusData.open
  648. ' rsFetusData.Fields("COMMENT") = sDetailComments
  649. ' rsFetusData.Update
  650. ' rsFetusData.Close
  651. ' set rsFetusData = nothing
  652. '
  653. 'end if
  654.  
  655. 'sDetailRadioNo = sDetailRadioNo + 1
  656. 'myRS2.MoveNext
  657. 'loop
  658. 'myRS2.Close
  659.  
  660.  
  661.  
  662.  
  663. sSectionRadioNo = sSectionRadioNo + 1
  664.  
  665. myRS.MoveNext
  666. loop
  667. myRS.Close
  668.  
  669. end If ' If Details Available
  670.  
  671. q = "select VISIT_DATETIME, EXAM_NO from long_short_exam "&_
  672. "where PAT_ID = '"&Request.QueryString("PatID")&"' "&_
  673. "and EPISODE = "& Request.QueryString("EP") & " "&_
  674. "and EXAM_NO <> "&newExamNo &_
  675. " order by VISIT_DATETIME desc"
  676. myRS.Open q, MyConn
  677. If not myRS.eof then
  678. ' If there were Previous Exams, check to see If they had ICD-9 Codes.
  679. vLastExam = myRS("EXAM_NO")
  680. myRS.Close
  681. q = "select * from CODEDATA "&_
  682. "where PAT_ID = '"&Request.QueryString("PatID")&"' "&_
  683. "and EPISODE = "& Request.QueryString("EP") & " "&_
  684. "and EXAM_NO = "& vLastExam & " "&_
  685. "and CODE_TYPE like 'ICD-9%' "
  686. myRS.Open q, MyConn
  687. do while not myRS.eof
  688. ' If there ICD-9 Codes, lets copy them to this exam.
  689. q = "insert into CODEDATA "&_
  690. "(PAT_ID, EPISODE, EXAM_NO, FET_ID, CODE_TYPE, CODE_NO, CODE_TEXT) " &_
  691. "values ('"&myRS("PAT_ID")&"', "&myRS("EPISODE")&", "&NewExamNo&", '"&_
  692. myRS("FET_ID")&"', '"&Replace(myRS("CODE_TYPE"), "'", "''")&"', '"&Replace(myRS("CODE_NO"), "'", "''")&"', '"&Replace(myRS("CODE_TEXT"), "'", "''")&"')"
  693. myConn.execute(q)
  694.  
  695. myRS.MoveNext
  696. loop
  697. end if
  698. myRS.Close
  699.  
  700. ' If Discipline = Surveillance update tracking type in exam
  701. If Request.QueryString("Disc") = "Surveillance" then
  702. If (Request.QueryString("Disc") = "Surveillance") and (Request.QueryString("ExamType") = "Thyroid Surveillance") then
  703. sLastExamNo = -1
  704.  
  705. ' Set TrackingType to allow multidimensional tracking
  706. q = "SELECT SUB_CATEGORY FROM CV_LOOKUP WHERE PROPERTY = 'SURV_LOOKUP' AND CATEGORY = 'TS_DIMENSIONS'"
  707. myRS.Open q, myConn
  708. If not myRS.EOF Then
  709. q = "UPDATE CT_EXAM SET TRACKING_TYPE = '"&myRS("SUB_CATEGORY")&"' WHERE PAT_ID='"&Request.QueryString("PatID")& "' and EPISODE = "&Request.QueryString("EP")&" AND EXAM_NO ="&NewExamNo
  710. myConn.Execute(q)
  711. End If
  712. myRS.Close
  713. ' Copy Nodules over from last exam
  714. q = "SELECT N.EXAM_NO,N.TRACKING_DATE, PREV_EXAM_REF FROM LONG_SHORT_EXAM L, T_SURVEILLANCE_NODULES N where N.PAT_ID = '"&Request.QueryString("PatID")&"' "&_
  715. "AND N.EPISODE = "&Request.QueryString("EP")&" and L.PAT_ID = N.PAT_ID and L.EPISODE = N.EPISODE and L.EXAM_NO = N.EXAM_NO "&_
  716. "ORDER by EXAM_NO desc,PREV_EXAM_REF desc, TRACKING_DATE desc"
  717. myRS.Open q, myConn
  718. If not myRS.eof then
  719. sLastExamNo = myRS("EXAM_NO")
  720. sLastTrackingDate = myRS("TRACKING_DATE")
  721. sPrevExamRef = myRS("PREV_EXAM_REF")
  722. End If
  723. myRS.Close
  724. sLocation = ""
  725. sMargins = ""
  726. sInternal = ""
  727. sDiameter = "NULL"
  728. sTR = ""
  729. sAP = ""
  730. sCC = ""
  731. sVolume1 = ""
  732. sVolume2 = ""
  733. If sLastExamNo > 0 Then
  734. ' Copy old image and carry it over/Create a new copy for new Exam
  735. q = "SELECT IMAGE_RIGHT FROM LONG_SHORT_EXAM WHERE PAT_ID = '"&Request.QueryString("PatID")&"' AND EPISODE = "& Request.QueryString("EP") &" AND EXAM_NO = "&sLastExamNo
  736. myRS.Open q, myConn
  737. If not myRS.EOF then
  738. oldImageLocation = myRS("IMAGE_RIGHT")
  739. Else
  740. oldImageLocation = ""
  741. End If
  742. myRs.Close
  743. If oldImageLocation <> "" Then
  744. q = "SELECT GEN_ID(GUIMAGEID,1) as GUIMAGEID FROM rdb$database"
  745. myRS.Open q, myConn
  746. newImageID = myRs("GUIMAGEID")
  747. myRs.Close
  748. q = "select VASCULAR_IMAGE_PATH FROM OPTIONS where OPTION_INDEX = '1'"
  749. myRS.Open q, myConn
  750. sImagePath = myRs("VASCULAR_IMAGE_PATH")
  751. myRs.Close
  752. set fso = Server.CreateObject("Scripting.FileSystemObject")
  753. iPath = Year(Date)&"\"&MonthName(Month(Date),True)&"\"
  754. If NOT (FSO.FolderExists(sImagePath&Year(Date))) Then
  755. fso.CreateFolder(sImagePath&Year(Date))
  756. end if
  757. If NOT (FSO.FolderExists(sImagePath&Year(Date)&"\"&MonthName(Month(Date),True))) Then
  758. fso.CreateFolder(sImagePath&Year(Date)&"\"&MonthName(Month(Date),True))
  759. end if
  760. ImageFileName = sImagePath&iPath&sExamType&"_"&newImageID&".png"
  761. FileName = iPath&sExamType&"_"&newImageID&".png"
  762. Set MyFile = fso.GetFile(sImagePath&"\"&oldImageLocation)
  763. MyFile.Copy (ImageFileName)
  764. set fso = nothing
  765. q = "UPDATE LONG_SHORT_EXAM SET IMAGE_RIGHT='"&FileName&"' WHERE PAT_ID = '"&Request.QueryString("PatID")&"' AND EPISODE = "& Request.QueryString("EP") &" AND EXAM_NO = "&NewExamNo
  766. myConn.Execute(q)
  767. End If
  768.  
  769. ' Copy Nodules over from last exam
  770. q = "SELECT DISTINCT NODULE_NO from T_SURVEILLANCE_NODULES "&_
  771. "WHERE PAT_ID = '"&Request.QueryString("PatID")&"' AND EPISODE = "&Request.QueryString("EP")&_
  772. " AND EXAM_NO = "&sLastExamNo&" and CURRENTLY_TRACKING='Y' AND TRACKING_DATE ='"&sLastTrackingDate&"'"
  773. myRS.Open q, myConn
  774. do while (not myRS.eof)
  775. q = "SELECT NODULE_NO,TRACKING_DATE, LOCATION, MARGINS, INTERNAL, DIAMETER, TR, AP, CC, VOLUME1, VOLUME2,PREV_EXAM_REF,CURRENTLY_TRACKING from T_SURVEILLANCE_NODULES "&_
  776. "WHERE NODULE_NO ="&myRS("NODULE_NO")&" AND PAT_ID = '"&Request.QueryString("PatID")&"' and EPISODE = "&Request.QueryString("EP")&" and EXAM_NO = "&sLastExamNo &_
  777. " ORDER BY PREV_EXAM_REF ASC "
  778. myRS2.Open q, myConn
  779. do while not myRS2.EOF
  780. sLocation = myRS2("LOCATION")
  781. If isNull(sLocation) then
  782. sLocation = ""
  783. End If
  784.  
  785. sMargins = myRS2("MARGINS")
  786. If isNull(sMargins) then
  787. sMargins = ""
  788. End If
  789.  
  790. sInternal = myRS2("INTERNAL")
  791. If isNull(sInternal) then
  792. sInternal = ""
  793. End If
  794.  
  795. sDiameter = myRS2("DIAMETER")
  796. If isNull(sDiameter) then
  797. sDiameter = "NULL"
  798. End If
  799. sTR = myRS2("TR")
  800. If isNull(sTR) then
  801. sTR = "NULL"
  802. End If
  803. sAP = myRS2("AP")
  804. If isNull(sAP) then
  805. sAP = "NULL"
  806. End If
  807. sCC = myRS2("CC")
  808. If isNull(sCC) then
  809. sCC = "NULL"
  810. End If
  811. sVolume1 = myRS2("VOLUME1")
  812. If isNull(sVolume1) then
  813. sVolume1 = "NULL"
  814. End If
  815. sVolume2 = myRS2("VOLUME2")
  816. If isNull(sVolume2) then
  817. sVolume2 = "NULL"
  818. End If
  819.  
  820. sPERef = myRS2("PREV_EXAM_REF")
  821. If isNull(sPERef) then
  822. sPERef = "NULL"
  823. End If
  824.  
  825. sCurrentlyTracking = myRS2("CURRENTLY_TRACKING")
  826. If isNull(sCurrentlyTracking) then
  827. sCurrentlyTracking = ""
  828. End If
  829.  
  830. q = "INSERT INTO T_SURVEILLANCE_NODULES (PAT_ID, EPISODE, EXAM_NO, NODULE_NO, TRACKING_DATE, CURRENTLY_TRACKING, LOCATION, MARGINS, INTERNAL, DIAMETER, TR, AP, CC, VOLUME1, VOLUME2, PREV_EXAM_REF ) values ("&_
  831. "'"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", "&myRS2("NODULE_NO")&", '"&myRS2("TRACKING_DATE")&"', '"&sCurrentlyTracking&"', "&_
  832. "'"&Replace(sLocation, "'", "''")&"', '"&Replace(sMargins, "'", "''")&"', '"&Replace(sInternal, "'", "''")&"',"&sDiameter&","&sTR&","&sAP&","&sCC&","&sVolume1&","&sVolume2&","&sPERef&") "
  833.  
  834. myConn.Execute(q)
  835. myRS2.MoveNext
  836. loop
  837. myRS2.Close
  838. If sCurrentlyTracking = "Y" Then
  839.  
  840. If isNull(sDiameter) then
  841. sDiameter = "NULL"
  842. End If
  843. q = "INSERT INTO T_SURVEILLANCE_NODULES (PAT_ID, EPISODE, EXAM_NO, NODULE_NO, TRACKING_DATE, CURRENTLY_TRACKING, LOCATION, MARGINS, INTERNAL, DIAMETER, PREV_EXAM_REF ) values ("&_
  844. "'"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", "&myRS("NODULE_NO")&", '"&sDate&"', '"&sCurrentlyTracking&"', "&_
  845. "'"&Replace(sLocation, "'", "''")&"', '"&Replace(sMargins, "'", "''")&"', '"&Replace(sInternal, "'", "''")&"',"&sDiameter&","&(NewExamNo)&") "
  846. myConn.Execute(q)
  847. End If
  848. myRS.MoveNext
  849. loop
  850. myRS.Close
  851. End If
  852.  
  853. ' Copy Events over from last exam
  854. q = "SELECT DISTINCT (L.VISIT_DATETIME), E.EXAM_NO FROM LONG_SHORT_EXAM L, T_SURVEILLANCE_EVENTS E where E.PAT_ID = '"&Request.QueryString("PatID")&"' "&_
  855. "AND E.EPISODE = "&Request.QueryString("EP")&" and L.PAT_ID = E.PAT_ID and L.EPISODE = E.EPISODE and L.EXAM_NO = E.EXAM_NO "&_
  856. "ORDER by VISIT_DATETIME desc"
  857. myRS.Open q, myConn
  858. If not myRS.eof then
  859. sLastExamNoE = myRS("EXAM_NO")
  860. Else
  861. sLastExamNoE = -1
  862. End If
  863. myRS.Close
  864.  
  865. If sLastExamNo > 0 then
  866. q = "SELECT EVENT_NO,EVENT_TYPE,EVENT_BEGIN_DATE,EVENT_END_DATE FROM T_SURVEILLANCE_EVENTS WHERE PAT_ID = '"&Request.QueryString("PatID")&"' and EPISODE = "&Request.QueryString("EP")&" and EXAM_NO = "&sLastExamNo
  867. myRS.Open q, myConn
  868. do while not myRS.eof
  869. If isNull(myRS("EVENT_BEGIN_DATE")) then
  870. sEventBeginDate = "null"
  871. Else
  872. sEventBeginDate = "'"&myRS("EVENT_BEGIN_DATE")&"'"
  873. End If
  874. If isNull(myRS("EVENT_END_DATE")) then
  875. sEventEndDate = "null"
  876. Else
  877. sEventEndDate = "'"&myRS("EVENT_END_DATE")&"'"
  878. End If
  879. q = "INSERT INTO T_SURVEILLANCE_EVENTS (PAT_ID, EPISODE, EXAM_NO, EVENT_NO, EVENT_TYPE, EVENT_BEGIN_DATE, EVENT_END_DATE) values ("&_
  880. "'"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", "&_
  881. myRS("EVENT_NO")&", "&"'"&Replace(myRS("EVENT_TYPE"), "'", "''")&"', "&sEventBeginDate & ", "&sEventEndDate & ")"
  882. myConn.Execute(q)
  883. myRS.MoveNext
  884. loop
  885. myRS.Close
  886. End If
  887.  
  888. 'Create Entries into T_ORGAN_MEASUREMNTS
  889. If Request.QueryString("ExamType") = "Thyroid Surveillance" Then
  890. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Left Lobe'"&");"
  891. myRS.Open q, myConn
  892. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Right Lobe'"&");"
  893. myRS.Open q, myConn
  894. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Pyramidal Lobe'"&");"
  895. myRS.Open q, myConn
  896. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Isthmus'"&");"
  897. myRS.Open q, myConn
  898. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Right Lymph Node'"&");"
  899. myRS.Open q, myConn
  900. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Left Lymph Node'"&");"
  901. myRS.Open q, myConn
  902. Elseif sDiscipline = "Aortic Aneurysm Surveillance" Then
  903. q = "INSERT INTO T_ORGAN_MEASUREMENTS( PAT_ID, EPISODE, EXAM_NO, LOCATION) values ('"&Request.QueryString("PatID")&"', "&Request.QueryString("EP")&", "&NewExamNo&", 'Aorta Measurement'"&");"
  904. myRS.Open q, myConn
  905. End If
  906. 'Insert data from DataLink into rows
  907. iAP = "null"
  908. RTW = "null"
  909. RTH = "null"
  910. RTL = "null"
  911. RTV = "null"
  912. LTW = "null"
  913. LTH = "null"
  914. LTL = "null"
  915. LTV = "null"
  916. ReDim RLN(4,0)
  917. Dim oldRLN(50)
  918. oldRLNCounter = -1
  919. RLNx = 0
  920.  
  921. ReDim R(4,0)
  922. Dim oldR(50)
  923. oldRCounter = -1
  924. Rx = 0
  925.  
  926. ReDim RI(4,0)
  927. Dim oldRI(50)
  928. oldRICounter = -1
  929. RIx = 0
  930.  
  931. ReDim LLN(4,0)
  932. Dim oldLLN(50)
  933. oldLLNCounter = -1
  934. LLNx = 0
  935.  
  936. ReDim L(4,0)
  937. Dim oldL(50)
  938. oldLCounter = -1
  939. Lx = 0
  940.  
  941. ReDim LI(4,0)
  942. Dim oldLI(50)
  943. oldLICounter = -1
  944. LIx = 0
  945.  
  946. For j = 0 to sUpperLimit
  947. If sUpperLimit > 0 then
  948. s = arDatalinkData(j)
  949. End If
  950. If Request.QueryString("ExamType") = "Thyroid Surveillance" Then
  951. ' Organ Measurements
  952. If mid(s,1,len("Isthmus AP")) = "Isthmus AP" then
  953. iAP = CDBL(recordValue(s))
  954. End If
  955. If mid(s,1,len("Right Thyroid Width")) = "Right Thyroid Width" then
  956. RTW = CDBL(recordValue(s))
  957. End If
  958. If mid(s,1,len("Right Thyroid Height")) = "Right Thyroid Height" then
  959. RTH = CDBL(recordValue(s))
  960. End If
  961. If mid(s,1,len("Right Thyroid Length")) = "Right Thyroid Length" then
  962. RTL = CDBL(recordValue(s))
  963. End If
  964. If mid(s,1,len("Right Thyroid Volume")) = "Right Thyroid Volume" then
  965. RTV = CDBL(recordValue(s))
  966. End If
  967. If mid(s,1,len("Left Thyroid Width")) = "Left Thyroid Width" then
  968. LTW = CDBL(recordValue(s))
  969. End If
  970. If mid(s,1,len("Left Thyroid Height")) = "Left Thyroid Height" then
  971. LTH = CDBL(recordValue(s))
  972. End If
  973. If mid(s,1,len("Left Thyroid Length")) = "Left Thyroid Length" then
  974. LTL = CDBL(recordValue(s))
  975. End If
  976. If mid(s,1,len("Left Thyroid Volume")) = "Left Thyroid Volume" then
  977. LTV = CDBL(recordValue(s))
  978. End If
  979.  
  980. ' Right Lymph Node Nodules
  981. oldCounterhit = -1
  982. noduleExists = -1
  983. If mid(s,1,len("Right Lymph Node Nodule")) = "Right Lymph Node Nodule" then
  984. For xx = 0 to ubound(oldRLN)
  985. if oldRLN(xx) <> "" Then
  986. oldRLNCounter = xx
  987. If oldRLN(xx) = Split(s," ")(4) Then
  988. noduleExists = 0
  989. exit for
  990. End If
  991. End If
  992. Next
  993. If noduleExists = -1 Then
  994. RLNx = oldRLNCounter+1
  995. oldRLN(oldRLNCounter+1) = Split(s," ")(4)
  996. if RLNx >= Ubound(RLN,2) Then
  997. ReDim Preserve RLN(4,ubound(RLN,2)+1)
  998. End If
  999. Else
  1000. RLNx = oldRLNCounter
  1001. End If
  1002. If(INSTR(s,"Width")) Then
  1003. RLN(0,CINT(RLNx)) = CDBL(recordValue(s))
  1004. Elseif(INSTR(s,"Height")) Then
  1005. RLN(1,CINT(RLNx)) = CDBL(recordValue(s))
  1006. Elseif(INSTR(s,"Length")) Then
  1007. RLN(2,CINT(RLNx)) = CDBL(recordValue(s))
  1008. Elseif(INSTR(s,"Volume")) Then
  1009. RLN(3,CINT(RLNx)) = CDBL(recordValue(s))
  1010. End If
  1011. End If
  1012. ' Right Lobe Nodules
  1013. If mid(s,1,len("Right Thyroid Nodule")) = "Right Thyroid Nodule" then
  1014. For xx = 0 to ubound(oldR)
  1015. if oldR(xx) <> "" Then
  1016. oldRCounter = xx
  1017. If oldR(xx) = Split(s," ")(3) Then
  1018. noduleExists = 0
  1019. exit for
  1020. End If
  1021. End If
  1022. Next
  1023. If noduleExists = -1 Then
  1024. Rx = oldRCounter+1
  1025. oldR(ubound(R,2)) = Split(s," ")(3)
  1026. if Rx >= Ubound(R,2) Then
  1027. ReDim Preserve R(4,ubound(R,2)+1)
  1028. End If
  1029. Else
  1030. Rx = oldRCounter
  1031. End If
  1032. If(INSTR(s,"Width")) Then
  1033. R(0,CINT(Rx)) = CDBL(recordValue(s))
  1034. Elseif(INSTR(s,"Height")) Then
  1035. R(1,CINT(Rx)) = CDBL(recordValue(s))
  1036. Elseif(INSTR(s,"Length")) Then
  1037. R(2,CINT(Rx)) = CDBL(recordValue(s))
  1038. Elseif(INSTR(s,"Volume")) Then
  1039. R(3,CINT(Rx)) = CDBL(recordValue(s))
  1040. End If
  1041. End If
  1042. ' Right Isthmus Nodules
  1043. If mid(s,1,len("Right Isthmus Nodule")) = "Right Isthmus Nodule" then
  1044. For xx = 0 to ubound(oldRI)
  1045. if oldRI(xx) <> "" Then
  1046. If oldRI(xx) = Split(s," ")(3) Then
  1047. oldRICounter = xx
  1048. noduleExists = 0
  1049. exit for
  1050. End If
  1051. End If
  1052. Next
  1053. If noduleExists = -1 Then
  1054. RIx = oldRICounter+1
  1055. oldRI(oldRICounter+1) = Split(s," ")(3)
  1056. If RIx >= Ubound(RI,2) Then
  1057. ReDim Preserve RI(4,ubound(RI,2)+1)
  1058. End If
  1059. Else
  1060. RIx = oldRICounter
  1061. End If
  1062. If(INSTR(s,"Width")) Then
  1063. RI(0,CINT(RIx)) = CDBL(recordValue(s))
  1064. Elseif(INSTR(s,"Height")) Then
  1065. RI(1,CINT(RIx)) = CDBL(recordValue(s))
  1066. Elseif(INSTR(s,"Length")) Then
  1067. RI(2,CINT(RIx)) = CDBL(recordValue(s))
  1068. Elseif(INSTR(s,"Volume")) Then
  1069. RI(3,CINT(RIx)) = CDBL(recordValue(s))
  1070. End If
  1071. End If
  1072. ' Left Lymph Node Nodules
  1073. If mid(s,1,len("Left Lymph Node Nodule")) = "Left Lymph Node Nodule" then
  1074. For xx = 0 to ubound(oldLLN)
  1075. if oldLLN(xx) <> "" Then
  1076. oldLLNCounter = xx
  1077. If oldLLN(xx) = Split(s," ")(4) Then
  1078. oldCounterhit = 0
  1079. exit for
  1080. End If
  1081. End If
  1082. Next
  1083. If noduleExists = -1 Then
  1084. LLNx = oldLLNCounter+1
  1085. oldLLN(ubound(LLN,2)) = Split(s," ")(4)
  1086. if LLNx >= Ubound(LLN,2) Then
  1087. ReDim Preserve LLN(4,ubound(LLN,2)+1)
  1088. End If
  1089. Else
  1090. LLNx = oldLLNCounter
  1091. End If
  1092. If(INSTR(s,"Width")) Then
  1093. LLN(0,CINT(LLNx)) = CDBL(recordValue(s))
  1094. Elseif(INSTR(s,"Height")) Then
  1095. LLN(1,CINT(LLNx)) = CDBL(recordValue(s))
  1096. Elseif(INSTR(s,"Length")) Then
  1097. LLN(2,CINT(LLNx)) = CDBL(recordValue(s))
  1098. Elseif(INSTR(s,"Volume")) Then
  1099. LLN(3,CINT(LLNx)) = CDBL(recordValue(s))
  1100. End If
  1101. End If
  1102. ' Left Lobe Nodules
  1103. If mid(Trim(s),1,len("Left Thyroid Nodule")) = "Left Thyroid Nodule" then
  1104. For xx = 0 to ubound(oldL)
  1105. if oldL(xx) <> "" Then
  1106. oldLCounter = xx
  1107. If oldL(xx) = Split(s," ")(3) Then
  1108. noduleExists = 0
  1109. exit for
  1110. End If
  1111. End If
  1112. Next
  1113. If noduleExists = -1 Then
  1114. Lx = oldLCounter+1
  1115. oldL(ubound(L,2)) = Split(s," ")(3)
  1116. if Lx >= Ubound(L,2) Then
  1117. ReDim Preserve L(4,ubound(L,2)+1)
  1118. End If
  1119. Else
  1120. Lx = oldLCounter
  1121. End If
  1122. If(INSTR(s,"Width")) Then
  1123. L(0,CINT(Lx)) = CDBL(recordValue(s))
  1124. Elseif(INSTR(s,"Height")) Then
  1125. L(1,CINT(Lx)) = CDBL(recordValue(s))
  1126. Elseif(INSTR(s,"Length")) Then
  1127. L(2,CINT(Lx)) = CDBL(recordValue(s))
  1128. Elseif(INSTR(s,"Volume")) Then
  1129. L(3,CINT(Lx)) = CDBL(recordValue(s))
  1130. End If
  1131. End If
  1132. ' Left Isthmus Nodules
  1133. If mid(s,1,len("Left Isthmus Nodule")) = "Left Isthmus Nodule" then
  1134. For xx = 0 to ubound(oldLI)
  1135. if oldLI(xx) <> "" Then
  1136. oldLICounter = xx
  1137. If oldLI(xx) = Split(s," ")(3) Then
  1138. noduleExists = 0
  1139. exit for
  1140. End If
  1141. End If
  1142. Next
  1143. If noduleExists = -1 Then
  1144. LIx = oldLICounter+1
  1145. oldLI(ubound(LI,2)) = Split(s," ")(3)
  1146. if LIx >= Ubound(LI,2) Then
  1147. ReDim Preserve LI(4,ubound(LI,2)+1)
  1148. End If
  1149. Else
  1150. LIx = oldLICounter
  1151. End If
  1152. If(INSTR(s,"Width")) Then
  1153. LI(0,CINT(LIx)) = CDBL(recordValue(s))
  1154. Elseif(INSTR(s,"Height")) Then
  1155. LI(1,CINT(LIx)) = CDBL(recordValue(s))
  1156. Elseif(INSTR(s,"Length")) Then
  1157. LI(2,CINT(LIx)) = CDBL(recordValue(s))
  1158. Elseif(INSTR(s,"Volume")) Then
  1159. LI(3,CINT(LIx)) = CDBL(recordValue(s))
  1160. End If
  1161. End If
  1162. Elseif Request.QueryString("ExamType") = "Aortic Aneurysm Surveillance" Then
  1163. Elseif Request.QueryString("ExamType") = "Solid Pulmonary Nodule Surveillance" Then
  1164. End If ' end of If Surveillance Type
  1165. Next 'End of FOR LOOP
  1166.  
  1167. If Request.QueryString("ExamType") = "Aortic Aneurysm Surveillance" Then
  1168. ' call insertOrganMeasurements(NewExamNo, "Aorta Measurement", 5, 5, 5, 65)
  1169. Elseif Request.QueryString("ExamType") = "Thyroid Surveillance" Then
  1170. call insertOrganMeasurements(NewExamNo, "Isthmus","NULL",iAP,"NULL","NULL")
  1171. call insertOrganMeasurements(NewExamNo, "Right Lobe", RTW, RTH, RTL, RTV)
  1172. call insertOrganMeasurements(NewExamNo, "Left Lobe", LTW, LTH, LTL, LTV)
  1173. RSize = UBound(R,2)-1
  1174. LSize = UBound(L,2)-1
  1175. If RSize < 0 Then
  1176. RSize = 0
  1177. End If
  1178. If LSize < 0 Then
  1179. LSize = 0
  1180. End If
  1181. For i = 1 to UBound(RLN,2)
  1182. call insertNodules(NewExamNo, "RLN"&i, "Right Lymph Node",RLN(0,i),RLN(1,i),RLN(2,i),RLN(3,i))
  1183. Next
  1184. For i = 0 to RSize
  1185. call insertNodules(NewExamNo, "R"&i,"Right Lobe", R(0,i), R(1,i), R(2,i), R(3,i))
  1186. Next
  1187. For i = 1 to UBound(RI,2)
  1188. call insertNodules(NewExamNo, "RI"&i,"Right Isthmus", RI(0,i), RI(1,i), RI(2,i), RI(3,i))
  1189. Next
  1190. For i = 1 to UBound(LLN,2)
  1191. call insertNodules(NewExamNo, "LLN"&i,"Left Lymph Node", LLN(0,i), LLN(1,i), LLN(2,i), LLN(3,i))
  1192. Next
  1193. For i = 0 to LSize
  1194. call insertNodules(NewExamNo, "L"&i,"Left Lobe", L(0,i), L(1,i), L(2,i), L(3,i))
  1195. Next
  1196. For i = 1 to UBound(LI,2)
  1197. call insertNodules(NewExamNo, "LI"&i,"Left Isthmus", LI(0,i), LI(1,i), LI(2,i), LI(3,i))
  1198. Next
  1199. End If
  1200. End If
  1201. End If
  1202.  
  1203.  
  1204. set myRS = nothing
  1205. set myRS2 = nothing
  1206. set myRS3 = nothing
  1207. myConn.Close
  1208. set myConn = nothing
  1209.  
  1210. call AuditThis("Inserted", "CT Exam", "QueryString")
  1211. sRedirect = "CTWorksheet.asp?PatID="&Request.QueryString("PatID")&"&EP="&Request.QueryString("EP")&"&ExamNo="&NewExamNo
  1212. If Request.QueryString("Datalinkfilename") <> "" then
  1213. sRedirect = sRedirect & "&Datalinkfilename="&Escape(Request.QueryString("Datalinkfilename"))
  1214. end if
  1215.  
  1216. Response.Redirect sRedirect
  1217. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement