Skip to content

Commit

Permalink
build: add wh types to start doc download and consolidated data
Browse files Browse the repository at this point in the history
Ref. metriport/metriport-internal#1040

Signed-off-by: Rafael Leite <[email protected]>
  • Loading branch information
leite08 committed Jun 18, 2024
1 parent def4f9c commit 1035117
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
14 changes: 3 additions & 11 deletions docs/home/api-info/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ General requirements for the endpoint:
1. Does not do an HTTP redirect (redirects will not be followed);
1. Accepts a `POST` HTTP request;
1. Verifies requests using the HTTP header `x-metriport-signature` - see [authentication](#authentication) below;
1. Responds `200` in under 4 seconds - we recommend processing the webhook request asynchronously;
1. Accepts and responds to a [`ping` message](#the-ping-message);
1. Be [idempotent](https://en.wikipedia.org/wiki/Idempotence) - it should accept being called more
than once with the same payload, with no changes to the end result.
Expand All @@ -39,9 +40,8 @@ Additionally, your endpoint will need to accept and process different messages w

## Authentication

When Metriport sends a webhook message, it includes an `x-metriport-signature` header.

- `x-metriport-signature`: This is an [HMAC](https://en.wikipedia.org/wiki/HMAC) SHA-256 hash computed using your webhook key and the body of the webhook message.
When Metriport sends a webhook message, it includes an `x-metriport-signature` header - this is an
[HMAC](https://en.wikipedia.org/wiki/HMAC) SHA-256 hash computed using your webhook key and the body of the webhook message.

At a high level, an HMAC works by taking a secret key (webhook key from the Settings page) and a message,
and performing iterative hashes of the two to create a signature. That signature is compared against the
Expand Down Expand Up @@ -89,16 +89,8 @@ if is_signature_valid:
print("Signature verified")
else:
print("Signature verification failed")


```

<Warning>
The previous method of authenticating webhooks, comparing your webhook key with the
`x-webhook-key` in each request's HTTP header, is being deprecated on **December 9th, 2023**.
Please update your implementation to use the `x-metriport-signature` header for authentication.
</Warning>

### Generating a new webhook key

If using the dashboard: simply delete your webhook URL on the [Developers page](https://dash.metriport.com/developers),
Expand Down
13 changes: 8 additions & 5 deletions docs/medical-api/api-reference/document/start-document-query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ incremented. Once all documents have been converted it too will be marked as `co

If there's no document to be converted, the total will be set to zero and the status to `completed`.

<Tip>
To get updates about the document query progress, including download and conversion status, check
out our [webhooks guide](/medical-api/more-info/webhooks). Note that the webhooks will only
contain updates for new data fetched in the current document query.
</Tip>
Once each process completes, a webhook request will be sent to [your configured URL](/home/api-reference/settings/post-settings)
containing the available data. **Note:** the webhooks will only contain updates for new data fetched in the current document query.

Webhook message types - see [the respective section on the webhooks page](/medical-api/more-info/webhooks#patient-document-data)
for more details:

- `medical.document-download`: contains the newly downloaded documents for the patient;
- `medical.document-conversion`: result of converting the newly downloaded C-CDA documents into FHIR.

<Warning>
If you were to trigger this endpoint again while the query is still processing, you will get a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ api: "POST /medical/v1/patient/{id}/consolidated/query"
When executed, this endpoint triggers an asynchronous query to retrieve a Patient's consolidated
data from the FHIR repository.

Once the data is consolidated and ready for consumption, a [Webhook request](/medical-api/more-info/webhooks#patient-consolidated-data)
is sent to [your configured URL](/home/api-reference/settings/post-settings) containing the Patient's
Once the data is consolidated and ready for consumption, webhook requests will be sent to
[your configured URL](/home/api-reference/settings/post-settings) containing the Patient's
data in FHIR-compliant format, based on the [parameters](#query-params) used to trigger the query.

Webhook message types - see [the respective section on the webhooks page](/medical-api/more-info/webhooks#patient-consolidated-data)
for more details:

- `medical.consolidated-data`: contains the patient's data in FHIR format.

You'll be able to query multiple times for the same Patient which will be added to the queue and
processed in order. If the parameters are the same as a previous query that is still processing,
the new query will be ignored and you'll get the status and request ID of the previous one.
Expand Down
4 changes: 2 additions & 2 deletions docs/medical-api/more-info/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ These are messages you can expect to receive in the following scenarios:
you'll be able to [download the raw files](/medical-api/api-reference/document/get-document);
2. Then, if the downloaded documents contained C-CDA/XML files, when the conversion to FHIR has
completed, the message `type` will be `medical.document-conversion`, and at this point
you'll be able to query for [patient consolidated data](#patient-consolidated-data) in
FHIR-compliant format.
you'll be able to query for [patient consolidated data](/medical-api/api-reference/fhir/consolidated-data-query-post)
in FHIR-compliant format.

<Tip>
Note that the webhooks will only contain updates for new data fetched in the current document
Expand Down

0 comments on commit 1035117

Please sign in to comment.