Lab connector
Send a whole laboratory report as CSV, HL7 v2 ORU^R01 or JSON and get laboratory Observations with LOINC codes and reference ranges.
A laboratory (or anyone holding a lab report) sends the whole report in one request and the
platform turns every result into a laboratory Observation of the patient:
POST /v1/patients/{patient_id}/labs/import
Authorization: Bearer <project key>
Content-Type: text/csv | x-application/hl7-v2+er7 | application/json
X-Anpheros-Source-System: labx (optional; recorded in Provenance)
Idempotency-Key: <report id> (optional; a retry returns the same answer)
Formats
CSV with a header row; separators , ; or tab, decimal comma accepted, dates ISO,
DD.MM.YYYY or DD/MM/YYYY. Recognised columns (Romanian or English): marker
(analiza, test, marker, name) — or only a LOINC code column, in which case the LOINC name becomes the marker —
value (rezultat, valoare, value, result), unit (um, unitate, unit),
reference range (interval, referinta: 70-100, <5, >3.5) or ref_low/ref_high,
date (data, recoltare), optional LOINC (loinc, code), note.
Analiza;Rezultat;UM;Interval de referinta;Data
Hemoglobina glicozilata (HbA1c);6,4;%;4,0-5,6;01.09.2026
TSH;2,1;mUI/L;0,4-4,0;01.09.2026
HL7 v2 ORU^R01 (ER7 text, segments separated by CR or LF): OBX-3 identifier (code^text^LN
is LOINC; a local code (^L, ^99zzz) or any other coding system is kept as the lab's own code under
urn:anpheros:lab-code), OBX-5 value (NM, SN, or text),
OBX-6 unit, OBX-7 reference range, OBX-8 abnormal flag → interpretation, OBX-11 status,
OBX-14 or OBR-7 date; OBR-3/MSH-10 become the report id in Provenance.
The laboratory. Each result names who produced it in performer, as the HL7 Europe Laboratory Report 2.1.0
requires: the organisation you act for (X-Anpheros-Acting-As), otherwise MSH-4 (sending facility) for HL7, or
laboratory in JSON (top level or per item). A CSV carries no laboratory; such results validate with a missing
performer, which is the truth.
Text reports, documents and missing dates. A text report sent one line per OBX (TX/FT, same OBX-3)
becomes one result with the lines joined. A whole document in OBX-5 (ED, or any value encoded Base64) is not
stored as a result; the response warns and the document belongs in /documents. Without OBR-7, results are dated by
OBR-14 (specimen received), with a warning.
Times and time zones. A v2 time without a time zone is the sender's local time, not UTC. The offset sent with
OBX-14/OBR-7 (20260901081000+0300) is kept (2026-09-01T08:10:00+03:00). Without one, the offset of MSH-7 is
used and a warning says so; with no offset anywhere, the result keeps only its date, also with a warning. CSV times
(01.09.2026 08:10) carry no time zone, so they are stored as dates only. Until 17 October 2026 such times were
labelled UTC; results imported then keep their identifiers and are still recognised when a report is sent again.
HL7 results that are still pending (OBX-11 I), unobtainable (X), deleted (D) or wrong (W), and OBX segments
without a value, do not become Observations; each is named in warnings.
JSON: {"date": "2026-09-01", "origin": "report-77", "laboratory": "Synevo", "items": [{"marker": "TSH", "value": 2.1, "unit": "mUI/L", "ref_low": 0.4, "ref_high": 4.0, "date": "2026-09-01", "code": "3016-3"}]}.
What you get back
{"created": 3, "skipped": 0, "unmapped": ["Marker foarte rar"], "warnings": [],
"observations": [{"id": "…", "marker": "TSH", "code": "3016-3", "system": "http://loinc.org", "value": 2.1, "unit": "mUI/L", "date": "2026-09-01"}]}
- Markers are mapped to LOINC when the report gives a LOINC code or the name matches the
platform's terminology (Romanian and English names and common aliases). Others keep the lab's
code under
urn:anpheros:lab-codewith the exact text from the report, and are listed inunmappedso you can improve the mapping on your side. A lab's own code is unique only together with its laboratory: the source system is recorded in each Observation's Provenance (X-Anpheros-Source-System). - Names are matched against LOINC names and synonyms (for example Hemoglobin A1c, Glycated hemoglobin,
HDL cholesterol, LDL-C). A name that matches several concepts, or that carries a qualifier the concept does
not have (urine, non-HDL, free, ratio…), is not guessed: it keeps the lab's code and is listed in
unmapped. Send LOINC codes whenever your system has them. - Urea and urea nitrogen (BUN) are different measurements: Uree / Urea maps to urea (LOINC
3091-6, or22664-7in mmol/L), BUN / Urea nitrogen / Azot ureic to urea nitrogen (3094-0, or14937-7in mmol/L). Values are never converted. - LDL cholesterol: a name without a method maps to
2089-1; calculated / calculat / Friedewald to the calculated LDL (13457-7); direct to the direct assay (18262-6). The method is a qualifier, like direct in Bilirubina directa, which is not total bilirubin and keeps the lab's code. - Glucose: a bare "Glicemie" / "Glucose" on a lab report is mapped to serum or plasma (LOINC
2345-7); a name that says capillary, finger-prick or whole blood ("capilar", "sânge integral") to whole blood (2339-0). A LOINC code in the report always takes priority. - Each row gets a stable identifier (
urn:anpheros:lab-import:v2) built from what the report says — report id, the name and code on the report, date, value and unit — never from the LOINC code the platform chose, so re-sending the same report skips rows already imported (skipped), even after the mapping improves. Rows that differ in any of these (another report, another time of collection, another value) are kept apart. Results imported before 14 October 2026 keep their original identifier and are recognised by name, date, value, unit and report id. Without a report id (CSV) such a match is reported inwarnings; send a report id (HL7OBR-3/MSH-10, JSONorigin) to keep separate reports apart. - Every Observation carries Provenance with
author_type = import, your source system and the report id; webhooks fireresource.createdper Observation; the patient sees the results in their app and any app they consented to can read them. - Up to 500 rows per request.
Both SDKs: labs.importCsv, labs.importHl7, labs.importItems.
A worked example from a CSV and an HL7 v2 report to FHIR Observations, with unmapped markers and resent reports: How to import laboratory results into a FHIR record.
How lab data moves between laboratories, clinics, apps and AI, and what to look for in a lab results API: Laboratory results API.
Ask your AI
Paste this into Claude, ChatGPT, Cursor or Claude Code. Your assistant reads this guide and adapts it to your code.
Read https://developers.anpheros.com/guides/lab-connector.md and help me apply this guide to my own project. Use the Anpheros sandbox (base URL https://platform.anpheros.com) with my API key from the ANPHEROS_KEY environment variable, never written in the code. Give me complete, runnable code, the response I should expect, and how to fix the errors in https://developers.anpheros.com/guides/troubleshooting.md if a call fails.Open in ClaudeOpen in ChatGPTThis guide as MarkdownBuild the whole integration with an AI coding tool
Try it free in the sandbox · first FHIR call in 5 minutesFree · 30 synthetic patients · no cardYour first API call in 2 minutes →
