The counter file has a limit based on the size set when it is initialized.
The default is something like a 9 digit value.
The initialization allows you to set the name for the counter file, the initial value, the maximum default, and the reset value.
All of this is covered in the Cloverleaf(R) Reference Guide under Tcl Extensions –> Counter Commands
What we use here is a concatenation of the epoch time (we are AIX) a 4 character literal (typically identifying the source of the message) and a 4 digit counter.
The above pretty much assures a unique message control ID (assuming proper use of the literal value) vertically and horizontally (that is within a given system and among various systems).
The reason we use the counter is the epoch time is only resolved to the second. We definitely send many messages per second to the destination. The counter breaks the tie. The literal provides for uniqueness when messages from multiple source systems of various types (ADT, Orders, Results) and Sources (Multiple Hospitals, Regular Lab, Radiology, dictation, etc.) are to be sent to a single system which requires each MSH have a unique NEVER repeated control ID.
Remember the MSH-10 Control ID does not have to be numeric. It is not necessarily a sequence number (that is another MSH field).
Theoretically randomly assigned characters could be used for MSH-10.
Many receiving systems are not as picky as the one for which the above was designed. But the Control-ID we use can be utilized for any system and virtually any message construct where control ids are needed (HL/7, X12, etc.).
Ideally we would like all source systems to provide a uniques Control ID. That way we can easily trace the message through the engine and onto it’s final destination as well as matching the acknowledgments to the original message.
Alas, that does not happen very often and when it does, the Control IDs provided are typically just counters that eventually repeat. That means multiple source systems could send messages with identical Control IDs.
So we have this proc for when the source system does not provide a Control ID.
I like doing it in the Xlate rather than a outbound proc because then the Control ID stays with the message on a resend (one does not have to remember to resend post TPS).
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.