An admit, a clinic visit, an emergency stay, and a virtual check-in are the same kind of record in HL7 FHIR: an Encounter. Orders, notes, charges, and diagnoses point at it. When that record is thin or late, downstream apps invent a second visit or attach a note to the wrong stay.
This is a build guide for the FHIR R4 Encounter resource itself. It covers required elements, how status and class move, where diagnosis and location live, what the hospitalization component is for, and which HL7 v2 ADT events should create or update the record. Patient matching and the Condition resource are separate builds.
What is a FHIR Encounter resource?
Building Encounter APIs for a real chart?
Agnotic Technologies designs FHIR R4 Encounter resources, US Core profiles, and the ADT feeds that keep them current.
A FHIR R4 Encounter records one interaction between a patient and healthcare providers for care or assessment. Status and class are required on every Encounter. US Core also requires an encounter type and a patient reference. Hospital stays add location history, participants, and a hospitalization component for admission and discharge details.
HL7 defines the resource as an interaction for providing healthcare services or assessing health status. The setting is what makes two Encounters different: ambulatory, emergency, home health, inpatient, or virtual. Because the scope is wide, admission and discharge details sit in a hospitalization component instead of on every outpatient visit. The class element tells validators which rules apply.
Hospitals disagree on when a new Encounter starts. Some open one for every practitioner during a stay. Others keep one Encounter for the hospitalization and hang visits off it with partOf. Write that rule down before go-live. An Encounter may also exist before arrival, with status planned. That record is not the Appointment that booked the time. HL7 keeps Appointment for scheduling and Encounter for the interaction, including the wait after arrival.
Which Encounter fields are required?
In FHIR R4, status and class are mandatory. US Core tightens that set: every Encounter must have a status, a class such as inpatient or emergency, an encounter type, and a patient. If the sending system knows an identifier, participants, the period, a reason, a discharge disposition, or a location, US Core says those elements must be supported.
- status: Required. The page lists planned, arrived, triaged, in-progress, onleave, finished, and cancelled, plus further EncounterStatus codes.
- class: Required Coding from the extensible v3 ActEncounterCode set. This is the setting, not a CPT code.
- type: Optional in FHIR R4, required by US Core. Use the local visit type, such as a new-patient office visit.
- subject: Optional in FHIR R4, required by US Core, normally a US Core Patient. The current profile also allows Group.
- identifier: Must Support in US Core when a visit number exists. Send system and value together.
- period: Must Support. Open at the start of the interaction and close it when the visit is finished.
- participant: Must Support. Point individual at a practitioner or role, and set type for attending, admitter, or consultant.
- serviceProvider: The organization responsible for the encounter when several facilities share one server.
Must Support does not mean the element is always present. It means that if the source system has the data, the API is able to carry it, and a client is able to read it. A clinic with no bed will not invent a location. A hospital that does track beds will not drop location on the floor.
How do status and class change during a stay?
Status follows the workflow: planned, then arrived or triaged, then in-progress, then finished or cancelled. Class says where the interaction happens and can change too, for example when an emergency visit becomes an inpatient stay. Keep both histories if auditors or quality staff will ask what the record looked like at a given hour.
HL7 includes statusHistory and classHistory because teams often need the path, not only the latest value. Each history row has the code and a period. If the server already keeps a full resource history, you can rebuild the path from versions. Many EHR facades do not, so the component is the practical place to store it.
There is no single status that means admitted. HL7 says the local workflow decides. Arrived, triaged, or in-progress may mark the start of an admission, especially once the hospitalization component is filled. The specification's own minimum is that a patient is admitted when status is in-progress. On leave is its own status, used when the patient is permitted to leave and return, and the location row often stays present.
- Planned: Expected visit. Do not bill from it, and do not copy the Appointment into it.
- Arrived: Patient is on site. The period can stay open until a clinician starts.
- Triaged: Emergency departments use this before a treatment space. Many clinics can skip it.
- In-progress: Care is underway. For an inpatient, HL7 treats this as admitted.
- Onleave: Patient is away and expected back. Do not mark the visit finished.
- Finished: Set period.end. For an inpatient, also set discharge disposition.
- Cancelled: Keep the record. Deleting it breaks orders that already point at the visit.
A class change is a business event, not a cosmetic edit. Moving from emergency to inpatient may be a new Encounter with partOf pointing at the emergency Encounter, or an update to class plus classHistory on the same record. Pick one pattern per health system. Mixing them makes length-of-stay reports double-count hours.
How should diagnosis, reason, and location be stored?
Reason says why the patient came. Diagnosis says what was relevant to this visit, with a rank and a role such as admission, billing, or discharge. Location is a list of places with their own status and period, because inpatients move. These three are not substitutes for one another.
- reasonCode: Coded reason on the Encounter. US Core marks it Must Support.
- reasonReference: Pointer to a Condition, Procedure, Observation, or immunization recommendation.
- diagnosis.condition: Required on each diagnosis row. Reference a Condition or Procedure. Keep the code on that resource.
- diagnosis.use: Role on this visit, such as admission, discharge, or billing.
- diagnosis.rank: Positive integer per role. Do not give two billing diagnoses rank 1.
- location.location: One Location reference per place the patient occupied.
- location.status: planned, active, reserved, or completed.
- location.period: Close the previous row before opening the next unless overlap is an explicit policy.
A common defect is a diagnosis code typed only onto the Encounter, with no Condition behind it. US Core clients expect the Condition. Another defect is a single location row that is edited in place, so the ward from yesterday disappears. Quality measures and infection tracing need the trail. Account is a separate list of Account references used for billing. Link the account the hospital billing system already knows, or the professional and hospital billers will not find the stay.
What belongs in the hospitalization component?
Hospitalization holds the extra facts of an admission: where the patient came from, the admit source, diet and special arrangements, the discharge destination, and the discharge disposition. HL7 expects its period to match the Encounter period. If the dates differ, create another Encounter and point partOf at the parent stay.
- origin: Where the patient came from, as a Location or Organization.
- admitSource: Physician referral, transfer, or another coded source. It is not class.
- reAdmission: Send it only when the stay is flagged as a readmission.
- dietPreference and specialArrangement: Bedside needs such as diet or a translator. Facades often drop them.
- destination and dischargeDisposition: Where the patient went, and the coded category. US Core marks disposition Must Support.
- preAdmissionIdentifier: The id used before a visit number existed.
Do not put hospitalization on a routine office visit just because the screen has empty fields. Empty components teach clients to ignore the element. Use it when the encounter is an admission or another stay that has a discharge disposition in the source system.
How does an HL7 v2 ADT message become an Encounter?
ADT messages are the usual source for hospital Encounters. Map the business event, not every segment, and keep the visit number as Encounter.identifier. The element-by-element crosswalk belongs in a mapping spec. The decisions below are the ones that change the Encounter you store.
- Admit: Set status to arrived or in-progress, set class from patient class, open period.start, and add the first location.
- Register: Outpatient or emergency arrival. Create an Encounter only when the visit number is new. Do not overwrite an inpatient stay that shares a medical record number.
- Transfer: Close the current location period and append a location. A new Encounter is only for hospitals that treat the transfer as a new visit.
- Discharge: status finished, period.end, discharge disposition, and destination.
- Update: Change only fields the message carries. A sparse update must not clear the attending participant.
- Cancel: Move to cancelled, or use the extra EncounterStatus code your event map names. Do not hard-delete a referenced visit.
- Preadmit: status planned, hospitalization filled with what is known, location planned or reserved.
Match on the visit identifier plus the assigning authority, not on patient plus date. Two visits on the same day are normal. Store the message control id on the interface log so a replay does not open a duplicate Encounter. If the same visit is also entered in the EHR UI, decide which system wins for status. Two writers without a winner produce a finished visit that an old ADT message then reopens.
Where do Encounter builds fail after go-live?
Most production failures are identity and time, not missing optional fields. The API returns 200 while the chart shows the wrong stay.
- Duplicate visits: The identifier system URI changed between environments, so one visit number became two Encounters.
- Finished with no end: A discharge flag set status and left period.end empty.
- Timezone shift: Local time without an offset is stored as UTC and the visit starts a day early.
- Class stuck: An inpatient admit moved the bed and never updated class or classHistory.
- Attending wiped: A participant list was replaced by a message that only carried the admitting doctor.
- Merge miss: subject still points at a retired Patient id after a merge.
- Appointment copied: Scheduling status was written onto Encounter.status, so a no-show looks cancelled or a booked slot looks in-progress.
- partOf cycle: The emergency Encounter and the inpatient Encounter each name the other as parent.
Test with a scripted stay: schedule, arrive, move beds twice, go on leave, return, discharge. Read the Encounter after each event and diff it against the previous version. That single fixture catches more defects than a spreadsheet of field mappings.
How should clients search and update Encounters?
Clients should search by patient and date, or by the visit identifier, and then read the one record they mean to change. Updates should send the whole Encounter only when the client is the owner. Everyone else should patch the fields they own, with a version check, so they do not clobber a concurrent ADT update.
- Search by patient plus date, and by visit identifier for interface engines.
- Read before write. Location and participant lists are easy to overwrite.
- Send the version you read. On conflict, re-read and apply the change again.
- Conditional update by identifier is fine for engines. Reject it when more than one Encounter matches.
- Publish allowed status transitions. A client should not move finished back to planned.
- Require clinical resources that belong to the visit to reference it, so a timeline can be rebuilt.
SMART on FHIR apps often receive one Encounter in launch context. Offer a patient-level search anyway, because a results review may need the prior inpatient stay.
How Agnotic can help
Agnotic Technologies builds Encounter support for EHR vendors, health systems, and digital health products: US Core profiles, visit-number identity, status rules, location history, and the ADT processing that keeps the resource aligned with registration. Agnotic implements the search parameters and versioned updates your partners will actually call.
For a facade over Epic, Oracle Health (Cerner), athenahealth, or eClinicalWorks, we start from the registration events the source already emits and write the Encounter rules in a testable fixture, including bed moves and discharge.
Ship an Encounter model that matches the stay
Talk with an engineer about your visit lifecycle, or read more FHIR guides.
Related reading on Agnotic
Patient identity, Condition records, US Core, and the HL7 v2 field map sit next to this resource.


