Skip to content

← All contracts

OHN-52 Paper Health Record Digitisation

Version
1.0.0
OpenAPI
3.1.0
Source in the repository
modules/OHN-52/api/openapi.yaml
Servers
https://opeshealthnetwork.com
Authentication
bearer: http bearer (JWT)

Download the contract (YAML)

Contracts are written in English.

Digitise patient-held paper health booklets. Every mutation needs `Idempotency-Key` (any non-empty value up to 255 characters); every request a Bearer token (role, jurisdiction, organization_id, purpose; subject, jurisdiction and organization are UUIDs, otherwise 401). Default deny: an unknown route is 404 after authentication, a role that is not listed for the route is 403 `denied_by_policy` (audited), and a purpose that is not the role's own is 403. Digitised items are never verified. Page images are kept as originals in OHN-13 (required: no original, no upload); recognition proposes items only when an extraction engine is configured, and every proposal needs a person's decision. Without an engine every page fails closed (`failure_reason: not_configured`) and the reviewer transcribes by hand (`POST /jobs/{id}/items`). 503 `not_configured` (with `dependency` and `setting`) means a required dependency or key is not configured and nothing was stored.

Operations

jobs

GET/api/ohn/v1/digitisation/jobsList jobs in scope

Authentication: bearer

Parameters

NameInTypeRequiredDescription
statequerystringnoAny state name up to 32 characters; an unknown name lists nothing.
patient_idquerystring (uuid)no

Responses

CodeDescriptionMedia type
200OK
POST/api/ohn/v1/digitisation/jobsUpload booklet pages with consent (F001, W001)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
Idempotency-Keyheaderstringyes

Request body (required)

Responses

CodeDescriptionMedia type
201Job created
application/json: Job
400Missing idempotency key or malformed body—
403patient_self_only, consent_denied (OHN-15), or role not permitted—
409Idempotency key reused with another payload—
413Body larger than OHN52_MAX_UPLOAD_BODY—
422domain_validation_failed, consent_method_invalid, type_mismatch, page_too_large, unsupported_type, image_too_many_pixels, pdf_active_content, image_corrupt—
429Rate limited—
503OHN-13 or OHN-15 unavailable or unconfigured; nothing stored—
GET/api/ohn/v1/digitisation/jobs/{id}Job detail (patients see items only after completion, never OCR text)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes

Responses

CodeDescriptionMedia type
200OK
application/json: Job
404Not in scope—
GET/api/ohn/v1/digitisation/jobs/{id}/pages/{pageId}/imagePage image (metadata stripped); viewing is audited

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
pageIdpathstring (uuid)yes

Responses

CodeDescriptionMedia type
200Image
image/png
image/jpeg
application/pdf
404Not in scope—

review

POST/api/ohn/v1/digitisation/jobs/{id}/itemsAdd an item the engine missed (F003)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body (required)

Responses

CodeDescriptionMedia type
201Added—
409Job not reviewable—
422domain_validation_failed; details maps each top-level field to the first failing check as a zod issue code (invalid_type, too_small, too_big, invalid_string, invalid_enum_value, invalid_literal, invalid_union, custom), unknown keys under _ as unrecognized_keys; the reference returned zod flatten() (formErrors, fieldErrors) instead—
POST/api/ohn/v1/digitisation/jobs/{id}/items/{itemId}/decisionAccept, edit or reject an item (F002, W003)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
itemIdpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body (required)

Responses

CodeDescriptionMedia type
200Decided—
409Stale version or job not reviewable—
422domain_validation_failed; details maps each top-level field to the first failing check as a zod issue code (invalid_type, too_small, too_big, invalid_string, invalid_enum_value, invalid_literal, invalid_union, custom), unknown keys under _ as unrecognized_keys; the reference returned zod flatten() (formErrors, fieldErrors) instead—
POST/api/ohn/v1/digitisation/jobs/{id}/sign-offSign off and write accepted items as unverified (F004, W004)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body (required)

Responses

CodeDescriptionMedia type
200Completed; `writes` counts per write_status (written, held_no_code, refused, pending_retry, kept_in_ohn52)—
403clinician_signoff_required—
409Stale version or job not reviewable—
422items_undecided—
POST/api/ohn/v1/digitisation/jobs/{id}/rejectReject the job (F005)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body (required)

Responses

CodeDescriptionMedia type
200Rejected—
409Invalid transition or stale—
POST/api/ohn/v1/digitisation/jobs/{id}/retry-writesRetry pending OHN-10 writes

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body

  • application/json: object

Responses

CodeDescriptionMedia type
200Retried—

record

GET/api/ohn/v1/digitisation/patients/{patientId}/digitised-itemsAccepted items of signed-off jobs, each with paper provenance

Authentication: bearer

Parameters

NameInTypeRequiredDescription
patientIdpathstring (uuid)yes

Responses

reports

GET/api/ohn/v1/digitisation/reportsReport catalogue

Authentication: bearer

Responses

CodeDescriptionMedia type
200OK—
GET/api/ohn/v1/digitisation/reports/{reportId}Run a report

Authentication: bearer

Parameters

NameInTypeRequiredDescription
reportIdpath"OHN-52-R001" | "OHN-52-R002" | "OHN-52-R003"yes
daysqueryintegerno

Responses

CodeDescriptionMedia type
200OK—
GET/api/ohn/v1/digitisation/reports/{reportId}/exportSigned CSV export

Authentication: bearer

Parameters

NameInTypeRequiredDescription
reportIdpath"OHN-52-R001" | "OHN-52-R002" | "OHN-52-R003"yes
daysqueryintegerno

Responses

CodeDescriptionMedia type
200CSV
text/csv
503OHN52_EXPORT_SIGNING_KEY not configured—

ops

GET/health/ohn-52Health, recognition engine and dependency modes

Responses

CodeDescriptionMedia type
200OK
application/json: Health
503Database unavailable—
GET/api/ohn/v1/digitisation/contextCaller context and engine status

Authentication: bearer

Responses

CodeDescriptionMedia type
200OK—
POST/api/ohn/v1/digitisation/jobs/{id}/reprocessRecognise again before any decision (admin)

Authentication: bearer

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes
Idempotency-Keyheaderstringyes

Request body

  • application/json: object

Responses

CodeDescriptionMedia type
200Queued—
409Review started—
GET/api/ohn/v1/digitisation/auditLatest audit receipts (digitisation_admin)

Authentication: bearer

Responses

CodeDescriptionMedia type
200OK—
POST/api/ohn/v1/digitisation/admin/outbox/relayRelay pending events to OHN-24

Authentication: bearer

Parameters

NameInTypeRequiredDescription
Idempotency-Keyheaderstringyes

Responses

CodeDescriptionMedia type
200Relay result—

Schemas

JobState

"uploaded" | "processing" | "ready_for_review" | "partially_reviewed" | "completed" | "rejected"

ItemType

"date" | "vaccination" | "diagnosis" | "medication" | "allergy" | "blood_group" | "genotype" | "vital_sign" | "visit"

CreateJob

NameTypeRequiredDescription
patient_idstring (uuid)noRequired for clinic capture; must be absent or own id for patients
review_org_idstring (uuid)noRequired for patient uploads: the care site (OHN-05 facility id) whose queue reviews the pages; ignored for staff, whose job belongs to their own organization
titlestringno
consentConsentyes
pagesarray of CreateJob.pages.itemyes

Bbox

Fractions (0..1) of page width/height

NameTypeRequiredDescription
xnumberno
ynumberno
wnumberno
hnumberno

Item

NameTypeRequiredDescription
idstring (uuid)no
page_idstring (uuid)no
item_typeItemTypeno
origin"engine" | "reviewer_added"no
source_textstringno
proposedobjectno
finalobject | nullno
confidencenumberno
low_confidencebooleanno
bboxBboxnoFractions (0..1) of page width/height
state"proposed" | "accepted" | "edited" | "rejected"no
versionintegerno
verification_status"unverified_patient_held"no
lab_verifiedfalseno
target"ohn10_problem" | "ohn10_medication" | "ohn10_allergy" | "ohn52_record"no
target_gapstring | nullno
write_status"not_applicable" | "written" | "held_no_code" | "refused" | "pending_retry" | "kept_in_ohn52"no
provenanceProvenanceno

Provenance

NameTypeRequiredDescription
source"digitised_from_paper"no
label_enstringno
label_frstringno
verification_status"unverified_patient_held"no
reviewer_idstring (uuid)no
reviewed_atstring (date-time)no
page_image_refProvenance.page_image_refno
lab_verifiedfalseno
transfusion_verifiedfalsenoblood_group only
caveat_enstringnoblood_group: Reported in paper booklet, not verified for transfusion.

RecordItem

NameTypeRequiredDescription
idstringno
item_typeItemTypeno
valueobjectno
write_statusstringno
lab_verifiedfalseno
provenanceProvenanceno

JobSummary

NameTypeRequiredDescription
idstringno
stateJobStateno
source"patient_upload" | "clinic_capture"no
page_countintegerno
item_countintegerno
open_itemsintegerno
low_confidence_openintegerno
enginesarray of stringno
images_left_platformbooleanno
versionintegerno

Job

NameTypeRequiredDescription
idstringno
stateJobStateno
source"patient_upload" | "clinic_capture"no
page_countintegerno
item_countintegerno
open_itemsintegerno
low_confidence_openintegerno
enginesarray of stringno
images_left_platformbooleanno
versionintegerno
allowed_actionsarray of "decide_item" | "add_item" | "sign_off" | "reject" | "reprocess" | "retry_writes"no
engine_requested"tesseract-local" | "anthropic-vision"no
ai_authorisation_refstring | nullno
pagesarray of objectno
itemsarray of Itemno
historyarray of objectno
engine_runsarray of Job.engine_runs.itemno
receiptobjectno

AddItem

NameTypeRequiredDescription
page_idstring (uuid)yes
item_typeItemTypeyes
source_textstringyes
valueobjectyesValues are strings of at most 500 characters, numbers, booleans or null; any key containing "verif" is dropped

Decision

NameTypeRequiredDescription
expected_versionintegeryes
decision"accept" | "edit" | "reject"yes
valueobjectnoRequired for edit
reasonstringnoRequired for reject (at least 3 characters)

SignOff

NameTypeRequiredDescription
expected_versionintegeryes
attestationtrueyes
notestringno

Health

NameTypeRequiredDescription
statusstringno
module"OHN-52"no
engineHealth.engineno
dependenciesobjectno
writes_enabledbooleannoFalse when the operator kill switch is on (every write 503 not_configured)
export_signing_configuredbooleanno
auth_configuredbooleanno
synthetic_authbooleannoAlways false in the Java service

get-api-ohn-v1-digitisation-jobs.response-200 defined inline

NameTypeRequiredDescription
itemsarray of JobSummaryno

post-api-ohn-v1-digitisation-jobs.request.form-data defined inline

NameTypeRequiredDescription
patient_idstring (uuid)no
review_org_idstring (uuid)noPatient uploads only: the care site that reviews the pages (the Java service reads it; the TypeScript reference ignored this multipart field)
titlestringno
consentstringyesJSON-encoded Consent
pagesarray of string (binary)yes

post-api-ohn-v1-digitisation-jobs-id-reject.request defined inline

NameTypeRequiredDescription
expected_versionintegeryes
reasonstringyes

get-api-ohn-v1-digitisation-patients-patientid-digitised-items.response-200 defined inline

NameTypeRequiredDescription
verification_status"unverified_patient_held"no
itemsarray of RecordItemno

CreateJob.pages.item defined inline

NameTypeRequiredDescription
media_type"image/jpeg" | "image/png" | "application/pdf"yes
content_base64stringyes

Provenance.page_image_ref defined inline

NameTypeRequiredDescription
job_idstringno
page_idstringno
ohn13_document_idstringno

Job.engine_runs.item defined inline

NameTypeRequiredDescription
enginestringno
modelstringno
left_platformbooleanno
authorisation_refstring | nullno
outcomestringno
duration_msintegerno

Health.engine defined inline

NameTypeRequiredDescription
default"tesseract-local"no
local_ocr_data"present" | "missing"no
ai"disabled" | "enabled" | "refused_incomplete_configuration"no
ai_modelstring | nullno
worker"running" | "stopped"no
adapter"none" | "wired"noJava only: none while no OCR adapter is wired (B820); local_ocr_data is then missing
worker_statsobjectno