There are more AWS SDK examples available in the AWS Doc SDK Examples
HealthLake examples using AWS CLI
The following code examples show you how to perform actions and implement common scenarios by using the AWS 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.
Each example includes a link to the complete source code, 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
.
- AWS 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-versionR4
\ --datastore-type-versionR4
\ --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.
-
For API details, see CreateFHIRDatastore
in AWS CLI Command Reference.
-
The following code example shows how to use delete-fhir-datastore
.
- AWS 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)
\ --regionus-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.
-
For API details, see DeleteFHIRDatastore
in AWS CLI Command Reference.
-
The following code example shows how to use describe-fhir-datastore
.
- AWS 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"
\ --regionus-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.
-
For API details, see DescribeFHIRDatastore
in AWS CLI Command Reference.
-
The following code example shows how to use describe-fhir-export-job
.
- AWS 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-id9b9a51943afaedd0a8c0c26c49135a31
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.
-
For API details, see DescribeFHIRExportJob
in AWS CLI Command Reference.
-
The following code example shows how to use describe-fhir-import-job
.
- AWS 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-idc145fbb27b192af392f8ce6e7838e34f
\ --regionus-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.
-
For API details, see DescribeFHIRImportJob
in AWS CLI Command Reference.
-
The following code example shows how to use list-fhir-datastores
.
- AWS 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
\ --filterDatastoreStatus=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.
-
For API details, see ListFHIRDatastores
in AWS CLI Command Reference.
-
The following code example shows how to use list-fhir-export-jobs
.
- AWS 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-statusSUBMITTED
\ --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.
-
For API details, see ListFHIRExportJobs
in AWS CLI Command Reference.
-
The following code example shows how to use list-fhir-import-jobs
.
- AWS 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-statusSUBMITTED
\-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.
-
For API details, see ListFHIRImportJobs
in AWS CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource
.
- AWS 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"
\ --regionus-east-1
Output:
{ "tags": { "key": "value", "key1": "value1" } }
For more information, see Tagging resources in Amazon HealthLake in the Amazon HealthLake Developer Guide.
-
For API details, see ListTagsForResource
in AWS CLI Command Reference.
-
The following code example shows how to use start-fhir-export-job
.
- AWS 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-arnarn: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.
-
For API details, see StartFHIRExportJob
in AWS CLI Command Reference.
-
The following code example shows how to use start-fhir-import-job
.
- AWS 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)"
\ --regionus-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.
-
For API details, see StartFHIRImportJob
in AWS CLI Command Reference.
-
The following code example shows how to use tag-resource
.
- AWS 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"}]
' \ --regionus-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 AWS CLI Command Reference.
-
The following code example shows how to use untag-resource
.
- AWS 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"]
' \ --regionus-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 AWS CLI Command Reference.
-