Skip to main content
Docs vCurrentAPI
Version: Current

FHIR R4 integration

Send a prescription as a FHIR R4 Bundle and get the risk analysis back as a FHIR Bundle of RiskAssessment + DetectedIssue. Ideal for hospital systems (EHR/HIS) that already speak FHIR.

Copia um prompt pronto com fluxo de integração, payload e exemplos.

Endpoint

POST /api/v1/fhir/$check (API key auth, scope interactions:check).

QueryDefaultDescription
formatfhirfhir returns a FHIR Bundle; internal returns the native SauBit response (prescription_risk_level, clinical_alerts, …).

Resources accepted in the Bundle

FHIR resourceMapped to
MedicationRequest / MedicationStatementMedication (name, dose, frequency, route). Status stopped/cancelled/entered-in-error/draft is ignored.
ConditionPatient clinical condition.
AllergyIntoleranceAllergy.
ObservationLab/context by LOINC code or text: potassium (2823-3), INR (6301-6), QTc, clearance/eGFR (33914-3), weight (29463-7), pregnancy (82810-3).
PatientAge (from birthDate) and sex (gender).
EncounterCare unit/setting (class/type) → per-unit governance (ICU/pediatrics/oncology).
DiagnosticReportContained Observations → labs; conclusionCode → condition.
PractitionerAccepted for completeness; no effect on the deterministic analysis.
  • The drug name comes from medicationCodeableConcept.text, coding[].display/code or medicationReference.display.
  • Dose: dosageInstruction[0].doseAndRate[0].doseQuantity (g converted to mg).
  • Frequency: dosageInstruction[0].timing.repeat (e.g. frequency:1, period:8, periodUnit:"h" becomes 8/8h).

Example

curl -X POST "https://api.saubit.com.br/api/v1/fhir/\$check" \
-H "X-API-Key: sm_live_..." \
-H "Content-Type: application/fhir+json" \
-d '{
"resourceType": "Bundle",
"type": "collection",
"entry": [
{ "resource": { "resourceType": "MedicationRequest", "status": "active",
"medicationCodeableConcept": { "text": "Ibuprofeno" } } },
{ "resource": { "resourceType": "MedicationRequest", "status": "active",
"medicationCodeableConcept": { "text": "Naproxeno" } } },
{ "resource": { "resourceType": "Condition", "code": { "text": "Insuficiência renal" } } }
]
}'

Response (FHIR)

{
"resourceType": "Bundle",
"type": "collection",
"total": 3,
"entry": [
{
"resource": {
"resourceType": "RiskAssessment",
"status": "final",
"method": { "text": "SauBit clinical engine" },
"prediction": [
{ "outcome": { "text": "Adverse drug event / prescription risk" },
"qualitativeRisk": { "text": "high" }, "probabilityDecimal": 0.82 }
]
}
},
{
"resource": {
"resourceType": "DetectedIssue",
"status": "preliminary",
"severity": "high",
"code": { "text": "drug_disease: NSAID may worsen renal function" },
"detail": "Avoid in this condition…",
"implicated": [ { "display": "Ibuprofeno" } ]
}
}
]
}

Severity mapping → DetectedIssue.severity: CONTRAINDICADO/GRAVEhigh, MODERADOmoderate, LEVElow. The prescription risk becomes a RiskAssessment (qualitativeRisk + probabilityDecimal = score/100).

Errors

Invalid bundles return a FHIR OperationOutcome with issue[].severity = "error":

{ "resourceType": "OperationOutcome",
"issue": [ { "severity": "error", "code": "invalid",
"diagnostics": "No MedicationRequest/MedicationStatement with a valid medication in the Bundle." } ] }

The analysis behind it is exactly the same as /interactions/check — including clinical_alerts, governance and the fail-safe policy.