PRMT-4568 - ehr-repository - Remove PostgreSQL Implementation and Sequelize Dependencies#73
Conversation
…tring to address a mac specific problem
…for local testing
…odb integration test
… separating model and repository layer
…termine latest record
…js to new dynamodb-based implementation
…. Store current progress
…ark and ticket number to old postgres related codes
package.json
Outdated
| @@ -18,10 +18,7 @@ | |||
| "build": "babel src -d build --ignore '**/*.test.js' --ignore '**/__mocks__/*' && cp src/*.json build", | |||
| "start": "node build/server.js", | |||
| "start:local": "npm run db:migrate ; babel-node -r dotenv/config src/server.js", | |||
There was a problem hiding this comment.
Doesn't this line npm run db:migrate need to be removed?
There was a problem hiding this comment.
Sure! Just removed this
terraform-db-roles/dynamodb.tf
Outdated
| data "aws_iam_policy_document" "ehr-transfer-tracker-db-access" { | ||
| statement { | ||
| actions = [ | ||
| "dynamodb:GetItem", | ||
| "dynamodb:PutItem", | ||
| "dynamodb:UpdateItem", | ||
| "dynamodb:Query" | ||
| ] | ||
| resources = [ | ||
| "arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource "aws_iam_policy" "ehr-transfer-tracker-db-access" { | ||
| name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | ||
| policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | ||
| } | ||
|
|
||
| # Grant ECS Task permissions to access the transfer tracker db | ||
| resource "aws_iam_role_policy_attachment" "dynamodb_application_user_policy_attach" { | ||
| role = "${var.environment}-${var.component_name}-EcsTaskRole" | ||
| policy_arn = aws_iam_policy.ehr-transfer-tracker-db-access.arn | ||
| } |
There was a problem hiding this comment.
I notice sometimes you've named the resource identifiers with hyphens and sometimes with underscores. Although there's no strict guideline on how to name identifiers, generally underscores are preferred, which is how we've been naming new Terraform code we've been writing.
| data "aws_iam_policy_document" "ehr-transfer-tracker-db-access" { | |
| statement { | |
| actions = [ | |
| "dynamodb:GetItem", | |
| "dynamodb:PutItem", | |
| "dynamodb:UpdateItem", | |
| "dynamodb:Query" | |
| ] | |
| resources = [ | |
| "arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | |
| ] | |
| } | |
| } | |
| resource "aws_iam_policy" "ehr-transfer-tracker-db-access" { | |
| name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | |
| policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | |
| } | |
| # Grant ECS Task permissions to access the transfer tracker db | |
| resource "aws_iam_role_policy_attachment" "dynamodb_application_user_policy_attach" { | |
| role = "${var.environment}-${var.component_name}-EcsTaskRole" | |
| policy_arn = aws_iam_policy.ehr-transfer-tracker-db-access.arn | |
| } | |
| data "aws_iam_policy_document" "ehr_transfer_tracker_db_access" { | |
| statement { | |
| actions = [ | |
| "dynamodb:GetItem", | |
| "dynamodb:PutItem", | |
| "dynamodb:UpdateItem", | |
| "dynamodb:Query" | |
| ] | |
| resources = [ | |
| "arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | |
| ] | |
| } | |
| } | |
| resource "aws_iam_policy" "ehr_transfer_tracker_db_access" { | |
| name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | |
| policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | |
| } |
There was a problem hiding this comment.
Thanks for spotting this! Just changed the hyphens to underscore
|
|
||
| export const getDynamodbClient = () => { | ||
| const clientConfig = { | ||
| region: process.env.AWS_DEFAULT_REGION ?? 'eu-west-2', |
There was a problem hiding this comment.
Is this comma at the end needed?
| // TODO: remove this duplicated `conversationIdFromEhrIn` field, | ||
| // after updating ehr-out to use the field name "inboundConversationId" |
There was a problem hiding this comment.
Could you please put the Ticket number on this TODO, so we know what it refers to?
There was a problem hiding this comment.
Sure! Just added ticket number to TODO
src/errors/errors.js
Outdated
|
|
||
| export const errorMessages = { | ||
| HealthRecordNotFound: 'No complete health record was found with given criteria', | ||
| MessageNotFound: 'There were no undeleted messages associated with conversation id', |
There was a problem hiding this comment.
May be better instead of "undeleted", maybe term it "There are no existing messages associated with conversation id" ?
There was a problem hiding this comment.
Thanks, changed to no existing messages
… from `CORE#{messageId}` to just `CORE`
| throw new Error('recordType has to be either Core or Fragment'); | ||
| } | ||
| if (!inboundConversationId && !inboundMessageId) { | ||
| throw new Error('must be called with both conversationId and inboundMessageId'); |
There was a problem hiding this comment.
could you replace "conversationId" with "inboundConversationId" for clarification.
There was a problem hiding this comment.
Thanks, updated the error message
MohammadIqbalAD-NHS
left a comment
There was a problem hiding this comment.
I have reviewed. Once you have addressed last comments, let me know so I can approve. Good job on this, I'm impressed you got all this done in a week!
No description provided.