Skip to content

Commit e0fab41

Browse files
authored
Merge pull request #1093 from opencrvs/ocrvs-10574-b
fix: Place of death in advanced search
2 parents 74c59b9 + 7b01174 commit e0fab41

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

src/form/v2/death/advancedSearch.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,44 @@
99
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
1010
*/
1111

12-
import { AdvancedSearchConfig, event, field } from '@opencrvs/toolkit/events'
13-
import { placeOfDeathOptions } from './forms/pages/eventDetails'
12+
import {
13+
AdvancedSearchConfig,
14+
ConditionalType,
15+
event,
16+
field,
17+
TranslationConfig
18+
} from '@opencrvs/toolkit/events'
19+
import { createSelectOptions } from '../utils'
20+
21+
const PlaceOfDeath = {
22+
HEALTH_FACILITY: 'HEALTH_FACILITY',
23+
DECEASED_USUAL_RESIDENCE: 'DECEASED_USUAL_RESIDENCE',
24+
OTHER: 'OTHER'
25+
} as const
26+
27+
const placeOfDeathMessageDescriptors = {
28+
HEALTH_FACILITY: {
29+
defaultMessage: 'Health Institution',
30+
description: 'Select item for Health Institution',
31+
id: 'form.field.label.healthInstitution'
32+
},
33+
DECEASED_USUAL_RESIDENCE: {
34+
defaultMessage: 'Residential address',
35+
description: 'Select item for Private Home',
36+
id: 'form.field.label.privateHome'
37+
},
38+
OTHER: {
39+
defaultMessage: 'Other',
40+
description: 'Select item for Other location',
41+
id: 'form.field.label.otherInstitution'
42+
}
43+
} satisfies Record<keyof typeof PlaceOfDeath, TranslationConfig>
44+
45+
const placeOfDeathOptions = createSelectOptions(
46+
PlaceOfDeath,
47+
placeOfDeathMessageDescriptors
48+
)
49+
1450
const deceasedPrefix = {
1551
id: 'death.search.criteria.label.prefix.deceased',
1652
defaultMessage: "Deceased's",
@@ -67,6 +103,16 @@ export const advancedSearchDeath = [
67103
field('eventDetails.deathLocation', {
68104
searchCriteriaLabelPrefix: deceasedPrefix
69105
}).exact(),
106+
field('deceased.address', {
107+
conditionals: [
108+
{
109+
type: ConditionalType.SHOW,
110+
conditional: field('eventDetails.placeOfDeath').isEqualTo(
111+
PlaceOfDeath.DECEASED_USUAL_RESIDENCE
112+
)
113+
}
114+
]
115+
}).exact(),
70116
field('eventDetails.deathLocationOther', {}).exact()
71117
]
72118
},

src/form/v2/death/forms/pages/eventDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const placeOfDeathMessageDescriptors = {
132132
}
133133
} satisfies Record<keyof typeof PlaceOfDeath, TranslationConfig>
134134

135-
export const placeOfDeathOptions = createSelectOptions(
135+
const placeOfDeathOptions = createSelectOptions(
136136
PlaceOfDeath,
137137
placeOfDeathMessageDescriptors
138138
)

0 commit comments

Comments
 (0)