Ontario Health
Ontario Clinical Report Exchange Implementation Guide v1.0.0 - Trial Use
fhir-logo
  • Index
  • Home
    • Home
    • Introduction
    • Relationship to Other Specifications
    • Scope
    • Glossary
  • Business Context
    • Business Context
    • Business Model
    • Business Data
    • Use Cases
    • Business Rules
  • Technical Context
    • Technical Context
    • Implementer Responsibility
    • Conformance Rules
    • Connectivity Summary
  • FHIR Artifacts
    • FHIR Artifacts
    • Interactions
    • Profiles
    • Extensions
    • Terminology
    • System URIs
    • Examples
    • Capability Statement
    • Response Handling
    • Downloads
  • Change Log
    • Change Log
    • Known Issues & Future Developments
    • Revision History
    1. Index
    2. FHIR Artifacts
    3. Interactions
    4. Upload Attachment

For a full list of available versions, see the Directory of published versions

4.1.3. Upload Attachment

4.1.3.1. Scope

This interaction involves a request by a Data Contribution system to upload an attachment to the OH OCRE File Repository. A Data Contribution system then maps the File Upload response to populate downloadURL and fileId data elements in the AttachmentMetadata extension on Binary.data (for clinical reports) / DiagnosticReport.presentedForm.data (for MI reports) instead of embedding an actual base64Binary in Binary.data / DiagnosticReport.presentedForm.data.

The maximum attachment size supported by Ontario Health is 500 Mb, but this might change in the future. Data contributors are encouraged to try reducing size of their attachments (e.g., by using improved pdf conversion and file compression) to minimize impact on storage and performance of OCRE, OH Pub/Sub Services and point of service systems receiving the reports.

For the users sending reports, there will be no change in their workflow (e.g. no extra clicks for the user to upload reports). All the interactions to enable upload functionality will be done by their respective systems and APIs.

4.1.3.2. Data Flow




4.1.3.3. Uploading File

System uploading a file to the repository must first authenticate and request an upload URL from the document service.

4.1.3.4. GET UPLOAD URL

Request:

POST {serverurl}
  Authorization: Bearer <OAGToken>
  Body:
  {
    "fileName": "<FileName>"
  }

Note: Both FileName and OAGToken are mandatory.

Response:

{
  "url": "<UploadFileURL>",
  "expiresInSec": 300
}

Potential Error Codes returned from this request:

Description Code HTTP Code
Mandatory field missing R_MANDATORY_FIELD_MISSING 400
User doesn't have proper permission to invoke this API R_USER_INSUFFICIENT_PERMISSIONS 403
Internal error R_INTERNAL_ERROR 500

4.1.3.5. UPLOAD FILE

In order to upload a file to the repository, the system must have an upload URL. The uploading system uploads the file to the repository by posting the file to the URL provided in the response to the GET UPLOAD URL operation. The downloadURL (to retrieve the file from the repository) is returned from this service request. The Uploading system should use downloadURL and fileId from the response to create the AttachmentMetadata extension on Binary.data (for clinical reports) / DiagnosticReport.presentedForm.data (for MI reports) .

Request:

POST <UploadFileURL>
  Content-Type: multipart/form-data
  Body parameter:
    file: <FileName>

Response:

{
  "id": <FileId>,
  "fileName": "<FileName>",
  "contentType": "<MimeType>", //"application/pdf", "image/jpeg", "image/png", "image/gif", "text/html"
  "status": "<Status>", //Active; Scanning; Virus_Found; Not_scanned; Deleted
  "createdBy": "<CreatedBy>",
  "repositoryName": "ocre",
  "fileSize": 9803426,
  “downloadURL”:<DownloadURL>
}

NOTE: downloadURL returned directly from the Upload request will NOT contain a token for access. The token will be subsequently generated by OCRE and the URL received by the receiving systems will include the full URL including a token.

The submitting system will map data elements from the response to the AttachmentMetadata extension on Binary.data (for clinical reports) / DiagnosticReport.presentedForm.data (for MI reports) instead of embedding an actual base64Binary in Binary.data / DiagnosticReport.presentedForm.data. Here is an example of a Binary resource with the AttachmentMetadata extension

Potential Error Codes returned from this request:

Description Code HTTP Code
Non-supported file types R_FILE_TYPE_NOT_SUPPORTED 400
File size exceeds 500MB R_FILE_SIZE_TOO_LARGE 400
Virus detected R_VIRUS_DETECTED 400
File upload URL expired or is invalid. The expiration period is 300 seconds R_EXPIRED_FILE_URL 400
File content is missing or file size is 0 R_EMPTY_FILE 400
The uploaded file name does not match the record R_INVALID_FILE_NAME 400
Internal error R_INTERNAL_ERROR 500

The MimeType ValueSet lists all the supported file types

4.1.3.6. GET FILE STATUS

Get File Status allows the requestor to check the status of the uploaded file. Virus scan operations can take time, and the uploading system SHOULD ensure the file is in “Active” state before sending the request to OCRE. Uploading system can poll the document service to check current status by calling the Get File Status operation:

Request

GET {serverurl}/<FileId>/status

Response:

{
  "id": <FileId>,
  "fileName": "<FileName>",
  "contentType": "image/jpeg",
  "status": "<Status>",
  "createdBy": "<CreatedBy>",   
  "repositoryName": "ocre",  
  "fileSize": 9803426,  
  "createdOnUTC": "2025-11-22T15:24:05Z" 
}

Potential Error Codes returned from this request:

Description Code HTTP Code
File ID is missing R_MISSING_FILE_ID 400
Invalid URL R_MANDATORY_FIELD_MISSING 400
User doesn't have proper permission to invoke this API R_USER_INSUFFICIENT_PERMISSIONS 403
File Not Found R_NOT_FOUND 404
Internal error R_INTERNAL_ERROR 500
Version: 1.0.0 FHIR Version: R4.0.1

Powered by SIMPLIFIER.NET

HL7® and FHIR® are the registered trademarks of Health Level Seven International