An AI agent for immunization related healthcare appointments built with **Amazon Bedrock AgentCore Gateway** using the **Model Context Protocol (MCP)** to expose the tools. This AI agent supports enquiring about current immunization status/schedule, checking appointment slots and booking appointments. It also provides personalized experience by knowing the logged in user (adult) and his/her children and uses **AWS Healthlake** as **FHIR R4** (Fast Healthcare Interoperability Resources) database.
| SDK used | Amazon Bedrock AgentCore SDK and boto3 |
### Use case Architecture

### Use case key Features
## Prerequisites
**Note: These steps are designed to work in us-east-1 and us-west-2 regions.**
### Required IAM Policies
Please ensure the required IAM permissions. Ignore if running this sample from Admin role.
Cloudformation stack used in this sample has AWS Healthlake, Cognito, S3, IAM Roles, API Gateway, Lambda functions related sources.
As a quick start, you may use the combination of AWS managed IAM policies and an Inline policy to avoid issues in deploying and setting up this code sample. However it is recommended to follow the principle of privilege in production.
**AWS managed IAM policies:**
* AmazonAPIGatewayAdministrator
* AmazonCognitoPowerUser
* AmazonHealthLakeFullAccess
* AmazonS3FullAccess
* AWSCloudFormationFullAccess
* AWSKeyManagementServicePowerUser
* AWSLakeFormationDataAdmin
* AWSLambda_FullAccess
* AWSResourceAccessManagerFullAccess
* CloudWatchFullAccessV2
* AmazonBedrockFullAccess
**Inline Policy:**
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::amzn-s3-demo-source-bucket/*",
"arn:aws:s3:::amzn-s3-demo-logging-bucket/*"
]
},
{
"Effect": "Allow",
"Action": [
"ram:GetResourceShareInvitations",
"ram:AcceptResourceShareInvitation",
"glue:CreateDatabase",
"glue:DeleteDatabase"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"bedrock-agentcore:*",
"agent-credential-provider:*"
],
"Resource": "*"
}
]
}
```
### Others
* Python 3.12
* GIT
* AWS CLI 2.x
* Claude 3.5 Sonnet model enabled on Amazon Bedrock. Please follow this [guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html) to set up the same.
## Use case Setup
Clone the GIT repository and navigate the the Healthcare-Appointment-Agent directory.
```
git clone <repository-url>
cd ./02-use-cases/05-Healthcare-Appointment-Agent/
```
### Setup Infrastructure
Create an S3 bucket (**ignore if you would like to use an existing bucket**)
Deploy cloudformation template by using below steps. The stack will take around 10 minutes. You can monitor the progress of stack by following this [guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/monitor-stack-progress.html).
### Install python dependencies and initialize the environment
Install UV as per this [guide](https://docs.astral.sh/uv/getting-started/installation/)
Create and activate virtual environment
```
uv venv --python 3.12
source ./.venv/bin/activate
```
Install dependencies
```
uv pip install -r requirements.txt
```
Initialize the environment by running below command. This will create an **.env** file which would be used for environment variables. Use the same region name as what was used with Cloudformation template above. Note down **APIEndpoint** and **APIGWCognitoLambdaName** as returned in the output.
```
python init_env.py \
--cfn_name healthcare-cfn-stack \
--openapi_spec_file ./fhir-openapi-spec.yaml \
--region <us-east-1orus-west-2>
```
if you need to use a named credential profile then same can be achieved with below.
Run the below python program to ingest the test data as present in **test_data** folder. It may take around ~5 minutes to complete.
```
python create_test_data.py
```
## Execution Instructions
### Create Bedrock AgentCore Gateway and Gateway Target
Open the OpenAPI spec file **fhir-openapi-spec.yaml** and replace **<yourAPIendpointhere>** with **APIEndpoint** as noted down earlier.
Set up Bedrock AgentCore Gateway and Gateway Target based on OpenAPI specification in **fhir-openapi-spec.yaml** file. Note down the Gaeway Id from the output as it would be needed in later steps.