Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Reset_Checkboxes()
- Range("G2:G18") = False
- Range("E2:E8") = False
- Range("A10") = Application.WorksheetFunction.HLookup(Range("qgenda!A1"), Range("qgenda!B1:BJ3"), 2, False)
- 'Range("A11") = Application.WorksheetFunction.HLookup(Format(Now(), "MM/DD/YYYY"), Range("qgenda!B1:BJ3"), 2, False)
- Range("qgenda!A1").ClearContents
- End Sub
- Sub Test_Email_Builder()
- Set rng = Range("E2:E10")
- i = 0
- For Each Cell In rng
- If Cell.Value = True Then
- i = i + 1
- End If
- Next Cell
- If i = 0 Then
- MsgBox ("No Analysis Items Seelcted")
- Exit Sub
- ElseIf i > 1 Then
- MsgBox ("Too Many Analysis Items Selected")
- Exit Sub
- End If
- Sheets("Main").Range("B2:B8").ClearContents
- PName = Range("B1")
- x = InStr(PName, "(") 'this value is the index of the open bracket which is used to calculate the mrn
- First_Name = Mid(PName, InStr(PName, "^") + 1, InStr(PName, "_") - (InStr(PName, "^") + 1))
- Last_Name = Left(PName, InStr(PName, "^") - 1)
- MRN = Mid(PName, x + 1, InStr(PName, ")") - (x + 1))
- Ref_Name = MRN & " (" & Last_Name & ", " & First_Name & ")" ' Ref_name means reformatted name
- 'Range("B2") = Ref_Name
- ' REDACTED
- 'this section generates the reformatted first and last name and mrn redacted
- Dim jcixs As Integer
- Dim jcimrn As Integer
- If Range("G9") = True Then
- ix = 7:
- imrn = 6
- Else
- ix = 3
- imrn = 2
- End If
- For i = 1 To Len(MRN) - ix
- CurChar = "X"
- xs = xs & CurChar
- Next i
- Red_Ref_Name = Left(MRN, 1) & xs & Right(MRN, imrn) & " (" & Left(PName, 2) & "," & Left(First_Name, 2) & ")" ' Redacted reformated name
- 'Range("B3") = Red_Ref_Name
- Curr_Date = Format(Now(), "YYYYMMDD")
- Atype = "Analysis_type"
- site = ""
- 'GENERATING THE EMAILS HERE
- 'CDIMN
- analysis_type_row_num = Range("E2:E8").Find("True").Row
- Select Case analysis_type_row_num
- Case 2:
- Atype = "CMR"
- Case 3:
- Atype = "CaScore"
- Case 4:
- Atype = "CorCTA"
- Case 5:
- Atype = "TAVR"
- Case 6:
- Atype = "Custom Analysis"
- If Range("D11").Value <> "" Then
- Atype = Range("D11").Value
- End If
- Case 7:
- Atype = "Pulm Veins"
- End Select
- Range("B20").Value = Atype
- site_row_num = Range("G2:G18").Find("True").Row
- to_email_field = "analysts@piamedical.com"
- Name = Red_Ref_Name
- body = ""
- Redacted = True
- Select Case site_row_num
- Case 2:
- site_greeting_name = "1002" 'St Anthonys
- to_email_field = "sue.neligan@cdirad.com; cindy.krachinski@cdirad.com; shood@cdirad.com; analysts@piamedical.com"
- body = "The report has been pushed to your PACS and is available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
- Case 3:
- site_greeting_name = "1004" ' Seattle Childrens
- Case 4:
- site_greeting_name = "Straub" ' Straub
- body = "The report is attached and is also available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
- Encrypt = True
- Case 5:
- site_greeting_name = "1007" ' U of Arkansas
- Case 6:
- site_greeting_name = "Dr. Sulaiman" ' f1009 KidsHeart Dubai
- to_email_field = "msulaiman@kidsheart.ae; analysts@piamedical.com"
- Case 7:
- site_greeting_name = "SHARP" ' Sharp
- body = "The report has been pushed to your PACS and is available on the PIA Portal: http://host.clariodatacenter.com/piaportal/"
- to_email_field = "sharp@piamedical.com; analysts@piamedical.com"
- Case 8:
- site_greeting_name = "Rush" ' 1018
- Redacted = False
- Range("qgenda!A1") = Format(Now(), "MM/DD/YYYY")
- 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
- If reading_doc = "Dinesh_Kalra@rush.edu" Then
- reading_doc = ""
- End If
- to_email_field = "Dinesh_Kalra@rush.edu; analysts@piamedical.com;" & reading_doc '
- If Atype = "CMR" Or Atype = "CaScore" Then
- body = "The report is attached and the saved session has been pushed to the reading room for review."
- End If
- If Atype = "TAVR" Then
- body = "The report is attached."
- End If
- If Atype = "CorCTA" Or Atype = "Pulm Veins" Then
- body = "The report is attached and the reconstructions have been pushed to your PACS."
- End If
- Case 9:
- site_greeting_name = "JCI" ' JOco
- to_email_field = "JCI@piamedical.com; analysts@piamedical.com"
- If Atype = "CaScore" Then
- 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/"
- End If
- Case 10:
- site_greeting_name = "CDI Vascular" 'f1026" CDI Vascular
- Redacted = False
- Case 11:
- site_greeting_name = "Elmhurst" ' Elmhurst
- Case 12:
- site_greeting_name = "Edwards" ' Edwards
- Case 13:
- site_greeting_name = "Radnet" 'Radnet
- Redacted = False
- Case 14:
- site_greeting_name = "Maine" ' Maine
- Range("B8").Value = "NOTE: Reply to previous email in email chain to notify Maine of completed cases."
- Range("B8").Font.Color = vbRed
- Case 15:
- site_greeting_name = "Tahoe forest" ' f1033" Tahoe forest
- Case 16:
- site_greeting_name = "Seattle Childrens Hospital" ' f1034" Seattle CHildrens hospital
- Case 17:
- site_greeting_name = "Kapiolani" ' Kapiolani
- Case 18:
- site_greeting_name = "Missouri Baptist" ' f1036" ' Missouri Baptist
- to_email_field = "MissouriBaptist@piamedical.com; analysts@piamedical.com"
- body = "The report and reconstructions have been pushed to your PACS."
- End Select
- Range("B21").Value = site_greeting_name
- If Redacted = False Then
- Name = Ref_Name
- End If
- subject_email_field = "PIA " & Atype & " Exam " & Name & " Complete"
- If Encrypt Then
- subject_email_field = "Encrypt: " & subject_email_field
- End If
- body = "<BODY style=font-size:11pt;font-family:Calibri>Dear " & site_greeting_name & " Team, <p> PIA has completed postprocessing of " & _
- Atype & " case " & Name & ". " & body & "</BODY>"
- Range("B2") = Name
- Range("B3") = to_email_field
- Range("B4") = subject_email_field
- Range("B5") = body
- Range("B6") = MRN & "_" & Last_Name & "^" & First_Name & "_" & Curr_Date & "_" & Atype & "_" & Curr_Date
- Range("G2:G18") = False
- Range("E2:E8") = False
- Range("B6").Copy
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement