encounter
A patient visit or stay. encounter records reach the canonical layer from two distinct
origins, distinguishable by patientRef.sourceSystem (and by which identifiers system
is present):
- Provider-origin — an inpatient admission or outpatient appointment reported by the
FHIR provider itself (
patientRef.sourceSystemis the provider's source system, e.g."michels";identifiers[].systemisurn:michels:encounter). This is the original behavior of this resource type. - Rosetta-app-origin — a therapy case's admission/discharge dates, captured in
rosetta-app and synced into the canonical layer (
patientRef.sourceSystemis"rosetta-app";identifiers[].systemisurn:rosetta-app:therapy-case). One canonicalencounterexists per (patient, discipline) therapy case — it is generated the moment rosetta-app records an admission date for that case, and is updated in place (not replaced) as the discharge date is later added. Other resource types such asconditionandproceduremay optionally reference either kind of encounter viaencounterRef.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
identifiers | Identifier[] | no (defaults []) | Business identifiers, e.g. a visit number, or the rosetta-app case key. |
patientRef | SourceRef | yes | The patient this encounter belongs to. |
status | string enum | yes | One of planned, in-progress, finished, cancelled, unknown. |
classCode | string | no | Source-provided encounter class, e.g. AMB (ambulatory), IMP (inpatient). |
periodStart | IsoDatetime | no | When the encounter started. |
periodEnd | IsoDatetime | no | When the encounter ended. |
classCode is provider-origin only — rosetta-app-origin encounters never set it (the
formData-free rosetta-app source has no equivalent column); do not treat its absence as
missing data on that origin.
Example payload — provider-origin
An outpatient visit reported by the FHIR provider:
{
"identifiers": [{ "system": "urn:michels:encounter", "value": "ENC-2001" }],
"patientRef": {
"sourceSystem": "michels",
"resourceType": "patient",
"sourceId": "pat-1"
},
"status": "finished",
"classCode": "IMP",
"periodStart": "2026-07-10T08:30:00.000Z",
"periodEnd": "2026-07-12T11:00:00.000Z"
}
Example payload — rosetta-app-origin (therapy case)
A physiotherapy case in rosetta-app, right after admission — only the admission date is
known, so status is in-progress and periodEnd is absent:
{
"identifiers": [
{ "system": "urn:rosetta-app:therapy-case", "value": "pat-42:physiotherapy" }
],
"patientRef": {
"sourceSystem": "rosetta-app",
"resourceType": "patient",
"sourceId": "pat-42"
},
"status": "in-progress",
"periodStart": "2026-07-01T00:00:00.000Z"
}
When the same case is later discharged, rosetta-app updates this same canonical
record in place — a new version, the same canonicalId — rather than creating a
second encounter:
{
"identifiers": [
{ "system": "urn:rosetta-app:therapy-case", "value": "pat-42:physiotherapy" }
],
"patientRef": {
"sourceSystem": "rosetta-app",
"resourceType": "patient",
"sourceId": "pat-42"
},
"status": "finished",
"periodStart": "2026-07-01T00:00:00.000Z",
"periodEnd": "2026-07-10T00:00:00.000Z"
}
periodStart/periodEnd on this origin come from rosetta-app's admitted_at/
discharged_at date columns (no time-of-day component), composed as clinic-local
midnight normalized to UTC — treat them as date-precision, not a true visit start/end
time.
As a change-feed event
The discharge update above, as it arrives on the change feed (operation: "update",
version: 2 — the same canonicalId as the case's admission event, version: 1):
{
"sequence": 214,
"resourceType": "encounter",
"canonicalId": "6a1e4c8d-2b5f-4a9c-8d1e-4c8b2f5a9d1e",
"operation": "update",
"version": 2,
"occurredAt": "2026-07-10T00:00:05.000Z",
"orgSlug": "default",
"record": {
"identifiers": [
{ "system": "urn:rosetta-app:therapy-case", "value": "pat-42:physiotherapy" }
],
"patientRef": {
"sourceSystem": "rosetta-app",
"resourceType": "patient",
"sourceId": "pat-42"
},
"status": "finished",
"periodStart": "2026-07-01T00:00:00.000Z",
"periodEnd": "2026-07-10T00:00:00.000Z"
}
}
From the Records API
curl -H "Authorization: Bearer $ROSETTA_SYNC_TOKEN" \
"https://sync.example.com/api/v1/records/encounter/6a1e4c8d-2b5f-4a9c-8d1e-4c8b2f5a9d1e"
{
"id": "6a1e4c8d-2b5f-4a9c-8d1e-4c8b2f5a9d1e",
"resourceType": "encounter",
"version": 2,
"payload": {
"identifiers": [
{ "system": "urn:rosetta-app:therapy-case", "value": "pat-42:physiotherapy" }
],
"patientRef": {
"sourceSystem": "rosetta-app",
"resourceType": "patient",
"sourceId": "pat-42"
},
"status": "finished",
"periodStart": "2026-07-01T00:00:00.000Z",
"periodEnd": "2026-07-10T00:00:00.000Z"
},
"updatedAt": "2026-07-10T00:00:05.000Z",
"orgSlug": "default",
"identifiers": [
{ "system": "urn:rosetta-app:therapy-case", "value": "pat-42:physiotherapy" }
]
}
Consumption notes
statusis a lifecycle enum; treatunknown(and any value your integration doesn't recognize yet) defensively rather than assuming it means the encounter is over. Rosetta-app-origin encounters only ever producein-progress(admitted, not yet discharged) orfinished(discharged) — neverplanned,cancelled, orunknown.periodStart/periodEndare normalized timestamps — alwaysZ-suffixed UTC regardless of the offset the source system reported.classCodeis a source-provided class string (e.g.AMB,IMP) — treat it as free text from the source system rather than a fixed enum you validate against, and expect it to be absent on rosetta-app-origin records (see Fields above).- Rosetta-app-origin
encounterrecords are an aggregate keyed on the (patient, discipline) case, updated in place as admission/discharge dates change — the same pattern asobservationandcare-plan. Always overwrite your stored copy on a new event rather than merging fields, and dedupe applied events on(canonicalId, version). - A therapy case's completed admission/discharge forms are separate records —
admissionanddischarge— correlate them to their case'sencounterby matchingpatientRefanddiscipline, not by any shared id (the form records carry their own row identity;encounter's identity is the case). patientRefis a source reference; correlate it to the canonicalpatientwhoseidentifierscontain the matching business identifier.