Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. Sub Reset_Checkboxes()
  2. Range("G2:G18") = False
  3. Range("E2:E8") = False
  4.  
  5. Range("A10") = Application.WorksheetFunction.HLookup(Range("qgenda!A1"), Range("qgenda!B1:BJ3"), 2, False)
  6. 'Range("A11") = Application.WorksheetFunction.HLookup(Format(Now(), "MM/DD/YYYY"), Range("qgenda!B1:BJ3"), 2, False)
  7. Range("qgenda!A1").ClearContents
  8. End Sub
  9.  
  10. Sub Test_Email_Builder()
  11.  
  12. Set rng = Range("E2:E10")
  13. i = 0
  14. For Each Cell In rng
  15. If Cell.Value = True Then
  16. i = i + 1
  17. End If
  18. Next Cell
  19.  
  20. If i = 0 Then
  21. MsgBox ("No Analysis Items Seelcted")
  22. Exit Sub
  23. ElseIf i > 1 Then
  24. MsgBox ("Too Many Analysis Items Selected")
  25. Exit Sub
  26. End If
  27.  
  28. Sheets("Main").Range("B2:B8").ClearContents
  29.  
  30. PName = Range("B1")
  31. x = InStr(PName, "(") 'this value is the index of the open bracket which is used to calculate the mrn
  32. First_Name = Mid(PName, InStr(PName, "^") + 1, InStr(PName, "_") - (InStr(PName, "^") + 1))
  33. Last_Name = Left(PName, InStr(PName, "^") - 1)
  34. MRN = Mid(PName, x + 1, InStr(PName, ")") - (x + 1))
  35. Ref_Name = MRN & " (" & Last_Name & ", " & First_Name & ")" ' Ref_name means reformatted name
  36. 'Range("B2") = Ref_Name
  37. ' REDACTED
  38. 'this section generates the reformatted first and last name and mrn redacted
  39. Dim jcixs As Integer
  40. Dim jcimrn As Integer
  41.  
  42. If Range("G9") = True Then
  43. ix = 7:
  44. imrn = 6
  45. Else
  46. ix = 3
  47. imrn = 2
  48. End If
  49.  
  50. For i = 1 To Len(MRN) - ix
  51. CurChar = "X"
  52. xs = xs & CurChar
  53. Next i
  54. Red_Ref_Name = Left(MRN, 1) & xs & Right(MRN, imrn) & " (" & Left(PName, 2) & "," & Left(First_Name, 2) & ")" ' Redacted reformated name
  55. 'Range("B3") = Red_Ref_Name
  56.  
  57. Curr_Date = Format(Now(), "YYYYMMDD")
  58.  
  59.  
  60. Atype = "Analysis_type"
  61. site = ""
  62.  
  63. 'GENERATING THE EMAILS HERE
  64. 'CDIMN
  65.  
  66. analysis_type_row_num = Range("E2:E8").Find("True").Row
  67.  
  68. Select Case analysis_type_row_num
  69. Case 2:
  70. Atype = "CMR"
  71. Case 3:
  72. Atype = "CaScore"
  73. Case 4:
  74. Atype = "CorCTA"
  75. Case 5:
  76. Atype = "TAVR"
  77. Case 6:
  78. Atype = "Custom Analysis"
  79. If Range("D11").Value <> "" Then
  80. Atype = Range("D11").Value
  81. End If
  82. Case 7:
  83. Atype = "Pulm Veins"
  84. End Select
  85.  
  86.  
  87.  
  88.  
  89. Range("B20").Value = Atype
  90.  
  91. site_row_num = Range("G2:G18").Find("True").Row
  92. to_email_field = "analysts@piamedical.com"
  93. Name = Red_Ref_Name
  94. body = ""
  95.  
  96. Redacted = True
  97.  
  98.  
  99. Select Case site_row_num
  100. Case 2:
  101. site_greeting_name = "1002" 'St Anthonys
  102. to_email_field = "sue.neligan@cdirad.com; cindy.krachinski@cdirad.com; shood@cdirad.com; analysts@piamedical.com"
  103. body = "The report has been pushed to your PACS and is available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
  104.  
  105. Case 3:
  106. site_greeting_name = "1004" ' Seattle Childrens
  107. Case 4:
  108. site_greeting_name = "Straub" ' Straub
  109. body = "The report is attached and is also available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
  110. Encrypt = True
  111.  
  112. Case 5:
  113. site_greeting_name = "1007" ' U of Arkansas
  114.  
  115. Case 6:
  116. site_greeting_name = "Dr. Sulaiman" ' f1009 KidsHeart Dubai
  117. to_email_field = "msulaiman@kidsheart.ae; analysts@piamedical.com"
  118. Case 7:
  119. site_greeting_name = "SHARP" ' Sharp
  120. body = "The report has been pushed to your PACS and is available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
  121. to_email_field = "sharp@piamedical.com; analysts@piamedical.com"
  122.  
  123. Case 8:
  124. site_greeting_name = "Rush" ' 1018
  125. Redacted = False
  126.  
  127. Range("qgenda!A1") = Format(Now(), "MM/DD/YYYY")
  128. reading_doc = Application.WorksheetFunction.HLookup(Range("qgenda!A1"), Range("qgenda!B1:BJ3"), 3, False) ' look for the value in qgenda A1 in qgenda B1 to bj3 and the column that matches take cell 2
  129. If reading_doc = "Dinesh_Kalra@rush.edu" Then
  130. reading_doc = ""
  131. End If
  132.  
  133. to_email_field = "Dinesh_Kalra@rush.edu; analysts@piamedical.com;" & reading_doc '
  134.  
  135. If Atype = "CMR" Or Atype = "CaScore" Then
  136. body = "The report is attached and the saved session has been pushed to the reading room for review."
  137. End If
  138.  
  139. If Atype = "TAVR" Then
  140. body = "The report is attached."
  141. End If
  142.  
  143. If Atype = "CorCTA" Or Atype = "Pulm Veins" Then
  144. body = "The report is attached and the reconstructions have been pushed to your PACS."
  145. End If
  146.  
  147. Case 9:
  148. site_greeting_name = "JCI" ' JOco
  149. to_email_field = "JCI@piamedical.com; analysts@piamedical.com"
  150.  
  151. If Atype = "CaScore" Then
  152. body = "The report has been pushed to your PACS, and a printer-friendly version can be found on the PIA Portal: host.clariodatacenter.com/piaportal/"
  153. End If
  154. Case 10:
  155. site_greeting_name = "CDI Vascular" 'f1026" CDI Vascular
  156. Redacted = False
  157.  
  158. Case 11:
  159. site_greeting_name = "Elmhurst" ' Elmhurst
  160.  
  161. Case 12:
  162. site_greeting_name = "Edwards" ' Edwards
  163.  
  164. Case 13:
  165. site_greeting_name = "Radnet" 'Radnet
  166. Redacted = False
  167.  
  168. Case 14:
  169. site_greeting_name = "Maine" ' Maine
  170. Range("B8").Value = "NOTE: Reply to previous email in email chain to notify Maine of completed cases."
  171. Range("B8").Font.Color = vbRed
  172.  
  173. Case 15:
  174. site_greeting_name = "Tahoe forest" ' f1033" Tahoe forest
  175.  
  176. Case 16:
  177. site_greeting_name = "Seattle Childrens Hospital" ' f1034" Seattle CHildrens hospital
  178.  
  179. Case 17:
  180. site_greeting_name = "Kapiolani" ' Kapiolani
  181.  
  182. Case 18:
  183. site_greeting_name = "Missouri Baptist" ' f1036" ' Missouri Baptist
  184. to_email_field = "MissouriBaptist@piamedical.com; analysts@piamedical.com"
  185. body = "The report and reconstructions have been pushed to your PACS."
  186.  
  187. End Select
  188.  
  189. Range("B21").Value = site_greeting_name
  190.  
  191. If Redacted = False Then
  192. Name = Ref_Name
  193. End If
  194.  
  195. subject_email_field = "PIA " & Atype & " Exam " & Name & " Complete"
  196.  
  197. If Encrypt Then
  198. subject_email_field = "Encrypt: " & subject_email_field
  199. End If
  200.  
  201.  
  202. body = "<BODY style=font-size:11pt;font-family:Calibri>Dear " & site_greeting_name & " Team, <p> PIA has completed postprocessing of " & _
  203. Atype & " case " & Name & ". " & body & "</BODY>"
  204.  
  205.  
  206. Range("B2") = Name
  207. Range("B3") = to_email_field
  208. Range("B4") = subject_email_field
  209. Range("B5") = body
  210.  
  211. Range("B6") = MRN & "_" & Last_Name & "^" & First_Name & "_" & Curr_Date & "_" & Atype & "_" & Curr_Date
  212.  
  213. Range("G2:G18") = False
  214. Range("E2:E8") = False
  215. Range("B6").Copy
  216.  
  217.  
  218.  
  219. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement