More bizarre picture of the traditional Perl Camel Perl Script Page

This page provides links to Perl Scripts written by Datagate users and contributed freely to this site.  All scripts can be considered open source.  Use of these scripts in a production environment is at the user's risk.


Current Offerings

    Name                    Description
parselogs.pl
Jacek Zagorski's log parsing utility.  Reads a Datagate log file, and, depending on the command line options, break each HL7 segment into it's major (i.e., field) components.  Additional command line options allow for different segment delimiters if the user modifies the source (easy to do!).
PYXIS.PL.new Helen Galluppi's (hgalluppi@hlinkinc.com) Perl script that opens the errMsg log file and reads thru to find Pyxis ID errors.  The errors were a result of a Pyxis charge interface that are not sent to the receiving system because they do not have one of the following:  1) A valid account number; 2) A non numeric item number; or 3) A patient name of ER STOCK or EAP.  These are reconciled by the user at a later time.
hl7srvr.pl
hl7srvr.rtf
hl7srvr.pl is a Perl script that sets up an HL7 compatible tcp/ip server that can be run on any platform that supports V5.0x of Perl (Unix, Linux, Windoze 9x, NT, etc., etc) and is connected to a tcp/ip network.  I've run it on a  Sun Sparc and Ultra 2 (solaris 2.5.1) and on my Windows 95 workstation.  The Perl script listens on a socket (command line designated) for incoming HL7 messages enveloped in the AAU-approved MLLP (i.e., 0x0b <message> 0x1c 0x0d), writes the incoming message to a file (also command line designated), and sends an HL7 MSA ack back to the sender of the message (presumably Datagate).  The ACK is also MLLP enveloped and formatted as an "AA" on a "good" HL7 message or an "AE" on a malformed message.  Malformed messages are those that do not start with an MSH.  I've tested this server with a Datagate 3.5 super client "client" delivering messages to hl7srvr.pl running on both my sun boxen and my Windoze 95 workstation and it works fine.  hl7srvr.rtf is a rich field format README file and contains more info on hl7srvr.pl's use and how to run it.  Questions or problems?  E-mail me at: bdilworth@mco.edu
stdsrvr.pl
stdsrvr.rtf
stdsrvr.pl is a Perl script that sets up a non-HL7 tcp/ip server that can be run on any platform that supports V5.0x of Perl (Unix, Linux, Windoze 9x, NT, etc., etc) and is connected to a tcp/ip network.  I've run it on a  Sun Sparc, an Ultra 2 (solaris 2.5.1), on my Windows 95 workstation, and on a Windows NT box (4.00.1381 service pack 6).  The Perl script listens on a socket (command line designated) for incoming messages enveloped between an ascii 11 and an ascii 28,  writes the incoming message to a file (also command line designated), and sends a single character ack (ascii 6) back to the sender of the message, also enveloped between an ascii 11 and an ascii 28.  Since this server is non-HL7 it is difficult for it to determine if the data it's received is OK or not so it never sends a NAK.  You can add such functionality to the script yourself, of course, if you're so inclined.  I've tested this server with a Perl TCP/IP client script (stdclient.pl) running on a SUN box and an NT box and it works fine.  stdsrvr.rtf is a rich field format README file and contains more info on stdsrvr.pl's use and how to run it.  Questions or problems?  E-mail me at: bdilworth@mco.edu
hl7client.pl
hl7client.rtf
hl7client.pl is a Perl script that creates a TCP/IP client that will connect to an associated TCP/IP server, read a queue file of HL7 records, and deliver those records to the server.  The script kind of assumes that it'll be delivering data to an HL7 Datagate inbound comm client (e.g., an ScTcpHl7 super client) and that the usual Datagate-ish stuff applies - enveloping of the data sent to the server as well as around the ACK/NAK sent back to hl7client.pl from the server.  There is a multitude of command line options to control its behavior, but there are certain assumptions made about its operation that make it a bit less than totally flexible.  These assumptions revolve mostly around the queue file which is discussed in the associated readme file (hl7client.rtf)  as well as some hard-coded values that can be easily changed by editing the script.  Questions or problems?  E-mail me at: bdilworth@mco.edu
stdclient.pl
stdclient.rtf
stdclient.pl is a Perl script that creates a TCP/IP client that will connect to an associated TCP/IP server, read a queue file of records, and deliver those records to the server.  The script kind of assumes that it'll be delivering data to a non-HL7 Datagate inbound comm client (e.g., an ScTcp super client) and that the usual Datagate-ish stuff applies - enveloping of the data sent to the server as well as around the ACK/NAK sent back to stdclient.pl from the server.  There is a multitude of command line options to control its behavior, but there are certain assumptions made about its operation that make it a bit less than totally flexible.  These assumptions revolve mostly around the queue file which is discussed  in the associeted readme file (stdclient.rtf) as well as some hard-coded values that can be easily changed by editing the script.  Questions or problems?  E-mail me at: bdilworth@mco.edu
stopcli.pl
stopcli.rtf
This Perl script is designed to be used in conjunction with stdclient.pl and hl7client.pl.  The script reads a file (command line specified) containing the process ID (PID) of the client process you wish to stop.  The script uses Perl's kill function and sends a signal 16 to the process in question.  Both stdclient.pl and hl7client.pl have registered signal handlers that will trap the signal and cause the client to gracefully exit.  Please note that signals are not supported on Windows products (NT included), at least at this time, so sending any signal to a ^(std|hl7)client.pl will cause it to stop  immediately.  Questions or problems?  E-mail me at: bdilworth@mco.edu
PerlRoolz.jpg
Snapshot (JPEG file) of  Jeff Drumm sporting his Perl (or is it perl?) tattoo.  Pretty snazzy.  Not for the faint of heart, however.  Definitely PG-13.
mrg-fils.pl
ins-crlf.pl
Louisa Jones's preprocessor Perl scripts for those pesky lab files that come in with a crlf at the end of each segment.  The script inserts another crlf before an MSH segment.  Your ScFtp client will need to delimit messages with \n\n. 

Mrg-fils.pl:   the particular lab for which this script was written uses as rs*.* naming convention and one might download several files at once.  My ScFtp client wants just one file and the same filename each time.  So this script knits together all the little rs*.* files and creates newfile.dat. You will probably want to insert a system call to move the file to your data directory searched by your ScFtp. 

Ins-Crlf.pl:  the particular lab for which this script was written generates one file per day names as X*.*.  Frequently, there will be two files when there were leftover results from the previous day.  So this script knits together the lab files and inserts the crlf before the MSH segments.  It creates two files, newfile.dat and labcorp.dat.  Labcorp.dat is the final file.

 cleanold.pl
cleanold.txt
The cleanold.pl Perl script is another attempt at cleaning up after DataGate comm client and server log file droppings. It's currently 
designed to be run manually, providing status information about the log files and directories it's manipulated. It can be easily adapted 
to unattended use (via cron) by simply commenting out some print statements.  Contributed by Jeff Drumm

cleanold.txt is the README file for the Perl script.

CHG_ONE_QA
CHG_ONE_PROD
Seth Rothenberg of the Montefiore Medical Center contributes these two Perl scripts used for moving Datagate files into production.  Montefiore creates unique file names for each unique inbound-outbound pair.  Shared table files (atb, ptb, rtb, etc.) are named inbound2outbound.xxx.  Translation tables (dtb) are all named uniquely using a similar method. Please note that these scripts cannot be used as-is, but should be used only to understand methods.  Both scripts were written by Rimma Maro at Montefiore. 

CHG_ONE_QA  looks in $DATAGATE/chg tree for files in the form ending with a change #, and the script moves that change into $DATAGATE/tables/build, and then regenerates the table.  Non-shared files are just copied to the correct place.  A copy of any new file is also placed in $DATAGATE/pending_prod.  Old files are saved in prev/.  Follow-up with Suspend/Reload Hard/Activate. 

CHG_ONE_PROD  requires a change number and moves only the requested change from QA:$DATAGATE/pending_prod  to  PROD:$DATAGATE/pending_prod, then it rebuilds the Prod table, saving the previous files in prev/  Follow-up with Suspend/Reload Hard/Activate. 

 

crack.pl
crack.rtf
view.pl
view.rtf
crack.pl is a little Perl script that will break apart (i.e., "crack") an HL7 transaction into it's field components and display those components, appropriately labeled, on the terminal screen.  crack.pl gets its input from STDIN and writes its output to STDOUT so it's "normal" use is as a filter.  crack.rtf is the README file for crack.pl and describes how to use it and provides a sample of its output.  crack.pl's screen output is similar to the screen output produced by Jacek Zagorski's parselogs.pl script above.  Thanks Jacek! 

view.pl is a little teeny Perl script that displays an HL7 message on the terminal screen with each HL7 segment on a separate line.  The reason for view.pl is because some HL7 messages are too long to view using vi.  I find this to be a pain I the butt.  I know I could use emacs or some other editor that isn't as lame as vi but that would be cheating.  Anyway, if you're stuck with vi, view.pl may be useful to you as a quick and dirty HL7 blob viewer.  view.pl pl gets its input from STDIN and writes it's output to STDOUT so it's "normal" use is as a filter.  view.rtf is the README file for view.pl and describes how to use it and provides a sample of its output.  Contributed by Bob Dilworth

transchk.pl
transchk.dat
transchkPL.rtf
It is occasionally useful to know if a particularly long period of time has elapsed between transactions for a given comm client.  Such stall situations can indicate a problem with the ancillary system, the comm client, or Datagate itself.  Here at MCO, for example, our Quadris radiology system occasionally fails to send results, orders, or charges over the connection due to an internal processing error on the Quadris side yet remains connected with Datagate (comm client remains white).  The only way we can tell if this is happening is to look at the Datagate log file for the inbound comm client and see if an inordinately long period of time has elapsed since the last transaction was received.  An automated solution, transchk.pl, was developed to provide a more proactive approach to detecting such problems. 

transchk.pl works by comparing the last modify time of the of the comm client's live log  file against the current time.  An e-mail notification is sent if the difference between the two times (in minutes) is over the configured threshold (in minutes) for the log file. 

PLEASE NOTE THAT THE SCRIPT HAS BEEN MODIFIED TO USE THE COMM CLIENT'S LOG FILE INSTEAD OF AN EATER FILE. 

transchk.pl is the Perl script, transchk.dat is an example configuration file, and transchkPL.rtf is the read-me file.  Script contributed by 
Bob Dilworth

ifmonster.pl
ifmoster.rtf
ifmonster can be used to monitor both in- and out-bound comm clients, checking both the connection status and the elapsed time since a record was sent or received. If a error condition is detected ifmonster will send an email to everyone in either the warnList or the critList, depending on the length of time the condition has persisted. Warning emails are polite requests to check the external system. Critical emails are more insistent that action is taken and / or someone is paged.  Contributed by Bill Rowley, Cooper Health System.
julian
julian.rtf
julian is a dumb little Perl script that will convert real dates to julian and julian to real dates.  The word "julian date" is actually a misnomer and, in this context, actually refers to the "day of the year".  At any rate, julian will do the following:

1. Return the current date's day-of -the-year when called with no parameters (e.g., julian)
2. Return the day-of-the-year of a date specified on the command line (e.g., julian 02/12/01)
3. Return the appropriate date of the current year when a day-of-the-year is specified on the command line (e.g., julian -j 34)
4. Return the appropriate date in the future (from "today") when a number of days is specified on the command line (e.g., julian -f 1000)

Please note that the Perl modules Date::Calc, and Getopt::Std are required to run this script.

julian.rtf is the README file
Contributed by Bob Dilworth, Medical College of Ohio
 

home