KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: DMO Advanced Scripting workaround for EPIC and Citrix via AHK
Topic Summary: Scripting in DMO sucks, AHK can help, here's some scripting that can connect the two.
Created On: 04/24/2022 09:19 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - NiptheZephyr - 04/24/2022 09:19 PM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - NiptheZephyr - 04/24/2022 09:30 PM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - ax - 04/25/2022 02:06 PM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - NiptheZephyr - 04/27/2022 10:45 AM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - Lunis Orcutt - 04/27/2022 10:49 AM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - NiptheZephyr - 04/27/2022 02:01 PM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - ax - 04/29/2022 07:14 PM  
 DMO Advanced Scripting workaround for EPIC and Citrix via AHK   - Lunis Orcutt - 04/30/2022 07:31 PM  
Keyword
 04/24/2022 09:19 PM
User is offline View Users Profile Print this message

Author Icon
NiptheZephyr
New Member

Posts: 13
Joined: 06/28/2020

Howdy everyone! Longtime fan of DMPE and it's advanced scripting. Lets me automate a huge portion of my note/EMR management to spend more time with patients or get home sooner. I moved to new state, got a job with a wonderful new hospital system that uses EPIC (hurray!), but unfortunately it uses DMO, and accesses both DMO and EPIC via Citrix (boo!). 

 

DMO's scripting capabilities are...lackluster. The most it has is fairly good Step-By-Step commands, compared to DMPE's advanced scripting and ability to use <lists>/ListVars, and just variables in general. As an example, you want to delete 10 sentences up? Get ready to click "new step" select "hotkey", press "shift up", select "hotkey", and press "delete". Now do that 10 times. Compare that to actual advanced scripting, something along the lines of +{up 10}{delete}. Or at least something similar, forgive me if it's missing "'s or the like, it's been many months since I actually did some scripting in it. Finally, DMO lacks the basic ability to click on the screen, allowing only keystrokes/key combinations.

 

So, in order to get around some of these deficits, I've been using AutoHotKey, a free, very straightforward scripting language with some great documentation, with practically all the benefits of VBS or Dragon's Advanced scripting. The biggest problem with it is that it uses keyboard and mouse inputs to activate. While it can be triggered by something like Windows Speech Recognition typing, DMO typing fails to do so, or at least DMO and EPIC accessed through Citrix, like my system uses. So, I've developed a workaround that I want to share with y'all. I'll post this in "Third Party Command Utilities" too since it might fit better there, but wanted to make you all aware of it in this category as it is likely most relevant to you all.

 

So, how it works first:

1. You design your "advanced scripting" in AHK. Set it to be triggered by a one word hotstring (::hotstring:

2. Make a DMO step-by-step command that types the first part of the hotstring (::hotstring), highlights it, then cuts it to the clipboard. 

 

So long as you have the below code in your .ahk document that is running, that's all you need! The script will execute. The .ahk script has code at that top which fills an array with a list of all the hotstrings in the .ahk document itself. It monitors the clipboard, and when what is put on the clipboard matches a hotstring, it runs it via the function at the bottom.

Limitations!

1. Current verson only looks at one word hotstrings. 

2. I have it set up so that anything else that is copied with but after the hostring is put into a variable for use (i.e. ::hotstring additionalWordsHerePutIntoAVariableAsAString). This "limitation" is on the DMO end; since it doesn't use "listVars", you'll have to verbalize what you'll want copied on a new line (so you don't copy unintentional stuff), then have your DMO Step-By-Step command {home} to the beginning of that line before it types your ::hotstring, then {end}, shift{home}, then cut to capture the whole thing.

3. If you are in the same situation as myself, you'll need to find a place for DMO to actually type its ::hotstring in EPIC. Meaning, Citrix makes everything look like an image, no access to "Controls", and if you are on a screen that doesn't have an edit DMO can type into (like your patient schedule), you'll have to bring something up for it to type into. I've found that bringing up a search bar gives you an edit to type into. The keystroke combo to bring up the search bar is either alt{space} or ctrl{space}, can't remember which right now. 

 

So, on to the ahk script/coding. Note that a comment is anything following a ; or between /* */. 

Begin AHK coding which you would put into a new .ahk under the autoexecute section:

;=====================================

;=====================================

;      ---Global Variables---

 

;=====================================

;Global Array holding the list of hotstrings in this script

 

Global ahkScriptsArray := {}

 

;=====================================

;Declared Global Variable to hold additional information for manipulation.

 

Global Input := ""

 

;=====================================

;    ---Additional Auto-Execute stuff---

 

;=====================================

;part that pulls the ::hotstrings:: out of this .ahk document and puts it into the array.

FileRead, fileInfoVar, %A_ScriptFullPath%re">

 

While pos := RegExMatch(fileInfoVar, "\R(::\w+)::", m, pos ? pos + StrLen(m) : 1)

ahkScriptsArray.Push(m1)

;=====================================

;Monitors for the clipboard to change, to compare to the below called function, which should compare to the hotstrings.

OnClipboardChange("DragonCompare")

 

 

;=====================================

;Put your "Advanced Scripting" ::hotstrings below here:

 

 

;=====================================

;Functions section, having the part that compares your clipboard to your ::hotstrings

DragonCompare() 

{

For A , hotString in ahkScriptsArray

{

RegExMatch(Clipboard, "(?P<ClipCompare>(?<!.)::\w*\b)(?P<Input>.*)", var)

If (hotString = varClipCompare)

{

Input := varInput

Try GoSub % varClipCompare

Input := ""

Return

}

Else

Continue

}

Return 

}

End AHK coding.

 

Hope this helps someone, as DMO's lack of functionality has frustrated me to know end, and knowing others have benefited from my frustration coding will make it worth it.

 04/24/2022 09:30 PM
User is offline View Users Profile Print this message

Author Icon
NiptheZephyr
New Member

Posts: 13
Joined: 06/28/2020

Couple of additional useful bits of information:

1. If you want to pull in patient demographic information through EPIC's .SmartLinks, type the .phrase to bring it in, highlight it, cut it, assign the clipboarded info to a variable. From there you can manipulate. See my script below for how I use the patient's age to calculate their moderate vs high intensity exercise heart rates to put into their after visit summary:

 

Edited for Clarity:

BEGIN CODE:

 

Sleep 200 ;lets the hotstring get deleted

OldClip := clipboard

Send .age{space}^+{left 2}^x

Sleep 400 ;needed to be this long before it'd process the above steps.

mathsVar := clipboard

RegExMatch(mathsVar, "\d*", mathsVar)

modIntEx := Ceil((220-mathsVar)*0.6)

highIntEx := Ceil((220-mathsVar)*0.8)

var1 = 

(

Moderate Intensity Exercise of 150 min/week at %modIntEx% bpm 

Or

High Intensity Exercise of 75 min/week at %highIntEx% bpm.

)

PasteVariable(var1)

Sleep 200

clipboard := OldClip

 

END CODE

 

Sorry, the script for my PasteVariable function is as follows:

 

BEGIN CODE:

 

PasteVariable(variable)

;in order to get the below to work in notepad++, needed to add in the StrPut and VarSetCapacity stuff. This was taken from jeeswg's post on this thread: https://www.autohotkey.com/boards/viewtopic.php?t=38715

{

;Sleep, 200 ;time for the hoststring to self delete.

ControlGetFocus, activeControlVar, A

If WinActive("ahk_class Notepad++")

{

vSize := StrPut(variable, "UTF-8") +2

VarSetCapacity(vUtf8, vSize, 0)

StrPut(variable, &vUtf8, "UTF-8")

Control, EditPaste, % vtf8, %activeControlVar%, A

}

Else

{

Control, EditPaste, %variable%, %activeControlVar%, A

}

Sleep, 200

ControlGetText, controlText, %activeControlVar%, A

If !InStr(controlText, variable)

{

Sleep, 200

OldClip := clipboard ;saves current clipboard as separate variable to not lose it

Sleep, 200

clipboard := variable

Send ^v

Sleep, 400

clipboard := OldClip

}

}

END CODE


 

2. If you are in the same situation, you may want to manipulate your notes text, but since DMO/EPIC accessed through Citrix doesn't let you pull the text from your note, here is my workaround: have the script put a verbal, F3 searchable marker where you want the text to go. ctrl{end} to the bottom, place a second marker. Type/pull in your EPIC .phrases, place an end marker. F3 search your 2nd marker, ctrl + shift {end} to the bottom, cut it. Manipulate the info via coding however you need, F3 search to the first marker, paste it. Done. Only disadvantage, it will remove all formating, and gets rid of the .SmartLinks. My coding below:

 

 

BEGIN CODE:

 

OldClip := clipboard	;Saves whatever was on the clipboard prior to editing
	Sleep 200				;Gives time for the hotstring to delete
	Send ---returnMarker---	;Sets a marker to jump back to after manipulation
	Send ^{end}{enter}		;Gets to the end of note so you don't screw anything else up.
	Send ---beginMarker---{enter}	;Sets another marker
;using the native program, do whatever key combos you need to do to gather whatever info you needed.	
	Sleep 500
	Send ---endMarker---	;Puts a final marker at the end for manipulation
	Sleep 200
	Send ^f					;opens search box for navigation
	Sleep 200
	Send ---beginMarker---{enter}{esc}	;navigates to just above the pulled in text
	Sleep 500
	Send ^+{end}^x			;Cuts everything you want to manipulate and puts it on the clipboard
	Sleep 200
;RegEx or manipulate the gathered info however you need.
	Sleep 200
	Send ^f					;search box
	Sleep 200
	Send ---returnMarker---{enter}{esc}^v	;back to the spot in your note/program you need to, then paste the manipulated data.

END CODE

 



 04/25/2022 02:06 PM
User is offline View Users Profile Print this message

Author Icon
ax
Top-Tier Member

Posts: 397
Joined: 03/22/2012

I haven't used DMO myself, although I've had it demonstrated to me by a colleague who does, which was also Epic through Citrix, whereby DMO was installed on the same "server" (or remote host) from which Epic was being "streamed". The local client (which may as well be a thin client for all intents and purposes) is simply a "dummy terminal" that redirects USB sound input across the Citrix interface.

To me this way of working remotely is pure horror. But I am with you that there is no use complaining about it. It's like saying we don't want inflation. But inflation wants us (merely paraphrasing Leon who said "doesn't matter you are not interested in war ... war is interested in you").

At least you are doing something about it.

I can't stand Citrix, especially the locked down kind (which is what my office-based EMR provider gives me - not just locked down. We are talking a 2-lb titanium chastity belt - to save me from my "poor judgment"). And reading between the lines, it seems that locked-down Citrix is what they give you for remote Epic access. My hospital-based EHR is Meditech Expanse. Slow as snail (as opposed to Epic's snappiness), but reasonably flexible and fairly accessible remotely, because it is browser-based.

Anyhow back to you:

1. Is your Remote Epic so lock-down that you couldn't even put the portable AHK executable on the server? After all, DMO step-by-step is supposed to be able to call out EXE directly (if they are on the same server).

2. Therefore you are forced to use Clipboard to transmit "hotstring" or "buzzword" for local parsing by AHK on the client, in order to trigger commands?

3. I am confused as to whether you have to manually copy the "hotstring" or text you ask DMO to spit into a text field on the server ... by pressing "Ctrl-C" as a user action?

Your situation arouses my curiosity for multiple reasons (one of which is simply self-interest). But I am completely, hopelessly, and unabashedly confused by what you are trying to do. Would you mind going back to basics, without any code, and explain the problems facing you and the workaround you found necessary?

Regards,

 04/27/2022 10:45 AM
User is offline View Users Profile Print this message

Author Icon
NiptheZephyr
New Member

Posts: 13
Joined: 06/28/2020

Howdy Ax,

 

Sorry for taking so long to reply.

 

1. Yeah, pretty much that locked down. We don't really have "server" access, just client. Sitting in the office, at my workstation, EPIC and DMO are accessed through the Citrix client, to the point where DMO cannot type in any other program, including Notepad, even with the Dictation box. If I try to remote from home into my "Desktop" I don't have access to EPIC or Dragon. I have to separately remote into them on the Citrix client.

 

2. Yup.

 

3. Sorry for my poor description. I have DMO's step by step do the cutting. So the step by step command goes something like

1. Send Text :ahkCode

2. HotKey "shift home"

3. Hotkey "Ctrl X"

 

Again, sorry for my poor description. You pretty much have the understanding completely right. My limitations are that I only have DMO, so can't MouseMove, Click, or manipulate variables. Second limitation is that DMO is technically completely server side in Citrix, so it's typing is not recognized by AHK. AHK is allowed, and solves the above, but is text only, not speech, which is inconvenient to move back and forth between holding the powermic and typing. My solution is a script I designed in AHK which monitors the clipboard for my ahk commands, and have DMO stwp by step commands that type the script and copy it on to the clipboard for AHK to recognize. I've posted the workaround in this thread just in case anyone else in a similar hospital system needs such a workaround.

 

Only thing left is to figure out a way to verbally get DMO to type into other programs remotely as mentioned in "2.". I can always have it type in the Dictation box, then me manually highlight all, copy and paste to the desired program, which sucks. My current above workaround script with ahk doesn't work, because when the Dictation box is open, it seems that DMO won't execute it's Step-by-steps.  *shrug* I'm sure I'll think of something. 

 04/27/2022 10:49 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 39832
Joined: 10/01/2006

#2 I'm not running DMO at the moment, but there is a non default Dictation Box option that allows you to force dictation into any field; similar to a stripped down version of DragonCapture.

-------------------------

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1

 04/27/2022 02:01 PM
User is offline View Users Profile Print this message

Author Icon
NiptheZephyr
New Member

Posts: 13
Joined: 06/28/2020

Thanks Lunis. I've ready about that in trying took for workarounds, but was not able to find it in my options. Tried all the transfer text methods. When nothing worked I reached out to our IT and they said it was a byproduct of how it was set up. While that could mean "we didn't pay Nuance to turn it on", it sounded more like that DMO "existed" only in the Citrix environment and couldn't even "see" other programs besides EPIC, since they were both in the Citrix environment. 



 04/29/2022 07:14 PM
User is offline View Users Profile Print this message

Author Icon
ax
Top-Tier Member

Posts: 397
Joined: 03/22/2012

@ OP:

Your workaround is quite a clever use of resource given the constraints facing you!  I'd have to digest your hotstring routine some more to understand it fully.  FWIW, clipboard is instrumental to my own workaround as well, but only as a means to get text across the browser/host sandbox boundary, using Javascript.  I don't use clipboard to parse anything.  But you have definitely given me additional ideas.  Thanks for sharing!

 

I reckon there is a 30% chance in 3 years and 50% chance in 5 years that the hospital I work at may embrace Epic and your style of set-up.  I think your set-up is quite popular with large institutions, if not the "default" already.

It is essentially "anti-physician" IMHO (not Epic, but the remote setup).  But the world has put up with anti-human practices for years - why should we physicians be exempt?  Having said that, it still rubs the wrong way (no pun intended) that I PAY my EMR provider to slap that chastity belt on my own access - to frustrate me.  And MFA is also coming to my EMR ... Is that Ag smirking in the corner?  Yup that's what "industry" folks do: protecting me from me.

Correction: they are protecting me from the infamous "anonymous".  Next to chopping firewood to save you from getting blackmailed by poutine, we still got a way to go yet.

It does make me appreciate my browser-based Meditech Expanse EHR, which doesn't require Citrix or other VDI to access remotely.  But did I mention it's sluggish?

Anyhow, now that we got venting out of the way ...

1. There is locked-down and there is locked-down.  Is your Epic/DMO server so locked-down to the point that you couldn't even call C:\Windows\System32\notepad.exe or C:\Windows\System32\cmd.exe (or their equivalent) on your server from DMO directly? 

 

Granted, even if you launch notepad.exe on your server, you seem to indicate that you still may not be able to dictate into it.  But if you could launch cmd.exe from your server, by using DMO to call out the executable, then you would, in theory anyway, have easier, more direct access to clipboard.

2. If you cannot install a copy of DPI on your client machines in the office (as I certainly can't in the hospital), I highly recommend giving VoiceMacro a test-drive.  This nifty, portable utility first caught my attention after being mentioned by one of the regular A-listers, PG, right here on this forum. 

 

I liked it so much that I did a review of it.  It surely isn't your Panzerhaubitze 2000, as the kind of voice-driven howitzer ala desktop dragon.  But it definitely got the flexibility and portability of Javelin.  Set up as a command-only tool, VoiceMacro is "lethal".  I am quite a fan of it and use it daily almost.



 04/30/2022 07:31 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 39832
Joined: 10/01/2006

We doubt your IT people are correct but it's easy to see why they would draw this conclusion. We believe it is nothing more than their network being too slow for DMO to transfer your text commands. If you had a way of creating Advanced-Scripting commands, you could slow the text down with SendKeys, which is available in local installations of Dragon. This should work in Lindsay's upcoming Scripting utility which will eventually allow you to create your personal Advanced-Scripting commands but you will have to wait a wee bit longer.

-------------------------

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1

Statistics
32305 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 488 guests browsing this forum, which makes a total of 488 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.