Skip to content

Commit

Permalink
fix(v1.6.2): handle unexpected state when a record is viewed before r…
Browse files Browse the repository at this point in the history
…egistration confirmation (#8306)

Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>
  • Loading branch information
ocrvs-bot and rikukissa authored Jan 9, 2025
1 parent cb78f23 commit 22834e1
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 7 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Bug fixes

- Fix task history getting corrupted if a user views a record while it's in external validation [#8278](https://github.com/opencrvs/opencrvs-core/issues/8278)
- Fix health facilities missing from dropdown after correcting a record address [#7528](https://github.com/opencrvs/opencrvs-core/issues/7528)
- Fix stale validations showing for document uploader with options form field

Expand Down Expand Up @@ -133,11 +134,7 @@
- **Set Metabase default credentials.** These must be configured via countryconfig repository environment variables and secrets otherwise the dashboard service won't start: OPENCRVS_METABASE_ADMIN_EMAIL & OPENCRVS_METABASE_ADMIN_PASSWORD
- **Check your Metabase map file.** For Metabase configuration, we renamed `farajaland-map.geojson` to `map.geojson` to not tie implementations into example country naming conventions.
- **Feature flags** In order to make application config settings more readable, we re-organised `src/api/application/application-config-default.ts` with a clear feature flag block like so. These are then used across the front and back end of the application to control configurable functionality. New feature flags DEATH_REGISTRATION allow you to optionally run off death registration if your country doesnt want to run its first pilot including death and PRINT_DECLARATION (see New Features) have been added.
`FEATURES: {
DEATH_REGISTRATION: true,
MARRIAGE_REGISTRATION: false,
...
} `
`FEATURES: { DEATH_REGISTRATION: true, MARRIAGE_REGISTRATION: false, ... } `
- **Improve rendering of addresses in review page where addresses match** When entering father's address details, some countries make use of a checkbox which says "Address is the same as the mothers. " which, when selected, makes the mother's address and fathers address the same. The checkbox has a programatic value of "Yes" or "No". As a result on the review page, the value "Yes" was displayed which didn't make grammatical sense as a response. We decided to use a custom label: "Same as mother's", which is what was asked on the form. This requires some code changes in the src/form/addresses/index.ts file to pull in the `hideInPreview` prop which will hide the value "Yes" on the review page and replace with a content managed label. Associated bug [#5086](https://github.com/opencrvs/opencrvs-core/issues/5086)

### Infrastructure breaking changes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { Db } from 'mongodb'

interface IncorrectTask {
extension: (Record<string, unknown> | null)[]
}

/*
* Removes nulls from the extension field of Task and Task_history collections.
*/
export const up = async (db: Db) => {
await db
.collection<IncorrectTask>('Task')
.updateMany(
{ extension: { $elemMatch: { $eq: null } } },
{ $pull: { extension: null } }
)

await db
.collection<IncorrectTask>('Task_history')
.updateMany(
{ extension: { $elemMatch: { $eq: null } } },
{ $pull: { extension: null } }
)
}

export const down = async () => {}
134 changes: 134 additions & 0 deletions packages/workflow/src/records/fhir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { SavedTask, TrackingID } from '@opencrvs/commons/types'
import { createRegisterTask } from './fhir'
import { UUID } from '@opencrvs/commons'

describe('https://github.com/opencrvs/opencrvs-core/issues/8278', () => {
/*
* It's possible that a user for instance "views" a record between the record being set to WAITING_VALIDATION and the record being set to REGISTERED.
* 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 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'
}
]
},
focus: {
reference:
'Composition/1a738c6a-2dfe-4fad-96c8-597834692b07' as `Composition/${UUID}`
},
id: '11af7c9c-8d57-4e83-9c83-93e28725da41' as UUID,
requester: {
agent: {
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' as TrackingID
},
{
system: 'http://opencrvs.org/specs/id/birth-tracking-id',
value: 'BJ5AGDQ' as TrackingID
}
],
extension: [
{
url: 'http://opencrvs.org/specs/extension/informants-signature',
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/timeLoggedMS',
valueInteger: 0
},
{
url: 'http://opencrvs.org/specs/extension/regLastUser',
valueReference: {
reference:
'Practitioner/c3647cf0-4abc-4fa1-896c-91fa7be2ac05' as `Practitioner/${UUID}`
}
},
{
url: 'http://opencrvs.org/specs/extension/regLastOffice',
valueReference: {
reference:
'Location/7ae08280-d387-494a-9f1c-52f90f1b6bd0' as `Location/${UUID}`
}
}
],
lastModified: '2025-01-08T01:57:45.455Z',
businessStatus: {
coding: [
{
system: 'http://opencrvs.org/specs/reg-status',
code: 'WAITING_VALIDATION'
}
]
},
meta: {
lastUpdated: '2025-01-08T01:57:45.492+00:00',
versionId: '9d39e624-9af6-455a-bdce-8d8e75b8d7d9'
}
}
expect(createRegisterTask(previousTask).extension).toStrictEqual([
{
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'
},
{
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'
},
{
url: 'http://opencrvs.org/specs/extension/contact-person-email',
valueString: 'informant@example.com'
}
// undefined – this appeared here previously
])
})
})
4 changes: 2 additions & 2 deletions packages/workflow/src/records/fhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ 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,
[timeLoggedMSExtension],
timeLoggedMSExtension ? [timeLoggedMSExtension] : [],
'REGISTERED'
)

Expand Down

0 comments on commit 22834e1

Please sign in to comment.