Algorithms – How to Calculate the Checksum for LIS Frames

algorithms

I am developing instrument driver and I want to know how to calculate checksum for a Laboratory Information System (LIS) frame.

Explanation:

Expressed by characters [0-9] and [A-F].

Characters beginning from the character after [STX] and until [ETB] or [ETX] (including [ETB] or [ETX]) are added in binary.

The 2-digit numbers, which represent the least significant 8 bits in hexadecimal code, are converted to ASCII characters [0-9] and [A-F].

The most significant digit is stored in CHK1 and the least significant digit in CHK2.

This is sample frame :

<STX>2Q|1|2^1||||20011001153000<CR><ETX><CHK1><CHK2><CR><LF>

and I want to know what is value of chk1 and chk2 and I am new in this so I am totally blank about how to calculate checksum

I am not getting above 3rd and 4th point.

Can anyone provide sample code for c#?

Best Answer

Speaking as someone who has developed an entire LIS communication protocol from serial driver to strongly typed entities for a machine used in hundreds of different labs.

I've come to a lot of conclusions (short list):

  1. The LIS Spec is bullshit (every LIS vendor has their own implementation which differs from every other) every hospital/lab LIS differs in the way the handshaking is written.
  2. The Frame "Checksum" is nothing more than a stupid calculation which is meant to make people who wrote the spec feel better (it is in no way a good checksum as it can be easily overcome)
  3. Whoever wrote the "State Machine" documentation for the LIS spec was a hack. As it does not properly convey any state nor transition (it is best to extrapolate your own stat machine than try to make sense of the drawing)

That being said:

http://www.hendricksongroup.com/code_003.aspx

Is a really simple example of how to calculate a checksum for an LIS frame.

If you are writing an LIS Driver my advice to you is to get LOTS of logs from the vendor (so that you may see exactly the communication taking place) you are connecting to and write LOTS of unit tests to match those logs, (that and if it needs to be for more than one vendor to make it EXTREMELY flexible). Oh and add lots of logging for yourself.

Related Topic