Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: [AEA-4207] - Set the isTerminalState field to bool #481

Merged
merged 10 commits into from
Jul 5, 2024
2 changes: 1 addition & 1 deletion packages/gsul/src/dynamoDBclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function getItemsUpdatesForPrescription(
return items.map((singleUpdate) => ({
itemId: String(singleUpdate.LineItemID),
latestStatus: String(singleUpdate.Status),
isTerminalState: String(singleUpdate.TerminalStatus),
isTerminalState: Boolean(singleUpdate.TerminalStatus),
kris-szlapa marked this conversation as resolved.
Show resolved Hide resolved
lastUpdateDateTime: String(singleUpdate.LastModified)
}))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gsul/src/schema/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const itemSchema = {
type: "string"
},
isTerminalState: {
type: "string"
type: "boolean"
},
lastUpdateDateTime: {
type: "string"
Expand Down
22 changes: 11 additions & 11 deletions packages/gsul/tests/testBuildResult.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
],
Expand All @@ -30,7 +30,7 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
]
Expand Down Expand Up @@ -59,13 +59,13 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "early_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
},
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1971-01-01T00:00:00Z"
}
],
Expand All @@ -76,7 +76,7 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1971-01-01T00:00:00Z"
}
]
Expand All @@ -92,25 +92,25 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "item_1_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
},
{
itemId: "item_1",
latestStatus: "latest_item_1_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1972-01-01T00:00:00Z"
},
{
itemId: "item_2",
latestStatus: "item_2_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1971-01-01T00:00:00Z"
},
{
itemId: "item_2",
latestStatus: "early_item_2_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
],
Expand All @@ -121,13 +121,13 @@ const scenarios: Array<scenariosType> = [
{
itemId: "item_1",
latestStatus: "latest_item_1_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1972-01-01T00:00:00Z"
},
{
itemId: "item_2",
latestStatus: "item_2_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1971-01-01T00:00:00Z"
}
]
Expand Down
83 changes: 50 additions & 33 deletions packages/gsul/tests/testHander.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ describe("test handler", () => {
})

it("respond with error when schema version is 2", async () => {
const response = await handler({
"schemaVersion": 2,
"prescriptions": [{
prescriptionID: "abc",
odsCode: "123"
}]
}, dummyContext)
const response = await handler(
{
schemaVersion: 2,
prescriptions: [
{
prescriptionID: "abc",
odsCode: "123"
}
]
},
dummyContext
)
expect(response).toMatchObject({
schemaVersion: 1,
isSuccess: false,
Expand All @@ -53,9 +58,11 @@ describe("test handler", () => {

const response = await handler(
{
"schemaVersion": 1,
"prescriptions": []
}, dummyContext)
schemaVersion: 1,
prescriptions: []
},
dummyContext
)
expect(response).toMatchObject({
schemaVersion: 1,
isSuccess: true,
Expand All @@ -66,37 +73,47 @@ describe("test handler", () => {
it("respond with success when data passed in", async () => {
const mockReply = {
Count: 1,
Items: [{
PrescriptionID: "abc",
LineItemID: "item_1",
Status: "latest_status",
TerminalStatus: "terminal",
LastModified: "1970-01-01T00:00:00Z"
}]
Items: [
{
PrescriptionID: "abc",
LineItemID: "item_1",
Status: "latest_status",
TerminalStatus: true,
LastModified: "1970-01-01T00:00:00Z"
}
]
}
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)

const response = await handler(
{
"schemaVersion": 1,
"prescriptions": [{
prescriptionID: "abc",
odsCode: "123"
}]
}, dummyContext)
schemaVersion: 1,
prescriptions: [
{
prescriptionID: "abc",
odsCode: "123"
}
]
},
dummyContext
)
expect(response).toMatchObject({
schemaVersion: 1,
isSuccess: true,
prescriptions: [{
prescriptionID: "abc",
onboarded: true,
items: [{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "terminal",
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}]
}]
prescriptions: [
{
prescriptionID: "abc",
onboarded: true,
items: [
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
]
}
]
})
})
})
12 changes: 6 additions & 6 deletions packages/gsul/tests/testRunDynamoDBQueries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("testing dynamoDBClient", () => {
PrescriptionID: "abc",
LineItemID: "item_1",
Status: "latest_status",
TerminalStatus: "is_terminal_status",
TerminalStatus: true,
LastModified: "1970-01-01T00:00:00Z"
}
]
Expand All @@ -37,7 +37,7 @@ describe("testing dynamoDBClient", () => {
{
itemId: "item_1",
latestStatus: "latest_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
])
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("testing pagination in dynamoDBClient", () => {
PrescriptionID: "abc",
LineItemID: "item_1",
Status: "first_status",
TerminalStatus: "is_terminal_status",
TerminalStatus: true,
LastModified: "1970-01-01T00:00:00Z"
}
],
Expand All @@ -88,7 +88,7 @@ describe("testing pagination in dynamoDBClient", () => {
PrescriptionID: "abc",
LineItemID: "item_1",
Status: "second_status",
TerminalStatus: "is_terminal_status",
TerminalStatus: true,
LastModified: "1970-01-01T00:00:00Z"
}
]
Expand All @@ -106,13 +106,13 @@ describe("testing pagination in dynamoDBClient", () => {
{
itemId: "item_1",
latestStatus: "first_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
},
{
itemId: "item_1",
latestStatus: "second_status",
isTerminalState: "is_terminal_status",
isTerminalState: true,
lastUpdateDateTime: "1970-01-01T00:00:00Z"
}
])
Expand Down
109 changes: 54 additions & 55 deletions packages/specification/examples/request-erd-dispatched.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"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": "completed",
"businessStatus": {
"coding": [
{
"system": "https://fhir.nhs.uk/CodeSystem/task-businessStatus-nppt",
"code": "Dispatched"
}
]
},
"intent": "order",
"focus": {
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"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-item-number",
"value": "6989b7bd-8db6-428c-a593-4022e3044c00"
"system": "https://fhir.nhs.uk/Id/prescription-order-number",
"value": "07A66F-A83008-1EEEA0"
}
},
"for": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "C9Z1O"
}
},
"input": [
}
],
"status": "completed",
"businessStatus": {
"coding": [
{
"type": {
"text": "Repeat Number"
},
"valueInteger": 2
"system": "https://fhir.nhs.uk/CodeSystem/task-businessStatus-nppt",
"code": "Dispatched"
}
]
},
"request": {
"method": "POST",
"url": "Task"
}
"intent": "order",
"focus": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/prescription-order-item-number",
"value": "6989b7bd-8db6-428c-a593-4022e3044c00"
}
},
"for": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9449304130"
}
},
"lastModified": "2024-01-30T12:01:24Z",
"owner": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "C9Z1O"
}
},
"input": [
{
"type": {
"text": "Repeat Number"
},
"valueInteger": 2
}
]
},
"request": {
"method": "POST",
"url": "Task"
}
]
}
}
]
}
Loading