POST
/
medical
/
v1
/
patient
/
{id}
/
consolidated
/
query
curl --request POST \
  --url https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated/query \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "metadata": {}
}'
import { MetriportMedicalApi } from "@metriport/api-sdk";

const metadata = {
    youCan: "putAny",
    stringKeyValue: "pairsHere",
};

const metriport = new MetriportMedicalApi(apiToken);

const consolidatedData = await metriport.startConsolidatedQuery(
  patientId,
  ["AllergyIntolerance", "Appointment"] as const,
  "2023-03-01",
  "2023-04-01",
  undefined,
  metadata
);

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 is sent to your configured URL containing the Patient’s data in FHIR-compliant format, based on the parameters used to trigger the query.

You can check the status of the data query by calling get consolidated data query.

This endpoint also provides the ability to render a Medical Record Summary from the FHIR bundle as a PDF or HTML document. This will be returned via a webhook as a FHIR bundle with a DocumentReference resource that will contain a URL to retrieve the data from.

Path Params

id
string
required

The ID of the Patient.

Query Params

You can optionally filter resources by date, using the dateFrom and dateTo query params. Note that not all resources will support this filter - see the FHIR R4 docs for a list of supported resources.

Some general resources, like Practitioner do not belong to a specific patient - when you query for these, all resources of that type will be returned.

resources
string

A comma separated, case sensitive list of resources to be returned. If none are provided all resources will be included.

dateFrom
string

The start date (inclusive) for which to filter returned resources - formatted YYYY-MM-DD as per ISO 8601. If not provided, no start date filter will be applied.

dateTo
string

The end date (inclusive) for which to filter returned resources - formatted YYYY-MM-DD as per ISO 8601. If not provided, no end date filter will be applied.

conversionType
string

The format of the resulting data. Can be one of pdf, html, or json.

If provided, the Webhook will contain a URL to the file of chosen type. The URL is active for 3 minutes.

Otherwise, the data will be returned in JSON format in the Webhook payload (default).

Providing pdf or html results in a Medical Record Summary being sent.

You can scroll to the bottom of the page to view all available resources.

Body

metadata
object

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 business use case - for example, external IDs. This metadata will be returned in the webhook response.

{
  "metadata": {
     "youCan": "putAny",
     "stringKeyValue": "pairsHere",
  }
}

Response

Returns a JSON containing a status property indicating the query status. Possible values for consolidated data query status are processing, completed, or failed.

{
  "status": "processing"
}

Available FHIR resources

This is the list of all available FHIR resources you can query for: