Hello,

Generally speaking, my scripts work OK when conditions are good.  It's
when the "edge" cases of Meditech client instability, network link
failures etc., come into play.

I sure would appreciate reading about the strategies successful
scripters use so they can sleep at night and know their scripts are
printing things such as pharmacy MARs reports reliably every evening.

Unfortunately, the network instability is something totally out of my
control - as is the Meditech installation.  (We are geographically
about 300 miles away from our data centre hosting the Meditech
servers).  Overall, it's pretty good, but we'll see a few Citrix
session drops a week, and a few times per day the 3 Tier Meditech
client's startup/shutdown will take anywhere from .5 seconds to a few
minutes, or completely freeze.  Obviously I'd have a lot more hair if
this situation improved ... but I still need to build some type of
error recovery, and this environment seems like a real good place to
perfect error recovery coding.

My strategy so far has been to use a VB6 EXE and the three tier client
for the added Boston Scripting functionality.  MeditechCS connection
BTW.

When the time comes to run the report.

Start the Meditech client.
Set a timeut of a couple of minutes.
Save the window handle.
Set an on error goto
Do normal script processing that generally works fairly well.
Call Shutdown and exit.

The error handler looks like this:
-------------
ScriptError:
        Logit ("RunMedStan - Error handler:  " & Err.Source & " " &
Hex(Err.Number) & " " & Err.Description)
        If Err.Number = seDoEvents Then DoEvents: Resume
        Call ExitMeditech
        Logit ("Error handler finished.")

The ExitMeditech sub looks like this:

Sub ExitMeditech()

  Dim I As Integer

  If Active Then
     Logit ("ExitMeditech:  Attempting to shutdown and exit.")
     Logit ("ExitMeditech:  Sending 4 ESCs - waiting 1 second between each.")
     For I = 1 To 4
       Key "{ESC}"
       Wait 1#
     Next
     Logit ("ExitMeditech:  Sending 4 ESCs - waiting 0.25 second between each.")
     For I = 1 To 4
        Key "{ESC}"
        Wait 0.25
     Next
     Logit ("ExitMeditech - Connecting to non existant stream.")
     Connect "fred", stStream     ' Close Boston Scripting
     Logit ("ExitMeditech - Setting Shutdown=True")
     Shutdown = True
     Wait 0.5
     Logit ("ExitMeditech:  Meditech client should be closed.")
     Logit ("ExitMeditech:  Sending @_UNLOAD")
     Key "@_UNLOAD"
  Else
     Logit ("ExitMeditech:  Meditech doesn't appear to be active.")
  End If
  '
  '  If the Window is still hanging around.
  '
  If IsWindow(meditech_hwnd) Then
    Logit ("ExitMeditech - hwnd still valid, killing process.")
    KillProcess (meditech_hwnd)
  End If

End Sub

Thanks,
Henry Hansen @ Palliser Health

Reply via email to