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,7 +202,22 @@ export const birthEvent = defineConfig({
188202 id : 'event.birth.action.detect-duplicate.label'
189203 } ,
190204 query : dedupConfig
191- }
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+ ]
192221 } ,
193222 {
194223 type : ActionType . VALIDATE ,
@@ -198,14 +227,6 @@ export const birthEvent = defineConfig({
198227 'This is shown as the action name anywhere the user can trigger the action from' ,
199228 id : 'event.birth.action.validate.label'
200229 } ,
201- review : {
202- title : {
203- defaultMessage : 'Validate' ,
204- description : 'Title of the form to show in review page' ,
205- id : 'event.birth.action.validate.form.review.title'
206- } ,
207- fields : [ ]
208- } ,
209230 deduplication : {
210231 id : 'birth-deduplication' ,
211232 label : {
@@ -225,14 +246,6 @@ export const birthEvent = defineConfig({
225246 'This is shown as the action name anywhere the user can trigger the action from' ,
226247 id : 'event.birth.action.register.label'
227248 } ,
228- review : {
229- title : {
230- defaultMessage : 'Register' ,
231- description : 'Title of the form to show in review page' ,
232- id : 'event.birth.action.register.form.review.title'
233- } ,
234- fields : [ ]
235- } ,
236249 deduplication : {
237250 id : 'birth-deduplication' ,
238251 label : {
0 commit comments