Skip to content

PRMT-4568 - ehr-repository - Remove PostgreSQL Implementation and Sequelize Dependencies#73

Merged
MohammadIqbalAD-NHS merged 67 commits intoPRMT-4402from
PRMT-4568
Mar 14, 2024
Merged

PRMT-4568 - ehr-repository - Remove PostgreSQL Implementation and Sequelize Dependencies#73
MohammadIqbalAD-NHS merged 67 commits intoPRMT-4402from
PRMT-4568

Conversation

@joefong-nhs
Copy link
Copy Markdown
Contributor

No description provided.

…ark and ticket number to old postgres related codes
@joefong-nhs joefong-nhs changed the base branch from main to PRMT-4402 March 11, 2024 14:01
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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this line npm run db:migrate need to be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Just removed this

Comment on lines +1 to +24
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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this! Just changed the hyphens to underscore


export const getDynamodbClient = () => {
const clientConfig = {
region: process.env.AWS_DEFAULT_REGION ?? 'eu-west-2',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comma at the end needed?

Comment on lines +41 to +42
// TODO: remove this duplicated `conversationIdFromEhrIn` field,
// after updating ehr-out to use the field name "inboundConversationId"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please put the Ticket number on this TODO, so we know what it refers to?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Just added ticket number to TODO


export const errorMessages = {
HealthRecordNotFound: 'No complete health record was found with given criteria',
MessageNotFound: 'There were no undeleted messages associated with conversation id',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better instead of "undeleted", maybe term it "There are no existing messages associated with conversation id" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed to no existing messages

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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you replace "conversationId" with "inboundConversationId" for clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated the error message

Copy link
Copy Markdown
Contributor

@MohammadIqbalAD-NHS MohammadIqbalAD-NHS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Contributor

@MohammadIqbalAD-NHS MohammadIqbalAD-NHS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well Done!

@MohammadIqbalAD-NHS MohammadIqbalAD-NHS merged commit fc47d7b into PRMT-4402 Mar 14, 2024
@chrisbloe-nhse chrisbloe-nhse deleted the PRMT-4568 branch November 13, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants