Skip to content

Commit

Permalink
clarifications based on test feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Jan 9, 2025
1 parent a9b344e commit 314bf04
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 56 deletions.
108 changes: 53 additions & 55 deletions packages/workflow/src/records/fhir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { TrackingID } from '@opencrvs/commons/types'
import { SavedTask, TrackingID } from '@opencrvs/commons/types'
import { createRegisterTask } from './fhir'
import { UUID } from '@opencrvs/commons'

Expand All @@ -18,13 +18,18 @@ describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
* In this case the "previous task" that the registration confirmation uses will have different values from expected.
* This test ensures that the new task will not have null values if this happens.
*/
test('create register task never produces an extension array with null values even when there is no timeLoggedMS extension in the previous task', () => {
const previousTask = createRegisterTask({
test('create register task produces an extension array with a pre-existing timeLoggedMS extension from the previous task if such extension exists', () => {
const previousTask: SavedTask = {
resourceType: 'Task',
status: 'ready',
intent: 'proposal',
code: {
coding: [{ system: 'http://opencrvs.org/specs/types', code: 'BIRTH' }]
coding: [
{
system: 'http://opencrvs.org/specs/types',
code: 'BIRTH'
}
]
},
focus: {
reference:
Expand All @@ -33,13 +38,14 @@ describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
id: '11af7c9c-8d57-4e83-9c83-93e28725da41' as UUID,
requester: {
agent: {
reference: 'Practitioner/c3647cf0-4abc-4fa1-896c-91fa7be2ac05'
reference:
'Practitioner/c3647cf0-4abc-4fa1-896c-91fa7be2ac05' as `Practitioner/${UUID}`
}
},
identifier: [
{
system: 'http://opencrvs.org/specs/id/draft-id',
value: 'b21428dd-6fd8-41bc-aae5-651db50596d2'
value: 'b21428dd-6fd8-41bc-aae5-651db50596d2' as TrackingID
},
{
system: 'http://opencrvs.org/specs/id/birth-tracking-id',
Expand All @@ -49,13 +55,17 @@ describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
extension: [
{
url: 'http://opencrvs.org/specs/extension/informants-signature',
valueString: '/ocrvs/00376d63-2b3f-4e26-890a-e70fad1403f3.png'
valueString:
'/ocrvs/00376d63-2b3f-4e26-890a-e70fad1403f3.png' as `ocrvs/${UUID}.png`
},
{
url: 'http://opencrvs.org/specs/extension/contact-person-email',
valueString: 'informant@example.com'
},
{ url: 'http://opencrvs.org/specs/extension/regViewed' },
{
url: 'http://opencrvs.org/specs/extension/timeLoggedMS',
valueInteger: 0
},
{
url: 'http://opencrvs.org/specs/extension/regLastUser',
valueReference: {
Expand All @@ -71,7 +81,7 @@ describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
}
}
],
lastModified: '2025-01-08T01:58:16.334Z',
lastModified: '2025-01-08T01:57:45.455Z',
businessStatus: {
coding: [
{
Expand All @@ -81,56 +91,44 @@ describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
]
},
meta: {
lastUpdated: '2025-01-08T01:57:56.335+00:00',
versionId: '74e0b495-0e83-402e-b968-463f3db2e25b' as UUID
lastUpdated: '2025-01-08T01:57:45.492+00:00',
versionId: '9d39e624-9af6-455a-bdce-8d8e75b8d7d9'
}
})
expect(previousTask).toStrictEqual({
resourceType: 'Task',
status: 'ready',
intent: 'proposal',
code: {
coding: [{ system: 'http://opencrvs.org/specs/types', code: 'BIRTH' }]
}
expect(createRegisterTask(previousTask).extension).toStrictEqual([
{
url: 'http://opencrvs.org/specs/extension/informants-signature',
valueString: '/ocrvs/00376d63-2b3f-4e26-890a-e70fad1403f3.png'
},
focus: { reference: 'Composition/1a738c6a-2dfe-4fad-96c8-597834692b07' },
id: '11af7c9c-8d57-4e83-9c83-93e28725da41',
requester: {
agent: {
reference: 'Practitioner/c3647cf0-4abc-4fa1-896c-91fa7be2ac05'
}
{
url: 'http://opencrvs.org/specs/extension/contact-person-email',
valueString: 'informant@example.com'
},
identifier: [
{
system: 'http://opencrvs.org/specs/id/draft-id',
value: 'b21428dd-6fd8-41bc-aae5-651db50596d2'
},
{
system: 'http://opencrvs.org/specs/id/birth-tracking-id',
value: 'BJ5AGDQ'
}
// undefined – this appeared here previously
],
extension: [
{
url: 'http://opencrvs.org/specs/extension/informants-signature',
valueString: '/ocrvs/00376d63-2b3f-4e26-890a-e70fad1403f3.png'
},
{
url: 'http://opencrvs.org/specs/extension/contact-person-email',
valueString: 'informant@example.com'
}
],
lastModified: expect.any(String),
note: undefined,
businessStatus: {
coding: [
{ system: 'http://opencrvs.org/specs/reg-status', code: 'REGISTERED' }
]
{
url: 'http://opencrvs.org/specs/extension/timeLoggedMS',
valueInteger: 0
}
])

const previousTaskWithNoTimeLoggedMS = {
...previousTask,
extension: previousTask.extension.filter(
(extension) =>
extension.url !== 'http://opencrvs.org/specs/extension/timeLoggedMS'
)
}
expect(
createRegisterTask(previousTaskWithNoTimeLoggedMS).extension
).toStrictEqual([
{
url: 'http://opencrvs.org/specs/extension/informants-signature',
valueString: '/ocrvs/00376d63-2b3f-4e26-890a-e70fad1403f3.png'
},
meta: {
lastUpdated: expect.any(String),
versionId: '74e0b495-0e83-402e-b968-463f3db2e25b'
{
url: 'http://opencrvs.org/specs/extension/contact-person-email',
valueString: 'informant@example.com'
}
})
// undefined – this appeared here previously
])
})
})
2 changes: 1 addition & 1 deletion packages/workflow/src/records/fhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export function createWaitingForValidationTask(
export function createRegisterTask(previousTask: SavedTask): Task {
const timeLoggedMSExtension = previousTask.extension.find(
(e) => e.url === 'http://opencrvs.org/specs/extension/timeLoggedMS'
)!
)

const registeredTask = createNewTaskResource(
previousTask,
Expand Down

0 comments on commit 314bf04

Please sign in to comment.