|
9 | 9 | * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. |
10 | 10 | */ |
11 | 11 |
|
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 | + |
14 | 50 | const deceasedPrefix = { |
15 | 51 | id: 'death.search.criteria.label.prefix.deceased', |
16 | 52 | defaultMessage: "Deceased's", |
@@ -67,6 +103,16 @@ export const advancedSearchDeath = [ |
67 | 103 | field('eventDetails.deathLocation', { |
68 | 104 | searchCriteriaLabelPrefix: deceasedPrefix |
69 | 105 | }).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(), |
70 | 116 | field('eventDetails.deathLocationOther', {}).exact() |
71 | 117 | ] |
72 | 118 | }, |
|
0 commit comments