Submits a single FHIR R4 resource JSON object.
POST
/
v1
/
fhir
/
resource
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Observation",
"id": "bp-example",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
}],
}],
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel",
}],
},
"subject": {"reference": "Patient/example"},
"effectiveDateTime": "2026-05-01T10:00:00Z",
"component": [
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6"}]},
"valueQuantity": {"value": 120, "unit": "mmHg"},
},
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4"}]},
"valueQuantity": {"value": 80, "unit": "mmHg"},
},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: new Dictionary<string, object?>
{
["resourceType"] = "Condition",
["clinicalStatus"] = new Dictionary<string, object?>
{
["coding"] = new List<object?>
{
new Dictionary<string, object?>
{
["system"] = "http://terminology.hl7.org/CodeSystem/condition-clinical",
["code"] = "active",
},
},
},
["code"] = new Dictionary<string, object?>
{
["text"] = "Breast cancer",
},
["subject"] = new Dictionary<string, object?> { ["reference"] = "Patient/example" },
},
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
POST /v1/fhir/resource
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"patient_id": "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
"resource": {
"resourceType": "Observation",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs"
}]
}],
"code": {
"coding": [{ "system": "http://loinc.org", "code": "85354-9" }]
},
"subject": { "reference": "Patient/example" },
"effectiveDateTime": "2026-05-01T10:00:00Z"
},
"idempotency_key": "emr-obs-88421"
}
BatchResult(accepted=1, failed=0, errors=[])
{
"error": true,
"status_code": 401,
"error_type": "authentication_error",
"message": "Could not validate credentials",
"details": [
{
"type": "authentication_error",
"message": "Could not validate credentials"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 403,
"error_type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint",
"details": [
{
"type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 404,
"error_type": "not_found_error",
"message": "Patient not found",
"details": [
{
"type": "not_found_error",
"message": "Patient not found"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 422,
"error_type": "validation_error",
"message": "Request validation failed (1 error)",
"details": [
{
"type": "missing",
"message": "Field required",
"field": "patient_id",
"location": ["body", "patient_id"],
"input_value": null
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 429,
"error_type": "server_error",
"message": "Rate limit exceeded",
"details": [
{
"type": "rate_limit",
"message": "Too many requests; retry after backoff"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 500,
"error_type": "internal_server_error",
"message": "An internal server error occurred",
"details": [
{
"type": "internal_server_error",
"message": "An unexpected error occurred while processing your request"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
olira.log_fhir(
patient_id: str,
resource: dict[str, Any],
idempotency_key: str | None = None,
) -> BatchResult
OliraModule.LogFhir(
string patientId,
Dictionary<string, object?> resource,
string? idempotencyKey = null,
) // -> BatchResult
sdk:event-log
Olira maps it to one or more platform log types via the FHIR absorber (same schema mapper used by Epic/Cerner integrations and Console FHIR upload), then processes each event immediately for the patient — unlike olira.log(), you do not choose log_type or build Olira-shaped payloads yourself. One resource may produce zero events (unsupported type or unmappable fields), one event, or several (for example a treatment plan from an EHR). See Supported FHIR resources below for the full resourceType → event type matrix.
Parameters
str
required
Olira patient id (from create_patient or your patient registry).
dict[str, Any]
required
FHIR R4 resource object with resourceType set. Supported types are listed in Supported FHIR resources below (17 resource families, including Observation, Condition, MedicationRequest, Patient, DocumentReference, DiagnosticReport, etc.).
str | None
Optional. Set this if you might retry the call (timeout or 5xx). Pass the same key you sent the first time — one key per resource, not per mapped event. See Retries and idempotency.
Returns
BatchResult
int
Number of mapped events processed through patient state.
int
Number of mapped events skipped or failed.
list[BatchError]
Mapping or processing errors (e.g. unknown resource fields, replay conflict).
Supported FHIR resources
FHIR resourceType | Olira event type(s) | Notes |
|---|---|---|
Observation | vitals_measurement, lab_results, genomic_variant, clinical_measurement, functional_class, clinical_finding, social_determinants, treatment_response_assessment | Routed by category and LOINC. Vital-signs Observations at the same effectiveDateTime merge into one vitals_measurement when submitted in a multi-entry Bundle; via log_fhir (single resource) each vital-signs Observation is processed alone. |
Patient | demographics | — |
Appointment | care_encounter | — |
Encounter | care_encounter | — |
Condition | condition | — |
MedicationRequest, MedicationStatement, MedicationAdministration | medication_list_update | Medication display/dose resolved from the resource; sibling Medication entries in a Bundle are not visible to log_fhir. |
AllergyIntolerance | allergy_intolerance | — |
CarePlan | clinical_plan_item, treatment_phase | treatment_phase uses a heuristic on plan category/text. |
CareTeam | care_team | — |
DiagnosticReport | lab_results, imaging_result, procedure_result, unstructured_report | Never clinical_note. Panel lab results need referenced Observation resources in the same Bundle; log_fhir cannot resolve result[] references across separate calls. |
DocumentReference | clinical_note, unstructured_report | Inline base64 attachment.data is decoded into note text. attachment.url is not fetched — placeholder text only. |
Procedure | procedure | — |
Immunization | immunization | — |
FamilyMemberHistory | family_history | — |
Goal | care_goal | — |
Coverage | insurance | — |
RelatedPerson | emergency_contact | — |
Per-resource examples
- Python
- C#
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Observation",
"id": "bp-example",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
}],
}],
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel",
}],
},
"subject": {"reference": "Patient/example"},
"effectiveDateTime": "2026-05-01T10:00:00Z",
"component": [
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6"}]},
"valueQuantity": {"value": 120, "unit": "mmHg"},
},
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4"}]},
"valueQuantity": {"value": 80, "unit": "mmHg"},
},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Patient",
"id": "patient-example",
"name": [{"given": ["Camila"], "family": "Lopez"}],
"gender": "female",
"birthDate": "1987-09-12",
"telecom": [
{"system": "email", "value": "camila@example.com"},
{"system": "phone", "value": "+1-469-555-0100"},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Appointment",
"id": "appt-example",
"status": "booked",
"appointmentType": {
"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}],
},
"start": "2026-06-15T14:00:00Z",
"end": "2026-06-15T14:30:00Z",
"created": "2026-06-01",
"participant": [{
"actor": {"reference": "Patient/example"},
"status": "accepted",
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Encounter",
"id": "enc-example",
"status": "finished",
"class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"},
"subject": {"reference": "Patient/example"},
"period": {"start": "2026-06-15T14:00:00Z", "end": "2026-06-15T14:45:00Z"},
"reasonCode": [{"text": "Follow-up visit"}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Condition",
"id": "condition-example",
"clinicalStatus": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
"code": "active",
}],
},
"code": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "254837009",
"display": "Breast cancer",
}],
"text": "Breast cancer",
},
"subject": {"reference": "Patient/example"},
"onsetDateTime": "2025-01-10T00:00:00Z",
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "MedicationRequest",
"id": "med-example",
"status": "active",
"intent": "order",
"medicationCodeableConcept": {
"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "860975"}],
"text": "Metformin 500 MG Oral Tablet",
},
"subject": {"reference": "Patient/example"},
"authoredOn": "2026-03-01T09:00:00Z",
"dosageInstruction": [{"text": "Take 500 mg twice daily with meals"}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "AllergyIntolerance",
"id": "allergy-example",
"clinicalStatus": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
"code": "active",
}],
},
"code": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "91936005",
"display": "Allergy to penicillin",
}],
"text": "Penicillin",
},
"patient": {"reference": "Patient/example"},
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "CarePlan",
"id": "careplan-example",
"status": "active",
"intent": "plan",
"category": [{
"coding": [{
"system": "http://hl7.org/fhir/us/core/CodeSystem/careplan-category",
"code": "assess-plan",
}],
}],
"subject": {"reference": "Patient/example"},
"activity": [{
"detail": {
"status": "in-progress",
"description": "Monitor blood glucose daily",
},
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "CareTeam",
"id": "careteam-example",
"status": "active",
"subject": {"reference": "Patient/example"},
"participant": [{
"role": [{"text": "Primary oncologist"}],
"member": {"display": "Dr. Sarah Patel"},
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "DiagnosticReport",
"id": "imaging-report-example",
"status": "final",
"category": [{"coding": [{"code": "RAD", "display": "Radiology"}]}],
"code": {"text": "CT chest"},
"subject": {"reference": "Patient/example"},
"effectiveDateTime": "2026-05-01T10:00:00Z",
"conclusion": "No acute cardiopulmonary findings.",
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "DocumentReference",
"id": "note-example",
"status": "current",
"type": {"coding": [{"system": "http://loinc.org", "code": "11506-3"}]},
"subject": {"reference": "Patient/example"},
"date": "2026-05-01",
"content": [{
"attachment": {
"contentType": "text/plain",
"data": "UHJvZ3Jlc3Mgbm90ZTogUGF0aWVudCBzdGFibGUu",
},
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Procedure",
"id": "procedure-example",
"status": "completed",
"code": {
"coding": [{"system": "http://www.ama-assn.org/go/cpt", "code": "93306"}],
"text": "Transthoracic echocardiogram",
},
"subject": {"reference": "Patient/example"},
"performedDateTime": "2026-04-20T15:30:00Z",
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Immunization",
"id": "immunization-example",
"status": "completed",
"vaccineCode": {
"coding": [{"system": "http://hl7.org/fhir/sid/cvx", "code": "115"}],
"text": "Tdap",
},
"patient": {"reference": "Patient/example"},
"occurrenceDateTime": "2026-02-10",
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "FamilyMemberHistory",
"id": "fmh-example",
"status": "completed",
"patient": {"reference": "Patient/example"},
"relationship": {"coding": [{"code": "MTH", "display": "Mother"}]},
"condition": [{
"code": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "44054006",
"display": "Type 2 diabetes mellitus",
}],
},
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Goal",
"id": "goal-example",
"lifecycleStatus": "active",
"description": {"text": "Walk 30 minutes daily"},
"subject": {"reference": "Patient/example"},
"target": [{
"measure": {"coding": [{"code": "steps"}]},
"detailQuantity": {"value": 30, "unit": "min"},
}],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Coverage",
"id": "coverage-example",
"status": "active",
"order": 1,
"subscriberId": "MEM123",
"type": {"coding": [{"code": "PPO", "display": "Commercial PPO"}]},
"payor": [{"display": "Blue Shield"}],
"class": [
{"type": {"coding": [{"code": "plan"}]}, "name": "Gold PPO", "value": "GP1"},
{"type": {"coding": [{"code": "group"}]}, "value": "GRP-9"},
],
"period": {"start": "2026-01-01"},
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "RelatedPerson",
"id": "related-person-example",
"patient": {"reference": "Patient/example"},
"relationship": [{"coding": [{"code": "SPS", "display": "spouse"}]}],
"name": [{"given": ["Bob"], "family": "Lopez"}],
"telecom": [
{"system": "phone", "value": "555-0100"},
{"system": "email", "value": "bob@example.com"},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Observation"
"id": "bp-example"
"status": "final"
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category"
"code": "vital-signs"
}]
}]
"code": {
"coding": [{
"system": "http://loinc.org"
"code": "85354-9"
"display": "Blood pressure panel"
}]
}
"subject": {"reference": "Patient/example"}
"effectiveDateTime": "2026-05-01T10:00:00Z"
"component": [
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6"}]}
"valueQuantity": {"value": 120, "unit": "mmHg"}
}
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4"}]}
"valueQuantity": {"value": 80, "unit": "mmHg"}
}
]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Patient"
"id": "patient-example"
"name": [{"given": ["Camila"], "family": "Lopez"}]
"gender": "female"
"birthDate": "1987-09-12"
"telecom": [
{"system": "email", "value": "camila@example.com"}
{"system": "phone", "value": "+1-469-555-0100"}
]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Appointment"
"id": "appt-example"
"status": "booked"
"appointmentType": {
"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}]
}
"start": "2026-06-15T14:00:00Z"
"end": "2026-06-15T14:30:00Z"
"created": "2026-06-01"
"participant": [{
"actor": {"reference": "Patient/example"}
"status": "accepted"
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Encounter"
"id": "enc-example"
"status": "finished"
"class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}
"subject": {"reference": "Patient/example"}
"period": {"start": "2026-06-15T14:00:00Z", "end": "2026-06-15T14:45:00Z"}
"reasonCode": [{"text": "Follow-up visit"}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Condition"
"id": "condition-example"
"clinicalStatus": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical"
"code": "active"
}]
}
"code": {
"coding": [{
"system": "http://snomed.info/sct"
"code": "254837009"
"display": "Breast cancer"
}]
"text": "Breast cancer"
}
"subject": {"reference": "Patient/example"}
"onsetDateTime": "2025-01-10T00:00:00Z"
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "MedicationRequest"
"id": "med-example"
"status": "active"
"intent": "order"
"medicationCodeableConcept": {
"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "860975"}]
"text": "Metformin 500 MG Oral Tablet"
}
"subject": {"reference": "Patient/example"}
"authoredOn": "2026-03-01T09:00:00Z"
"dosageInstruction": [{"text": "Take 500 mg twice daily with meals"}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "AllergyIntolerance"
"id": "allergy-example"
"clinicalStatus": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"
"code": "active"
}]
}
"code": {
"coding": [{
"system": "http://snomed.info/sct"
"code": "91936005"
"display": "Allergy to penicillin"
}]
"text": "Penicillin"
}
"patient": {"reference": "Patient/example"}
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "CarePlan"
"id": "careplan-example"
"status": "active"
"intent": "plan"
"category": [{
"coding": [{
"system": "http://hl7.org/fhir/us/core/CodeSystem/careplan-category"
"code": "assess-plan"
}]
}]
"subject": {"reference": "Patient/example"}
"activity": [{
"detail": {
"status": "in-progress"
"description": "Monitor blood glucose daily"
}
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "CareTeam"
"id": "careteam-example"
"status": "active"
"subject": {"reference": "Patient/example"}
"participant": [{
"role": [{"text": "Primary oncologist"}]
"member": {"display": "Dr. Sarah Patel"}
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "DiagnosticReport"
"id": "imaging-report-example"
"status": "final"
"category": [{"coding": [{"code": "RAD", "display": "Radiology"}]}]
"code": {"text": "CT chest"}
"subject": {"reference": "Patient/example"}
"effectiveDateTime": "2026-05-01T10:00:00Z"
"conclusion": "No acute cardiopulmonary findings."
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "DocumentReference"
"id": "note-example"
"status": "current"
"type": {"coding": [{"system": "http://loinc.org", "code": "11506-3"}]}
"subject": {"reference": "Patient/example"}
"date": "2026-05-01"
"content": [{
"attachment": {
"contentType": "text/plain"
"data": "UHJvZ3Jlc3Mgbm90ZTogUGF0aWVudCBzdGFibGUu"
}
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Procedure"
"id": "procedure-example"
"status": "completed"
"code": {
"coding": [{"system": "http://www.ama-assn.org/go/cpt", "code": "93306"}]
"text": "Transthoracic echocardiogram"
}
"subject": {"reference": "Patient/example"}
"performedDateTime": "2026-04-20T15:30:00Z"
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Immunization"
"id": "immunization-example"
"status": "completed"
"vaccineCode": {
"coding": [{"system": "http://hl7.org/fhir/sid/cvx", "code": "115"}]
"text": "Tdap"
}
"patient": {"reference": "Patient/example"}
"occurrenceDateTime": "2026-02-10"
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "FamilyMemberHistory"
"id": "fmh-example"
"status": "completed"
"patient": {"reference": "Patient/example"}
"relationship": {"coding": [{"code": "MTH", "display": "Mother"}]}
"condition": [{
"code": {
"coding": [{
"system": "http://snomed.info/sct"
"code": "44054006"
"display": "Type 2 diabetes mellitus"
}]
}
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Goal"
"id": "goal-example"
"lifecycleStatus": "active"
"description": {"text": "Walk 30 minutes daily"}
"subject": {"reference": "Patient/example"}
"target": [{
"measure": {"coding": [{"code": "steps"}]}
"detailQuantity": {"value": 30, "unit": "min"}
}]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "Coverage"
"id": "coverage-example"
"status": "active"
"order": 1
"subscriberId": "MEM123"
"type": {"coding": [{"code": "PPO", "display": "Commercial PPO"}]}
"payor": [{"display": "Blue Shield"}]
"class": [
{"type": {"coding": [{"code": "plan"}]}, "name": "Gold PPO", "value": "GP1"}
{"type": {"coding": [{"code": "group"}]}, "value": "GRP-9"}
]
"period": {"start": "2026-01-01"}
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
using System.Text.Json;
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var resource = JsonSerializer.Deserialize<object>("""
{
"resourceType": "RelatedPerson"
"id": "related-person-example"
"patient": {"reference": "Patient/example"}
"relationship": [{"coding": [{"code": "SPS", "display": "spouse"}]}]
"name": [{"given": ["Bob"], "family": "Lopez"}]
"telecom": [
{"system": "phone", "value": "555-0100"}
{"system": "email", "value": "bob@example.com"}
]
}
""")!;
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: resource,
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
Each call accepts one FHIR resource. Linked resources in the same payload are not resolved together (for example, lab Observations referenced from a DiagnosticReport). Use historical ingestion or an EHR integration when you need multi-resource imports.
Unsupported resource types (zero events accepted): QuestionnaireResponse, ImagingStudy, ServiceRequest, Task, AdverseEvent, Device, EpisodeOfCare, ClinicalImpression, MolecularSequence, and standalone Binary. Support for additional FHIR resource types is added continuously.
Ingested data is stored as Olira event logs (type and payload), not as raw FHIR. Read it back with get_logs() or logs().
If you might retry, set idempotency_key. A resource with no usable date is timestamped at processing time, so two calls without a key can both be stored. See Retries and idempotency.
Raises
| Exception | When |
|---|---|
AuthError | HTTP 401 or 403 — invalid API key or insufficient OAuth scope for this endpoint. |
ServerError | HTTP 409 (e.g. conflicting external identifier) or repeated 5xx after retries; includes status_code when applicable. |
RateLimitError | HTTP 429 — rate limited; check retry_after (seconds). |
NetworkError | Connection timeout, DNS failure, or read error after retries. |
ValidationError | HTTP 422 — missing resourceType or malformed request. Also raised when the resource maps to zero Olira events (unsupported type, unrecognized fields, or Observation with unrecognized category/LOINC) — the exception message explains why. |
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Observation",
"id": "bp-example",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
}],
}],
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel",
}],
},
"subject": {"reference": "Patient/example"},
"effectiveDateTime": "2026-05-01T10:00:00Z",
"component": [
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6"}]},
"valueQuantity": {"value": 120, "unit": "mmHg"},
},
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4"}]},
"valueQuantity": {"value": 80, "unit": "mmHg"},
},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: new Dictionary<string, object?>
{
["resourceType"] = "Condition",
["clinicalStatus"] = new Dictionary<string, object?>
{
["coding"] = new List<object?>
{
new Dictionary<string, object?>
{
["system"] = "http://terminology.hl7.org/CodeSystem/condition-clinical",
["code"] = "active",
},
},
},
["code"] = new Dictionary<string, object?>
{
["text"] = "Breast cancer",
},
["subject"] = new Dictionary<string, object?> { ["reference"] = "Patient/example" },
},
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
POST /v1/fhir/resource
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"patient_id": "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
"resource": {
"resourceType": "Observation",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs"
}]
}],
"code": {
"coding": [{ "system": "http://loinc.org", "code": "85354-9" }]
},
"subject": { "reference": "Patient/example" },
"effectiveDateTime": "2026-05-01T10:00:00Z"
},
"idempotency_key": "emr-obs-88421"
}
BatchResult(accepted=1, failed=0, errors=[])
{
"error": true,
"status_code": 401,
"error_type": "authentication_error",
"message": "Could not validate credentials",
"details": [
{
"type": "authentication_error",
"message": "Could not validate credentials"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 403,
"error_type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint",
"details": [
{
"type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 404,
"error_type": "not_found_error",
"message": "Patient not found",
"details": [
{
"type": "not_found_error",
"message": "Patient not found"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 422,
"error_type": "validation_error",
"message": "Request validation failed (1 error)",
"details": [
{
"type": "missing",
"message": "Field required",
"field": "patient_id",
"location": ["body", "patient_id"],
"input_value": null
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 429,
"error_type": "server_error",
"message": "Rate limit exceeded",
"details": [
{
"type": "rate_limit",
"message": "Too many requests; retry after backoff"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 500,
"error_type": "internal_server_error",
"message": "An internal server error occurred",
"details": [
{
"type": "internal_server_error",
"message": "An unexpected error occurred while processing your request"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
⌘I
import olira
olira.init(api_key="YOUR_API_KEY")
result = olira.log_fhir(
patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource={
"resourceType": "Observation",
"id": "bp-example",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
}],
}],
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel",
}],
},
"subject": {"reference": "Patient/example"},
"effectiveDateTime": "2026-05-01T10:00:00Z",
"component": [
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6"}]},
"valueQuantity": {"value": 120, "unit": "mmHg"},
},
{
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4"}]},
"valueQuantity": {"value": 80, "unit": "mmHg"},
},
],
},
idempotency_key="emr-resource-88421",
)
print(result.accepted, result.failed)
using Olira;
OliraModule.Init(apiKey: "YOUR_API_KEY");
var result = OliraModule.LogFhir(
patientId: "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
resource: new Dictionary<string, object?>
{
["resourceType"] = "Condition",
["clinicalStatus"] = new Dictionary<string, object?>
{
["coding"] = new List<object?>
{
new Dictionary<string, object?>
{
["system"] = "http://terminology.hl7.org/CodeSystem/condition-clinical",
["code"] = "active",
},
},
},
["code"] = new Dictionary<string, object?>
{
["text"] = "Breast cancer",
},
["subject"] = new Dictionary<string, object?> { ["reference"] = "Patient/example" },
},
idempotencyKey: "emr-resource-88421");
Console.WriteLine($"{result.Accepted} {result.Failed}");
POST /v1/fhir/resource
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"patient_id": "8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
"resource": {
"resourceType": "Observation",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs"
}]
}],
"code": {
"coding": [{ "system": "http://loinc.org", "code": "85354-9" }]
},
"subject": { "reference": "Patient/example" },
"effectiveDateTime": "2026-05-01T10:00:00Z"
},
"idempotency_key": "emr-obs-88421"
}
BatchResult(accepted=1, failed=0, errors=[])
{
"error": true,
"status_code": 401,
"error_type": "authentication_error",
"message": "Could not validate credentials",
"details": [
{
"type": "authentication_error",
"message": "Could not validate credentials"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 403,
"error_type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint",
"details": [
{
"type": "authorization_error",
"message": "Insufficient OAuth scope for this endpoint"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 404,
"error_type": "not_found_error",
"message": "Patient not found",
"details": [
{
"type": "not_found_error",
"message": "Patient not found"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 422,
"error_type": "validation_error",
"message": "Request validation failed (1 error)",
"details": [
{
"type": "missing",
"message": "Field required",
"field": "patient_id",
"location": ["body", "patient_id"],
"input_value": null
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 429,
"error_type": "server_error",
"message": "Rate limit exceeded",
"details": [
{
"type": "rate_limit",
"message": "Too many requests; retry after backoff"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}
{
"error": true,
"status_code": 500,
"error_type": "internal_server_error",
"message": "An internal server error occurred",
"details": [
{
"type": "internal_server_error",
"message": "An unexpected error occurred while processing your request"
}
],
"timestamp": "2026-05-06T12:00:00+00:00"
}

