**Full name**: projects.locations.datasets.fhirStores.import

Imports resources to the FHIR store by loading data from the specified sources. This method is optimized to load large quantities of data using import semantics that ignore some FHIR store configuration options and are not suitable for all use cases. It is primarily intended to load data into an empty FHIR store that is not being used by other clients. In cases where this method is not appropriate, consider using `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/executeBundle#google.cloud.healthcare.v1.fhir.rest.FhirService.ExecuteBundle` to load data.

Every resource in the input must contain a client-supplied ID. Each resource is stored using the supplied ID regardless of the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore.FIELDS.enable_update_create` setting on the FHIR store. It is strongly advised not to include or encode any sensitive data such as patient identifiers in client-specified resource IDs. Those IDs are part of the FHIR resource path recorded in Cloud Audit Logs and Cloud Pub/Sub notifications. Those IDs can also be contained in reference fields within other resources.

The import process does not enforce referential integrity, regardless of the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore.FIELDS.disable_referential_integrity` setting on the FHIR store. This allows the import of resources with arbitrary interdependencies without considering grouping or ordering, but if the input data contains invalid references or if some resources fail to be imported, the FHIR store might be left in a state that violates referential integrity.

The import process does not trigger Pub/Sub notification or BigQuery streaming update, regardless of how those are configured on the FHIR store.

If a resource with the specified ID already exists, the most recent version of the resource is overwritten without creating a new historical version, regardless of the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore.FIELDS.disable_resource_versioning` setting on the FHIR store. If transient failures occur during the import, it's possible that successfully imported resources will be overwritten more than once.

The import operation is idempotent unless the input data contains multiple valid resources with the same ID but different contents. In that case, after the import completes, the store contains exactly one resource with that ID but there is no ordering guarantee on which version of the contents it will have. The operation result counters do not count duplicate IDs as an error and count one success for each resource in the input, which might result in a success count larger than the number of resources in the FHIR store. This often occurs when importing data organized in bundles produced by `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/Patient-everything#google.cloud.healthcare.v1.fhir.rest.FhirService.GetPatientEverything` where each bundle contains its own copy of a resource such as Practitioner that might be referred to by many patients.

If some resources fail to import, for example due to parsing errors, successfully imported resources are not rolled back.

The location and format of the input data is specified by the parameters in `ImportResourcesRequest`. Note that if no format is specified, this method assumes the `BUNDLE` format. When using the `BUNDLE` format this method ignores the `Bundle.type` field, except that `history` bundles are rejected, and does not apply any of the bundle processing semantics for batch or transaction bundles. Unlike in `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/executeBundle#google.cloud.healthcare.v1.fhir.rest.FhirService.ExecuteBundle`, transaction bundles are not executed as a single transaction and bundle-internal references are not rewritten. The bundle is treated as a collection of resources to be written as provided in `Bundle.entry.resource`, ignoring `Bundle.entry.request`. As an example, this allows the import of `searchset` bundles produced by a `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/search#google.cloud.healthcare.v1.fhir.rest.FhirService.SearchResources` or `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/Patient-everything#google.cloud.healthcare.v1.fhir.rest.FhirService.GetPatientEverything` operation.

This method returns an `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation` that can be used to track the status of the import by calling `operations.get`.

Immediate fatal errors appear in the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation.FIELDS.error` field, errors are also logged to Cloud Logging (see [Viewing error logs in Cloud Logging](https://cloud.google.com/healthcare/docs/how-tos/logging)). Otherwise, when the operation finishes, a detailed response of type `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ImportResourcesResponse` is returned in the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation.FIELDS.response` field. The `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation.FIELDS.metadata` field type for this operation is `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/OperationMetadata`.

### HTTP request

`POST https://healthcare.googleapis.com/v1/{name=projects/*/locations/*/datasets/*/fhirStores/*}:import`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The name of the FHIR store to import FHIR resources to, in the format of `projects/{projectId}/locations/{locationId}/datasets/{datasetId}/fhirStores/{fhirStoreId}`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `healthcare.fhirStores.import` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "contentStructure": enum(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores/import#ContentStructure`), // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "gcsSource": { object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/GcsSource`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `contentStructure` | ``enum(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores/import#ContentStructure`)`` The content structure in the source location. If not specified, the server treats the input source files as `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores/import#ContentStructure.ENUM_VALUES.BUNDLE`. |
| Specifies the import source and configuration. To enable the Cloud Healthcare API to read from resources in your project such as Cloud Storage buckets, you must give the consumer Cloud Healthcare API service account the proper permissions. The service account is: `service-{PROJECT_NUMBER}@gcp-sa-healthcare.iam.gserviceaccount.com`. The PROJECT_NUMBER identifies the project that contains the destination FHIR store. To get the project number, go to the Cloud Console Dashboard. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `gcsSource` | ``object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/GcsSource`)`` Cloud Storage source data location and import configuration. The Healthcare Service Agent account requires the `roles/storage.objectAdmin` role on the Cloud Storage location. Each Cloud Storage object should be a text file that contains the format specified in `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.fhirStores/import#ContentStructure`. |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-healthcare`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## ContentStructure

The content structure of the input source files.

| Enums ||
|---|---|
| `CONTENT_STRUCTURE_UNSPECIFIED` | If the content structure is not specified, the default value `BUNDLE` is used. |
| `BUNDLE` | The source file contains one or more lines of newline-delimited JSON (ndjson). Each line is a bundle that contains one or more resources. |
| `RESOURCE` | The source file contains one or more lines of newline-delimited JSON (ndjson). Each line is a single resource. |
| `BUNDLE_PRETTY` | The entire file is one JSON bundle. The JSON can span multiple lines. |
| `RESOURCE_PRETTY` | The entire file is one JSON resource. The JSON can span multiple lines. |