I was writing HL7 Acknowledgement mechanism on my own.
From the online documentation I followed, they state that a Hl7 acknowledgement message has following segments
MSH
MSA
ERR [ optional ]
And I am wondering - if there are multiple errors exists in HL7 file, can I put multiple ERR segments to describe each error? Is there any standard for this?
It depends.
As of HL7 v2.5, you would put each error into its own ERR segment, populating field ERR-2-x (cf. ch 2.15.5 of the standard)
Before 2.5 you would have a single ERR segment and describe each error into its own repetition of the (repeatable) field ERR-1.
Related
I am new to Health care domain's project. In this project I am having a batch HL7 file that contains multiple patient information in the below format.
FSH
MSH
PID
OBR
OBX
MSH
PID
OBR
OBX
OBX
SO my concern is that MSH segment can be a different in same batch file or it should be same.
Any help will be appreciated.
The MSH header would typically be different betweeen the different records as each set of segments describes one complete transaction (with some execptions). In a batched layout, where the transmission may occur because of an accumulation of records over time that is sent out to the destination on some time interval, there would be several expected differences. If you consider the link below that describes the field layout for the MSH segment, I would at a minimum expect that the date time of message in the batch to differ based on when the actual event occurred and the message control id.
It would also be possible for the message type to differ depending on what your batch reflects. I included a link to the Texas immunization batch specification that expresses a uniqueness constraint on the MSH msg control id
http://www.corepointhealth.com/resource-center/hl7-resources/hl7-msh-message-header
https://www.dshs.state.tx.us/immunize/docs/immtrac/HL7_Data_Transfer_Guide.pdf
You can have different MSH in a HL7 file containing batch results. I am developing HL7 interfaces since last 10 years. As message header can change for results it is possible to do so. You can have same MSH for all results or different MSH for every result in a batch file.
I am new to CAN protocol, going through the Robert Bosch's CAN Specification ver2.0 Part B. I can't understand the following lines on page 63
" Note:
Start up / Wake up:
if during startup only one node is online, and if this node transmits some message, it will get no acknowledgement, detect an error and repeats the message. It can become 'error passive' but not 'bus off' due to this reason."
As far as I understand when a transmitter detects an error(like Acknowledgement error) it retransmits the message and also increments the transmit error count (TEC) by 8. So if there is only one node then its TEC should increase by 8 everytime it transmits a message and should go into 'bus off' condition once TEC goes above 255.
Can someone please explain why the specification says it can only go 'Error Passive' but not 'Bus off'?
I think you missed this part of the specification:
"Exception 1:
If the TRANSMITTER is 'error passive' and detects an ACKNOWLEDGEMENT ERROR because of not detecting a 'dominant' ACK and does not detect a 'dominant' bit while sending its PASSIVE ERROR FLAG.
"
In this case, the TEC is not changed!
So, in your case, when the only node in the network re-transmits every time and the TEC becomes >= 128, it becomes 'error passive'. Then the above exception case becomes valid! And the TEC is no more changed! Hence no 'bus off'.
Yes, that is correct as if the Tx ECU is not receiving any ACK from any ECU in the CAN network then it will stay in Error passive state.
Because the Networking protocol needs when more than one systems are available in CAN network and if no ECU available in the network, then it is not meaning as the ECU is having an issue, so instead of going to CAN bus off state it should stay in Error passive state.
To know more about CAN error, you can follow the below link:
This question is on HL7, my understanding is that any segment(sch, pv1 etc) in HL7 is independent of message type(ADT, SIU etc), that means any type of message can contain any type of segment and there are no restrictions that a particular type of message type can have only certain segments and not any segment, am I correct?
Hope my question is clear...
Not exactly. HL7 has many segments and trigger events, each having a specific purpose and action. Out of that whole lot, when someone is designing a healthcare interfacing application, they have to choose the right segments and trigger events. That is called cardinality which requires a definition of:
Mandatory segments (MSH,PID,PV1 etc)
Optional Segments (DG1,PR1,AL1 etc)
Repeating Segments (OBX)
Once cardinality is defined, then the message starts taking its shape.
A patient demographics trigger event shall include MSH, EVN, PID, PV1, IN1, GT1. But not necessarily DG1, PR1 and AL1.
Similarly, a charge message should definitely include FT1 (financial transactions) segment in the message. An order message should definitely include OBR and ORC segments.
Each segment in HL7 has a defined purpose. There isn't any point in including FT1 in demographics message or an OBR in an SIU message (just an example).
What an application can or cannot send out is called specification of that application.
It is required to understand message cardinality. One cannot create an HL7 message on the fly. It is neither technically feasible nor logically correct.
There is one more segment type called āZā segment which carries the user defined information and is not defined by HL7. For example, ZDS contains additional ID for the imaging study. The number and coding of Z segments are also user defined.
In order to process such segments both sending and receiving applications must agree on the format, which potentially leads to errors.
I am about to write a message protocol going over a TCP stream. The receiver needs to know where the message boundaries are.
I can either send 1) fixed length messages, 2) size fields so the receiver knows how big the message is, or 3) a unique message terminator (I guess this can't be used anywhere else in the message).
I won't use #1 for efficiency reasons.
I like #2 but is it possible for the stream to get out of sync?
I don't like idea #3 because it means receiver can't know the size of the message ahead of time and also requires that the terminator doesn't appear elsewhere in the message.
With #2, if it's possible to get out of sync, can I add a terminator or am I guaranteed to never get out of sync as long as the sender program is correct in what it sends? Is it necessary to do #2 AND #3?
Please let me know.
Thanks,
jbu
You are using TCP, the packet delivery is reliable. So the connection either drops, timeouts or you will read the whole message.
So option #2 is ok.
I agree with sigjuice.
If you have a size field, it's not necessary to add and end-of-message delimiter --
however, it's a good idea.
Having both makes things much more robust and easier to debug.
Consider using the standard netstring format, which includes both a size field and also a end-of-string character.
Because it has a size field, it's OK for the end-of-string character to be used inside the message.
If you are developing both the transmit and receive code from scratch, it wouldn't hurt to use both length headers and delimiters. This would provide robustness and error detection. Consider the case where you just use #2. If you write a length field of N to the TCP stream, but end up sending a message which is of a size different from N, the receiving end wouldn't know any better and end up confused.
If you use both #2 and #3, while not foolproof, the receiver can have a greater degree of confidence that it received the message correctly if it encounters the delimiter after consuming N bytes from the TCP stream. You can also safely use the delimiter inside your message.
Take a look at HTTP Chunked Transfer Coding for a real world example of using both #2 and #3.
Depending on the level at which you're working, #2 may actually not have an issues with going out of sync (TCP has sequence numbering in the packets, and does reassemble the stream in correct order for you if it arrives out of order).
Thus, #2 is probably your best bet. In addition, knowing the message size early on in the transmission will make it easier to allocate memory on the receiving end.
Interesting there is no clear answer here. #2 is generally safe over TCP, and is done "in the real world" quite often. This is because TCP guarantees that all data arrives both uncorrupted* and in the order that it was sent.
*Unless corrupted in such a way that the TCP checksum still passes.
Answering to old message since there is stuff to correnct:
Unlike many answers here claim, TCP does not guarantee data to arrive uncorrupted. Not even practically.
TCP protocol has a 2-byte crc-checksum that obviously has a 1:65536 chance of collision if more than one bit flips. This is such a small chance it will never be encountered in tests, but if you are developing something that either transmits large amounts of data and/or is used by very many end users, that dice gets thrown trillions of times (not kidding, youtube throws it about 30 times a second per user.)
Option 2: size field is the only practical option for the reasons you yourself listed. Fixed length messages would be wasteful, and delimiter marks necessitate running the entire payload through some sort of encoding-decoding stage to replace at least three different symbols: start-symbol, end-symbol, and the replacement-symbol that signals replacement has occurred.
In addition to this one will most likely want to use some sort of error checking with a serious checksum. Probably implemented in tandem with the encryption protocol as a message validity check.
As to the possibility of getting out of sync:
This is possible per message, but has a remedy.
A useful scheme is to start each message with a header. This header can be quite short (<30 bytes) and contain the message payload length, eventual correct checksum of the payload, and a checksum for that first portion of the header itself. Messages will also have a maximum length. Such a short header can also be delimited with known symbols.
Now the receiving end will always be in one of two states:
Waiting for new message header to arrive
Receiving more data to an ongoing message, whose length and checksum are known.
This way the receiver will in any situation get out of sync for at most the maximum length of one message. (Assuming there was a corrupted header with corruption in message length field)
With this scheme all messages arrive as discrete payloads, the receiver cannot get stuck forever even with maliciously corrupted data in between, the length of arriving payloads is know in advance, and a successfully transmitted payload has been verified by an additional longer checksum, and that checksum itself has been verified. The overhead for all this can be a mere 26 byte header containing three 64-bit fields, and two delimiting symbols.
(The header does not require replacement-encoding since it is expected only in a state whout ongoing message, and the entire 26 bytes can be processed at once)
There is a fourth alternative: a self-describing protocol such as XML.
I'm having a mental block for the words describing data flow in a communications protocol + google isn't helping, due to information glut.
In the following scenarios A and B are communicating to each other.
command or request: a packet of data going from A to B indicating that B should take some kind of action
response: a packet of data going from B to A in response to a particular packet that A has previously sent to B.
acknowledge or ACK: a specific kind of response that just indicates Yes I got that packet of data. (negative acknowledge or NAK indicates No there was some problem receiving data)
{X}: unsolicited information either from A to B, or B to A, which is neither a response, nor a request for the recipient to take action. Examples: datalogging packets, notification packets, etc.
I can't think of what to call {X}, I'm having a brain cramp.
Also are there other common words in this category? Where would you look them up?
Why not call your "X" just "Message" or "Signal" ?
For some inspiration regarding this subject, may I suggest the IETF or ITU-T standards bodies. These two bodies are dominating the communications scene.
I would following the terminology in Steven's TCP/IP Illusrated
So you have a request, response, acknowledement, push and poll are used if I remember correctly