Sorting Messages
The first question you might ask is “why would you want to sort messages?” Let's consider the scenarios below:
- Messages in a given file have been saved in a different order from how they were received.
- You have opened several files into a single Message Tab using the “Open Folder” feature (see Opening/Loading HL7 Messages for more details). In this case, the files are not likely to be opened in the correct order and the messages in the Message Tab will be out-of-order.
- You have “Merged” to Message Collections into a new collection and wish to order the messages in the new message collection by the Control ID (MSH-10) so that they are in time sequence order.
- You want to find the largest message in a Message Collection.
The search dialog can be displayed by clicking on the "Sort Order" button, and the following dialog is displayed.
The radio button options provide some of the more common sort orders that one might want to use. Please see below for descriptions of each:
Message Sort Order
- Default (MSH-7, MSH-13, MSH-10) - This option sorts all messages in a Message Collection by “Message Control ID,” then by “Message Sequence Number”, then by “Date/Time of the Message” This is usually a pretty robust option to sort messages in their natural, or received order provided that they come from the same HL7 source.
- Control ID (MSH-10) - This option sorts all messages in a Message Collection by “Message Control ID."
- Sequence Number (MSH-13) - This option sorts all messages in a Message Collection by “Sequence Number."
- Patient ID (PID-3) - This option sorts all messages in a Message Collection by “Patient ID."
- Patient Name (PID-5.1.1, PID-5.2.1) - This option sorts all messages in a Message Collection by “Patient Last Name," then by "Patient First Name."
- Message Offset - This option will allow you to sort messages in a Message collection in the original order that they appear within a given file. This is useful to revert a previous sort performed on a Message Collection.
- Message Size - This option is useful if you want to find the largest or smallest message in a Message Collection. (After sorting the smallest message will be the first message, and the largest will be the last.)
- Custom Sort - If the predefined “field” sort options do not have the sort criteria you are looking for, you can always define your own. The syntax of a custom sort is: Field1 [ASC|DESC], Field2 [ASC|DESC]... You will notice that if you select any of the other radio buttons (except Message Size and Message Offset) that the “Sort Expression” dialog is updated with the proper syntax, so you have some examples to follow.
- Don't Sort - This option will not perform a sort.
- Open results in new tab - If this option is selected, the sorted collection is placed in a new Message Tab, and the existing tab is left unchanged.