Signals API - Observations

Submit several readings for one patient

  • Sandbox: available
  • Staging: available
  • Production: unknown
POST
/v1/signals/api/observation/{patientId}/batch

{observations: [<FHIR Observation>]}, each as POST /api/observation/:patientId takes it. In one transaction, evaluated in the order given. Answers v1's array, one entry per reading in request order: the reading as stored, or for a resend the 409 DUPLICATE_READING error body in its place. An array has nowhere to carry the ingest outcome, so a caller that needs alertIds posts them singly.

The body is a FHIR R4 Observation: code, value[x] (any of FHIR R4's eleven) or dataAbsentReason, and a combined device sample's vitals as component[] (each code, value[x], optional dataAbsentReason). The clinical time is effectiveDateTime, effectiveInstant or effectivePeriod.start, else issued, else the server's receipt; device is {reference, display}; the first identifier's value is stored as v1's refId. Other FHIR elements (meta, extension, performer, interpretation, referenceRange, …) are accepted and ignored. v1's observedAt (it wins over effective[x]), refId, string dataAbsentReason and device.id still work. A node with dataAbsentReason and no value is judged as carrying no value, and the rules read the reason as absent. valueSampledData is judged by its latest sample and stored whole, and the rules read every sample as samples. A valueDateTime, on the reading or a component, is judged and aggregated as epoch ms (valueNumber) and listed as sent. A valueBoolean is judged as 1 or 0. A valueTime is judged as ms since midnight, a valuePeriod as its length in ms (none while open or without an offset), a valueRatio as its quotient, and each is also kept as text (valueString); a valueRange is judged as the text low..high.

History is never judged. A reading whose category has a coding the tenant names as history (its historyCategories; the default pack's: batch-data, statistics, presence-batch, derived) is stored and deduplicated like any other, answered with no alerts, and never judged nor read by the rules.

The caller must be one of the patient's submitters, admins included: a known patient it is not attached to is a 403, an unknown one a 404 with type PATIENT_NOT_FOUND.

Idempotent. A reading is named by its first identifier (system|value), else by its clinical time, code, device and refId. A resend of one stored within the last hour is a 409 DUPLICATE_READING whose data.observationId is the stored reading, and is neither stored nor evaluated again. A reading with neither an identifier nor a clinical time is not deduplicated.

Concurrent requests are batched server-side. With Prefer: respond-sync evaluation finishes first and the reply adds alertIds, alerts ([{id, code}]), resolvedAlertIds and ruleCoverage; without it mode is async and alerts are delivered by webhook.

Through ovok

  • Who can call it: Submitter apps, and users whose access policy grants the capabilities.
  • Capabilities, all required: signals_observations:create. Project admins have every capability; client applications get no admin bypass.
  • If your access covers only some patients (anyone but project admins, manager or submitter apps, and anyone whose Patient access has no criteria), the patient must be one you can update. A patient is named by its Signals id, or by its Medplum Patient id where Signals takes a refId; ovok asks Signals which patient a Signals id is.
  • Each reading counts its patient as monitored for billing.

Authorization

headerAuthorizationBearer <JWT>

Path Parameters

patientId*string

The Signals patient id.

Header Parameters

Prefer?string

respond-sync evaluates the readings before answering: the response reports the alerts they raised and closed, and no webhook is sent for them. Without it the readings are stored and evaluated the same way before the response, which carries no alerts: they are delivered by webhook.

Request Body

application/json
  1. body
observations*array<>
Items1 <= items

Response Body

Per reading, in request order: the reading as stored, or a resend's 409 body.

application/json
  1. response
[index: integer]?|
Example Request
curl -X POST 'https://api.sandbox.ovok.com/v1/signals/api/observation/string/batch' \  -H 'Content-Type: application/json' \  -d '{  "observations": [    {      "code": {}    }  ]}'
Example Response
[  {    "_id": "string",    "id": "string",    "patient": "string",    "code": {},    "valueQuantity": {},    "observedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }]

Submit a reading for a patient id POST

`subject` is ignored: the path names the patient. The body is a FHIR R4 Observation: `code`, `value[x]` (any of FHIR R4's eleven) or `dataAbsentReason`, and a combined device sample's vitals as `component[]` (each `code`, `value[x]`, optional `dataAbsentReason`). The clinical time is `effectiveDateTime`, `effectiveInstant` or `effectivePeriod.start`, else `issued`, else the server's receipt; `device` is `{reference, display}`; the first `identifier`'s `value` is stored as v1's `refId`. Other FHIR elements (`meta`, `extension`, `performer`, `interpretation`, `referenceRange`, …) are accepted and ignored. v1's `observedAt` (it wins over `effective[x]`), `refId`, string `dataAbsentReason` and `device.id` still work. A node with `dataAbsentReason` and no value is judged as carrying no value, and the rules read the reason as `absent`. `valueSampledData` is judged by its latest sample and stored whole, and the rules read every sample as `samples`. A `valueDateTime`, on the reading or a component, is judged and aggregated as epoch ms (`valueNumber`) and listed as sent. A `valueBoolean` is judged as 1 or 0. A `valueTime` is judged as ms since midnight, a `valuePeriod` as its length in ms (none while open or without an offset), a `valueRatio` as its quotient, and each is also kept as text (`valueString`); a `valueRange` is judged as the text `low..high`. **History is never judged.** A reading whose `category` has a coding the tenant names as history (its `historyCategories`; the default pack's: `batch-data`, `statistics`, `presence-batch`, `derived`) is stored and deduplicated like any other, answered with no alerts, and never judged nor read by the rules. The caller must be one of the patient's submitters, admins included: a known patient it is not attached to is a 403, an unknown one a 404 with type `PATIENT_NOT_FOUND`. **Idempotent.** A reading is named by its first `identifier` (`system|value`), else by its clinical time, code, device and `refId`. A resend of one stored within the last hour is a 409 `DUPLICATE_READING` whose `data.observationId` is the stored reading, and is neither stored nor evaluated again. A reading with neither an identifier nor a clinical time is not deduplicated. Concurrent requests are batched server-side. With `Prefer: respond-sync` evaluation finishes first and the reply adds `alertIds`, `alerts` (`[{id, code}]`), `resolvedAlertIds` and `ruleCoverage`; without it `mode` is `async` and alerts are delivered by webhook. ### Through ovok - **Who can call it:** Submitter apps, and users whose access policy grants the capabilities. - **Capabilities, all required:** `signals_observations:create`. Project admins have every capability; client applications get no admin bypass. - If your access covers only some patients (anyone but project admins, manager or submitter apps, and anyone whose Patient access has no criteria), the patient must be one you can update. A patient is named by its Signals id, or by its Medplum Patient id where Signals takes a `refId`; ovok asks Signals which patient a Signals id is. - Each reading counts its patient as monitored for billing.

Write one config to many patients POST

Applies the same triggers, flags and metadata to every id named. An id may be the Signals id or the `refId`. Unknown ids are reported in `misses[]` rather than failing the batch. `modifiedCount` counts patients where a row actually changed; `status.triggerWrites` gives the row counts behind it. Trigger `metadata` is MERGED and left untouched when absent. Send `resolvedAt` (the instant the configuration was COMPUTED, not sent) to have this push refused rather than applied when the patient already carries a configuration resolved strictly later. Refusal is a silent no-op reported as `staleIgnoredCount`, never an error. Omitting it applies the push unconditionally. ### Through ovok - **Who can call it:** Manager apps, and users whose access policy grants the capabilities. - **Capabilities, all required:** `signals_config:update`, `signals_silence:update`. Project admins have every capability; client applications get no admin bypass. - A patient stamped with another project is refused. - If your access covers only some patients (anyone but project admins, manager or submitter apps, and anyone whose Patient access has no criteria), every patient the body names must be one you can update. A patient is named by its Signals id, or by its Medplum Patient id where Signals takes a `refId`; ovok asks Signals which patient a Signals id is.