Skip to content
Merged
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
50 changes: 48 additions & 2 deletions src/form/v2/death/advancedSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,44 @@
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { AdvancedSearchConfig, event, field } from '@opencrvs/toolkit/events'
import { placeOfDeathOptions } from './forms/pages/eventDetails'
import {
AdvancedSearchConfig,
ConditionalType,
event,
field,
TranslationConfig
} from '@opencrvs/toolkit/events'
import { createSelectOptions } from '../utils'

const PlaceOfDeath = {
HEALTH_FACILITY: 'HEALTH_FACILITY',
DECEASED_USUAL_RESIDENCE: 'DECEASED_USUAL_RESIDENCE',
OTHER: 'OTHER'
} as const

const placeOfDeathMessageDescriptors = {
HEALTH_FACILITY: {
defaultMessage: 'Health Institution',
description: 'Select item for Health Institution',
id: 'form.field.label.healthInstitution'
},
DECEASED_USUAL_RESIDENCE: {
defaultMessage: 'Residential address',
description: 'Select item for Private Home',
id: 'form.field.label.privateHome'
},
OTHER: {
defaultMessage: 'Other',
description: 'Select item for Other location',
id: 'form.field.label.otherInstitution'
}
} satisfies Record<keyof typeof PlaceOfDeath, TranslationConfig>

const placeOfDeathOptions = createSelectOptions(
PlaceOfDeath,
placeOfDeathMessageDescriptors
)

const deceasedPrefix = {
id: 'death.search.criteria.label.prefix.deceased',
defaultMessage: "Deceased's",
Expand Down Expand Up @@ -67,6 +103,16 @@ export const advancedSearchDeath = [
field('eventDetails.deathLocation', {
searchCriteriaLabelPrefix: deceasedPrefix
}).exact(),
field('deceased.address', {
conditionals: [
{
type: ConditionalType.SHOW,
conditional: field('eventDetails.placeOfDeath').isEqualTo(
PlaceOfDeath.DECEASED_USUAL_RESIDENCE
)
}
]
}).exact(),
field('eventDetails.deathLocationOther', {}).exact()
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/form/v2/death/forms/pages/eventDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const placeOfDeathMessageDescriptors = {
}
} satisfies Record<keyof typeof PlaceOfDeath, TranslationConfig>

export const placeOfDeathOptions = createSelectOptions(
const placeOfDeathOptions = createSelectOptions(
PlaceOfDeath,
placeOfDeathMessageDescriptors
)
Expand Down
Loading