# Phenoml Console > Phenoml is a healthcare AI developer platform offering configurable, healthcare-compliant APIs for providers, biopharma, healthtech, and payers. This is the Phenoml developer console. The console app requires sign-in and isn't represented here; the public documentation covers the Phenoml platform APIs and Phenostore beta guides. Complete Phenoml platform API reference with every endpoint inlined for language-model ingestion. Phenostore beta guides are linked below; their content is available from the individual Markdown exports. ## Phenostore (Beta) - [Phenostore — Beta](/docs/guides/phenostore.md): Managed healthcare data storage for application workloads, with a practical subset of FHIR R4, plus Go and Python SDKs. - [Your first Phenostore resources](/docs/guides/phenostore-quickstart.md): Authenticate to Phenostore, create and read a synthetic Patient, and search by identifier using curl. - [Phenostore SDKs](/docs/guides/phenostore-sdk.md): Install the Go or Python SDK, configure OAuth credentials, and create and read a synthetic Patient with complete examples. # Construe Extract medical codes from natural language clinical text. Supports SNOMED CT, ICD-10, RxNorm, LOINC, and more. ## Construe / Code Systems Manage custom medical code systems used by the extractor. ### GET /construe/codes/systems **List available code systems** Returns the catalog of available code systems, including both built-in standard terminologies and custom uploaded systems. **Operation ID:** `construe_list` #### Responses **200** - List of available code systems Content-Type: `application/json` ```json { "type": "object", "required": [ "systems" ], "properties": { "systems": { "type": "array", "items": { "type": "object", "required": [ "name", "version", "code_count", "builtin" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" }, "code_count": { "type": "integer", "description": "Total number of codes in the system", "example": 72750 }, "builtin": { "type": "boolean", "description": "Whether this is a built-in system (vs custom uploaded)", "example": true } } } } } } ``` **Example:** ```json { "systems": [ { "name": "CPT", "version": "umls-2026aa", "code_count": 10298, "builtin": true }, { "name": "CPT", "version": "2025", "code_count": 10192, "builtin": true }, { "name": "HCPCS", "version": "umls-2026aa", "code_count": 7322, "builtin": true }, { "name": "HPO", "version": "umls-2026aa", "code_count": 19698, "builtin": true }, { "name": "HPO", "version": "2025", "code_count": 19542, "builtin": true }, { "name": "ICD-10", "version": "umls-2026aa", "code_count": 12292, "builtin": true }, { "name": "ICD-10-CM", "version": "umls-2026aa", "code_count": 98506, "builtin": true }, { "name": "ICD-10-CM", "version": "2025", "code_count": 97584, "builtin": true }, { "name": "ICD-10-PCS", "version": "umls-2026aa", "code_count": 79232, "builtin": true }, { "name": "ICD-10-PCS", "version": "2025", "code_count": 78717, "builtin": true }, { "name": "LOINC", "version": "umls-2026aa", "code_count": 99231, "builtin": true }, { "name": "LOINC", "version": "2.78", "code_count": 98123, "builtin": true }, { "name": "RXNORM", "version": "umls-2026aa", "code_count": 259884, "builtin": true }, { "name": "RXNORM", "version": "11042024", "code_count": 257619, "builtin": true }, { "name": "SNOMED_CT_US", "version": "umls-2026aa", "code_count": 386110, "builtin": true }, { "name": "SNOMED_CT_US", "version": "20240901", "code_count": 371482, "builtin": true }, { "name": "SNOMED_CT_US_LITE", "version": "20240901", "code_count": 102837, "builtin": true } ] } ``` **401** - Unauthorized **500** - Server error --- ### GET /construe/codes/systems/{codesystem} **Get code system detail** Returns full metadata for a single code system, including timestamps and builtin status. **Operation ID:** `construe_find` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE") | | `version` | query | string | No | Specific version of the code system, such as `umls-2026aa`. | #### Responses **200** - Code system detail Content-Type: `application/json` ```json { "type": "object", "required": [ "name", "version", "code_count", "builtin", "status", "created_at", "updated_at" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" }, "code_count": { "type": "integer", "description": "Total number of codes in the system", "example": 72750 }, "builtin": { "type": "boolean", "description": "Whether this is a built-in system (vs custom uploaded)", "example": true }, "status": { "type": "string", "enum": [ "processing", "ready", "failed" ], "description": "Processing status of the code system.\n- \"processing\": embeddings are being generated\n- \"ready\": code system is ready for use\n- \"failed\": processing failed (re-upload with replace=true to retry)\n", "example": "ready" }, "created_at": { "type": "string", "format": "date-time", "description": "When the code system was created" }, "updated_at": { "type": "string", "format": "date-time", "description": "When the code system was last updated" } } } ``` **Example:** ```json { "name": "ICD-10-CM", "version": "2025", "code_count": 97584, "builtin": true, "status": "ready", "created_at": "2026-02-10T18:33:23Z", "updated_at": "2026-02-10T18:33:23Z" } ``` **400** - Invalid parameters **401** - Unauthorized **404** - Code system not found **500** - Server error --- ### DELETE /construe/codes/systems/{codesystem} **Delete custom code system** Deletes a custom (non-builtin) code system and all its codes. Builtin systems cannot be deleted. Only available on dedicated instances. Large systems may take up to a minute to delete. **Operation ID:** `construe_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name | | `version` | query | string | No | Specific version of the custom code system. | #### Responses **200** - Code system deleted successfully Content-Type: `application/json` ```json { "type": "object", "required": [ "message" ], "properties": { "message": { "type": "string", "description": "Confirmation message", "example": "code system deleted successfully" } } } ``` **Example:** ```json { "message": "code system deleted successfully" } ``` **400** - Invalid parameters **401** - Unauthorized **403** - Cannot delete builtin code systems or not on a dedicated instance **404** - Code system not found **500** - Server error --- ### GET /construe/codes/systems/{codesystem}/export **Export custom code system** Exports a custom (non-builtin) code system as a JSON file compatible with the upload format. The exported file can be re-uploaded directly via POST /construe/upload with format "json". Only available on dedicated instances. Builtin systems cannot be exported. **Operation ID:** `construe_export` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name | | `version` | query | string | No | Specific version of the custom code system. | #### Responses **200** - Exported code system as JSON file Content-Type: `application/json` ```json { "type": "object", "required": [ "name", "version", "format", "codes" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "CUSTOM_CODES" }, "version": { "type": "string", "description": "Code system version", "example": "1.0" }, "format": { "type": "string", "enum": [ "json" ], "description": "Upload format (always \"json\")" }, "codes": { "type": "array", "description": "All codes in the system", "items": { "type": "object", "required": [ "code", "description" ], "properties": { "code": { "type": "string", "description": "The code identifier", "example": "E11.65" }, "description": { "type": "string", "description": "Short description of the code", "example": "Type 2 diabetes mellitus with hyperglycemia" }, "definition": { "type": "string", "nullable": true, "description": "Extended definition of the code (if available)" } } } } } } ``` **Example:** ```json { "name": "CUSTOM_CODES", "version": "1.0", "format": "json", "codes": [ { "code": "X001", "description": "Example custom code 1" }, { "code": "X002", "description": "Example custom code 2" } ] } ``` **400** - Invalid parameters **401** - Unauthorized **403** - Cannot export builtin code systems or not on a dedicated instance **404** - Code system not found **409** - Code system is still processing **424** - Code system processing failed **500** - Server error --- ### POST /construe/upload **Upload custom code system** Upload a custom medical code system with codes and descriptions for use in code extraction. Requires a paid plan. Returns 202 immediately; embedding generation runs asynchronously. Poll GET /construe/codes/systems/{codesystem}?version={version} to check when status transitions from "processing" to "ready" or "failed". **Operation ID:** `construe_upload` #### Request Body The complete JSON request may be up to 100 MiB. Base64-encoded `file` content and inline `codes` content each decode to at most 50 MiB. **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "description": "Upload a custom code system. The `format` field determines which additional fields are required:\n- **csv**: requires `file`, `code_col`, `desc_col`\n- **json**: requires either `file` (base64-encoded JSON array) or `codes` (direct JSON array)\n", "required": [ "name", "version", "format" ], "properties": { "name": { "type": "string", "description": "Name of the code system. Names are case-insensitive and stored uppercase.\nBuiltin system names (e.g. ICD-10-CM, SNOMED_CT_US_LITE, LOINC, CPT, etc.) are\nreserved and cannot be used for custom uploads; attempts return HTTP 403 Forbidden.\n", "example": "CUSTOM_CODES" }, "version": { "type": "string", "description": "Version of the code system", "example": "1.0" }, "revision": { "type": "number", "description": "Optional revision number", "example": 1 }, "format": { "type": "string", "enum": [ "csv", "json" ], "description": "Upload format" }, "file": { "type": "string", "format": "byte", "description": "The file contents as a base64-encoded string.\nFor CSV format, this is the CSV file contents.\nFor JSON format, this is a base64-encoded JSON array; prefer using 'codes' instead.\n" }, "code_col": { "type": "string", "description": "Column name containing codes (required for CSV format)", "example": "code" }, "desc_col": { "type": "string", "description": "Column name containing descriptions (required for CSV format)", "example": "description" }, "defn_col": { "type": "string", "description": "Optional column name containing long definitions (for CSV format)", "example": "definition" }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description" ], "properties": { "code": { "type": "string", "description": "The code identifier", "example": "E11.65" }, "description": { "type": "string", "description": "Short description of the code", "example": "Type 2 diabetes mellitus with hyperglycemia" }, "definition": { "type": "string", "nullable": true, "description": "Extended definition of the code (if available)" } } }, "description": "The codes to upload as a JSON array (JSON format only).\nThis is the preferred way to upload JSON codes, as it avoids unnecessary base64 encoding.\nIf both 'codes' and 'file' are provided, 'codes' takes precedence.\n" }, "replace": { "type": "boolean", "default": false, "description": "If true, replaces an existing code system with the same name and version.\nBuiltin systems cannot be replaced; attempts to do so return HTTP 403 Forbidden.\nWhen false (default), uploading a duplicate returns 409 Conflict.\n" } } } ``` **Example:** ```json { "name": "CUSTOM_CODES", "version": "1.0", "format": "json", "codes": [ { "code": "X001", "description": "Example custom code 1" }, { "code": "X002", "description": "Example custom code 2" } ] } ``` #### Responses **202** - Upload accepted for asynchronous processing Content-Type: `application/json` ```json { "type": "object", "properties": { "status": { "type": "string", "example": "processing" }, "name": { "type": "string", "example": "CUSTOM_CODES" }, "version": { "type": "string", "example": "1.0" } } } ``` **Example:** ```json { "status": "processing", "name": "CUSTOM_CODES", "version": "1.0" } ``` **400** - Invalid request format or parameters **401** - Unauthorized **403** - Forbidden (not on a dedicated instance, or replace=true on a builtin system) **409** - Code system version already exists (when replace=false) **424** - Failed dependency (error processing or storing the code system) **500** - Server error --- ## Construe / Codes Extract and search codes within a code system. ### GET /construe/codes/{codesystem} **List codes in a code system** Returns a paginated list of all codes in the specified code system. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_listCodes` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE") | | `version` | query | string | No | Specific version of the code system, such as `umls-2026aa`. | | `cursor` | query | string | No | Pagination cursor from previous response | | `limit` | query | integer | No | Maximum number of codes to return (default 20) | #### Responses **200** - Paginated list of codes Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "codes", "has_more" ], "properties": { "system": { "type": "object", "required": [ "name", "version" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" } } }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description" ], "properties": { "code": { "type": "string", "description": "The code identifier", "example": "E11.65" }, "description": { "type": "string", "description": "Short description of the code", "example": "Type 2 diabetes mellitus with hyperglycemia" }, "definition": { "type": "string", "nullable": true, "description": "Extended definition of the code (if available)" } } } }, "next_cursor": { "type": "string", "nullable": true, "description": "Cursor for fetching the next page (null if no more results)" }, "has_more": { "type": "boolean", "description": "Whether there are more results available" } } } ``` **Example:** ```json { "system": { "name": "ICD-10-CM", "version": "2025" }, "codes": [ { "code": "A00", "description": "Cholera" }, { "code": "A000", "description": "Cholera due to Vibrio cholerae 01, biovar cholerae" }, { "code": "A001", "description": "Cholera due to Vibrio cholerae 01, biovar eltor" }, { "code": "A009", "description": "Cholera, unspecified" }, { "code": "A01", "description": "Typhoid and paratyphoid fevers" } ], "next_cursor": "QTAx", "has_more": true } ``` **400** - Invalid parameters **401** - Unauthorized **404** - Code system not found **500** - Server error --- ### GET /construe/codes/{codesystem}/{codeID} **Get a specific code** Looks up a specific code and returns its details. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_lookup` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name | | `codeID` | path | string | Yes | The code identifier. ICD-10-CM codes are stored without their cosmetic dot (use "E1165", not "E11.65"). | | `version` | query | string | No | Specific version of the code system, such as `umls-2026aa`. | #### Responses **200** - Code details Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "code", "description" ], "properties": { "system": { "type": "object", "required": [ "name", "version" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" } } }, "code": { "type": "string", "description": "The code identifier", "example": "E11.65" }, "description": { "type": "string", "description": "Short description of the code", "example": "Type 2 diabetes mellitus with hyperglycemia" }, "definition": { "type": "string", "nullable": true, "description": "Extended definition of the code (if available)" } } } ``` **Example:** ```json { "system": { "name": "ICD-10-CM", "version": "2025" }, "code": "E1165", "description": "Type 2 diabetes mellitus with hyperglycemia" } ``` **400** - Invalid code ID or parameters **401** - Unauthorized **404** - Code or code system not found **500** - Server error --- ### GET /construe/codes/{codesystem}/search/semantic **Semantic search (embedding-based)** Performs semantic similarity search using vector embeddings. **Availability**: This endpoint works for both **built-in and custom** code systems. **When to use**: Best for natural language queries where you want to find conceptually related codes, even when different terminology is used. The search understands meaning, not just keywords. **Examples**: - Query "trouble breathing at night" finds codes like "Sleep apnea", "Orthopnea", "Nocturnal dyspnea" — semantically related but no exact keyword matches - Query "heart problems" finds "Myocardial infarction", "Cardiac arrest", "Arrhythmia" **Trade-offs**: Slower than text search (requires embedding generation), but finds conceptually similar results that keyword search would miss. See also: `/search/text` for faster keyword-based lookup with typo tolerance. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_searchSemantic` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name | | `text` | query | string | Yes | Natural language text to find semantically similar codes for | | `version` | query | string | No | Specific version of the code system, such as `umls-2026aa`. | | `limit` | query | integer | No | Maximum number of results (default 10, max 50) | #### Responses **200** - Semantic search results ordered by similarity Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "results" ], "properties": { "system": { "type": "object", "required": [ "name", "version" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" } } }, "results": { "type": "array", "description": "Codes ordered by semantic similarity (most similar first)", "items": { "type": "object", "required": [ "code", "description" ], "properties": { "code": { "type": "string", "example": "E11.65" }, "description": { "type": "string", "example": "Type 2 diabetes mellitus with hyperglycemia" } } } } } } ``` **Example:** ```json { "system": { "name": "ICD-10-CM", "version": "2025" }, "results": [ { "code": "R06.00", "description": "Dyspnea, unspecified" }, { "code": "R06.01", "description": "Orthopnea" }, { "code": "G47.33", "description": "Obstructive sleep apnea" }, { "code": "R06.83", "description": "Snoring" }, { "code": "J45.20", "description": "Mild intermittent asthma, uncomplicated" } ] } ``` **400** - Invalid parameters or missing search text **401** - Unauthorized **404** - Code system not found **500** - Server error --- ### GET /construe/codes/{codesystem}/search/text **Text search (keyword-based)** Performs fast full-text search over code IDs and descriptions. **Availability**: This endpoint is only available for **built-in code systems**. Custom code systems uploaded via `/construe/upload` are not indexed for full-text search and will return empty results. Use `/search/semantic` to search custom code systems. **When to use**: Best for autocomplete UIs, code lookup, or when users know part of the code ID or specific keywords. Fast response times suitable for typeahead interfaces. **Features**: - Substring matching on code IDs (e.g., "11.65" finds "E11.65") - Typo tolerance on descriptions (not on code IDs) - Fast response times (~10-50ms) **Examples**: - Query "E11" finds all codes starting with E11 (diabetes codes) - Query "diabtes" (typo) still finds "diabetes" codes **Trade-offs**: Faster than semantic search, but only matches keywords/substrings. Won't find conceptually related codes with different terminology. See also: `/search/semantic` for finding conceptually similar codes. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_searchText` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `codesystem` | path | string | Yes | Code system name | | `q` | query | string | Yes | Search query (searches code IDs and descriptions) | | `version` | query | string | No | Specific version of the code system, such as `umls-2026aa`. | | `limit` | query | integer | No | Maximum number of results (default 20, max 100) | #### Responses **200** - Text search results Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "results", "found" ], "properties": { "system": { "type": "object", "required": [ "name", "version" ], "properties": { "name": { "type": "string", "description": "Code system name", "example": "ICD-10-CM" }, "version": { "type": "string", "description": "Code system version", "example": "umls-2026aa" } } }, "results": { "type": "array", "description": "Codes matching the search query", "items": { "type": "object", "required": [ "code", "description" ], "properties": { "code": { "type": "string", "example": "E11.65" }, "description": { "type": "string", "example": "Type 2 diabetes mellitus with hyperglycemia" } } } }, "found": { "type": "integer", "description": "Total number of matching results (may exceed results array due to pagination)", "example": 150 } } } ``` **Example:** ```json { "system": { "name": "ICD-10-CM", "version": "2025" }, "results": [ { "code": "E11.65", "description": "Type 2 diabetes mellitus with hyperglycemia" }, { "code": "E11.649", "description": "Type 2 diabetes mellitus with hypoglycemia without coma" }, { "code": "E11.69", "description": "Type 2 diabetes mellitus with other specified complication" } ], "found": 3 } ``` **400** - Invalid parameters or missing query **401** - Unauthorized **404** - Code system not found **500** - Server error **501** - Text search not configured --- ### POST /construe/codes/crosswalk **Crosswalk a code to target code systems** Maps one source medical code to one or more target code-system URIs using shared UMLS CUIs. A successful response is HTTP 200 even when the source code or a target has no matches; inspect `reason_code` on the item and target entries for miss details. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_crosswalk` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "title": "CrosswalkRequest", "type": "object", "required": [ "system", "code", "targets" ], "properties": { "system": { "type": "string", "description": "Source FHIR code-system URI.", "example": "http://hl7.org/fhir/sid/icd-10-cm" }, "code": { "type": "string", "description": "Source code to map.", "example": "A02.24" }, "targets": { "type": "array", "minItems": 1, "maxItems": 1000, "description": "Target FHIR code-system URIs.", "items": { "type": "string" }, "example": [ "http://human-phenotype-ontology.org" ] } } } ``` **Example:** ```json { "system": "http://hl7.org/fhir/sid/icd-10-cm", "code": "A02.24", "targets": [ "http://human-phenotype-ontology.org" ] } ``` #### Responses **200** - Crosswalk result for the source code Content-Type: `application/json` ```json { "title": "CrosswalkResponse", "type": "object", "required": [ "resolved_umls_release", "system", "code", "targets" ], "properties": { "resolved_umls_release": { "type": "string", "description": "UMLS release used for the crosswalk.", "example": "2026AA" }, "system": { "type": "string", "description": "Source FHIR code-system URI.", "example": "http://hl7.org/fhir/sid/icd-10-cm" }, "code": { "type": "string", "description": "Source code that was mapped.", "example": "A02.24" }, "reason_code": { "type": "string", "description": "Item-level reason code when the source code could not be mapped.", "example": "NO_SOURCE_CUI" }, "targets": { "type": "array", "description": "Crosswalk matches grouped by requested target code-system URI.", "items": { "title": "CrosswalkTarget", "type": "object", "required": [ "system", "matches" ], "properties": { "system": { "type": "string", "description": "Target FHIR code-system URI.", "example": "http://human-phenotype-ontology.org" }, "reason_code": { "type": "string", "description": "Target-level reason code when this target has no matches.", "example": "NO_TARGET_MATCHES" }, "matches": { "type": "array", "description": "Codes in this target system that share a UMLS CUI with the source code.", "items": { "title": "CrosswalkMatch", "type": "object", "required": [ "code", "display", "cui" ], "properties": { "code": { "type": "string", "description": "Matched code in the target system.", "example": "HP:0005661" }, "display": { "type": "string", "description": "Human-readable target code display.", "example": "Salmonella infection" }, "cui": { "type": "string", "description": "UMLS CUI that links the source and target code.", "example": "C0036111" }, "suppress": { "type": "string", "description": "UMLS suppressibility flag, when present.", "example": "N" } } } } } } } } } ``` **Example:** ```json { "resolved_umls_release": "2026AA", "system": "http://hl7.org/fhir/sid/icd-10-cm", "code": "A02.24", "targets": [ { "system": "http://human-phenotype-ontology.org", "matches": [ { "code": "HP:0005661", "display": "Salmonella infection", "cui": "C0036111" } ] } ] } ``` **400** - Invalid request format or parameters **401** - Unauthorized **500** - Server error --- ### POST /construe/extract **Extract medical codes from text** Converts natural language text into structured medical codes. Pass `system.version` to select a specific code system version, for example `umls-2026aa` for UMLS 2026AA-backed systems. Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service. **Operation ID:** `construe_extract` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text" ], "properties": { "text": { "type": "string", "description": "Natural language text to extract codes from", "example": "Patient is a 14-year-old female, previously healthy, who is here for evaluation of abnormal renal ultrasound with atrophic right kidney" }, "system": { "type": "object", "properties": { "name": { "type": "string", "description": "Code system name. Can be a built-in system or a custom system name.\n\nBuilt-in systems:\n* CPT\n* HCPCS\n* HPO\n* ICD-10\n* ICD-10-CM\n* ICD-10-PCS\n* LOINC\n* RXNORM\n* SNOMED_CT_US\n* SNOMED_CT_US_LITE\n\nCustom systems:\n* Any valid system name uploaded via /construe/upload. Requires a paid plan.\n\nUsage of CPT is subject to AMA requirements: see PhenoML Terms of Service.\n", "example": "SNOMED_CT_US_LITE" }, "version": { "type": "string", "description": "Specific code system version.", "example": "umls-2026aa" } } }, "config": { "type": "object", "properties": { "chunking_method": { "type": "string", "enum": [ "none", "sentences", "paragraphs", "topics", "soap_note", "clinical_ner_extract", "fasthpocr" ], "default": "sentences", "description": "Method for splitting input text into chunks before code extraction.\n* none - Treat the full input as a single chunk.\n* sentences - Split on sentence boundaries (supports citations).\n* paragraphs / topics / soap_note - LLM-based chunking.\n* clinical_ner_extract - Extract clinical concepts (problems, tests,\n treatments) and use each as a chunk (supports citations).\n* fasthpocr - Extract HPO concepts directly with category\n annotations (supports citations). Requires `system: HPO`;\n other systems are rejected. Causes most other config options\n to be ignored.\n" }, "max_codes_per_chunk": { "type": "integer", "minimum": 1, "example": 5, "description": "Maximum number of codes to extract per chunk. If not specified, uses system-specific defaults:\n* SNOMED: 10\n* LOINC, HPO, RXNORM: 20\n* All other systems: 5\n" }, "code_similarity_filter": { "type": "number", "format": "float", "minimum": 0, "maximum": 1, "default": 0.9, "example": 0.9, "description": "Threshold for filtering similar codes (0.0-1.0)" }, "validation_method": { "type": "string", "enum": [ "none", "simple", "semantic_mapping", "medication_search", "chunk_code_jaccard_similarity" ], "default": "simple", "description": "Method for validating extracted codes:\n* none - No validation, returns all candidate codes\n* simple - LLM-based validation\n* semantic_mapping - LLM validation requiring equivalent meaning for an entire local clinical term, preserving negation and specificity. Disables code-to-code similarity filtering so distinct equivalent candidates remain visible\n* medication_search - LLM-based validation tailored for medication concepts\n* chunk_code_jaccard_similarity - Token-level Jaccard similarity between source text chunk and code description\n" }, "chunk_code_jaccard_similarity_filtering_threshold": { "type": "number", "format": "float", "minimum": 0, "maximum": 1, "default": 0.2, "description": "Minimum Jaccard similarity (0.0-1.0) for a code to be considered valid\nwhen using the \"chunk_code_jaccard_similarity\" validation method. Ignored by other methods.\n" }, "include_rationale": { "type": "boolean", "default": true, "description": "Whether to include explanations for why each code was extracted" }, "include_ancestors": { "type": "boolean", "default": false, "description": "Whether to include ancestor/parent codes in the results" }, "include_invalid": { "type": "boolean", "default": false, "description": "Whether to include codes that failed validation in the results" }, "include_citations": { "type": "boolean", "default": false, "description": "Whether to include source text citations for each extracted code.\nCitations show the exact text spans (with character offsets) that led to each code.\nSupported when chunking_method is \"sentences\", \"clinical_ner_extract\", or \"fasthpocr\".\n" }, "extraction_context": { "type": "string", "maxLength": 1000, "description": "Optional context describing the goal of the extraction.\nRequired when min_context_relevance is greater than 0.\n", "example": "extract billing codes for an outpatient visit" }, "min_context_relevance": { "type": "number", "format": "double", "minimum": 0, "maximum": 1, "default": 0, "description": "Minimum relevance score (0.0–1.0) a chunk must reach to proceed to code extraction.\nChunks are scored by an LLM against the extraction_context goal. Chunks below this\nthreshold are dropped, reducing noise and extraction cost.\nSet to 0 (the default) to disable relevance filtering and extract from all chunks.\nRequires the \"extraction_context\" field when set above 0.\n" }, "consistency_effort": { "type": "string", "enum": [ "none", "low", "medium", "high" ], "default": "none", "description": "How much effort to spend ensuring consistent results across repeated requests.\nHigher levels apply stricter filtering to remove borderline results that may\nvary between calls, improving determinism at the cost of additional latency.\n\nWhen validation_method is set to a value other than \"none\", consistency is\napplied to the validation step: codes must be unanimously validated across\nmultiple rounds to be included.\n\nWhen validation_method is \"none\" and min_context_relevance is set above 0,\nconsistency is applied to the relevance ranking step instead: chunks must\npass the relevance threshold in every round to be included.\n" } } } } } ``` **Example:** ```json { "text": "Patient is a 14-year-old female, previously healthy, who is here for evaluation of abnormal renal ultrasound with atrophic right kidney.", "system": { "name": "ICD-10-CM", "version": "2025" } } ``` #### Responses **200** - Successfully extracted codes Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "codes" ], "properties": { "system": { "type": "object", "properties": { "name": { "type": "string", "description": "Code system name. Can be a built-in system or a custom system name.\n\nBuilt-in systems:\n* CPT\n* HCPCS\n* HPO\n* ICD-10\n* ICD-10-CM\n* ICD-10-PCS\n* LOINC\n* RXNORM\n* SNOMED_CT_US\n* SNOMED_CT_US_LITE\n\nCustom systems:\n* Any valid system name uploaded via /construe/upload. Requires a paid plan.\n\nUsage of CPT is subject to AMA requirements: see PhenoML Terms of Service.\n", "example": "SNOMED_CT_US_LITE" }, "version": { "type": "string", "description": "Specific code system version.", "example": "umls-2026aa" } } }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description", "valid" ], "properties": { "code": { "type": "string", "description": "The extracted code", "example": "195967001" }, "description": { "type": "string", "description": "Short description of the code", "example": "Asthma" }, "valid": { "type": "boolean", "description": "Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.", "example": true }, "reason": { "type": "string", "description": "Explanation for why this code was extracted (if include_rationale is true)" }, "is_ancestor": { "type": "boolean", "nullable": true, "description": "Whether this code is an ancestor (parent) of an extracted code rather than directly extracted.\nOnly present when include_ancestors is true.\n" }, "citations": { "type": "array", "nullable": true, "description": "Source text references showing where this code was found in the input.\nOnly present when include_citations is true and chunking method supports it.\nAncestor codes do not receive citations.\n", "items": { "type": "object", "required": [ "text", "begin_offset", "end_offset" ], "description": "A reference to source text that led to a code extraction", "properties": { "text": { "type": "string", "description": "The exact text span containing evidence for the code", "example": "Patient has type 2 diabetes" }, "begin_offset": { "type": "integer", "description": "Starting byte offset in the original input text (0-indexed)", "example": 0 }, "end_offset": { "type": "integer", "description": "Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text", "example": 27 } } } }, "categories": { "type": "array", "nullable": true, "description": "Higher-level groupings the extracted code belongs to (e.g. HPO category terms).\nOnly populated by full-extraction chunking methods such as \"fasthpocr\".\n", "items": { "type": "object", "required": [ "uri", "label" ], "description": "A higher-level grouping (e.g. HPO category) for an extracted code.", "properties": { "uri": { "type": "string", "description": "Identifier for the category term (e.g. an HPO URI).", "example": "HP:0025142" }, "label": { "type": "string", "description": "Human-readable label for the category term.", "example": "Constitutional symptom" } } } } } } } } } ``` **Example:** ```json { "system": { "name": "ICD-10-CM", "version": "2025" }, "codes": [ { "code": "Q60.3", "description": "Renal hypoplasia, unspecified", "valid": true }, { "code": "R93.42", "description": "Abnormal findings on diagnostic imaging of kidney", "valid": true }, { "code": "N28.1", "description": "Cyst of kidney, acquired", "valid": true } ] } ``` **400** - Invalid request **401** - Unauthorized **404** - Code system not found **500** - Server error **503** - Service temporarily unavailable **504** - Request timed out --- ### POST /construe/phenocr **[Alpha] Extract medical codes with phenocr** **Alpha:** phenocr is an alpha feature. Request parameters, response shape, and results may change between releases. Do not depend on it for production workloads yet. Extracts medical codes from natural language clinical text using phenocr. Supported code systems: HPO, ICD-10-CM, RXNORM, and SNOMED_CT_US. The code system name and version are both required. **Operation ID:** `construe_phenocr` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text", "system" ], "properties": { "text": { "type": "string", "description": "Natural language text to extract codes from", "example": "5-year-old male with seizures, severe intellectual disability, microcephaly, and hypotonia." }, "system": { "type": "object", "required": [ "name", "version" ], "properties": { "name": { "type": "string", "description": "Code system name. Supported by phenocr: HPO, ICD-10-CM, RXNORM, SNOMED_CT_US.\n", "example": "HPO" }, "version": { "type": "string", "description": "Code system version to run against.", "example": "umls-2026AA" } } } } } ``` **Example:** ```json { "text": "5-year-old male with seizures, severe intellectual disability, microcephaly, and hypotonia.", "system": { "name": "HPO", "version": "umls-2026AA" } } ``` #### Responses **200** - Successfully extracted codes Content-Type: `application/json` ```json { "type": "object", "required": [ "system", "codes" ], "properties": { "system": { "type": "object", "properties": { "name": { "type": "string", "description": "Code system name. Can be a built-in system or a custom system name.\n\nBuilt-in systems:\n* CPT\n* HCPCS\n* HPO\n* ICD-10\n* ICD-10-CM\n* ICD-10-PCS\n* LOINC\n* RXNORM\n* SNOMED_CT_US\n* SNOMED_CT_US_LITE\n\nCustom systems:\n* Any valid system name uploaded via /construe/upload. Requires a paid plan.\n\nUsage of CPT is subject to AMA requirements: see PhenoML Terms of Service.\n", "example": "SNOMED_CT_US_LITE" }, "version": { "type": "string", "description": "Specific code system version.", "example": "umls-2026aa" } } }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description", "valid" ], "properties": { "code": { "type": "string", "description": "The extracted code", "example": "195967001" }, "description": { "type": "string", "description": "Short description of the code", "example": "Asthma" }, "valid": { "type": "boolean", "description": "Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.", "example": true }, "reason": { "type": "string", "description": "Explanation for why this code was extracted (if include_rationale is true)" }, "is_ancestor": { "type": "boolean", "nullable": true, "description": "Whether this code is an ancestor (parent) of an extracted code rather than directly extracted.\nOnly present when include_ancestors is true.\n" }, "citations": { "type": "array", "nullable": true, "description": "Source text references showing where this code was found in the input.\nOnly present when include_citations is true and chunking method supports it.\nAncestor codes do not receive citations.\n", "items": { "type": "object", "required": [ "text", "begin_offset", "end_offset" ], "description": "A reference to source text that led to a code extraction", "properties": { "text": { "type": "string", "description": "The exact text span containing evidence for the code", "example": "Patient has type 2 diabetes" }, "begin_offset": { "type": "integer", "description": "Starting byte offset in the original input text (0-indexed)", "example": 0 }, "end_offset": { "type": "integer", "description": "Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text", "example": 27 } } } }, "categories": { "type": "array", "nullable": true, "description": "Higher-level groupings the extracted code belongs to (e.g. HPO category terms).\nOnly populated by full-extraction chunking methods such as \"fasthpocr\".\n", "items": { "type": "object", "required": [ "uri", "label" ], "description": "A higher-level grouping (e.g. HPO category) for an extracted code.", "properties": { "uri": { "type": "string", "description": "Identifier for the category term (e.g. an HPO URI).", "example": "HP:0025142" }, "label": { "type": "string", "description": "Human-readable label for the category term.", "example": "Constitutional symptom" } } } } } } } } } ``` **400** - Invalid request **401** - Unauthorized **404** - Code system not found **500** - Server error **503** - Service temporarily unavailable **504** - Request timed out --- ## Untagged ### POST /construe/feedback **Submit feedback on extraction results** Submits user feedback on results from the Construe extraction endpoint. Feedback includes the full extraction result received and the result the user expected. **Operation ID:** `construe_submitFeedback` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text", "received_result", "expected_result" ], "properties": { "text": { "type": "string", "description": "The natural language text that was used for code extraction", "example": "Patient has type 2 diabetes with hyperglycemia" }, "received_result": { "type": "object", "required": [ "system", "codes" ], "properties": { "system": { "type": "object", "properties": { "name": { "type": "string", "description": "Code system name. Can be a built-in system or a custom system name.\n\nBuilt-in systems:\n* CPT\n* HCPCS\n* HPO\n* ICD-10\n* ICD-10-CM\n* ICD-10-PCS\n* LOINC\n* RXNORM\n* SNOMED_CT_US\n* SNOMED_CT_US_LITE\n\nCustom systems:\n* Any valid system name uploaded via /construe/upload. Requires a paid plan.\n\nUsage of CPT is subject to AMA requirements: see PhenoML Terms of Service.\n", "example": "SNOMED_CT_US_LITE" }, "version": { "type": "string", "description": "Specific code system version.", "example": "umls-2026aa" } } }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description", "valid" ], "properties": { "code": { "type": "string", "description": "The extracted code", "example": "195967001" }, "description": { "type": "string", "description": "Short description of the code", "example": "Asthma" }, "valid": { "type": "boolean", "description": "Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.", "example": true }, "reason": { "type": "string", "description": "Explanation for why this code was extracted (if include_rationale is true)" }, "is_ancestor": { "type": "boolean", "nullable": true, "description": "Whether this code is an ancestor (parent) of an extracted code rather than directly extracted.\nOnly present when include_ancestors is true.\n" }, "citations": { "type": "array", "nullable": true, "description": "Source text references showing where this code was found in the input.\nOnly present when include_citations is true and chunking method supports it.\nAncestor codes do not receive citations.\n", "items": { "type": "object", "required": [ "text", "begin_offset", "end_offset" ], "description": "A reference to source text that led to a code extraction", "properties": { "text": { "type": "string", "description": "The exact text span containing evidence for the code", "example": "Patient has type 2 diabetes" }, "begin_offset": { "type": "integer", "description": "Starting byte offset in the original input text (0-indexed)", "example": 0 }, "end_offset": { "type": "integer", "description": "Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text", "example": 27 } } } }, "categories": { "type": "array", "nullable": true, "description": "Higher-level groupings the extracted code belongs to (e.g. HPO category terms).\nOnly populated by full-extraction chunking methods such as \"fasthpocr\".\n", "items": { "type": "object", "required": [ "uri", "label" ], "description": "A higher-level grouping (e.g. HPO category) for an extracted code.", "properties": { "uri": { "type": "string", "description": "Identifier for the category term (e.g. an HPO URI).", "example": "HP:0025142" }, "label": { "type": "string", "description": "Human-readable label for the category term.", "example": "Constitutional symptom" } } } } } } } } }, "expected_result": { "type": "object", "required": [ "system", "codes" ], "properties": { "system": { "type": "object", "properties": { "name": { "type": "string", "description": "Code system name. Can be a built-in system or a custom system name.\n\nBuilt-in systems:\n* CPT\n* HCPCS\n* HPO\n* ICD-10\n* ICD-10-CM\n* ICD-10-PCS\n* LOINC\n* RXNORM\n* SNOMED_CT_US\n* SNOMED_CT_US_LITE\n\nCustom systems:\n* Any valid system name uploaded via /construe/upload. Requires a paid plan.\n\nUsage of CPT is subject to AMA requirements: see PhenoML Terms of Service.\n", "example": "SNOMED_CT_US_LITE" }, "version": { "type": "string", "description": "Specific code system version.", "example": "umls-2026aa" } } }, "codes": { "type": "array", "items": { "type": "object", "required": [ "code", "description", "valid" ], "properties": { "code": { "type": "string", "description": "The extracted code", "example": "195967001" }, "description": { "type": "string", "description": "Short description of the code", "example": "Asthma" }, "valid": { "type": "boolean", "description": "Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.", "example": true }, "reason": { "type": "string", "description": "Explanation for why this code was extracted (if include_rationale is true)" }, "is_ancestor": { "type": "boolean", "nullable": true, "description": "Whether this code is an ancestor (parent) of an extracted code rather than directly extracted.\nOnly present when include_ancestors is true.\n" }, "citations": { "type": "array", "nullable": true, "description": "Source text references showing where this code was found in the input.\nOnly present when include_citations is true and chunking method supports it.\nAncestor codes do not receive citations.\n", "items": { "type": "object", "required": [ "text", "begin_offset", "end_offset" ], "description": "A reference to source text that led to a code extraction", "properties": { "text": { "type": "string", "description": "The exact text span containing evidence for the code", "example": "Patient has type 2 diabetes" }, "begin_offset": { "type": "integer", "description": "Starting byte offset in the original input text (0-indexed)", "example": 0 }, "end_offset": { "type": "integer", "description": "Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text", "example": 27 } } } }, "categories": { "type": "array", "nullable": true, "description": "Higher-level groupings the extracted code belongs to (e.g. HPO category terms).\nOnly populated by full-extraction chunking methods such as \"fasthpocr\".\n", "items": { "type": "object", "required": [ "uri", "label" ], "description": "A higher-level grouping (e.g. HPO category) for an extracted code.", "properties": { "uri": { "type": "string", "description": "Identifier for the category term (e.g. an HPO URI).", "example": "HP:0025142" }, "label": { "type": "string", "description": "Human-readable label for the category term.", "example": "Constitutional symptom" } } } } } } } } }, "detail": { "type": "string", "description": "Optional details explaining the feedback", "example": "Expected code X instead because ..." } } } ``` **Example:** ```json { "text": "Patient has type 2 diabetes with hyperglycemia", "received_result": { "system": { "name": "ICD-10-CM", "version": "2025" }, "codes": [ { "code": "E11.9", "description": "Type 2 diabetes mellitus without complications", "valid": true } ] }, "expected_result": { "system": { "name": "ICD-10-CM", "version": "2025" }, "codes": [ { "code": "E11.65", "description": "Type 2 diabetes mellitus with hyperglycemia", "valid": true } ] }, "detail": "Expected code E11.65 because the text mentions hyperglycemia" } ``` #### Responses **201** - Feedback saved successfully Content-Type: `application/json` ```json { "type": "object", "required": [ "id" ], "properties": { "id": { "type": "string", "description": "The ID of the saved feedback", "example": "abc123def456" } } } ``` **Example:** ```json { "id": "abc123def456" } ``` **400** - Invalid request (missing required fields or malformed JSON) **401** - Unauthorized **500** - Server error **503** - Database unavailable --- # Lang2FHIR Convert natural language clinical text into structured FHIR resources including Patient, Condition, MedicationRequest, and more. ## Endpoints ### POST /cohort **Analyze text for patient cohort criteria** Converts natural language text into structured FHIR search queries for patient cohort analysis **Operation ID:** `cohort_analyze` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text" ], "properties": { "text": { "type": "string", "description": "Natural language text describing patient cohort criteria", "example": "female patients over 65 with diabetes but not hypertension" } } } ``` **Example:** ```json { "text": "female patients over 65 with diabetes but not hypertension" } ``` #### Responses **200** - Successfully analyzed cohort criteria Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the cohort analysis was successful", "example": true }, "message": { "type": "string", "description": "Human-readable message about the analysis result", "example": "Cohort analysis completed successfully. Generated 3 search queries from 3 concepts." }, "queries": { "type": "array", "description": "Array of search concepts converted to FHIR search queries", "items": { "type": "object", "properties": { "resource_type": { "type": "string", "description": "The FHIR resource type for this search concept", "example": "Patient" }, "search_params": { "type": "string", "description": "FHIR search parameters in standard format", "example": "gender=female&birthdate=le1959-01-01" }, "concept": { "type": "string", "description": "The original concept description", "example": "female patients over 65" }, "exclude": { "type": "boolean", "description": "Whether this concept should be excluded from the search", "example": false } } } } } } ``` **Example:** ```json { "success": true, "message": "Cohort analysis completed successfully. Generated 3 search queries from 3 concepts.", "queries": [ { "resource_type": "Patient", "search_params": "gender=female&birthdate=le1959-01-01", "concept": "female patients over 65", "exclude": false }, { "resource_type": "Condition", "search_params": "code=44054006", "concept": "diabetes", "exclude": false }, { "resource_type": "Condition", "search_params": "code=38341003", "concept": "hypertension", "exclude": true } ] } ``` **400** - Invalid request **401** - Unauthorized **500** - Server error --- ### GET /lang2fhir/batch **List batch jobs** Returns a page of the instance's batch jobs, newest first, without per-job counts. Jobs are shared across the instance's credentials, so this lists every batch job on the instance, not just the calling credential's. **Operation ID:** `batch_list` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - A page of batch jobs Content-Type: `application/json` ```json { "type": "object", "description": "A page of job records, without per-job counts.", "required": [ "jobs", "has_more" ], "properties": { "jobs": { "type": "array", "items": { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more jobs remain beyond this page.", "example": false } } } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/batch **Create a batch job** Opens an empty job; upload items, then finalize it to start processing. `request_id` makes creation idempotent: a retry returns the original job. A token is released when its job is canceled or fails before finalization; otherwise it continues to resolve to that job. **Operation ID:** `batch_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "description": "Body of a create-batch request. Opens an empty job.", "properties": { "request_id": { "type": "string", "description": "Optional client idempotency token (at most 256 UTF-8 bytes). A\nretried create with the same token returns the original job instead\nof opening a second one.\n", "example": "submit-2025-09-02-batch-001" } } } ``` **Example:** ```json { "request_id": "submit-2025-09-02-batch-001" } ``` #### Responses **202** - Batch job created (or an idempotent replay of an existing job) Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **400** - Invalid request (e.g. request_id over its 256-byte limit) **401** - Unauthorized **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /lang2fhir/batch/{job_id} **Get a batch job** Returns a job's record, its per-status item counts, and one page of per-item statuses. Items are listed in a stable order that is not upload order and is the same across pages. Match each entry to your own records by its `id` (your correlation label) or `item_id` (from the upload response), never by position. **Operation ID:** `batch_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size for the item-status page. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - The job record, counts, and a page of item statuses Content-Type: `application/json` ```json { "description": "A job's record, its counts, and one page of item statuses.\n", "allOf": [ { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } }, { "type": "object", "required": [ "counts", "items", "has_more" ], "properties": { "counts": { "type": "object", "description": "A job's per-status item tally.", "required": [ "total", "pending", "processing", "succeeded", "failed" ], "properties": { "total": { "type": "integer", "example": 12 }, "pending": { "type": "integer", "example": 3 }, "processing": { "type": "integer", "example": 2 }, "succeeded": { "type": "integer", "example": 6 }, "failed": { "type": "integer", "example": 1 } } }, "items": { "type": "array", "items": { "type": "object", "description": "One item's status line.", "required": [ "item_id", "status", "attempts" ], "properties": { "item_id": { "type": "string", "description": "Server-assigned opaque item ID, used in result URLs.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "chart-note-0042" }, "status": { "type": "string", "description": "Item status.", "enum": [ "pending", "processing", "succeeded", "failed" ], "example": "succeeded" }, "attempts": { "type": "integer", "description": "Number of processing attempts started so far. The service may retry\ninterrupted work; a conversion error fails the item without retry.\n", "example": 1 }, "detect_retries": { "type": "integer", "format": "int64", "description": "How many times concept detection was re-run for the item because a\npass returned no concepts. Present only on a succeeded item whose\ndetection re-ran at least once; omitted otherwise.\n", "example": 1 }, "result_size": { "type": "integer", "format": "int64", "description": "Size in bytes of the item's stored result. Present once the item has succeeded.", "example": 20482 }, "error": { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } }, "completed_at": { "type": "string", "format": "date-time", "description": "When the item finished. Absent until then." } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more item statuses remain beyond this page.", "example": false } } } ] } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **404** - Batch job not found **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/batch/{job_id}/cancel **Cancel a batch job** Drives a job to the terminal `canceled` state on request. Takes no request body. Cancel does not delete the job: the job record and any results already produced are preserved for the normal retention window, the same as a `completed` or `failed` job. Items stop being processed and keep the state they held at cancellation, so a canceled job's `counts` may show unfinished items that never resolve. Cancel is idempotent: canceling an already-`canceled` job returns `200` with the job. Canceling a job that has already `completed` or `failed` is a `409`. **Operation ID:** `batch_cancel` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Responses **200** - The job, now canceled Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **401** - Unauthorized **404** - Batch job not found **409** - The job has already completed or failed and cannot be canceled **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/batch/{job_id}/finalize **Finalize a batch job** Seals the job's item set and starts processing. Takes no request body. Finalize is idempotent: a retried finalize succeeds again. If a previous upload did not complete, finalize returns a `409`; re-send the missing upload (with the same `request_id`), then finalize. Finalizing a job with no items is a `400`. **Operation ID:** `batch_finalize` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Responses **202** - Job finalized and processing started Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **400** - The batch has no items to finalize **401** - Unauthorized **404** - Batch job not found **409** - A previous upload did not complete; re-send it with the same request_id, then finalize **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/batch/{job_id}/items **Upload one batch item** Stores one multipart item. Set **either** `document` with a raw `file`, or JSON-only `create`. Set exactly one JSON object. `document` requires `file`; `create` forbids it. Violations return `400`. Upload validates only the envelope. Endpoint request validation happens during processing: decoding failures are `invalid_input`; other pipeline failures are `processing_failed`. Use `request_id` for every upload so retries replace the same item. `deduplicated` is true only for an unchanged payload; a changed payload overwrites the item and returns false. Uploads return `409` after finalization or at the item limit, and `413` when the item is too large. **Operation ID:** `batch_uploadItem` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Request Body **Required:** Yes **Content-Type:** `multipart/form-data` ```json { "type": "object", "properties": { "document": { "type": "object", "description": "The JSON body of `POST /lang2fhir/document/multi`, **without**\nits base64 `content` field — the uploaded `file` supplies the\ncontent. Accepts that endpoint's fields (`version`, `provider`,\n`primary_patient`, `patient_reference` (deprecated), `implementation_guide`, `detection_effort` (deprecated),\n`validation_method`, `config`). This is the **multi**-resource\nbody: it has no single-`resource` field, and the item's result\nis a `DocumentMultiResponse` (a Bundle of resources). Mutually\nexclusive with `create`; requires `file`. Do not combine\n`primary_patient` with `patient_reference`.\n" }, "create": { "type": "object", "description": "The JSON body of `POST /lang2fhir/create/multi`. Accepts that\nendpoint's fields (`text`, `version`, `provider`,\n`primary_patient`, `patient_reference` (deprecated), `implementation_guide`, `detection_effort` (deprecated),\n`validation_method`, `resource_review`, `small_note`). This is the\n**multi**-resource body: it has no single-`resource` field, and\nthe item's result is a `CreateMultiResponse` (a Bundle of\nresources). Mutually exclusive with `document`; must **not** be\naccompanied by a `file`. Do not combine `primary_patient` with\n`patient_reference`.\n" }, "file": { "type": "string", "format": "binary", "description": "The document's file content (PDF, PNG, JPEG, TIFF, RTF, or\nXML/C-CDA). The document pipeline accepts files up to 20 MiB;\nan upload that passes the storage cap but exceeds this limit\nfails during processing. RTF and XML/C-CDA documents whose\nextracted text exceeds 1 MiB also fail during processing.\nGeneric XML must include an XML declaration; C-CDA documents\nrooted at `ClinicalDocument` may omit it.\nRequired with `document`; forbidden with `create`.\n" }, "request_id": { "type": "string", "description": "Optional idempotency token (at most 256 UTF-8 bytes).\nRe-uploading under the same token overwrites the same item\ninstead of adding a new one. The token is scoped to this job;\nthe same token in another job is independent and creates a\nseparate item.\n" }, "id": { "type": "string", "description": "Optional caller-supplied correlation label (at most 512 UTF-8\nbytes), echoed back on status and result listings so you can\nmatch the server's item_id to your own record.\n" } } } ``` #### Responses **202** - Item accepted Content-Type: `application/json` ```json { "description": "The upload response: the job record plus the ID the server assigned the\nuploaded item.\n", "allOf": [ { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "submit-2025-09-02-batch-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /lang2fhir/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } }, { "type": "object", "required": [ "item_id", "deduplicated" ], "properties": { "item_id": { "type": "string", "description": "The server-assigned ID of the uploaded item; use it to fetch the result.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "chart-note-0042" }, "deduplicated": { "type": "boolean", "description": "True only when a repeated `request_id` resolved to an item whose\npayload matched the one already stored. A same-token upload with a\nchanged payload overwrites in place and returns false.\n", "example": false } } } ] } ``` **400** - Invalid upload — e.g. both or neither of document/create set, a non-object document/create, a document item missing its file, a create item carrying a file, a `small_note` create item whose `text` exceeds 15,360 bytes, or an over-length request_id/id. **401** - Unauthorized **404** - Batch job not found **409** - The job is finalized or at its item limit **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /lang2fhir/batch/{job_id}/results **List a batch job's results** A lighter status page. Returns the same per-item status entries as `GET /lang2fhir/batch/{job_id}`, but without the job record or counts, and the entries carry `result_size` rather than any result content. Use each entry's `item_id` to fetch that item's result from `GET /lang2fhir/batch/{job_id}/results/{item_id}`. Entries are listed in a stable order that is not upload order and is the same across pages. Match each entry to your own records by its `id` (your correlation label) or `item_id` (from the upload response), never by position. **Operation ID:** `batch_getResults` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - A page of per-item result statuses Content-Type: `application/json` ```json { "type": "object", "description": "A page of per-item result statuses, without the job counts.", "required": [ "results", "has_more" ], "properties": { "results": { "type": "array", "items": { "type": "object", "description": "One item's status line.", "required": [ "item_id", "status", "attempts" ], "properties": { "item_id": { "type": "string", "description": "Server-assigned opaque item ID, used in result URLs.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "chart-note-0042" }, "status": { "type": "string", "description": "Item status.", "enum": [ "pending", "processing", "succeeded", "failed" ], "example": "succeeded" }, "attempts": { "type": "integer", "description": "Number of processing attempts started so far. The service may retry\ninterrupted work; a conversion error fails the item without retry.\n", "example": 1 }, "detect_retries": { "type": "integer", "format": "int64", "description": "How many times concept detection was re-run for the item because a\npass returned no concepts. Present only on a succeeded item whose\ndetection re-ran at least once; omitted otherwise.\n", "example": 1 }, "result_size": { "type": "integer", "format": "int64", "description": "Size in bytes of the item's stored result. Present once the item has succeeded.", "example": 20482 }, "error": { "type": "object", "description": "A job- or item-level failure. Never contains document or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(the stored body was not a valid create/document request),\n`processing_failed` (the conversion failed), `result_too_large` (the\nresult exceeded the storage cap), `input_unavailable` (the input\ncould not be read), and `retries_exhausted` / `attempts_exhausted`\n(the item could not complete after repeated interruptions).\nJob-level kinds: `timeout` (the job did not finish within 36 hours\nof creation).\n", "example": "processing_failed" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "the item could not be converted" } } }, "completed_at": { "type": "string", "format": "date-time", "description": "When the item finished. Absent until then." } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more results remain beyond this page.", "example": false } } } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **404** - Batch job not found **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /lang2fhir/batch/{job_id}/results/{item_id} **Get one batch item's result** Streams one item's stored result bytes verbatim as `application/json`. The body is the response the item's synchronous multi endpoint would have returned — a `DocumentMultiResponse` for a document item or a `CreateMultiResponse` for a create item. Only a succeeded item has a result: an item that has not succeeded (pending, processing, or failed) is a `409`, and a result that has expired is a `404`. **Operation ID:** `batch_getResult` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `item_id` | path | string | Yes | | #### Responses **200** - The item's raw result JSON Content-Type: `application/json` ```json { "type": "object", "description": "The item's extraction result — a DocumentMultiResponse (document\nitem) or CreateMultiResponse (create item).\n" } ``` **400** - Invalid request (e.g. empty item_id) **401** - Unauthorized **404** - Batch job or item not found, or the result has expired **409** - The item has not succeeded, so it has no result to serve **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/create **Create FHIR resource from text** Converts natural language text into a structured FHIR resource. The complete JSON request body is limited to 32 MiB (33,554,432 bytes). The application enforces this whole-envelope limit. **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. **Operation ID:** `lang2fhir_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "version", "resource", "text" ], "properties": { "version": { "type": "string", "description": "FHIR version to use", "example": "R4", "default": "R4" }, "resource": { "type": "string", "description": "Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported profile. The default profile set includes US Core profiles and selected base R4 resources. The built-in PhenoML HPO profiles must be requested by id: `phenoml-hpo-condition` and `phenoml-hpo-phenotypic-observation` code findings with the Human Phenotype Ontology, and `phenoml-hpo-head-circumference-tape-measure` and `phenoml-hpo-head-circumference-percentile` record a head circumference measured as a length or stated as an age-adjusted percentile. You can also use any custom profile you've uploaded (if you're a develop or launch customer).\n", "example": "condition-encounter-diagnosis", "enum": [ "auto", "appointment", "condition-encounter-diagnosis", "familymemberhistory", "medicationadministration", "medicationrequest", "medicationstatement", "careplan", "condition-problems-health-concerns", "coverage", "encounter", "observation-clinical-result", "observation-lab", "patient", "phenoml-hpo-condition", "phenoml-hpo-phenotypic-observation", "phenoml-hpo-head-circumference-tape-measure", "phenoml-hpo-head-circumference-percentile", "procedure", "questionnaire", "questionnaireresponse", "servicerequest", "simple-observation", "vital-signs" ] }, "text": { "type": "string", "description": "Natural language text to convert", "example": "Patient has severe asthma with acute exacerbation" } } } ``` **Example:** ```json { "text": "Patient has severe persistent asthma with acute exacerbation", "version": "R4", "resource": "condition-encounter-diagnosis" } ``` #### Responses **200** - Successfully created FHIR resource Content-Type: `application/json` ```json { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ``` **Example:** ```json { "resourceType": "Condition", "clinicalStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-clinical", "code": "active" } ] }, "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "195967001", "display": "Asthma" } ], "text": "Severe persistent asthma with acute exacerbation" }, "severity": { "coding": [ { "system": "http://snomed.info/sct", "code": "24484000", "display": "Severe" } ] } } ``` **400** - Invalid request **401** - Unauthorized **404** - Profile not found **422** - Generated FHIR resource failed validation or terminology constraints **500** - Server error --- ### POST /lang2fhir/create/multi **Extract multiple FHIR resources from text** Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text. Resources are linked with proper references (e.g., Conditions reference the Patient). The complete JSON request body is limited to 32 MiB (33,554,432 bytes). The application enforces this whole-envelope limit. **Patient handling.** Every bundle contains exactly one Patient, and every clinical resource references it. When the text names its patient, the Patient is built from the text. When it names several patients, the Patient is the one `primary_patient` names, otherwise the one most of the text is about; the others are not represented as Patients. Otherwise it is built from `primary_patient` when supplied, or is an unidentified Patient carrying only a synthetic identifier. When the text names its patient, the `primary_patient` identifier is added to that Patient unless its name, birth date, or gender contradicts the text's; the response `message` says whether it was added or did not match. **Patient identifier handling.** US Core requires `Patient.identifier` (a business identifier such as an MRN). Every Patient carries a synthetic identifier with `system: "urn:phenoml:lang2fhir-generated-id"` and a UUID `value`, so the bundle remains FHIR-valid and US Core conformant. A medical record number stated in the text is added with `system: "urn:phenoml:lang2fhir-document-mrn"`, and the `primary_patient` identifier is added as described above. Callers who need a tenant-specific namespace should rewrite these systems after extraction. **Operation ID:** `lang2fhir_createMulti` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text" ], "properties": { "text": { "type": "string", "description": "Natural language text containing multiple clinical concepts to extract", "example": "John Smith, male born on 1980-03-12, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily." }, "version": { "type": "string", "description": "FHIR version to use", "example": "R4", "default": "R4" }, "provider": { "type": "string", "description": "Optional FHIR provider name for provider-specific profiles", "example": "canvas" }, "primary_patient": { "allOf": [ { "type": "object", "minProperties": 1, "description": "Partial context for the patient the source is primarily about. This is not a complete FHIR Patient resource. When the source does not name its patient, the bundle's Patient is built from exactly these fields. When it does, the identifier supplied here is added to that Patient unless its name, birth date, or gender contradicts these fields, so the bundle can be matched back to the caller's own record.\n", "properties": { "identifier": { "type": "object", "description": "Business identifier for the primary patient. The bundle's Patient carries this identifier alongside its synthetic one, unless the Patient found in the source contradicts primary_patient. Supply the patient-level identifier (not an order or specimen identifier).\n", "required": [ "system", "value" ], "properties": { "system": { "type": "string", "description": "Identifier system (namespace) for the patient identifier.", "example": "urn:acmehealth:patient_index_id" }, "value": { "type": "string", "description": "Identifier value for the patient within that system." } }, "example": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" } }, "name": { "type": "object", "description": "The known portions of the primary patient's name. Provide a non-empty family name or at least one non-empty given name.\n", "properties": { "family": { "type": "string", "description": "Family name.", "example": "Smith" }, "given": { "type": "array", "description": "Given names.", "items": { "type": "string" }, "example": [ "Jane" ] } } }, "birthDate": { "type": "string", "format": "date", "description": "Complete date of birth in YYYY-MM-DD format.", "example": "1980-03-12" }, "gender": { "type": "string", "enum": [ "male", "female", "other", "unknown" ], "description": "Administrative gender.", "example": "female" } }, "example": { "identifier": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" }, "name": { "family": "Smith", "given": [ "Jane" ] }, "birthDate": "1980-03-12", "gender": "female" } } ], "description": "Context for the patient the text is primarily about. When the text does not name its patient, the bundle's Patient is built from these fields. When it does, the identifier is added to that Patient unless its name, birth date, or gender contradicts these fields.\n" }, "patient_reference": { "deprecated": true, "description": "Deprecated compatibility alias for primary_patient.identifier. Cannot be combined with primary_patient.", "type": "object", "required": [ "system", "value" ], "properties": { "system": { "type": "string", "description": "Identifier system (namespace) for the patient identifier.", "example": "urn:acmehealth:patient_index_id" }, "value": { "type": "string", "description": "Identifier value for the patient within that system." } }, "example": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" } }, "implementation_guide": { "type": "string", "description": "Implementation Guide to generate resources under. `us_core` (the default) and `phenoml_hpo` select a built-in guide. Any other value is a custom Implementation Guide name: its profiles are included alongside the US Core profiles, which are always the base layer. A custom name that matches no uploaded Implementation Guide returns 404.\n", "default": "us_core", "example": "acme-cardiology" }, "detection_effort": { "type": "string", "deprecated": true, "description": "Deprecated and ignored: both values produce the same result. This field will be removed in a future release.", "enum": [ "standard", "deep" ], "default": "standard" }, "validation_method": { "type": "string", "description": "FHIR validation method to apply to the generated bundle. 'none' skips validation (default). 'check' runs the bundle through a FHIR structure validator and includes the results in the response. 'fix' runs validation and attempts to auto-correct errors using an LLM (up to 3 validation passes). The response includes results from each pass. Warning: 'fix' can significantly increase latency due to multiple LLM and validation round-trips.\n", "enum": [ "none", "check", "fix" ], "default": "none" }, "resource_review": { "type": "object", "description": "Faithfulness audit of the generated resources (honored by /lang2fhir/create/multi and /lang2fhir/document/multi). When resource_review is omitted, the audit runs with these default targets: Encounter checks dates; Procedure and DiagnosticReport check dates and codes; Observation, Condition, and MedicationRequest check codes. Supplying resource_review replaces the defaults with the listed targets; an empty targets list turns the audit off. For each selected resource type an LLM checks whether selected dates and clinical code concepts are actually supported by the full source document. An unsupported individual coding is removed when another coding remains in its concept. Resources with an unsupported structural field, a profile-required coding, or no coding remaining in an affected concept, are pulled out of the returned bundle and reported under resource_review in the response. Encounters, and diagnostic reports built from the source's report dates, are never pulled out, because other resources in the bundle reference them: an unsupported field is removed from them when their profile does not require it, and kept and reported when it does.\n", "required": [ "targets" ], "properties": { "targets": { "type": "array", "maxItems": 25, "description": "The resource types to audit and which date or clinical code field kinds to check. An empty list turns the audit off.\n", "items": { "type": "object", "required": [ "resource_type" ], "properties": { "resource_type": { "type": "string", "description": "FHIR resourceType to audit (e.g. Condition, Procedure, Observation, Encounter, MedicationRequest), matched against each generated resource's resourceType. Patient is not supported.\n", "example": "Condition" }, "fields": { "type": "array", "description": "Field kinds to check for this resource type. Defaults to [\"dates\"] when omitted; use \"codes\" to audit clinical code concepts.", "items": { "type": "string", "enum": [ "dates", "codes" ] }, "example": [ "dates", "codes" ] } } } } } }, "small_note": { "type": "boolean", "default": false, "description": "Bills the request at the lower small-note rate. When true, `text` must be at most 15,360 bytes (15 KiB) when UTF-8 encoded; longer text is rejected with a 400 error. Extraction behavior is the same as a standard request.\n" } } } ``` **Example:** ```json { "text": "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily. Blood pressure 140/90.", "version": "R4" } ``` #### Responses **200** - Successfully extracted FHIR resources Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether extraction was successful", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Successfully extracted 3 resources" }, "bundle": { "type": "object", "description": "FHIR transaction Bundle containing all extracted resources", "properties": { "resourceType": { "type": "string", "example": "Bundle" }, "type": { "type": "string", "example": "transaction" }, "entry": { "type": "array", "items": { "type": "object", "properties": { "fullUrl": { "type": "string", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resource": { "type": "object" }, "request": { "type": "object", "properties": { "method": { "type": "string", "example": "POST" }, "url": { "type": "string", "example": "Patient" } } } } } } } }, "resources": { "type": "array", "description": "Summary of extracted resources", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "Temporary UUID for the resource", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "description": "FHIR resource type", "example": "Patient" }, "description": { "type": "string", "description": "Context-enriched rewritten text excerpt for this resource", "example": "John Smith (DOB 1980-05-12) was diagnosed with Type 2 Diabetes during office visit on 2025-03-01 with Dr. Chen" }, "originalText": { "type": "string", "description": "Verbatim text excerpt from the original clinical document", "example": "diagnosed with Type 2 Diabetes" }, "group": { "type": "string", "description": "Split classification id assigned to this resource by the /lang2fhir/document/multi endpoint. When the resource came from pages in more than one group, this is the group covering the most of its source pages, with ties going to the group with the earliest source page. Omitted when the resource came only from ungrouped pages, when its sourcePages is omitted, or for raw-text create/multi.\n", "example": "clinical" }, "sourcePages": { "type": "array", "items": { "type": "integer" }, "description": "1-indexed source document page number(s) this resource was extracted from. Populated only by the /lang2fhir/document/multi endpoint; omitted when the source page could not be determined (e.g. raw-text create/multi, or a resource with no verbatim source text).\n", "example": [ 2 ] } } } }, "validation": { "type": "object", "nullable": true, "description": "FHIR validation results. Present when validation_method is 'check' or 'fix'. Contains results from each validation pass. For 'check', there is one pass. For 'fix', there may be up to 3 passes as the system attempts auto-correction.\n", "properties": { "passes": { "type": "array", "description": "Results from each validation pass, in chronological order", "items": { "type": "object", "properties": { "issues": { "type": "array", "description": "Validation issues found in this pass", "items": { "type": "object", "properties": { "severity": { "type": "string", "description": "Issue severity level", "enum": [ "fatal", "error", "warning", "information" ] }, "code": { "type": "string", "description": "Issue type code" }, "diagnostics": { "type": "string", "description": "Human-readable description of the issue" }, "expression": { "type": "array", "items": { "type": "string" }, "description": "FHIRPath expression(s) pointing to the issue location" }, "source": { "type": "string", "description": "Validation phase that generated this issue" } } } }, "stats": { "type": "object", "nullable": true, "description": "Validation statistics for this pass", "properties": { "resource_type": { "type": "string" }, "profile_url": { "type": "string" }, "is_custom_profile": { "type": "boolean" }, "duration_ms": { "type": "number", "description": "Validation duration in milliseconds" } } } } } }, "fixed": { "type": "boolean", "description": "Whether validation errors were successfully fixed by the LLM. Always false for 'check' mode. For 'fix' mode, true if errors were resolved and the returned bundle is the corrected version.\n" }, "attempts": { "type": "integer", "description": "Total number of validation passes run (1 for check, 1-3 for fix)" }, "summary": { "type": "string", "description": "Human-readable summary of the validation outcome" } } }, "resource_review": { "type": "object", "description": "Present when the resource review ran and at least one resource was quarantined, safely remediated, or kept with an unsupported required field. The returned bundle is authoritative and contains the post-review representation of every retained resource.\n", "properties": { "flagged": { "type": "array", "description": "Resources pulled from the bundle because an unsupported finding could not be safely repaired.", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "The urn:uuid of the flagged resource (its former bundle fullUrl).", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "example": "Condition" }, "resource": { "type": "object", "description": "The full generated FHIR resource that was pulled from the bundle." }, "findings": { "type": "array", "description": "The findings that caused the resource to be quarantined.", "items": { "type": "object", "properties": { "fieldKind": { "type": "string", "enum": [ "dates", "codes" ], "example": "dates" }, "fieldPath": { "type": "string", "description": "JSON path of the field within the resource.", "example": "onsetDateTime" }, "value": { "type": "string", "example": "2024-01-15" }, "supported": { "type": "boolean", "description": "False when the reviewer found the field unsupported. Do not treat this field as a verdict when unaudited is true.", "example": false }, "unaudited": { "type": "boolean", "description": "True when the reviewer did not return a verdict for this field; the resource was quarantined without treating the finding as evidence that the value is unsupported.", "example": true }, "rationale": { "type": "string", "description": "Short explanation of why the value is not supported by the source.", "example": "Date is the visit date, not when the condition began." } } } } } } }, "remediated": { "type": "array", "description": "Resources retained in the bundle after review: unsupported codings or fields were safely removed, or unsupported required fields were kept and are reported here (see action).\n", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "The urn:uuid of the remediated resource (its bundle fullUrl).", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "example": "Condition" }, "action": { "type": "string", "enum": [ "removed_codings", "removed_fields", "flagged_required" ], "description": "What review did to the resource in the returned bundle: removed_codings removed unsupported codings while each affected concept kept one; removed_fields removed unsupported fields its profile does not require; flagged_required kept unsupported fields its profile requires, so the findings report values that remain in the bundle.\n" }, "findings": { "type": "array", "description": "Findings for fields in the pre-remediation resource that caused this action.", "items": { "type": "object", "properties": { "fieldKind": { "type": "string", "enum": [ "dates", "codes" ], "example": "dates" }, "fieldPath": { "type": "string", "description": "JSON path of the field within the resource.", "example": "onsetDateTime" }, "value": { "type": "string", "example": "2024-01-15" }, "supported": { "type": "boolean", "description": "False when the reviewer found the field unsupported. Do not treat this field as a verdict when unaudited is true.", "example": false }, "unaudited": { "type": "boolean", "description": "True when the reviewer did not return a verdict for this field; the resource was quarantined without treating the finding as evidence that the value is unsupported.", "example": true }, "rationale": { "type": "string", "description": "Short explanation of why the value is not supported by the source.", "example": "Date is the visit date, not when the condition began." } } } } } } } } } } } ``` **Example:** ```json { "success": true, "message": "Successfully extracted 3 resources", "bundle": { "resourceType": "Bundle", "type": "transaction", "entry": [ { "fullUrl": "urn:uuid:patient-001", "resource": { "resourceType": "Patient", "name": [ { "given": [ "John" ], "family": "Smith" } ], "gender": "male" }, "request": { "method": "POST", "url": "Patient" } }, { "fullUrl": "urn:uuid:condition-001", "resource": { "resourceType": "Condition", "code": { "text": "Type 2 Diabetes" } }, "request": { "method": "POST", "url": "Condition" } }, { "fullUrl": "urn:uuid:medication-001", "resource": { "resourceType": "MedicationRequest", "medicationCodeableConcept": { "text": "Metformin 500mg" } }, "request": { "method": "POST", "url": "MedicationRequest" } } ] } } ``` **400** - Invalid request **401** - Unauthorized **404** - Profile or implementation guide not found **422** - Generated FHIR resource failed validation or terminology constraints **500** - Server error --- ### POST /lang2fhir/document **Convert document to FHIR resource** Extracts text from a PDF, image, RTF, or XML/C-CDA document and converts it into a structured FHIR resource. The complete JSON request body is limited to 32 MiB (33,554,432 bytes). The application enforces this whole-envelope limit, including base64-encoded document `content`. **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. **Operation ID:** `lang2fhir_document` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "version", "resource", "content" ], "properties": { "version": { "type": "string", "description": "FHIR version to use", "example": "R4" }, "resource": { "type": "string", "description": "Type of FHIR resource to create. Accepts any FHIR resource type or US Core profile name.", "example": "questionnaire" }, "content": { "type": "string", "description": "Base64 encoded file content.\nSupported file types: PDF (application/pdf), PNG (image/png), JPEG (image/jpeg), TIFF (image/tiff), RTF (application/rtf), XML/C-CDA (text/xml).\nTIFF, RTF, and XML/C-CDA uploads are available on dedicated instances only.\nFile type is auto-detected from content magic bytes.\nThe decoded file must not exceed 20 MiB. RTF and XML/C-CDA documents whose extracted text exceeds 1 MiB are rejected.\nGeneric XML must include an XML declaration; C-CDA documents rooted at `ClinicalDocument` may omit it.\n" }, "config": { "type": "object", "description": "Optional processing configuration shared across document endpoints.", "properties": { "split_classifications": { "type": "array", "maxItems": 20, "description": "Optional per-page classifications, applied before extraction; accepts up to 20 classifications. When omitted or empty, every page with extracted text is used. This is a caller-defined list, not a fixed taxonomy: choose each classification id and describe the pages that belong to it. Each page is assigned at most one classification; a page that does not clearly match any, or that cannot be classified, is kept and left ungrouped. Pages matching a drop classification are removed before extraction. Pages matching a group classification are kept; on /lang2fhir/document/multi, resources extracted from them include the classification id in resources[].group and as a FHIR meta.tag. When every page is dropped, /lang2fhir/document returns 422 and /lang2fhir/document/multi returns success false with page_classifications. Example ids such as clinical and admin are illustrative, not a fixed set.\n", "items": { "type": "object", "title": "SplitClassification", "description": "One caller-defined page classification and the operation to apply when it matches.", "required": [ "id", "description", "operation" ], "properties": { "id": { "type": "string", "maxLength": 64, "description": "Unique, non-blank classification id. Returned as page_classifications[].classification_id and, for group classifications, as resources[].group and the FHIR meta.tag code. The reserved id \"__ungrouped__\" is not allowed.\n", "example": "labs" }, "description": { "type": "string", "maxLength": 500, "description": "Non-blank natural-language description of the pages that belong to this classification. Each page's text is compared against these descriptions, so describe what distinguishes these pages from the rest of the document.\n", "example": "Laboratory reports and results." }, "operation": { "type": "string", "description": "Operation applied to pages assigned this classification. group keeps the pages and labels resources extracted from them with this id. drop removes the pages before extraction.\n", "enum": [ "group", "drop" ], "example": "group" } } } }, "resource_review": { "type": "object", "description": "Faithfulness audit of the generated resources (honored by /lang2fhir/create/multi and /lang2fhir/document/multi). When resource_review is omitted, the audit runs with these default targets: Encounter checks dates; Procedure and DiagnosticReport check dates and codes; Observation, Condition, and MedicationRequest check codes. Supplying resource_review replaces the defaults with the listed targets; an empty targets list turns the audit off. For each selected resource type an LLM checks whether selected dates and clinical code concepts are actually supported by the full source document. An unsupported individual coding is removed when another coding remains in its concept. Resources with an unsupported structural field, a profile-required coding, or no coding remaining in an affected concept, are pulled out of the returned bundle and reported under resource_review in the response. Encounters, and diagnostic reports built from the source's report dates, are never pulled out, because other resources in the bundle reference them: an unsupported field is removed from them when their profile does not require it, and kept and reported when it does.\n", "required": [ "targets" ], "properties": { "targets": { "type": "array", "maxItems": 25, "description": "The resource types to audit and which date or clinical code field kinds to check. An empty list turns the audit off.\n", "items": { "type": "object", "required": [ "resource_type" ], "properties": { "resource_type": { "type": "string", "description": "FHIR resourceType to audit (e.g. Condition, Procedure, Observation, Encounter, MedicationRequest), matched against each generated resource's resourceType. Patient is not supported.\n", "example": "Condition" }, "fields": { "type": "array", "description": "Field kinds to check for this resource type. Defaults to [\"dates\"] when omitted; use \"codes\" to audit clinical code concepts.", "items": { "type": "string", "enum": [ "dates", "codes" ] }, "example": [ "dates", "codes" ] } } } } } } } } } } ``` **Example:** ```json { "version": "R4", "resource": "questionnaire", "content": "JVBERi0xLjQKJeLjz9MK...(base64-encoded document bytes)" } ``` #### Responses **200** - Successfully created FHIR resource from document Content-Type: `application/json` ```json { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ``` **Example:** ```json { "resourceType": "Questionnaire", "status": "active", "title": "Patient Intake Form", "item": [ { "linkId": "1", "text": "What is your name?", "type": "string" }, { "linkId": "2", "text": "What is your date of birth?", "type": "date" } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - TIFF, RTF, and XML/C-CDA uploads are only available on dedicated instances **404** - Profile not found **422** - Document could not be processed, or the generated resource failed validation or terminology constraints **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/document/multi **Extract multiple FHIR resources from a document** Extracts text from a PDF, image, RTF, or XML/C-CDA document and converts it into multiple FHIR resources, returned as a transaction Bundle. Combines document text extraction with multi-resource detection. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types. Resources are linked with proper references (e.g., Conditions reference the Patient). The complete JSON request body is limited to 32 MiB (33,554,432 bytes). The application enforces this whole-envelope limit, including base64-encoded document `content`. **Patient handling.** Every bundle contains exactly one Patient, and every clinical resource references it. When the document names its patient, the Patient is built from the document. When it names several patients, the Patient is the one `primary_patient` names, otherwise the one most of the document is about; the others are not represented as Patients. Otherwise it is built from `primary_patient` when supplied, or is an unidentified Patient carrying only a synthetic identifier. When the document names its patient, the `primary_patient` identifier is added to that Patient unless its name, birth date, or gender contradicts the document's; the response `message` says whether it was added or did not match. **Patient identifier handling.** US Core requires `Patient.identifier` (a business identifier such as an MRN). Every Patient carries a synthetic identifier with `system: "urn:phenoml:lang2fhir-generated-id"` and a UUID `value`, so the bundle remains FHIR-valid and US Core conformant. A medical record number stated in the document is added with `system: "urn:phenoml:lang2fhir-document-mrn"`, and the `primary_patient` identifier is added as described above. Callers who need a tenant-specific namespace should rewrite these systems after extraction. **Page classification (optional).** By default, every page with extracted text is used for extraction, and the response omits `page_classifications`. To classify pages so they can be grouped or dropped before extraction, set `config.split_classifications`. An empty list is the same as omitting it. `split_classifications` is a list of up to 20 classifications that you define; there is no fixed taxonomy. Each classification has: - `id`: your label for the classification. Ids must be non-blank, unique, up to 64 characters, and must not be the reserved value `__ungrouped__`. - `description`: a non-blank description, up to 500 characters, of the pages that belong to the classification. Each page's text is compared against these descriptions, so describe what sets those pages apart from the rest of the document. - `operation`: `group` keeps matching pages and labels the resources extracted from them; `drop` removes matching pages before extraction. Each page is classified on its own text and assigned at most one classification. A page that does not clearly match any classification is left ungrouped. Ungrouped pages are kept, but resources extracted only from ungrouped pages are not labeled. A page that cannot be classified, for example because classification failed temporarily, is also kept and left ungrouped. A resource's label comes from its `resources[].sourcePages`. When those pages include `group` pages, the resource carries the classification `id` in `resources[].group` and as a `meta.tag` with `system: "https://phenoml.com/fhir/split-classification"`. When its source pages span more than one group, it takes the group that covers the most of them; ties go to the group with the earliest source page. Resources without `sourcePages` are not labeled. The response's `page_classifications` reports the decision for every page, kept or dropped. When every page is dropped, the response has `success: false`, a `message`, and `page_classifications`, with `bundle` and `resources` set to null. For example, the `clinical` and `admin` classifications in the request example keep and label clinical pages and drop administrative pages. To skip lab or diagnostic order forms, add a `drop` classification that describes them. **Operation ID:** `lang2fhir_documentMulti` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "version", "content" ], "properties": { "version": { "type": "string", "description": "FHIR version to use", "example": "R4" }, "content": { "type": "string", "description": "Base64 encoded file content.\nSupported file types: PDF (application/pdf), PNG (image/png), JPEG (image/jpeg), TIFF (image/tiff), RTF (application/rtf), XML/C-CDA (text/xml).\nTIFF, RTF, and XML/C-CDA uploads are available on dedicated instances only.\nFile type is auto-detected from content magic bytes.\nThe decoded file must not exceed 20 MiB. RTF and XML/C-CDA documents whose extracted text exceeds 1 MiB are rejected.\nGeneric XML must include an XML declaration; C-CDA documents rooted at `ClinicalDocument` may omit it.\n" }, "provider": { "type": "string", "description": "Optional FHIR provider name for provider-specific profiles", "example": "canvas" }, "primary_patient": { "allOf": [ { "type": "object", "minProperties": 1, "description": "Partial context for the patient the source is primarily about. This is not a complete FHIR Patient resource. When the source does not name its patient, the bundle's Patient is built from exactly these fields. When it does, the identifier supplied here is added to that Patient unless its name, birth date, or gender contradicts these fields, so the bundle can be matched back to the caller's own record.\n", "properties": { "identifier": { "type": "object", "description": "Business identifier for the primary patient. The bundle's Patient carries this identifier alongside its synthetic one, unless the Patient found in the source contradicts primary_patient. Supply the patient-level identifier (not an order or specimen identifier).\n", "required": [ "system", "value" ], "properties": { "system": { "type": "string", "description": "Identifier system (namespace) for the patient identifier.", "example": "urn:acmehealth:patient_index_id" }, "value": { "type": "string", "description": "Identifier value for the patient within that system." } }, "example": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" } }, "name": { "type": "object", "description": "The known portions of the primary patient's name. Provide a non-empty family name or at least one non-empty given name.\n", "properties": { "family": { "type": "string", "description": "Family name.", "example": "Smith" }, "given": { "type": "array", "description": "Given names.", "items": { "type": "string" }, "example": [ "Jane" ] } } }, "birthDate": { "type": "string", "format": "date", "description": "Complete date of birth in YYYY-MM-DD format.", "example": "1980-03-12" }, "gender": { "type": "string", "enum": [ "male", "female", "other", "unknown" ], "description": "Administrative gender.", "example": "female" } }, "example": { "identifier": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" }, "name": { "family": "Smith", "given": [ "Jane" ] }, "birthDate": "1980-03-12", "gender": "female" } } ], "description": "Context for the patient the document is primarily about. When the document does not name its patient, the bundle's Patient is built from these fields. When it does, the identifier is added to that Patient unless its name, birth date, or gender contradicts these fields.\n" }, "patient_reference": { "deprecated": true, "description": "Deprecated compatibility alias for primary_patient.identifier. Cannot be combined with primary_patient.", "type": "object", "required": [ "system", "value" ], "properties": { "system": { "type": "string", "description": "Identifier system (namespace) for the patient identifier.", "example": "urn:acmehealth:patient_index_id" }, "value": { "type": "string", "description": "Identifier value for the patient within that system." } }, "example": { "system": "urn:acmehealth:patient_index_id", "value": "abc-123" } }, "implementation_guide": { "type": "string", "description": "Implementation Guide to generate resources under. `us_core` (the default) and `phenoml_hpo` select a built-in guide. Any other value is a custom Implementation Guide name: its profiles are included alongside the US Core profiles, which are always the base layer. A custom name that matches no uploaded Implementation Guide returns 404.\n", "default": "us_core", "example": "acme-cardiology" }, "detection_effort": { "type": "string", "deprecated": true, "description": "Deprecated and ignored: both values produce the same result. This field will be removed in a future release.", "enum": [ "standard", "deep" ], "default": "standard" }, "validation_method": { "type": "string", "description": "FHIR validation method to apply to the generated bundle. 'none' skips validation (default). 'check' runs the bundle through a FHIR structure validator and includes the results in the response. 'fix' runs validation and attempts to auto-correct errors using an LLM (up to 3 validation passes). The response includes results from each pass. Warning: 'fix' can significantly increase latency due to multiple LLM and validation round-trips.\n", "enum": [ "none", "check", "fix" ], "default": "none" }, "config": { "type": "object", "description": "Optional processing configuration shared across document endpoints.", "properties": { "split_classifications": { "type": "array", "maxItems": 20, "description": "Optional per-page classifications, applied before extraction; accepts up to 20 classifications. When omitted or empty, every page with extracted text is used. This is a caller-defined list, not a fixed taxonomy: choose each classification id and describe the pages that belong to it. Each page is assigned at most one classification; a page that does not clearly match any, or that cannot be classified, is kept and left ungrouped. Pages matching a drop classification are removed before extraction. Pages matching a group classification are kept; on /lang2fhir/document/multi, resources extracted from them include the classification id in resources[].group and as a FHIR meta.tag. When every page is dropped, /lang2fhir/document returns 422 and /lang2fhir/document/multi returns success false with page_classifications. Example ids such as clinical and admin are illustrative, not a fixed set.\n", "items": { "type": "object", "title": "SplitClassification", "description": "One caller-defined page classification and the operation to apply when it matches.", "required": [ "id", "description", "operation" ], "properties": { "id": { "type": "string", "maxLength": 64, "description": "Unique, non-blank classification id. Returned as page_classifications[].classification_id and, for group classifications, as resources[].group and the FHIR meta.tag code. The reserved id \"__ungrouped__\" is not allowed.\n", "example": "labs" }, "description": { "type": "string", "maxLength": 500, "description": "Non-blank natural-language description of the pages that belong to this classification. Each page's text is compared against these descriptions, so describe what distinguishes these pages from the rest of the document.\n", "example": "Laboratory reports and results." }, "operation": { "type": "string", "description": "Operation applied to pages assigned this classification. group keeps the pages and labels resources extracted from them with this id. drop removes the pages before extraction.\n", "enum": [ "group", "drop" ], "example": "group" } } } }, "resource_review": { "type": "object", "description": "Faithfulness audit of the generated resources (honored by /lang2fhir/create/multi and /lang2fhir/document/multi). When resource_review is omitted, the audit runs with these default targets: Encounter checks dates; Procedure and DiagnosticReport check dates and codes; Observation, Condition, and MedicationRequest check codes. Supplying resource_review replaces the defaults with the listed targets; an empty targets list turns the audit off. For each selected resource type an LLM checks whether selected dates and clinical code concepts are actually supported by the full source document. An unsupported individual coding is removed when another coding remains in its concept. Resources with an unsupported structural field, a profile-required coding, or no coding remaining in an affected concept, are pulled out of the returned bundle and reported under resource_review in the response. Encounters, and diagnostic reports built from the source's report dates, are never pulled out, because other resources in the bundle reference them: an unsupported field is removed from them when their profile does not require it, and kept and reported when it does.\n", "required": [ "targets" ], "properties": { "targets": { "type": "array", "maxItems": 25, "description": "The resource types to audit and which date or clinical code field kinds to check. An empty list turns the audit off.\n", "items": { "type": "object", "required": [ "resource_type" ], "properties": { "resource_type": { "type": "string", "description": "FHIR resourceType to audit (e.g. Condition, Procedure, Observation, Encounter, MedicationRequest), matched against each generated resource's resourceType. Patient is not supported.\n", "example": "Condition" }, "fields": { "type": "array", "description": "Field kinds to check for this resource type. Defaults to [\"dates\"] when omitted; use \"codes\" to audit clinical code concepts.", "items": { "type": "string", "enum": [ "dates", "codes" ] }, "example": [ "dates", "codes" ] } } } } } } } } } } ``` **Example:** ```json { "version": "R4", "content": "JVBERi0xLjQKJeLjz9MK...(base64-encoded document bytes)", "provider": "medplum", "config": { "split_classifications": [ { "id": "clinical", "description": "Clinical notes, diagnoses, medications, observations, and patient demographics.", "operation": "group" }, { "id": "admin", "description": "Administrative boilerplate, insurance forms, and cover sheets.", "operation": "drop" } ] } } ``` #### Responses **200** - Successfully extracted FHIR resources from document Content-Type: `application/json` ```json { "allOf": [ { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether extraction was successful", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Successfully extracted 3 resources" }, "bundle": { "type": "object", "description": "FHIR transaction Bundle containing all extracted resources", "properties": { "resourceType": { "type": "string", "example": "Bundle" }, "type": { "type": "string", "example": "transaction" }, "entry": { "type": "array", "items": { "type": "object", "properties": { "fullUrl": { "type": "string", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resource": { "type": "object" }, "request": { "type": "object", "properties": { "method": { "type": "string", "example": "POST" }, "url": { "type": "string", "example": "Patient" } } } } } } } }, "resources": { "type": "array", "description": "Summary of extracted resources", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "Temporary UUID for the resource", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "description": "FHIR resource type", "example": "Patient" }, "description": { "type": "string", "description": "Context-enriched rewritten text excerpt for this resource", "example": "John Smith (DOB 1980-05-12) was diagnosed with Type 2 Diabetes during office visit on 2025-03-01 with Dr. Chen" }, "originalText": { "type": "string", "description": "Verbatim text excerpt from the original clinical document", "example": "diagnosed with Type 2 Diabetes" }, "group": { "type": "string", "description": "Split classification id assigned to this resource by the /lang2fhir/document/multi endpoint. When the resource came from pages in more than one group, this is the group covering the most of its source pages, with ties going to the group with the earliest source page. Omitted when the resource came only from ungrouped pages, when its sourcePages is omitted, or for raw-text create/multi.\n", "example": "clinical" }, "sourcePages": { "type": "array", "items": { "type": "integer" }, "description": "1-indexed source document page number(s) this resource was extracted from. Populated only by the /lang2fhir/document/multi endpoint; omitted when the source page could not be determined (e.g. raw-text create/multi, or a resource with no verbatim source text).\n", "example": [ 2 ] } } } }, "validation": { "type": "object", "nullable": true, "description": "FHIR validation results. Present when validation_method is 'check' or 'fix'. Contains results from each validation pass. For 'check', there is one pass. For 'fix', there may be up to 3 passes as the system attempts auto-correction.\n", "properties": { "passes": { "type": "array", "description": "Results from each validation pass, in chronological order", "items": { "type": "object", "properties": { "issues": { "type": "array", "description": "Validation issues found in this pass", "items": { "type": "object", "properties": { "severity": { "type": "string", "description": "Issue severity level", "enum": [ "fatal", "error", "warning", "information" ] }, "code": { "type": "string", "description": "Issue type code" }, "diagnostics": { "type": "string", "description": "Human-readable description of the issue" }, "expression": { "type": "array", "items": { "type": "string" }, "description": "FHIRPath expression(s) pointing to the issue location" }, "source": { "type": "string", "description": "Validation phase that generated this issue" } } } }, "stats": { "type": "object", "nullable": true, "description": "Validation statistics for this pass", "properties": { "resource_type": { "type": "string" }, "profile_url": { "type": "string" }, "is_custom_profile": { "type": "boolean" }, "duration_ms": { "type": "number", "description": "Validation duration in milliseconds" } } } } } }, "fixed": { "type": "boolean", "description": "Whether validation errors were successfully fixed by the LLM. Always false for 'check' mode. For 'fix' mode, true if errors were resolved and the returned bundle is the corrected version.\n" }, "attempts": { "type": "integer", "description": "Total number of validation passes run (1 for check, 1-3 for fix)" }, "summary": { "type": "string", "description": "Human-readable summary of the validation outcome" } } }, "resource_review": { "type": "object", "description": "Present when the resource review ran and at least one resource was quarantined, safely remediated, or kept with an unsupported required field. The returned bundle is authoritative and contains the post-review representation of every retained resource.\n", "properties": { "flagged": { "type": "array", "description": "Resources pulled from the bundle because an unsupported finding could not be safely repaired.", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "The urn:uuid of the flagged resource (its former bundle fullUrl).", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "example": "Condition" }, "resource": { "type": "object", "description": "The full generated FHIR resource that was pulled from the bundle." }, "findings": { "type": "array", "description": "The findings that caused the resource to be quarantined.", "items": { "type": "object", "properties": { "fieldKind": { "type": "string", "enum": [ "dates", "codes" ], "example": "dates" }, "fieldPath": { "type": "string", "description": "JSON path of the field within the resource.", "example": "onsetDateTime" }, "value": { "type": "string", "example": "2024-01-15" }, "supported": { "type": "boolean", "description": "False when the reviewer found the field unsupported. Do not treat this field as a verdict when unaudited is true.", "example": false }, "unaudited": { "type": "boolean", "description": "True when the reviewer did not return a verdict for this field; the resource was quarantined without treating the finding as evidence that the value is unsupported.", "example": true }, "rationale": { "type": "string", "description": "Short explanation of why the value is not supported by the source.", "example": "Date is the visit date, not when the condition began." } } } } } } }, "remediated": { "type": "array", "description": "Resources retained in the bundle after review: unsupported codings or fields were safely removed, or unsupported required fields were kept and are reported here (see action).\n", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "The urn:uuid of the remediated resource (its bundle fullUrl).", "example": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8" }, "resourceType": { "type": "string", "example": "Condition" }, "action": { "type": "string", "enum": [ "removed_codings", "removed_fields", "flagged_required" ], "description": "What review did to the resource in the returned bundle: removed_codings removed unsupported codings while each affected concept kept one; removed_fields removed unsupported fields its profile does not require; flagged_required kept unsupported fields its profile requires, so the findings report values that remain in the bundle.\n" }, "findings": { "type": "array", "description": "Findings for fields in the pre-remediation resource that caused this action.", "items": { "type": "object", "properties": { "fieldKind": { "type": "string", "enum": [ "dates", "codes" ], "example": "dates" }, "fieldPath": { "type": "string", "description": "JSON path of the field within the resource.", "example": "onsetDateTime" }, "value": { "type": "string", "example": "2024-01-15" }, "supported": { "type": "boolean", "description": "False when the reviewer found the field unsupported. Do not treat this field as a verdict when unaudited is true.", "example": false }, "unaudited": { "type": "boolean", "description": "True when the reviewer did not return a verdict for this field; the resource was quarantined without treating the finding as evidence that the value is unsupported.", "example": true }, "rationale": { "type": "string", "description": "Short explanation of why the value is not supported by the source.", "example": "Date is the visit date, not when the condition began." } } } } } } } } } } }, { "type": "object", "properties": { "page_classifications": { "type": "array", "description": "Per-page classifier decisions, one entry per input page, kept and dropped. Returned only when config sets a non-empty split_classifications.\n", "items": { "type": "object", "description": "The classifier's decision for a single page of the input document.", "properties": { "page_number": { "type": "integer", "description": "1-indexed page number.", "example": 1 }, "include": { "type": "boolean", "description": "Whether the page was kept (true) or dropped (false) from FHIR extraction. Pages that could not be classified are kept.", "example": true }, "classification_id": { "type": "string", "description": "Split classification id assigned to the page. Omitted for ungrouped pages, including pages that could not be classified.\n", "example": "clinical" }, "reason": { "type": "string", "description": "Short LLM-generated explanation of the decision. When the page could not be classified, says that the classifier was unavailable.\n", "example": "clinical notes with diagnoses" } } } } } } ] } ``` **Example:** ```json { "success": true, "message": "Successfully extracted 3 resources", "bundle": { "resourceType": "Bundle", "type": "transaction", "entry": [ { "fullUrl": "urn:uuid:patient-001", "resource": { "resourceType": "Patient", "meta": { "tag": [ { "system": "https://phenoml.com/fhir/split-classification", "code": "clinical" } ] }, "name": [ { "given": [ "John" ], "family": "Doe" } ], "gender": "male", "birthDate": "1979-03-15" }, "request": { "method": "POST", "url": "Patient" } }, { "fullUrl": "urn:uuid:condition-001", "resource": { "resourceType": "Condition", "meta": { "tag": [ { "system": "https://phenoml.com/fhir/split-classification", "code": "clinical" } ] }, "code": { "text": "Type 2 Diabetes Mellitus" }, "subject": { "reference": "urn:uuid:patient-001" } }, "request": { "method": "POST", "url": "Condition" } }, { "fullUrl": "urn:uuid:medication-001", "resource": { "resourceType": "MedicationRequest", "meta": { "tag": [ { "system": "https://phenoml.com/fhir/split-classification", "code": "clinical" } ] }, "medicationCodeableConcept": { "text": "Metformin 500mg" }, "subject": { "reference": "urn:uuid:patient-001" } }, "request": { "method": "POST", "url": "MedicationRequest" } } ] }, "resources": [ { "tempId": "urn:uuid:patient-001", "resourceType": "Patient", "description": "John Doe, born 1979-03-15", "originalText": "John Doe, DOB 1979-03-15", "group": "clinical", "sourcePages": [ 1 ] }, { "tempId": "urn:uuid:condition-001", "resourceType": "Condition", "description": "Type 2 Diabetes Mellitus diagnosis", "originalText": "diagnosed with Type 2 Diabetes", "group": "clinical", "sourcePages": [ 1 ] }, { "tempId": "urn:uuid:medication-001", "resourceType": "MedicationRequest", "description": "Metformin 500mg prescription", "originalText": "Prescribed Metformin 500mg", "group": "clinical", "sourcePages": [ 2 ] } ], "page_classifications": [ { "page_number": 1, "include": true, "classification_id": "clinical", "reason": "clinical demographics and diagnosis" }, { "page_number": 2, "include": true, "classification_id": "clinical", "reason": "clinical medication details" }, { "page_number": 3, "include": false, "classification_id": "admin", "reason": "administrative cover sheet" } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - TIFF, RTF, and XML/C-CDA uploads are only available on dedicated instances **404** - Profile or implementation guide not found **422** - Document could not be processed or generated resource failed validation **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /lang2fhir/profile/upload > **Deprecated** **Upload custom FHIR profile (deprecated)** **Deprecated — use `POST /fhir/profiles` instead.** This route continues to work and operates on the same custom profiles, so no migration is required; it will be removed in a future release. Note that `POST /fhir/profiles` does not accept `profile_context`; set implementation-guide context with `PUT /fhir/implementation-guides/{name}`. Upload a custom FHIR StructureDefinition profile for use with the lang2fhir service. All metadata is derived from the StructureDefinition JSON itself. The lowercase `id` field from the StructureDefinition is used as the profile's unique identifier and lookup key. To use the uploaded profile with `/lang2fhir/create`, pass this id as the `resource` parameter. Uploads will be rejected if: - A built-in profile (US Core, PhenoML HPO, or R4 base) already exists with the same id, or the id starts with a reserved prefix (`us-core-`, `phenoml-hpo-`) - A custom profile with the same id has already been uploaded - A custom profile with the same url has already been uploaded **Operation ID:** `lang2fhir_uploadProfile` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "profile" ], "properties": { "profile": { "type": "string", "description": "Base64 encoded JSON string of a FHIR StructureDefinition. The profile must include id, url, type, and a snapshot with elements. All metadata (version, resource type, identifier) is derived from the StructureDefinition itself. The lowercase id from the StructureDefinition becomes the profile's lookup key.\n", "example": "(base64 encoded FHIR StructureDefinition JSON)" }, "implementation_guide": { "type": "string", "description": "Implementation Guide name to group this profile under. Defaults to \"custom\" if omitted. Cannot be \"us_core\" or \"phenoml_hpo\" (reserved). Use this to organize custom profiles into named IGs that can be referenced when calling create/multi or document/multi endpoints.\n", "example": "acme-cardiology" }, "profile_context": { "type": "string", "maxLength": 2000, "description": "Natural language context that helps the LLM select the right profiles from this implementation guide during resource detection. For example, \"When the text mentions phenotypic features or abnormalities, prefer the hpo-observation profile over Condition.\" This is stored as IG-level metadata and injected into the LLM prompt. Max 2000 characters. Providing this field on any upload will update the context for the entire IG (last write wins).\n", "example": "When clinical text describes phenotypic features, abnormalities, or findings that map to HPO terms, use the hpo-phenotype-observation profile instead of Condition." } } } ``` **Example:** ```json { "profile": "eyJyZXNvdXJjZVR5cGUiOiJTdHJ1Y3R1cmVEZWZpbml0aW9uIiwiaWQiOiJjdXN0b20tcGF0aWVudCIsInVybCI6Imh0dHA6Ly9waGVub21sLmNvbS9maGlyL1N0cnVjdHVyZURlZmluaXRpb24vY3VzdG9tLXBhdGllbnQiLCJuYW1lIjoiQ3VzdG9tUGF0aWVudCIsInN0YXR1cyI6ImFjdGl2ZSIsImZoaXJWZXJzaW9uIjoiNC4wLjEiLCJraW5kIjoicmVzb3VyY2UiLCJhYnN0cmFjdCI6ZmFsc2UsInR5cGUiOiJQYXRpZW50IiwiYmFzZURlZmluaXRpb24iOiJodHRwOi8vaGw3Lm9yZy9maGlyL1N0cnVjdHVyZURlZmluaXRpb24vUGF0aWVudCIsImRlcml2YXRpb24iOiJjb25zdHJhaW50Iiwic25hcHNob3QiOnsiZWxlbWVudCI6W3siaWQiOiJQYXRpZW50IiwicGF0aCI6IlBhdGllbnQiLCJtaW4iOjAsIm1heCI6IioifSx7ImlkIjoiUGF0aWVudC5uYW1lIiwicGF0aCI6IlBhdGllbnQubmFtZSIsIm1pbiI6MSwibWF4IjoiKiJ9XX19Cg==", "implementation_guide": "acme-cardiology", "profile_context": "When clinical text describes cardiology-specific findings, prefer this profile over the generic US Core Condition." } ``` #### Responses **201** - Profile successfully uploaded Content-Type: `application/json` ```json { "type": "object", "properties": { "message": { "type": "string", "example": "Profile uploaded successfully" }, "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's unique identifier and lookup key. Pass this value as the `resource` parameter to `/lang2fhir/create` or `/lang2fhir/profile/json/:version/:resource` to use this profile.\n", "example": "custom-patient" }, "type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" } } } ``` **Example:** ```json { "message": "Profile uploaded successfully", "id": "custom-patient", "type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient" } ``` **400** - Invalid request or profile validation failed. Possible reasons: - Missing or invalid StructureDefinition JSON - Missing required fields (id, url, type, snapshot with elements) - A built-in profile (US Core, PhenoML HPO, or R4 base) exists with the same id, or the id starts with a reserved prefix (`us-core-`, `phenoml-hpo-`) - A custom profile with the same id or url already exists **401** - Unauthorized **403** - Forbidden - profile upload is only available on dedicated instances **500** - Server error --- ### POST /lang2fhir/search **Generate FHIR search parameters from text** Converts natural language text into FHIR search parameters. Automatically identifies the appropriate FHIR resource type and generates valid search query parameters. Supported resource types include: AllergyIntolerance, Appointment, CarePlan, CareTeam, Condition, Coverage, Device, DiagnosticReport, DocumentReference, Encounter, Goal, Immunization, Location, Medication, MedicationRequest, Observation, Organization, Patient, PlanDefinition, Practitioner, PractitionerRole, Procedure, Provenance, Questionnaire, QuestionnaireResponse, RelatedPerson, Schedule, ServiceRequest, Slot, and Specimen. **Operation ID:** `lang2fhir_search` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text" ], "properties": { "text": { "type": "string", "description": "Natural language text to convert into FHIR search parameters.\nThe system will automatically identify the appropriate resource type and generate valid search parameters.\n\nExamples:\n- \"Appointments between March 2-9, 2025\" → Appointment search with date range\n- \"Patients with diabetes\" → Condition search with code parameter\n- \"Active medication requests for metformin\" → MedicationRequest search\n- \"Lab results for creatinine\" → DiagnosticReport search\n- \"Dr. Smith's schedule\" → Practitioner or Schedule search\n", "example": "Appointments between March 2-9, 2025" } } } ``` **Example:** ```json { "text": "Appointments between March 2-9, 2025" } ``` #### Responses **200** - Successfully generated FHIR search parameters Content-Type: `application/json` ```json { "type": "object", "properties": { "resource_type": { "type": "string", "description": "The FHIR resource type identified for the search", "enum": [ "AllergyIntolerance", "Appointment", "CarePlan", "CareTeam", "Condition", "Coverage", "Device", "DiagnosticReport", "DocumentReference", "Encounter", "Goal", "Immunization", "Location", "Medication", "MedicationRequest", "Observation", "Organization", "Patient", "PlanDefinition", "Practitioner", "PractitionerRole", "Procedure", "Provenance", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "Schedule", "ServiceRequest", "Slot", "Specimen" ], "example": "Appointment" }, "search_params": { "type": "string", "description": "FHIR search parameters in standard query string format.\nParameters are formatted according to the FHIR specification with appropriate operators.\nCode parameters are resolved to standard terminology codes (SNOMED CT, LOINC, RxNorm, ICD-10-CM).\n", "example": "date=ge2025-03-02&date=le2025-03-09" } } } ``` **Example:** ```json { "resource_type": "Appointment", "search_params": "date=ge2025-03-02&date=le2025-03-09" } ``` **400** - Invalid request **401** - Unauthorized **500** - Server error --- # FHIR Artifacts Manage custom FHIR artifacts on a dedicated instance — StructureDefinition profiles and the implementation guides that group them — used by Lang2FHIR extraction and other FHIR capabilities. ## FHIR Artifacts / Implementation Guides Manage implementation guides that group custom FHIR profiles. ### GET /fhir/implementation-guides **List implementation guides** Returns every implementation guide on this instance — both guides that have stored metadata (a profile_context) and guides referenced by at least one custom profile — with the number of profiles in each. **Operation ID:** `implementation-guides_list` #### Responses **200** - List of implementation guides Content-Type: `application/json` ```json { "type": "object", "properties": { "implementation_guides": { "type": "array", "items": { "type": "object", "description": "Metadata for an implementation guide. Canonical fields are present only for published canonical packages; guides without a published package omit them.\n", "properties": { "name": { "type": "string", "description": "The instance-local implementation guide name (the stable key).", "example": "acme-cardiology" }, "profile_context": { "type": "string", "description": "Natural-language context injected into the LLM during resource detection.", "example": "When the text mentions phenotypic features, prefer the hpo-observation profile over Condition." }, "profile_count": { "type": "integer", "description": "The number of custom profiles in this implementation guide.", "example": 3 }, "canonical_url": { "type": "string", "description": "Canonical FHIR ImplementationGuide URL, when the family has an exact package." }, "version_count": { "type": "integer", "description": "Number of retained exact package versions." }, "created_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata (a profile_context has been set). Omitted for guides that exist solely because a profile references them.\n" }, "updated_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata. Omitted for guides that exist solely because a profile references them.\n" } } } } } } ``` **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **500** - Server error --- ### GET /fhir/implementation-guides/{name} **Get an implementation guide** Returns a single implementation guide, including its profile_context and the ids of the profiles that belong to it. **Operation ID:** `implementation-guides_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `name` | path | string | Yes | The implementation guide name. | #### Responses **200** - The requested implementation guide Content-Type: `application/json` ```json { "allOf": [ { "type": "object", "description": "Metadata for an implementation guide. Canonical fields are present only for published canonical packages; guides without a published package omit them.\n", "properties": { "name": { "type": "string", "description": "The instance-local implementation guide name (the stable key).", "example": "acme-cardiology" }, "profile_context": { "type": "string", "description": "Natural-language context injected into the LLM during resource detection.", "example": "When the text mentions phenotypic features, prefer the hpo-observation profile over Condition." }, "profile_count": { "type": "integer", "description": "The number of custom profiles in this implementation guide.", "example": 3 }, "canonical_url": { "type": "string", "description": "Canonical FHIR ImplementationGuide URL, when the family has an exact package." }, "version_count": { "type": "integer", "description": "Number of retained exact package versions." }, "created_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata (a profile_context has been set). Omitted for guides that exist solely because a profile references them.\n" }, "updated_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata. Omitted for guides that exist solely because a profile references them.\n" } } }, { "type": "object", "properties": { "profiles": { "type": "array", "description": "The ids of the profiles that belong to this implementation guide.", "items": { "type": "string" }, "example": [ "custom-patient", "acme-vital-signs" ] } } } ] } ``` **400** - The name is reserved or malformed **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Implementation guide not found **500** - Server error --- ### PUT /fhir/implementation-guides/{name} **Set an implementation guide's profile context** Sets (or clears, with an empty value) the natural-language profile_context for an implementation guide. The context is injected into the LLM during resource detection to help select the right profiles from this guide. It applies to every profile in the guide. **Operation ID:** `implementation-guides_update` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `name` | path | string | Yes | The implementation guide name. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "properties": { "profile_context": { "type": "string", "maxLength": 2000, "description": "Natural-language context that helps the LLM select the right profiles from this implementation guide during resource detection. An empty value clears the context. Max 2000 characters.\n", "example": "When clinical text describes phenotypic features, use the hpo-phenotype-observation profile instead of Condition." } } } ``` #### Responses **200** - Implementation guide successfully updated Content-Type: `application/json` ```json { "type": "object", "description": "Metadata for an implementation guide. Canonical fields are present only for published canonical packages; guides without a published package omit them.\n", "properties": { "name": { "type": "string", "description": "The instance-local implementation guide name (the stable key).", "example": "acme-cardiology" }, "profile_context": { "type": "string", "description": "Natural-language context injected into the LLM during resource detection.", "example": "When the text mentions phenotypic features, prefer the hpo-observation profile over Condition." }, "profile_count": { "type": "integer", "description": "The number of custom profiles in this implementation guide.", "example": 3 }, "canonical_url": { "type": "string", "description": "Canonical FHIR ImplementationGuide URL, when the family has an exact package." }, "version_count": { "type": "integer", "description": "Number of retained exact package versions." }, "created_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata (a profile_context has been set). Omitted for guides that exist solely because a profile references them.\n" }, "updated_at": { "type": "string", "format": "date-time", "description": "Present only for guides that have stored metadata. Omitted for guides that exist solely because a profile references them.\n" } } } ``` **400** - Invalid implementation guide name or profile_context too long **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **500** - Server error --- ### DELETE /fhir/implementation-guides/{name} **Delete an implementation guide family** Deletes the guide's metadata and all its canonical package versions. Custom profiles and their implementation-guide assignments are preserved. **Operation ID:** `implementation-guides_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `name` | path | string | Yes | The implementation guide name. | #### Responses **204** - Implementation guide family successfully deleted **400** - The name is reserved or malformed **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - No implementation guide family exists for this name **500** - Server error --- ### POST /fhir/implementation-guides/{name}/versions **Publish an exact custom-profile package** Publishes an exact package beneath this guide family. Each guide family supports one exact package version. Publishing another version returns `409 Conflict`. **Operation ID:** `implementation-guides_createVersion` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `name` | path | string | Yes | | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "implementation_guide", "profile_refs" ], "properties": { "implementation_guide": { "type": "object", "description": "A complete authored FHIR ImplementationGuide JSON resource.", "required": [ "resourceType", "url", "version" ], "additionalProperties": true, "properties": { "resourceType": { "type": "string", "enum": [ "ImplementationGuide" ] }, "id": { "type": "string" }, "url": { "type": "string" }, "version": { "type": "string" }, "name": { "type": "string" }, "status": { "type": "string" }, "packageId": { "type": "string" }, "fhirVersion": { "type": "array", "items": { "type": "string" } } } }, "profile_refs": { "type": "array", "minItems": 1, "maxItems": 250, "description": "Exact canonical `url|version` references to builtin or custom profiles. A package can contain at most 250 references.\n", "items": { "type": "string" } }, "profile_context": { "type": "string", "maxLength": 2000, "description": "Natural-language profile-selection context for this package." } } } ``` #### Responses **201** - Canonical package published Content-Type: `application/json` ```json { "type": "object", "required": [ "name", "url", "version", "profile_context", "profiles", "profile_refs", "implementation_guide", "created_at", "updated_at" ], "properties": { "name": { "type": "string" }, "url": { "type": "string" }, "version": { "type": "string" }, "profile_context": { "type": "string" }, "profiles": { "type": "array", "items": { "type": "string" } }, "profile_refs": { "type": "array", "items": { "type": "string" } }, "implementation_guide": { "type": "object", "description": "A complete authored FHIR ImplementationGuide JSON resource.", "required": [ "resourceType", "url", "version" ], "additionalProperties": true, "properties": { "resourceType": { "type": "string", "enum": [ "ImplementationGuide" ] }, "id": { "type": "string" }, "url": { "type": "string" }, "version": { "type": "string" }, "name": { "type": "string" }, "status": { "type": "string" }, "packageId": { "type": "string" }, "fhirVersion": { "type": "array", "items": { "type": "string" } } } }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } ``` **400** - Invalid ImplementationGuide, profile reference, version, or context **404** - An exact profile reference was not found **409** - The guide family already has a package version, or the canonical URL belongs to another guide family --- ### GET /fhir/implementation-guides/{name}/versions/{version} **Get an exact custom-profile package** **Operation ID:** `implementation-guides_getVersion` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `name` | path | string | Yes | | | `version` | path | string | Yes | The authored ImplementationGuide.version. It may contain letters, numbers, and the punctuation characters `.`, `_`, `~`, `+`, and `-`; it cannot be exactly `.` or `..`. | #### Responses **200** - Exact canonical package Content-Type: `application/json` ```json { "type": "object", "required": [ "name", "url", "version", "profile_context", "profiles", "profile_refs", "implementation_guide", "created_at", "updated_at" ], "properties": { "name": { "type": "string" }, "url": { "type": "string" }, "version": { "type": "string" }, "profile_context": { "type": "string" }, "profiles": { "type": "array", "items": { "type": "string" } }, "profile_refs": { "type": "array", "items": { "type": "string" } }, "implementation_guide": { "type": "object", "description": "A complete authored FHIR ImplementationGuide JSON resource.", "required": [ "resourceType", "url", "version" ], "additionalProperties": true, "properties": { "resourceType": { "type": "string", "enum": [ "ImplementationGuide" ] }, "id": { "type": "string" }, "url": { "type": "string" }, "version": { "type": "string" }, "name": { "type": "string" }, "status": { "type": "string" }, "packageId": { "type": "string" }, "fhirVersion": { "type": "array", "items": { "type": "string" } } } }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } ``` **400** - Invalid guide name or version **404** - Package version not found --- ## FHIR Artifacts / Profiles Manage custom FHIR profiles (StructureDefinitions). ### GET /fhir/profiles **List custom FHIR profiles** Returns metadata for every custom (uploaded) FHIR profile on this instance, across all implementation guides. The full StructureDefinition JSON is omitted from each entry; fetch a single profile by id to retrieve it. The `url` query parameter filters by canonical URL. The canonical URL is the stable key other platform features use to reference a profile (FHIR's `meta.profile`, `baseDefinition`), since StructureDefinition ids are only unique within a package. An unpinned `url` filter returns metadata for the profile's current StructureDefinition. Pinned `url|version` filters resolve a retained version when present; otherwise they can fall back to the profile's current StructureDefinition, whose content can change through the profile update endpoint. A non-matching filter returns an empty list, not a 404. **Operation ID:** `profiles_list` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `url` | query | string | No | Filter by canonical URL. Accepts the FHIR pinned form `url\|version`; without a version pin, returns the profile's current StructureDefinition metadata. | #### Responses **200** - List of uploaded profiles Content-Type: `application/json` ```json { "type": "object", "required": [ "profiles" ], "example": { "profiles": [ { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" } ] }, "properties": { "profiles": { "type": "array", "items": { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } } } } } ``` **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **500** - Server error --- ### POST /fhir/profiles **Upload a custom FHIR profile** Creates a custom profile from a FHIR StructureDefinition supplied as a JSON object. Metadata such as version, resource type, and url is read from the StructureDefinition; the lowercase StructureDefinition id becomes the profile's lookup key. When id is omitted, a random UUID is assigned. Optionally group the profile under a named implementation guide. **Operation ID:** `profiles_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "structure_definition" ], "example": { "implementation_guide": "acme-cardiology", "structure_definition": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" } ] } } }, "properties": { "structure_definition": { "allOf": [ { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ], "description": "A FHIR StructureDefinition as a JSON object. Must include url, type, and a snapshot with elements. Metadata such as version, resource type, and url is read from the StructureDefinition itself. The lowercase id becomes the profile's lookup key; when omitted, a random UUID is assigned.\n", "example": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" }, { "id": "Patient.name", "path": "Patient.name", "min": 1, "max": "*" } ] } } }, "implementation_guide": { "type": "string", "description": "Implementation Guide name to group this profile under. On create, defaults to \"custom\" if omitted; on update, omitting it preserves the profile's current guide. Cannot be \"us_core\" or \"phenoml_hpo\" (reserved). Use this to organize custom profiles into named IGs that can be referenced when calling create/multi or document/multi endpoints.\n", "example": "acme-cardiology" } } } ``` #### Responses **201** - Profile successfully created Content-Type: `application/json` ```json { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } } ``` **400** - Invalid request or profile validation failed. Possible reasons: - Missing or invalid StructureDefinition JSON - The id collides with a built-in profile (US Core, PhenoML HPO, or R4 base) or starts with a reserved prefix (`us-core-`, `phenoml-hpo-`) - A custom profile with the same id or url already exists - The implementation_guide is reserved or invalid **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **500** - Server error --- ### GET /fhir/profiles/{id} **Get a custom FHIR profile** Returns a single custom profile by id, including its full StructureDefinition JSON. **Operation ID:** `profiles_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | #### Responses **200** - The requested profile Content-Type: `application/json` ```json { "description": "Metadata and full StructureDefinition JSON for either a custom profile's current StructureDefinition or one retained version.\n", "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z", "structure_definition": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" } ] } } }, "allOf": [ { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } }, { "type": "object", "required": [ "structure_definition" ], "properties": { "structure_definition": { "allOf": [ { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ], "description": "The full FHIR StructureDefinition JSON." } } } ] } ``` **400** - The id is not a valid profile id **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile not found **500** - Server error --- ### PUT /fhir/profiles/{id} **Update a custom FHIR profile** Replaces an existing custom profile with a new StructureDefinition. The `id` path parameter is authoritative: if the StructureDefinition includes an `id` it must match the path parameter, and if it omits one the path parameter is used. The FHIR resource type of the profile cannot change. When `implementation_guide` is omitted, the profile keeps its existing implementation guide. A retained version string is allowed only when re-submitting the profile's current version with an unchanged StructureDefinition; otherwise it returns a conflict. While the profile has retained versions, its canonical URL cannot be changed. **Operation ID:** `profiles_update` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "structure_definition" ], "example": { "implementation_guide": "acme-cardiology", "structure_definition": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" } ] } } }, "properties": { "structure_definition": { "allOf": [ { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ], "description": "A FHIR StructureDefinition as a JSON object. Must include url, type, and a snapshot with elements. Metadata such as version, resource type, and url is read from the StructureDefinition itself. The lowercase id becomes the profile's lookup key; when omitted, a random UUID is assigned.\n", "example": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" }, { "id": "Patient.name", "path": "Patient.name", "min": 1, "max": "*" } ] } } }, "implementation_guide": { "type": "string", "description": "Implementation Guide name to group this profile under. On create, defaults to \"custom\" if omitted; on update, omitting it preserves the profile's current guide. Cannot be \"us_core\" or \"phenoml_hpo\" (reserved). Use this to organize custom profiles into named IGs that can be referenced when calling create/multi or document/multi endpoints.\n", "example": "acme-cardiology" } } } ``` #### Responses **200** - Profile successfully updated Content-Type: `application/json` ```json { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } } ``` **400** - Invalid request or profile validation failed. Possible reasons: - Missing or invalid StructureDefinition JSON - The StructureDefinition id does not match the id path parameter - The resource type differs from the existing profile - The url collides with a built-in profile or another custom profile - The implementation_guide is reserved or invalid **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile not found **409** - Conflict. Possible reasons: - The requested StructureDefinition.version is already used by a retained version and this is not an unchanged re-submission of the profile's current version - The profile has retained versions and the request changes its canonical URL **500** - Server error --- ### DELETE /fhir/profiles/{id} **Delete a custom FHIR profile** Permanently deletes a custom profile by id. This also deletes all retained versions for that profile so the canonical URL can be reused by a later upload. **Operation ID:** `profiles_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | #### Responses **204** - Profile successfully deleted **400** - The id is not a valid profile id **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile not found **409** - Profile is pinned by an exact implementation guide package **500** - Server error --- ### GET /fhir/profiles/{id}/versions **List versions for a custom FHIR profile** Returns retained versions for a custom profile. **Operation ID:** `profiles_listVersions` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | #### Responses **200** - List of profile versions Content-Type: `application/json` ```json { "type": "object", "required": [ "versions" ], "example": { "versions": [ { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "2.0.0", "status": "active", "date": "2026-08-26", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|2.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-26T15:04:05Z", "updated_at": "2026-08-26T15:04:05Z" }, { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-24T15:04:05Z" } ] }, "properties": { "versions": { "type": "array", "items": { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } } } } } ``` **400** - The id is not a valid profile id **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile not found **500** - Server error --- ### POST /fhir/profiles/{id}/versions **Add a retained version to a custom FHIR profile** Adds an immutable StructureDefinition version to a custom profile. If the profile does not exist, it is created from the submitted version. The StructureDefinition must include a non-empty `version`; its canonical URL and resource type must match the profile when one already exists. If it includes an `id`, that id must match the path parameter; if it omits `id`, the path parameter is used. Profiles created through this endpoint are grouped under `custom`. Posting the profile's current StructureDefinition unchanged retains it as a version. Version strings may contain letters, numbers, and the punctuation characters `.`, `_`, `~`, `+`, and `-`; they cannot be exactly `.` or `..`. Each profile can retain up to 250 versions; delete old versions before adding more. **Operation ID:** `profiles_createVersion` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "allOf": [ { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ], "description": "A FHIR StructureDefinition as a JSON object. Must include resourceType: StructureDefinition, url, type, version, and a snapshot with elements. The canonical URL and resource type must match the profile when one already exists. If id is present, its lowercased value must match the path id; if omitted, the path id is used. The version may contain letters, numbers, and the punctuation characters `.`, `_`, `~`, `+`, and `-`; it cannot be exactly `.` or `..`.\n", "example": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "2.0.0", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient" } ] } } } ``` #### Responses **201** - Profile version successfully created Content-Type: `application/json` ```json { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } } ``` **400** - Invalid request, version does not match the profile, or the canonical URL is already used by another profile. **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile not found **409** - Conflict. Possible reasons: - The requested StructureDefinition.version is already in use by a different StructureDefinition: either the profile's current one or a retained version - The profile has reached the retained version limit **500** - Server error --- ### GET /fhir/profiles/{id}/versions/{version} **Get a retained custom FHIR profile version** Returns metadata and the full StructureDefinition for one retained version. The returned StructureDefinition's id is the profile id. The path version is the authored `StructureDefinition.version` value. **Operation ID:** `profiles_getVersion` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | | `version` | path | string | Yes | The authored StructureDefinition.version. It may contain letters, numbers, and the punctuation characters `.`, `_`, `~`, `+`, and `-`; it cannot be exactly `.` or `..`. | #### Responses **200** - The requested profile version Content-Type: `application/json` ```json { "description": "Metadata and full StructureDefinition JSON for either a custom profile's current StructureDefinition or one retained version.\n", "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z", "structure_definition": { "resourceType": "StructureDefinition", "id": "custom-patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "name": "CustomPatient", "status": "active", "fhirVersion": "4.0.1", "kind": "resource", "abstract": false, "type": "Patient", "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", "derivation": "constraint", "snapshot": { "element": [ { "id": "Patient", "path": "Patient", "min": 0, "max": "*" } ] } } }, "allOf": [ { "type": "object", "description": "Metadata for either a custom profile's current StructureDefinition or one retained version. For retained versions, `source` is always `custom` and `updated_at` is equal to `created_at`.\n", "required": [ "id", "source", "resource_type", "url", "version", "canonical", "fhir_version", "implementation_guide", "created_at", "updated_at" ], "example": { "id": "custom-patient", "source": "custom", "resource_type": "Patient", "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient", "version": "1.0.0", "status": "active", "date": "2026-08-24", "canonical": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0", "fhir_version": "4.0.1", "implementation_guide": "acme-cardiology", "created_at": "2026-08-24T15:04:05Z", "updated_at": "2026-08-25T16:04:05Z" }, "properties": { "id": { "type": "string", "description": "The lowercase StructureDefinition id, used as the profile's lookup key.", "example": "custom-patient" }, "source": { "type": "string", "enum": [ "custom", "builtin" ], "description": "The profile's origin. Profile management responses return custom (uploaded) profiles, so this value is always \"custom\".\n", "example": "custom" }, "resource_type": { "type": "string", "description": "The FHIR resource type from the StructureDefinition.", "example": "Patient" }, "url": { "type": "string", "description": "The canonical URL from the StructureDefinition.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient" }, "version": { "type": "string", "description": "The version from the StructureDefinition.version field.", "example": "1.0.0" }, "status": { "type": "string", "description": "The publication status from StructureDefinition.status. Expected FHIR values include `draft`, `active`, `retired`, and `unknown`; the server preserves authored strings.\n", "example": "active" }, "date": { "type": "string", "description": "The authored publication date from StructureDefinition.date, when present. This is a FHIR dateTime string and may be less precise than a full timestamp.\n", "example": "2026-08-24" }, "canonical": { "type": "string", "description": "The canonical profile reference, including the version pin when present.", "example": "http://phenoml.com/fhir/StructureDefinition/custom-patient|1.0.0" }, "fhir_version": { "type": "string", "description": "The base FHIR version the StructureDefinition targets.", "example": "4.0.1" }, "implementation_guide": { "type": "string", "description": "The implementation guide the profile belongs to.", "example": "acme-cardiology" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time", "description": "Last update timestamp for the profile's current StructureDefinition. For retained versions, this equals `created_at`.\n" } } }, { "type": "object", "required": [ "structure_definition" ], "properties": { "structure_definition": { "allOf": [ { "type": "object", "description": "A FHIR resource (schema depends on resource type)" } ], "description": "The full FHIR StructureDefinition JSON." } } } ] } ``` **400** - The id or version is invalid **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile or version not found **500** - Server error --- ### DELETE /fhir/profiles/{id}/versions/{version} **Delete a retained custom FHIR profile version** Deletes one retained version from a custom profile. The path version is the authored `StructureDefinition.version` value. **Operation ID:** `profiles_deleteVersion` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | The lowercase StructureDefinition id of the custom profile. | | `version` | path | string | Yes | The authored StructureDefinition.version. It may contain letters, numbers, and the punctuation characters `.`, `_`, `~`, `+`, and `-`; it cannot be exactly `.` or `..`. | #### Responses **204** - Profile version successfully deleted **400** - The id or version is invalid **401** - Unauthorized **403** - Forbidden - custom profiles are only available on dedicated instances **404** - Profile or version not found **409** - Profile version is pinned by an exact implementation guide package **500** - Server error --- # Summary Generate clinical summaries from FHIR resources. Supports narrative templates, flattening for RAG, and IPS generation. ## Summary / Templates Reusable summary templates that drive FHIR-to-text generation. ### POST /fhir2summary/template **Create a new summary template** Creates a summary template from an example using LLM function calling **Operation ID:** `summary_createTemplate` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "example_summary", "target_resources", "mode" ], "properties": { "name": { "type": "string", "description": "Name of the template" }, "description": { "type": "string", "description": "Description of the template" }, "example_summary": { "type": "string", "description": "Example summary note to generate template from", "example": "Patient John Doe, age 45, presents with hypertension diagnosed on 2024-01-15." }, "target_resources": { "type": "array", "items": { "type": "string" }, "description": "List of target FHIR resources", "example": [ "Patient", "Condition", "Observation" ] }, "example_fhir_data": { "type": "object", "description": "Optional example FHIR data that corresponds to the example summary", "additionalProperties": true }, "mode": { "type": "string", "description": "Template mode (stored with the template)" } } } ``` **Example:** ```json { "name": "Discharge Summary", "example_summary": "Patient John Doe, age 45, was admitted on 2024-01-10 with Type 2 Diabetes. Discharged on 2024-01-15 with Metformin 500mg BID.", "target_resources": [ "Patient", "Condition", "MedicationRequest" ], "mode": "narrative" } ``` #### Responses **200** - Template created successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "template_id": { "type": "string", "format": "uuid" }, "template": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "description": { "type": "string" }, "template": { "type": "string", "description": "Template with {{resource.field}} placeholders" }, "target_resources": { "type": "array", "items": { "type": "string" }, "description": "List of FHIR resource types/profiles" }, "mode": { "type": "string", "description": "Template mode (stored value)" }, "metadata": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } } } ``` **Example:** ```json { "success": true, "message": "Template created successfully", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "template": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Discharge Summary", "template": "Patient <>, age <>, was admitted on <> with <>. Discharged on <> with <> <>.", "target_resources": [ "Patient", "Condition", "MedicationRequest" ], "mode": "narrative", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" } } ``` **400** - Bad request - invalid input **401** - Unauthorized **500** - Internal server error --- ### GET /fhir2summary/template/{id} **Get a summary template by ID** Retrieves a specific summary template **Operation ID:** `summary_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Template ID | #### Responses **200** - Template retrieved successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "template": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "description": { "type": "string" }, "template": { "type": "string", "description": "Template with {{resource.field}} placeholders" }, "target_resources": { "type": "array", "items": { "type": "string" }, "description": "List of FHIR resource types/profiles" }, "mode": { "type": "string", "description": "Template mode (stored value)" }, "metadata": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } } } ``` **Example:** ```json { "success": true, "template": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Discharge Summary", "template": "Patient <>, age <>, was admitted on <> with <>.", "target_resources": [ "Patient", "Condition", "MedicationRequest" ], "mode": "narrative", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" } } ``` **401** - Unauthorized **403** - Access denied **404** - Template not found **500** - Internal server error --- ### PUT /fhir2summary/template/{id} **Update a summary template** Updates an existing summary template **Operation ID:** `summary_update` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Template ID | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "template", "target_resources", "mode" ], "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "template": { "type": "string", "description": "Updated template with placeholders" }, "target_resources": { "type": "array", "items": { "type": "string" } }, "mode": { "type": "string", "description": "Template mode" } } } ``` **Example:** ```json { "name": "Discharge Summary", "template": "Patient {{Patient.name[0].text}} was discharged on {{Encounter[0].period.end}} with {{MedicationRequest[0].medicationCodeableConcept.coding[0].display}} {{MedicationRequest[0].dosageInstruction[0].text}}.", "target_resources": [ "Patient", "Encounter", "MedicationRequest" ], "mode": "narrative" } ``` #### Responses **200** - Template updated successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "template": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "description": { "type": "string" }, "template": { "type": "string", "description": "Template with {{resource.field}} placeholders" }, "target_resources": { "type": "array", "items": { "type": "string" }, "description": "List of FHIR resource types/profiles" }, "mode": { "type": "string", "description": "Template mode (stored value)" }, "metadata": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } } } ``` **Example:** ```json { "success": true, "message": "Template updated successfully", "template": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Discharge Summary", "template": "Patient <> was discharged on <> with <> <>.", "target_resources": [ "Patient", "Encounter", "MedicationRequest" ], "mode": "narrative", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-02-20T11:00:00Z" } } ``` **400** - Bad request - invalid input **401** - Unauthorized **403** - Access denied **404** - Template not found **500** - Internal server error --- ### DELETE /fhir2summary/template/{id} **Delete a summary template** Deletes a summary template **Operation ID:** `summary_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Template ID | #### Responses **200** - Template deleted successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" } } } ``` **Example:** ```json { "success": true, "message": "Template deleted successfully" } ``` **401** - Unauthorized **403** - Access denied **404** - Template not found **500** - Internal server error --- ### GET /fhir2summary/templates **List all summary templates** Retrieves all summary templates for the authenticated user **Operation ID:** `summary_list` #### Responses **200** - Templates retrieved successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "templates": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "description": { "type": "string" }, "template": { "type": "string", "description": "Template with {{resource.field}} placeholders" }, "target_resources": { "type": "array", "items": { "type": "string" }, "description": "List of FHIR resource types/profiles" }, "mode": { "type": "string", "description": "Template mode (stored value)" }, "metadata": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } } } } } ``` **Example:** ```json { "success": true, "templates": [ { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Discharge Summary", "template": "Patient <>, age <>, was admitted on <> with <>.", "target_resources": [ "Patient", "Condition", "MedicationRequest" ], "mode": "narrative", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" } ] } ``` **401** - Unauthorized **500** - Internal server error --- ## Untagged ### POST /fhir2summary/create **Generate a summary from FHIR resources** Creates a summary from FHIR resources using one of three modes: - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id) - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed) - **ips**: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs. **Operation ID:** `summary_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "fhir_resources" ], "properties": { "mode": { "type": "string", "enum": [ "narrative", "flatten", "ips" ], "default": "narrative", "description": "Summary generation mode:\n- narrative: Substitute FHIR data into a template (requires template_id)\n- flatten: Flatten FHIR resources for RAG/search (no template needed)\n- ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG\n" }, "template_id": { "type": "string", "format": "uuid", "description": "ID of the template to use (required for narrative mode)" }, "fhir_resources": { "type": "object", "additionalProperties": true, "description": "FHIR resources (single resource or Bundle).\nFor IPS mode, must be a Bundle containing exactly one Patient resource with at least one\nidentifier (id, fullUrl, or identifier field). Returns an error if no Patient is found,\nif multiple Patients are present, or if the Patient has no identifiers. Resources are\nautomatically filtered to only include those referencing the patient.\n" } } } ``` **Example:** ```json { "mode": "narrative", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "fhir_resources": { "resourceType": "Bundle", "type": "collection", "entry": [ { "resource": { "resourceType": "Patient", "name": [ { "given": [ "John" ], "family": "Doe" } ], "gender": "male", "birthDate": "1979-03-15" } }, { "resource": { "resourceType": "Condition", "code": { "text": "Type 2 Diabetes Mellitus" }, "onsetDateTime": "2024-01-15" } } ] } } ``` #### Responses **200** - Summary generated successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "summary": { "type": "string", "description": "Generated summary text" }, "warnings": { "type": "array", "items": { "type": "string" }, "description": "Unresolved placeholders or issues (narrative mode only)" } } } ``` **Example:** ```json { "success": true, "summary": "Patient John Doe is a 45-year-old male diagnosed with Type 2 Diabetes Mellitus on January 15, 2024. Current treatment plan includes lifestyle modifications and medication management.", "warnings": [] } ``` **400** - Bad request - invalid input. Possible reasons: - Invalid or unsupported mode value - Missing template_id (required for narrative mode) - No Patient resource found in bundle (IPS mode) - Multiple Patient resources found in bundle - IPS requires exactly one (IPS mode) - Patient resource has no identifiers for reference matching (IPS mode) Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "summary": { "type": "string", "description": "Generated summary text" }, "warnings": { "type": "array", "items": { "type": "string" }, "description": "Unresolved placeholders or issues (narrative mode only)" } } } ``` **401** - Unauthorized **403** - Access denied - template belongs to another user **404** - Template not found (narrative mode with invalid template_id) **500** - Internal server error --- # FHIR2OMOP Map FHIR R4 resources and bundles into OMOP Common Data Model (CDM v5.4) tables. ## Endpoints ### GET /fhir2omop/batch **List batch jobs** Returns a page of the instance's FHIR2OMOP batch jobs, newest first, without per-job counts. Jobs are shared across the instance's credentials, so this lists every FHIR2OMOP batch job on the instance, not just the calling credential's. **Operation ID:** `fhir2omop_batch_list` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - A page of batch jobs Content-Type: `application/json` ```json { "type": "object", "description": "A page of job records, without per-job counts.", "required": [ "jobs", "has_more" ], "properties": { "jobs": { "type": "array", "items": { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more jobs remain beyond this page.", "example": false } } } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /fhir2omop/batch **Create a batch job** Opens an empty job; upload items, then finalize it to start processing. `request_id` makes creation idempotent: a retry returns the original job instead of opening a second one. A token is released when its job is canceled or fails before finalization; otherwise it continues to resolve to that job. **Operation ID:** `fhir2omop_batch_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "description": "Body of a create-batch request. Opens an empty job.", "properties": { "request_id": { "type": "string", "description": "Optional client idempotency token (at most 256 UTF-8 bytes). A\nretried create with the same token returns the original job instead\nof opening a second one.\n", "example": "omop-cohort-2026-11-02-001" } } } ``` **Example:** ```json { "request_id": "omop-cohort-2026-11-02-001" } ``` #### Responses **202** - Batch job created (or an idempotent replay of an existing job) Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **400** - Invalid request (e.g. request_id over its 256-byte limit) **401** - Unauthorized **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /fhir2omop/batch/{job_id} **Get a batch job** Returns a job's record, its per-status item counts, and one page of per-item statuses. Items are listed in a stable order that is not upload order and is the same across pages. Match each entry to your own records by its `id` (your correlation label) or `item_id` (from the upload response), never by position. **Operation ID:** `fhir2omop_batch_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size for the item-status page. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - The job record, counts, and a page of item statuses Content-Type: `application/json` ```json { "description": "A job's record, its counts, and one page of item statuses.\n", "allOf": [ { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } }, { "type": "object", "required": [ "counts", "items", "has_more" ], "properties": { "counts": { "type": "object", "description": "A job's per-status item tally.", "required": [ "total", "pending", "processing", "succeeded", "failed" ], "properties": { "total": { "type": "integer", "example": 12 }, "pending": { "type": "integer", "example": 3 }, "processing": { "type": "integer", "example": 2 }, "succeeded": { "type": "integer", "example": 6 }, "failed": { "type": "integer", "example": 1 } } }, "items": { "type": "array", "items": { "type": "object", "description": "One item's status line.", "required": [ "item_id", "status", "attempts" ], "properties": { "item_id": { "type": "string", "description": "Server-assigned opaque item ID, used in result URLs.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "patient-000123" }, "status": { "type": "string", "description": "Item status.", "enum": [ "pending", "processing", "succeeded", "failed" ], "example": "succeeded" }, "attempts": { "type": "integer", "description": "Number of processing attempts started so far. The service retries\nan item that was interrupted, or whose vocabulary lookups or\nconcept inference were temporarily unavailable; any other mapping\nerror fails the item without retry.\n", "example": 1 }, "result_size": { "type": "integer", "format": "int64", "description": "Size in bytes of the item's stored result. Present once the item has succeeded.", "example": 20482 }, "error": { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } }, "completed_at": { "type": "string", "format": "date-time", "description": "When the item finished. Absent until then." } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more item statuses remain beyond this page.", "example": false } } } ] } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **404** - Batch job not found **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /fhir2omop/batch/{job_id}/cancel **Cancel a batch job** Drives a job to the terminal `canceled` state on request. Takes no request body. Cancel does not delete the job: the job record and any results already produced are preserved for the normal retention window, the same as a `completed` or `failed` job. Items stop being processed and keep the state they held at cancellation, so a canceled job's `counts` may show unfinished items that never resolve. Cancel is idempotent: canceling an already-`canceled` job returns `200` with the job. Canceling a job that has already `completed` or `failed` is a `409`. **Operation ID:** `fhir2omop_batch_cancel` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Responses **200** - The job, now canceled Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **401** - Unauthorized **404** - Batch job not found **409** - The job has already completed or failed and cannot be canceled **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /fhir2omop/batch/{job_id}/finalize **Finalize a batch job** Seals the job's item set and starts processing. Takes no request body. Finalize is idempotent: a retried finalize succeeds again. If a previous upload did not complete, finalize returns a `409`; re-send the missing upload (with the same `request_id`), then finalize. A job that was canceled or failed before it was finalized also returns `409`, and can't be finalized. Finalizing a job with no items is a `400`. **Operation ID:** `fhir2omop_batch_finalize` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Responses **202** - Job finalized and processing started Content-Type: `application/json` ```json { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } } ``` **400** - The batch has no items to finalize **401** - Unauthorized **404** - Batch job not found **409** - A previous upload did not complete (re-send it with the same request_id, then finalize), or the job was canceled or failed before finalization **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /fhir2omop/batch/{job_id}/items **Upload one batch item** Stores one item: the body of one `POST /fhir2omop/create` request, with `vocab_version` required. Upload checks only that `fhir_resources` is a JSON object and that `vocab_version` names a specific release. The FHIR content, and whether the release exists, are checked when the item is processed: input that `POST /fhir2omop/create` would reject with a `400` fails the item with `invalid_input` and the same message. Use `request_id` for every upload so retries replace the same item. `deduplicated` is true only for an unchanged payload; a changed payload overwrites the item and returns false. Uploads return `409` after finalization or at the item limit, and `413` when the item is too large. **Operation ID:** `fhir2omop_batch_uploadItem` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "description": "One batch item.", "required": [ "fhir_resources", "vocab_version" ], "properties": { "fhir_resources": { "type": "object", "additionalProperties": true, "description": "A FHIR R4 resource or Bundle, the same as `fhir_resources` on\n`POST /fhir2omop/create`. Must contain at least one Patient\nresource for the item to succeed.\n" }, "vocab_version": { "type": "string", "description": "OMOP vocabulary release the item maps against, the same setting as\n`vocab_version` on `POST /fhir2omop/create`. Required here, and it\nmust name a specific release: an item has no default release.\n", "example": "v20260829" }, "request_id": { "type": "string", "description": "Optional idempotency token (at most 256 UTF-8 bytes).\nRe-uploading under the same token overwrites the same item\ninstead of adding a new one. The token is scoped to this job;\nthe same token in another job is independent and creates a\nseparate item.\n", "example": "omop-cohort-2026-11-02-001-patient-000123" }, "id": { "type": "string", "description": "Optional caller-supplied correlation label (at most 512 UTF-8\nbytes), echoed back on status and result listings so you can\nmatch the server's item_id to your own record.\n", "example": "patient-000123" } } } ``` **Example:** ```json { "id": "patient-000123", "request_id": "omop-cohort-2026-11-02-001-patient-000123", "vocab_version": "v20260829", "fhir_resources": { "resourceType": "Bundle", "type": "collection", "entry": [ { "resource": { "resourceType": "Patient", "id": "patient-000123", "gender": "female", "birthDate": "1985-07-22" } }, { "resource": { "resourceType": "Condition", "id": "condition-1", "subject": { "reference": "Patient/patient-000123" }, "onsetDateTime": "2024-01-01", "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "44054006", "display": "Type 2 diabetes mellitus" } ] } } } ] } } ``` #### Responses **202** - Item accepted Content-Type: `application/json` ```json { "description": "The upload response: the job record plus the ID the server assigned the\nuploaded item.\n", "allOf": [ { "type": "object", "description": "One batch job record.", "required": [ "job_id", "status", "finalized", "total_items", "created_at", "updated_at", "expires_at" ], "properties": { "job_id": { "type": "string", "description": "Server-assigned job identifier.", "example": "f2o_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d" }, "request_id": { "type": "string", "description": "The idempotency token supplied at create, if any.", "example": "omop-cohort-2026-11-02-001" }, "status": { "type": "string", "description": "Job status. `completed` means every item has finished — some may have\nfailed, so check `counts` for the split. `failed` is a whole-job\nfailure (the job could not run at all), distinct from individual item\nfailures, which never fail the job. `canceled` is a caller-requested\ncancellation via `POST /fhir2omop/batch/{job_id}/cancel`; like the\nother terminal states it keeps any results already produced readable\nfor the retention window.\n", "enum": [ "pending", "processing", "completed", "failed", "canceled" ], "example": "pending" }, "finalized": { "type": "boolean", "description": "Whether the job's item set has been sealed.", "example": false }, "total_items": { "type": "integer", "description": "The sealed item count. It is 0 until the job is finalized, so an\nupload response always reports 0; poll the job after finalize for the\nreal count.\n", "example": 12 }, "error": { "description": "A whole-job failure. Present only on a `failed` job.", "allOf": [ { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } } ] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time", "description": "When the job finished. Absent until then." }, "expires_at": { "type": "string", "format": "date-time", "description": "When the job and its stored inputs and results are deleted. Set 7\ndays out, with the clock restarting when the job reaches `completed`,\n`failed`, or `canceled`. At expiry the job's `request_id` is freed for reuse.\n" } } }, { "type": "object", "required": [ "item_id", "deduplicated" ], "properties": { "item_id": { "type": "string", "description": "The server-assigned ID of the uploaded item; use it to fetch the result.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "patient-000123" }, "deduplicated": { "type": "boolean", "description": "True only when a repeated `request_id` resolved to an item whose\npayload matched the one already stored. A same-token upload with a\nchanged payload overwrites in place and returns false.\n", "example": false } } } ] } ``` **400** - Invalid upload: a body that isn't valid JSON, a missing or non-object `fhir_resources`, a missing or non-string `vocab_version` or one that doesn't name a specific release, a non-string `id` or `request_id`, or an over-length `request_id` or `id`. **401** - Unauthorized **404** - Batch job not found **409** - The job is finalized, canceled, or failed, or is at its item limit **413** - The upload body is over 32 MiB, or its fhir_resources and vocab_version together over about 28 MiB **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /fhir2omop/batch/{job_id}/results **List a batch job's results** A lighter status page. Returns the same per-item status entries as `GET /fhir2omop/batch/{job_id}`, but without the job record or counts, and the entries carry `result_size` rather than any result content. Use each entry's `item_id` to fetch that item's result from `GET /fhir2omop/batch/{job_id}/results/{item_id}`. Entries are listed in a stable order that is not upload order and is the same across pages. Match each entry to your own records by its `id` (your correlation label) or `item_id` (from the upload response), never by position. **Operation ID:** `fhir2omop_batch_getResults` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `cursor` | query | string | No | Opaque pagination cursor from a previous page's next_cursor. | | `limit` | query | integer | No | Page size. Defaults to 20; values above 100 are clamped to 100. | #### Responses **200** - A page of per-item result statuses Content-Type: `application/json` ```json { "type": "object", "description": "A page of per-item result statuses, without the job counts.", "required": [ "results", "has_more" ], "properties": { "results": { "type": "array", "items": { "type": "object", "description": "One item's status line.", "required": [ "item_id", "status", "attempts" ], "properties": { "item_id": { "type": "string", "description": "Server-assigned opaque item ID, used in result URLs.", "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }, "id": { "type": "string", "description": "The caller's correlation label, echoed back; omitted when none was supplied.", "example": "patient-000123" }, "status": { "type": "string", "description": "Item status.", "enum": [ "pending", "processing", "succeeded", "failed" ], "example": "succeeded" }, "attempts": { "type": "integer", "description": "Number of processing attempts started so far. The service retries\nan item that was interrupted, or whose vocabulary lookups or\nconcept inference were temporarily unavailable; any other mapping\nerror fails the item without retry.\n", "example": 1 }, "result_size": { "type": "integer", "format": "int64", "description": "Size in bytes of the item's stored result. Present once the item has succeeded.", "example": 20482 }, "error": { "type": "object", "description": "A job- or item-level failure. Never contains FHIR or patient content.", "required": [ "kind", "message" ], "properties": { "kind": { "type": "string", "description": "Short stable token to branch on. Item-level kinds: `invalid_input`\n(`POST /fhir2omop/create` would reject the item with a `400`; the\nmessage is that response's message), `processing_failed` (the\nitem could not be mapped; the message says why), `result_too_large`\n(the result exceeded 28 MiB), `input_unavailable` (the input could\nnot be read), and\n`retries_exhausted` / `attempts_exhausted` (the item could not\ncomplete after repeated interruptions or after vocabulary lookups\nstayed unavailable; it may succeed if you upload it again in a new\njob). Job-level kinds: `timeout` (the job did not\nfinish within 36 hours of creation).\n", "example": "invalid_input" }, "message": { "type": "string", "description": "Human-readable description of the failure.", "example": "no Patient resource found; OMOP requires at least one person" } } }, "completed_at": { "type": "string", "format": "date-time", "description": "When the item finished. Absent until then." } } } }, "next_cursor": { "type": "string", "description": "Cursor for the next page, when has_more is true." }, "has_more": { "type": "boolean", "description": "Whether more results remain beyond this page.", "example": false } } } ``` **400** - Invalid request (e.g. non-integer limit or malformed cursor) **401** - Unauthorized **404** - Batch job not found **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### GET /fhir2omop/batch/{job_id}/results/{item_id} **Get one batch item's result** Streams one item's stored result bytes verbatim as `application/json`. The body is the response `POST /fhir2omop/create` would have returned for the item (`CreateOmopResponse`). Its `vocab_version` is the release the mapping used, and is omitted when the item needed no vocabulary lookups, as in that endpoint's response. Only a succeeded item has a result: an item that has not succeeded (pending, processing, or failed) is a `409`, and a result that has expired is a `404`. **Operation ID:** `fhir2omop_batch_getResult` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `job_id` | path | string | Yes | | | `item_id` | path | string | Yes | | #### Responses **200** - The item's raw result JSON Content-Type: `application/json` ```json { "type": "object", "description": "The item's mapping result, a `CreateOmopResponse` from\n`POST /fhir2omop/create`.\n" } ``` **400** - Invalid request (e.g. empty item_id) **401** - Unauthorized **404** - Batch job or item not found, or the result has expired **409** - The item has not succeeded, so it has no result to serve **499** - Client closed request before response was ready **500** - Server error **504** - Request timed out --- ### POST /fhir2omop/create **Map FHIR resources to OMOP CDM v5.4** Maps a FHIR R4 resource or Bundle to OMOP CDM v5.4 rows, grouped by destination table in `tables`. The request must include at least one top-level Patient. Unsupported resource types are ignored; supported resources that cannot produce a row are reported in `dropped`. All shaped rows remain in `tables`, including partial rows and clinical rows with uncertain status or unresolved primary concepts. Use `rows_for_review` to identify the latter, `mappings` to inspect concept resolution, and `diagnostics` to understand unusable data or links. Resource-specific context arrays preserve source information linked to the emitted rows; see the response schemas for their fields and outcomes. Rows may lack CDM-required fields when the source cannot supply them. Before loading a CDM dataset, callers must handle incomplete rows, assign durable IDs, and remap primary and foreign keys together. Returned IDs start at 1 within each table and are local to one response. The source format is [FHIR R4 v4.0.1](https://hl7.org/fhir/R4/) and the output follows [OMOP CDM v5.4](https://ohdsi.github.io/CommonDataModel/cdm54.html). The informative [Vulcan FHIR-to-OMOP IG](https://hl7.org/fhir/uv/omop/) provides an R5 baseline adapted here to R4 source fields. Full FHIR or US Core profile conformance is not validated. **Resource coverage** | FHIR source | OMOP output | | --- | --- | | Patient | `person`; deceased status can produce `death`, the first address can produce `location`, and multiple resolved races produce race `observation` rows | | Location | `location` and `care_site` | | Organization | `care_site`; its first address can produce `location` | | HealthcareService | `care_site` | | Practitioner, PractitionerRole | `provider`, with role context retained separately | | Encounter | `visit_occurrence`, or `visit_detail` for supported explicit components | | Specimen | `specimen`, requiring an explicit Patient subject | | DeviceUseStatement | `device_exposure`, using referenced Device details | | Condition | Domain-selected clinical table; default `condition_occurrence` | | Procedure | Domain-selected clinical table; default `procedure_occurrence` | | MedicationRequest, MedicationStatement, MedicationAdministration, MedicationDispense, Immunization | Domain-selected clinical table; default `drug_exposure` | | Observation | Domain-selected clinical table; numeric values default to `measurement`, other values to `observation` | | AllergyIntolerance | Contextual allergy `observation` or another supported clinical table, excluding drug/device exposure; default `observation` | | Medication, Device | Reference data; no independent row | One request-local `observation_period` is derived per person with qualifying dates. It spans visit/clinical rows not indexed for review, plus Specimen and Death rows, including selected source end dates even when the destination has no end column. Dates from `rows_for_review` do not expand it. This period is not evidence of enrollment or complete data capture. **Concept resolution and placement** Use `vocab_version` to select the vocabulary release; omitted or empty values use the default release. The response reports the release used when vocabulary resolution occurred. Select a release explicitly for reproducibility. Resolved primary clinical concepts determine placement in `condition_occurrence`, `procedure_occurrence`, `drug_exposure`, `device_exposure`, `measurement`, or `observation`. For Observation, numeric versus nonnumeric values break a tie between Measurement and Observation placement. An unresolved or destination-invalid concept keeps the resource's default table, concept ID 0, and `UNMAPPED` status. Clinical records produce one row each, except the explicit DeviceUseStatement Timing events described below; multiple vocabulary targets do not expand a record into multiple rows. Note destinations and vocabulary `Maps to value` decomposition are unsupported. Source timing and eligibility apply regardless of the selected table. Source-specific values populate only compatible columns: Condition status in `condition_occurrence`, medication supply/dosage and Immunization lot details in `drug_exposure`, and Observation values in `measurement` or `observation`. Coded routes on other tables are resolved as mapping context; Observation values on other tables are preserved without concept resolution. Those entries omit `omop_field` and have `selected: false`. Supported primary clinical concepts, specimen material, and unresolved coded Observation results can use semantic mapping from descriptive text. CodeableConcept text takes precedence over coding display; bare codes do not supply descriptions. Deterministic mappings take precedence, and ambiguous or domain-mismatched results are not reinterpreted. Inference requires one validated, equivalent active standard concept valid for the destination; a broader crosswalk target does not validate a suggestion. Units, routes, visits, demographics, specialties, collection sites, and contextual allergy findings follow their separate policies. Inferred results have `resolution.semantic_mapping.status: MAPPED` in their linked mappings; unsuccessful attempts report `UNMAPPED` with concept ID 0. Original coding is preserved and no source coding is invented. Successful inference does not remove uncertain-status review reasons. Use mapping row links to filter inferred results if needed. Clinical `*_source_value` fields contain the selected bare code, or text for text-only inputs. The selected mapping preserves its coding provenance. Unresolved source concept IDs are 0, except allergy rows can retain a known original source identity even when the finding is unresolved. Known coding system OIDs, bare or `urn:oid:`, resolve like their canonical URLs and are reported canonically in coding mappings. Quantity unit mappings preserve the supplied system spelling. Unknown OIDs remain unchanged. **References and eligibility** Top-level references resolve only within the request, by exact `Type/id` or Bundle `fullUrl`, including URNs and absolute URLs. Contained references are supported for medication lookup, DeviceUseStatement.device, and PractitionerRole.practitioner. The latter also supports request-local identifier matching. Resources are not fetched remotely. Clinical subject/patient references must resolve unambiguously to a supplied Patient. If the reference is absent, a sole Patient can supply attribution, except for Specimen, DeviceUseStatement, and MedicationDispense, which require explicit subjects. Unusable explicit patient references drop the resource. Unusable optional links leave the link unset with a diagnostic while retaining otherwise eligible rows. Every nonzero structural foreign key targets a row in the same response, and clinical visit links must belong to the same patient. Eligibility follows the source resource's status policy. Other than the absent/uncertain statuses explicitly supported below, missing or unrecognized required statuses drop the resource. Entered-in-error and explicitly non-performed events do not produce positive clinical-event rows. | Resource | Eligible status or evidence | Retained for review | | --- | --- | --- | | Condition | Absent or confirmed canonical-HL7 verificationStatus; refuted and entered-in-error are dropped | Unconfirmed, provisional, differential, or unreadable supplied verificationStatus | | Encounter | arrived, triaged, in-progress, onleave, finished; planned, cancelled, and entered-in-error are dropped | Unknown, missing, or unreadable status | | Procedure | completed, stopped | Explicit unknown status | | MedicationRequest | active, on-hold, completed, stopped, with authorizing intent: order, original-order, reflex-order, filler-order, or instance-order; doNotPerform excludes the request | None | | MedicationStatement | active, completed, stopped, on-hold | Explicit unknown status | | MedicationAdministration | completed, in-progress, stopped, or on-hold; on-hold also requires a usable effective start, including partial dates | None | | MedicationDispense | completed, including partial fills; stopped also requires a valid whenHandedOver, including partial dates | None | | Immunization | completed | None | | Observation | final, amended, corrected | Explicit unknown status | | AllergyIntolerance | Absent, unconfirmed, or confirmed canonical-HL7 verificationStatus; invalid supplied type/category drops the resource | None | | Specimen | Absent, available, unavailable, unsatisfactory | None | | DeviceUseStatement | active, completed, stopped, on-hold | None | Condition clinical course is not a diagnosis-role mapping. Retained uncertain rows preserve their supplied statuses without asserting that an event occurred or medication was taken. Eligible clinical rows with primary concept 0 are also indexed for review; unresolved secondary units, routes, or result concepts alone do not index a mapped row. Administrative/demographic, Specimen, and Death rows are excluded from the review index. See `rows_for_review` for filtering and linked-visit requirements. Device placement additionally requires eligible use evidence. MedicationRequest, AllergyIntolerance, uncertain-status records, and explicit negative Observation results cannot produce device exposure. Negative evidence includes false, SNOMED Negative/Known absent/No, and `NEG` from `http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation`. Reporting actors such as recorder, asserter, or informationSource do not supply a device event's treating provider. **Timing** Dates require at least day precision and use the source calendar date. Datetimes are present only when time of day was supplied, as local wall-clock time without a UTC offset, retaining fractional seconds to microseconds. For example, `2024-01-15T23:30:00-05:00` becomes `2024-01-15T23:30:00`. A timestamp without a timezone is read as local time. A valid year/month-only date leaves date and datetime unset and stops a fallback chain. Malformed dates and unsupported timing forms are ignored so a later source can be used. Dates are not imputed from other resources. Specimen, DeviceUseStatement, and MedicationDispense report unusable timing through diagnostics; otherwise missing dates usually retain partial rows. The effective-start and handover eligibility requirements above still apply. | Source | Start/date source, in priority order | End or additional timing | | --- | --- | --- | | Patient | birthDate supplies year/month/day components; deceasedDateTime supplies death timing | birth_datetime is not set; boolean-only deceased status supplies no death date | | Practitioner | birthDate supplies year_of_birth | — | | Encounter | period.start | period.end | | Condition | onsetDateTime, onsetPeriod.start, recordedDate | abatementDateTime or abatementPeriod.end | | Procedure | performedDateTime or performedPeriod.start | performedPeriod.end | | Observation | effectiveDateTime, effectivePeriod.start, effectiveInstant | — | | AllergyIntolerance | recordedDate, onsetDateTime, onsetPeriod.start | — | | MedicationRequest | authoredOn, as prescription timing | No exposure end; validity period is not exposure duration | | MedicationStatement | effectiveDateTime or effectivePeriod.start | effectivePeriod.end; dateAsserted is not exposure timing | | MedicationAdministration | effectiveDateTime or effectivePeriod.start | A single dateTime also sets the end; otherwise effectivePeriod.end | | MedicationDispense | whenHandedOver | No exposure end, including from daysSupply; whenPrepared is not a fallback | | Immunization | occurrenceDateTime | The same dateTime also sets the end; expirationDate is not used | | Specimen | collection.collectedDateTime or collection.collectedPeriod.start | Period end and receivedTime are not collection-start fallbacks | | DeviceUseStatement | timingDateTime, independent timingPeriod boundaries, or one start per timingTiming.event | No end is inferred for dateTime/Timing events; repeat-only schedules retain an undated row | End columns are populated only where supported by the destination table. For medication rows, `verbatim_end_date` comes only from an explicit Period.end, not a single-event end. **Providers and patient demographics** Administrative links are best-effort. Patient.managingOrganization is a record custodian and does not supply a care site. Address.country resolves to `location.country_concept_id`; CMS Place of Service codings in Location.type resolve to `care_site.place_of_service_concept_id`. Practitioner recorded gender is separate from Person demographics: male/female can resolve to Provider Gender concepts; other, unknown, or absent values stay 0. Within a request, Practitioners and role-only providers sharing one confirmed individual NPI (Type 1) merge only when their supplied rendered name, recorded gender, DEA identifier, and parsed birth year are compatible. The first name entry and first non-empty DEA identifier are used; supplied identity values compare exactly. Missing attributes can enrich a compatible row. A conflict keeps the entire NPI group separate with linked diagnostics. Multiple distinct NPIs on a Practitioner also prevent merging and leave npi unset. No merge occurs across requests. NPI classification trims whitespace and validates ten digits and the NPI check digit; returned source values and merge comparisons preserve the supplied spelling. Known individual NPIs remain usable for historical care when deactivated. An invalid or unconfirmed NPI retains a source-scoped Practitioner without npi, with an UNRESOLVED diagnostic at identifier. No live public registry lookup is performed; classification failures return HTTP 500. Accepted NPI system forms, missing-value markers, and source-identity semantics are defined in ProviderRow. A PractitionerRole can alias a supplied Practitioner by structural reference, unambiguous parent-contained reference, or identifier match to a top-level Practitioner. Supplied Reference.type must be Practitioner. NPI identifier matching requires a confirmed individual NPI and accepts the NPI system aliases; other identifiers match exactly. Unusable or ambiguous references have diagnostics. A resolved Practitioner's identity takes precedence over the role's identifiers. Without a resolvable supplied Practitioner, a role requires one confirmed individual NPI in PractitionerRole.identifier or practitioner.identifier to emit a provider. NPIs from both fields must agree exactly. A usable logical NPI reference needs no supplied Practitioner and produces no missing-Practitioner diagnostic. Role-only providers share the NPI grouping rules; names, gender, and birth information are not invented. provider_role_contexts preserves every emitted role's specialty and care-site context, including when roles share a provider. Provider exclusions are reported in dropped: - provider_npi_is_organization: a top-level Practitioner or role-only provider is identified by an organization NPI (Type 2). - provider_role_requires_individual_npi: a role has neither a usable Practitioner nor a confirmed individual NPI. - provider_role_conflicting_npis: a role without a usable Practitioner supplies multiple distinct NPIs across its identifier fields. - provider_practitioner_is_not_individual: a role resolves to an organization Practitioner. Clinical rows remain eligible when a provider is omitted; their provider links stay unset, with UNRESOLVED diagnostics pointing to the provider's dropped entry. Each role specialty resolves independently from supported codings, with deterministic explicit-text fallback for text-only entries or complete codings from unsupported systems. Incomplete/malformed codings or recognized systems block text fallback; coding displays do not supply fallback text. Complete unsupported companions do not block agreeing supported codings. Unsupported systems must be well-formed absolute URIs without whitespace, credentials, or fragments. `specialty_concept_id` is populated only when at least one specialty is supplied and every distinct input resolves to the same standard Provider concept; otherwise it stays 0. Each role's source and outcome remain in mappings, including repeated inputs. Specialty mappings have `selected: false`; see SpecialtyResolution for per-coding evidence and MappingResolution.via for the reported matching route. Patient sex at birth, race, and ethnicity use these US Core 6.1.0 extension structures/value sets on any Patient; a US Core profile declaration is not required. Other demographic extensions are ignored. | Demographic | Extension URL | Supported value source | | --- | --- | --- | | Birth sex | http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex | valueCode, using http://hl7.org/fhir/us/core/ValueSet/birthsex | | Race | http://hl7.org/fhir/us/core/StructureDefinition/us-core-race | ombCategory, using http://hl7.org/fhir/us/core/ValueSet/omb-race-category | | Ethnicity | http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity | ombCategory, using http://hl7.org/fhir/us/core/ValueSet/omb-ethnicity-category | - A supplied birth-sex extension takes precedence: M/F resolve, while unknown, unsupported, or conflicting values, or an extension without valueCode, leave concept 0 without falling back to Patient.gender. Without a birth-sex extension, male/female administrative gender is used under the OMOP sex-at-birth convention; other/unknown remain 0. - One distinct resolved race sets the Person race concept. Multiple races use `1546847` (More than one race) and one observation per race: concept `4013886` (Race), type `32817`, and the race in `value_as_concept_id`. The category code is `value_source_value`; observation_source_value and observation_date are absent. Loaders must supply their own required-date policy. - One non-null ethnicity category can resolve; conflicting categories leave concept 0. Multiple-ethnicity observations are not produced. Race/ethnicity null flavors are ignored, and detailed codes/text are preserved without resolution. Source codes are joined with `|` in source order, falling back to extension text when no code exists. - Mappings preserve supplied demographic codes and indicate which were selected; overridden administrative gender is unselected. Conflicting birth sex/ethnicity and birth sex without valueCode also have diagnostics. Summary counts follow the field-level rules in Summary. Demographics are not inferred from other data. **Allergies and observations** Coded AllergyIntolerance statements use original codings, optional type, and category to resolve an Observation finding and the causative substance independently. A Drug-domain substance can be a value without implying drug exposure or medication allergy. Contextual findings report `MAPPED` and `resolution.via: CONTEXTUAL`; original source concept identity is retained. The contextual finding policy is: | Supplied type | Medication, optionally with biologic | Food alone | Other or unknown categories | | --- | --- | --- | --- | | allergy | Allergy to drug (439224) | Allergic disposition (43530807) | Allergic disposition (43530807) | | intolerance | Intolerance to drug (4240582) | Intolerance to food (4340252) | Intolerance to substance (36684107) | | Absent | Propensity to adverse reactions to drug (4305025) | Propensity to adverse reactions to food (4303802) | Propensity to adverse reaction (4172024) | Selected findings must be active standard concepts in the requested release. Limited reviewed substance mappings can supply an absent category; Drug-domain membership alone does not. An absent type remains absent. Supported existing findings and negative statements retain their meaning. Conflicting or ambiguous evidence leaves the affected concept unresolved; the finding and substance can resolve independently, so partial rows are retained. In particular, category conflict need not prevent resolution of a single identified substance. Unsupported contextual sources retain domain-based placement, excluding drug/device exposure, with contextual coverage reported separately. `resolution.allergy` preserves supplied context and interpretation evidence; finding and substance mappings link to the same row and separate fields. Text-only statements follow primary semantic mapping. Reaction-substance fallback and `Maps to value` decomposition are not applied. Invalid supplied type/category drops that AllergyIntolerance with `allergy_type_unrecognized` or `allergy_category_unrecognized`, while other resources continue. For Observation rows placed in Measurement or Observation, numeric Quantity, Integer, and numeric-looking String values populate `value_as_number`. Comparators are represented only by Measurement.operator_concept_id. valueQuantity.value and valueInteger accept JSON numbers. Finite numeric valueString results are interpreted equivalently, including optional comparators, while preserving the original text in value_source_value. Other non-coded values populate Observation.value_as_string or Measurement.value_source_value. Coded valueCodeableConcept results resolve to `value_as_concept_id` using active standard concepts from any domain; the selected code becomes value_source_value. Unmapped coded results use 0, and an Observation's value_as_string remains empty for coded results. Text-only result concepts remain text without concept resolution. Other unsupported value[x] forms and components do not produce separate values. Quantity units on Measurement, Observation, and Specimen use exact, case-sensitive coded UCUM, including accepted OID spellings. Matching may be direct or through an active OMOP Maps to relationship; there is no UMLS bridge, text guessing, alias correction, or numeric conversion. An absent unit is null; a supplied unit without a valid standard Unit match is 0. Explicit UCUM `1` is supplied unit evidence. Quantity.code supplies unit_source_value when present, otherwise Quantity.unit. Unit mappings preserve Quantity.system/code/unit in source_system/source_code/source_name. See unit field schemas for source-concept and resolution metadata. Observation units on other clinical destinations are not resolved separately. **Specimens and devices** Specimen requires an explicit top-level Patient subject using the shared reference rules; supplied Reference.type must identify Patient. Missing collection timing or material retains a partial row with diagnostics. Material resolves against Specimen, collection quantity units against Unit, and collection.bodySite against Spec Anatomic Site. Missing material produces concept 0 without a terminology outcome; supplied unmapped material has its own outcome. Text-only sites retain text and concept 0 without a suggestion. Absent unit/site concepts are null; supplied unmapped values are 0. Specimen quantity is copied without conversion when nonnegative and free of a comparator; unusable quantities are omitted with diagnostics. Missing, partial, invalid, or conflicting collection choices leave timing unset. Parent/derived specimens require their own Patient and do not inherit missing material/dates. Parent and Measurement-to-Specimen links are not represented. `specimen_source_contexts` retains availability, identities, and original timing; SpecimenRow describes source-ID precedence and required-date limitations. For US Core Specimen 7.0.0 inputs, only the fields described here are mapped; full profile conformance is not validated. DeviceUseStatement requires an explicit emitted Patient and supports request-local Device references, including unambiguous contained Devices. Missing or unusable Device details retain a known-patient exposure with concept 0 and diagnostics. Missing type evidence has no terminology outcome; supplied unmapped type evidence has one. Inventory-only Devices produce no exposure. Each timingTiming.event produces a separate start-only exposure, even if the event date is unusable; events plus repeat rules produce only those event rows. A repeat-only schedule retains one undated row without expanding recurrence. Competing timing choices or a provably reversed Period leave both bounds unset. Partial or malformed individual dates leave their columns absent. RecordedOn and status do not supply missing use dates. Device exposure contexts group row links and source evidence per source record, with event_index for Timing events. Distinct records remain separate, including overlapping use and matching device/source identifiers; row counts do not count distinct physical devices. An unambiguous UDI-DI supplies unique_device_id; competing identifiers and production details remain in context, and production_id is unset. Device source values identify clinical/type coding, not inventory IDs. Device quantity defaults to 1 when quantity evidence is absent. Clinical quantities, doses, rates, and numeric Observation results, including numeric valueString, do not establish device counts and leave quantity omitted. device_exposure_contexts retains the original evidence; quantity_basis and diagnostics explain the result. Timing repeat count does not establish quantity. Device unit IDs are always null. DeviceUseStatement uses EHR type 32817 and has no provider or visit links; routed clinical rows retain eligible performer and same-patient visit links. **Medication and drug quantities** MedicationRequest, MedicationStatement, and MedicationAdministration accept inline medicationCodeableConcept, a request-local Medication reference, or display-text fallback when a reference cannot resolve. A reference resolving to a non-Medication is not rescued by display. MedicationDispense requires usable inline code/text or a reference resolving to a Medication with usable code/text; both choice forms together drop the dispense. Display-only or unresolved references do not establish dispensing medication identity. For MedicationDispense, context links to a supplied same-patient Encounter, and the first resolvable Practitioner/PractitionerRole performer supplies the provider. Authorizing prescriptions provide validated request-local linkage only; dispensing values come from the dispense. Orders, dispenses, and administrations emit independently without deduplication by drug. Comparable handover/preparation dates proving handover before preparation leave start timing unset with a conflict diagnostic. A completed dispense can remain partial without usable handover, and no exposure end is derived. For US Core MedicationDispense 7.0.0 inputs, only the fields described here are mapped; full profile conformance is not validated. For drug_exposure output: - MedicationRequest.dispenseRequest.numberOfRepeatsAllowed supplies refills; its positive whole-day expectedSupplyDuration supplies days_supply. - MedicationDispense.daysSupply requires positive whole coded UCUM `d` days, without a supplied comparator. Missing supply is allowed; unsupported values are omitted with diagnostics. It does not derive exposure end or refills. - Non-empty dosage text supplies newline-joined sig. Coded dosage/Immunization routes resolve against Route; conflicting routes remain unset, while codings shared by all dosage instructions can select a route. Immunization.lotNumber supplies lot_number. - MedicationRequest uses type 32838 (EHR prescription), MedicationDispense uses 32825 (EHR dispensing record), and other current sources use 32817 (EHR). These are provenance classifications, not proof of medication consumption. Direct quantities are supported at MedicationRequest.dispenseRequest.quantity, MedicationDispense.quantity, MedicationAdministration.dosage.dose, and Immunization.doseQuantity. Values must be positive finite numbers without a supplied comparator and with a supported system/code. Rates and MedicationStatement dosages do not establish a supported total quantity. The selected drug must be Clinical Drug or Branded Drug with one active, supported dose form and sufficient unambiguous vocabulary evidence. | Quantity policy | Supported RxNorm dose forms | Output meaning | | --- | --- | --- | | fixed_dose_form_count | Oral Tablet (317541), Oral Capsule (316965), Extended Release Oral Tablet (316945), Extended Release Oral Capsule (316943), Delayed Release Oral Tablet (10312), Delayed Release Oral Capsule (316995) | Count of the selected form, copied from a matching coded count or derived from ingredient amount and per-unit strength; only whole, half, or third units are supported | | clinical_injection_ingredient_amount | Injectable Solution (316949), Injectable Suspension (316950), Injection (1649574) | Ingredient amount in result_unit, copied/converted from ingredient amount or derived from volume and validated per-unit concentration | Fixed-form counts accept `TAB`/`CAP` under `http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm`, or `{tbl}`/`{Capsule}` under `http://unitsofmeasure.org`, matching the selected tablet/capsule family. Explicit counts do not require ingredient strength, including for combination products. Strength-based conversions require one ingredient strength; concentration-based strength cannot derive fixed-form counts. Minor arithmetic roundoff is normalized to a supported fraction. Ingredient amounts and injection volumes require coded UCUM, including its bare/OID-URN forms. Exact vocabulary-backed strength units, including `[U]`, are accepted. Differing-unit conversion is limited to compatible mass (`ug`, `mg`, `g`), volume (`uL`, `mL`, `L`), and milliequivalent (`meq`, `10*-3.eq`) groups. Codes are case-sensitive; free text, generic count annotations, unsupported units, and cross-dimensional conversions are not interpreted. Injection volume conversion requires explicit, consistent per-unit concentration evidence; a missing denominator alone does not establish it. Use `quantity_transformations.result_unit`: injection output is already the ingredient amount and must not be multiplied by concentration again. Unsupported formulations, quantified products, packs/prefilled syringes, unsupported fractions, or insufficient/ambiguous evidence leave quantity unset while retaining the row. QuantityTransformation.reason distinguishes omissions. The audit records each supplied direct quantity, including null/malformed input, on an emitted drug_exposure row as DIRECT, DERIVED, or OMITTED. Missing quantities, dropped resources, other destination tables, and unsupported dosage/rate paths have no audit entry. Result units, evidence, and intermediate unit conversion use the response vocabulary release; quantity audits do not affect terminology counts in Summary. **Encounter classification and components** Encounter classifications require both Coding.system and Coding.code. The following class codes are supported under `http://terminology.hl7.org/CodeSystem/v3-ActCode` or `http://hl7.org/fhir/v3/ActCode`: | Class | Visit concept | | --- | --- | | IMP | Inpatient Visit (9201) | | AMB | Outpatient Visit (9202) | | EMER | Emergency Room Visit (9203) | | VR | Telehealth (722455) | | HH | Home Visit (581476) | OBSENC has no direct class mapping. Other class/type codes require a valid standard Visit mapping in the selected release. Mapped class takes precedence; a disagreeing mapped type produces a conflict diagnostic. If class is missing or unmapped, type supplies the Visit only when all mapped type classifications agree. Codings within one type are alternative encodings. Unresolved or conflicting selection leaves concept 0 without defaulting to outpatient. Source values/concepts identify the selected original classification. An explicit Encounter.partOf can produce a child visit_detail linked to a parent visit_occurrence when both are supplied top-level Encounters, explicitly reference the same unambiguous Patient, have eligible known statuses, and form a supported two-level parent/child structure. Supplied reference types must agree. Details use their own timing, classification, and supported provider/care-site links without inheriting parent values. | Compatibility assessment | Output for the child | | --- | --- | | COMPATIBLE | visit_detail, including identical or parent-ancestor/detail-descendant Visit concepts | | UNKNOWN | Partial visit_detail with an unsupported diagnostic explaining the limitation | | INCOMPATIBLE | Independent visit_occurrence with a conflict diagnostic | `visit_component_contexts` links each assessment to the final child row and reports its concepts and vocabulary release. Assessment unavailability or malformed results fail the request with HTTP 500. An UNKNOWN assessment alone does not index a mapped row for review; primary concept 0 still does. Classifications and source dates are preserved in all outcomes. Period comparisons require matching precision and timezone presence; offset timestamps compare as instants. Timing that proves reversed or disjoint periods prevents grouping. Incomplete or incomparable timing can retain grouping with diagnostics. Overlapping periods may extend outside the parent, with a conflict diagnostic and no clipping or expansion. Unsupported references, patient/status relationships, cycles, and deeper hierarchies retain independently eligible standalone visits. Encounters with unknown, missing, or unreadable status do not qualify as components. ClassHistory, location-period segmentation, admission/discharge concepts, and inferred sequencing are not mapped. A clinical reference to a detail supplies both visit_detail_id and its parent visit_occurrence_id; a parent reference supplies only the visit ID. These links apply across all supported clinical destinations. Failed optional references retain the clinical row without the link. DeviceUseStatement has no R4 Encounter reference and receives neither link; dates alone never establish links. **Operation ID:** `fhir2omop_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "fhir_resources" ], "properties": { "vocab_version": { "type": "string", "description": "OMOP vocabulary release to use for coded concept resolution. If\nomitted or empty, the API uses its default release (`v20260829`).\nSpecify a release explicitly when reproducibility matters. The response's\n`vocab_version`, when present, identifies the release used.\n" }, "fhir_resources": { "type": "object", "additionalProperties": true, "description": "A single FHIR R4 resource or Bundle containing at least one top-level Patient.\nSupported row-producing sources: Patient, Location, Organization,\nHealthcareService, Practitioner, PractitionerRole, Encounter, Specimen,\nDeviceUseStatement, Condition, Procedure, MedicationRequest,\nMedicationStatement, MedicationAdministration, MedicationDispense,\nImmunization, Observation, and AllergyIntolerance.\nMedication and Device supply referenced details without independent rows;\nunsupported resource types are ignored.\n\nEach concept field submitted for vocabulary resolution supports at most\n1,000 source items: each coding and any non-empty PractitionerRole.specialty\ntext (including whitespace-only text) count as one item. Exceeding the\nper-field limit rejects the entire request with HTTP 400.\n" } } } ``` **Example:** ```json { "fhir_resources": { "resourceType": "Bundle", "type": "collection", "entry": [ { "resource": { "resourceType": "Patient", "id": "patient-1", "gender": "female", "birthDate": "1985-07-22" } }, { "resource": { "resourceType": "Condition", "id": "condition-1", "subject": { "reference": "Patient/patient-1" }, "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "44054006", "display": "Type 2 diabetes mellitus" } ] }, "onsetDateTime": "2024-01-15" } }, { "resource": { "resourceType": "MedicationRequest", "id": "medreq-1", "status": "active", "intent": "order", "subject": { "reference": "Patient/patient-1" }, "medicationReference": { "reference": "#med0" }, "authoredOn": "2024-01-16", "contained": [ { "resourceType": "Medication", "id": "med0", "code": { "coding": [ { "system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "860975", "display": "metformin hydrochloride 500 MG" } ] } } ] } } ] } } ``` #### Responses **200** - FHIR resources mapped to OMOP CDM v5.4 Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "tables": { "type": "object", "description": "OMOP CDM v5.4 rows grouped by destination table. IDs are sequential and\nscoped to one response; they are not stable keys across requests.\nFields with no value are unset (omitted from the row), except concept\nIDs reported as `0` and the following nullable concept fields, which are\nalways present: `unit_concept_id` on Measurement, Observation, and\nSpecimen rows, `unit_source_concept_id` on Measurement rows, and\n`anatomic_site_concept_id` on Specimen rows. These nullable fields are\n`null` when the source value is absent and `0` when supplied but unmapped.\nDevice exposure `unit_concept_id` and `unit_source_concept_id` are always\npresent as `null`.\nEach `*_datetime` comes from the same source as its `*_date` and is set\nonly when that source has a time of day.\n", "properties": { "location": { "type": "array", "items": { "type": "object", "properties": { "location_id": { "type": "integer", "format": "int64" }, "address_1": { "type": "string" }, "address_2": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "zip": { "type": "string" }, "county": { "type": "string" }, "location_source_value": { "type": "string" }, "country_concept_id": { "type": "integer", "format": "int64" }, "country_source_value": { "type": "string" }, "latitude": { "type": "number", "format": "double" }, "longitude": { "type": "number", "format": "double" } } } }, "care_site": { "type": "array", "items": { "type": "object", "properties": { "care_site_id": { "type": "integer", "format": "int64" }, "care_site_name": { "type": "string" }, "place_of_service_concept_id": { "type": "integer", "format": "int64" }, "location_id": { "type": "integer", "format": "int64" }, "care_site_source_value": { "type": "string" }, "place_of_service_source_value": { "type": "string" } } } }, "provider": { "type": "array", "items": { "type": "object", "properties": { "provider_id": { "type": "integer", "format": "int64" }, "provider_name": { "type": "string" }, "npi": { "type": "string", "description": "Single distinct confirmed individual NPI from Practitioner.identifier or,\nfor a role-only provider, PractitionerRole.identifier or practitioner.identifier.\nRecognized systems are http://hl7.org/fhir/sid/us-npi,\nurn:oid:2.16.840.1.113883.4.6, and 2.16.840.1.113883.4.6.\nClassification trims whitespace and validates ten digits and the NPI check\ndigit; this field preserves the original value. Blank and UNK/UNKNOWN markers\nare missing, ignoring case and surrounding whitespace. Organization, invalid,\nunconfirmed, and conflicting NPIs do not populate this field.\n" }, "dea": { "type": "string" }, "specialty_concept_id": { "type": "integer", "format": "int64", "description": "Standard Provider concept shared by every distinct supplied role specialty; otherwise `0`. Inputs resolve independently, without frequency or hierarchy selection." }, "care_site_id": { "type": "integer", "format": "int64" }, "year_of_birth": { "type": "integer", "description": "Year from Practitioner.birthDate." }, "gender_concept_id": { "type": "integer", "format": "int64", "description": "For recorded `Practitioner.gender`, `male` and `female` resolve to validated OMOP Gender concepts. `other`, `unknown`, and absent values remain `0`." }, "provider_source_value": { "type": "string", "description": "The single confirmed individual NPI, including for role-only providers and\nwhen conflicting identity attributes keep an NPI group in separate rows.\nCheck identity diagnostics and compatibility before deduplicating across responses.\n\nWithout an unambiguous individual NPI, the Practitioner's source identity is\nused, excluding missing markers and unconfirmed NPIs. Role-only providers\nrequire a confirmed NPI. Without a source identity, `@provider-index:N`\nmarks a response-local provider ordinal. Contained Practitioners use\n`PractitionerRole/#`; a role without a source\nidentity uses `@role-index:N` as its response-local scope. These fallbacks\nare not global identity guarantees; row IDs and merging are request-local.\n" }, "specialty_source_value": { "type": "string", "description": "Supplied specialty text (or coding display/code) when source values across roles agree, including unresolved text. Conflicting source values remain in provider_role_contexts and mappings." }, "specialty_source_concept_id": { "type": "integer", "format": "int64", "description": "Shared input OMOP source concept when all specialties agree on both target and source concept. Text, UMLS routes, conflicting inputs, or differing source concepts leave `0`." }, "gender_source_value": { "type": "string", "description": "The recorded FHIR administrative-gender value for this Provider." }, "gender_source_concept_id": { "type": "integer", "format": "int64", "description": "Remains `0` because FHIR administrative-gender codes do not themselves identify OMOP source concepts." } } } }, "person": { "type": "array", "items": { "type": "object", "properties": { "person_id": { "type": "integer", "format": "int64" }, "gender_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Gender concept for sex at birth, from US Core birth sex when supplied, otherwise from Patient `gender` `male` or `female`. `0` for absent, unknown, other, unsupported, or conflicting values." }, "year_of_birth": { "type": "integer", "description": "Year from Patient.birthDate." }, "month_of_birth": { "type": "integer", "description": "Month from Patient.birthDate, when it supplies one." }, "day_of_birth": { "type": "integer", "description": "Day from Patient.birthDate, when it supplies one." }, "birth_datetime": { "type": "string", "description": "Not set; Patient.birthDate has no time of day." }, "race_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Race concept from a US Core race OMB category; `1546847` (More than one race) when more than one distinct race resolves, with each race in an `observation` row. `0` when no category resolves." }, "ethnicity_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Ethnicity concept from the US Core ethnicity OMB category. `0` when absent, unresolved, or conflicting; never derived from race." }, "location_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "person_source_value": { "type": "string", "description": "Patient.id, or the first non-empty Patient.identifier.value when id is absent. Omitted when neither is available." }, "gender_source_value": { "type": "string", "description": "The selected sex-at-birth source code: the US Core birth sex `valueCode`, or Patient `gender` when no birth sex is supplied. Conflicting birth sex values are joined with `|`; empty when the birth sex has no `valueCode`." }, "gender_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of the selected sex-at-birth code, when that code is itself an OMOP source concept; `0` otherwise, as for FHIR administrative gender codes." }, "race_source_value": { "type": "string", "description": "Every supplied US Core race category and detailed code, joined with `|` in source order, or the extension text when no code is supplied." }, "race_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of a single resolved race code, when that code is itself an OMOP source concept; `0` otherwise, including when more than one race resolves." }, "ethnicity_source_value": { "type": "string", "description": "Every supplied US Core ethnicity category and detailed code, joined with `|` in source order, or the extension text when no code is supplied." }, "ethnicity_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of the resolved ethnicity code, when that code is itself an OMOP source concept; `0` otherwise." } } } }, "death": { "type": "array", "items": { "type": "object", "properties": { "person_id": { "type": "integer", "format": "int64" }, "death_date": { "type": "string", "description": "Date from Patient.deceasedDateTime; unset for a boolean-only or partial value." }, "death_datetime": { "type": "string" }, "death_type_concept_id": { "type": "integer", "format": "int64" }, "cause_concept_id": { "type": "integer", "format": "int64" }, "cause_source_value": { "type": "string" }, "cause_source_concept_id": { "type": "integer", "format": "int64" } } } }, "observation_period": { "type": "array", "items": { "type": "object", "properties": { "observation_period_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "observation_period_start_date": { "type": "string", "description": "Earliest date selected by the source timing rules from the person's\nvisit and clinical rows not listed in rows_for_review, plus Specimen\nand Death rows in this request. No period row is returned without\nqualifying dates; not enrollment evidence.\n" }, "observation_period_end_date": { "type": "string", "description": "Latest date selected by the source timing rules from the person's\nvisit and clinical rows not listed in rows_for_review, plus Specimen\nand Death rows in this request. Includes source end dates from\nunindexed rows even when the output table has no end column.\nNo period row is returned without qualifying dates; not enrollment evidence.\n" }, "period_type_concept_id": { "type": "integer", "format": "int64" } } } }, "visit_occurrence": { "type": "array", "items": { "type": "object", "properties": { "visit_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "visit_concept_id": { "type": "integer", "format": "int64" }, "visit_start_date": { "type": "string", "description": "Date from Encounter.period.start." }, "visit_start_datetime": { "type": "string" }, "visit_end_date": { "type": "string", "description": "Date from Encounter.period.end." }, "visit_end_datetime": { "type": "string" }, "visit_type_concept_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "visit_source_value": { "type": "string" }, "visit_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept for the selected Encounter.class or Encounter.type coding when available; `0` when the source coding has no OMOP source concept, including the HL7 encounter class codes listed above." } } } }, "visit_detail": { "type": "array", "items": { "type": "object", "description": "An explicitly supplied component Encounter linked to its same-patient parent visit. Missing dates remain absent for downstream load completion.", "required": [ "visit_detail_id", "person_id", "visit_detail_concept_id", "visit_detail_type_concept_id", "visit_detail_source_concept_id", "visit_occurrence_id" ], "properties": { "visit_detail_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "visit_detail_concept_id": { "type": "integer", "format": "int64" }, "visit_detail_start_date": { "type": "string", "description": "Date from Encounter.period.start." }, "visit_detail_start_datetime": { "type": "string" }, "visit_detail_end_date": { "type": "string", "description": "Date from Encounter.period.end." }, "visit_detail_end_datetime": { "type": "string" }, "visit_detail_type_concept_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "visit_detail_source_value": { "type": "string" }, "visit_detail_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept for the selected Encounter.class or Encounter.type coding when available; `0` when the source coding has no OMOP source concept, including the HL7 encounter class codes listed above." }, "visit_occurrence_id": { "type": "integer", "format": "int64", "description": "The emitted same-patient overarching visit referenced by this component." } } } }, "condition_occurrence": { "type": "array", "items": { "type": "object", "properties": { "condition_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "condition_concept_id": { "type": "integer", "format": "int64" }, "condition_start_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For a Condition, onsetDateTime or onsetPeriod.start, otherwise recordedDate; see the endpoint's timing sources for other resources." }, "condition_start_datetime": { "type": "string" }, "condition_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For a Condition, abatementDateTime or abatementPeriod.end; see the endpoint's timing sources for other resources." }, "condition_end_datetime": { "type": "string" }, "condition_type_concept_id": { "type": "integer", "format": "int64" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "condition_source_value": { "type": "string" }, "condition_source_concept_id": { "type": "integer", "format": "int64" }, "condition_status_source_value": { "type": "string" } } } }, "drug_exposure": { "type": "array", "items": { "type": "object", "properties": { "drug_exposure_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "drug_concept_id": { "type": "integer", "format": "int64" }, "drug_exposure_start_date": { "type": "string", "description": "Start date selected by the source resource's timing rules, such as effective[x], occurrenceDateTime, MedicationRequest.authoredOn, or MedicationDispense.whenHandedOver; see the endpoint's timing sources for all supported resources." }, "drug_exposure_start_datetime": { "type": "string" }, "drug_exposure_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For medication resources, an explicit effectivePeriod.end or the start date of a single-event administration or immunization; see the endpoint's timing sources for other resources." }, "drug_exposure_end_datetime": { "type": "string" }, "verbatim_end_date": { "type": "string", "description": "Date from an explicit FHIR Period.end only; inferred same-day ends are not verbatim source values." }, "drug_type_concept_id": { "type": "integer", "format": "int64", "description": "MedicationDispense uses 32825 (EHR dispensing record); MedicationRequest uses 32838 (EHR prescription). Other current resources use 32817 (EHR). These identify record provenance, not proof of medication consumption." }, "stop_reason": { "type": "string" }, "refills": { "type": "integer", "format": "int64", "description": "Direct MedicationRequest.dispenseRequest.numberOfRepeatsAllowed value, when supplied." }, "days_supply": { "type": "integer", "format": "int64", "description": "Direct positive whole-day MedicationRequest.dispenseRequest.expectedSupplyDuration or coded UCUM-day MedicationDispense.daysSupply; never derived from drug quantity, dosage, refills, or timing. Does not derive an exposure end date." }, "quantity": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Formulation-specific quantity from a direct MedicationRequest dispense quantity, MedicationDispense quantity, MedicationAdministration dose, or Immunization dose quantity. Under fixed_dose_form_count this is a matched coded tablet/capsule count copied directly, or an ingredient amount divided by per-unit strength. Under clinical_injection_ingredient_amount this is the ingredient amount, converted to the ingredient unit or derived using explicit concentration evidence; exact-unit ingredient amounts are copied directly. See the endpoint's supported dose forms and prerequisites; quantity_transformations identifies the policy, source, calculation evidence, intermediate UCUM conversion, and output unit, or explains why a supplied quantity was omitted." }, "sig": { "type": "string", "description": "Newline-joined non-empty FHIR Dosage.text instructions in source order." }, "route_concept_id": { "type": "integer", "format": "int64", "description": "Target-valid OMOP Route concept for an unambiguous coded FHIR route; `0` for an unmapped coded route, omitted for absent, text-only, or conflicting routes." }, "lot_number": { "type": "string", "description": "Direct FHIR R4 Immunization.lotNumber value." }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "drug_source_value": { "type": "string" }, "drug_source_concept_id": { "type": "integer", "format": "int64" }, "route_source_value": { "type": "string", "description": "Selected source coding or text for an unambiguous FHIR route." } } } }, "procedure_occurrence": { "type": "array", "items": { "type": "object", "properties": { "procedure_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "procedure_concept_id": { "type": "integer", "format": "int64" }, "procedure_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For a Procedure, performedDateTime or performedPeriod.start; see the endpoint's timing sources for other resources." }, "procedure_datetime": { "type": "string" }, "procedure_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For a Procedure, performedPeriod.end; see the endpoint's timing sources for other resources." }, "procedure_end_datetime": { "type": "string" }, "procedure_type_concept_id": { "type": "integer", "format": "int64" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "procedure_source_value": { "type": "string" }, "procedure_source_concept_id": { "type": "integer", "format": "int64" } } } }, "measurement": { "type": "array", "items": { "type": "object", "required": [ "unit_concept_id", "unit_source_concept_id" ], "properties": { "measurement_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "measurement_concept_id": { "type": "integer", "format": "int64" }, "measurement_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For an Observation, effectiveDateTime, effectivePeriod.start, or effectiveInstant; see the endpoint's timing sources for other resources." }, "measurement_datetime": { "type": "string" }, "measurement_type_concept_id": { "type": "integer", "format": "int64" }, "value_as_number": { "type": "number", "format": "double" }, "operator_concept_id": { "type": "integer", "format": "int64", "description": "OMOP \"Meas Value Operator\" standard concept qualifying value_as_number (<, <=, >, >=), parsed from a numeric-string value or a FHIR valueQuantity.comparator. 0 when no operator (a bare number)." }, "value_as_concept_id": { "type": "integer", "format": "int64" }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied but unmapped units, null for absent units. Always present in JSON." }, "range_low": { "type": "number", "format": "double" }, "range_high": { "type": "number", "format": "double" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "measurement_source_value": { "type": "string" }, "measurement_source_concept_id": { "type": "integer", "format": "int64" }, "unit_source_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "OMOP source concept ID corresponding to Quantity.system/code; 0 for supplied units without a matching source concept, null for absent units. Always present in JSON." }, "unit_source_value": { "type": "string", "description": "Original Quantity.code if supplied, otherwise Quantity.unit; human-readable unit text is preserved in the unit mapping's source_name." }, "value_source_value": { "type": "string" } } } }, "device_exposure": { "type": "array", "items": { "type": "object", "required": [ "device_exposure_id", "person_id", "device_concept_id", "device_type_concept_id", "device_source_concept_id", "unit_concept_id", "unit_source_concept_id" ], "properties": { "device_exposure_id": { "type": "integer", "format": "int64", "description": "Request-local exposure identity, distinct from physical or model device identity." }, "person_id": { "type": "integer", "format": "int64", "description": "Emitted Patient identity." }, "device_concept_id": { "type": "integer", "format": "int64", "description": "Validated standard Device concept; 0 for missing or unresolved type evidence." }, "device_exposure_start_date": { "type": "string", "format": "date", "description": "Source use start at day precision; absent when unknown or unusable." }, "device_exposure_start_datetime": { "type": "string", "description": "Source local wall-clock start, without UTC offset; absent for date-only input.", "example": "2026-01-01T23:30:00" }, "device_exposure_end_date": { "type": "string", "format": "date", "description": "Explicit source end; absent when unknown or unusable." }, "device_exposure_end_datetime": { "type": "string", "description": "Source local wall-clock end, without UTC offset; absent for date-only input.", "example": "2026-01-03T08:00:00" }, "device_type_concept_id": { "type": "integer", "format": "int64", "description": "Coarse source provenance; DeviceUseStatement uses generic EHR 32817." }, "unique_device_id": { "type": "string", "description": "Unambiguous supplied UDI-DI; competing values remain in source context." }, "production_id": { "type": "string", "description": "Unset; supplied production components and carriers remain in source context." }, "quantity": { "type": "integer", "format": "int64", "description": "Default 1 when quantity evidence is absent; otherwise omitted. See device_exposure_contexts.quantity_basis." }, "provider_id": { "type": "integer", "format": "int64", "description": "Compatible explicit performer on routed rows; absent for DeviceUseStatement and reporting-only actors." }, "visit_occurrence_id": { "type": "integer", "format": "int64", "description": "Explicit emitted same-patient visit for routed rows; absent for DeviceUseStatement." }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component for routed rows, with its overarching visit_occurrence_id; absent for DeviceUseStatement." }, "device_source_value": { "type": "string", "description": "Original selected type or clinical code, or supplied text; never a resource/inventory identifier." }, "device_source_concept_id": { "type": "integer", "format": "int64", "description": "Original source concept when established by vocabulary resolution; otherwise 0." }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Always null." }, "unit_source_value": { "type": "string", "description": "Unset; unsupported clinical units remain in source context." }, "unit_source_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Always null." } } } }, "specimen": { "type": "array", "items": { "type": "object", "required": [ "specimen_id", "person_id", "specimen_concept_id", "specimen_type_concept_id", "unit_concept_id", "anatomic_site_concept_id" ], "properties": { "specimen_id": { "type": "integer", "format": "int64", "description": "Request-local generated row identity; distinct from specimen_source_id." }, "person_id": { "type": "integer", "format": "int64", "description": "Explicitly resolved top-level Patient in this response." }, "specimen_concept_id": { "type": "integer", "format": "int64", "description": "Material validated against Specimen; 0 for supplied unmapped material or absent material. Absence has a linked type diagnostic and no mapping/summary count; supplied unmapped material has a vocabulary mapping outcome." }, "specimen_type_concept_id": { "type": "integer", "format": "int64", "description": "32817 (EHR record provenance), independent of material and availability." }, "specimen_date": { "type": "string", "description": "Collection date from collectedDateTime or collectedPeriod.start at day\nprecision. Missing, partial, invalid, or conflicting timing leaves it absent\nwith a linked diagnostic; callers must handle required-date completion for\nCDM loading.\n" }, "specimen_datetime": { "type": "string", "description": "Collection local wall-clock time, only when supplied; no fabricated time or offset conversion." }, "quantity": { "type": "number", "format": "double", "description": "Exact nonnegative collection.quantity.value, without comparator or numeric conversion." }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied unmapped units, null for absence." }, "anatomic_site_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Spec Anatomic Site concept for a coded site; 0 for a supplied unmapped or text-only site, null for absence. Text-only sites retain source text without a concept suggestion." }, "specimen_source_id": { "type": "string", "description": "Resource id, first valued identifier, accession value, then fullUrl. All source identities and selection path are in specimen_source_contexts. Kept verbatim; downstream loaders must handle CDM varchar(50) limits." }, "specimen_source_value": { "type": "string", "description": "Selected bare material code or source text." }, "unit_source_value": { "type": "string", "description": "Exact Quantity.code when supplied, otherwise Quantity.unit." }, "anatomic_site_source_value": { "type": "string", "description": "Selected bare bodySite code or source text." } } } }, "observation": { "type": "array", "items": { "type": "object", "required": [ "unit_concept_id" ], "properties": { "observation_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "observation_concept_id": { "type": "integer", "format": "int64" }, "observation_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For an Observation, effectiveDateTime, effectivePeriod.start, or effectiveInstant. For an AllergyIntolerance, recordedDate, otherwise onsetDateTime or onsetPeriod.start; see the endpoint's timing sources for other resources." }, "observation_datetime": { "type": "string" }, "observation_type_concept_id": { "type": "integer", "format": "int64" }, "value_as_number": { "type": "number", "format": "double" }, "value_as_string": { "type": "string" }, "value_as_concept_id": { "type": "integer", "format": "int64" }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied but unmapped units, null for absent units. Always present in JSON." }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "observation_source_value": { "type": "string" }, "observation_source_concept_id": { "type": "integer", "format": "int64", "description": "For coded AllergyIntolerance rows, the known OMOP identity of the original coding rendered in observation_source_value, even when the finding is unresolved. 0 when no original source identity is known; the configured contextual finding is not a source concept." }, "unit_source_value": { "type": "string", "description": "Original Quantity.code if supplied, otherwise Quantity.unit; human-readable unit text is preserved in the unit mapping's source_name." }, "value_source_value": { "type": "string" } } } } } }, "visit_component_contexts": { "type": "array", "description": "Compatibility assessments for explicit Encounter components, linked to the\nfinal detail or standalone visit. Omitted when no component is assessed;\nassessments do not contribute to terminology counts in summary.\n", "items": { "type": "object", "required": [ "parent_reference", "omop_table", "omop_id", "assessment" ], "properties": { "resource_id": { "type": "string", "description": "Source child Encounter ID, when supplied." }, "full_url": { "type": "string", "description": "Source child Bundle entry fullUrl, when supplied." }, "parent_reference": { "type": "string", "description": "Supplied Encounter.partOf.reference, preserved even when grouping is not applied." }, "omop_table": { "type": "string", "enum": [ "visit_detail", "visit_occurrence" ], "description": "Final table containing the emitted child row." }, "omop_id": { "type": "integer", "format": "int64", "description": "Request-local ID of the emitted child row within omop_table." }, "assessment": { "type": "object", "required": [ "parent_concept_id", "detail_concept_id", "status", "reason_code", "vocab_version" ], "description": "Compatibility of the selected parent/detail Visit concepts under the CDM\nsame-concept/descendant convention. Compatible concepts must be active and\nstandard in the Visit domain. An assessment describes classification\ncompatibility, not the clinical truth of the source partOf relationship.\n", "properties": { "parent_concept_id": { "type": "integer", "format": "int64", "description": "Selected parent Visit concept assessed; 0 means unresolved." }, "detail_concept_id": { "type": "integer", "format": "int64", "description": "Selected candidate detail concept assessed; 0 means unresolved." }, "status": { "type": "string", "enum": [ "COMPATIBLE", "INCOMPATIBLE", "UNKNOWN" ] }, "reason_code": { "type": "string", "enum": [ "SAME_CONCEPT", "DESCENDANT", "NOT_DESCENDANT", "UNRESOLVED_CONCEPT", "CONCEPT_NOT_FOUND", "INACTIVE_CONCEPT", "NONSTANDARD_CONCEPT", "WRONG_DOMAIN", "ANCESTRY_UNAVAILABLE" ], "description": "SAME_CONCEPT and DESCENDANT are compatible outcomes. NOT_DESCENDANT means\nthe usable concepts lack the required parent-ancestor/detail-descendant\nrelationship. Other reasons are unknown outcomes: an unresolved or unusable\nconcept, or insufficient ancestry evidence. Assessment unavailability or\nmalformed results fail the request with HTTP 500 rather than returning\nan UNKNOWN result.\n" }, "invalid_concept_role": { "type": "string", "enum": [ "parent", "detail" ], "description": "Identifies the unusable concept for UNKNOWN concept-validation outcomes.\nAbsent for ANCESTRY_UNAVAILABLE and compatible/incompatible outcomes.\n" }, "min_levels_of_separation": { "type": "integer", "description": "Present only for compatible outcomes; 0 for identity, positive for a descendant relationship." }, "vocab_version": { "type": "string", "description": "Concrete vocabulary version used for both selected concepts and this assessment; matches the response vocab_version." } } } } } }, "quantity_transformations": { "type": "array", "description": "Audits supplied direct quantities on emitted drug_exposure rows, including\nderivations and omissions. Omitted when no applicable quantity was supplied.\nUses the response vocabulary release and does not affect terminology counts\nin summary. Example concept IDs are illustrative.\n", "items": { "type": "object", "description": "Audit of one supplied quantity on an emitted drug_exposure row. All evidence uses the response's vocab_version. Result and result_unit are present only for successful outcomes; reason is present only for OMITTED. Policy is present once a supported formulation policy was selected.", "required": [ "resource_type", "resource_id", "source_path", "source_quantity", "omop_table", "omop_field", "omop_id", "outcome" ], "properties": { "resource_type": { "type": "string", "enum": [ "MedicationRequest", "MedicationDispense", "MedicationAdministration", "Immunization" ] }, "resource_id": { "type": "string", "description": "Source FHIR resource id; empty when none was supplied." }, "source_path": { "type": "string", "enum": [ "dispenseRequest.quantity", "quantity", "dosage.dose", "doseQuantity" ], "description": "Exact source element path relative to resource_type." }, "source_quantity": { "nullable": true, "description": "Original supplied Quantity object, including value, system, code, unit, comparator, and other supplied fields. Explicit nulls and malformed values are also preserved as supplied." }, "omop_table": { "type": "string", "enum": [ "drug_exposure" ] }, "omop_field": { "type": "string", "enum": [ "quantity" ] }, "omop_id": { "type": "integer", "format": "int64", "description": "The drug_exposure_id of the row in this response." }, "outcome": { "type": "string", "enum": [ "DIRECT", "DERIVED", "OMITTED" ], "description": "DIRECT copies a matched fixed-form count or an ingredient amount in the same unit; DERIVED converts units or calculates a dose-form count or ingredient amount under the named policy; OMITTED leaves quantity unset while retaining the row." }, "policy": { "type": "string", "enum": [ "fixed_dose_form_count", "clinical_injection_ingredient_amount" ], "description": "The formulation policy documented in the endpoint description. May be present for an omission occurring after policy selection." }, "reason": { "type": "string", "enum": [ "unsupported_quantity", "unsupported_comparator", "unsupported_unit", "drug_unresolved", "missing_drug_evidence", "incomplete_drug_evidence", "ambiguous_drug_evidence", "missing_classification", "unsupported_drug_class", "unsupported_dose_form", "unsupported_strength", "unit_mismatch", "unsupported_fraction", "invalid_result" ], "description": "Stable omission reason:\n- unsupported_quantity: supplied value is not a Quantity object with a positive finite numeric value.\n- unsupported_comparator: a comparator field was supplied.\n- unsupported_unit: source system/code does not identify a UCUM-coded quantity or a supported HL7 TAB/CAP count.\n- drug_unresolved: no standard drug concept was resolved.\n- missing_drug_evidence: formulation and strength evidence is unavailable.\n- incomplete_drug_evidence: required vocabulary evidence is missing or invalid.\n- ambiguous_drug_evidence: more than one dose form exists, or more than one strength exists for a conversion requiring strength. Direct counts allow combination products.\n- missing_classification: the selected drug's concept class is unavailable.\n- unsupported_drug_class: the drug is outside Clinical Drug or Branded Drug, including quantified products and packs.\n- unsupported_dose_form: the dose form has no supported classification for these policies.\n- unsupported_strength: strength does not establish the selected policy, including missing, non-positive, non-finite, or conflicting values or an absent/unsupported denominator basis for volume conversion.\n- unit_mismatch: the source neither matches a validated vocabulary-backed strength unit nor converts within the documented supported unit groups, or an explicit count disagrees with the selected tablet/capsule form.\n- unsupported_fraction: a fixed-form count is not whole units or multiples of one-half or one-third.\n- invalid_result: arithmetic does not produce a positive finite result.\n" }, "evidence": { "type": "object", "description": "Available selected-drug, dose-form, and single-ingredient strength evidence. Missing or ambiguous evidence is not replaced with an arbitrary value. On successful outcomes these fields explain the named policy's calculation.", "required": [ "drug_concept_id" ], "properties": { "drug_concept_id": { "type": "integer", "format": "int64" }, "drug_concept_class": { "type": "string" }, "dose_form": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "strength": { "type": "object", "description": "Single-ingredient strength evidence: amount is ingredient per fixed unit;\nnumerator/denominator describe concentration. Missing raw values remain\nabsent without defaults. denominator_basis records the interpretation of\nthe denominator. Box-size/refill arithmetic is not applied.\n", "required": [ "ingredient_concept_id" ], "properties": { "ingredient_concept_id": { "type": "integer", "format": "int64" }, "amount_value": { "type": "number", "format": "double" }, "amount_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "numerator_value": { "type": "number", "format": "double" }, "numerator_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "denominator_value": { "type": "number", "format": "double" }, "denominator_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "denominator_basis": { "type": "object", "description": "Interpretation of the vocabulary denominator, retained for audit even when\nconversion is omitted. PER_UNIT denotes a normalized per-unit concentration;\nQUANTIFIED_TOTAL supplies an explicit product total. NOT_APPLICABLE and\nUNKNOWN supply no basis value. Only PER_UNIT supports injection volume\nconversion. Omitted when no basis is supplied.\n", "required": [ "kind" ], "properties": { "kind": { "type": "string", "enum": [ "PER_UNIT", "QUANTIFIED_TOTAL", "NOT_APPLICABLE", "UNKNOWN" ] }, "value": { "type": "number", "format": "double", "description": "Original numeric denominator-basis value, including zero or negative values retained for audit. Successful volume-to-ingredient conversion requires kind PER_UNIT and value 1." } } } } } } }, "unit_conversion": { "type": "object", "description": "Successful case-sensitive UCUM conversion of the source magnitude into a\nsupported strength unit. Present only when the unit code changes. The result\nis an intermediate value, not the linked row's quantity, and can remain\npresent when a later policy check omits that quantity.\n", "required": [ "source_code", "result", "result_unit" ], "properties": { "source_code": { "type": "string", "description": "Original UCUM code from source_quantity.code." }, "result": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Original source magnitude converted to result_unit, before strength arithmetic." }, "result_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } } } }, "result": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Same numeric value as the linked row's quantity." }, "result_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } } } }, "example": [ { "resource_type": "MedicationRequest", "resource_id": "tablet-order", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 1000, "system": "http://unitsofmeasure.org", "code": "mg" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 1, "outcome": "DERIVED", "policy": "fixed_dose_form_count", "evidence": { "drug_concept_id": 100, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 300, "amount_value": 500, "amount_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } } }, "result": 2, "result_unit": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" } }, { "resource_type": "MedicationAdministration", "resource_id": "injection-dose", "source_path": "dosage.dose", "source_quantity": { "value": 80, "system": "http://unitsofmeasure.org", "code": "mL" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 2, "outcome": "DERIVED", "policy": "clinical_injection_ingredient_amount", "evidence": { "drug_concept_id": 101, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 201, "code": "316949", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 301, "numerator_value": 2, "numerator_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" }, "denominator_basis": { "kind": "PER_UNIT", "value": 1 }, "denominator_unit": { "concept_id": 401, "code": "mL", "vocabulary_id": "UCUM" } } }, "result": 160, "result_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } }, { "resource_type": "MedicationRequest", "resource_id": "counted-tablets", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 30, "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 4, "outcome": "DIRECT", "policy": "fixed_dose_form_count", "evidence": { "drug_concept_id": 100, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 300, "amount_value": 500, "amount_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } } }, "result": 30, "result_unit": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" } }, { "resource_type": "MedicationRequest", "resource_id": "free-text-unit", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 2, "unit": "tablet" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 3, "outcome": "OMITTED", "reason": "unsupported_unit" } ] }, "rows_for_review": { "type": "array", "description": "Index of clinical rows with uncertain source status and/or primary concept 0,\nfollowing the endpoint's eligibility policy. Each entry identifies an existing\nrow in tables; payloads are not moved or duplicated. Omitted when empty.\nUnresolved secondary units, routes, result values, or alternate codings alone\ndo not index a mapped row. Administrative/demographic, Specimen, and Death\nrows are not indexed.\n\nConsumers select or filter the linked table rows. If a selected row points\nto a visit or detail marked for exclusion, either keep that target or clear\nthe row's optional visit_occurrence_id / visit_detail_id links in the load\ncopy. Each included detail requires its parent visit; keep that parent or\nexclude the detail. Returned observation periods exclude indexed dates;\nrecompute them for a selected load if needed. Indexed rows may still lack\nCDM-required fields.\n", "items": { "type": "object", "description": "Metadata for one existing shaped row in tables. omop_table and omop_id\nform its unique response-local row key, also used by mappings and\ndiagnostics. One entry per indexed row, even with multiple reasons.\n", "required": [ "resource_type", "resource_id", "omop_table", "omop_id", "reasons" ], "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "source_full_url": { "type": "string", "description": "Original Bundle entry fullUrl, when supplied." }, "omop_table": { "type": "string" }, "omop_id": { "type": "integer", "format": "int64" }, "reasons": { "type": "array", "items": { "type": "string", "enum": [ "condition_verification_unconfirmed", "condition_verification_provisional", "condition_verification_differential", "condition_verification_unrecognized", "encounter_status_unknown", "encounter_status_unrecognized", "medication_statement_status_unknown", "observation_status_unknown", "procedure_status_unknown", "primary_concept_unresolved" ] } }, "source_statuses": { "type": "object", "description": "Supplied status, verificationStatus, and clinicalStatus fields copied\nverbatim from FHIR, including nulls or unreadable JSON values. Missing\nfields have no key. No inferred status is supplied.\n", "additionalProperties": true } } } }, "mappings": { "type": "array", "description": "Source-coding and text outcomes linked to emitted rows. Primary concepts,\ncoded routes/results, supplied Quantity units, and specimen sites have\nseparate entries; absent units/sites have none. Text-only sites and units\ncan have unmapped outcomes without vocabulary resolution.\n\nValues or routes retained outside a compatible destination column omit\nomop_field and have selected: false. Demographic entries link to their\nPerson field or emitted race Observation. See MappingEntry for selection\nand provenance semantics, and Summary for field-level counting.\n", "items": { "type": "object", "description": "Outcome for one source coding or supplied text, including source information\nretained without resolution. omop_table and omop_id identify the emitted row;\nomop_field identifies its populated concept column when applicable. A field\ncan have multiple coding entries sharing one resolution outcome. selected\nidentifies the source coding used in the linked row's source-value column.\n", "required": [ "selected" ], "example": { "resource_type": "Condition", "resource_id": "condition-123", "omop_table": "condition_occurrence", "omop_id": 7, "omop_field": "condition_concept_id", "source_system": "https://your-org.example/custom-codes", "source_code": "DX-123", "source_name": "Type 2 diabetes mellitus", "target_vocabulary": "SNOMED", "target_code": "44054006", "mapping_status": "MAPPED", "selected": true, "resolution": { "status": "RESOLVED", "semantic_mapping": { "status": "MAPPED", "vocab_version": "v20260829" } } }, "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "omop_table": { "type": "string" }, "omop_id": { "type": "integer", "format": "int64", "description": "The id of the OMOP row this coding produced (e.g. `condition_occurrence_id`),\nwithin `omop_table`. A resource with multiple codings yields one entry\nper coding, all sharing this id.\n" }, "omop_field": { "type": "string", "description": "The OMOP concept-ID field populated from this source coding, such as `condition_concept_id`, `route_concept_id`, or `race_concept_id`. Omitted when the entry preserves source information without populating a row column." }, "source_system": { "type": "string" }, "source_code": { "type": "string" }, "source_name": { "type": "string" }, "source_coding_index": { "type": "integer", "minimum": 0, "description": "Zero-based index of this coding in its originating specialty entry's coding array. When specialty audit is available, it also identifies the corresponding resolution.specialty_resolution.coding_results outcome. Present only for coded specialty mappings, including empty Coding objects; these mappings retain the supplied coding order." }, "target_vocabulary": { "type": "string" }, "target_code": { "type": "string", "description": "The standard concept's own code: the source code itself for an\nALREADY_STANDARD row, the standard concept's code for a MAPPED row,\nor the suggested code for an UNCHECKED row. Omitted for UNMAPPED\nrows.\n" }, "target_name": { "type": "string" }, "mapping_status": { "type": "string", "enum": [ "ALREADY_STANDARD", "MAPPED", "UNCHECKED", "UNMAPPED" ], "description": "ALREADY_STANDARD: the source coding is already an OMOP standard concept.\nMAPPED: coding or descriptive text resolved to a standard concept.\nUNCHECKED: a suggestion is unvalidated and concept ID remains 0.\nUNMAPPED: no valid target was selected, or information was retained without\nresolution as explained in note.\n\nSpecialty entries report the selected field-level outcome; independent\ncoding support remains in resolution.specialty_resolution.coding_results.\n" }, "selected": { "type": "boolean", "description": "Whether this coding supplies the row's source value; always present. False\nfor alternate codings, text-only rows, specialties, and entries without a\ncorresponding column. For demographics, marks the code determining the\nPerson field or race Observation, even without a resolved concept.\nRace/ethnicity null flavors, conflicting inputs, overridden Patient gender,\nand race categories not determining the field are unselected.\n" }, "resolution": { "type": "object", "description": "Field-level outcome and provenance shared by that field's coding entries.\nPaths describe the selected concept, not independent mappings of alternates.\nPresent for semantic attempts; omitted for source information retained\nwithout resolution, including text-only sites, units lacking supported\ncoding, and result values retained without a corresponding row column.\nAllergy evidence can retain source targets that were not selected as\nsubstance values.\n", "required": [ "status" ], "properties": { "semantic_mapping": { "type": "object", "required": [ "status", "vocab_version" ], "description": "Semantic-mapping outcome for a supported concept field; present when\ninference was attempted. The containing MappingEntry supplies row/field\nlinks. Multiple coding entries can share one field outcome; group by\nomop_table, omop_id, and omop_field when processing it. Original source\ncoding is preserved; text-only inputs do not invent coding.\n", "example": { "status": "UNMAPPED", "vocab_version": "v20260829", "reason_code": "AMBIGUOUS" }, "properties": { "status": { "type": "string", "enum": [ "MAPPED", "UNMAPPED" ], "description": "MAPPED when semantic mapping selected a validated standard OMOP concept; UNMAPPED when no standard concept was selected." }, "vocab_version": { "type": "string", "description": "OMOP vocabulary release selected for this mapping." }, "reason_code": { "type": "string", "enum": [ "MISSING_DESCRIPTION", "NO_VALID_SUGGESTION", "AMBIGUOUS", "INVALID_TARGET" ], "description": "Why semantic mapping did not select a standard concept. Present when\n`status` is UNMAPPED; omitted when `status` is MAPPED.\n\n- `MISSING_DESCRIPTION`: no usable source text or coding display was supplied.\n- `NO_VALID_SUGGESTION`: semantic validation completed without accepting a candidate as having the same clinical meaning as the source description.\n- `AMBIGUOUS`: a unique standard concept could not be selected from the possible matches.\n- `INVALID_TARGET`: the suggested code is not an active standard OMOP concept valid for the destination field.\n\nThe linked concept field retains ID 0. An unresolved result-value field\ndoes not unset the row's primary concept.\n" } } }, "specialty_resolution": { "type": "object", "required": [ "text_fallback_reason", "coding_results" ], "description": "Optional fallback decision and independent coding outcomes for one specialty\nentry. The enclosing resolution describes the selected result; unsupported\ncodings can coexist with successful explicit-text resolution. Omitted when\naudit evidence is unavailable; omission does not change the field outcome.\n", "properties": { "text_fallback_reason": { "type": "string", "enum": [ "NO_CODINGS", "INVALID_CODING", "SUPPORTED_SYSTEM_PRESENT", "NO_SPECIALTY_TEXT", "UNSUPPORTED_SYSTEMS_ONLY" ], "description": "NO_CODINGS identifies ordinary text-only resolution. INVALID_CODING\nmeans a missing code or missing/malformed system blocks fallback.\nSUPPORTED_SYSTEM_PRESENT blocks fallback even when a supported code\ndoes not resolve. NO_SPECIALTY_TEXT means complete unsupported\ncodings lack explicit nonblank text. UNSUPPORTED_SYSTEMS_ONLY means\ncomplete unsupported codings permit a text attempt; the attempt may\nstill be unresolved or ambiguous.\n" }, "coding_results": { "type": "array", "description": "Independent outcome of every supplied coding in its original order, including empty or incomplete objects. Empty for text-only specialties. Each mapping's source_coding_index identifies its corresponding outcome.", "items": { "type": "object", "required": [ "coding_index", "system_support", "status" ], "properties": { "coding_index": { "type": "integer", "minimum": 0, "description": "Zero-based index in the originating specialty entry's coding array." }, "system_support": { "type": "string", "enum": [ "SUPPORTED", "UNSUPPORTED", "INVALID" ], "description": "Whether the coding system is supported for resolution, unsupported, or missing/malformed. A missing code can still have a supported or unsupported system." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ], "description": "This coding's independent outcome before combining the entry's evidence." }, "reason_code": { "type": "string", "enum": [ "NO_SOURCE_CODE", "NO_OMOP_SOURCE_CONCEPT", "NO_STANDARD_MAP", "AMBIGUOUS", "DOMAIN_MISMATCH", "UNSUPPORTED_SYSTEM", "UNSUPPORTED_CODE" ], "description": "Machine-readable explanation when available; omitted for successful codings and unknown reasons." } } } } } }, "source_text": { "type": "string", "description": "Explicit source text used to select a specialty concept. Its vocabulary spelling or full preferred term is retained separately in paths[].matched_text." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ], "description": "Vocabulary resolution outcome. Any outcome other than RESOLVED yields mapping_status UNMAPPED and concept ID 0 while retaining an otherwise usable row." }, "reason_code": { "type": "string", "enum": [ "NO_SOURCE_CODE", "NO_OMOP_SOURCE_CONCEPT", "NO_STANDARD_MAP", "AMBIGUOUS", "DOMAIN_MISMATCH", "UNSUPPORTED_SYSTEM", "UNSUPPORTED_CODE", "CONFLICTING_ALLERGY_EVIDENCE", "UNSUPPORTED_ALLERGY_SOURCE", "UNSUPPORTED_ALLERGY_CONTEXT", "UNSUPPORTED_SOURCE_MEANING" ], "description": "Machine-readable explanation for an unresolved mapping, when available:\n\n- `NO_SOURCE_CODE`: no source coding was supplied.\n- `NO_OMOP_SOURCE_CONCEPT`: no OMOP source concept matches the supplied coding.\n- `NO_STANDARD_MAP`: no usable standard OMOP mapping was found for the supplied coding.\n- `AMBIGUOUS`: multiple candidate concepts could not be disambiguated.\n- `DOMAIN_MISMATCH`: candidate standard concepts do not match the domain required by the linked OMOP field.\n- `UNSUPPORTED_SYSTEM`: the source code system is unsupported.\n- `UNSUPPORTED_CODE`: the source code is unsupported for the linked OMOP field.\n- `CONFLICTING_ALLERGY_EVIDENCE`: allergy source meanings or context conflict.\n- `UNSUPPORTED_ALLERGY_SOURCE`: no supported allergy source meaning was established.\n- `UNSUPPORTED_ALLERGY_CONTEXT`: the source context has no supported finding policy.\n- `UNSUPPORTED_SOURCE_MEANING`: a known source concept has no supported allergy interpretation.\n\nUnknown reason codes are omitted; `status` still records the outcome.\n" }, "via": { "type": "string", "enum": [ "DIRECT", "UMLS_BRIDGE", "CONTEXTUAL", "CONCEPT_NAME", "CONCEPT_SYNONYM", "UMLS_STRING", "NUCC_LABEL" ], "description": "How the selected concept was reached: DIRECT uses vocabulary identity or\nMaps to; UMLS_BRIDGE uses a shared UMLS concept; CONTEXTUAL uses allergy\nsource context. Specialty text routes identify a concept name (CONCEPT_NAME),\nEnglish synonym (CONCEPT_SYNONYM), English UMLS string (UMLS_STRING), or\nNUCC preferred label (NUCC_LABEL). Omitted when unavailable or no concept\nwas selected; paths retain matching evidence.\n" }, "paths": { "type": "array", "description": "Mapping paths to the selected concept, in response order. Omitted when unavailable or no concept was selected.", "items": { "type": "object", "description": "Provenance path to the selected concept, starting at an input, UMLS sibling,\nor policy concept. Its source ID can differ from the original input's OMOP\nidentity and must not replace that input's source-concept column.\n", "required": [ "mapping_status", "source_concept_id" ], "properties": { "mapping_status": { "type": "string", "enum": [ "ALREADY_STANDARD", "MAPPED", "POLICY_MAPPED" ], "description": "Path outcome. MAPPED denotes an OMOP Maps to crosswalk; POLICY_MAPPED identifies an explicit vocabulary mapping policy and is retained here even though the enclosing mapping_status reports MAPPED." }, "source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP concept at the start of this mapping path." }, "source_vocabulary": { "type": "string" }, "source_code": { "type": "string", "description": "Code of the path's source concept in its OMOP vocabulary." }, "cui": { "type": "string", "description": "Shared UMLS concept identifier for UMLS_BRIDGE, UMLS_STRING, or NUCC_LABEL, when supplied." }, "sab": { "type": "string", "description": "UMLS sibling source abbreviation, such as NUCCHCPT for NUCC routes." }, "matched_text": { "type": "string", "description": "Actual vocabulary string matched by a specialty text layer. For NUCC_LABEL this is the full original preferred term, including its grouping prefix; source_text retains the supplied text." } } } }, "truncated": { "type": "boolean", "description": "Present and true when candidate matches were truncated during resolution. Absence means no truncation was reported." }, "allergy": { "type": "object", "description": "Contextual finding policy and original coding interpretation, shared by the\nfield's mappings. When domain-based placement supplies a result outside\ncontextual coverage, this object retains the contextual no-match while the\nenclosing resolution describes placement. Missing mechanism, certainty, or\nactivity is not inferred from source statuses. incomplete describes source-interpretation\ncoverage; inspect finding and substance mappings independently for resolution.\n", "required": [ "method", "status", "categories", "effective_categories", "category_derived", "incomplete", "information_loss", "evidence" ], "properties": { "method": { "type": "string", "enum": [ "DIRECT", "CONTEXTUAL", "DERIVED", "UNRESOLVED" ], "description": "Direct vocabulary finding mapping, contextual finding selection, selection using a derived category, or no contextual finding selected." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ] }, "reason_code": { "type": "string", "description": "Machine-readable reason for the contextual policy outcome, when available." }, "type": { "type": "string", "enum": [ "allergy", "intolerance" ], "description": "Supplied FHIR type; omitted when absent." }, "categories": { "type": "array", "description": "Supplied FHIR category values, preserving their order and repeats; null primitive placeholders are omitted. Empty when no category value is supplied.", "items": { "type": "string", "enum": [ "food", "medication", "environment", "biologic" ] } }, "clinical_status": { "type": "array", "description": "Supplied clinical-status codings; omitted when none are available.", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } }, "verification_status": { "type": "array", "description": "Supplied verification-status codings; omitted when absent. A retained unconfirmed statement is not promoted to confirmed.", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } }, "date_source": { "type": "string", "enum": [ "recordedDate", "onsetDateTime", "onsetPeriod.start" ], "description": "Source element selected by the existing date rule, including when its value has partial precision. Omitted when no usable or partial date is supplied; no date is invented." }, "effective_categories": { "type": "array", "description": "Distinct sorted categories used by the contextual policy, including any reviewed derivation.", "items": { "type": "string" } }, "category_derived": { "type": "boolean", "description": "Whether reviewed vocabulary evidence supplied an absent category. This can also accompany a direct finding." }, "incomplete": { "type": "boolean", "description": "Whether some coding evidence was uninterpretable or outside policy coverage." }, "information_loss": { "type": "array", "description": "Explanations of specificity omitted by the selected finding or published mapping. Source coding and context remain in the audit metadata.", "items": { "type": "string" } }, "evidence": { "type": "array", "items": { "type": "object", "description": "Interpretation of an original allergy code. Concept IDs are vocabulary evidence, not a selected value or a claim that a product's complete meaning fits one value field.", "required": [ "coding", "meaning", "standard_concept_ids" ], "properties": { "coding": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } }, "meaning": { "type": "string", "enum": [ "SUBSTANCE", "FINDING", "NEGATIVE", "UNSUPPORTED", "UNINTERPRETABLE" ] }, "source_concept_id": { "type": "integer", "format": "int64", "description": "Original coding's OMOP source identity, when known. This evidence does not override the linked row's source-concept semantics." }, "standard_concept_ids": { "type": "array", "description": "Standard targets reported for the original code. Empty when none are available; multiple targets do not choose one ingredient as the complete substance value.", "items": { "type": "integer", "format": "int64" } }, "category": { "type": "string", "description": "Reviewed substance category, when available." }, "reason_code": { "type": "string", "description": "Machine-readable interpretation gap, when available." } } } } } } } }, "note": { "type": "string", "description": "Explanatory context for source interpretation, table placement, unmapped\noutcomes, and values retained without a corresponding row column.\nDemographic notes identify the source and why a supplied value was not used.\nNotes are human-readable text, not stable identifiers; use selected,\nmapping_status, and resolution fields for programmatic decisions.\n" } } } }, "device_exposure_contexts": { "type": "array", "description": "One context per source record producing device exposures, with links to all\nderived rows and their shared timing, device evidence, and quantity basis.\nPreserved source values may contain clinical data.\n", "items": { "type": "object", "description": "Shared evidence and quantity explanation for all device exposures derived from one source record. Matching or absent resource identifiers do not merge distinct source records.", "required": [ "resource_type", "exposures", "quantity_basis" ], "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "source_full_url": { "type": "string" }, "exposures": { "type": "array", "minItems": 1, "description": "Links to all device exposure rows derived from this source record.", "items": { "type": "object", "required": [ "device_exposure_id" ], "properties": { "device_exposure_id": { "type": "integer", "format": "int64", "description": "Request-local ID of a row in tables.device_exposure." }, "event_index": { "type": "integer", "minimum": 0, "description": "Zero-based index in this context's supplied timingTiming.event evidence, including unusable events retained as partial rows. Omitted for other timing forms." } } } }, "quantity_basis": { "type": "string", "enum": [ "default_absent_count", "unsupported_supplied_evidence" ], "description": "Applies to every linked exposure. default_absent_count identifies the default quantity of 1. unsupported_supplied_evidence identifies omitted quantity due to supplied clinical quantity evidence, including null or malformed numeric fields. UNSUPPORTED diagnostics identify the source paths." }, "evidence": { "type": "array", "description": "Original supplied source values with source paths. Device detail paths begin with device.; other paths refer to the clinical source resource. Timing precision, offsets, schedules, statuses, relationships, UDI carriers, and unsupported quantities are preserved here.", "items": { "type": "object", "required": [ "path", "value" ], "properties": { "path": { "type": "string" }, "value": { "description": "Original supplied JSON value, including null or malformed source evidence.", "nullable": true } } } } }, "example": { "resource_type": "DeviceUseStatement", "resource_id": "use-1", "exposures": [ { "device_exposure_id": 1, "event_index": 0 }, { "device_exposure_id": 2, "event_index": 1 } ], "quantity_basis": "default_absent_count", "evidence": [ { "path": "timingTiming", "value": { "event": [ "2026-01-01T09:00:00Z", "2026-01-03T09:00:00Z" ] } } ] } } }, "specimen_source_contexts": { "type": "array", "description": "Identity, availability, and collection timing for emitted specimens, linked\nby specimen_id. Retains original timing precision/offsets and source\nidentifiers; source_id_path identifies the selected specimen source ID.\n", "items": { "type": "object", "required": [ "specimen_id" ], "properties": { "specimen_id": { "type": "integer", "format": "int64" }, "resource_id": { "type": "string" }, "full_url": { "type": "string" }, "status": { "type": "string", "enum": [ "available", "unavailable", "unsatisfactory" ], "description": "Original FHIR Specimen.status for this emitted row, describing sample availability or suitability. Omitted when no status was supplied; no availability is inferred. This is source metadata, not an OMOP disease-status concept." }, "identifiers": { "type": "array", "items": { "type": "object", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } } }, "accession_identifier": { "type": "object", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } }, "source_id_path": { "type": "string", "description": "Selected source path (id, identifier[index].value, accessionIdentifier.value, or fullUrl); absent if no source identity was supplied." }, "collection_timing": { "type": "object", "description": "Supplied FHIR timing retained verbatim for audit and downstream completion. This is response provenance, not a CDM table or an inferred collection date.", "properties": { "collected_date_time": { "type": "string", "description": "Original collection.collectedDateTime, including partial precision, invalid text, or timezone offset." }, "collected_period": { "type": "object", "properties": { "start": { "type": "string", "description": "Original collectedPeriod.start, without precision completion." }, "end": { "type": "string", "description": "Original collectedPeriod.end, retained without using it as collection start." } } }, "received_time": { "type": "string", "description": "Original receivedTime, never substituted for collection timing." }, "selected_path": { "type": "string", "description": "collection.collectedDateTime or collection.collectedPeriod.start when specimen_date was populated; omitted when no date could safely be selected." } } } } } }, "medication_dispense_source_contexts": { "type": "array", "description": "Supplied dispensing context linked to each emitted dispense's actual output\ntable and row. Omitted when no dispense is emitted. This provenance does not\nestablish administration or adherence.\n", "items": { "type": "object", "required": [ "omop_table", "omop_id", "source" ], "description": "Original dispensing context linked to an emitted clinical row by its actual\ntable and request-local ID, including destinations outside drug_exposure.\nPreserved source values do not establish exposure duration or medication use.\n", "properties": { "resource_id": { "type": "string", "description": "Original MedicationDispense.id, when supplied." }, "full_url": { "type": "string", "description": "Original Bundle entry fullUrl, when supplied." }, "omop_table": { "type": "string", "enum": [ "drug_exposure", "condition_occurrence", "procedure_occurrence", "device_exposure", "measurement", "observation" ] }, "omop_id": { "type": "integer", "format": "int64" }, "source": { "type": "object", "additionalProperties": true, "description": "Only supplied fields are present, using original FHIR names and values: status, statusReasonCodeableConcept, statusReasonReference, category, type, whenPrepared, whenHandedOver, daysSupply, performer, context, authorizingPrescription, dosageInstruction, and medicationReference. Raw values preserve original precision, offsets, explicit nulls, and malformed values. Presence is not a promise that a value was mapped; diagnostics explain unusable values and mappings describe coded outcomes. Direct quantities are audited separately in quantity_transformations for drug_exposure rows." } } } }, "provider_role_contexts": { "type": "array", "description": "Source context for every PractitionerRole linked to an emitted provider.\nPreserves role-specific facts that the provider's singular specialty and\ncare-site columns cannot represent together.\n", "items": { "type": "object", "description": "Source FHIR PractitionerRole context linked to one response-local provider row.", "required": [ "provider_id" ], "properties": { "provider_id": { "type": "integer", "format": "int64" }, "role_source_value": { "type": "string", "description": "The PractitionerRole source identity: its FHIR id, identifier value,\nname, or fullUrl. When none is available, it is `PractitionerRole`.\n" }, "practitioner_reference": { "type": "string", "description": "The role's supplied practitioner reference, when present." }, "practitioner_identifier": { "type": "object", "description": "The logical identifier supplied on a PractitionerRole's practitioner reference. Preserves unknown NPI markers even though they are ignored for identity matching.", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } }, "role_codes": { "type": "array", "items": { "type": "object", "properties": { "source_value": { "type": "string" }, "codings": { "type": "array", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } } } } }, "specialties": { "type": "array", "items": { "type": "object", "properties": { "source_value": { "type": "string" }, "codings": { "type": "array", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } } } } }, "care_sites": { "type": "array", "description": "Every organization, healthcareService, or location reference supplied by the role.", "items": { "type": "object", "required": [ "path", "reference" ], "properties": { "path": { "type": "string", "description": "The FHIR element path on the PractitionerRole." }, "reference": { "type": "string" }, "care_site_id": { "type": "integer", "format": "int64" } } } }, "active": { "type": "boolean" }, "period_start": { "type": "string" }, "period_end": { "type": "string" } } } }, "dropped": { "type": "array", "description": "Supported resources that cannot produce a row because of clinical eligibility\nor unusable patient, code/text, or medication evidence. Provider organizations\nand roles without a confirmed individual NPI or usable Practitioner are also\nreported. Unsupported resource types are ignored. Missing dates or other\nCDM-required fields usually retain partial rows; see resource-specific policies\nfor required evidence.\n\nEligibility exclusions use stable resource-specific reason codes; other\nshaping failures use explanatory reason text.\n", "items": { "type": "object", "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "reason": { "type": "string" } } } }, "diagnostics": { "type": "array", "description": "Explains missing or unusable source data, unresolved links, and conflicting\nor unsupported values. When an affected row is emitted, omop_table and\nomop_id identify it; otherwise both are omitted. Shared issues may link to\nseveral rows. Diagnostics can accompany retained rows or dropped resources.\n\noutcome classifies the issue, path identifies the source field, and reason\nprovides context. Missing optional references do not produce diagnostics.\nReferences resolve only against resources supplied in this request. An invalid\nor unconfirmed NPI omitted from a retained Practitioner has an UNRESOLVED\ndiagnostic at identifier.\n", "items": { "type": "object", "description": "Explains why source data or a reference could not be used. omop_table and\nomop_id identify the affected emitted row, not a rejected target; both are\nomitted when no affected row is emitted. Multiple source resources can link\nto one row. IDs are local to this response.\n", "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "omop_table": { "type": "string", "description": "Table containing the affected row in this response. Present together with omop_id when that row is emitted." }, "omop_id": { "type": "integer", "format": "int64", "description": "Primary key of the affected row within omop_table in this response. Present together with omop_table when that row is emitted." }, "path": { "type": "string", "description": "Source field or diagnostic label. Demographic labels include\n`extension:birthsex` and `extension:ethnicity`; provider identity labels\nare `name`, `gender`, `birthDate`, and `identifier`. For Encounters,\n`class/type` identifies class/type disagreement and `type` identifies\nconflicting type classifications. Joint rules can use slash-separated\npaths such as `whenHandedOver/daysSupply`.\n" }, "reference": { "type": "string", "description": "The supplied Reference.reference value, when present." }, "outcome": { "type": "string", "enum": [ "UNRESOLVED", "AMBIGUOUS", "CONFLICTING", "UNSUPPORTED" ], "description": "- UNRESOLVED: required source data is missing, or a supported reference cannot\n resolve to a supplied resource or emitted target.\n- AMBIGUOUS: a reference or identifier does not identify a unique target.\n- CONFLICTING: source values or relationships disagree or require review\n under the mapping policy.\n- UNSUPPORTED: a source form/type or relationship cannot be fully represented\n or assessed under the supported policy.\n\nreason explains the effect on the row or link. An outcome alone does not\nimply that the resource was dropped; partial rows or grouping can be retained.\n" }, "reason": { "type": "string", "description": "Explanation of the condition and its effect on mapping. Resource-specific\nreason codes can be followed by `; ` and explanatory text; match these\ncodes as prefixes rather than whole strings. Collection timing uses\nspecimen_collection_date_missing, specimen_collection_date_partial,\nspecimen_collection_date_unusable, or specimen_collection_multiple_forms.\nDispensing timing uses medication_dispense_handover_missing,\nmedication_dispense_handover_partial, or medication_dispense_handover_unusable.\nmedication_dispense_handover_before_preparation identifies conflicting\nhandover/preparation timing;\nmedication_dispense_end_date_absent identifies an unset exposure end.\n" } } } }, "vocab_version": { "type": "string", "description": "The OMOP vocabulary release used for coded concept resolution\n(for example, \"v20260829\"), for reproducibility. Omitted when no\nvocabulary resolution was performed.\n" }, "summary": { "type": "object", "description": "Resolution outcome counts and the share not already standard. Each evaluated\nfield contributes one outcome even when several codings produce mappings.\n\n| Included outcomes | Counting unit |\n| --- | --- |\n| Primary clinical concepts, specimen material/sites, supplied Quantity units on Measurement/Observation/Specimen, coded Observation results on Measurement/Observation, allergy substance values, Encounter classifications, Address.country, CMS Place of Service, and recorded Practitioner gender | Each evaluated field |\n| Coded medication/Immunization routes, including context on other destinations | Each source-selected route; report-only alternates do not add outcomes |\n| Provider specialties | Each distinct input per provider |\n| Patient demographics | Each selected Person field or emitted race Observation; conflicting values count once as unmapped |\n\nAbsent specimen material/sites and units do not count. Demographic null\nflavors, Patient gender other/unknown or overridden by birth sex, and race\ncategories not determining a field are reported only in mappings.\nObservation values retained without a corresponding row column, quantity\naudits, and visit compatibility assessments do not add resolution outcomes.\nDropped resources do not count; indexed rows remain included in codes_*\nand off_vocab_rate.\n", "properties": { "codes_already_standard": { "type": "integer", "description": "Resolution outcomes already a standard OMOP concept (ALREADY_STANDARD)." }, "codes_normalized": { "type": "integer", "description": "Resolution outcomes mapped or suggested to a standard concept (MAPPED or UNCHECKED)." }, "codes_unmapped": { "type": "integer", "description": "Resolution outcomes with no standard concept valid for the destination selected (UNMAPPED)." }, "rows_for_review": { "type": "integer", "description": "Length of the rows_for_review index; each row counts once even with multiple retention reasons. codes_* and off_vocab_rate include all shaped rows; dropped resources do not count." }, "off_vocab_rate": { "type": "number", "format": "double", "description": "Share of resolution outcomes not already standard ((normalized + unmapped) / total)." } } } } } ``` **Example:** ```json { "success": true, "message": "FHIR resources mapped to OMOP CDM v5.4", "tables": { "person": [ { "person_id": 1, "gender_concept_id": 8532, "year_of_birth": 1985, "month_of_birth": 7, "day_of_birth": 22, "race_concept_id": 0, "ethnicity_concept_id": 0, "person_source_value": "patient-1", "gender_source_value": "female", "gender_source_concept_id": 0, "race_source_concept_id": 0, "ethnicity_source_concept_id": 0 } ], "observation_period": [ { "observation_period_id": 1, "person_id": 1, "observation_period_start_date": "2024-01-15", "observation_period_end_date": "2024-01-16", "period_type_concept_id": 32817 } ], "condition_occurrence": [ { "condition_occurrence_id": 1, "person_id": 1, "condition_concept_id": 201826, "condition_start_date": "2024-01-15", "condition_type_concept_id": 32817, "condition_source_value": "44054006", "condition_source_concept_id": 201826 } ], "drug_exposure": [ { "drug_exposure_id": 1, "person_id": 1, "drug_concept_id": 40163924, "drug_exposure_start_date": "2024-01-16", "drug_type_concept_id": 32838, "drug_source_value": "860975", "drug_source_concept_id": 40163924 } ] }, "mappings": [ { "resource_type": "Patient", "resource_id": "patient-1", "omop_table": "person", "omop_field": "gender_concept_id", "omop_id": 1, "source_system": "http://hl7.org/fhir/administrative-gender", "source_code": "female", "source_name": "female", "target_vocabulary": "Gender", "target_code": "F", "target_name": "FEMALE", "mapping_status": "MAPPED", "selected": true, "note": "FHIR administrative gender; assumed sex at birth" }, { "resource_type": "Condition", "resource_id": "condition-1", "omop_table": "condition_occurrence", "omop_field": "condition_concept_id", "omop_id": 1, "source_system": "http://snomed.info/sct", "source_code": "44054006", "source_name": "Type 2 diabetes mellitus", "target_vocabulary": "SNOMED", "target_code": "44054006", "target_name": "Type 2 diabetes mellitus", "mapping_status": "ALREADY_STANDARD", "selected": true }, { "resource_type": "MedicationRequest", "resource_id": "medreq-1", "omop_table": "drug_exposure", "omop_field": "drug_concept_id", "omop_id": 1, "source_system": "http://www.nlm.nih.gov/research/umls/rxnorm", "source_code": "860975", "source_name": "metformin hydrochloride 500 MG", "target_vocabulary": "RXNORM", "target_code": "860975", "target_name": "metformin hydrochloride 500 MG", "mapping_status": "ALREADY_STANDARD", "selected": true } ], "vocab_version": "v20260829", "summary": { "codes_already_standard": 2, "codes_normalized": 1, "codes_unmapped": 0, "off_vocab_rate": 0.3333333333333333 } } ``` **400** - Bad request - invalid input. Possible reasons: - Missing or malformed request body (no `fhir_resources`) - Invalid FHIR input (non-Bundle/non-resource payload) - No Patient resource found (OMOP requires at least one person) - Coded fields or provider identifiers are too large to process - A concept field exceeds 1,000 source items (codings plus any non-empty specialty text, including whitespace-only text, which counts as one item) - Unsupported `vocab_version` Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "message": { "type": "string" }, "tables": { "type": "object", "description": "OMOP CDM v5.4 rows grouped by destination table. IDs are sequential and\nscoped to one response; they are not stable keys across requests.\nFields with no value are unset (omitted from the row), except concept\nIDs reported as `0` and the following nullable concept fields, which are\nalways present: `unit_concept_id` on Measurement, Observation, and\nSpecimen rows, `unit_source_concept_id` on Measurement rows, and\n`anatomic_site_concept_id` on Specimen rows. These nullable fields are\n`null` when the source value is absent and `0` when supplied but unmapped.\nDevice exposure `unit_concept_id` and `unit_source_concept_id` are always\npresent as `null`.\nEach `*_datetime` comes from the same source as its `*_date` and is set\nonly when that source has a time of day.\n", "properties": { "location": { "type": "array", "items": { "type": "object", "properties": { "location_id": { "type": "integer", "format": "int64" }, "address_1": { "type": "string" }, "address_2": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "zip": { "type": "string" }, "county": { "type": "string" }, "location_source_value": { "type": "string" }, "country_concept_id": { "type": "integer", "format": "int64" }, "country_source_value": { "type": "string" }, "latitude": { "type": "number", "format": "double" }, "longitude": { "type": "number", "format": "double" } } } }, "care_site": { "type": "array", "items": { "type": "object", "properties": { "care_site_id": { "type": "integer", "format": "int64" }, "care_site_name": { "type": "string" }, "place_of_service_concept_id": { "type": "integer", "format": "int64" }, "location_id": { "type": "integer", "format": "int64" }, "care_site_source_value": { "type": "string" }, "place_of_service_source_value": { "type": "string" } } } }, "provider": { "type": "array", "items": { "type": "object", "properties": { "provider_id": { "type": "integer", "format": "int64" }, "provider_name": { "type": "string" }, "npi": { "type": "string", "description": "Single distinct confirmed individual NPI from Practitioner.identifier or,\nfor a role-only provider, PractitionerRole.identifier or practitioner.identifier.\nRecognized systems are http://hl7.org/fhir/sid/us-npi,\nurn:oid:2.16.840.1.113883.4.6, and 2.16.840.1.113883.4.6.\nClassification trims whitespace and validates ten digits and the NPI check\ndigit; this field preserves the original value. Blank and UNK/UNKNOWN markers\nare missing, ignoring case and surrounding whitespace. Organization, invalid,\nunconfirmed, and conflicting NPIs do not populate this field.\n" }, "dea": { "type": "string" }, "specialty_concept_id": { "type": "integer", "format": "int64", "description": "Standard Provider concept shared by every distinct supplied role specialty; otherwise `0`. Inputs resolve independently, without frequency or hierarchy selection." }, "care_site_id": { "type": "integer", "format": "int64" }, "year_of_birth": { "type": "integer", "description": "Year from Practitioner.birthDate." }, "gender_concept_id": { "type": "integer", "format": "int64", "description": "For recorded `Practitioner.gender`, `male` and `female` resolve to validated OMOP Gender concepts. `other`, `unknown`, and absent values remain `0`." }, "provider_source_value": { "type": "string", "description": "The single confirmed individual NPI, including for role-only providers and\nwhen conflicting identity attributes keep an NPI group in separate rows.\nCheck identity diagnostics and compatibility before deduplicating across responses.\n\nWithout an unambiguous individual NPI, the Practitioner's source identity is\nused, excluding missing markers and unconfirmed NPIs. Role-only providers\nrequire a confirmed NPI. Without a source identity, `@provider-index:N`\nmarks a response-local provider ordinal. Contained Practitioners use\n`PractitionerRole/#`; a role without a source\nidentity uses `@role-index:N` as its response-local scope. These fallbacks\nare not global identity guarantees; row IDs and merging are request-local.\n" }, "specialty_source_value": { "type": "string", "description": "Supplied specialty text (or coding display/code) when source values across roles agree, including unresolved text. Conflicting source values remain in provider_role_contexts and mappings." }, "specialty_source_concept_id": { "type": "integer", "format": "int64", "description": "Shared input OMOP source concept when all specialties agree on both target and source concept. Text, UMLS routes, conflicting inputs, or differing source concepts leave `0`." }, "gender_source_value": { "type": "string", "description": "The recorded FHIR administrative-gender value for this Provider." }, "gender_source_concept_id": { "type": "integer", "format": "int64", "description": "Remains `0` because FHIR administrative-gender codes do not themselves identify OMOP source concepts." } } } }, "person": { "type": "array", "items": { "type": "object", "properties": { "person_id": { "type": "integer", "format": "int64" }, "gender_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Gender concept for sex at birth, from US Core birth sex when supplied, otherwise from Patient `gender` `male` or `female`. `0` for absent, unknown, other, unsupported, or conflicting values." }, "year_of_birth": { "type": "integer", "description": "Year from Patient.birthDate." }, "month_of_birth": { "type": "integer", "description": "Month from Patient.birthDate, when it supplies one." }, "day_of_birth": { "type": "integer", "description": "Day from Patient.birthDate, when it supplies one." }, "birth_datetime": { "type": "string", "description": "Not set; Patient.birthDate has no time of day." }, "race_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Race concept from a US Core race OMB category; `1546847` (More than one race) when more than one distinct race resolves, with each race in an `observation` row. `0` when no category resolves." }, "ethnicity_concept_id": { "type": "integer", "format": "int64", "description": "Standard OMOP Ethnicity concept from the US Core ethnicity OMB category. `0` when absent, unresolved, or conflicting; never derived from race." }, "location_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "person_source_value": { "type": "string", "description": "Patient.id, or the first non-empty Patient.identifier.value when id is absent. Omitted when neither is available." }, "gender_source_value": { "type": "string", "description": "The selected sex-at-birth source code: the US Core birth sex `valueCode`, or Patient `gender` when no birth sex is supplied. Conflicting birth sex values are joined with `|`; empty when the birth sex has no `valueCode`." }, "gender_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of the selected sex-at-birth code, when that code is itself an OMOP source concept; `0` otherwise, as for FHIR administrative gender codes." }, "race_source_value": { "type": "string", "description": "Every supplied US Core race category and detailed code, joined with `|` in source order, or the extension text when no code is supplied." }, "race_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of a single resolved race code, when that code is itself an OMOP source concept; `0` otherwise, including when more than one race resolves." }, "ethnicity_source_value": { "type": "string", "description": "Every supplied US Core ethnicity category and detailed code, joined with `|` in source order, or the extension text when no code is supplied." }, "ethnicity_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept of the resolved ethnicity code, when that code is itself an OMOP source concept; `0` otherwise." } } } }, "death": { "type": "array", "items": { "type": "object", "properties": { "person_id": { "type": "integer", "format": "int64" }, "death_date": { "type": "string", "description": "Date from Patient.deceasedDateTime; unset for a boolean-only or partial value." }, "death_datetime": { "type": "string" }, "death_type_concept_id": { "type": "integer", "format": "int64" }, "cause_concept_id": { "type": "integer", "format": "int64" }, "cause_source_value": { "type": "string" }, "cause_source_concept_id": { "type": "integer", "format": "int64" } } } }, "observation_period": { "type": "array", "items": { "type": "object", "properties": { "observation_period_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "observation_period_start_date": { "type": "string", "description": "Earliest date selected by the source timing rules from the person's\nvisit and clinical rows not listed in rows_for_review, plus Specimen\nand Death rows in this request. No period row is returned without\nqualifying dates; not enrollment evidence.\n" }, "observation_period_end_date": { "type": "string", "description": "Latest date selected by the source timing rules from the person's\nvisit and clinical rows not listed in rows_for_review, plus Specimen\nand Death rows in this request. Includes source end dates from\nunindexed rows even when the output table has no end column.\nNo period row is returned without qualifying dates; not enrollment evidence.\n" }, "period_type_concept_id": { "type": "integer", "format": "int64" } } } }, "visit_occurrence": { "type": "array", "items": { "type": "object", "properties": { "visit_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "visit_concept_id": { "type": "integer", "format": "int64" }, "visit_start_date": { "type": "string", "description": "Date from Encounter.period.start." }, "visit_start_datetime": { "type": "string" }, "visit_end_date": { "type": "string", "description": "Date from Encounter.period.end." }, "visit_end_datetime": { "type": "string" }, "visit_type_concept_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "visit_source_value": { "type": "string" }, "visit_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept for the selected Encounter.class or Encounter.type coding when available; `0` when the source coding has no OMOP source concept, including the HL7 encounter class codes listed above." } } } }, "visit_detail": { "type": "array", "items": { "type": "object", "description": "An explicitly supplied component Encounter linked to its same-patient parent visit. Missing dates remain absent for downstream load completion.", "required": [ "visit_detail_id", "person_id", "visit_detail_concept_id", "visit_detail_type_concept_id", "visit_detail_source_concept_id", "visit_occurrence_id" ], "properties": { "visit_detail_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "visit_detail_concept_id": { "type": "integer", "format": "int64" }, "visit_detail_start_date": { "type": "string", "description": "Date from Encounter.period.start." }, "visit_detail_start_datetime": { "type": "string" }, "visit_detail_end_date": { "type": "string", "description": "Date from Encounter.period.end." }, "visit_detail_end_datetime": { "type": "string" }, "visit_detail_type_concept_id": { "type": "integer", "format": "int64" }, "provider_id": { "type": "integer", "format": "int64" }, "care_site_id": { "type": "integer", "format": "int64" }, "visit_detail_source_value": { "type": "string" }, "visit_detail_source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP source concept for the selected Encounter.class or Encounter.type coding when available; `0` when the source coding has no OMOP source concept, including the HL7 encounter class codes listed above." }, "visit_occurrence_id": { "type": "integer", "format": "int64", "description": "The emitted same-patient overarching visit referenced by this component." } } } }, "condition_occurrence": { "type": "array", "items": { "type": "object", "properties": { "condition_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "condition_concept_id": { "type": "integer", "format": "int64" }, "condition_start_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For a Condition, onsetDateTime or onsetPeriod.start, otherwise recordedDate; see the endpoint's timing sources for other resources." }, "condition_start_datetime": { "type": "string" }, "condition_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For a Condition, abatementDateTime or abatementPeriod.end; see the endpoint's timing sources for other resources." }, "condition_end_datetime": { "type": "string" }, "condition_type_concept_id": { "type": "integer", "format": "int64" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "condition_source_value": { "type": "string" }, "condition_source_concept_id": { "type": "integer", "format": "int64" }, "condition_status_source_value": { "type": "string" } } } }, "drug_exposure": { "type": "array", "items": { "type": "object", "properties": { "drug_exposure_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "drug_concept_id": { "type": "integer", "format": "int64" }, "drug_exposure_start_date": { "type": "string", "description": "Start date selected by the source resource's timing rules, such as effective[x], occurrenceDateTime, MedicationRequest.authoredOn, or MedicationDispense.whenHandedOver; see the endpoint's timing sources for all supported resources." }, "drug_exposure_start_datetime": { "type": "string" }, "drug_exposure_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For medication resources, an explicit effectivePeriod.end or the start date of a single-event administration or immunization; see the endpoint's timing sources for other resources." }, "drug_exposure_end_datetime": { "type": "string" }, "verbatim_end_date": { "type": "string", "description": "Date from an explicit FHIR Period.end only; inferred same-day ends are not verbatim source values." }, "drug_type_concept_id": { "type": "integer", "format": "int64", "description": "MedicationDispense uses 32825 (EHR dispensing record); MedicationRequest uses 32838 (EHR prescription). Other current resources use 32817 (EHR). These identify record provenance, not proof of medication consumption." }, "stop_reason": { "type": "string" }, "refills": { "type": "integer", "format": "int64", "description": "Direct MedicationRequest.dispenseRequest.numberOfRepeatsAllowed value, when supplied." }, "days_supply": { "type": "integer", "format": "int64", "description": "Direct positive whole-day MedicationRequest.dispenseRequest.expectedSupplyDuration or coded UCUM-day MedicationDispense.daysSupply; never derived from drug quantity, dosage, refills, or timing. Does not derive an exposure end date." }, "quantity": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Formulation-specific quantity from a direct MedicationRequest dispense quantity, MedicationDispense quantity, MedicationAdministration dose, or Immunization dose quantity. Under fixed_dose_form_count this is a matched coded tablet/capsule count copied directly, or an ingredient amount divided by per-unit strength. Under clinical_injection_ingredient_amount this is the ingredient amount, converted to the ingredient unit or derived using explicit concentration evidence; exact-unit ingredient amounts are copied directly. See the endpoint's supported dose forms and prerequisites; quantity_transformations identifies the policy, source, calculation evidence, intermediate UCUM conversion, and output unit, or explains why a supplied quantity was omitted." }, "sig": { "type": "string", "description": "Newline-joined non-empty FHIR Dosage.text instructions in source order." }, "route_concept_id": { "type": "integer", "format": "int64", "description": "Target-valid OMOP Route concept for an unambiguous coded FHIR route; `0` for an unmapped coded route, omitted for absent, text-only, or conflicting routes." }, "lot_number": { "type": "string", "description": "Direct FHIR R4 Immunization.lotNumber value." }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "drug_source_value": { "type": "string" }, "drug_source_concept_id": { "type": "integer", "format": "int64" }, "route_source_value": { "type": "string", "description": "Selected source coding or text for an unambiguous FHIR route." } } } }, "procedure_occurrence": { "type": "array", "items": { "type": "object", "properties": { "procedure_occurrence_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "procedure_concept_id": { "type": "integer", "format": "int64" }, "procedure_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For a Procedure, performedDateTime or performedPeriod.start; see the endpoint's timing sources for other resources." }, "procedure_datetime": { "type": "string" }, "procedure_end_date": { "type": "string", "description": "End date selected by the source resource's timing rules, when available. For a Procedure, performedPeriod.end; see the endpoint's timing sources for other resources." }, "procedure_end_datetime": { "type": "string" }, "procedure_type_concept_id": { "type": "integer", "format": "int64" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "procedure_source_value": { "type": "string" }, "procedure_source_concept_id": { "type": "integer", "format": "int64" } } } }, "measurement": { "type": "array", "items": { "type": "object", "required": [ "unit_concept_id", "unit_source_concept_id" ], "properties": { "measurement_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "measurement_concept_id": { "type": "integer", "format": "int64" }, "measurement_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For an Observation, effectiveDateTime, effectivePeriod.start, or effectiveInstant; see the endpoint's timing sources for other resources." }, "measurement_datetime": { "type": "string" }, "measurement_type_concept_id": { "type": "integer", "format": "int64" }, "value_as_number": { "type": "number", "format": "double" }, "operator_concept_id": { "type": "integer", "format": "int64", "description": "OMOP \"Meas Value Operator\" standard concept qualifying value_as_number (<, <=, >, >=), parsed from a numeric-string value or a FHIR valueQuantity.comparator. 0 when no operator (a bare number)." }, "value_as_concept_id": { "type": "integer", "format": "int64" }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied but unmapped units, null for absent units. Always present in JSON." }, "range_low": { "type": "number", "format": "double" }, "range_high": { "type": "number", "format": "double" }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "measurement_source_value": { "type": "string" }, "measurement_source_concept_id": { "type": "integer", "format": "int64" }, "unit_source_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "OMOP source concept ID corresponding to Quantity.system/code; 0 for supplied units without a matching source concept, null for absent units. Always present in JSON." }, "unit_source_value": { "type": "string", "description": "Original Quantity.code if supplied, otherwise Quantity.unit; human-readable unit text is preserved in the unit mapping's source_name." }, "value_source_value": { "type": "string" } } } }, "device_exposure": { "type": "array", "items": { "type": "object", "required": [ "device_exposure_id", "person_id", "device_concept_id", "device_type_concept_id", "device_source_concept_id", "unit_concept_id", "unit_source_concept_id" ], "properties": { "device_exposure_id": { "type": "integer", "format": "int64", "description": "Request-local exposure identity, distinct from physical or model device identity." }, "person_id": { "type": "integer", "format": "int64", "description": "Emitted Patient identity." }, "device_concept_id": { "type": "integer", "format": "int64", "description": "Validated standard Device concept; 0 for missing or unresolved type evidence." }, "device_exposure_start_date": { "type": "string", "format": "date", "description": "Source use start at day precision; absent when unknown or unusable." }, "device_exposure_start_datetime": { "type": "string", "description": "Source local wall-clock start, without UTC offset; absent for date-only input.", "example": "2026-01-01T23:30:00" }, "device_exposure_end_date": { "type": "string", "format": "date", "description": "Explicit source end; absent when unknown or unusable." }, "device_exposure_end_datetime": { "type": "string", "description": "Source local wall-clock end, without UTC offset; absent for date-only input.", "example": "2026-01-03T08:00:00" }, "device_type_concept_id": { "type": "integer", "format": "int64", "description": "Coarse source provenance; DeviceUseStatement uses generic EHR 32817." }, "unique_device_id": { "type": "string", "description": "Unambiguous supplied UDI-DI; competing values remain in source context." }, "production_id": { "type": "string", "description": "Unset; supplied production components and carriers remain in source context." }, "quantity": { "type": "integer", "format": "int64", "description": "Default 1 when quantity evidence is absent; otherwise omitted. See device_exposure_contexts.quantity_basis." }, "provider_id": { "type": "integer", "format": "int64", "description": "Compatible explicit performer on routed rows; absent for DeviceUseStatement and reporting-only actors." }, "visit_occurrence_id": { "type": "integer", "format": "int64", "description": "Explicit emitted same-patient visit for routed rows; absent for DeviceUseStatement." }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component for routed rows, with its overarching visit_occurrence_id; absent for DeviceUseStatement." }, "device_source_value": { "type": "string", "description": "Original selected type or clinical code, or supplied text; never a resource/inventory identifier." }, "device_source_concept_id": { "type": "integer", "format": "int64", "description": "Original source concept when established by vocabulary resolution; otherwise 0." }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Always null." }, "unit_source_value": { "type": "string", "description": "Unset; unsupported clinical units remain in source context." }, "unit_source_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Always null." } } } }, "specimen": { "type": "array", "items": { "type": "object", "required": [ "specimen_id", "person_id", "specimen_concept_id", "specimen_type_concept_id", "unit_concept_id", "anatomic_site_concept_id" ], "properties": { "specimen_id": { "type": "integer", "format": "int64", "description": "Request-local generated row identity; distinct from specimen_source_id." }, "person_id": { "type": "integer", "format": "int64", "description": "Explicitly resolved top-level Patient in this response." }, "specimen_concept_id": { "type": "integer", "format": "int64", "description": "Material validated against Specimen; 0 for supplied unmapped material or absent material. Absence has a linked type diagnostic and no mapping/summary count; supplied unmapped material has a vocabulary mapping outcome." }, "specimen_type_concept_id": { "type": "integer", "format": "int64", "description": "32817 (EHR record provenance), independent of material and availability." }, "specimen_date": { "type": "string", "description": "Collection date from collectedDateTime or collectedPeriod.start at day\nprecision. Missing, partial, invalid, or conflicting timing leaves it absent\nwith a linked diagnostic; callers must handle required-date completion for\nCDM loading.\n" }, "specimen_datetime": { "type": "string", "description": "Collection local wall-clock time, only when supplied; no fabricated time or offset conversion." }, "quantity": { "type": "number", "format": "double", "description": "Exact nonnegative collection.quantity.value, without comparator or numeric conversion." }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied unmapped units, null for absence." }, "anatomic_site_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Spec Anatomic Site concept for a coded site; 0 for a supplied unmapped or text-only site, null for absence. Text-only sites retain source text without a concept suggestion." }, "specimen_source_id": { "type": "string", "description": "Resource id, first valued identifier, accession value, then fullUrl. All source identities and selection path are in specimen_source_contexts. Kept verbatim; downstream loaders must handle CDM varchar(50) limits." }, "specimen_source_value": { "type": "string", "description": "Selected bare material code or source text." }, "unit_source_value": { "type": "string", "description": "Exact Quantity.code when supplied, otherwise Quantity.unit." }, "anatomic_site_source_value": { "type": "string", "description": "Selected bare bodySite code or source text." } } } }, "observation": { "type": "array", "items": { "type": "object", "required": [ "unit_concept_id" ], "properties": { "observation_id": { "type": "integer", "format": "int64" }, "person_id": { "type": "integer", "format": "int64" }, "observation_concept_id": { "type": "integer", "format": "int64" }, "observation_date": { "type": "string", "description": "Start date selected by the source resource's timing rules. For an Observation, effectiveDateTime, effectivePeriod.start, or effectiveInstant. For an AllergyIntolerance, recordedDate, otherwise onsetDateTime or onsetPeriod.start; see the endpoint's timing sources for other resources." }, "observation_datetime": { "type": "string" }, "observation_type_concept_id": { "type": "integer", "format": "int64" }, "value_as_number": { "type": "number", "format": "double" }, "value_as_string": { "type": "string" }, "value_as_concept_id": { "type": "integer", "format": "int64" }, "unit_concept_id": { "type": "integer", "format": "int64", "nullable": true, "description": "Valid standard Unit concept for coded UCUM; 0 for supplied but unmapped units, null for absent units. Always present in JSON." }, "visit_occurrence_id": { "type": "integer", "format": "int64" }, "visit_detail_id": { "type": "integer", "format": "int64", "description": "Explicit same-patient component link, supplied together with its overarching visit_occurrence_id." }, "provider_id": { "type": "integer", "format": "int64" }, "observation_source_value": { "type": "string" }, "observation_source_concept_id": { "type": "integer", "format": "int64", "description": "For coded AllergyIntolerance rows, the known OMOP identity of the original coding rendered in observation_source_value, even when the finding is unresolved. 0 when no original source identity is known; the configured contextual finding is not a source concept." }, "unit_source_value": { "type": "string", "description": "Original Quantity.code if supplied, otherwise Quantity.unit; human-readable unit text is preserved in the unit mapping's source_name." }, "value_source_value": { "type": "string" } } } } } }, "visit_component_contexts": { "type": "array", "description": "Compatibility assessments for explicit Encounter components, linked to the\nfinal detail or standalone visit. Omitted when no component is assessed;\nassessments do not contribute to terminology counts in summary.\n", "items": { "type": "object", "required": [ "parent_reference", "omop_table", "omop_id", "assessment" ], "properties": { "resource_id": { "type": "string", "description": "Source child Encounter ID, when supplied." }, "full_url": { "type": "string", "description": "Source child Bundle entry fullUrl, when supplied." }, "parent_reference": { "type": "string", "description": "Supplied Encounter.partOf.reference, preserved even when grouping is not applied." }, "omop_table": { "type": "string", "enum": [ "visit_detail", "visit_occurrence" ], "description": "Final table containing the emitted child row." }, "omop_id": { "type": "integer", "format": "int64", "description": "Request-local ID of the emitted child row within omop_table." }, "assessment": { "type": "object", "required": [ "parent_concept_id", "detail_concept_id", "status", "reason_code", "vocab_version" ], "description": "Compatibility of the selected parent/detail Visit concepts under the CDM\nsame-concept/descendant convention. Compatible concepts must be active and\nstandard in the Visit domain. An assessment describes classification\ncompatibility, not the clinical truth of the source partOf relationship.\n", "properties": { "parent_concept_id": { "type": "integer", "format": "int64", "description": "Selected parent Visit concept assessed; 0 means unresolved." }, "detail_concept_id": { "type": "integer", "format": "int64", "description": "Selected candidate detail concept assessed; 0 means unresolved." }, "status": { "type": "string", "enum": [ "COMPATIBLE", "INCOMPATIBLE", "UNKNOWN" ] }, "reason_code": { "type": "string", "enum": [ "SAME_CONCEPT", "DESCENDANT", "NOT_DESCENDANT", "UNRESOLVED_CONCEPT", "CONCEPT_NOT_FOUND", "INACTIVE_CONCEPT", "NONSTANDARD_CONCEPT", "WRONG_DOMAIN", "ANCESTRY_UNAVAILABLE" ], "description": "SAME_CONCEPT and DESCENDANT are compatible outcomes. NOT_DESCENDANT means\nthe usable concepts lack the required parent-ancestor/detail-descendant\nrelationship. Other reasons are unknown outcomes: an unresolved or unusable\nconcept, or insufficient ancestry evidence. Assessment unavailability or\nmalformed results fail the request with HTTP 500 rather than returning\nan UNKNOWN result.\n" }, "invalid_concept_role": { "type": "string", "enum": [ "parent", "detail" ], "description": "Identifies the unusable concept for UNKNOWN concept-validation outcomes.\nAbsent for ANCESTRY_UNAVAILABLE and compatible/incompatible outcomes.\n" }, "min_levels_of_separation": { "type": "integer", "description": "Present only for compatible outcomes; 0 for identity, positive for a descendant relationship." }, "vocab_version": { "type": "string", "description": "Concrete vocabulary version used for both selected concepts and this assessment; matches the response vocab_version." } } } } } }, "quantity_transformations": { "type": "array", "description": "Audits supplied direct quantities on emitted drug_exposure rows, including\nderivations and omissions. Omitted when no applicable quantity was supplied.\nUses the response vocabulary release and does not affect terminology counts\nin summary. Example concept IDs are illustrative.\n", "items": { "type": "object", "description": "Audit of one supplied quantity on an emitted drug_exposure row. All evidence uses the response's vocab_version. Result and result_unit are present only for successful outcomes; reason is present only for OMITTED. Policy is present once a supported formulation policy was selected.", "required": [ "resource_type", "resource_id", "source_path", "source_quantity", "omop_table", "omop_field", "omop_id", "outcome" ], "properties": { "resource_type": { "type": "string", "enum": [ "MedicationRequest", "MedicationDispense", "MedicationAdministration", "Immunization" ] }, "resource_id": { "type": "string", "description": "Source FHIR resource id; empty when none was supplied." }, "source_path": { "type": "string", "enum": [ "dispenseRequest.quantity", "quantity", "dosage.dose", "doseQuantity" ], "description": "Exact source element path relative to resource_type." }, "source_quantity": { "nullable": true, "description": "Original supplied Quantity object, including value, system, code, unit, comparator, and other supplied fields. Explicit nulls and malformed values are also preserved as supplied." }, "omop_table": { "type": "string", "enum": [ "drug_exposure" ] }, "omop_field": { "type": "string", "enum": [ "quantity" ] }, "omop_id": { "type": "integer", "format": "int64", "description": "The drug_exposure_id of the row in this response." }, "outcome": { "type": "string", "enum": [ "DIRECT", "DERIVED", "OMITTED" ], "description": "DIRECT copies a matched fixed-form count or an ingredient amount in the same unit; DERIVED converts units or calculates a dose-form count or ingredient amount under the named policy; OMITTED leaves quantity unset while retaining the row." }, "policy": { "type": "string", "enum": [ "fixed_dose_form_count", "clinical_injection_ingredient_amount" ], "description": "The formulation policy documented in the endpoint description. May be present for an omission occurring after policy selection." }, "reason": { "type": "string", "enum": [ "unsupported_quantity", "unsupported_comparator", "unsupported_unit", "drug_unresolved", "missing_drug_evidence", "incomplete_drug_evidence", "ambiguous_drug_evidence", "missing_classification", "unsupported_drug_class", "unsupported_dose_form", "unsupported_strength", "unit_mismatch", "unsupported_fraction", "invalid_result" ], "description": "Stable omission reason:\n- unsupported_quantity: supplied value is not a Quantity object with a positive finite numeric value.\n- unsupported_comparator: a comparator field was supplied.\n- unsupported_unit: source system/code does not identify a UCUM-coded quantity or a supported HL7 TAB/CAP count.\n- drug_unresolved: no standard drug concept was resolved.\n- missing_drug_evidence: formulation and strength evidence is unavailable.\n- incomplete_drug_evidence: required vocabulary evidence is missing or invalid.\n- ambiguous_drug_evidence: more than one dose form exists, or more than one strength exists for a conversion requiring strength. Direct counts allow combination products.\n- missing_classification: the selected drug's concept class is unavailable.\n- unsupported_drug_class: the drug is outside Clinical Drug or Branded Drug, including quantified products and packs.\n- unsupported_dose_form: the dose form has no supported classification for these policies.\n- unsupported_strength: strength does not establish the selected policy, including missing, non-positive, non-finite, or conflicting values or an absent/unsupported denominator basis for volume conversion.\n- unit_mismatch: the source neither matches a validated vocabulary-backed strength unit nor converts within the documented supported unit groups, or an explicit count disagrees with the selected tablet/capsule form.\n- unsupported_fraction: a fixed-form count is not whole units or multiples of one-half or one-third.\n- invalid_result: arithmetic does not produce a positive finite result.\n" }, "evidence": { "type": "object", "description": "Available selected-drug, dose-form, and single-ingredient strength evidence. Missing or ambiguous evidence is not replaced with an arbitrary value. On successful outcomes these fields explain the named policy's calculation.", "required": [ "drug_concept_id" ], "properties": { "drug_concept_id": { "type": "integer", "format": "int64" }, "drug_concept_class": { "type": "string" }, "dose_form": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "strength": { "type": "object", "description": "Single-ingredient strength evidence: amount is ingredient per fixed unit;\nnumerator/denominator describe concentration. Missing raw values remain\nabsent without defaults. denominator_basis records the interpretation of\nthe denominator. Box-size/refill arithmetic is not applied.\n", "required": [ "ingredient_concept_id" ], "properties": { "ingredient_concept_id": { "type": "integer", "format": "int64" }, "amount_value": { "type": "number", "format": "double" }, "amount_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "numerator_value": { "type": "number", "format": "double" }, "numerator_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "denominator_value": { "type": "number", "format": "double" }, "denominator_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } }, "denominator_basis": { "type": "object", "description": "Interpretation of the vocabulary denominator, retained for audit even when\nconversion is omitted. PER_UNIT denotes a normalized per-unit concentration;\nQUANTIFIED_TOTAL supplies an explicit product total. NOT_APPLICABLE and\nUNKNOWN supply no basis value. Only PER_UNIT supports injection volume\nconversion. Omitted when no basis is supplied.\n", "required": [ "kind" ], "properties": { "kind": { "type": "string", "enum": [ "PER_UNIT", "QUANTIFIED_TOTAL", "NOT_APPLICABLE", "UNKNOWN" ] }, "value": { "type": "number", "format": "double", "description": "Original numeric denominator-basis value, including zero or negative values retained for audit. Successful volume-to-ingredient conversion requires kind PER_UNIT and value 1." } } } } } } }, "unit_conversion": { "type": "object", "description": "Successful case-sensitive UCUM conversion of the source magnitude into a\nsupported strength unit. Present only when the unit code changes. The result\nis an intermediate value, not the linked row's quantity, and can remain\npresent when a later policy check omits that quantity.\n", "required": [ "source_code", "result", "result_unit" ], "properties": { "source_code": { "type": "string", "description": "Original UCUM code from source_quantity.code." }, "result": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Original source magnitude converted to result_unit, before strength arithmetic." }, "result_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } } } }, "result": { "type": "number", "format": "double", "minimum": 0, "exclusiveMinimum": true, "description": "Same numeric value as the linked row's quantity." }, "result_unit": { "type": "object", "description": "Vocabulary concept identifying the measurement unit. For fixed_dose_form_count results this is the RxNorm dose form being counted; for clinical_injection_ingredient_amount results it is the UCUM ingredient unit. Strength units use UCUM. Codes are vocabulary-native and concept IDs belong to vocab_version.", "required": [ "concept_id", "code", "vocabulary_id" ], "properties": { "concept_id": { "type": "integer", "format": "int64" }, "code": { "type": "string" }, "vocabulary_id": { "type": "string" } } } } }, "example": [ { "resource_type": "MedicationRequest", "resource_id": "tablet-order", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 1000, "system": "http://unitsofmeasure.org", "code": "mg" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 1, "outcome": "DERIVED", "policy": "fixed_dose_form_count", "evidence": { "drug_concept_id": 100, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 300, "amount_value": 500, "amount_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } } }, "result": 2, "result_unit": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" } }, { "resource_type": "MedicationAdministration", "resource_id": "injection-dose", "source_path": "dosage.dose", "source_quantity": { "value": 80, "system": "http://unitsofmeasure.org", "code": "mL" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 2, "outcome": "DERIVED", "policy": "clinical_injection_ingredient_amount", "evidence": { "drug_concept_id": 101, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 201, "code": "316949", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 301, "numerator_value": 2, "numerator_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" }, "denominator_basis": { "kind": "PER_UNIT", "value": 1 }, "denominator_unit": { "concept_id": 401, "code": "mL", "vocabulary_id": "UCUM" } } }, "result": 160, "result_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } }, { "resource_type": "MedicationRequest", "resource_id": "counted-tablets", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 30, "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 4, "outcome": "DIRECT", "policy": "fixed_dose_form_count", "evidence": { "drug_concept_id": 100, "drug_concept_class": "Clinical Drug", "dose_form": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" }, "strength": { "ingredient_concept_id": 300, "amount_value": 500, "amount_unit": { "concept_id": 400, "code": "mg", "vocabulary_id": "UCUM" } } }, "result": 30, "result_unit": { "concept_id": 200, "code": "317541", "vocabulary_id": "RxNorm" } }, { "resource_type": "MedicationRequest", "resource_id": "free-text-unit", "source_path": "dispenseRequest.quantity", "source_quantity": { "value": 2, "unit": "tablet" }, "omop_table": "drug_exposure", "omop_field": "quantity", "omop_id": 3, "outcome": "OMITTED", "reason": "unsupported_unit" } ] }, "rows_for_review": { "type": "array", "description": "Index of clinical rows with uncertain source status and/or primary concept 0,\nfollowing the endpoint's eligibility policy. Each entry identifies an existing\nrow in tables; payloads are not moved or duplicated. Omitted when empty.\nUnresolved secondary units, routes, result values, or alternate codings alone\ndo not index a mapped row. Administrative/demographic, Specimen, and Death\nrows are not indexed.\n\nConsumers select or filter the linked table rows. If a selected row points\nto a visit or detail marked for exclusion, either keep that target or clear\nthe row's optional visit_occurrence_id / visit_detail_id links in the load\ncopy. Each included detail requires its parent visit; keep that parent or\nexclude the detail. Returned observation periods exclude indexed dates;\nrecompute them for a selected load if needed. Indexed rows may still lack\nCDM-required fields.\n", "items": { "type": "object", "description": "Metadata for one existing shaped row in tables. omop_table and omop_id\nform its unique response-local row key, also used by mappings and\ndiagnostics. One entry per indexed row, even with multiple reasons.\n", "required": [ "resource_type", "resource_id", "omop_table", "omop_id", "reasons" ], "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "source_full_url": { "type": "string", "description": "Original Bundle entry fullUrl, when supplied." }, "omop_table": { "type": "string" }, "omop_id": { "type": "integer", "format": "int64" }, "reasons": { "type": "array", "items": { "type": "string", "enum": [ "condition_verification_unconfirmed", "condition_verification_provisional", "condition_verification_differential", "condition_verification_unrecognized", "encounter_status_unknown", "encounter_status_unrecognized", "medication_statement_status_unknown", "observation_status_unknown", "procedure_status_unknown", "primary_concept_unresolved" ] } }, "source_statuses": { "type": "object", "description": "Supplied status, verificationStatus, and clinicalStatus fields copied\nverbatim from FHIR, including nulls or unreadable JSON values. Missing\nfields have no key. No inferred status is supplied.\n", "additionalProperties": true } } } }, "mappings": { "type": "array", "description": "Source-coding and text outcomes linked to emitted rows. Primary concepts,\ncoded routes/results, supplied Quantity units, and specimen sites have\nseparate entries; absent units/sites have none. Text-only sites and units\ncan have unmapped outcomes without vocabulary resolution.\n\nValues or routes retained outside a compatible destination column omit\nomop_field and have selected: false. Demographic entries link to their\nPerson field or emitted race Observation. See MappingEntry for selection\nand provenance semantics, and Summary for field-level counting.\n", "items": { "type": "object", "description": "Outcome for one source coding or supplied text, including source information\nretained without resolution. omop_table and omop_id identify the emitted row;\nomop_field identifies its populated concept column when applicable. A field\ncan have multiple coding entries sharing one resolution outcome. selected\nidentifies the source coding used in the linked row's source-value column.\n", "required": [ "selected" ], "example": { "resource_type": "Condition", "resource_id": "condition-123", "omop_table": "condition_occurrence", "omop_id": 7, "omop_field": "condition_concept_id", "source_system": "https://your-org.example/custom-codes", "source_code": "DX-123", "source_name": "Type 2 diabetes mellitus", "target_vocabulary": "SNOMED", "target_code": "44054006", "mapping_status": "MAPPED", "selected": true, "resolution": { "status": "RESOLVED", "semantic_mapping": { "status": "MAPPED", "vocab_version": "v20260829" } } }, "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "omop_table": { "type": "string" }, "omop_id": { "type": "integer", "format": "int64", "description": "The id of the OMOP row this coding produced (e.g. `condition_occurrence_id`),\nwithin `omop_table`. A resource with multiple codings yields one entry\nper coding, all sharing this id.\n" }, "omop_field": { "type": "string", "description": "The OMOP concept-ID field populated from this source coding, such as `condition_concept_id`, `route_concept_id`, or `race_concept_id`. Omitted when the entry preserves source information without populating a row column." }, "source_system": { "type": "string" }, "source_code": { "type": "string" }, "source_name": { "type": "string" }, "source_coding_index": { "type": "integer", "minimum": 0, "description": "Zero-based index of this coding in its originating specialty entry's coding array. When specialty audit is available, it also identifies the corresponding resolution.specialty_resolution.coding_results outcome. Present only for coded specialty mappings, including empty Coding objects; these mappings retain the supplied coding order." }, "target_vocabulary": { "type": "string" }, "target_code": { "type": "string", "description": "The standard concept's own code: the source code itself for an\nALREADY_STANDARD row, the standard concept's code for a MAPPED row,\nor the suggested code for an UNCHECKED row. Omitted for UNMAPPED\nrows.\n" }, "target_name": { "type": "string" }, "mapping_status": { "type": "string", "enum": [ "ALREADY_STANDARD", "MAPPED", "UNCHECKED", "UNMAPPED" ], "description": "ALREADY_STANDARD: the source coding is already an OMOP standard concept.\nMAPPED: coding or descriptive text resolved to a standard concept.\nUNCHECKED: a suggestion is unvalidated and concept ID remains 0.\nUNMAPPED: no valid target was selected, or information was retained without\nresolution as explained in note.\n\nSpecialty entries report the selected field-level outcome; independent\ncoding support remains in resolution.specialty_resolution.coding_results.\n" }, "selected": { "type": "boolean", "description": "Whether this coding supplies the row's source value; always present. False\nfor alternate codings, text-only rows, specialties, and entries without a\ncorresponding column. For demographics, marks the code determining the\nPerson field or race Observation, even without a resolved concept.\nRace/ethnicity null flavors, conflicting inputs, overridden Patient gender,\nand race categories not determining the field are unselected.\n" }, "resolution": { "type": "object", "description": "Field-level outcome and provenance shared by that field's coding entries.\nPaths describe the selected concept, not independent mappings of alternates.\nPresent for semantic attempts; omitted for source information retained\nwithout resolution, including text-only sites, units lacking supported\ncoding, and result values retained without a corresponding row column.\nAllergy evidence can retain source targets that were not selected as\nsubstance values.\n", "required": [ "status" ], "properties": { "semantic_mapping": { "type": "object", "required": [ "status", "vocab_version" ], "description": "Semantic-mapping outcome for a supported concept field; present when\ninference was attempted. The containing MappingEntry supplies row/field\nlinks. Multiple coding entries can share one field outcome; group by\nomop_table, omop_id, and omop_field when processing it. Original source\ncoding is preserved; text-only inputs do not invent coding.\n", "example": { "status": "UNMAPPED", "vocab_version": "v20260829", "reason_code": "AMBIGUOUS" }, "properties": { "status": { "type": "string", "enum": [ "MAPPED", "UNMAPPED" ], "description": "MAPPED when semantic mapping selected a validated standard OMOP concept; UNMAPPED when no standard concept was selected." }, "vocab_version": { "type": "string", "description": "OMOP vocabulary release selected for this mapping." }, "reason_code": { "type": "string", "enum": [ "MISSING_DESCRIPTION", "NO_VALID_SUGGESTION", "AMBIGUOUS", "INVALID_TARGET" ], "description": "Why semantic mapping did not select a standard concept. Present when\n`status` is UNMAPPED; omitted when `status` is MAPPED.\n\n- `MISSING_DESCRIPTION`: no usable source text or coding display was supplied.\n- `NO_VALID_SUGGESTION`: semantic validation completed without accepting a candidate as having the same clinical meaning as the source description.\n- `AMBIGUOUS`: a unique standard concept could not be selected from the possible matches.\n- `INVALID_TARGET`: the suggested code is not an active standard OMOP concept valid for the destination field.\n\nThe linked concept field retains ID 0. An unresolved result-value field\ndoes not unset the row's primary concept.\n" } } }, "specialty_resolution": { "type": "object", "required": [ "text_fallback_reason", "coding_results" ], "description": "Optional fallback decision and independent coding outcomes for one specialty\nentry. The enclosing resolution describes the selected result; unsupported\ncodings can coexist with successful explicit-text resolution. Omitted when\naudit evidence is unavailable; omission does not change the field outcome.\n", "properties": { "text_fallback_reason": { "type": "string", "enum": [ "NO_CODINGS", "INVALID_CODING", "SUPPORTED_SYSTEM_PRESENT", "NO_SPECIALTY_TEXT", "UNSUPPORTED_SYSTEMS_ONLY" ], "description": "NO_CODINGS identifies ordinary text-only resolution. INVALID_CODING\nmeans a missing code or missing/malformed system blocks fallback.\nSUPPORTED_SYSTEM_PRESENT blocks fallback even when a supported code\ndoes not resolve. NO_SPECIALTY_TEXT means complete unsupported\ncodings lack explicit nonblank text. UNSUPPORTED_SYSTEMS_ONLY means\ncomplete unsupported codings permit a text attempt; the attempt may\nstill be unresolved or ambiguous.\n" }, "coding_results": { "type": "array", "description": "Independent outcome of every supplied coding in its original order, including empty or incomplete objects. Empty for text-only specialties. Each mapping's source_coding_index identifies its corresponding outcome.", "items": { "type": "object", "required": [ "coding_index", "system_support", "status" ], "properties": { "coding_index": { "type": "integer", "minimum": 0, "description": "Zero-based index in the originating specialty entry's coding array." }, "system_support": { "type": "string", "enum": [ "SUPPORTED", "UNSUPPORTED", "INVALID" ], "description": "Whether the coding system is supported for resolution, unsupported, or missing/malformed. A missing code can still have a supported or unsupported system." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ], "description": "This coding's independent outcome before combining the entry's evidence." }, "reason_code": { "type": "string", "enum": [ "NO_SOURCE_CODE", "NO_OMOP_SOURCE_CONCEPT", "NO_STANDARD_MAP", "AMBIGUOUS", "DOMAIN_MISMATCH", "UNSUPPORTED_SYSTEM", "UNSUPPORTED_CODE" ], "description": "Machine-readable explanation when available; omitted for successful codings and unknown reasons." } } } } } }, "source_text": { "type": "string", "description": "Explicit source text used to select a specialty concept. Its vocabulary spelling or full preferred term is retained separately in paths[].matched_text." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ], "description": "Vocabulary resolution outcome. Any outcome other than RESOLVED yields mapping_status UNMAPPED and concept ID 0 while retaining an otherwise usable row." }, "reason_code": { "type": "string", "enum": [ "NO_SOURCE_CODE", "NO_OMOP_SOURCE_CONCEPT", "NO_STANDARD_MAP", "AMBIGUOUS", "DOMAIN_MISMATCH", "UNSUPPORTED_SYSTEM", "UNSUPPORTED_CODE", "CONFLICTING_ALLERGY_EVIDENCE", "UNSUPPORTED_ALLERGY_SOURCE", "UNSUPPORTED_ALLERGY_CONTEXT", "UNSUPPORTED_SOURCE_MEANING" ], "description": "Machine-readable explanation for an unresolved mapping, when available:\n\n- `NO_SOURCE_CODE`: no source coding was supplied.\n- `NO_OMOP_SOURCE_CONCEPT`: no OMOP source concept matches the supplied coding.\n- `NO_STANDARD_MAP`: no usable standard OMOP mapping was found for the supplied coding.\n- `AMBIGUOUS`: multiple candidate concepts could not be disambiguated.\n- `DOMAIN_MISMATCH`: candidate standard concepts do not match the domain required by the linked OMOP field.\n- `UNSUPPORTED_SYSTEM`: the source code system is unsupported.\n- `UNSUPPORTED_CODE`: the source code is unsupported for the linked OMOP field.\n- `CONFLICTING_ALLERGY_EVIDENCE`: allergy source meanings or context conflict.\n- `UNSUPPORTED_ALLERGY_SOURCE`: no supported allergy source meaning was established.\n- `UNSUPPORTED_ALLERGY_CONTEXT`: the source context has no supported finding policy.\n- `UNSUPPORTED_SOURCE_MEANING`: a known source concept has no supported allergy interpretation.\n\nUnknown reason codes are omitted; `status` still records the outcome.\n" }, "via": { "type": "string", "enum": [ "DIRECT", "UMLS_BRIDGE", "CONTEXTUAL", "CONCEPT_NAME", "CONCEPT_SYNONYM", "UMLS_STRING", "NUCC_LABEL" ], "description": "How the selected concept was reached: DIRECT uses vocabulary identity or\nMaps to; UMLS_BRIDGE uses a shared UMLS concept; CONTEXTUAL uses allergy\nsource context. Specialty text routes identify a concept name (CONCEPT_NAME),\nEnglish synonym (CONCEPT_SYNONYM), English UMLS string (UMLS_STRING), or\nNUCC preferred label (NUCC_LABEL). Omitted when unavailable or no concept\nwas selected; paths retain matching evidence.\n" }, "paths": { "type": "array", "description": "Mapping paths to the selected concept, in response order. Omitted when unavailable or no concept was selected.", "items": { "type": "object", "description": "Provenance path to the selected concept, starting at an input, UMLS sibling,\nor policy concept. Its source ID can differ from the original input's OMOP\nidentity and must not replace that input's source-concept column.\n", "required": [ "mapping_status", "source_concept_id" ], "properties": { "mapping_status": { "type": "string", "enum": [ "ALREADY_STANDARD", "MAPPED", "POLICY_MAPPED" ], "description": "Path outcome. MAPPED denotes an OMOP Maps to crosswalk; POLICY_MAPPED identifies an explicit vocabulary mapping policy and is retained here even though the enclosing mapping_status reports MAPPED." }, "source_concept_id": { "type": "integer", "format": "int64", "description": "OMOP concept at the start of this mapping path." }, "source_vocabulary": { "type": "string" }, "source_code": { "type": "string", "description": "Code of the path's source concept in its OMOP vocabulary." }, "cui": { "type": "string", "description": "Shared UMLS concept identifier for UMLS_BRIDGE, UMLS_STRING, or NUCC_LABEL, when supplied." }, "sab": { "type": "string", "description": "UMLS sibling source abbreviation, such as NUCCHCPT for NUCC routes." }, "matched_text": { "type": "string", "description": "Actual vocabulary string matched by a specialty text layer. For NUCC_LABEL this is the full original preferred term, including its grouping prefix; source_text retains the supplied text." } } } }, "truncated": { "type": "boolean", "description": "Present and true when candidate matches were truncated during resolution. Absence means no truncation was reported." }, "allergy": { "type": "object", "description": "Contextual finding policy and original coding interpretation, shared by the\nfield's mappings. When domain-based placement supplies a result outside\ncontextual coverage, this object retains the contextual no-match while the\nenclosing resolution describes placement. Missing mechanism, certainty, or\nactivity is not inferred from source statuses. incomplete describes source-interpretation\ncoverage; inspect finding and substance mappings independently for resolution.\n", "required": [ "method", "status", "categories", "effective_categories", "category_derived", "incomplete", "information_loss", "evidence" ], "properties": { "method": { "type": "string", "enum": [ "DIRECT", "CONTEXTUAL", "DERIVED", "UNRESOLVED" ], "description": "Direct vocabulary finding mapping, contextual finding selection, selection using a derived category, or no contextual finding selected." }, "status": { "type": "string", "enum": [ "RESOLVED", "UNRESOLVED", "DOMAIN_MISMATCH", "AMBIGUOUS" ] }, "reason_code": { "type": "string", "description": "Machine-readable reason for the contextual policy outcome, when available." }, "type": { "type": "string", "enum": [ "allergy", "intolerance" ], "description": "Supplied FHIR type; omitted when absent." }, "categories": { "type": "array", "description": "Supplied FHIR category values, preserving their order and repeats; null primitive placeholders are omitted. Empty when no category value is supplied.", "items": { "type": "string", "enum": [ "food", "medication", "environment", "biologic" ] } }, "clinical_status": { "type": "array", "description": "Supplied clinical-status codings; omitted when none are available.", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } }, "verification_status": { "type": "array", "description": "Supplied verification-status codings; omitted when absent. A retained unconfirmed statement is not promoted to confirmed.", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } }, "date_source": { "type": "string", "enum": [ "recordedDate", "onsetDateTime", "onsetPeriod.start" ], "description": "Source element selected by the existing date rule, including when its value has partial precision. Omitted when no usable or partial date is supplied; no date is invented." }, "effective_categories": { "type": "array", "description": "Distinct sorted categories used by the contextual policy, including any reviewed derivation.", "items": { "type": "string" } }, "category_derived": { "type": "boolean", "description": "Whether reviewed vocabulary evidence supplied an absent category. This can also accompany a direct finding." }, "incomplete": { "type": "boolean", "description": "Whether some coding evidence was uninterpretable or outside policy coverage." }, "information_loss": { "type": "array", "description": "Explanations of specificity omitted by the selected finding or published mapping. Source coding and context remain in the audit metadata.", "items": { "type": "string" } }, "evidence": { "type": "array", "items": { "type": "object", "description": "Interpretation of an original allergy code. Concept IDs are vocabulary evidence, not a selected value or a claim that a product's complete meaning fits one value field.", "required": [ "coding", "meaning", "standard_concept_ids" ], "properties": { "coding": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } }, "meaning": { "type": "string", "enum": [ "SUBSTANCE", "FINDING", "NEGATIVE", "UNSUPPORTED", "UNINTERPRETABLE" ] }, "source_concept_id": { "type": "integer", "format": "int64", "description": "Original coding's OMOP source identity, when known. This evidence does not override the linked row's source-concept semantics." }, "standard_concept_ids": { "type": "array", "description": "Standard targets reported for the original code. Empty when none are available; multiple targets do not choose one ingredient as the complete substance value.", "items": { "type": "integer", "format": "int64" } }, "category": { "type": "string", "description": "Reviewed substance category, when available." }, "reason_code": { "type": "string", "description": "Machine-readable interpretation gap, when available." } } } } } } } }, "note": { "type": "string", "description": "Explanatory context for source interpretation, table placement, unmapped\noutcomes, and values retained without a corresponding row column.\nDemographic notes identify the source and why a supplied value was not used.\nNotes are human-readable text, not stable identifiers; use selected,\nmapping_status, and resolution fields for programmatic decisions.\n" } } } }, "device_exposure_contexts": { "type": "array", "description": "One context per source record producing device exposures, with links to all\nderived rows and their shared timing, device evidence, and quantity basis.\nPreserved source values may contain clinical data.\n", "items": { "type": "object", "description": "Shared evidence and quantity explanation for all device exposures derived from one source record. Matching or absent resource identifiers do not merge distinct source records.", "required": [ "resource_type", "exposures", "quantity_basis" ], "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "source_full_url": { "type": "string" }, "exposures": { "type": "array", "minItems": 1, "description": "Links to all device exposure rows derived from this source record.", "items": { "type": "object", "required": [ "device_exposure_id" ], "properties": { "device_exposure_id": { "type": "integer", "format": "int64", "description": "Request-local ID of a row in tables.device_exposure." }, "event_index": { "type": "integer", "minimum": 0, "description": "Zero-based index in this context's supplied timingTiming.event evidence, including unusable events retained as partial rows. Omitted for other timing forms." } } } }, "quantity_basis": { "type": "string", "enum": [ "default_absent_count", "unsupported_supplied_evidence" ], "description": "Applies to every linked exposure. default_absent_count identifies the default quantity of 1. unsupported_supplied_evidence identifies omitted quantity due to supplied clinical quantity evidence, including null or malformed numeric fields. UNSUPPORTED diagnostics identify the source paths." }, "evidence": { "type": "array", "description": "Original supplied source values with source paths. Device detail paths begin with device.; other paths refer to the clinical source resource. Timing precision, offsets, schedules, statuses, relationships, UDI carriers, and unsupported quantities are preserved here.", "items": { "type": "object", "required": [ "path", "value" ], "properties": { "path": { "type": "string" }, "value": { "description": "Original supplied JSON value, including null or malformed source evidence.", "nullable": true } } } } }, "example": { "resource_type": "DeviceUseStatement", "resource_id": "use-1", "exposures": [ { "device_exposure_id": 1, "event_index": 0 }, { "device_exposure_id": 2, "event_index": 1 } ], "quantity_basis": "default_absent_count", "evidence": [ { "path": "timingTiming", "value": { "event": [ "2026-01-01T09:00:00Z", "2026-01-03T09:00:00Z" ] } } ] } } }, "specimen_source_contexts": { "type": "array", "description": "Identity, availability, and collection timing for emitted specimens, linked\nby specimen_id. Retains original timing precision/offsets and source\nidentifiers; source_id_path identifies the selected specimen source ID.\n", "items": { "type": "object", "required": [ "specimen_id" ], "properties": { "specimen_id": { "type": "integer", "format": "int64" }, "resource_id": { "type": "string" }, "full_url": { "type": "string" }, "status": { "type": "string", "enum": [ "available", "unavailable", "unsatisfactory" ], "description": "Original FHIR Specimen.status for this emitted row, describing sample availability or suitability. Omitted when no status was supplied; no availability is inferred. This is source metadata, not an OMOP disease-status concept." }, "identifiers": { "type": "array", "items": { "type": "object", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } } }, "accession_identifier": { "type": "object", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } }, "source_id_path": { "type": "string", "description": "Selected source path (id, identifier[index].value, accessionIdentifier.value, or fullUrl); absent if no source identity was supplied." }, "collection_timing": { "type": "object", "description": "Supplied FHIR timing retained verbatim for audit and downstream completion. This is response provenance, not a CDM table or an inferred collection date.", "properties": { "collected_date_time": { "type": "string", "description": "Original collection.collectedDateTime, including partial precision, invalid text, or timezone offset." }, "collected_period": { "type": "object", "properties": { "start": { "type": "string", "description": "Original collectedPeriod.start, without precision completion." }, "end": { "type": "string", "description": "Original collectedPeriod.end, retained without using it as collection start." } } }, "received_time": { "type": "string", "description": "Original receivedTime, never substituted for collection timing." }, "selected_path": { "type": "string", "description": "collection.collectedDateTime or collection.collectedPeriod.start when specimen_date was populated; omitted when no date could safely be selected." } } } } } }, "medication_dispense_source_contexts": { "type": "array", "description": "Supplied dispensing context linked to each emitted dispense's actual output\ntable and row. Omitted when no dispense is emitted. This provenance does not\nestablish administration or adherence.\n", "items": { "type": "object", "required": [ "omop_table", "omop_id", "source" ], "description": "Original dispensing context linked to an emitted clinical row by its actual\ntable and request-local ID, including destinations outside drug_exposure.\nPreserved source values do not establish exposure duration or medication use.\n", "properties": { "resource_id": { "type": "string", "description": "Original MedicationDispense.id, when supplied." }, "full_url": { "type": "string", "description": "Original Bundle entry fullUrl, when supplied." }, "omop_table": { "type": "string", "enum": [ "drug_exposure", "condition_occurrence", "procedure_occurrence", "device_exposure", "measurement", "observation" ] }, "omop_id": { "type": "integer", "format": "int64" }, "source": { "type": "object", "additionalProperties": true, "description": "Only supplied fields are present, using original FHIR names and values: status, statusReasonCodeableConcept, statusReasonReference, category, type, whenPrepared, whenHandedOver, daysSupply, performer, context, authorizingPrescription, dosageInstruction, and medicationReference. Raw values preserve original precision, offsets, explicit nulls, and malformed values. Presence is not a promise that a value was mapped; diagnostics explain unusable values and mappings describe coded outcomes. Direct quantities are audited separately in quantity_transformations for drug_exposure rows." } } } }, "provider_role_contexts": { "type": "array", "description": "Source context for every PractitionerRole linked to an emitted provider.\nPreserves role-specific facts that the provider's singular specialty and\ncare-site columns cannot represent together.\n", "items": { "type": "object", "description": "Source FHIR PractitionerRole context linked to one response-local provider row.", "required": [ "provider_id" ], "properties": { "provider_id": { "type": "integer", "format": "int64" }, "role_source_value": { "type": "string", "description": "The PractitionerRole source identity: its FHIR id, identifier value,\nname, or fullUrl. When none is available, it is `PractitionerRole`.\n" }, "practitioner_reference": { "type": "string", "description": "The role's supplied practitioner reference, when present." }, "practitioner_identifier": { "type": "object", "description": "The logical identifier supplied on a PractitionerRole's practitioner reference. Preserves unknown NPI markers even though they are ignored for identity matching.", "required": [ "value" ], "properties": { "system": { "type": "string" }, "value": { "type": "string" } } }, "role_codes": { "type": "array", "items": { "type": "object", "properties": { "source_value": { "type": "string" }, "codings": { "type": "array", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } } } } }, "specialties": { "type": "array", "items": { "type": "object", "properties": { "source_value": { "type": "string" }, "codings": { "type": "array", "items": { "type": "object", "properties": { "system": { "type": "string" }, "code": { "type": "string" }, "display": { "type": "string" } } } } } } }, "care_sites": { "type": "array", "description": "Every organization, healthcareService, or location reference supplied by the role.", "items": { "type": "object", "required": [ "path", "reference" ], "properties": { "path": { "type": "string", "description": "The FHIR element path on the PractitionerRole." }, "reference": { "type": "string" }, "care_site_id": { "type": "integer", "format": "int64" } } } }, "active": { "type": "boolean" }, "period_start": { "type": "string" }, "period_end": { "type": "string" } } } }, "dropped": { "type": "array", "description": "Supported resources that cannot produce a row because of clinical eligibility\nor unusable patient, code/text, or medication evidence. Provider organizations\nand roles without a confirmed individual NPI or usable Practitioner are also\nreported. Unsupported resource types are ignored. Missing dates or other\nCDM-required fields usually retain partial rows; see resource-specific policies\nfor required evidence.\n\nEligibility exclusions use stable resource-specific reason codes; other\nshaping failures use explanatory reason text.\n", "items": { "type": "object", "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "reason": { "type": "string" } } } }, "diagnostics": { "type": "array", "description": "Explains missing or unusable source data, unresolved links, and conflicting\nor unsupported values. When an affected row is emitted, omop_table and\nomop_id identify it; otherwise both are omitted. Shared issues may link to\nseveral rows. Diagnostics can accompany retained rows or dropped resources.\n\noutcome classifies the issue, path identifies the source field, and reason\nprovides context. Missing optional references do not produce diagnostics.\nReferences resolve only against resources supplied in this request. An invalid\nor unconfirmed NPI omitted from a retained Practitioner has an UNRESOLVED\ndiagnostic at identifier.\n", "items": { "type": "object", "description": "Explains why source data or a reference could not be used. omop_table and\nomop_id identify the affected emitted row, not a rejected target; both are\nomitted when no affected row is emitted. Multiple source resources can link\nto one row. IDs are local to this response.\n", "properties": { "resource_type": { "type": "string" }, "resource_id": { "type": "string" }, "omop_table": { "type": "string", "description": "Table containing the affected row in this response. Present together with omop_id when that row is emitted." }, "omop_id": { "type": "integer", "format": "int64", "description": "Primary key of the affected row within omop_table in this response. Present together with omop_table when that row is emitted." }, "path": { "type": "string", "description": "Source field or diagnostic label. Demographic labels include\n`extension:birthsex` and `extension:ethnicity`; provider identity labels\nare `name`, `gender`, `birthDate`, and `identifier`. For Encounters,\n`class/type` identifies class/type disagreement and `type` identifies\nconflicting type classifications. Joint rules can use slash-separated\npaths such as `whenHandedOver/daysSupply`.\n" }, "reference": { "type": "string", "description": "The supplied Reference.reference value, when present." }, "outcome": { "type": "string", "enum": [ "UNRESOLVED", "AMBIGUOUS", "CONFLICTING", "UNSUPPORTED" ], "description": "- UNRESOLVED: required source data is missing, or a supported reference cannot\n resolve to a supplied resource or emitted target.\n- AMBIGUOUS: a reference or identifier does not identify a unique target.\n- CONFLICTING: source values or relationships disagree or require review\n under the mapping policy.\n- UNSUPPORTED: a source form/type or relationship cannot be fully represented\n or assessed under the supported policy.\n\nreason explains the effect on the row or link. An outcome alone does not\nimply that the resource was dropped; partial rows or grouping can be retained.\n" }, "reason": { "type": "string", "description": "Explanation of the condition and its effect on mapping. Resource-specific\nreason codes can be followed by `; ` and explanatory text; match these\ncodes as prefixes rather than whole strings. Collection timing uses\nspecimen_collection_date_missing, specimen_collection_date_partial,\nspecimen_collection_date_unusable, or specimen_collection_multiple_forms.\nDispensing timing uses medication_dispense_handover_missing,\nmedication_dispense_handover_partial, or medication_dispense_handover_unusable.\nmedication_dispense_handover_before_preparation identifies conflicting\nhandover/preparation timing;\nmedication_dispense_end_date_absent identifies an unset exposure end.\n" } } } }, "vocab_version": { "type": "string", "description": "The OMOP vocabulary release used for coded concept resolution\n(for example, \"v20260829\"), for reproducibility. Omitted when no\nvocabulary resolution was performed.\n" }, "summary": { "type": "object", "description": "Resolution outcome counts and the share not already standard. Each evaluated\nfield contributes one outcome even when several codings produce mappings.\n\n| Included outcomes | Counting unit |\n| --- | --- |\n| Primary clinical concepts, specimen material/sites, supplied Quantity units on Measurement/Observation/Specimen, coded Observation results on Measurement/Observation, allergy substance values, Encounter classifications, Address.country, CMS Place of Service, and recorded Practitioner gender | Each evaluated field |\n| Coded medication/Immunization routes, including context on other destinations | Each source-selected route; report-only alternates do not add outcomes |\n| Provider specialties | Each distinct input per provider |\n| Patient demographics | Each selected Person field or emitted race Observation; conflicting values count once as unmapped |\n\nAbsent specimen material/sites and units do not count. Demographic null\nflavors, Patient gender other/unknown or overridden by birth sex, and race\ncategories not determining a field are reported only in mappings.\nObservation values retained without a corresponding row column, quantity\naudits, and visit compatibility assessments do not add resolution outcomes.\nDropped resources do not count; indexed rows remain included in codes_*\nand off_vocab_rate.\n", "properties": { "codes_already_standard": { "type": "integer", "description": "Resolution outcomes already a standard OMOP concept (ALREADY_STANDARD)." }, "codes_normalized": { "type": "integer", "description": "Resolution outcomes mapped or suggested to a standard concept (MAPPED or UNCHECKED)." }, "codes_unmapped": { "type": "integer", "description": "Resolution outcomes with no standard concept valid for the destination selected (UNMAPPED)." }, "rows_for_review": { "type": "integer", "description": "Length of the rows_for_review index; each row counts once even with multiple retention reasons. codes_* and off_vocab_rate include all shaped rows; dropped resources do not count." }, "off_vocab_rate": { "type": "number", "format": "double", "description": "Share of resolution outcomes not already standard ((normalized + unmapped) / total)." } } } } } ``` **401** - Unauthorized **500** - Internal server error --- # Agent Create AI agents that can query and interact with electronic health records using natural language. ## Agent / Chat Conversational sessions with an agent. ### POST /agent/chat **Chat with agent** Send a message to an agent and receive a JSON response. **Operation ID:** `agent_send` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "message", "agent_id" ], "properties": { "message": { "type": "string", "description": "The message to send to the agent", "example": "What is the patient's current condition?" }, "context": { "type": "string", "description": "Optional context for the conversation", "example": "Respond concisely and with clear rationale" }, "session_id": { "type": "string", "description": "Optional session ID for conversation continuity. Only one request may be active for a session at a time; overlapping turns for the same session return 409 Conflict.", "example": "session-abc123" }, "agent_id": { "type": "string", "description": "The ID of the agent to chat with", "example": "agent-123" }, "enhanced_reasoning": { "type": "boolean", "description": "Enable enhanced reasoning capabilities. Increases latency but improves response quality and reliability.", "default": false, "example": false } } } ``` **Example:** ```json { "message": "What is the patient's current condition?", "agent_id": "agent-123", "session_id": "session-abc123" } ``` #### Responses **200** - Chat response received successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "response": { "type": "string", "description": "Agent's response", "example": "I'll create a patient record for John Doe with diabetes. Let me process that information..." }, "success": { "type": "boolean", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Chat response generated successfully" }, "session_id": { "type": "string", "description": "Chat session ID", "example": "session_123" } } } ``` **Example:** ```json { "success": true, "message": "Response generated successfully", "response": "Based on the patient records, they have been diagnosed with Type 2 Diabetes Mellitus (ICD-10: E11.65) and Essential Hypertension (ICD-10: I10). Current medications include Metformin 500mg BID and Lisinopril 10mg daily. Most recent HbA1c was 7.2% on 2024-12-15.", "session_id": "session-abc123" } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent or session not found **409** - Chat session already has an active request. Retry after the in-flight turn completes. **500** - Server error **504** - Request timed out --- ### GET /agent/chat/messages **Get chat messages** Retrieves a list of chat messages for a given chat session **Operation ID:** `agent_listMessages` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `chat_session_id` | query | string | Yes | Chat session ID | | `num_messages` | query | integer | No | Number of messages to return | | `role` | query | string | No | Filter by one or more message roles. Multiple roles can be specified as a comma-separated string. If not specified, messages with all roles are returned. **Available roles:** - `user` - Messages from the user - `assistant` - Text responses from the AI assistant - `model` - Function/tool call requests from the model - `function` - Function/tool call results | | `order` | query | string | No | Order of messages | #### Responses **200** - Chat messages retrieved successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Chat message ID", "example": "message_123" }, "session_id": { "type": "string", "description": "Chat session ID", "example": "session_123" }, "role": { "type": "string", "description": "Message role indicating the source/type of the message:\n- `user` - Messages from the user\n- `assistant` - Text responses from the AI assistant\n- `model` - Function/tool call requests to the model\n- `function` - Function/tool call results\n", "enum": [ "user", "assistant", "model", "function" ], "example": "user" }, "content": { "type": "string", "description": "Message content", "example": "Hello, how are you?" }, "created": { "type": "string", "description": "Message created time", "example": "2021-01-01T00:00:00Z" }, "updated": { "type": "string", "description": "Message updated time", "example": "2021-01-01T00:00:00Z" }, "function_name": { "type": "string", "description": "Function name", "example": "get_patient_info" }, "function_args": { "type": "object", "description": "Function arguments", "example": { "patient_id": "123" } }, "function_result": { "type": "object", "description": "Function result", "example": { "name": "John Doe" } }, "message_order": { "type": "integer", "description": "Message order", "example": 1 } } } }, "total": { "type": "integer", "example": 10 }, "session_id": { "type": "string", "example": "session_123" } } } ``` **Example:** ```json { "session_id": "session_123", "total": 2, "messages": [ { "id": "message_001", "session_id": "session_123", "role": "user", "content": "What is the patient's current condition?", "created": "2025-03-01T14:00:00Z", "updated": "2025-03-01T14:00:00Z", "message_order": 1 }, { "id": "message_002", "session_id": "session_123", "role": "assistant", "content": "Based on the patient records, they have been diagnosed with Type 2 Diabetes Mellitus (ICD-10: E11.65).", "created": "2025-03-01T14:00:02Z", "updated": "2025-03-01T14:00:02Z", "message_order": 2 } ] } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Chat session not found **500** - Server error **504** - Request timed out --- ### POST /agent/stream-chat **Chat with agent (streaming)** Send a message to an agent and receive the response as a Server-Sent Events (SSE) stream. Events include message_start, content_delta, tool_use, tool_result, message_end, and error. **Operation ID:** `agent_stream` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "description": "Request body for the streaming chat endpoint.", "required": [ "message", "agent_id" ], "properties": { "message": { "type": "string", "description": "The message to send to the agent", "example": "What is the patient's current condition?" }, "context": { "type": "string", "description": "Optional context for the conversation", "example": "Respond concisely and with clear rationale" }, "session_id": { "type": "string", "description": "Optional session ID for conversation continuity. Only one request may be active for a session at a time; overlapping turns for the same session return 409 Conflict.", "example": "session-abc123" }, "agent_id": { "type": "string", "description": "The ID of the agent to chat with", "example": "agent-123" }, "enhanced_reasoning": { "type": "boolean", "description": "Enable enhanced reasoning capabilities. Increases latency but improves response quality and reliability.", "default": false, "example": false } } } ``` **Example:** ```json { "message": "What is the patient's current condition?", "agent_id": "agent-123", "session_id": "session-abc123" } ``` #### Responses **200** - Streaming chat response. Each frame is a standard SSE record (`event:` line + `data:` JSON line). The example shows a single `content_delta` payload — multiple frames stream until `message_end`. Content-Type: `text/event-stream` ```json { "type": "object", "description": "JSON payload sent in the `data:` line of a Server-Sent Event (SSE) frame for streaming chat responses.\nEach SSE frame uses the standard `event:` and `data:` lines; this schema describes the JSON object\nin the `data:` line. The event type is encoded in the top-level `type` property.\nEvent types: message_start, content_delta, tool_use, tool_result, message_end, error.\n", "properties": { "type": { "type": "string", "description": "The event type", "enum": [ "message_start", "content_delta", "tool_use", "tool_result", "message_end", "error" ], "example": "content_delta" }, "session_id": { "type": "string", "description": "Chat session ID", "example": "session_123" }, "content": { "type": "string", "description": "Incremental text content (present in content_delta events)", "example": "I'll create a patient record..." }, "success": { "type": "boolean", "description": "Whether the operation was successful", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Response generated successfully" }, "function_name": { "type": "string", "description": "Tool/function name (present in tool_use and tool_result events)", "example": "lang2fhir_search" }, "function_args": { "type": "object", "description": "Tool arguments (present in tool_use events)", "additionalProperties": true }, "function_result": { "type": "object", "description": "Tool execution result (present in tool_result events)", "additionalProperties": true } } } ``` **Example:** ```json { "type": "content_delta", "session_id": "session-abc123", "content": "Based on the patient records, " } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent or session not found **409** - Chat session already has an active request. Retry after the in-flight turn completes. **500** - Server error **504** - Request timed out --- ## Agent / Prompts Reusable prompt templates that agents can attach to chats. ### POST /agent/prompts **Create agent prompt** Creates a new agent prompt **Operation ID:** `agent_createPrompt` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "content" ], "properties": { "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant specialized in FHIR data processing..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } ``` **Example:** ```json { "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant specialized in FHIR data processing.", "is_default": false, "tags": [ "medical", "system" ] } ``` #### Responses **201** - Prompt created successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Prompt ID", "example": "prompt_123" }, "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } } } ``` **Example:** ```json { "success": true, "message": "Prompt created successfully", "data": { "id": "prompt_123", "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant...", "is_default": false, "tags": [ "medical", "system" ] } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ### GET /agent/prompts/{id} **Get prompt by ID** Retrieves a specific prompt by its ID **Operation ID:** `agent_getPrompt` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Prompt ID | #### Responses **200** - Prompt retrieved successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Prompt ID", "example": "prompt_123" }, "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } } } ``` **Example:** ```json { "success": true, "message": "Prompt retrieved successfully", "data": { "id": "prompt_123", "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant...", "is_default": false, "tags": [ "medical", "system" ] } } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Prompt not found **500** - Server error --- ### PUT /agent/prompts/{id} **Update prompt** Updates an existing prompt **Operation ID:** `agent_updatePrompt` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Prompt ID | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "properties": { "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant specialized in FHIR data processing..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } ``` **Example:** ```json { "name": "Medical Assistant System Prompt", "description": "Updated system prompt", "content": "You are a helpful medical assistant. Always cite ICD-10 codes when discussing diagnoses.", "is_default": false, "tags": [ "medical", "system", "updated" ] } ``` #### Responses **200** - Prompt updated successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Prompt ID", "example": "prompt_123" }, "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } } } ``` **Example:** ```json { "success": true, "message": "Prompt updated successfully", "data": { "id": "prompt_123", "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant...", "is_default": false, "tags": [ "medical", "system" ] } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Prompt not found **500** - Server error --- ### DELETE /agent/prompts/{id} **Delete prompt** Deletes a prompt **Operation ID:** `agent_deletePrompt` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Prompt ID | #### Responses **200** - Prompt deleted successfully Content-Type: `application/json` ```json { "type": "object", "title": "PromptsDeleteResponse", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Prompt deleted successfully" } } } ``` **Example:** ```json { "success": true, "message": "Prompt deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Prompt not found **500** - Server error --- ### PATCH /agent/prompts/{id} **Patch prompt** Patches an existing prompt **Operation ID:** `agent_patchPrompt` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Agent Prompt ID | #### Request Body **Required:** Yes **Content-Type:** `application/json+patch` ```json { "type": "array", "description": "RFC 6902 JSON Patch document", "items": { "type": "object", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "enum": [ "add", "remove", "replace", "move", "copy", "test" ], "description": "The operation to be performed", "example": "replace" }, "path": { "type": "string", "description": "A JSON Pointer string specifying a location within the target document", "example": "/name" }, "value": { "description": "The value to be used within the operations", "example": "New Agent Name" }, "from": { "type": "string", "description": "A JSON Pointer string specifying the location in the target document to move the value from (used with move and copy operations)", "example": "/oldName" } } }, "example": [ { "op": "replace", "path": "/name", "value": "Updated Agent Name" }, { "op": "add", "path": "/tags/-", "value": "new-tag" }, { "op": "remove", "path": "/description" } ] } ``` **Example:** ```json [ { "op": "replace", "path": "/content", "value": "Updated prompt content." } ] ``` #### Responses **200** - Prompt patched successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Prompt ID", "example": "prompt_123" }, "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } } } ``` **Example:** ```json { "success": true, "message": "Prompt patched successfully", "data": { "id": "prompt_123", "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant...", "is_default": false, "tags": [ "medical", "system" ] } } ``` **400** - Failed to apply JSON patch. **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Prompt not found **500** - Internal Server Error --- ### GET /agent/prompts/list **List agent prompts** Retrieves a list of agent prompts belonging to the authenticated user **Operation ID:** `agent_listPrompts` #### Responses **200** - Prompts retrieved successfully Content-Type: `application/json` ```json { "type": "object", "title": "PromptsListResponse", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Prompts retrieved successfully" }, "prompts": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Prompt ID", "example": "prompt_123" }, "name": { "type": "string", "description": "Prompt name", "example": "Medical Assistant System Prompt" }, "description": { "type": "string", "description": "Prompt description", "example": "System prompt for medical assistant agent" }, "content": { "type": "string", "description": "Prompt content", "example": "You are a helpful medical assistant..." }, "is_default": { "type": "boolean", "description": "Whether this is a default prompt", "example": false }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the prompt", "example": [ "medical", "system" ] } } } } } } ``` **Example:** ```json { "success": true, "message": "Prompts retrieved successfully", "prompts": [ { "id": "prompt_123", "name": "Medical Assistant System Prompt", "description": "System prompt for medical assistant agent", "content": "You are a helpful medical assistant...", "is_default": false, "tags": [ "medical", "system" ] }, { "id": "prompt_456", "name": "Clinical Coding Prompt", "description": "Prompt for ICD-10 / SNOMED coding tasks", "content": "You assist with mapping clinical text to standard codes...", "is_default": false, "tags": [ "coding" ] } ] } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ## Untagged ### GET /agent/{id} **Get agent by ID** Retrieves a specific agent by its ID **Operation ID:** `agent_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Agent ID | #### Responses **200** - Agent retrieved successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Agent ID", "example": "agent_123" }, "name": { "type": "string", "description": "Agent name", "example": "Medical Assistant" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs used by this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs used by this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs exposed as tools by this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } } } ``` **Example:** ```json { "success": true, "message": "Agent retrieved successfully", "data": { "id": "agent_123", "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123", "prompt_456" ], "tools": [ "mcp_server_123", "mcp_server_456" ], "workflows": [ "workflow_123", "workflow_456" ], "tags": [ "medical", "fhir" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent not found **500** - Server error --- ### PUT /agent/{id} **Update agent** Updates an existing agent's configuration **Operation ID:** `agent_update` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Agent ID | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "prompts", "provider" ], "properties": { "name": { "type": "string", "description": "Agent name" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs to use for this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs to use for this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs to expose as tools for this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) for this agent. Required.\nIn shared/experiment environments, the default sandbox provider is used if a different provider is not explicitly specified.\n", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } ``` **Example:** ```json { "name": "Medical Assistant", "description": "Updated description for the medical assistant", "prompts": [ "prompt_123" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35", "tags": [ "medical", "fhir", "updated" ] } ``` #### Responses **200** - Agent updated successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Agent ID", "example": "agent_123" }, "name": { "type": "string", "description": "Agent name", "example": "Medical Assistant" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs used by this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs used by this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs exposed as tools by this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } } } ``` **Example:** ```json { "success": true, "message": "Agent updated successfully", "data": { "id": "agent_123", "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123", "prompt_456" ], "tools": [ "mcp_server_123", "mcp_server_456" ], "workflows": [ "workflow_123", "workflow_456" ], "tags": [ "medical", "fhir" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent not found **500** - Server error --- ### DELETE /agent/{id} **Delete agent** Deletes an existing agent **Operation ID:** `agent_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Agent ID | #### Responses **200** - Agent deleted successfully Content-Type: `application/json` ```json { "type": "object", "title": "DeleteResponse", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Agent deleted successfully" } } } ``` **Example:** ```json { "success": true, "message": "Agent deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent not found **500** - Server error --- ### PATCH /agent/{id} **Patch agent** Patches an existing agent's configuration **Operation ID:** `agent_patch` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string | Yes | Agent ID | #### Request Body **Required:** Yes **Content-Type:** `application/json+patch` ```json { "type": "array", "description": "RFC 6902 JSON Patch document", "items": { "type": "object", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "enum": [ "add", "remove", "replace", "move", "copy", "test" ], "description": "The operation to be performed", "example": "replace" }, "path": { "type": "string", "description": "A JSON Pointer string specifying a location within the target document", "example": "/name" }, "value": { "description": "The value to be used within the operations", "example": "New Agent Name" }, "from": { "type": "string", "description": "A JSON Pointer string specifying the location in the target document to move the value from (used with move and copy operations)", "example": "/oldName" } } }, "example": [ { "op": "replace", "path": "/name", "value": "Updated Agent Name" }, { "op": "add", "path": "/tags/-", "value": "new-tag" }, { "op": "remove", "path": "/description" } ] } ``` **Example:** ```json [ { "op": "replace", "path": "/description", "value": "patched description" }, { "op": "add", "path": "/tags/-", "value": "updated" } ] ``` #### Responses **200** - Agent patched successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Agent ID", "example": "agent_123" }, "name": { "type": "string", "description": "Agent name", "example": "Medical Assistant" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs used by this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs used by this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs exposed as tools by this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } } } ``` **Example:** ```json { "success": true, "message": "Agent patched successfully", "data": { "id": "agent_123", "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123", "prompt_456" ], "tools": [ "mcp_server_123", "mcp_server_456" ], "workflows": [ "workflow_123", "workflow_456" ], "tags": [ "medical", "fhir" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } ``` **400** - Failed to apply JSON patch. **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **404** - Agent not found **500** - Internal Server Error --- ### POST /agent/create **Create a new agent** Creates a new PhenoAgent with specified configuration **Operation ID:** `agent_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "prompts", "provider" ], "properties": { "name": { "type": "string", "description": "Agent name" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs to use for this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs to use for this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs to expose as tools for this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) for this agent. Required.\nIn shared/experiment environments, the default sandbox provider is used if a different provider is not explicitly specified.\n", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } ``` **Example:** ```json { "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35", "tags": [ "medical", "fhir" ] } ``` #### Responses **201** - Agent created successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "properties": { "id": { "type": "string", "description": "Agent ID", "example": "agent_123" }, "name": { "type": "string", "description": "Agent name", "example": "Medical Assistant" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs used by this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs used by this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs exposed as tools by this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } } } ``` **Example:** ```json { "success": true, "message": "Agent created successfully", "data": { "id": "agent_123", "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123", "prompt_456" ], "tools": [ "mcp_server_123", "mcp_server_456" ], "workflows": [ "workflow_123", "workflow_456" ], "tags": [ "medical", "fhir" ], "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ### GET /agent/list **List agents** Retrieves a list of PhenoAgents belonging to the authenticated user **Operation ID:** `agent_list` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `tags` | query | string | No | Filter by tags | #### Responses **200** - Agents retrieved successfully Content-Type: `application/json` ```json { "type": "object", "title": "ListResponse", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Agents retrieved successfully" }, "agents": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Agent ID", "example": "agent_123" }, "name": { "type": "string", "description": "Agent name", "example": "Medical Assistant" }, "description": { "type": "string", "description": "Agent description", "example": "An AI assistant for medical information processing" }, "prompts": { "type": "array", "items": { "type": "string" }, "description": "Array of prompt IDs used by this agent", "example": [ "prompt_123", "prompt_456" ] }, "tools": { "type": "array", "items": { "type": "string" }, "description": "Array of MCP server tool IDs used by this agent", "example": [ "mcp_server_123", "mcp_server_456" ] }, "workflows": { "type": "array", "items": { "type": "string" }, "description": "Array of workflow IDs exposed as tools by this agent", "example": [ "workflow_123", "workflow_456" ] }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags for categorizing the agent", "example": [ "medical", "fhir" ] }, "provider": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Array of FHIR provider IDs" } ], "description": "FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers", "example": "7002b0b4-8d09-445a-bf65-0fafdaf26c35" } } } } } } ``` **Example:** ```json { "success": true, "message": "Agents retrieved successfully", "agents": [ { "id": "agent_123", "name": "Medical Assistant", "description": "An AI assistant for medical information processing", "prompts": [ "prompt_123" ], "tags": [ "medical", "fhir" ], "provider": [ "7002b0b4-8d09-445a-bf65-0fafdaf26c35" ] }, { "id": "agent_456", "name": "Clinical Coding Assistant", "description": "Helps with ICD-10 and SNOMED coding", "prompts": [ "prompt_456" ], "tags": [ "coding" ], "provider": [ "7002b0b4-8d09-445a-bf65-0fafdaf26c35" ] } ] } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- # Workflow Create and execute clinical workflows. Define workflow logic and test execution with sample data. ## Endpoints ### GET /workflows **List all workflows** Retrieves all workflow definitions for the authenticated user **Operation ID:** `workflows_list` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `verbose` | query | boolean | No | If true, includes full workflow implementation details in workflow_details field | #### Responses **200** - Successfully retrieved workflows Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the workflow list was retrieved successfully", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Workflows retrieved successfully" }, "workflows": { "type": "array", "items": { "type": "object", "description": "Simplified workflow representation without implementation details", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "description": "Simplified workflow step without implementation details", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "step_1_id" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Find Patient" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Search for an existing patient by first name and last name" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "search" }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" } } }, "description": "Simplified list of workflow steps without operation details" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } }, "description": "Array of simplified workflow responses for the authenticated user" }, "workflow_details": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "1" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Create Patient Resource" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Create a FHIR Patient resource from input data" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "create" }, "operation": { "type": "object", "properties": { "search_definition": { "type": "object", "properties": { "original_query": { "type": "string", "description": "Original natural language query", "example": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name" }, "resource_type": { "type": "string", "description": "FHIR resource type to search", "example": "Patient" }, "search_parameters": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR search parameters", "example": { "family": "{{patient_last_name}}", "given": "{{patient_first_name}}" } }, "required_fields": { "type": "array", "items": { "type": "string" }, "description": "Fields needed from search results", "example": [ "id", "name", "identifier" ] }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{patient_first_name}}": "input.patient_first_name", "{{patient_last_name}}": "input.patient_last_name" } } } }, "create_definition": { "type": "object", "properties": { "original_description": { "type": "string", "description": "Original natural language description", "example": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01" }, "resource_type": { "type": "string", "description": "FHIR resource type to create", "example": "Condition" }, "resource_template": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR resource template", "example": { "resourceType": "Condition", "code": { "coding": [ { "code": "{{diagnosis_code}}", "system": "http://hl7.org/fhir/sid/icd-10" } ] }, "subject": { "reference": "Patient/{{step_1_id}}" } } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{diagnosis_code}}": "input.diagnosis_code", "{{diagnosis_date}}": "input.diagnosis_date" } } } }, "workflow_definition": { "type": "object", "properties": { "workflow_id": { "type": "string", "format": "uuid", "description": "ID of the workflow to execute as a sub-workflow", "example": "550e8400-e29b-41d4-a716-446655440002" }, "input": { "type": "object", "additionalProperties": true, "description": "Input data to pass to the sub-workflow", "example": { "patient_id": "{{step_1_id}}", "additional_context": "laboratory_results" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for sub-workflow", "example": { "{{step_1_id}}": "step_1.result.id", "{{patient_data}}": "input.patient_data" } } } }, "decision_definition": { "type": "object", "properties": { "expression": { "type": "string", "description": "Simple equality expression for decision logic", "example": "input.patient_age >= 18" }, "paths": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps decision outcomes to next step IDs", "example": { "true": "step_adult_workflow", "false": "step_pediatric_workflow", "default": "step_error_handler" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for decision evaluation", "example": { "{{patient_age}}": "input.patient_age", "{{diagnosis_type}}": "step_2.result.diagnosis_category" } } } } } }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" }, "dependencies": { "type": "array", "items": { "type": "string" }, "description": "IDs of steps this step depends on", "example": [] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation for this step", "example": false } } }, "description": "Ordered list of workflow execution steps" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } }, "description": "Only included when verbose=true - contains full implementation details for all workflows" } } } ``` **Example:** ```json { "success": true, "message": "Workflows retrieved successfully", "workflows": [ { "id": "7a8b9c0d-1234-5678-abcd-ef9876543210", "name": "Patient Data Mapping Workflow", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "config": { "fhir_provider_ids": [ "550e8400-e29b-41d4-a716-446655440000" ], "dynamic_generation": false }, "graph": { "steps": [ { "id": "step_1_id", "name": "Find Patient", "description": "Search for an existing patient by first name and last name", "type": "search", "provider_id": "550e8400-e29b-41d4-a716-446655440000" }, { "id": "step_2_id", "name": "Create Condition", "description": "Create a FHIR Condition resource for the patient", "type": "create", "provider_id": "550e8400-e29b-41d4-a716-446655440000" } ] }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } ] } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **500** - Server error --- ### POST /workflows **Create new workflow** Creates a new workflow definition with graph generation from workflow instructions **Operation ID:** `workflows_create` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `verbose` | query | boolean | No | If true, includes full workflow implementation details in workflow_details field | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "workflow_instructions", "sample_data", "fhir_provider_id" ], "properties": { "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data to use for workflow graph generation", "example": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10" } }, "fhir_provider_id": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID", "example": "550e8400-e29b-41d4-a716-446655440000" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Multiple FHIR provider IDs", "example": [ "550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001" ] } ], "description": "FHIR provider ID(s) - must be valid UUID(s) from existing FHIR providers" }, "dynamic_generation": { "type": "boolean", "description": "Enable dynamic lang2fhir calls instead of pre-populated templates", "example": false } } } ``` **Example:** ```json { "name": "Patient Data Mapping Workflow", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "fhir_provider_id": "550e8400-e29b-41d4-a716-446655440000" } ``` #### Responses **200** - Successfully created workflow Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the workflow was created successfully", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Workflow created successfully" }, "workflow_id": { "type": "string", "format": "uuid", "description": "ID of the created workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "workflow": { "description": "Simplified workflow response with only essential step information", "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "description": "Simplified workflow step without implementation details", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "step_1_id" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Find Patient" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Search for an existing patient by first name and last name" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "search" }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" } } }, "description": "Simplified list of workflow steps without operation details" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } }, "workflow_details": { "description": "Only included when verbose=true - contains full implementation details including operation definitions and placeholders", "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "1" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Create Patient Resource" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Create a FHIR Patient resource from input data" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "create" }, "operation": { "type": "object", "properties": { "search_definition": { "type": "object", "properties": { "original_query": { "type": "string", "description": "Original natural language query", "example": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name" }, "resource_type": { "type": "string", "description": "FHIR resource type to search", "example": "Patient" }, "search_parameters": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR search parameters", "example": { "family": "{{patient_last_name}}", "given": "{{patient_first_name}}" } }, "required_fields": { "type": "array", "items": { "type": "string" }, "description": "Fields needed from search results", "example": [ "id", "name", "identifier" ] }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{patient_first_name}}": "input.patient_first_name", "{{patient_last_name}}": "input.patient_last_name" } } } }, "create_definition": { "type": "object", "properties": { "original_description": { "type": "string", "description": "Original natural language description", "example": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01" }, "resource_type": { "type": "string", "description": "FHIR resource type to create", "example": "Condition" }, "resource_template": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR resource template", "example": { "resourceType": "Condition", "code": { "coding": [ { "code": "{{diagnosis_code}}", "system": "http://hl7.org/fhir/sid/icd-10" } ] }, "subject": { "reference": "Patient/{{step_1_id}}" } } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{diagnosis_code}}": "input.diagnosis_code", "{{diagnosis_date}}": "input.diagnosis_date" } } } }, "workflow_definition": { "type": "object", "properties": { "workflow_id": { "type": "string", "format": "uuid", "description": "ID of the workflow to execute as a sub-workflow", "example": "550e8400-e29b-41d4-a716-446655440002" }, "input": { "type": "object", "additionalProperties": true, "description": "Input data to pass to the sub-workflow", "example": { "patient_id": "{{step_1_id}}", "additional_context": "laboratory_results" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for sub-workflow", "example": { "{{step_1_id}}": "step_1.result.id", "{{patient_data}}": "input.patient_data" } } } }, "decision_definition": { "type": "object", "properties": { "expression": { "type": "string", "description": "Simple equality expression for decision logic", "example": "input.patient_age >= 18" }, "paths": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps decision outcomes to next step IDs", "example": { "true": "step_adult_workflow", "false": "step_pediatric_workflow", "default": "step_error_handler" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for decision evaluation", "example": { "{{patient_age}}": "input.patient_age", "{{diagnosis_type}}": "step_2.result.diagnosis_category" } } } } } }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" }, "dependencies": { "type": "array", "items": { "type": "string" }, "description": "IDs of steps this step depends on", "example": [] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation for this step", "example": false } } }, "description": "Ordered list of workflow execution steps" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } } } } ``` **Example:** ```json { "success": true, "message": "Workflow created successfully", "workflow_id": "7a8b9c0d-1234-5678-abcd-ef9876543210", "workflow": { "id": "7a8b9c0d-1234-5678-abcd-ef9876543210", "name": "Patient Data Mapping Workflow", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **500** - Server error --- ### GET /workflows/{id} **Get workflow by ID** Retrieves a workflow definition by its ID **Operation ID:** `workflows_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string (uuid) | Yes | ID of the workflow to retrieve | | `verbose` | query | boolean | No | If true, includes full workflow implementation details in workflow_details field | #### Responses **200** - Successfully retrieved workflow Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "workflow": { "type": "object", "description": "Simplified workflow representation without implementation details", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "description": "Simplified workflow step without implementation details", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "step_1_id" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Find Patient" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Search for an existing patient by first name and last name" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "search" }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" } } }, "description": "Simplified list of workflow steps without operation details" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } }, "workflow_details": { "description": "Only included when verbose=true - contains full implementation details", "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "1" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Create Patient Resource" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Create a FHIR Patient resource from input data" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "create" }, "operation": { "type": "object", "properties": { "search_definition": { "type": "object", "properties": { "original_query": { "type": "string", "description": "Original natural language query", "example": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name" }, "resource_type": { "type": "string", "description": "FHIR resource type to search", "example": "Patient" }, "search_parameters": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR search parameters", "example": { "family": "{{patient_last_name}}", "given": "{{patient_first_name}}" } }, "required_fields": { "type": "array", "items": { "type": "string" }, "description": "Fields needed from search results", "example": [ "id", "name", "identifier" ] }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{patient_first_name}}": "input.patient_first_name", "{{patient_last_name}}": "input.patient_last_name" } } } }, "create_definition": { "type": "object", "properties": { "original_description": { "type": "string", "description": "Original natural language description", "example": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01" }, "resource_type": { "type": "string", "description": "FHIR resource type to create", "example": "Condition" }, "resource_template": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR resource template", "example": { "resourceType": "Condition", "code": { "coding": [ { "code": "{{diagnosis_code}}", "system": "http://hl7.org/fhir/sid/icd-10" } ] }, "subject": { "reference": "Patient/{{step_1_id}}" } } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{diagnosis_code}}": "input.diagnosis_code", "{{diagnosis_date}}": "input.diagnosis_date" } } } }, "workflow_definition": { "type": "object", "properties": { "workflow_id": { "type": "string", "format": "uuid", "description": "ID of the workflow to execute as a sub-workflow", "example": "550e8400-e29b-41d4-a716-446655440002" }, "input": { "type": "object", "additionalProperties": true, "description": "Input data to pass to the sub-workflow", "example": { "patient_id": "{{step_1_id}}", "additional_context": "laboratory_results" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for sub-workflow", "example": { "{{step_1_id}}": "step_1.result.id", "{{patient_data}}": "input.patient_data" } } } }, "decision_definition": { "type": "object", "properties": { "expression": { "type": "string", "description": "Simple equality expression for decision logic", "example": "input.patient_age >= 18" }, "paths": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps decision outcomes to next step IDs", "example": { "true": "step_adult_workflow", "false": "step_pediatric_workflow", "default": "step_error_handler" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for decision evaluation", "example": { "{{patient_age}}": "input.patient_age", "{{diagnosis_type}}": "step_2.result.diagnosis_category" } } } } } }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" }, "dependencies": { "type": "array", "items": { "type": "string" }, "description": "IDs of steps this step depends on", "example": [] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation for this step", "example": false } } }, "description": "Ordered list of workflow execution steps" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } } } } ``` **Example:** ```json { "success": true, "workflow": { "id": "7a8b9c0d-1234-5678-abcd-ef9876543210", "name": "Patient Data Mapping Workflow", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "config": { "fhir_provider_ids": [ "550e8400-e29b-41d4-a716-446655440000" ], "dynamic_generation": false }, "graph": { "steps": [ { "id": "step_1_id", "name": "Find Patient", "description": "Search for an existing patient by first name and last name", "type": "search", "provider_id": "550e8400-e29b-41d4-a716-446655440000" }, { "id": "step_2_id", "name": "Create Condition", "description": "Create a FHIR Condition resource for the patient", "type": "create", "provider_id": "550e8400-e29b-41d4-a716-446655440000" } ] }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **404** - Workflow not found **500** - Server error **504** - Request timed out --- ### PUT /workflows/{id} **Update workflow** Updates an existing workflow definition **Operation ID:** `workflows_update` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string (uuid) | Yes | ID of the workflow to update | | `verbose` | query | boolean | No | If true, includes full workflow implementation details in workflow_details field | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "workflow_instructions", "sample_data", "fhir_provider_id" ], "properties": { "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Updated Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data to use for workflow graph generation", "example": { "patient_last_name": "Smith", "patient_first_name": "John", "diagnosis_code": "E11" } }, "fhir_provider_id": { "oneOf": [ { "type": "string", "format": "uuid", "description": "Single FHIR provider ID", "example": "550e8400-e29b-41d4-a716-446655440000" }, { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Multiple FHIR provider IDs", "example": [ "550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001" ] } ], "description": "FHIR provider ID(s) - must be valid UUID(s) from existing FHIR providers" }, "dynamic_generation": { "type": "boolean", "description": "Enable dynamic lang2fhir calls instead of pre-populated templates", "example": false } } } ``` **Example:** ```json { "name": "Patient Data Mapping Workflow (v2)", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "fhir_provider_id": "550e8400-e29b-41d4-a716-446655440000" } ``` #### Responses **200** - Successfully updated workflow Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Workflow updated successfully" }, "workflow": { "description": "Simplified workflow response with only essential step information", "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "description": "Simplified workflow step without implementation details", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "step_1_id" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Find Patient" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Search for an existing patient by first name and last name" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "search" }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" } } }, "description": "Simplified list of workflow steps without operation details" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } }, "workflow_details": { "description": "Only included when verbose=true - contains full implementation details", "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the workflow", "example": "550e8400-e29b-41d4-a716-446655440001" }, "name": { "type": "string", "description": "Human-readable name for the workflow", "example": "Patient Data Mapping Workflow" }, "workflow_instructions": { "type": "string", "description": "Natural language instructions that define the workflow logic", "example": "Given diagnosis data, find the patient and create condition record" }, "sample_data": { "type": "object", "additionalProperties": true, "description": "Sample data used for workflow graph generation", "example": { "diagnosis_code": "I10", "diagnosis_date": "2025-01-01", "patient_first_name": "Clay", "patient_last_name": "Rippin" } }, "config": { "type": "object", "properties": { "fhir_provider_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "FHIR provider IDs for executing workflow steps", "example": [ "550e8400-e29b-41d4-a716-446655440000" ] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation instead of pre-populated templates", "example": false } } }, "graph": { "type": "object", "properties": { "steps": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique identifier for the step", "example": "1" }, "name": { "type": "string", "description": "Human-readable name for the step", "example": "Create Patient Resource" }, "description": { "type": "string", "description": "Detailed description of what the step does", "example": "Create a FHIR Patient resource from input data" }, "type": { "type": "string", "enum": [ "search", "create", "workflow", "decision_node" ], "description": "Type of operation this step performs", "example": "create" }, "operation": { "type": "object", "properties": { "search_definition": { "type": "object", "properties": { "original_query": { "type": "string", "description": "Original natural language query", "example": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name" }, "resource_type": { "type": "string", "description": "FHIR resource type to search", "example": "Patient" }, "search_parameters": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR search parameters", "example": { "family": "{{patient_last_name}}", "given": "{{patient_first_name}}" } }, "required_fields": { "type": "array", "items": { "type": "string" }, "description": "Fields needed from search results", "example": [ "id", "name", "identifier" ] }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{patient_first_name}}": "input.patient_first_name", "{{patient_last_name}}": "input.patient_last_name" } } } }, "create_definition": { "type": "object", "properties": { "original_description": { "type": "string", "description": "Original natural language description", "example": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01" }, "resource_type": { "type": "string", "description": "FHIR resource type to create", "example": "Condition" }, "resource_template": { "type": "object", "additionalProperties": true, "description": "Prepared FHIR resource template", "example": { "resourceType": "Condition", "code": { "coding": [ { "code": "{{diagnosis_code}}", "system": "http://hl7.org/fhir/sid/icd-10" } ] }, "subject": { "reference": "Patient/{{step_1_id}}" } } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths", "example": { "{{diagnosis_code}}": "input.diagnosis_code", "{{diagnosis_date}}": "input.diagnosis_date" } } } }, "workflow_definition": { "type": "object", "properties": { "workflow_id": { "type": "string", "format": "uuid", "description": "ID of the workflow to execute as a sub-workflow", "example": "550e8400-e29b-41d4-a716-446655440002" }, "input": { "type": "object", "additionalProperties": true, "description": "Input data to pass to the sub-workflow", "example": { "patient_id": "{{step_1_id}}", "additional_context": "laboratory_results" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for sub-workflow", "example": { "{{step_1_id}}": "step_1.result.id", "{{patient_data}}": "input.patient_data" } } } }, "decision_definition": { "type": "object", "properties": { "expression": { "type": "string", "description": "Simple equality expression for decision logic", "example": "input.patient_age >= 18" }, "paths": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps decision outcomes to next step IDs", "example": { "true": "step_adult_workflow", "false": "step_pediatric_workflow", "default": "step_error_handler" } }, "runtime_placeholders": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Maps placeholder tokens to their input data paths for decision evaluation", "example": { "{{patient_age}}": "input.patient_age", "{{diagnosis_type}}": "step_2.result.diagnosis_category" } } } } } }, "provider_id": { "type": "string", "format": "uuid", "description": "Selected FHIR provider ID for this step", "example": "550e8400-e29b-41d4-a716-446655440000" }, "dependencies": { "type": "array", "items": { "type": "string" }, "description": "IDs of steps this step depends on", "example": [] }, "dynamic_generation": { "type": "boolean", "description": "Whether to use dynamic lang2fhir generation for this step", "example": false } } }, "description": "Ordered list of workflow execution steps" } } }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when the workflow was last updated", "example": "2024-01-15T15:45:00Z" } } } } } ``` **Example:** ```json { "success": true, "message": "Workflow updated successfully", "workflow": { "id": "7a8b9c0d-1234-5678-abcd-ef9876543210", "name": "Patient Data Mapping Workflow (v2)", "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter", "sample_data": { "patient_last_name": "Rippin", "patient_first_name": "Clay", "diagnosis_code": "I10", "encounter_date": "2024-01-15" }, "config": { "fhir_provider_ids": [ "550e8400-e29b-41d4-a716-446655440000" ], "dynamic_generation": false }, "graph": { "steps": [ { "id": "step_1_id", "name": "Find Patient", "description": "Search for an existing patient by first name and last name", "type": "search", "provider_id": "550e8400-e29b-41d4-a716-446655440000" } ] }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-02-20T11:00:00Z" } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **404** - Workflow not found **500** - Server error **504** - Request timed out --- ### DELETE /workflows/{id} **Delete workflow** Deletes a workflow definition by its ID **Operation ID:** `workflows_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string (uuid) | Yes | ID of the workflow to delete | #### Responses **200** - Successfully deleted workflow Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Workflow deleted successfully" } } } ``` **Example:** ```json { "success": true, "message": "Workflow deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **404** - Workflow not found **500** - Server error **504** - Request timed out --- ### POST /workflows/{id}/execute **Execute workflow** Executes a workflow with provided input data and returns results **Operation ID:** `workflows_execute` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `id` | path | string (uuid) | Yes | ID of the workflow to execute | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "input_data" ], "properties": { "input_data": { "type": "object", "additionalProperties": true, "description": "Input data for workflow execution", "example": { "patient_last_name": "Johnson", "patient_first_name": "Mary", "diagnosis_code": "M79.3", "encounter_date": "2024-01-15" } }, "preview": { "type": "boolean", "description": "If true, create operations return mock resources instead of persisting to the FHIR server", "default": false, "example": false } } } ``` **Example:** ```json { "input_data": { "patient_last_name": "Johnson", "patient_first_name": "Mary", "diagnosis_code": "M79.3", "encounter_date": "2024-03-20" } } ``` #### Responses **200** - Successfully executed workflow Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the workflow execution was successful", "example": true }, "message": { "type": "string", "description": "Status message with execution details", "example": "Workflow executed successfully" }, "results": { "type": "object", "properties": { "steps": { "type": "object", "additionalProperties": true, "description": "Results for each executed workflow step, keyed by step ID" } } }, "preview": { "type": "boolean", "description": "Whether the workflow was executed in preview mode", "example": false } } } ``` **Example:** ```json { "success": true, "message": "Workflow executed successfully", "results": { "steps": { "step_1_id": { "type": "search_result", "original_query": "find patient by first name Mary and last name Johnson", "resource_type": "Patient", "search_params": { "family": "Johnson", "given": "Mary" }, "results": [ { "resourceType": "Patient", "id": "patient-123", "name": [ { "family": "Johnson", "given": [ "Mary" ], "use": "usual" } ], "gender": "female", "birthDate": "1961-01-01" } ] }, "step_2_id": { "type": "create_result", "id": "condition-456", "resource_type": "Condition", "original_desc": "create condition with diagnosis code M79.3 for the patient from step_1_id", "preview": false, "created_resource": { "resourceType": "Condition", "id": "condition-456", "clinicalStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-clinical", "code": "active" } ] }, "code": { "coding": [ { "system": "http://hl7.org/fhir/sid/icd-10", "code": "M79.3", "display": "Panniculitis, unspecified" } ] }, "subject": { "reference": "Patient/patient-123" } } } } }, "preview": false } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested workflow **404** - Workflow not found **500** - Server error **504** - Workflow execution exceeded the server-side time budget --- # Authentication Manage API credentials, generate authentication tokens, and handle authorization. ## Endpoints ### POST /auth/token **Generate authentication token** Generates a JWT token using Basic Authentication with API credential client ID and secret. **Operation ID:** `authtoken_getLegacyToken` #### Responses **200** - Successfully generated token Content-Type: `application/json` ```json { "type": "object", "properties": { "token": { "type": "string", "description": "JWT token to be used for subsequent authenticated requests" } }, "required": [ "token" ] } ``` **401** - Unauthorized - Invalid credentials Content-Type: `application/json` ```json { "type": "object", "properties": { "code": { "type": "integer", "example": 401 }, "message": { "type": "string", "example": "Invalid credentials" }, "data": { "type": "object", "nullable": true } } } ``` --- ### POST /v2/auth/token **Request an access token** OAuth 2.0 client credentials token endpoint (RFC 6749 §4.4). Accepts client_id and client_secret in the request body (JSON or form-encoded) or via Basic Auth header (RFC 6749 §2.3.1), and returns an access token with token expiration information. **Operation ID:** `authtoken_getToken` #### Request Body **Required:** No **Content-Type:** `application/json` ```json { "type": "object", "description": "When using body credentials, both client_id and client_secret are required. When using Basic Auth, the body may contain only grant_type.\n", "properties": { "grant_type": { "type": "string", "description": "Must be \"client_credentials\" if provided", "example": "client_credentials" }, "client_id": { "type": "string", "description": "The client ID (credential username)" }, "client_secret": { "type": "string", "description": "The client secret (credential password)" } } } ``` **Example:** ```json { "client_id": "your_client_id", "client_secret": "your_client_secret" } ``` **Content-Type:** `application/x-www-form-urlencoded` ```json { "type": "object", "description": "When using body credentials, both client_id and client_secret are required. When using Basic Auth, the body may contain only grant_type.\n", "properties": { "grant_type": { "type": "string", "description": "Must be \"client_credentials\" if provided", "example": "client_credentials" }, "client_id": { "type": "string", "description": "The client ID (credential username)" }, "client_secret": { "type": "string", "description": "The client secret (credential password)" } } } ``` #### Responses **200** - Successfully generated token Content-Type: `application/json` ```json { "type": "object", "properties": { "access_token": { "type": "string", "description": "JWT access token for subsequent authenticated requests" }, "token_type": { "type": "string", "description": "Token type (always \"Bearer\")", "example": "Bearer" }, "expires_in": { "type": "integer", "description": "Token lifetime in seconds", "example": 172800 } }, "required": [ "access_token", "token_type", "expires_in" ] } ``` **Example:** ```json { "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "Bearer", "expires_in": 172800 } ``` **400** - Bad Request - Missing client credentials or unsupported grant type Content-Type: `application/json` ```json { "type": "object", "description": "OAuth 2.0 error response (RFC 6749 §5.2)", "properties": { "error": { "type": "string", "description": "Error code", "enum": [ "invalid_request", "invalid_client", "unsupported_grant_type", "server_error" ] }, "error_description": { "type": "string", "description": "Human-readable error description" } }, "required": [ "error" ] } ``` **401** - Unauthorized - Invalid client credentials Content-Type: `application/json` ```json { "type": "object", "description": "OAuth 2.0 error response (RFC 6749 §5.2)", "properties": { "error": { "type": "string", "description": "Error code", "enum": [ "invalid_request", "invalid_client", "unsupported_grant_type", "server_error" ] }, "error_description": { "type": "string", "description": "Human-readable error description" } }, "required": [ "error" ] } ``` **500** - Internal Server Error - Authentication service unavailable Content-Type: `application/json` ```json { "type": "object", "description": "OAuth 2.0 error response (RFC 6749 §5.2)", "properties": { "error": { "type": "string", "description": "Error code", "enum": [ "invalid_request", "invalid_client", "unsupported_grant_type", "server_error" ] }, "error_description": { "type": "string", "description": "Human-readable error description" } }, "required": [ "error" ] } ``` --- # Tools LLM tools that combine lang2fhir with FHIR server operations. ## Tools / MCP Servers Register and manage MCP servers exposed as agent tools. ### GET /tools/mcp-server/{mcp_server_id} **Get MCP server by ID** Gets a MCP server by ID **Operation ID:** `tools_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `mcp_server_id` | path | string | Yes | ID of the MCP server to retrieve | #### Responses **200** - Successfully retrieved MCP server Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_servers": { "type": "array", "description": "List of MCP servers. Returned by /tools/mcp-server/create (the\nnewly created server) and /tools/mcp-server/list (all servers).\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } }, "mcp_server_tools": { "type": "array", "description": "Tools loaded from the MCP server. Returned by /tools/mcp-server/create\nalongside the server record, since tool discovery happens at create time.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server retrieved successfully", "data": { "id": "123", "name": "My MCP Server", "description": "My MCP Server is a server that provides MCP services", "mcp_server_url": "https://mcp.example.com" } } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **404** - MCP server not found **500** - Server error --- ### DELETE /tools/mcp-server/{mcp_server_id} **Delete MCP server by ID** Deletes a MCP server by ID **Operation ID:** `tools_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `mcp_server_id` | path | string | Yes | ID of the MCP server to delete | #### Responses **200** - Successfully deleted MCP server Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_servers": { "type": "array", "description": "List of MCP servers. Returned by /tools/mcp-server/create (the\nnewly created server) and /tools/mcp-server/list (all servers).\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } }, "mcp_server_tools": { "type": "array", "description": "Tools loaded from the MCP server. Returned by /tools/mcp-server/create\nalongside the server record, since tool discovery happens at create time.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server Configuration and Tools deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **404** - MCP server not found **500** - Server error --- ### POST /tools/mcp-server/create **Create MCP server** Creates a new MCP server **Operation ID:** `tools_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "mcp_server_url" ], "properties": { "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } ``` **Example:** ```json { "name": "My MCP Server", "mcp_server_url": "https://mcp.example.com" } ``` #### Responses **200** - Successfully created MCP server Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_servers": { "type": "array", "description": "List of MCP servers. Returned by /tools/mcp-server/create (the\nnewly created server) and /tools/mcp-server/list (all servers).\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } }, "mcp_server_tools": { "type": "array", "description": "Tools loaded from the MCP server. Returned by /tools/mcp-server/create\nalongside the server record, since tool discovery happens at create time.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server and Tools created successfully", "mcp_servers": [ { "id": "123", "name": "My MCP Server", "description": "My MCP Server is a server that provides MCP services", "mcp_server_url": "https://mcp.example.com" } ], "mcp_server_tools": [ { "id": "tool-001", "name": "search_endpoints", "description": "Search across the documented endpoints", "input_schema": { "query": "string" }, "mcp_server_id": "123", "mcp_server_url": "https://mcp.example.com" }, { "id": "tool-002", "name": "get_endpoint", "description": "Fetch a single endpoint by ID", "input_schema": { "endpoint_id": "string" }, "mcp_server_id": "123", "mcp_server_url": "https://mcp.example.com" } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **500** - Server error --- ### GET /tools/mcp-server/list **List MCP servers** Lists all MCP servers for a specific user **Operation ID:** `tools_list` #### Responses **200** - Successfully listed MCP servers Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_servers": { "type": "array", "description": "List of MCP servers. Returned by /tools/mcp-server/create (the\nnewly created server) and /tools/mcp-server/list (all servers).\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server", "example": "My MCP Server" }, "description": { "type": "string", "description": "Description of the MCP server", "example": "My MCP Server is a server that provides MCP services" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } }, "mcp_server_tools": { "type": "array", "description": "Tools loaded from the MCP server. Returned by /tools/mcp-server/create\nalongside the server record, since tool discovery happens at create time.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Servers retrieved successfully", "mcp_servers": [ { "id": "123", "name": "My MCP Server", "description": "My MCP Server is a server that provides MCP services", "mcp_server_url": "https://mcp.example.com" }, { "id": "456", "name": "Another MCP Server", "description": "A second MCP server", "mcp_server_url": "https://other.mcp.example.com" } ] } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **500** - Server error --- ## Tools / MCP Tools List and manage individual tools exposed by an MCP server. ### GET /tools/mcp-server/{mcp_server_id}/list **List MCP server tools** Lists all MCP server tools for a specific MCP server **Operation ID:** `tools_listTools` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `mcp_server_id` | path | string | Yes | ID of the MCP server to list tools for | #### Responses **200** - Successfully listed MCP server tools Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_server_tools": { "type": "array", "description": "List of MCP server tools. Returned by\n/tools/mcp-server/{mcp_server_id}/list.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server tools retrieved successfully", "mcp_server_tools": [ { "id": "tool-001", "name": "search_endpoints", "description": "Search across the documented endpoints", "input_schema": { "query": "string" }, "mcp_server_id": "123", "mcp_server_url": "https://mcp.example.com" }, { "id": "tool-002", "name": "get_endpoint", "description": "Fetch a single endpoint by ID", "input_schema": { "endpoint_id": "string" }, "mcp_server_id": "123", "mcp_server_url": "https://mcp.example.com" } ] } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **500** - Server error --- ### GET /tools/mcp-server/tool/{mcp_server_tool_id} **Get MCP server tool by ID** Gets a MCP server tool by ID **Operation ID:** `tools_getTool` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `mcp_server_tool_id` | path | string | Yes | ID of the MCP server tool to retrieve | #### Responses **200** - Successfully retrieved MCP server tool Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_server_tools": { "type": "array", "description": "List of MCP server tools. Returned by\n/tools/mcp-server/{mcp_server_id}/list.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server tool retrieved successfully", "data": { "id": "123", "name": "My MCP Server Tool", "description": "My MCP Server Tool is a tool that provides MCP services", "input_schema": { "name": "string", "age": "number" }, "mcp_server_id": "123", "mcp_server_url": "https://mcp.example.com" } } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **404** - MCP server tool not found **500** - Server error --- ### DELETE /tools/mcp-server/tool/{mcp_server_tool_id} **Delete MCP server tool by ID** Deletes a MCP server tool by ID **Operation ID:** `tools_deleteTool` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `mcp_server_tool_id` | path | string | Yes | ID of the MCP server tool to delete | #### Responses **200** - Successfully deleted MCP server tool Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the operation succeeded", "example": true }, "message": { "type": "string", "description": "Status message" }, "data": { "description": "Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).", "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } }, "mcp_server_tools": { "type": "array", "description": "List of MCP server tools. Returned by\n/tools/mcp-server/{mcp_server_id}/list.\n", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of the MCP server tool", "example": "123" }, "name": { "type": "string", "description": "Name of the MCP server tool", "example": "My MCP Server Tool" }, "description": { "type": "string", "description": "Description of the MCP server tool", "example": "My MCP Server Tool is a tool that provides MCP services" }, "input_schema": { "type": "object", "description": "Input schema of the MCP server tool", "example": { "name": "string", "age": "number" } }, "mcp_server_id": { "type": "string", "description": "ID of the MCP server that the tool belongs to", "example": "123" }, "mcp_server_url": { "type": "string", "description": "URL of the MCP server", "example": "https://mcp.example.com" } } } } } } ``` **Example:** ```json { "success": true, "message": "MCP Server tool deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - MCP server endpoints require a dedicated instance, or access denied to this resource **404** - MCP server tool not found **500** - Server error --- ## Untagged ### POST /tools/cohort **Analyze patient cohorts** Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria **Operation ID:** `tools_analyzeCohort` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text", "provider" ], "properties": { "text": { "type": "string", "description": "Natural language text describing the patient cohort criteria", "example": "female patients over 20 with diabetes but not hypertension" }, "provider": { "type": "string", "format": "uuid", "description": "FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)", "example": "550e8400-e29b-41d4-a716-446655440000" } } } ``` **Example:** ```json { "text": "female patients over 20 with diabetes but not hypertension", "provider": "550e8400-e29b-41d4-a716-446655440000" } ``` #### Responses **200** - Successfully analyzed cohort and retrieved patient list Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the cohort analysis was successful", "example": true }, "message": { "type": "string", "description": "Status message with details about the analysis", "example": "Cohort analysis completed successfully. Found 33 patients from 2 search concepts." }, "patientIds": { "type": "array", "items": { "type": "string" }, "description": "Array of patient IDs that match the cohort criteria", "example": [ "patient-123", "patient-456", "patient-789" ] }, "patientCount": { "type": "integer", "description": "Total number of patients in the cohort", "example": 33 }, "queries": { "type": "array", "items": { "type": "object", "description": "A single search concept detected in cohort mode", "properties": { "resource_type": { "type": "string", "description": "The FHIR resource type identified for this concept", "example": "Condition" }, "search_params": { "type": "string", "description": "FHIR search parameters for this concept", "example": "code=55822004" }, "concept": { "type": "string", "description": "Description of what this search represents", "example": "hyperlipidemia" }, "exclude": { "type": "boolean", "description": "Whether this is an exclusion criteria", "example": false } } }, "description": "Individual search concepts that were identified and executed", "example": [ { "resource_type": "Patient", "search_params": "gender=female&birthdate=le2004-01-01", "concept": "female patients over 20", "exclude": false }, { "resource_type": "Condition", "search_params": "code=55822004", "concept": "hyperlipidemia", "exclude": false } ] } } } ``` **Example:** ```json { "success": true, "message": "Cohort analysis completed successfully. Found 33 patients from 2 search concepts.", "patientIds": [ "patient-123", "patient-456", "patient-789" ], "patientCount": 33, "queries": [ { "resource_type": "Patient", "search_params": "gender=female&birthdate=le2004-01-01", "concept": "female patients over 20", "exclude": false }, { "resource_type": "Condition", "search_params": "code=44054006", "concept": "diabetes", "exclude": false }, { "resource_type": "Condition", "search_params": "code=38341003", "concept": "hypertension", "exclude": true } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ### POST /tools/lang2fhir-and-create **Create FHIR resource from text and store it** Converts natural language to FHIR resource and optionally stores it in a FHIR server **Operation ID:** `tools_createFhirResource` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "resource", "text" ], "properties": { "resource": { "type": "string", "description": "Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.\n", "example": "condition-encounter-diagnosis", "enum": [ "auto", "appointment", "condition-encounter-diagnosis", "medicationrequest", "careplan", "condition-problems-health-concerns", "coverage", "encounter", "observation-clinical-result", "observation-lab", "patient", "procedure", "questionnaire", "questionnaireresponse", "servicerequest", "simple-observation", "vital-signs" ] }, "text": { "type": "string", "description": "Natural language text to convert to FHIR resource", "example": "Patient John Doe has severe asthma with acute exacerbation" }, "provider": { "type": "string", "format": "uuid", "description": "FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)", "example": "550e8400-e29b-41d4-a716-446655440000" } } } ``` **Example:** ```json { "resource": "condition-encounter-diagnosis", "text": "Patient has severe persistent asthma with acute exacerbation", "provider": "550e8400-e29b-41d4-a716-446655440000" } ``` #### Responses **200** - Successfully created FHIR resource Content-Type: `application/json` ```json { "type": "object", "properties": { "fhir_resource": { "type": "object", "description": "The created FHIR resource", "additionalProperties": true, "example": { "resourceType": "Condition", "id": "condition-123", "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "195967001", "display": "Asthma" } ] }, "subject": { "reference": "Patient/patient-123", "display": "John Doe" } } }, "fhir_id": { "type": "string", "description": "ID of the resource in the FHIR server (if successfully stored)", "example": "condition-123" }, "success": { "type": "boolean", "example": true }, "message": { "type": "string", "description": "Status message", "example": "FHIR resource created and stored in FHIR server successfully" } } } ``` **Example:** ```json { "success": true, "message": "FHIR resource created successfully", "fhir_id": "condition-123", "fhir_resource": { "resourceType": "Condition", "id": "condition-123", "clinicalStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-clinical", "code": "active" } ] }, "verificationStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", "code": "confirmed" } ] }, "category": [ { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-category", "code": "encounter-diagnosis" } ] } ], "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "195967001", "display": "Asthma" } ], "text": "Severe persistent asthma with acute exacerbation" }, "subject": { "reference": "Patient/patient-123" } } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ### POST /tools/lang2fhir-and-create-multi **Extract and store multiple FHIR resources** Extracts multiple FHIR resources from natural language text and stores them in a FHIR server. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types. Resources are linked with proper references and submitted as a transaction bundle. For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically resolve them via PUT requests after the initial bundle creation. **Operation ID:** `tools_createFhirResourcesMulti` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text", "provider" ], "properties": { "text": { "type": "string", "description": "Natural language text containing multiple clinical concepts to extract", "example": "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily." }, "version": { "type": "string", "description": "FHIR version to use", "example": "R4", "default": "R4" }, "provider": { "type": "string", "description": "FHIR provider ID or name", "example": "medplum" } } } ``` **Example:** ```json { "text": "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.", "version": "R4", "provider": "medplum" } ``` #### Responses **200** - Successfully created FHIR resources Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the resources were created successfully", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Created 3 resources" }, "response_bundle": { "type": "object", "description": "FHIR transaction-response Bundle from the server with resolved resource IDs", "properties": { "resourceType": { "type": "string", "example": "Bundle" }, "type": { "type": "string", "example": "transaction-response" }, "entry": { "type": "array", "items": { "type": "object" } } } }, "resource_info": { "type": "array", "description": "Metadata about created resources (temp IDs, types, descriptions)", "items": { "type": "object", "properties": { "tempId": { "type": "string", "description": "Original temporary UUID", "example": "urn:uuid:patient-abc123" }, "resourceType": { "type": "string", "description": "FHIR resource type", "example": "Patient" }, "description": { "type": "string", "description": "Text excerpt this resource was extracted from", "example": "John Smith, 45-year-old male" } } } } } } ``` **Example:** ```json { "success": true, "message": "Created 3 resources", "response_bundle": { "resourceType": "Bundle", "type": "transaction-response", "entry": [ { "response": { "status": "201 Created", "location": "Patient/patient-001" } }, { "response": { "status": "201 Created", "location": "Condition/condition-001" } }, { "response": { "status": "201 Created", "location": "MedicationRequest/medication-001" } } ] }, "resource_info": [ { "tempId": "urn:uuid:patient-abc123", "resourceType": "Patient", "description": "John Smith, 45-year-old male" }, { "tempId": "urn:uuid:condition-abc123", "resourceType": "Condition", "description": "Type 2 Diabetes diagnosis" }, { "tempId": "urn:uuid:medication-abc123", "resourceType": "MedicationRequest", "description": "Metformin 500mg twice daily" } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- ### POST /tools/lang2fhir-and-search **Search FHIR resources from natural language** Converts natural language to FHIR search parameters and executes search in FHIR server **Operation ID:** `tools_searchFhirResources` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "text" ], "properties": { "text": { "type": "string", "description": "Natural language text to convert to FHIR search parameters", "example": "Find all appointments for patient John Doe next week" }, "patient_id": { "type": "string", "description": "Patient ID to filter results", "example": "patient-123" }, "count": { "type": "integer", "description": "Maximum number of results to return", "example": 10, "minimum": 1, "maximum": 100 }, "provider": { "type": "string", "format": "uuid", "description": "FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)", "example": "550e8400-e29b-41d4-a716-446655440000" } } } ``` **Example:** ```json { "text": "Find all appointments for patient John Doe next week", "count": 10, "provider": "550e8400-e29b-41d4-a716-446655440000" } ``` #### Responses **200** - Successfully generated search and retrieved results Content-Type: `application/json` ```json { "type": "object", "properties": { "resource_type": { "type": "string", "description": "The FHIR resource type identified for the search", "example": "Appointment" }, "search_params": { "type": "string", "description": "FHIR search parameters in standard format", "example": "patient=Patient/patient-123&date=ge2024-01-15&date=le2024-01-22" }, "fhir_results": { "type": "array", "items": { "type": "object", "additionalProperties": true }, "description": "Array of FHIR resources returned from the search", "example": [ { "resourceType": "Appointment", "id": "appointment-123", "status": "booked", "start": "2024-01-16T10:00:00Z", "end": "2024-01-16T11:00:00Z", "participant": [ { "actor": { "reference": "Patient/patient-123", "display": "John Doe" } } ] } ] }, "success": { "type": "boolean", "example": true }, "message": { "type": "string", "description": "Status message", "example": "Search query generated and executed in FHIR server successfully. Found 1 results." } } } ``` **Example:** ```json { "success": true, "message": "Search query generated and executed in FHIR server successfully. Found 1 results.", "resource_type": "Appointment", "search_params": "patient=Patient/patient-123&date=ge2024-01-15&date=le2024-01-22", "fhir_results": [ { "resourceType": "Appointment", "id": "appointment-123", "status": "booked", "start": "2024-01-16T10:00:00Z", "end": "2024-01-16T11:00:00Z", "participant": [ { "actor": { "reference": "Patient/patient-123", "display": "John Doe" } } ] } ] } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - access denied to the requested resource **500** - Server error --- # FHIR FHIR server operations including resource CRUD, search, and batch operations. ## FHIR / Auth Config Manage authentication configurations attached to a FHIR provider. ### PATCH /fhir-provider/{fhir_provider_id}/add-auth-config **Add authentication configuration** Adds a new authentication configuration to an existing FHIR provider. This enables key rotation and multiple auth configurations per provider. Note: Sandbox providers cannot be modified. **Operation ID:** `fhir_provider_add` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | ID of the FHIR provider to add auth config to | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "oneOf": [ { "type": "object", "required": [ "auth_method", "client_id" ], "properties": { "auth_method": { "type": "string", "enum": [ "jwt" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for JWT credentials. If omitted, a default expiry is used.", "example": "2024-12-31T23:59:59Z" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "client_id", "client_secret" ], "properties": { "auth_method": { "type": "string", "enum": [ "client_secret" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "client_secret": { "type": "string", "description": "OAuth client secret", "example": "your-client-secret" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "client_id", "client_secret" ], "properties": { "auth_method": { "type": "string", "enum": [ "on_behalf_of" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "client_secret": { "type": "string", "description": "OAuth client secret", "example": "your-client-secret" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "service_account_key" ], "properties": { "auth_method": { "type": "string", "enum": [ "google_healthcare" ] }, "service_account_key": { "type": "object", "description": "Google Cloud Service Account key (required for google_healthcare auth method)", "required": [ "type", "project_id", "private_key_id", "private_key", "client_email", "client_id", "auth_uri", "token_uri", "auth_provider_x509_cert_url", "client_x509_cert_url", "universe_domain" ], "properties": { "type": { "type": "string", "example": "service_account" }, "project_id": { "type": "string", "example": "my-gcp-project" }, "private_key_id": { "type": "string", "example": "key-id-123" }, "private_key": { "type": "string", "example": "-----BEGIN PRIVATE KEY-----\n..." }, "client_email": { "type": "string", "format": "email", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "example": "123456789012345678901" }, "auth_uri": { "type": "string", "format": "uri", "example": "https://accounts.google.com/o/oauth2/auth" }, "token_uri": { "type": "string", "format": "uri", "example": "https://oauth2.googleapis.com/token" }, "auth_provider_x509_cert_url": { "type": "string", "format": "uri", "example": "https://www.googleapis.com/oauth2/v1/certs" }, "client_x509_cert_url": { "type": "string", "format": "uri", "example": "https://www.googleapis.com/robot/v1/metadata/x509/service-account%40my-gcp-project.iam.gserviceaccount.com" }, "universe_domain": { "type": "string", "example": "googleapis.com" } } } } }, { "type": "object", "required": [ "auth_method" ], "properties": { "auth_method": { "type": "string", "enum": [ "token_passthrough" ] } } }, { "type": "object", "required": [ "auth_method" ], "properties": { "auth_method": { "type": "string", "enum": [ "none" ] } } } ], "discriminator": { "propertyName": "auth_method", "mapping": { "jwt": "#/components/schemas/fhir_provider_JwtAuth", "client_secret": "#/components/schemas/fhir_provider_ClientSecretAuth", "on_behalf_of": "#/components/schemas/fhir_provider_OnBehalfOfAuth", "google_healthcare": "#/components/schemas/fhir_provider_GoogleHealthcareAuth", "token_passthrough": "#/components/schemas/fhir_provider_TokenPassthroughAuth", "none": "#/components/schemas/fhir_provider_NoAuth" } } } ``` **Example:** ```json { "auth_method": "client_secret", "client_id": "your-other-client-id", "client_secret": "your-other-client-secret", "role": "read" } ``` #### Responses **200** - Auth configuration added successfully Content-Type: `application/json` ```json { "type": "object", "description": "Response payload for a single FHIR Provider operation.", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "oneOf": [ { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } }, { "type": "object", "description": "Limited information returned for sandbox FHIR providers. Sandbox\nresponses omit `auth_configs` and `last_updated`, which is what\ndistinguishes this shape from `FhirProviderTemplate` in `oneOf`.\n", "required": [ "id", "name", "provider" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "PhenoML Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Shared sandbox environment for experimentation" }, "provider": { "type": "string", "enum": [ "sandbox" ], "description": "Provider type (always \"sandbox\" for this schema)", "example": "sandbox" } } } ], "description": "Provider details. Sandbox providers return FhirProviderSandboxInfo.\n" } } } ``` **Example:** ```json { "success": true, "message": "Fhir provider auth config added successfully", "data": { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "jwt", "is_active_auth_config": true, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T14:45:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" }, "auth-config-456": { "auth_config_id": "auth-config-456", "auth_method": "client_secret", "is_active_auth_config": false, "created_at": "2024-02-20T09:00:00Z", "updated_at": "2024-02-20T09:00:00Z", "scopes": "system/Patient.read", "client_id": "your-other-client-id" } }, "last_updated": "2024-02-20T09:00:00Z" } } ``` **400** - Invalid request - missing required fields or invalid values **401** - Unauthorized **403** - Forbidden - dedicated instance required, or sandbox provider cannot be modified **404** - FHIR provider not found **500** - Server error --- ### PATCH /fhir-provider/{fhir_provider_id}/remove-auth-config **Remove authentication configuration** Removes an authentication configuration from a FHIR provider. Cannot remove the currently active auth configuration. Note: Sandbox providers cannot be modified. **Operation ID:** `fhir_provider_remove` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | ID of the FHIR provider | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "auth_config_id" ], "properties": { "auth_config_id": { "type": "string", "description": "ID of the auth configuration to remove", "example": "auth-config-123" } } } ``` **Example:** ```json { "auth_config_id": "auth-config-456" } ``` #### Responses **200** - Auth configuration removed successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } } } } ``` **Example:** ```json { "success": true, "message": "Fhir provider auth config deleted successfully", "data": { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "jwt", "is_active_auth_config": true, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" } }, "last_updated": "2024-02-20T11:30:00Z" } } ``` **400** - Invalid request - cannot remove active auth configuration **401** - Unauthorized **403** - Forbidden - dedicated instance required, or sandbox provider cannot be modified **404** - FHIR provider or auth config not found **500** - Server error --- ### PATCH /fhir-provider/{fhir_provider_id}/set-active-auth-config **Set active authentication configuration** Sets which authentication configuration should be active for a FHIR provider. Only one auth config can be active at a time. If the specified auth config is already active, the request succeeds without making any changes and returns a message indicating the config is already active. Note: Sandbox providers cannot be modified. **Operation ID:** `fhir_provider_setActive` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | ID of the FHIR provider | #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "auth_config_id" ], "properties": { "auth_config_id": { "type": "string", "description": "ID of the auth configuration to set as active", "example": "auth-config-123" } } } ``` **Example:** ```json { "auth_config_id": "auth-config-456" } ``` #### Responses **200** - Active auth configuration set successfully, or the config was already active. Check the message field to determine which case occurred. Content-Type: `application/json` ```json { "type": "object", "description": "Response payload for a single FHIR Provider operation.", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "oneOf": [ { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } }, { "type": "object", "description": "Limited information returned for sandbox FHIR providers. Sandbox\nresponses omit `auth_configs` and `last_updated`, which is what\ndistinguishes this shape from `FhirProviderTemplate` in `oneOf`.\n", "required": [ "id", "name", "provider" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "PhenoML Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Shared sandbox environment for experimentation" }, "provider": { "type": "string", "enum": [ "sandbox" ], "description": "Provider type (always \"sandbox\" for this schema)", "example": "sandbox" } } } ], "description": "Provider details. Sandbox providers return FhirProviderSandboxInfo.\n" } } } ``` **Example:** ```json { "success": true, "message": "FHIR provider auth config set as active successfully", "data": { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "jwt", "is_active_auth_config": false, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-02-20T11:00:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" }, "auth-config-456": { "auth_config_id": "auth-config-456", "auth_method": "client_secret", "is_active_auth_config": true, "created_at": "2024-02-20T09:00:00Z", "updated_at": "2024-02-20T11:00:00Z", "scopes": "system/Patient.read", "client_id": "your-other-client-id" } }, "last_updated": "2024-02-20T11:00:00Z" } } ``` **400** - Invalid request **401** - Unauthorized **403** - Forbidden - dedicated instance required, or sandbox provider cannot be modified **404** - FHIR provider or auth config not found **500** - Server error --- ## Untagged ### POST /fhir-provider **Create FHIR provider** Creates a new FHIR provider configuration with authentication credentials. Note: The "sandbox" provider type cannot be created via this API - it is managed internally. **Operation ID:** `fhir_provider_create` #### Request Body **Required:** Yes **Content-Type:** `application/json` ```json { "type": "object", "required": [ "name", "provider", "base_url", "auth" ], "properties": { "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox", "minLength": 1 }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "auth": { "oneOf": [ { "type": "object", "required": [ "auth_method", "client_id" ], "properties": { "auth_method": { "type": "string", "enum": [ "jwt" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for JWT credentials. If omitted, a default expiry is used.", "example": "2024-12-31T23:59:59Z" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "client_id", "client_secret" ], "properties": { "auth_method": { "type": "string", "enum": [ "client_secret" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "client_secret": { "type": "string", "description": "OAuth client secret", "example": "your-client-secret" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "client_id", "client_secret" ], "properties": { "auth_method": { "type": "string", "enum": [ "on_behalf_of" ] }, "client_id": { "type": "string", "description": "OAuth client ID", "example": "your-client-id" }, "client_secret": { "type": "string", "description": "OAuth client secret", "example": "your-client-secret" }, "role": { "type": "string", "description": "Predefined access level that maps to provider-specific OAuth scopes.\nCannot be specified together with `scopes`. Only applicable to\n`client_secret`, `jwt`, and `on_behalf_of` auth methods.\n\nRoles apply across **all FHIR resource types** (e.g., Patient, Observation,\nCondition, etc.) — they are not limited to a single resource. The server\nresolves each role to the appropriate system-level scopes for the provider:\n- `admin`: Full CRUD access (create, read, update, delete, search) on all resources\n- `read`: Read and search access on all resources\n- `write`: Create, update, and delete access on all resources (no read)\n\n**The exact scopes generated depend on the provider**, because each EHR uses a\ndifferent SMART on FHIR version or scope format:\n- **Epic**: SMART v2 scopes (e.g., `system/*.cruds` for admin)\n- **Cerner**: Cerner-specific SMART v2 scopes with per-resource grants for the\n subset of resources Cerner supports\n- **Athenahealth**: USCDI SMART v2 scopes with explicit per-resource grants\n (e.g., `system/Patient.rs`, `system/Observation.rs`, etc.)\n- **Elation**: SMART v1 scopes (e.g., `system/*.read` for read)\n- **Medplum, Phenostore**: SMART v2 scopes\n\nIf neither `role` nor `scopes` is specified, the provider-specific default\nrole is used (typically `read`; `admin` for Medplum/sandbox).\n\nIf the generated scopes don't match what your EHR expects, use the `scopes`\nfield to specify exact scopes instead.\n\nCanvas does not support system-level roles — use `scopes` directly.\nGoogle Healthcare, HAPI, Meditech, and `none`/`token_passthrough`\nauth methods do not use scopes at all.\n", "enum": [ "admin", "read", "write" ], "example": "read" }, "scopes": { "type": "string", "description": "OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used.", "example": "system/Patient.read system/Observation.read" } } }, { "type": "object", "required": [ "auth_method", "service_account_key" ], "properties": { "auth_method": { "type": "string", "enum": [ "google_healthcare" ] }, "service_account_key": { "type": "object", "description": "Google Cloud Service Account key (required for google_healthcare auth method)", "required": [ "type", "project_id", "private_key_id", "private_key", "client_email", "client_id", "auth_uri", "token_uri", "auth_provider_x509_cert_url", "client_x509_cert_url", "universe_domain" ], "properties": { "type": { "type": "string", "example": "service_account" }, "project_id": { "type": "string", "example": "my-gcp-project" }, "private_key_id": { "type": "string", "example": "key-id-123" }, "private_key": { "type": "string", "example": "-----BEGIN PRIVATE KEY-----\n..." }, "client_email": { "type": "string", "format": "email", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "example": "123456789012345678901" }, "auth_uri": { "type": "string", "format": "uri", "example": "https://accounts.google.com/o/oauth2/auth" }, "token_uri": { "type": "string", "format": "uri", "example": "https://oauth2.googleapis.com/token" }, "auth_provider_x509_cert_url": { "type": "string", "format": "uri", "example": "https://www.googleapis.com/oauth2/v1/certs" }, "client_x509_cert_url": { "type": "string", "format": "uri", "example": "https://www.googleapis.com/robot/v1/metadata/x509/service-account%40my-gcp-project.iam.gserviceaccount.com" }, "universe_domain": { "type": "string", "example": "googleapis.com" } } } } }, { "type": "object", "required": [ "auth_method" ], "properties": { "auth_method": { "type": "string", "enum": [ "token_passthrough" ] } } }, { "type": "object", "required": [ "auth_method" ], "properties": { "auth_method": { "type": "string", "enum": [ "none" ] } } } ], "discriminator": { "propertyName": "auth_method", "mapping": { "jwt": "#/components/schemas/fhir_provider_JwtAuth", "client_secret": "#/components/schemas/fhir_provider_ClientSecretAuth", "on_behalf_of": "#/components/schemas/fhir_provider_OnBehalfOfAuth", "google_healthcare": "#/components/schemas/fhir_provider_GoogleHealthcareAuth", "token_passthrough": "#/components/schemas/fhir_provider_TokenPassthroughAuth", "none": "#/components/schemas/fhir_provider_NoAuth" } } } } } ``` **Example:** ```json { "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth": { "auth_method": "client_secret", "client_id": "your-client-id", "client_secret": "your-client-secret", "role": "read" } } ``` #### Responses **201** - FHIR provider created successfully Content-Type: `application/json` ```json { "type": "object", "description": "Response payload for a single FHIR Provider operation.", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "oneOf": [ { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } }, { "type": "object", "description": "Limited information returned for sandbox FHIR providers. Sandbox\nresponses omit `auth_configs` and `last_updated`, which is what\ndistinguishes this shape from `FhirProviderTemplate` in `oneOf`.\n", "required": [ "id", "name", "provider" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "PhenoML Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Shared sandbox environment for experimentation" }, "provider": { "type": "string", "enum": [ "sandbox" ], "description": "Provider type (always \"sandbox\" for this schema)", "example": "sandbox" } } } ], "description": "Provider details. Sandbox providers return FhirProviderSandboxInfo.\n" } } } ``` **Example:** ```json { "success": true, "message": "Fhir provider created successfully", "data": { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "client_secret", "is_active_auth_config": true, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" } }, "last_updated": "2024-01-15T10:30:00Z" } } ``` **400** - Invalid request - missing required fields or invalid values **401** - Unauthorized **403** - Forbidden - only available on dedicated instances **500** - Server error --- ### GET /fhir-provider/{fhir_provider_id} **Get FHIR provider by ID** Retrieves a specific FHIR provider configuration by its ID. Sandbox providers return FhirProviderSandboxInfo. On shared instances, only sandbox providers can be accessed. **Operation ID:** `fhir_provider_get` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | ID of the FHIR provider to retrieve | #### Responses **200** - FHIR provider retrieved successfully Content-Type: `application/json` ```json { "type": "object", "description": "Response payload for a single FHIR Provider operation.", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string" }, "data": { "oneOf": [ { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } }, { "type": "object", "description": "Limited information returned for sandbox FHIR providers. Sandbox\nresponses omit `auth_configs` and `last_updated`, which is what\ndistinguishes this shape from `FhirProviderTemplate` in `oneOf`.\n", "required": [ "id", "name", "provider" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "PhenoML Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Shared sandbox environment for experimentation" }, "provider": { "type": "string", "enum": [ "sandbox" ], "description": "Provider type (always \"sandbox\" for this schema)", "example": "sandbox" } } } ], "description": "Provider details. Sandbox providers return FhirProviderSandboxInfo.\n" } } } ``` **Example:** ```json { "success": true, "message": "Fhir provider retrieved successfully", "data": { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "jwt", "is_active_auth_config": true, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T14:45:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" } }, "last_updated": "2024-01-15T14:45:00Z" } } ``` **401** - Unauthorized **404** - FHIR provider not found **500** - Server error --- ### DELETE /fhir-provider/{fhir_provider_id} **Delete FHIR provider** Deletes a FHIR provider. Note: Sandbox providers cannot be deleted. **Operation ID:** `fhir_provider_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | ID of the FHIR provider to delete | #### Responses **200** - FHIR provider deleted successfully Content-Type: `application/json` ```json { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Fhir provider deleted successfully" } } } ``` **Example:** ```json { "success": true, "message": "Fhir provider deleted successfully" } ``` **401** - Unauthorized **403** - Forbidden - dedicated instance required, or sandbox provider cannot be modified **404** - FHIR provider not found **500** - Server error --- ### POST /fhir-provider/{fhir_provider_id}/fhir **Execute FHIR bundle operation** Executes a FHIR Bundle transaction or batch operation on the specified provider. This allows multiple FHIR resources to be processed in a single request. The request body should contain a valid FHIR Bundle resource with transaction or batch type. On shared instances, only the default sandbox provider is accessible. The Bundle must contain an `entry` array, and each entry must have a `request.method` of `POST` and a relative resource-type `request.url`, such as `Patient` or `Observation`. URLs must contain only a resource type starting with an uppercase letter followed by letters or digits; absolute URLs, query strings, resource IDs, custom operation paths, and nested bundle execution are not supported. Entry resources and references are forwarded unchanged. On shared instances, invalid JSON, an invalid Bundle envelope, missing request fields, or duplicate property names in the Bundle, entry, or request objects return `400`. Unsupported entry methods or URLs return `403`, and a non-default provider returns `404`. If any entry is rejected, the entire Bundle is rejected without executing any entries. Dedicated instances support the upstream server's transaction and batch operations without these create-only restrictions. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_executeBundle` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body FHIR Bundle for transaction or batch processing **Required:** Yes **Content-Type:** `application/fhir+json` ```json {} ``` **Example:** ```json { "resourceType": "Bundle", "type": "transaction", "entry": [ { "request": { "method": "POST", "url": "Patient" }, "resource": { "resourceType": "Patient", "name": [ { "family": "Doe", "given": [ "John" ] } ] } }, { "request": { "method": "POST", "url": "Observation" }, "resource": { "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/123" } } } ] } ``` #### Responses **200** - Bundle executed successfully Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "Bundle", "type": "transaction-response", "entry": [ { "response": { "status": "201 Created", "location": "Patient/456" }, "resource": { "resourceType": "Patient", "id": "456" } } ] } ``` --- ### GET /fhir-provider/{fhir_provider_id}/fhir/{fhir_path} **Read or search FHIR resources** Retrieves FHIR resources from the specified provider. Supports both individual resource retrieval (e.g. `Patient/123` via the path) and search operations. FHIR search parameters are passed through to the upstream server verbatim as native query-string parameters; this proxy does not model, validate, or transform them. Append standard FHIR search parameters directly to the request URL. Supported parameters include: - Resource-specific search parameters (e.g. `name` for Patient, `status` for Observation) - Common search parameters (`_id`, `_lastUpdated`, `_tag`, `_profile`, `_security`, `_text`, `_content`, `_filter`) - Result parameters (`_count`, `_offset`, `_sort`, `_include`, `_revinclude`, `_summary`, `_elements`) - Search prefixes for dates, numbers, and quantities (`eq`, `ne`, `gt`, `ge`, `lt`, `le`, `sa`, `eb`, `ap`) Examples: - `Patient?name=John%20Doe&_count=10&_sort=family` - `Observation?patient=Patient/123&date=ge2023-01-01&category=vital-signs&_sort=-date` When using a generated SDK, supply these via the client's request-level query-parameter option (the SDK escape hatch) rather than a typed argument. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_search` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `fhir_path` | path | string | Yes | The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples: - "Patient" (for resource type operations) - "Patient/123" (for specific resource operations) - "Patient/123/_history" (for history operations) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Responses **200** - Successfully retrieved FHIR resource(s) Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "Bundle", "total": 2, "entry": [ { "resource": { "resourceType": "Patient", "id": "123", "name": [ { "family": "Doe", "given": [ "John" ] } ] } } ] } ``` --- ### PUT /fhir-provider/{fhir_provider_id}/fhir/{fhir_path} **Upsert FHIR resource** Creates or updates a FHIR resource on the specified provider. If the resource exists, it will be updated; otherwise, it will be created. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_upsert` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `fhir_path` | path | string | Yes | The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples: - "Patient" (for resource type operations) - "Patient/123" (for specific resource operations) - "Patient/123/_history" (for history operations) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body FHIR resource to create or update **Required:** Yes **Content-Type:** `application/fhir+json` ```json {} ``` **Example:** ```json { "resourceType": "Patient", "id": "123" } ``` #### Responses **200** - Resource upserted successfully Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "Patient", "id": "123", "meta": { "versionId": "2", "lastUpdated": "2024-02-20T11:00:00Z" } } ``` --- ### POST /fhir-provider/{fhir_provider_id}/fhir/{fhir_path} **Create FHIR resource** Creates a new FHIR resource on the specified provider. The request body should contain a valid FHIR resource in JSON format. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_create` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `fhir_path` | path | string | Yes | The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples: - "Patient" (for resource type operations) - "Patient/123" (for specific resource operations) - "Patient/123/_history" (for history operations) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body FHIR resource to create **Required:** Yes **Content-Type:** `application/fhir+json` ```json {} ``` **Example:** ```json { "resourceType": "Patient" } ``` #### Responses **200** - Resource created successfully Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "Patient", "id": "456", "meta": { "versionId": "1", "lastUpdated": "2024-01-15T10:30:00Z" } } ``` --- ### DELETE /fhir-provider/{fhir_provider_id}/fhir/{fhir_path} **Delete FHIR resource** Deletes a FHIR resource from the specified provider. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_delete` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `fhir_path` | path | string | Yes | The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples: - "Patient" (for resource type operations) - "Patient/123" (for specific resource operations) - "Patient/123/_history" (for history operations) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Responses **200** - Resource deleted successfully Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "OperationOutcome", "issue": [ { "severity": "information", "code": "informational", "details": { "text": "Resource deleted successfully" } } ] } ``` --- ### PATCH /fhir-provider/{fhir_provider_id}/fhir/{fhir_path} **Patch FHIR resource** Partially updates a FHIR resource on the specified provider. Two body formats are supported, selected by request content type: - `application/json-patch+json` — an array of JSON Patch operations as defined in RFC 6902. Each operation specifies: - `op`: The operation type (add, remove, replace, move, copy, test) - `path`: JSON Pointer to the target location in the resource - `value`: The value to use (required for add, replace, and test operations) - `application/fhir+json` — a partial FHIR resource for merge-patch semantics. **Note:** This proxy currently forwards the request body to the upstream FHIR server with `Content-Type: application/fhir+json` regardless of the declared request content type. JSON Patch (RFC 6902) therefore only succeeds against upstream servers that accept patch arrays under `application/fhir+json`; servers that strictly enforce patch media types may reject or misinterpret it. Support for either format ultimately depends on the upstream FHIR server. The request is proxied to the configured FHIR server with appropriate authentication headers. **Operation ID:** `fhir_patch` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `fhir_provider_id` | path | string | Yes | The ID of the FHIR provider to use. Can be either: - A UUID representing the provider ID - A provider name (legacy support - will just use the most recently updated provider with this name) | | `fhir_path` | path | string | Yes | The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples: - "Patient" (for resource type operations) - "Patient/123" (for specific resource operations) - "Patient/123/_history" (for history operations) | | `X-Phenoml-On-Behalf-Of` | header | string | No | Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid} | | `X-Phenoml-Fhir-Provider` | header | string | No | Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values. | #### Request Body JSON Patch operations to apply to the FHIR resource (RFC 6902) **Required:** Yes **Content-Type:** `application/json-patch+json` ```json { "type": "array", "description": "Array of JSON Patch operations following RFC 6902", "items": { "type": "object", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "enum": [ "add", "remove", "replace", "move", "copy", "test" ], "description": "The operation to perform" }, "path": { "type": "string", "description": "JSON Pointer to the target location" }, "value": { "description": "The value to use (required for add, replace, test operations)" }, "from": { "type": "string", "description": "Source location for move and copy operations (JSON Pointer)" } } } } ``` **Example:** ```json [ { "op": "replace", "path": "/name/0/family", "value": "NewFamilyName" } ] ``` **Content-Type:** `application/fhir+json` ```json {} ``` **Example:** ```json { "name": [ { "family": "NewName", "given": [ "John" ] } ] } ``` #### Responses **200** - Resource patched successfully Content-Type: `application/json` ```json {} ``` **Example:** ```json { "resourceType": "Patient", "id": "123", "meta": { "versionId": "3", "lastUpdated": "2024-02-20T11:30:00Z" } } ``` --- ### GET /fhir-provider/list **List FHIR providers** Retrieves a list of all active FHIR providers for the authenticated user. On shared instances, only sandbox providers are returned. Sandbox providers return FhirProviderSandboxInfo. **Operation ID:** `fhir_provider_list` #### Responses **200** - FHIR providers retrieved successfully Content-Type: `application/json` ```json { "type": "object", "description": "Response payload for listing FHIR Providers.\nOn shared instances, only sandbox providers are returned (as FhirProviderSandboxInfo).\nOn dedicated instances, full provider details are returned (as FhirProviderTemplate).\n", "properties": { "success": { "type": "boolean", "example": true }, "message": { "type": "string", "example": "Fhir providers retrieved successfully" }, "fhir_providers": { "type": "array", "description": "List of FHIR providers. Sandbox providers return FhirProviderSandboxInfo,\nother providers return FhirProviderTemplate.\n", "items": { "oneOf": [ { "type": "object", "description": "Full FHIR provider configuration returned for non-sandbox providers.\n`auth_configs` and `last_updated` are always populated, which is how\nlist responses distinguish this shape from `FhirProviderSandboxInfo`.\n", "required": [ "id", "name", "provider", "auth_configs", "last_updated" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "Epic Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Epic sandbox environment for testing" }, "provider": { "type": "string", "description": "Type of FHIR server provider.\n\nThe \"sandbox\" provider type is managed internally and cannot be created via API.\nIt is used on shared instances.\n", "enum": [ "aidbox", "athenahealth", "canvas", "cerner", "elation", "epic", "google_healthcare", "hapi", "meditech", "medplum", "phenostore", "sandbox" ], "example": "epic" }, "base_url": { "type": "string", "format": "uri", "description": "Base URL of the FHIR server", "example": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" }, "client_id": { "type": "string", "deprecated": true, "description": "OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.", "example": "your-client-id" }, "auth_configs": { "type": "object", "description": "Map of authentication configurations (key is auth_config_id)", "additionalProperties": { "type": "object", "description": "Authentication configuration for a FHIR provider (sensitive fields are hidden from JSON responses)", "properties": { "auth_config_id": { "type": "string", "description": "Unique identifier for this auth configuration", "example": "auth-config-123" }, "auth_method": { "type": "string", "description": "Authentication method for the FHIR provider. Only one authentication method can be used at a time,\nbut these can be rotated on the FHIR Provider as needed.\n\n**Scope behavior by auth method:**\n- `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.\n They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific\n default scopes derived from a default role are used. Roles grant access across all FHIR resource\n types, but the exact scope format varies by EHR — see the `Role` schema for details.\n- `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will\n return an error.\n- `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header\n as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`\n will return an error. This is the recommended mode for providers like Meditech where the bearer token\n is typically obtained outside PhenoML.\n- `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.\n\nFor the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference\nin the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works\nfor the medplum provider currently.\n\nMore on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and\nAgent documentation.\n", "enum": [ "client_secret", "google_healthcare", "jwt", "on_behalf_of", "token_passthrough", "none" ], "example": "jwt" }, "is_active_auth_config": { "type": "boolean", "description": "Whether this auth configuration is currently active", "example": true }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was created", "example": "2024-01-15T10:30:00Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp when this auth configuration was last updated", "example": "2024-01-15T14:45:00Z" }, "public_key_cert_pem": { "type": "string", "description": "Public key certificate in PEM format (visible for JWT auth)", "example": "-----BEGIN CERTIFICATE-----\n..." }, "json_web_key": { "type": "object", "description": "JSON Web Key structure for RSA keys used in JWT authentication. Keys are automatically generated using RSA-2048 with RS384 signing algorithm. The Key ID (kid) is derived from a SHA256 hash of the public key PEM format.", "properties": { "kty": { "type": "string", "description": "Key Type", "example": "RSA" }, "use": { "type": "string", "description": "Usage (sig for signature)", "example": "sig" }, "kid": { "type": "string", "description": "Key ID - SHA256 hash of the public key PEM (including headers) encoded as base64url. Generated by taking the public key in PEM format, hashing with SHA256, then base64url encoding (replacing + with -, / with _, and removing padding).", "example": "FHIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoeb" }, "alg": { "type": "string", "description": "Algorithm used for JWT signing (RSA with SHA-384)", "example": "RS384" }, "n": { "type": "string", "description": "RSA Modulus (base64url encoded)", "example": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbIS" }, "e": { "type": "string", "description": "RSA Exponent (base64url encoded)", "example": "AQAB" } } }, "credential_expiry": { "type": "string", "format": "date-time", "description": "Expiry time for credentials (JWT auth only)", "example": "2024-12-31T23:59:59Z" }, "smart_configuration": { "type": "object", "description": "SMART on FHIR configuration for OAuth-based providers", "properties": { "authorization_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 authorization endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" }, "token_endpoint": { "type": "string", "format": "uri", "description": "OAuth2 token endpoint", "example": "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" }, "issuer": { "type": "string", "format": "uri", "description": "OIDC issuer URL", "example": "https://fhir.epic.com/interconnect-fhir-oauth" }, "jwks_uri": { "type": "string", "format": "uri", "description": "JSON Web Key Set URI", "example": "https://fhir.epic.com/interconnect-fhir-oauth/.well-known/jwks" }, "scopes_supported": { "type": "array", "description": "List of supported scopes", "items": { "type": "string" }, "example": [ "patient/*.read", "system/*.read" ] } } }, "service_account_metadata": { "type": "object", "description": "Non-sensitive metadata from a Google Cloud Service Account, exposed in API responses to help identify auth configurations without revealing sensitive credentials.", "properties": { "type": { "type": "string", "description": "Account type (always \"service_account\")", "example": "service_account" }, "project_id": { "type": "string", "description": "Google Cloud project ID", "example": "my-gcp-project" }, "client_email": { "type": "string", "format": "email", "description": "Service account email address", "example": "service-account@my-gcp-project.iam.gserviceaccount.com" }, "client_id": { "type": "string", "description": "Service account client ID", "example": "123456789012345678901" } } }, "scopes": { "type": "string", "description": "OAuth scopes", "example": "system/Patient.read system/Observation.read" }, "client_id": { "type": "string", "description": "OAuth client ID for this auth configuration. When set, takes precedence over the provider-level client_id.", "example": "your-client-id" } } } }, "last_updated": { "type": "string", "format": "date-time", "description": "Timestamp when the provider was last updated", "example": "2024-01-15T10:30:00Z" } } }, { "type": "object", "description": "Limited information returned for sandbox FHIR providers. Sandbox\nresponses omit `auth_configs` and `last_updated`, which is what\ndistinguishes this shape from `FhirProviderTemplate` in `oneOf`.\n", "required": [ "id", "name", "provider" ], "properties": { "id": { "type": "string", "description": "Unique identifier for the FHIR provider", "example": "1716d214-de93-43a4-aa6b-a878d864e2ad" }, "name": { "type": "string", "description": "Display name for the FHIR provider", "example": "PhenoML Sandbox" }, "description": { "type": "string", "description": "Optional description of the FHIR provider", "example": "Shared sandbox environment for experimentation" }, "provider": { "type": "string", "enum": [ "sandbox" ], "description": "Provider type (always \"sandbox\" for this schema)", "example": "sandbox" } } } ] } } } } ``` **Example:** ```json { "success": true, "message": "Fhir providers retrieved successfully", "fhir_providers": [ { "id": "1716d214-de93-43a4-aa6b-a878d864e2ad", "name": "Epic Sandbox", "description": "Epic sandbox environment for testing", "provider": "epic", "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4", "auth_configs": { "auth-config-123": { "auth_config_id": "auth-config-123", "auth_method": "jwt", "is_active_auth_config": true, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z", "scopes": "system/Patient.read system/Observation.read", "client_id": "your-client-id" } }, "last_updated": "2024-01-15T10:30:00Z" }, { "id": "4da196da-5cf1-4574-9e65-f97d7ea20b38", "name": "PhenoML Sandbox", "description": "Shared sandbox environment for experimentation", "provider": "sandbox" } ] } ``` **401** - Unauthorized **500** - Server error --- # Voice Transcribe audio recordings into text with speech-to-text. Pair the transcript with Lang2FHIR to turn spoken clinical notes into structured FHIR resources. ### POST /transcribe **Transcribe audio** Transcribes an uploaded audio recording and returns the transcript. Send the raw audio bytes as the request body; the audio format is detected automatically (WAV, FLAC, MP3, OGG/WebM Opus). The raw audio request body is limited to 32 MiB. Supports up to ~5 minutes of audio per request. This duration limit is independent of file size or format, so a compressed recording within the body-size limit can still be rejected for being too long. Pair the transcript with a downstream text step (e.g. `POST /lang2fhir/create`) to turn it into a FHIR resource. **Operation ID:** `voice_transcribe` #### Parameters | Name | In | Type | Required | Description | |------|-----|------|----------|-------------| | `language` | query | string[] | No | BCP-47 language tag, repeatable for up to 4 candidate languages. Defaults to `en-US`. | #### Request Body Raw audio bytes (WAV, FLAC, MP3, or OGG/WebM Opus), up to 32 MiB. **Required:** Yes **Content-Type:** `application/octet-stream` ```json { "type": "string", "format": "binary" } ``` #### Responses **200** - Transcription succeeded. Content-Type: `application/json` ```json { "type": "object", "required": [ "transcript" ], "properties": { "transcript": { "type": "string", "description": "The full transcript of the audio." } } } ``` **400** - Invalid request (empty body, too many languages, no transcript produced, or audio that is too long or in an unsupported format) **401** - Unauthorized **402** - Payment required (credits exhausted or subscription inactive) **502** - Speech recognition failed **503** - Transcription temporarily unavailable **504** - Transcription timed out ---