Overview
When using the Medical API, Metriport will send Webhook messages to your app as soon as data becomes available. This is the usual flow to obtain Patient data:- You trigger a document query to retrieve a Patient’s medical documents from HIEs;
- XML C-CDA documents will be converted and stored on Metriport’s FHIR storage;
- as documents get downloaded and converted, you should get patient document data webhook messages;
- Once document conversion is completed, you can query for patient consolidated data;
- depending on the amount of data this can take some time to crunch together, so results are sent through a webhook message: patient consolidated data
Types of Messages
medical.document-download: result of Document Query, containing the newly downloaded documents for the patient - see details below;medical.document-conversion: result of converting the newly downloaded C-CDA documents into FHIR - see details below;medical.document-bulk-download-urls: list of download urls for a patient’s documents, see details below;medical.consolidated-data: result of a Consolidated Data Query, containing the patient’s data in FHIR format - see details below.medical.bulk-patient-create: updates for a Bulk Patient Create- see details below.
Workflow
Download URLs
Below is a flowchart of the process to download all the raw documents we’ve received from the networks for a patient:Consolidated Data
Below is a flowchart of the process to get a patient’s consolidated FHIR data:Passing Metadata
You can pass metadata to endpoints that support webhooks, and you will receive themeta.data field of the webhook request.
Metadata holds a record of up to 50 custom string key-value pairs. Key names can be up to 40 characters long and values up to 500 characters long. You may use this to attach whatever metadata is relevant for your use-case - for example, external IDs.
Below is an example payload you could send in the request body of one of those endpoints and how you would use the sdk:
Metriport SDK
Patient Document Data
These are messages you can expect to receive in the following scenarios:- When queried documents have completed
downloading, the message
typewill bemedical.document-download, and at this point you’ll be able to download the raw files; - Then when the conversion to FHIR has completed, the message
typewill bemedical.document-conversion, and at this point you’ll be able to query for patient consolidated data in FHIR-compliant format.
PatientDocQueryUpdate[]
required
Array of Document query status updates - where each item corresponds to a specific patient.
Patient Consolidated Data
A Patient’s consolidated data is the result of converting all C-CDA documents into deduplicated and standardized FHIR, as well as other FHIR data your application has inserted into Metriport’s FHIR repository. This data can be retrieved in either FHIR JSON format, or a rendered PDF or HTML Medical Record Summary. Patients can have a large amount of data, so in order to have access to a Patient’s data:- Trigger a consolidated data query - one query per patient at any given time;
- Your app can check the status by calling get consolidated query status (optional);
- When the result is ready, we’ll send a webhook message with the results (below).
Bundle you’ll find a DocumentReference resource with attachments in the content array:
- The first item contains an attachment with a
urlwhich can be used to download the data. - If requested
conversionTypeisjson, an additional attachment withcontentType: "application/gzip"provides a gzip-compressed copy for faster downloads.
If there was no data available for the Patient, the
Bundle will be empty (the entry array will have no
elements).PatientConsolidatedData[]
required
Array of consolidated data query results - where each item corresponds to a specific patient.
Bulk Patient Create
During the processing of a Bulk Patient Create, the Metriport API sends Webhook messages of typemedical.bulk-patient-create to indicate the status
update and provide relevant information.
You can expect to get two messages of this type for each Bulk Patient Create, with the status
being the main difference between each:
- First message:
processing: the CSV file has been uploaded and is being processed;
- Second message - one of:
completed: the bulk create is completed - includes the result CSV file;failed: the bulk create failed (likely due to the uploaded file being invalid).
The URL will only be valid for 600 seconds (10 minutes).
BulkPatientCreate
required
The information about the Bulk Patient Create request.
Result CSV File
The messagemedical.bulk-patient-create with status completed includes a URL in the result
field, which you can use to download the result of the Bulk Patient Create.
The URL will only be valid for 600 seconds (10 minutes).
string
The ID of the Patient on Metriport - only provided if the
Patient was created successfully.
string
required
Whether the respective demographics was accepted and used
to create a Patient. Can be one of
succeeded or
failed.string
If the patient failed to be created, this indictes the
reason for failure. Only included if the patient fails to
be created.
Bulk Document Download URLs
If you want to download all of a patient’s documents, you can start a Bulk Get Document URL query.The URLs will only be valid for 600 seconds (10 minutes).
DocumentBulkDownloadUrls[]
required
An array of Document bulk download URLs, where each item corresponds to the queried patient.

