[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThis page explains the process of registering user data with the Consent Management API, which involves creating user data mappings without storing the actual user data in the API.\u003c/p\u003e\n"],["\u003cp\u003eUser data mappings contain a user ID, a data ID, and resource attributes that describe the characteristics of the user data, all stored elsewhere.\u003c/p\u003e\n"],["\u003cp\u003eTo create a user data mapping, you must use the \u003ccode\u003eprojects.locations.datasets.consentStores.userDataMappings.create\u003c/code\u003e method and provide necessary details like the parent consent store name, user ID, data ID, resource attributes, and an access token.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edata_id\u003c/code\u003e field in user data mapping can be any string, such as an opaque ID or a URI, and should describe the referenced data's location and granularity, like a Google Cloud Storage object or a BigQuery row.\u003c/p\u003e\n"],["\u003cp\u003eThe provided examples demonstrate the proper way to register data from multiple sources, such as Amazon S3 objects, BigQuery elements, or even conceptual representations.\u003c/p\u003e\n"]]],[],null,["# Registering user data\n\nThis page describes how to register user data with the Consent Management API.\n\nData elements are registered with the Consent Management API and connected to\nconsents using user data mappings. User data is never stored in the\nConsent Management API.\n\nThe user data mappings, represented as [`UserDataMappings`](/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.consentStores.userDataMappings)\nresources, include the following elements:\n\n- A user ID that identifies the user. This ID matches the ID the application provided the Consent Management API when registering the consent.\n- A data ID that identifies user data stored elsewhere, such as on Google Cloud or on-premises. The data ID can be an opaque ID, a URL, or any other identifier.\n- Resource attributes, which describe the characteristics of the user data using resource attribute values configured for the consent store using attribute definitions. For example, the data could include the `attribute_definition_id` `data_identifiable` with the value of `de-identified`.\n\nThe following diagram shows the data flow for creating user data mappings:\n\nRegistering user data mappings\n------------------------------\n\nTo create a user data mapping, use the\n[`projects.locations.datasets.consentStores.userDataMappings.create`](/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.consentStores.userDataMappings/create)\nmethod. Make a `POST` request and specify the following information in the\nrequest:\n\n- The name of the parent consent store\n- A unique and opaque `userID` that represents the user with whom the data element is associated\n- An identifier for the user data resource, such as the REST path to a unique resource\n- A set of `RESOURCE` attributes that describe the data element\n- An access token\n\n### curl\n\nThe following sample shows a `POST` request using `curl`: \n\n```bash\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n -H \"Content-Type: application/consent+json; charset=utf-8\" \\\n --data \"{\n 'user_id': '\u003cvar class=\"edit\" translate=\"no\"\u003eUSER_ID\u003c/var\u003e',\n 'data_id' : '\u003cvar class=\"edit\" translate=\"no\"\u003eDATA_ID\u003c/var\u003e',\n 'resource_attributes': [{\n 'attribute_definition_id': 'data_identifiable',\n 'values': ['de-identified']\n }]\n }\" \\\n\"https://healthcare.googleapis.com/v1/projects/\u003cvar class=\"edit\" translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar class=\"edit\" translate=\"no\"\u003eLOCATION\u003c/var\u003e/datasets/\u003cvar class=\"edit\" translate=\"no\"\u003eDATASET_ID\u003c/var\u003e/consentStores/\u003cvar class=\"edit\" translate=\"no\"\u003eCONSENT_STORE_ID\u003c/var\u003e/userDataMappings\"\n```\n\nIf the request is successful, the server returns a response similar to the\nfollowing sample in JSON format: \n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings/USER_DATA_MAPPING_ID\",\n \"dataId\": \"DATA_ID\",\n \"userId\": \"USER_ID\",\n \"resourceAttributes\": [\n {\n \"attributeDefinitionId\": \"data_identifiable\",\n \"values\": [\n \"de-identified\"\n ]\n }\n ]\n}\n```\n\n### PowerShell\n\nThe following sample shows a `POST` request using Windows PowerShell: \n\n```bash\n$cred = gcloud auth application-default print-access-token\n$headers = @{ Authorization = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method Post `\n -Headers $headers `\n -ContentType: \"application/consent+json; charset=utf-8\" `\n -Body \"{\n 'user_id': '\u003cvar class=\"edit\" translate=\"no\"\u003eUSER_ID\u003c/var\u003e',\n 'data_id' : '\u003cvar class=\"edit\" translate=\"no\"\u003eDATA_ID\u003c/var\u003e',\n 'resource_attributes': [{\n 'attribute_definition_id': 'data_identifiable',\n 'values': ['de-identified']\n }]\n }\" `\n -Uri \"https://healthcare.googleapis.com/v1/projects/\u003cvar class=\"edit\" translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar class=\"edit\" translate=\"no\"\u003eLOCATION\u003c/var\u003e/datasets/\u003cvar class=\"edit\" translate=\"no\"\u003eDATASET_ID\u003c/var\u003e/consentStores/\u003cvar class=\"edit\" translate=\"no\"\u003eCONSENT_STORE_ID\u003c/var\u003e/userDataMappings\" | Select-Object -Expand Content\n```\n\nIf the request is successful, the server returns a response similar to the\nfollowing sample in JSON format: \n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings/USER_DATA_MAPPING_ID\",\n \"dataId\": \"DATA_ID\",\n \"userId\": \"USER_ID\",\n \"resourceAttributes\": [\n {\n \"attributeDefinitionId\": \"data_identifiable\",\n \"values\": [\n \"de-identified\"\n ]\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\nConfiguring data IDs\n--------------------\n\nThe `data_id` field of the user data mapping resource contains a\ncustomer-specified string that describes the data that the user data mapping resource\nrefers to. Any string is permitted, such as an opaque ID or URI.\n\nData IDs can be as granular as is required by your application. If\nthe data you are registering can be described at the\ntable or bucket level, define `data_id` as the REST path to that resource.\nIf the data you are registering requires more granularity,\nthen you may want to specify specific rows or cells. If your application uses conceptual resources, such as permitted actions or classes of data, you should\ndefine `data_id` with a convention that supports those use-cases.\n\nExamples of a `data_id` that describes data stored in different services and at\nvarious levels of granularity include, but are not limited to, the following:\n\nGoogle Cloud Storage object\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'gs://BUCKET_NAME/OBJECT_NAME'\n \n```\n\n\u003cbr /\u003e\n\nAmazon S3 object \n\n```\n 'data_id' : 'https://BUCKET_NAME.s3.REGION.amazonaws.com/OBJECT_NAME'\n \n```\n\nBigQuery table\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'bigquery/v2/projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID'\n \n```\n\n\u003cbr /\u003e\n\nBigQuery row (there is no REST path for a BigQuery row, so your own identifier is necessary - one possible approach is below)\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'bigquery/v2/projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID/myRows/ROW_ID'\n \n```\n\n\u003cbr /\u003e\n\nBigQuery cell (there is no REST path for a BigQuery cell, so your own identifier is necessary - one possible approach is below)\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'bigquery/v2/projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID/myRows/ROW_ID/myColumns/COLUMN_ID'\n \n```\n\n\u003cbr /\u003e\n\nFHIR resource\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID'\n \n```\n\n\u003cbr /\u003e\n\nConceptual representation\n\n\u003cbr /\u003e\n\n```\n 'data_id' : 'wearables/fitness/step_count/daily_sum'\n \n```\n\n\u003cbr /\u003e"]]