Skip to content

Commit

Permalink
Update: [AEA-3830] - Request content validation (#80)
Browse files Browse the repository at this point in the history
## Summary

- Routine Change
- ✨ New Feature

### Details

Validation for request content. DynamoDB transaction rather than
individual writes.

---------

Co-authored-by: Anthony Brown <[email protected]>
  • Loading branch information
originalphil and anthony-nhs authored Apr 15, 2024
1 parent c86374c commit 6c8a4c8
Show file tree
Hide file tree
Showing 39 changed files with 1,855 additions and 707 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
CREATE_INT_RELEASE_NOTES: true
CREATE_PROD_RELEASE_NOTES: true
Expand All @@ -144,6 +145,7 @@ jobs:
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}
Expand All @@ -160,6 +162,7 @@ jobs:
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
Expand All @@ -176,6 +179,7 @@ jobs:
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
CREATE_INT_RELEASE_NOTES: true
CREATE_INT_RC_RELEASE_NOTES: true
Expand All @@ -198,6 +202,7 @@ jobs:
# TRUSTSTORE_FILE: psu-truststore.pem
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
# LOG_LEVEL: INFO
# LOG_RETENTION_DAYS: 731
# MARK_JIRA_RELEASED: true
# CREATE_PROD_RELEASE_NOTES: true
Expand Down
80 changes: 17 additions & 63 deletions SAMtemplates/tables/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: |
PSU DynamoDB tables and related resources
Expand All @@ -14,7 +14,7 @@ Resources:
Properties:
TableName: !Sub ${StackName}-PrescriptionStatusUpdates
AttributeDefinitions:
- AttributeName: RequestID
- AttributeName: TaskID
AttributeType: S
- AttributeName: PrescriptionID
AttributeType: S
Expand All @@ -23,87 +23,41 @@ Resources:
- AttributeName: PharmacyODSCode
AttributeType: S
KeySchema:
- AttributeName: RequestID
KeyType: HASH
- AttributeName: PrescriptionID
KeyType: HASH
- AttributeName: TaskID
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: '5'
WriteCapacityUnits: '5'
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
GlobalSecondaryIndexes:
- IndexName: RequestIDIndex
- IndexName: PharmacyODSCodePrescriptionIDIndex
KeySchema:
- AttributeName: RequestID
- AttributeName: PharmacyODSCode
KeyType: HASH
- AttributeName: PrescriptionID
KeyType: RANGE
Projection:
NonKeyAttributes:
- PatientNHSNumber
- PharmacyODSCode
- TaskID
- LineItemID
- TerminalStatus
- RequestMessage
- LastModified
- Status
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: '5'
WriteCapacityUnits: '5'
- IndexName: PrescriptionIDIndex
KeySchema:
- AttributeName: PrescriptionID
KeyType: HASH
- AttributeName: PatientNHSNumber
KeyType: RANGE
Projection:
NonKeyAttributes:
- PharmacyODSCode
- TaskID
- LineItemID
- TerminalStatus
- RequestID
- RequestMessage
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: '5'
WriteCapacityUnits: '5'
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
- IndexName: PatientNHSNumberIndex
KeySchema:
- AttributeName: PatientNHSNumber
KeyType: HASH
- AttributeName: PrescriptionID
KeyType: RANGE
Projection:
NonKeyAttributes:
- PharmacyODSCode
- TaskID
- LineItemID
- TerminalStatus
- RequestID
- RequestMessage
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: '5'
WriteCapacityUnits: '5'
- IndexName: PharmacyODSCodeIndex
KeySchema:
- AttributeName: PharmacyODSCode
KeyType: HASH
- AttributeName: PrescriptionID
KeyType: RANGE
Projection:
NonKeyAttributes:
- PatientNHSNumber
- TaskID
- LineItemID
- TerminalStatus
- RequestID
- RequestMessage
ProjectionType: INCLUDE
ProjectionType: KEYS_ONLY
ProvisionedThroughput:
ReadCapacityUnits: '5'
WriteCapacityUnits: '5'
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"

PrescriptionStatusUpdatesResources:
Type: AWS::Serverless::Application
Properties:
Expand All @@ -117,7 +71,7 @@ Outputs:
PrescriptionStatusUpdatesTableName:
Description: PrescriptionStatusUpdates table name
Value: !Ref PrescriptionStatusUpdatesTable

PrescriptionStatusUpdatesTableArn:
Description: PrescriptionStatusUpdates table arn
Value: !GetAtt PrescriptionStatusUpdatesTable.Arn
2 changes: 1 addition & 1 deletion jest.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const jestConfig: JestConfigWithTsJest = {
collectCoverage: true,
coverageDirectory: "coverage",
coverageProvider: "v8",
testMatch: ["**/tests/*.test.ts"],
testMatch: ["**/tests/**/*.test.ts"],
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts"],
verbose: true,
Expand Down
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ components:
properties:
fullUrl:
type: string
example: http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46
example: urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46
resource:
$ref: "#/components/schemas/UpdatePrescriptionStatusTask"
request:
Expand Down
16 changes: 8 additions & 8 deletions packages/specification/examples/error-ods-code.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "value",
"diagnostic": "ODS code already in use"
}
]
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "value",
"diagnostic": "ODS code already in use"
}
]
}
4 changes: 2 additions & 2 deletions packages/specification/examples/request-collected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "transaction",
"entry": [
{
"fullUrl": "http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"fullUrl": "urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"resource": {
"resourceType": "Task",
"id": "4d70678c-81e4-4ff4-8c67-17596fd0aa46",
Expand Down Expand Up @@ -37,7 +37,7 @@
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"lastModified": "2023-09-11T10:11:12Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
Expand Down
4 changes: 2 additions & 2 deletions packages/specification/examples/request-dispatched.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "transaction",
"entry": [
{
"fullUrl": "http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"fullUrl": "urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"resource": {
"resourceType": "Task",
"id": "4d70678c-81e4-4ff4-8c67-17596fd0aa46",
Expand Down Expand Up @@ -37,7 +37,7 @@
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"lastModified": "2023-09-11T10:11:12Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
Expand Down
4 changes: 2 additions & 2 deletions packages/specification/examples/request-erd-dispatched.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "transaction",
"entry": [
{
"fullUrl": "http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"fullUrl": "urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"resource": {
"resourceType": "Task",
"id": "4d70678c-81e4-4ff4-8c67-17596fd0aa46",
Expand Down Expand Up @@ -60,4 +60,4 @@
}
]
}


21 changes: 14 additions & 7 deletions packages/specification/examples/request-missing-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
"type": "transaction",
"entry": [
{
"fullUrl": "http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"fullUrl": "urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"resource": {
"resourceType": "Task",
"id": "4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"basedOn": [
{
"identifier": {
"system": "https://fhir.nhs.uk/Id/prescription-order-number",
"value": "07A66F-A83008-1EEEA0"
}
}
],
"status": "in-progress",
"businessStatus": {
"coding": [
Expand All @@ -24,13 +31,13 @@
"value": "6989b7bd-8db6-428c-a593-4022e3044c00"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"owner": {
"for": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "C9Z1O"
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9449304130"
}
}
},
"lastModified": "2023-09-11T10:11:12Z"
},
"request": {
"method": "POST",
Expand Down
14 changes: 7 additions & 7 deletions packages/specification/examples/request-multiple-items.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"type": "transaction",
"entry": [
{
"fullUrl": "http://example.org/fhir/Task/4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"fullUrl": "urn:uuid:4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"resource": {
"resourceType": "Task",
"id": "4d70678c-81e4-4ff4-8c67-17596fd0aa46",
"basedOn": [
{
"identifier": {
"system": "https://fhir.nhs.uk/Id/prescription-order-number",
"value": "3F8A06-A83008-3E85AX"
"value": "07A66F-A83008-1EEEA0"
}
}
],
Expand All @@ -20,7 +20,7 @@
"coding": [
{
"system": "https://fhir.nhs.uk/CodeSystem/task-businessStatus-nppt",
"code": "Ready to collect"
"code": "Dispatched"
}
]
},
Expand All @@ -37,7 +37,7 @@
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"lastModified": "2023-09-11T10:11:12Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
Expand All @@ -51,10 +51,10 @@
}
},
{
"fullUrl": "http://example.org/fhir/Task/346d2bfe-7dc0-451b-ad0d-da81833c08da",
"fullUrl": "urn:uuid:0ae4daf3-f24b-479d-b8fa-b69e2d873b60",
"resource": {
"resourceType": "Task",
"id": "346d2bfe-7dc0-451b-ad0d-da81833c08da",
"id": "0ae4daf3-f24b-479d-b8fa-b69e2d873b60",
"basedOn": [
{
"identifier": {
Expand Down Expand Up @@ -85,7 +85,7 @@
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"lastModified": "2023-09-11T10:11:12Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
Expand Down
Loading

0 comments on commit 6c8a4c8

Please sign in to comment.