S3 Trigger to convert FHIR to CDA format
- Java 8 or Higher
- AWS SDK - STS or Eclipse
- AWS Account
- Maven 3.3.x
- GIT
Clone the repository using the below command in command prompt
git clone https://github.com/drajer-health/ecr-fhir-to-cda-lambda.git
Import Project as Maven Project Build:
Navigate to ecr-fhir-to-cda-lambda directory ..../ and run Maven build to build lambda jar file.
$ mvn clean
$ mvn clean install
This will generate a war file under target/ecr-fhir-to-cda-lambda-1.0.0.jar.
Login to your AWS Account
-
Click on Services then select Lambda
-
Click on Create Function
-
Select "Author from Scratch" option
-
Enter:
Function Name: ecrFHIR-to-CDA-lambda
Runtime: Java 8 on Amazon Linux 1 or any other Java runtimes
Permissions: Create a new role with basic Lambda permissions or select your organization specific security
- Click on "Create Function"
At this point Lambda function would be created, navigate to the newly created function and configure the lambda function and environment variable.
-
Go to the newly created Role.
-
Under
Permissionstab click onAdd inline Policy -
Click on
{ } JSONtab and ad the following security policy. Replace theS3-BUCKET-NAMEwith your S3 bucket name.{ "Version": "2012-10-17", "Statement": [ { "Sid": "ListObjectsInBucket", "Action": [ "s3:GetObjectVersion", "s3:GetBucketLocation", "s3:GetObject", "s3:PutObject", "s3:PutObjectAcl" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::S3-BUCKET-NAME/*" ] } ]
} ``
-
Click on button
Review policyand then clickSave changes -
Come back to your AWS Lambda Function and navigate to
Configurationtab. -
Go to the
General Configurationand click onEditbutton. Increase the Timeout to minimum 1 minute. -
Under the "Code" tab select "Upload from"
-
Select .zip or .jar file option.
-
Click upload and navigate to your local workspace target folder and select ecr-fhir-to-cda-lambda-1.0.0.jar and click "Save".
-
Click on "Edit" on "Runtime Settings".
-
Enter below value for Handler
com.drajer.ecr.fhir2cda.converter.FHIR2CDAConverterLambdaFunctionHandler::handleRequest
- Click "Save"
To process the file from the S3 bucket, lambda function needs to be configured to process from the specified folder. Add the Environment Variable to the lambda function specifying the S3 bucket folder name.
-
Click on "Configuration" tab and then "Environment Variables"
-
Click on "Edit" to add new environment variable
-
Click on "Add new environment variable"
-
Enter
| Environment Variable | Value |
|---|---|
| BUCKET_NAME | <- S3-FolderName -> |
Lambda function needs to be triggered, for this we need to add and configure the trigger. Follow the following steps to add the trigger to your lambda function.
-
Go to you Lambda function
-
Click on
Add trigger -
From the
Trigger configurationdrop down selectS3option -
From the
Bucketdrop down select your bucket that this lambda function will listen. -
Add the
Suffixto add filter to the function. For exampleEICR_FHIR.xml -
Select the acknowledgement and click Add.