# FHIR API (supported subset)

The FHIR data API is a standard FHIR R4 server, hosted separately from the auth server
(Production: `https://au.fhir.innowell.org/fhir/R4`; staging:
`https://au.fhir-stg.innowell.dev/fhir/R4`). This page summarises the resources
and operations Innowell exposes; the full endpoint documentation with request builders
lives in the [FHIR API reference](/api-fhir), and the machine-readable
CapabilityStatement is always available at `{fhir_base}/metadata`.

Authenticate with a token from **App Launch** (user context) or
**Backend Services** (system context). Access is narrowed by both scope and tenant.
The token must be issued for this FHIR base URL (its `aud`); a Backend Services token
minted without `aud` is rejected with `401` (see
[Backend Services](/guides/smart-backend-services)).

## Supported resources

| Resource | Operations | Search parameters |
|---|---|---|
| Patient | read, search | `_id`, `identifier`, `name`, `general-practitioner`, `birthdate`, `_lastUpdated`; `_include=Patient:general-practitioner` |
| Practitioner | read, search | `_id`, `identifier`, `name`, `active` |
| Encounter | read, search | `patient`, `date` (`ge`/`le` prefixes), `status`, `appointment` |
| DocumentReference | create, search | `encounter`, `patient` |
| Flag | search | `subject`, `status`, `category` |
| Goal | search | `subject`, `lifecycle-status` |
| Observation | search | `subject`, `category` (`survey`, `social-history`) |
| Condition | search | `subject` |
| QuestionnaireResponse | search | `subject` |
| Questionnaire | search | (definitional — not patient-scoped) |
| MedicationStatement | search | `subject` |

> **Note:** Patient names are synced as free-text entries without structured
> `family`/`given` parts (see [Patient content](#patient-content) below), so the
> `family` and `given` search parameters do not match. Search with `name`, which
> matches the free text, or by `identifier` or `_id`.

To find a clinician's patients, search `Patient?general-practitioner=Practitioner/{id}`.
To fetch patients together with their assigned clinicians in one response, add
`_include=Patient:general-practitioner`. For incremental sync, `_lastUpdated=gt{date}`
returns only records changed since that date. Searches return a `Bundle`; page with
`_count` and the `next` link.

Each resource type requires its matching scope (e.g. `system/Flag.rs`); see
[Scopes](/guides/scopes). Resource types not listed are not exposed — requests return
`403`, as do requests for a listed type whose scope your client was not granted.

Several of these are read-only projections of Innowell platform data: Flags come from
escalations, Goals from individual goals, Observations from assessment scores
(`category=survey`) and social history, Conditions and MedicationStatements from the
patient's personal details, and QuestionnaireResponses from completed assessments
(linked to their score Observations via `derivedFrom`).

QuestionnaireResponses carry the patient's answered questions in `item[]` — each entry
holds the question text and the answer as the patient would read it (option labels for
choice questions, typed values for numbers and free text), in questionnaire order.
Unanswered questions are skipped. Score Observations carry the instrument's overall
bounds in `referenceRange[]` (e.g. low 10, high 50 for the K10) alongside the
severity label in `interpretation`; scores without defined bounds omit it.

## Patient content

Patient names are free-text entries in `name[]`, each labelled with `use`:

- `official` — the patient's legal name
- `usual` — the name the patient goes by (their preferred name)

Read `usual` and fall back to `official` when addressing the patient. A missing
`usual` entry means Innowell holds no preferred name. Entries carry `text` only —
the structured `family` and `given` fields are not populated, because Innowell
stores each name as a single unstructured string.

`Patient.extension` carries the patient's Australian Indigenous status using the
HL7 Australia AU Base extension — read the extension array rather than expecting a
top-level field:

- `url`: `http://hl7.org.au/fhir/StructureDefinition/indigenous-status`
- `valueCoding.system`: `https://healthterminologies.gov.au/fhir/CodeSystem/australian-indigenous-status-1`

| Code | Display |
|---|---|
| `1` | Aboriginal but not Torres Strait Islander origin |
| `2` | Torres Strait Islander but not Aboriginal origin |
| `3` | Both Aboriginal and Torres Strait Islander origin |
| `4` | Neither Aboriginal nor Torres Strait Islander origin |

When Innowell holds no answer, the extension is omitted entirely — an absent
extension means "not recorded", never "neither".

Other Patient fields:

| Field | Contents |
|---|---|
| `identifier` | System `https://innowell.org/fhir/sid/role`, value = the patient's Innowell id |
| `telecom` | Email and phone, where recorded |
| `gender`, `birthDate` | Where recorded |
| `address` | `city` (suburb), `state` and `postalCode` only; no street address |
| `maritalStatus` | Coded, system `http://terminology.hl7.org/CodeSystem/v3-MaritalStatus` |
| `generalPractitioner` | The patient's assigned clinicians, as `Practitioner/{id}` references |
| `link` | The same person's other Patient records in the tenant, if any |
| `managingOrganization` | The tenant's Organization |

## Practitioner content

Practitioners are the tenant's clinicians. Each patient's assigned clinicians are listed
in that patient's `generalPractitioner`.

| Field | Contents |
|---|---|
| `identifier` | System `https://innowell.org/fhir/sid/role`, value = the clinician's Innowell id |
| `active` | `false` once the clinician no longer has access |
| `name` | The clinician's legal name, as free `text` (no `family`/`given` parts) |
| `telecom` | Email and phone, where recorded |
| `qualification` | Profession and credentials, as `code.text` |

## Batch reads

To fetch a patient's context in one round trip, `POST` a `batch` Bundle to the FHIR
base URL instead of issuing separate reads — see
[the batch endpoint](/api-fhir) for the request shape and per-entry error semantics.

## Example: write a clinical note

```bash
curl -X POST "$FHIR_BASE/DocumentReference" \
  -H "Authorization: Bearer $SYSTEM_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d @document-reference.json
```

Requires `system/DocumentReference.cru`. The note body goes in
`content[0].attachment.data`, base64-encoded — `text/markdown` preferred. The note is
attached to the referenced patient and encounter, both of which must belong to the
token's tenant.

## Conformance

For full SMART App Launch conformance testing, point your integration at
[Inferno](https://inferno.healthit.gov/). This documentation covers manual integration, not
certification.
