Below is a script I've been using in my Electronic Medical Record (EMR). It takes a diagnosis and changes it to a more descriptive phrase (for example it changes CHRONIC AIRWAY OBSTRUCTION NEC to CHRONIC OBSTRUCTIVE PULMONARY DISEASE and also adds a priority and whether it's chronic or not using a look up table. This worked fine until a recent EMR upgrade, then it kept telling me it couldn't find the diagnosis. I figured out that strJustICD is now missing the right most letter (for example CHRONIC AIRWAY OBSTRUCTION NE) so it's not on the list. What I can't figure out is why. I can probably just increase the length by one to fix the problem, but would like to understand the issue. I'd appreciate any help.
Option Explicit
Sub Main
'by Daniel Ginsberg, MD, FACP
'This code extract items from a list of diagnoses, ICD codes etc. to use for various things.
'positions are left to right, starting at 0
'position 0 = Preferred spelling for Problem List
'position 1 = ICD code
'position 2 = Priority (1=high, 2=medium, 3=low)
'position 3 = Classification (1=acute, 2=chronic, 3=minor, 4=temporary, 5=Stage 1, 6=Stage 2, 7=Stage 3, 8=End Stage)
'
'****************************************************
'The following extracts the ICD code from the highlighted Problem in Problem Details Edit.
Dim Problem As String
SendDragonKeys "{Alt+e}" 'select CodeSearch as an initial step to alway go back to the Problem field
SendDragonKeys "{Alt+c}" 'select Cancel to end up in the Problem field
SendDragonKeys "{Shift+Tab}" 'added 7/29/08 due to some change that occured
SendDragonKeys "{Ctrl+c}" 'Copy the Problem, in Problem Details Edit, to the clipboard
Wait 0.3
SendKeys "{Right}"
Wait 0.3
Problem = Clipboard
Dim strProblem As String
Dim strJustICD As String
strProblem = Clipboard
strJustICD = Mid$(strProblem, _
InStrRev(strProblem, "[")+1)
strJustICD = Left(strJustICD, Len(strJustICD)-1)
'****************************************************
Dim fso, TextStream, s
Dim StrWordList, Match
Dim ICD As String
Dim Dx As String
Dim strMasterList
strMasterList = "C:\Documents And Settings\dginsberg\My Documents\diagnosisicd.txt" 'location of file containing ICD codes, diagnoses, etc.
'The following code pulls up a file that contains ICD codes, diagnoses, etc., and reads them a line at a time.
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set TextStream = fso.OpenTextFile(strMasterList, ForReading)
Do While Not TextStream.AtEndOfStream
s = TextStream.ReadLine
If s = "" Then Exit Do 'check to see if you're at the end of the file
StrWordList = Split(s,"\",-1)
If StrWordList(1) = strJustICD Then 'check to see if extracted ICD code equals line from list of diagnoses
SendDragonKeys "{Tab}" 'move to the Display as field
SendDragonKeys "{Tab}"
SendKeys StrWordList(0)
SendKeys "{tab}" 'move to Priority field
SendKeys StrWordList(2) 'enter priority
SendKeys "{tab}" 'move to Classification field
SendKeys StrWordList(3) 'enter Classification
SendKeys "{tab 3}" 'move to the Comments field
Match = strJustICD 'if a match is made between the diagnosis being evaluated and the text file, assign ICD code to variable
Else
End If
Loop
If Match <> strJustICD Then 'test to see if the extracted ICD list is in the strMasterList file
MsgBox "The list is empty! Edit " + strMasterList + " to add to the list."
Else
End If
TextStream.Close
End Sub