You're correct, Darius. The set ID of HL7 segments (like PV1-1) is used for transaction numbering (usually sequential within a message or group of message) and is not the place for identifiers. Systems don't always depend on a set ID being filled, but in some cases this field can be used to ensure ordering of messages/segments as they're being processed.
An encounter identifier should go into a field like PV1-19 (Visit number).
Good catch, Darius. I smell a ticket coming. 
-Burke
On Dec 13, 2008, at 6:15 PM, Darius Jazayeri wrote:
> Hi All,
>
> Our lab system's ability to send HL7 messages to OpenMRS broke when we upgraded to 1.4.x, and stepping through the code I came across a change I'm not sure I agree with.
>
> The changeset is rev:5438 at http://dev.openmrs.org/changeset/5438
>
> In this changeset we start treating the HL7 PV1 Set ID as an existing encounter ID, so if it's specified, then we append observations to that encounter, rather than create a new one.
>
> Here's the definition from chapter 3 of the HL7 manual:
>
> 3.4.3.1 PV1-1 Set ID - PV1 (SI) 00131
> Definition: This field contains the number that identifies this transaction. For the first occurrence of the
> segment, the sequence number shall be one, for the second occurrence, the sequence number shall be two,
> etc.
>
>
> When I read this before I interpreted that to mean that the first PV1 in a message should be 1, the second is 2, etc. This is clearly wrong. But I'm not sure I buy that it means encounter id either.
>
> Anyone know the right usage for this?
>
> -Darius
Fixed in rev:5438