1010 */
1111import {
1212 ActionType ,
13+ and ,
1314 ConditionalType ,
1415 defineConfig ,
15- field
16+ field ,
17+ not
1618} from '@opencrvs/toolkit/events'
1719import {
1820 BIRTH_DECLARATION_FORM ,
@@ -24,6 +26,7 @@ import { BIRTH_CERTIFICATE_COLLECTOR_FORM } from './forms/printForm'
2426import { PlaceOfBirth } from './forms/pages/child'
2527import { CORRECTION_FORM } from './forms/correctionForm'
2628import { dedupConfig } from './dedupConfig'
29+ import { applicationConfig } from '@countryconfig/api/application/application-config'
2730
2831export const birthEvent = defineConfig ( {
2932 id : Event . Birth ,
@@ -45,6 +48,17 @@ export const birthEvent = defineConfig({
4548 description :
4649 'This is a fallback title if actual title resolves to empty string'
4750 } ,
51+ flags : [
52+ {
53+ id : 'approval-required-for-late-registration' ,
54+ label : {
55+ id : 'event.birth.flag.approval-required-for-late-registration' ,
56+ defaultMessage : 'Approval required for late registration' ,
57+ description : 'Flag label for approval required for late registration'
58+ } ,
59+ requiresAction : true
60+ }
61+ ] ,
4862 summary : {
4963 fields : [
5064 {
@@ -188,6 +202,47 @@ export const birthEvent = defineConfig({
188202 id : 'event.birth.action.detect-duplicate.label'
189203 } ,
190204 query : dedupConfig
205+ } ,
206+ flags : [
207+ {
208+ id : 'approval-required-for-late-registration' ,
209+ operation : 'add' ,
210+ conditional : and (
211+ not (
212+ field ( 'child.dob' )
213+ . isAfter ( )
214+ . days ( applicationConfig . BIRTH . LATE_REGISTRATION_TARGET )
215+ . inPast ( )
216+ ) ,
217+ field ( 'child.dob' ) . isBefore ( ) . now ( )
218+ )
219+ }
220+ ]
221+ } ,
222+ {
223+ type : ActionType . CUSTOM ,
224+ customActionType : 'Approve' ,
225+ label : {
226+ defaultMessage : 'Approve' ,
227+ description :
228+ 'This is shown as the action name anywhere the user can trigger the action from' ,
229+ id : 'event.birth.action.approve.label'
230+ } ,
231+ supportingCopy : {
232+ defaultMessage :
233+ 'This birth has been registered late. You are now approving it for further validation and registration.' ,
234+ description : 'This is the confirmation text for the approve action' ,
235+ id : 'event.birth.action.approve.confirmationText'
236+ } ,
237+ form : [ ] ,
238+ flags : [
239+ { id : 'approval-required-for-late-registration' , operation : 'remove' }
240+ ] ,
241+ auditHistoryLabel : {
242+ defaultMessage : 'Approved' ,
243+ description :
244+ 'The label to show in audit history for the approve action' ,
245+ id : 'event.birth.action.approve.audit-history-label'
191246 }
192247 } ,
193248 {
@@ -198,7 +253,6 @@ export const birthEvent = defineConfig({
198253 'This is shown as the action name anywhere the user can trigger the action from' ,
199254 id : 'event.birth.action.validate.label'
200255 } ,
201- review : BIRTH_DECLARATION_REVIEW ,
202256 deduplication : {
203257 id : 'birth-deduplication' ,
204258 label : {
@@ -218,7 +272,6 @@ export const birthEvent = defineConfig({
218272 'This is shown as the action name anywhere the user can trigger the action from' ,
219273 id : 'event.birth.action.register.label'
220274 } ,
221- review : BIRTH_DECLARATION_REVIEW ,
222275 deduplication : {
223276 id : 'birth-deduplication' ,
224277 label : {
0 commit comments