Configuration
defineConfig
Defines and validates a complete event type (birth, death, marriage, or any custom event). Parses and validates the config at startup; throws if the config is invalid.
Signature
function defineConfig(config: EventConfigInput): EventConfigParameters
Configuration defining an event type registered in OpenCRVS (for example birth or death).
Machine-readable identifier of the event (e.g. "birth", "death").
Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified.
Configuration of core and custom actions associated with the event.
Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions.
Indicates whether the records of this event type are included in analytics
trueThe EventConfig object
{
"id": "text",
"dateOfEvent": {
"$$field": "text",
"$$subfield": [
"text"
],
"$$code": "text"
},
"placeOfEvent": {
"$$field": "text",
"$$subfield": [
"text"
],
"$$code": "text"
},
"title": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"fallbackTitle": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"summary": {
"banners": [
{
"type": "info",
"background": "tinted",
"icon": "Archived",
"heading": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"description": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"conditionals": [
{
"type": "text",
"conditional": null
}
]
}
],
"fields": [
{
"emptyValueMessage": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"conditionals": [
{
"type": "text",
"conditional": null
}
],
"id": "text",
"value": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
}
}
]
},
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"actions": [
{
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"flags": null,
"supportingCopy": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"icon": "text",
"conditionals": null,
"type": "text",
"review": {
"title": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"fields": [
{
"id": "text",
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"parent": {
"$$field": "text",
"$$subfield": [
"text"
],
"$$code": "text"
},
"required": false,
"conditionals": [
{
"type": "text",
"conditional": null
}
],
"secured": false,
"placeholder": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"validation": [
{
"validator": null,
"message": {
"id": "text",
"defaultMessage": "text",
"description": "text"
}
}
],
"helperText": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"hideLabel": false,
"uncorrectable": false,
"value": {
"$$field": "text",
"$$subfield": [
"text"
],
"$$code": "text"
},
"analytics": false,
"type": "text",
"fields": "[Circular Reference]",
"configuration": {
"separator": "text",
"hideEmptyFields": false
}
}
]
}
}
],
"actionOrder": [
"text"
],
"advancedSearch": [
{
"title": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"fields": [
{
"config": {
"type": "fuzzy",
"searchFields": [
"text"
]
},
"type": "NAME",
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"options": [
{
"value": "text",
"label": "text",
"conditionals": [
{
"type": "text",
"conditional": null
}
]
}
],
"searchCriteriaLabelPrefix": {
"id": "text",
"defaultMessage": "text",
"description": "text"
},
"conditionals": [
{
"type": "text",
"conditional": null
}
],
"validations": [
{
"validator": null,
"message": {
"id": "text",
"defaultMessage": "text",
"description": "text"
}
}
],
"allowedLocations": {
"$jurisdiction": "administrativeArea"
},
"fieldId": "text",
"fieldType": "text"
}
]
}
],
"flags": [
{
"id": "text",
"requiresAction": true,
"label": {
"id": "text",
"defaultMessage": "text",
"description": "text"
}
}
],
"analytics": true,
"icon": {
"ANY_ADDITIONAL_PROPERTY": null
}
}Example 1 — marriage event
import { defineConfig, field, ActionType } from '@opencrvs/toolkit/events'
export const marriageEvent = defineConfig({
id: 'marriage',
label: { id: 'event.marriage.label', defaultMessage: 'Marriage', description: '' },
title: {
id: 'event.marriage.title',
defaultMessage: '{bride.name.firstname} & {groom.name.firstname}',
description: ''
},
fallbackTitle: { id: 'event.marriage.fallbackTitle', defaultMessage: 'No names provided', description: '' },
dateOfEvent: field('marriage.date'),
summary: { fields: [{ fieldId: 'marriage.date' }, { fieldId: 'marriage.placeOfMarriage' }] },
declaration: MARRIAGE_DECLARATION_FORM,
actions: [
{ type: ActionType.DECLARE, label: { id: 'event.marriage.declare', defaultMessage: 'Declare', description: '' }, review: MARRIAGE_REVIEW_FORM, form: MARRIAGE_DECLARATION_FORM },
{ type: ActionType.REGISTER, label: { id: 'event.marriage.register', defaultMessage: 'Register', description: '' }, review: MARRIAGE_REVIEW_FORM, form: MARRIAGE_DECLARATION_FORM }
]
})Example 2 — birth event with date/place references
Last updated