Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions v1-to-v2-data-migration/helpers/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function normalizeDateString(
}

const datePattern = /^(\d{4})-(\d{1,2})-(\d{1,2})$/
const match = dateStr.match(datePattern)
const match = dateStr?.toString().match(datePattern)

if (!match) {
return dateStr
Expand All @@ -26,6 +26,5 @@ export function normalizeDateString(

export function isDateField(fieldId: string): boolean {
const dateFieldPatterns = ['BirthDate', 'birthDate', 'Date', 'deathDate']

return dateFieldPatterns.some((pattern) => fieldId.includes(pattern))
}
14 changes: 10 additions & 4 deletions v1-to-v2-data-migration/helpers/historyResolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Certificate, HistoryItem } from './types.ts'

export const collectorResolver = {
'collector.requesterId': (data: Certificate) => data.collector?.relationship,
'collector.requesterId': (data: Certificate) =>
other(data) ? 'SOMEONE_ELSE' : data.collector?.relationship,
'collector.OTHER.name': (data: Certificate) =>
other(data) && {
surname: data.collector?.name[0].familyName, // TODO - I think I need to use the name resolver
Expand All @@ -14,11 +15,13 @@ export const collectorResolver = {
other(data) && getId(data).type,
'collector.PASSPORT.details': (data: Certificate) =>
getIdForType(data, 'PASSPORT'),
'collector.DRIVING_LICENSE.details': (data: Certificate) =>
'collector.DRIVING-LICENCE.details': (data: Certificate) =>
getIdForType(data, 'DRIVING_LICENSE'),
'collector.REFUGEE_NUMBER.details': (data: Certificate) =>
'collector.DRIVING-LICENSE.details': (data: Certificate) =>
getIdForType(data, 'DRIVING_LICENSE'),
'collector.REFUGEE-NUMBER.details': (data: Certificate) =>
getIdForType(data, 'REFUGEE_NUMBER'),
'collector.ALIEN_NUMBER.details': (data: Certificate) =>
'collector.ALIEN-NUMBER.details': (data: Certificate) =>
getIdForType(data, 'ALIEN_NUMBER'),
'collector.OTHER.idTypeOther': (data: Certificate) =>
other(data) && getId(data).otherType,
Expand All @@ -41,6 +44,9 @@ export const collectorResolver = {
'collector.collect.payment.data.beforeRegistrationTarget': (
data: Certificate
) => data.x, // TODO
'collector.collect.payment.data.afterRegistrationTarget': (
data: Certificate
) => data.x, // TODO
}

export const correctionResolver = {
Expand Down
12 changes: 9 additions & 3 deletions v1-to-v2-data-migration/tests/unit/corrections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ Deno.test('Corrections - with incorrectly formatted dates', async (t) => {
},
{
date: '2024-01-02T12:00:00Z',
action: 'REQUESTED_CORRECTION',
action: 'CORRECTED',
user: { id: 'user2', role: { id: 'REGISTRATION_AGENT' } },
office: { id: 'office1' },
input: [],
Expand All @@ -1588,6 +1588,11 @@ Deno.test('Corrections - with incorrectly formatted dates', async (t) => {
valueId: 'informantBirthDate',
value: '1966-6-6',
},
{
valueCode: 'informant',
valueId: 'exactDateOfBirthUnknown',
value: true,
},
],
},
],
Expand All @@ -1603,6 +1608,7 @@ Deno.test('Corrections - with incorrectly formatted dates', async (t) => {
'mother.dob': '1971-01-01',
'father.dob': '1970-06-06',
'informant.dob': '1966-06-06',
'informant.dobUnknown': true,
})
}
)
Expand Down Expand Up @@ -1648,7 +1654,7 @@ Deno.test('Corrections - with incorrectly formatted dates', async (t) => {
{
valueCode: 'informant',
valueId: 'exactDateOfBirthUnknown',
value: 'false',
value: false,
},
],
},
Expand All @@ -1664,7 +1670,7 @@ Deno.test('Corrections - with incorrectly formatted dates', async (t) => {
'eventDetails.date': '1971-01-01',
'spouse.dob': '1970-06-06',
'informant.dob': '1966-06-06',
'informant.dobUnknown': 'false',
'informant.dobUnknown': false,
})
}
)
Expand Down