HealthLake examples using Amazon CLI - Amazon Command Line Interface
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

HealthLake examples using Amazon CLI

The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with HealthLake.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios and cross-service examples.

Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Each example includes a link to GitHub, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use create-fhir-datastore.

Amazon CLI

To create a FHIR Data Store.

The following create-fhir-datastore example demonstrates how to create a new Data Store in Amazon HealthLake.

aws healthlake create-fhir-datastore \ --region us-east-1 \ --datastore-type-version R4 \ --datastore-type-version R4 \ --datastore-name "FhirTestDatastore"

Output:

{ "DatastoreEndpoint": "https://healthlake.us-east-1.amazonaws.com/datastore/(Datastore ID)/r4/", "DatastoreArn": "arn:aws:healthlake:us-east-1:(AWS Account ID):datastore/(Datastore ID)", "DatastoreStatus": "CREATING", "DatastoreId": "(Datastore ID)" }

For more information, see Creating and monitoring a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use delete-fhir-datastore.

Amazon CLI

To delete a FHIR Data Store

The following delete-fhir-datastore example demonstrates how to delete a Data Store and all of its contents in Amazon HealthLake.

aws healthlake delete-fhir-datastore \ --datastore-id (Data Store ID) \ --region us-east-1

Output:

{ "DatastoreEndpoint": "https://healthlake.us-east-1.amazonaws.com/datastore/(Datastore ID)/r4/", "DatastoreArn": "arn:aws:healthlake:us-east-1:(AWS Account ID):datastore/(Datastore ID)", "DatastoreStatus": "DELETING", "DatastoreId": "(Datastore ID)" }

For more information, see Creating and monitoring a FHIR Data Store <https://docs.aws.amazon.com/healthlake/latest/devguide/working-with-FHIR-healthlake.html> in the Amazon HealthLake Developer Guide.

The following code example shows how to use describe-fhir-datastore.

Amazon CLI

To describe a FHIR Data Store

The following describe-fhir-datastore example demonstrates how to find the properties of a Data Store in Amazon HealthLake.

aws healthlake describe-fhir-datastore \ --datastore-id "1f2f459836ac6c513ce899f9e4f66a59" \ --region us-east-1

Output:

{ "DatastoreProperties": { "PreloadDataConfig": { "PreloadDataType": "SYNTHEA" }, "DatastoreName": "FhirTestDatastore", "DatastoreArn": "arn:aws:healthlake:us-east-1:(AWS Account ID):datastore/(Datastore ID)", "DatastoreEndpoint": "https://healthlake.us-east-1.amazonaws.com/datastore/(Datastore ID)/r4/", "DatastoreStatus": "CREATING", "DatastoreTypeVersion": "R4", "DatastoreId": "(Datastore ID)" } }

For more information, see Creating and monitoring a FHIR Data Stores in the Amazon HealthLake Developer Guide.

The following code example shows how to use describe-fhir-export-job.

Amazon CLI

To describe a FHIR export job

The following describe-fhir-export-job example shows how to find the properties of a FHIR export job in Amazon HealthLake.

aws healthlake describe-fhir-export-job \ --datastore-id (Datastore ID) \ --job-id 9b9a51943afaedd0a8c0c26c49135a31

Output:

{ "ExportJobProperties": { "DataAccessRoleArn": "arn:aws:iam::(AWS Account ID):role/(Role Name)", "JobStatus": "IN_PROGRESS", "JobId": "9009813e9d69ba7cf79bcb3468780f16", "SubmitTime": 1609175692.715, "OutputDataConfig": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/59593b2d0367ce252b5e66bf5fd6b574-FHIR_EXPORT-9009813e9d69ba7cf79bcb3468780f16/" }, "DatastoreId": "(Datastore ID)" } }

For more information, see Exporting files from a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use describe-fhir-import-job.

Amazon CLI

To describe a FHIR import job

The following describe-fhir-import-job example shows how to learn the properties of a FHIR import job using Amazon HealthLake.

aws healthlake describe-fhir-import-job \ --datastore-id (Datastore ID) \ --job-id c145fbb27b192af392f8ce6e7838e34f \ --region us-east-1

Output:

{ "ImportJobProperties": { "InputDataConfig": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/" { "arrayitem2": 2 } }, "DataAccessRoleArn": "arn:aws:iam::(AWS Account ID):role/(Role Name)", "JobStatus": "COMPLETED", "JobId": "c145fbb27b192af392f8ce6e7838e34f", "SubmitTime": 1606272542.161, "EndTime": 1606272609.497, "DatastoreId": "(Datastore ID)" } }

For more information, see Importing files to a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use list-fhir-datastores.

Amazon CLI

To list FHIR Data Stores

The following list-fhir-datastores example shows to how to use the command and how users can filter results based on Data Store status in Amazon HealthLake.

aws healthlake list-fhir-datastores \ --region us-east-1 \ --filter DatastoreStatus=ACTIVE

Output:

{ "DatastorePropertiesList": [ { "PreloadDataConfig": { "PreloadDataType": "SYNTHEA" }, "DatastoreName": "FhirTestDatastore", "DatastoreArn": "arn:aws:healthlake:us-east-1:<AWS Account ID>:datastore/<Datastore ID>", "DatastoreEndpoint": "https://healthlake.us-east-1.amazonaws.com/datastore/<Datastore ID>/r4/", "DatastoreStatus": "ACTIVE", "DatastoreTypeVersion": "R4", "CreatedAt": 1605574003.209, "DatastoreId": "<Datastore ID>" }, { "DatastoreName": "Demo", "DatastoreArn": "arn:aws:healthlake:us-east-1:<AWS Account ID>:datastore/<Datastore ID>", "DatastoreEndpoint": "https://healthlake.us-east-1.amazonaws.com/datastore/<Datastore ID>/r4/", "DatastoreStatus": "ACTIVE", "DatastoreTypeVersion": "R4", "CreatedAt": 1603761064.881, "DatastoreId": "<Datastore ID>" } ] }

For more information, see Creating and monitoring a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use list-fhir-export-jobs.

Amazon CLI

To list all FHIR export jobs

The following list-fhir-export-jobs example shows how to use the command to view a list of export jobs associated with an account.

aws healthlake list-fhir-export-jobs \ --datastore-id (Datastore ID) \ --submitted-before (DATE like 2024-10-13T19:00:00Z)\ --submitted-after (DATE like 2020-10-13T19:00:00Z )\ --job-name "FHIR-EXPORT" \ --job-status SUBMITTED \ --max-results (Integer between 1 and 500)

Output:

{ "ExportJobProperties": { "OutputDataConfig": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/" "S3Configuration": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/", "KmsKeyId" : "(KmsKey Id)" }, }, "DataAccessRoleArn": "arn:aws:iam::(AWS Account ID):role/(Role Name)", "JobStatus": "COMPLETED", "JobId": "c145fbb27b192af392f8ce6e7838e34f", "JobName" "FHIR-EXPORT", "SubmitTime": 1606272542.161, "EndTime": 1606272609.497, "DatastoreId": "(Datastore ID)" } } "NextToken": String

For more information, see Exporting files from a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use list-fhir-import-jobs.

Amazon CLI

To list all FHIR import jobs

The following list-fhir-import-jobs example shows how to use the command to view a list of all import jobs associated with an account.

aws healthlake list-fhir-import-jobs \ --datastore-id (Datastore ID) \ --submitted-before (DATE like 2024-10-13T19:00:00Z) \ --submitted-after (DATE like 2020-10-13T19:00:00Z ) \ --job-name "FHIR-IMPORT" \ --job-status SUBMITTED \ -max-results (Integer between 1 and 500)

Output:

{ "ImportJobProperties": { "OutputDataConfig": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/", "S3Configuration": { "S3Uri": "s3://(Bucket Name)/(Prefix Name)/", "KmsKeyId" : "(KmsKey Id)" }, }, "DataAccessRoleArn": "arn:aws:iam::(AWS Account ID):role/(Role Name)", "JobStatus": "COMPLETED", "JobId": "c145fbb27b192af392f8ce6e7838e34f", "JobName" "FHIR-IMPORT", "SubmitTime": 1606272542.161, "EndTime": 1606272609.497, "DatastoreId": "(Datastore ID)" } } "NextToken": String

For more information, see Importing files to FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use list-tags-for-resource.

Amazon CLI

To list tags for a Data Store

The following list-tags-for-resource example lists the tags associated with the specified Data Store.:

aws healthlake list-tags-for-resource \ --resource-arn "arn:aws:healthlake:us-east-1:674914422125:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe" \ --region us-east-1

Output:

{ "tags": { "key": "value", "key1": "value1" } }

For more information, see Tagging resources in Amazon HealthLake in the Amazon HealthLake Developer Guide.

The following code example shows how to use start-fhir-export-job.

Amazon CLI

To start a FHIR export job

The following start-fhir-export-job example shows how to start a FHIR export job using Amazon HealthLake.

aws healthlake start-fhir-export-job \ --output-data-config S3Uri="s3://(Bucket Name)/(Prefix Name)/" \ --datastore-id (Datastore ID) \ --data-access-role-arn arn:aws:iam::(AWS Account ID):role/(Role Name)

Output:

{ "DatastoreId": "(Datastore ID)", "JobStatus": "SUBMITTED", "JobId": "9b9a51943afaedd0a8c0c26c49135a31" }

For more information, see Exporting files from a FHIR Data Store in the Amazon HealthLake Developer Guide.

The following code example shows how to use start-fhir-import-job.

Amazon CLI

To start a FHIR import job

The following start-fhir-import-job example shows how to start a FHIR import job using Amazon HealthLake.

aws healthlake start-fhir-import-job \ --input-data-config S3Uri="s3://(Bucket Name)/(Prefix Name)/" \ --datastore-id (Datastore ID) \ --data-access-role-arn "arn:aws:iam::(AWS Account ID):role/(Role Name)" \ --region us-east-1

Output:

{ "DatastoreId": "(Datastore ID)", "JobStatus": "SUBMITTED", "JobId": "c145fbb27b192af392f8ce6e7838e34f" }

For more information, see Importing files to a FHIR Data Store 'https://docs.aws.amazon.com/healthlake/latest/devguide/import-datastore.html in the Amazon HeatlhLake Developer Guide.

The following code example shows how to use tag-resource.

Amazon CLI

To add a tag to Data Store

The following tag-resource example shows how to add a tag to a Data Store.

aws healthlake tag-resource \ --resource-arn "arn:aws:healthlake:us-east-1:691207106566:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe" \ --tags '[{"Key": "key1", "Value": "value1"}]' \ --region us-east-1

This command produces no output.

For more information, see 'Adding a tag to a Data Store <https://docs.aws.amazon.com/healthlake/latest/devguide/add-a-tag.html>'__ in the Amazon HealthLake Developer Guide..

  • For API details, see TagResource in Amazon CLI Command Reference.

The following code example shows how to use untag-resource.

Amazon CLI

To remove tags from a Data Store.

The following untag-resource example shows how to remove tags from a Data Store.

aws healthlake untag-resource \ --resource-arn "arn:aws:healthlake:us-east-1:674914422125:datastore/fhir/b91723d65c6fdeb1d26543a49d2ed1fa" \ --tag-keys '["key1"]' \ --region us-east-1

This command produces no output.

For more information, see Removing tags from a Data Store in the Amazon HealthLake Developer Guide.

  • For API details, see UntagResource in Amazon CLI Command Reference.