Skip to content

Send a CDA report (FHIR DocumentReference)

post /api/fhir/DocumentReference

A DocumentReference whose content.attachment.data is a Base64 CDA document. The document's inFulfillmentOf order ID is matched to an order by accession number; the report is attached to it.

Scope: fhir:write (hl7 tokens).

Rate limit: Per-token HL7 limit.

Audited as order.receive in the practice's audit log.

Request body

A FHIR R4 DocumentReference, up to 2 MiB

application/fhir+json

{
  "resourceType": "DocumentReference",
  "status": "current",
  "content": [
    {
      "attachment": {
        "contentType": "application/xml",
        "data": "PD94bWwgdmVyc2lvbj0iMS4wIj8+…"
      }
    }
  ]
}

Responses

201

Report attached to the order

application/fhir+json

Field Type Description
resourceType "DocumentReference"
id string
status "current"
{
  "resourceType": "DocumentReference",
  "id": "01JA2Z6Q7Y9K3M5N8P0R2S4T6V",
  "status": "current"
}

400

Not JSON, not a DocumentReference or not Base64 (structure). Problem: validation

application/fhir+json

Field Type Description
resourceType "OperationOutcome"
issue array of object

401

Problem: unauthenticated

403

Problem: forbidden, tenant-suspended, trial-expired

413

Problem: too-large

415

Not application/fhir+json (not-supported)

application/fhir+json

Field Type Description
resourceType "OperationOutcome"
issue array of object

422

No CDA attachment, or no order with this accession number (value, not-found)

application/fhir+json

Field Type Description
resourceType "OperationOutcome"
issue array of object

429

Problem: rate-limited

500

Problem: internal

503

Problem: tenant-migrating

Errors

Status Type Meaning
401 unauthenticated Not authenticated
403 forbidden Not allowed
500 internal Internal error
429 rate-limited Rate limited
503 tenant-migrating Practice is being moved
403 tenant-suspended Practice is read-only
403 trial-expired Trial has ended
413 too-large Message too large
400 validation Invalid request

Examples

curl

curl -X POST 'https://app.pacspilot.com/api/fhir/DocumentReference' \
  -H "Authorization: Bearer $PACSPILOT_TOKEN" \
  -H 'Content-Type: application/fhir+json' \
  --data-binary '{
  "resourceType": "DocumentReference",
  "status": "current",
  "content": [
    {
      "attachment": {
        "contentType": "application/xml",
        "data": "PD94bWwgdmVyc2lvbj0iMS4wIj8+…"
      }
    }
  ]
}'

JavaScript

const res = await fetch("https://app.pacspilot.com/api/fhir/DocumentReference", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PACSPILOT_TOKEN}`,
    "Content-Type": "application/fhir+json",
  },
  body: JSON.stringify({
    "resourceType": "DocumentReference",
    "status": "current",
    "content": [
      {
        "attachment": {
          "contentType": "application/xml",
          "data": "PD94bWwgdmVyc2lvbj0iMS4wIj8+…"
        }
      }
    ]
  }),
});
console.log(res.status, await res.text());

Python

import os
import requests

data = "{\n  \"resourceType\": \"DocumentReference\",\n  \"status\": \"current\",\n  \"content\": [\n    {\n      \"attachment\": {\n        \"contentType\": \"application/xml\",\n        \"data\": \"PD94bWwgdmVyc2lvbj0iMS4wIj8+…\"\n      }\n    }\n  ]\n}"

res = requests.request(
    "POST",
    "https://app.pacspilot.com/api/fhir/DocumentReference",
    headers={"Authorization": f"Bearer {os.environ['PACSPILOT_TOKEN']}", "Content-Type": "application/fhir+json"},
    data=data.encode("utf-8"),
)
print(res.status_code, res.text)