Skip to content

Commit 42125fc

Browse files
committed
OCRVS-10898 add mappings and resolvers for marginal notes
1 parent 0a0a5b7 commit 42125fc

File tree

5 files changed

+2223
-68
lines changed

5 files changed

+2223
-68
lines changed

v1-to-v2-data-migration/countryData/countryMappings.ts

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{v1Field.customQuestionMappingId}: {v2Field.id}
77
*/
88

9-
export const COUNTRY_FIELD_MAPPINGS = {
9+
const INITIAL_COUNTRY_FIELD_MAPPINGS = {
1010
'birth.child.child-view-group.birthTime' : 'child.birthTime',
1111
'birth.child.child-view-group.fokontanyCustomAddress' : 'child.birthLocation.privateHome',
1212
'birth.child.child-view-group.otherPlaceOfBirthAddress' : 'child.birthLocation.other',
@@ -37,4 +37,78 @@ export const COUNTRY_FIELD_MAPPINGS = {
3737
'birth.father.iD' : 'father.iD',
3838
'birth.father.father-view-group.birthPlace' : 'father.birthPlace',
3939
'birth.father.father-view-group.fokontanyCustomAddress' : 'father.address'
40+
}
41+
42+
// Mention fields
43+
const mentionKeyBase = "birth.mention.mention-view-group";
44+
45+
const mentionKeys = [
46+
"detailsMentionExist",
47+
"typeOfMention",
48+
"recognitionActNumber",
49+
"recognitionDate",
50+
"recognitionPlace",
51+
"childFamilyName",
52+
"childFirstName",
53+
"mentionChildNID",
54+
"simpleAdoptionActNumber",
55+
"simpleAdoptionDate",
56+
"simpleAdoptionParent1FamilyName",
57+
"simpleAdoptionParent1FirstName",
58+
"simpleAdoptionParent1NID",
59+
"simpleAdoptionParent2FamilyName",
60+
"simpleAdoptionParent2FirstName",
61+
"simpleAdoptionParent2NID",
62+
"judicialAdoptionActNumber",
63+
"judicialAdoptionDate",
64+
"judicialAdoptionJudgementDecisionNumber",
65+
"judicialAdoptionJudgementDecisionDate",
66+
"judicialAdoptionTribunalOfFirstInstanceAct",
67+
"judicialAdoptionParent1FamilyName",
68+
"judicialAdoptionParent1FirstName",
69+
"judicialAdoptionParent1NID",
70+
"judicialAdoptionParent2FamilyName",
71+
"judicialAdoptionParent2FirstName",
72+
"judicialAdoptionParent2NID",
73+
"nameChangeActNumber",
74+
"nameChangeDate",
75+
"nameChangeJudgementDecisionNumber",
76+
"nameChangeJudgementDecisionDate",
77+
"nameChangeTribunalOfFirstInstanceAct",
78+
"modification",
79+
"marriageActNumber",
80+
"marriageDate",
81+
"marriageJudgementDecisionNumber",
82+
"marriageJudgementDecisionDate",
83+
"marriageTribunalOfFirstInstanceAct",
84+
"brideOrGroomFamilyName",
85+
"brideOrGroomFirstName",
86+
"brideOrGroomNID",
87+
"divorceActNumber",
88+
"divorceDate",
89+
"divorcePlace",
90+
"wifeOrHusbandFamilyName",
91+
"wifeOrHusbandFirstName",
92+
"wifeOrHusbandNID",
93+
"deathActNumber",
94+
"deathDate",
95+
"deathPlace",
96+
"deathdateOfDeath",
97+
"deathDeathPlace",
98+
"notes",
99+
];
100+
101+
const MENTION_FIELD_MAPPINGS: Record<string, string> = {};
102+
103+
for (let i = 0; i < 10; i++) {
104+
for (const key of mentionKeys) {
105+
const fullKey = `${mentionKeyBase}.${key}__${i}`;
106+
const value = `${key}-${i}`;
107+
MENTION_FIELD_MAPPINGS[fullKey] = value;
108+
}
109+
}
110+
111+
export const COUNTRY_FIELD_MAPPINGS = {
112+
...INITIAL_COUNTRY_FIELD_MAPPINGS,
113+
...MENTION_FIELD_MAPPINGS
40114
}

v1-to-v2-data-migration/countryData/countryResolvers.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { getCustomField, getDocuments } from '../helpers/resolverUtils.ts'
22
import { EventRegistration } from '../helpers/types.ts'
3+
import pairs from './unResolvedBirthFields.json' with { type: 'json' };
34

4-
export const countryResolver = {
5+
const initialCountryResolver = {
56
'child.birthTime': (data: EventRegistration) =>
67
getCustomField(data, 'birth.child.child-view-group.birthTime'),
78
'child.iD': (data: EventRegistration) => data.child?.identifier?.[0]?.id,
@@ -69,6 +70,19 @@ export const countryResolver = {
6970
getDocuments(data, 'LEGAL_GUARDIAN_PROOF'),
7071
}
7172

73+
const unResolvedBirthFieldsResolverObject = Object.fromEntries(
74+
(pairs as [string, string][]).map(([v1, v2]) => [
75+
v2,
76+
(data: EventRegistration) => getCustomField(data, v1)
77+
])
78+
);
79+
80+
81+
export const countryResolver = {
82+
...initialCountryResolver,
83+
...unResolvedBirthFieldsResolverObject
84+
}
85+
7286
/*
7387
'child.createNUI': ,
7488
'child.nuiGenerator': ,

v1-to-v2-data-migration/countryData/ignoreList.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -62,68 +62,3 @@ export const v1IgnoreList = [
6262
"death.spouse.ruralOrUrbanPrimarySpouse",
6363
"death.informant.ruralOrUrbanPrimaryInformant",
6464
];
65-
66-
// Mention fields
67-
const base = "birth.mention.mention-view-group";
68-
const fields = [
69-
"detailsMentionExist",
70-
"typeOfMention",
71-
"recognitionActNumber",
72-
"recognitionDate",
73-
"recognitionPlace",
74-
"childFamilyName",
75-
"childFirstName",
76-
"mentionChildNID",
77-
"simpleAdoptionActNumber",
78-
"simpleAdoptionDate",
79-
"simpleAdoptionParent1FamilyName",
80-
"simpleAdoptionParent1FirstName",
81-
"simpleAdoptionParent1NID",
82-
"simpleAdoptionParent2FamilyName",
83-
"simpleAdoptionParent2FirstName",
84-
"simpleAdoptionParent2NID",
85-
"judicialAdoptionActNumber",
86-
"judicialAdoptionDate",
87-
"judicialAdoptionJudgementDecisionNumber",
88-
"judicialAdoptionJudgementDecisionDate",
89-
"judicialAdoptionTribunalOfFirstInstanceAct",
90-
"judicialAdoptionParent1FamilyName",
91-
"judicialAdoptionParent1FirstName",
92-
"judicialAdoptionParent1NID",
93-
"judicialAdoptionParent2FamilyName",
94-
"judicialAdoptionParent2FirstName",
95-
"judicialAdoptionParent2NID",
96-
"nameChangeActNumber",
97-
"nameChangeDate",
98-
"nameChangeJudgementDecisionNumber",
99-
"nameChangeJudgementDecisionDate",
100-
"nameChangeTribunalOfFirstInstanceAct",
101-
"modification",
102-
"marriageActNumber",
103-
"marriageDate",
104-
"marriageJudgementDecisionNumber",
105-
"marriageJudgementDecisionDate",
106-
"marriageTribunalOfFirstInstanceAct",
107-
"brideOrGroomFamilyName",
108-
"brideOrGroomFirstName",
109-
"brideOrGroomNID",
110-
"divorceActNumber",
111-
"divorceDate",
112-
"divorcePlace",
113-
"wifeOrHusbandFamilyName",
114-
"wifeOrHusbandFirstName",
115-
"wifeOrHusbandNID",
116-
"deathActNumber",
117-
"deathDate",
118-
"deathPlace",
119-
"deathdateOfDeath",
120-
"deathDeathPlace",
121-
"notes",
122-
];
123-
124-
const mentionFields = Array.from({ length: 10 }, (_, i) =>
125-
fields.map((field) => `${base}.${field}__${i}`)
126-
).flat();
127-
128-
// Add all the mention fields to the existing ignore list
129-
v1IgnoreList.push(...mentionFields);

0 commit comments

Comments
 (0)