Reference·MRG Segment·MRG-7
HL7 v2 Reference

Understanding HL7 v2 MRG-7: Prior Visit Number in Practice

Jul 27, 2026 · 4 min read
← MRG-5

A patient merge that happens mid-encounter leaves MRG-7 pointing at a visit number that orders and results might still be actively writing to.

Quick answer

MRG-7 carries the visit or encounter number tied to the losing patient record, letting a receiving system know which in-progress or historical visit needs to be reassociated with the surviving patient. Unlike MRG-1's MRN or MRG-4's account number, a visit number often represents something time-sensitive — an encounter that may still be open when the merge message arrives.

What this field contains

ID Number
First component — the retiring visit number value, tied to a specific encounter rather than the patient as a whole
Assigning Authority
Fourth component — the facility or system that issued the retiring visit number
Timing sensitivity
Practical note — a visit tied to this number may still be open or actively receiving orders and results at merge time

Example

Synthetic example Generated by Synthibase
MRG|847213609^^^HOSP^MR|||55219847^^^HOSP^AN|ACC-102938

This synthetic example omits MRG-7, reflecting a merge where the losing record had no visit currently in progress.

Where this trips people up

The riskiest scenario for MRG-7 isn't a malformed value, it's timing: a merge message arriving while the retiring visit number is still receiving orders or results from other feeds. If the merge is processed before those in-flight messages, they can land against a visit number that no longer resolves to an active patient context. Test suites should include a scenario where order or result messages referencing the old visit number arrive both before and after the merge event, not just a static snapshot with no concurrent traffic.

HL7 v2 MRG Segment Guide: Fields, Format, and Testing Gotchas
HL7 ADT Messages: A01 through A08 Explained
How to Build a Synthetic Patient Registry for Healthcare Testing
Test merges against in-flight encounter traffic
Synthibase can sequence merge messages alongside concurrent order and result traffic referencing the retiring visit number, so timing bugs surface in testing instead of on a live floor.
Start free trial →
This page is written independently by Synthibase for testing and informational purposes. It is not an official publication of HL7 International or X12/Washington Publishing Company, and is not a substitute for reviewing the official standard or your trading partner's companion guide. See our Terms of Service for full legal terms.