Advertisement
Guest User

Untitled

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