Convert document to FHIR resource

POST/lang2fhir/document

Extracts text from a document (PDF or image) and converts it into a structured FHIR resource.

Patient identifier handling. When generating a patient (or patient-canvas) resource, US Core requires Patient.identifier (a business identifier such as an MRN). When the source text contains an identifier, it is extracted with an appropriate URI system. When the source text does not contain a detectable identifier, a synthetic one is generated with system: "urn:phenoml:lang2fhir-generated-id" and a UUID value so the resource remains FHIR-valid and US Core conformant. Callers who need a tenant-specific namespace should rewrite the synthetic system after extraction.

RequiresBearerauthentication

Body parameters

versionstringrequired

FHIR version to use

resourcestringrequired

Type of FHIR resource to create. Accepts any FHIR resource type or US Core profile name.

contentstringrequired

Base64 encoded file content. Supported file types: PDF (application/pdf), PNG (image/png), JPEG (image/jpeg). File type is auto-detected from content magic bytes.

configobjectoptional

Optional processing configuration shared across document endpoints.

page_filterobjectoptional

Configures per-page pre-extraction filtering. When set, each page of text extracted from the document is classified by an LLM, and pages classified as irrelevant to the supplied context are dropped before FHIR extraction.

contextstringrequired

Natural-language description of what IS relevant to the extraction goal. Pages that do not match are dropped from downstream FHIR extraction.

Returns  

Successfully created FHIR resource from document

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/document' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "version": "R4",
  "resource": "questionnaire",
  "content": "Example text content",
  "config": {
    "page_filter": {
      "context": "clinical notes, diagnoses, medications — not sample collection instructions or insurance forms"
    }
  }
}'
200 OKResponse
{}