> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metriport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Start Consolidated Data Query

> Trigger a consolidated data query for the given patient

<Info>
  **Important:** This endpoint retrieves the **cached**
  consolidated data from your most recent [Network
  Query](/medical-api/api-reference/network/start-network-query)
  (or [Legacy Document
  Query](/medical-api/legacy-api-reference/document/start-document-query)
  if you're still using it). It does not fetch new data from
  external sources.
</Info>

When executed, this endpoint triggers an asynchronous query to retrieve a Patient's consolidated data in either
FHIR JSON format, or a rendered PDF or HTML [Medical Record Summary](/medical-api/handling-data/medical-record-summary).

Once the data is ready for consumption, a `consolidated-data` [Webhook message](/medical-api/handling-data/webhooks-with-nq#patient-consolidated-data) will be sent to
[your configured URL](/medical-api/api-reference/settings/post-settings) - this message will contain a URL to download the data,
based on the [parameters](#query-params) used to trigger the query.

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.

You can check the status of the data query by calling [get consolidated data query](/medical-api/api-reference/fhir/consolidated-data-query-get).

## Path Params

<ParamField path="id" type="string" required>
  The ID of the Patient.
</ParamField>

## Query Params

<ParamField query="conversionType" type="string" required>
  The format of the resulting data. Can be one of `json`,
  `pdf`, or `html`.
</ParamField>

<Tip>
  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](https://www.hl7.org/fhir/R4/searchparameter-registry.html#clinical-date)
  for a list of supported resources.
</Tip>

<ParamField query="resources" type="string" optional>
  A comma separated, case sensitive list of resources to be
  returned. If none are provided all resources will be
  included. Metriport will automatically hydrate the
  initially filtered resources with referenced ones to
  create bundle consistency. The list of accepted resources
  can be accessed
  [here](/medical-api/api-reference/fhir/consolidated-data-query-post#available-fhir-resources).
</ParamField>

<ParamField query="dateFrom" type="string" optional>
  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.
</ParamField>

<ParamField query="dateTo" type="string" optional>
  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.
</ParamField>

## Body

<Snippet file="webhook-request-metadata.mdx" />

<Snippet file="webhook-metadata-post-example.mdx" />

## Response

Returns the filters used for this query, in addition to the identifier used by the system to uniquely identify this query (property `requestId`).

<ResponseExample>
  <Snippet file="webhook-metadata-sdk-example.mdx" />
</ResponseExample>

<Snippet file="consolidated-query.mdx" />

```json theme={null}
{
  "requestId": "5f4b3b4b-4b3b-4b3b-4b3b-4b3b4b3b4b3b",
  "status": "processing",
  "startedAt": "2021-01-01T00:00:00Z",
  "dateFrom": "2021-01-01",
  "dateTo": "2021-01-31",
  "resources": ["Observation", "MedicationRequest"],
  "conversionType": "pdf"
}
```

## Rate Limits

See [limits and throttling](/medical-api/more-info/limits#rate-limits)

## Available FHIR resources

This is the list of all available [FHIR resources](/medical-api/fhir/resources) you can query for:

* [AllergyIntolerance](/medical-api/fhir/resources/allergyintolerance)
* [Binary](/medical-api/fhir/resources/binary)
* [Communication](/medical-api/fhir/resources/communication)
* [Composition](/medical-api/fhir/resources/composition)
* [Condition](/medical-api/fhir/resources/condition)
* [Consent](/medical-api/fhir/resources/consent)
* [Coverage](/medical-api/fhir/resources/coverage)
* [Device](/medical-api/fhir/resources/device)
* [DiagnosticReport](/medical-api/fhir/resources/diagnosticreport)
* [DocumentReference](/medical-api/fhir/resources/documentreference)
* [Encounter](/medical-api/fhir/resources/encounter)
* [FamilyMemberHistory](/medical-api/fhir/resources/familymemberhistory)
* [Goal](/medical-api/fhir/resources/goal)
* [Immunization](/medical-api/fhir/resources/immunization)
* [MedicationAdministration](/medical-api/fhir/resources/medicationadministration)
* [MedicationDispense](/medical-api/fhir/resources/medicationdispense)
* [MedicationRequest](/medical-api/fhir/resources/medicationrequest)
* [MedicationStatement](/medical-api/fhir/resources/medicationstatement)
* [Observation](/medical-api/fhir/resources/observation)
* [Practitioner](/medical-api/fhir/resources/practitioner)
* [Procedure](/medical-api/fhir/resources/procedure)
* [Provenance](/medical-api/fhir/resources/provenance)
* [RelatedPerson](/medical-api/fhir/resources/relatedperson)
* [ServiceRequest](/medical-api/fhir/resources/servicerequest)

<Tip>
  Other resources referenced in the bundle will be
  automatically added to the bundle. This could include
  resources like
  [Location](/medical-api/fhir/resources/location),
  [Organization](/medical-api/fhir/resources/organization),
  [Practitioner](/medical-api/fhir/resources/practitioner),
  [Medication](/medical-api/fhir/resources/medication), and
  others.
</Tip>
