Healthcare pack

Encounters CSV import API

Map ADT and visit exports from any CSV to FHIR R4 Encounter: admission and discharge, class, status, ward. DE/FR/IT/ES headers handled.

30-second curl
curl -X POST https://api.adaptivmapr.com/v1/uploads \
  -H "Authorization: Bearer $ADAPTIVMAPR_API_KEY" \
  -F "template=encounters_v1" \
  -F "file=@your_data.csv"
→ 9 canonical fields · 0 validated · medium risk

Canonical columns

The whole schema, printed as it ships.

Every canonical column, the type each row carries, whether it is required, the field-level validators that fire on commit, and the multilingual header hints the cascade resolves against. This is the shipped definition, not a summary of it.

encounters_v1FHIR · Encounter
fields
9
required
3
validated
0
hints
62
Canonical columnTypeRequiredValidatorsHeader hints the cascade matches
encounter_idstringyes—fallnummerfall-nrbesuchsnummernuméro de séjournumero di casovisit idcase idnúmero de episodio
patient_idstringyes—patientpatient_idpidpatienten-idid patient
encounter_classenumoutpatientinpatientemergencyhomevirtualday case——fallartbehandlungsarttype de séjourtipo di ricoverosettingvisit typetipo de atención
statusenumplannedarrivedin-progressfinishedcancelled——statusstatutstatoestadofallstatus
start_timedateyes—eintritteintrittsdatumaufnahmeaufnahmedatumdate d'admissiondata di ricoveroadmission dateadmittedfecha de ingreso
end_timedate——austrittaustrittsdatumentlassungdate de sortiedata di dimissionedischarge datedischargedfecha de alta
encounter_typestring——grundeintrittsgrundmotifmotivoreason for visitreason
practitioner_idstring——arztbehandelnder arztmédecinmedicoproviderdoctormédico
location_idstring——stationabteilungservicerepartowardunitlocation

Read the same definition as JSON at GET /v1/templates/encounters_v1. A hint match resolves on layer 2 — no LLM call, no token spend, just the flat per-map fee. Hover a validator id to see what it checks.

  • 9 canonical fields
  • 3 required
  • 0 validated
  • 62 header hints, 5 languages
  • FHIR Encounter

Why it exists

Written for the file you actually receive.

The Encounters template is the schema for the question every clinical dataset eventually asks: when was this patient seen, where, and in what setting? One row is one contact — an outpatient consultation, an emergency attendance, a multi-day inpatient stay, a video call. encounter_id, patient_id and start_time are required; class, status, discharge time, reason, treating practitioner and ward are optional, because ADT extracts rarely agree on which of those they carry. On FHIR output each row becomes an R4 Encounter: the stay number lands in identifier, the patient becomes a Patient/ reference in subject, admission and discharge fill period.start and period.end, the practitioner becomes a participant and the ward a Location/ reference. The template is `medium` risk — a dated visit tied to a patient identifier is health information — so in production a commit is refused until a workspace member approves that exact mapping in the dashboard.

encounter_class takes six plain-language values — outpatient, inpatient, emergency, home, virtual, day case — and the FHIR emitter translates them into the v3 ActCode codes R4 binds Encounter.class to (AMB, IMP, EMER, HH, VR, SS). status follows the R4 lifecycle subset planned / arrived / in-progress / finished / cancelled. A row with no status is emitted as finished, which suits a discharge extract but not a live bed board, so map the column whenever the source has one. The reason column is free text and lands in Encounter.type as text, not as a code.

Migration scenarios & the foreign headers they ship

Encounter files usually come out of a hospital information system's ADT feed, a practice-management scheduler, or a case-mix extract assembled for billing. Typical jobs: a hospital group consolidating the case lists of two sites after a merger, a research data warehouse pulling a year of stays for a cohort, a telehealth provider reporting video consultations to a partner clinic, and a payer reconciling claimed stays against the hospital's own record. The headers we meet look like "Fallnummer / Fall-Nr / Numéro de séjour / Numero di caso / Case ID / Visit ID / Fallart / Type de séjour / Tipo di ricovero / Eintrittsdatum / Aufnahme / Date d'admission / Austritt / Entlassung / Date de sortie / Data di dimissione / Station / Abteilung / Reparto / Ward". Every one of them is a registered hint, so a stay list in any of those languages maps on the deterministic layers alone.

The cascade

Six layers, and the cheapest one wins.

Layers run in order and stop the moment a column resolves. That is the single biggest cost lever in the system: a column caught on layer 2 never reaches the metered layer 5.

  1. L1Statisticsno LLM

    Auto-accepts a header that past confirmations already resolved the same way, at {minN:100, minRatio:0.95} or {minN:20, minRatio:1.00}.

  2. L2Heuristicno LLM

    Normalises accents, punctuation and whitespace, then compares against the column name, the label, and every registered hint (DE / FR / IT / EN / ES).

  3. L3Fuzzyno LLM

    Token-set ratio plus Levenshtein over the normalised strings. Auto-accepts at 0.80 — it absorbs typos and reordered words.

  4. L4Semanticcheap, cached

    Embedding cosine between the header and the field’s label + hints. Catches the long tail of paraphrases.

  5. L5LLMmetered

    Everything still unresolved goes up in ONE batched, collision-aware call, constrained to this template’s column set so it cannot invent a field.

Try it

One template id, two ways in.

REST for your import pipeline, MCP for your editor. Both run the same cascade and both honour the same schema-only clamp.

REST · POST /v1/uploads

Name the template; the cascade picks up the rest. The canonical definition is read-only at GET /v1/templates/encounters_v1.

bash
curl -X POST https://api.adaptivmapr.com/v1/uploads \
  -H "Authorization: Bearer $ADAPTIVMAPR_API_KEY" \
  -F "template=encounters_v1" \
  -F "file=@your_data.csv"
→ upload created · mappings ready · confirm before commit

MCP · Cursor / Claude Desktop

Drop AdaptivMapr into your editor and call the same cascade as a tool. Schema-only calls leave only column names and a few example values.

mcp
// In Cursor or Claude Desktop with the AdaptivMapr MCP server installed:
adaptivmapr.match_headers({
  template_id: "encounters_v1",
  headers: ["encounter_id", "patient_id", "encounter_class", "status"]
})
schema-only · column names and a few examples only
MCP install instructions
medium-risk template

The mappings response comes back flagged. PATCH /uploads/:id/mappings returns requires_hitl: true and hitl_status: "pending_review" and on the hosted API a commit waits until a workspace member records an approval. Schema-only mode (column names and a few example values, never the full file) is a data-minimization mode enforced at the HTTP edge. Full-data mode routes the metered layer-5 call to phi-cloud in-region under a BAA, costs 20% more on the whole map charge, and stays locked until the workspace accepts the BAA/NDA in Settings → Security & Data.

How the wallet is charged

Questions

Encounters CSV import — FAQ

Why are the class values plain words rather than FHIR codes?
Because source files say "inpatient" far more often than "IMP". The template validates the six readable values and the FHIR emitter translates them to v3 ActCode on the way out, so the committed rows stay legible and the Encounter resources stay conformant. A value outside the six is reported as an invalid row rather than guessed.
Can one row describe a transfer between wards?
No. The row carries one location_id, emitted as a single Encounter.location entry. A stay that moved is either one row per ward segment, each with its own encounter_id, or one row naming the discharging ward — decide which your destination expects before you import.
Do patients and practitioners have to exist first?
Not for the mapping. patient_id, practitioner_id and location_id are emitted as references (Patient/…, Practitioner/…, Location/…) built from the values in the row, and nothing checks that the referenced resource exists. If your FHIR server enforces referential integrity, load those resources under the same ids first.
Can I commit an encounters mapping straight from the API?
Once it has been approved. Encounters is a medium-risk template, so in production POST /v1/uploads/:id/commit answers 428 hitl_approval_required until a workspace member approves that exact mapping in the dashboard; changing the mapping afterwards needs a fresh approval.

Map encounters in production — without shipping raw records.

Minimal data mode sends only column names and a few example values — never the full file. Add full-data when you need row-level AI, routed in-region under a BAA.