Skip to content

SunCharts EHR API

Data import

EHR API as of 26.11.11.41 8 operations openapi.json ↓

# List migration jobs

GET /api/v1/migrations

Owner only; latest 100 jobs. Every job returns cutover.allowed=false.

Access OAuth 2.0 access tokenmigration.manage

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl "$EHR_URL/api/v1/migrations" -H "Authorization: Bearer $ACCESS_TOKEN"

# Create migration job

POST /api/v1/migrations

Owner only; manifest declares bounded source counts and source snapshot. Maximum 100000 total records. Does not independently verify source freeze.

Access OAuth 2.0 access tokenmigration.manage

Request body application/json · required

Fields object · 5
Field Type Details
consistency required string one of read_only_export, transactional_export
expected_counts required object
source_instance required string length ≤ 200
source_revision required string length ≤ 200
limitations array of string
Example request body placeholder values
{
  "consistency": "read_only_export",
  "expected_counts": {},
  "source_instance": "string",
  "source_revision": "string",
  "limitations": [
    "string"
  ]
}

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl -X POST "$EHR_URL/api/v1/migrations" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Migration status

GET /api/v1/migrations/{id}

Owner only; counts, digest, limitations and reconciliation issues.

Access OAuth 2.0 access tokenmigration.manage

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl "$EHR_URL/api/v1/migrations/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# Commit migration

POST /api/v1/migrations/{id}/commit

Owner only. Reconciled digest required and every matching patient needs a stored attach or create decision. Atomic import: attached patients are linked to the chosen chart without changing it, new charts get identity and contact details from the source, and all other records become immutable historical records with external identity mapping. Source signatures stay unverified; no native signing or cutover.

Access OAuth 2.0 access tokenmigration.manage

Parameters

Name In Type Details
id required path string (uuid)

Request body application/json · required

Fields object · 1
Field Type Details
digest required string
Example request body placeholder values
{
  "digest": "string"
}

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl -X POST "$EHR_URL/api/v1/migrations/{id}/commit" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Stage migration items

POST /api/v1/migrations/{id}/items

Owner only; 1..50 records, 64KiB request limit. Exact retries safe; changed source record in one snapshot conflicts. Credentials rejected.

Access OAuth 2.0 access tokenmigration.manage

Parameters

Name In Type Details
id required path string (uuid)

Request body application/json · required

Fields object · 6
Field Type Details
items required array of MigrationItem items 1–50
data required object
kind required string
source_data required object
source_id required string
patient_source_id string or null
Example request body placeholder values
{
  "items": [
    {
      "data": {},
      "kind": "string",
      "source_data": {},
      "source_id": "string",
      "patient_source_id": "string"
    }
  ]
}

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl -X POST "$EHR_URL/api/v1/migrations/{id}/items" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Decide migration patient

POST /api/v1/migrations/{id}/patient-decisions

Owner only. For a staged patient that matches an existing chart (same normalized family name, first given name and birth date, or a weaker match), record attach with the chosen candidate chart, or create. Only listed candidates are accepted and one chart takes one imported patient. Not available after import. Audited.

Access OAuth 2.0 access tokenmigration.manage

Parameters

Name In Type Details
id required path string (uuid)

Request body application/json · required

Fields object · 3
Field Type Details
action required string one of attach, create
source_id required string
patient_id string (uuid) Required for attach; omitted for create.
Example request body placeholder values
{
  "action": "attach",
  "source_id": "string",
  "patient_id": "00000000-0000-4000-8000-000000000000"
}

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
404 Record not found in the authenticated clinic
409 Conflicting state

Example call

curl -X POST "$EHR_URL/api/v1/migrations/{id}/patient-decisions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Reconcile migration

POST /api/v1/migrations/{id}/reconcile

Checks declared counts, external identities, patient links and MRN conflicts; digest covers manifest and ordered items. The report lists every staged patient as new, linked by an earlier import, an exact single match to an existing chart (attach pre-selected) or a possible match needing an owner decision; ready_to_import is false while any decision is missing.

Access OAuth 2.0 access tokenmigration.manage

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Success application/json

Body: object

400 Invalid request
401 Authentication required
403 Scope or role denied
409 Conflicting state

Example call

curl -X POST "$EHR_URL/api/v1/migrations/{id}/reconcile" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json