diff --git a/package.json b/package.json index 8cfa7e2b9..096dea5dd 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@hapi/boom": "^9.1.1", "@hapi/hapi": "^20.0.1", "@hapi/inert": "^6.0.3", - "@opencrvs/toolkit": "0.0.13-events", + "@opencrvs/toolkit": "0.0.14-events", "@types/chalk": "^2.2.0", "@types/csv2json": "^1.4.0", "@types/fhir": "^0.0.30", diff --git a/src/api/custom-event/handler.ts b/src/api/custom-event/handler.ts index 4ca319462..ff699df83 100644 --- a/src/api/custom-event/handler.ts +++ b/src/api/custom-event/handler.ts @@ -11,13 +11,13 @@ import * as Hapi from '@hapi/hapi' import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership' import { EventDocument } from '@opencrvs/toolkit/events' -import { BirthEvent } from '@countryconfig/form/V2/birth' +import { birthEvent } from '@countryconfig/form/v2/birth' export function getCustomEventsHandler( request: Hapi.Request, h: Hapi.ResponseToolkit ) { - return h.response([tennisClubMembershipEvent, BirthEvent]).code(200) + return h.response([tennisClubMembershipEvent, birthEvent]).code(200) } export function onRegisterHandler( diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts deleted file mode 100644 index 6c065b5fc..000000000 --- a/src/form/V2/birth.ts +++ /dev/null @@ -1,801 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ - -import { - defineConfig, - defineForm, - SelectOption -} from '@opencrvs/toolkit/events' -import { - defineConditional, - eventHasAction, - not, - field, - and -} from '@opencrvs/toolkit/conditionals' -import { formMessageDescriptors } from './messageDescriptors' -import { - getAddressFields, - getInformantFields, - getPersonInputFields -} from './person' -import { appendConditionalsToFields } from './utils' - -const informantTypes = { - SPOUSE: 'SPOUSE', - SON: 'SON', - DAUGHTER: 'DAUGHTER', - SON_IN_LAW: 'SON_IN_LAW', - DAUGHTER_IN_LAW: 'DAUGHTER_IN_LAW', - MOTHER: 'MOTHER', - FATHER: 'FATHER', - GRANDSON: 'GRANDSON', - GRANDDAUGHTER: 'GRANDDAUGHTER', - OTHER: 'OTHER', - GROOM: 'GROOM', - BRIDE: 'BRIDE', - GRANDFATHER: 'GRANDFATHER', - GRANDMOTHER: 'GRANDMOTHER', - BROTHER: 'BROTHER', - SISTER: 'SISTER', - OTHER_FAMILY_MEMBER: 'OTHER_FAMILY_MEMBER', - LEGAL_GUARDIAN: 'LEGAL_GUARDIAN', - HEAD_OF_GROOM_FAMILY: 'HEAD_OF_GROOM_FAMILY', - HEAD_OF_BRIDE_FAMILY: 'HEAD_OF_BRIDE_FAMILY' -} - -export const informantMessageDescriptors = { - birthInformantTitle: { - defaultMessage: 'Informant type', - description: 'Who is applying for birth registration', - id: 'register.selectInformant.birthInformantTitle' - }, - MOTHER: { - defaultMessage: 'Mother', - description: 'Label for option mother', - id: 'form.field.label.informantRelation.mother' - }, - FATHER: { - defaultMessage: 'Father', - description: 'Label for option father', - id: 'form.field.label.informantRelation.father' - }, - GRANDFATHER: { - defaultMessage: 'Grandfather', - description: 'Label for option Grandfather', - id: 'form.field.label.informantRelation.grandfather' - }, - GRANDMOTHER: { - defaultMessage: 'Grandmother', - description: 'Label for option Grandmother', - id: 'form.field.label.informantRelation.grandmother' - }, - BROTHER: { - defaultMessage: 'Brother', - description: 'Label for option brother', - id: 'form.field.label.informantRelation.brother' - }, - SISTER: { - defaultMessage: 'Sister', - description: 'Label for option Sister', - id: 'form.field.label.informantRelation.sister' - }, - OTHER_FAMILY_MEMBER: { - defaultMessage: 'Other family member', - description: 'Label for other family member relation', - id: 'form.field.label.relationOtherFamilyMember' - }, - LEGAL_GUARDIAN: { - defaultMessage: 'Legal guardian', - description: 'Label for option Legal Guardian', - id: 'form.field.label.informantRelation.legalGuardian' - }, - OTHER: { - defaultMessage: 'Someone else', - description: 'Label for option someone else', - id: 'form.field.label.informantRelation.others' - }, - deathInformantTitle: { - defaultMessage: 'Who is applying for death registration?', - description: 'Who is applying for death registration', - id: 'register.selectInformant.deathInformantTitle' - }, - SPOUSE: { - defaultMessage: 'Spouse', - description: 'Label for option Spouse', - id: 'form.field.label.informantRelation.spouse' - }, - SON: { - defaultMessage: 'Son', - description: 'Label for option Son', - id: 'form.field.label.informantRelation.son' - }, - DAUGHTER: { - defaultMessage: 'Daughter', - description: 'Label for option Daughter', - id: 'form.field.label.informantRelation.daughter' - }, - SON_IN_LAW: { - defaultMessage: 'Son in law', - description: 'Label for option Son in law', - id: 'form.field.label.informantRelation.sonInLaw' - }, - DAUGHTER_IN_LAW: { - defaultMessage: 'Daughter in law', - description: 'Label for option Daughter in law', - id: 'form.field.label.informantRelation.daughterInLaw' - }, - GRANDSON: { - defaultMessage: 'Grandson', - description: 'Label for option Grandson', - id: 'form.field.label.informantRelation.grandson' - }, - GRANDDAUGHTER: { - defaultMessage: 'Granddaughter', - description: 'Label for option Granddaughter', - id: 'form.field.label.informantRelation.granddaughter' - }, - // selectContactPoint: {}, - selectContactPoint: { - defaultMessage: 'Contact Point', - description: 'Label for option Contact point', - id: 'form.field.label.informantRelation.contactPoint' - }, - marriageInformantTitle: { - defaultMessage: 'Who is applying for marriage registration?', - description: 'Who is applying for marriage registration', - id: 'register.selectInformant.marriageInformantTitle' - }, - GROOM: { - defaultMessage: 'Groom', - description: 'Label for option groom', - id: 'form.field.label.informantRelation.groom' - }, - BRIDE: { - defaultMessage: 'Bride', - description: 'Label for option bride', - id: 'form.field.label.informantRelation.bride' - } -} - -const genderOptions: SelectOption[] = [ - { - value: 'male', - label: formMessageDescriptors.sexMale - }, - { - value: 'female', - label: formMessageDescriptors.sexFemale - }, - { - value: 'unknown', - label: formMessageDescriptors.sexUnknown - } -] - -const typeOfBirthOptions: SelectOption[] = [ - { - value: 'SINGLE', - label: formMessageDescriptors.birthTypeSingle - }, - { - value: 'TWIN', - label: formMessageDescriptors.birthTypeTwin - }, - { - value: 'TRIPLET', - label: formMessageDescriptors.birthTypeTriplet - }, - { - value: 'QUADRUPLET', - label: formMessageDescriptors.birthTypeQuadruplet - }, - { - value: 'HIGHER_MULTIPLE_DELIVERY', - label: formMessageDescriptors.birthTypeHigherMultipleDelivery - } -] - -const attendantAtBirthOptions: SelectOption[] = [ - { - value: 'PHYSICIAN', - label: formMessageDescriptors.physician - }, - { - value: 'NURSE', - label: formMessageDescriptors.attendantAtBirthNurse - }, - { - value: 'MIDWIFE', - label: formMessageDescriptors.attendantAtBirthMidwife - }, - { - value: 'OTHER_PARAMEDICAL_PERSONNEL', - label: formMessageDescriptors.attendantAtBirthOtherParamedicalPersonnel - }, - { - value: 'LAYPERSON', - label: formMessageDescriptors.attendantAtBirthLayperson - }, - { - value: 'TRADITIONAL_BIRTH_ATTENDANT', - label: formMessageDescriptors.attendantAtBirthTraditionalBirthAttendant - }, - { - value: 'NONE', - label: formMessageDescriptors.attendantAtBirthNone - } -] - -const birthInformantTypeOptions: SelectOption[] = [ - { - value: informantTypes.MOTHER, - label: informantMessageDescriptors.MOTHER - }, - { - value: informantTypes.FATHER, - label: informantMessageDescriptors.FATHER - }, - { - value: informantTypes.GRANDFATHER, - label: informantMessageDescriptors.GRANDFATHER - }, - { - value: informantTypes.GRANDMOTHER, - label: informantMessageDescriptors.GRANDMOTHER - }, - { - value: informantTypes.BROTHER, - label: informantMessageDescriptors.BROTHER - }, - { - value: informantTypes.SISTER, - label: informantMessageDescriptors.SISTER - }, - { - value: informantTypes.LEGAL_GUARDIAN, - label: informantMessageDescriptors.LEGAL_GUARDIAN - }, - { - value: informantTypes.OTHER, - label: informantMessageDescriptors.OTHER - } -] - -export const placeOfBirthOptions: SelectOption[] = [ - { - value: 'HEALTH_FACILITY', - label: formMessageDescriptors.healthInstitution - }, - { - value: 'PRIVATE_HOME', - label: formMessageDescriptors.privateHome - }, - { - value: 'OTHER', - label: formMessageDescriptors.otherInstitution - } -] -const BIRTH_FORM = defineForm({ - label: { - id: 'event.birth.action.declare.form.label', - defaultMessage: 'Birth decalration form', - description: 'This is what this form is referred as in the system' - }, - review: { - title: { - id: 'event.birth.action.declare.form.review.title', - defaultMessage: 'Birth declaration for {firstname} {surname}', - description: 'Title of the form to show in review page' - } - }, - active: true, - version: { - id: '1.0.0', - label: { - id: 'event.birth.action.declare.form.version.1', - defaultMessage: 'Version 1', - description: 'This is the first version of the form' - } - }, - pages: [ - { - id: 'introduction', - title: { - defaultMessage: - 'Introduce the birth registration process to the informant', - description: 'Event information title for the birth', - id: 'register.eventInfo.birth.title' - }, - fields: [ - { - type: 'BULLET_LIST', - id: 'form.section.information.birth.bulletList', - label: { - id: 'form.section.information.birth.bulletList.label', - defaultMessage: 'Birth Information', - description: 'Label for the birth information bullet list' - }, - items: [ - { - defaultMessage: - 'I am going to help you make a declaration of birth.', - description: 'Form information for birth', - id: 'form.section.information.birth.bullet1' - }, - { - defaultMessage: - 'As the legal Informant it is important that all the information provided by you is accurate.', - description: 'Form information for birth', - id: 'form.section.information.birth.bullet2' - }, - { - defaultMessage: - 'Once the declaration is processed you will receive an SMS to tell you when to visit the office to collect the certificate - Take your ID with you.', - description: 'Form information for birth', - id: 'form.section.information.birth.bullet3' - }, - { - defaultMessage: - 'Make sure you collect the certificate. A birth certificate is critical for this child, especially to make their life easy later on. It will help to access health services, school examinations and government benefits.', - description: 'Form information for birth', - id: 'form.section.information.birth.bullet4' - } - ], - font: 'reg16' - } - ] - }, - { - id: 'child', - title: { - defaultMessage: "Child's details", - description: 'Form section title for Child', - id: 'form.birth.child.title' - }, - fields: [ - { - id: 'child.firstname', - type: 'TEXT', - required: true, - label: { - defaultMessage: 'First name(s)', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.firstname.label' - } - }, - { - id: 'child.surname', - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Last name', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.surname.label' - } - }, - { - id: 'child.gender', - type: 'SELECT', - required: true, - label: { - defaultMessage: 'Sex', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.gender.label' - }, - options: genderOptions - }, - { - id: 'child.dob', - type: 'DATE', - required: true, - validation: [ - { - message: { - defaultMessage: 'Please enter a valid date', - description: 'This is the error message for invalid date', - id: 'event.birth.action.declare.form.section.child.field.dob.error' - }, - validator: field('child.dob').isBeforeNow() - } - ], - label: { - defaultMessage: 'Date of birth', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.dob.label' - } - }, - { - id: 'child.placeOfBirth', - type: 'SELECT', - required: true, - label: { - defaultMessage: 'Place of delivery', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.placeOfBirth.label' - }, - options: placeOfBirthOptions - }, - { - id: 'child.birthLocation', - type: 'LOCATION', - required: true, - label: { - defaultMessage: 'Health Institution', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.birthLocation.label' - }, - options: { - type: 'HEALTH_FACILITY' - }, - conditionals: [ - { - type: 'HIDE', - conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ - 'HEALTH_FACILITY' - ]) - } - ] - }, - ...appendConditionalsToFields({ - inputFields: getAddressFields('child.birthLocation'), - newConditionals: [ - { - type: 'HIDE', - conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ - 'PRIVATE_HOME' - ]) - } - ] - }), - ...appendConditionalsToFields({ - inputFields: getAddressFields('child.birthLocation'), - newConditionals: [ - { - type: 'HIDE', - conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ - 'OTHER' - ]) - } - ] - }), - { - id: 'child.attendantAtBirth', - type: 'SELECT', - required: false, - label: { - defaultMessage: 'Attendant at birth', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.attendantAtBirth.label' - }, - options: attendantAtBirthOptions - }, - { - id: 'child.birthType', - type: 'SELECT', - required: false, - label: { - defaultMessage: 'Type of birth', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.birthType.label' - }, - options: typeOfBirthOptions - }, - { - id: 'child.weightAtBirth', - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Weight at birth', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.child.field.weightAtBirth.label' - }, - options: { - type: 'number' - } - } - ] - }, - { - id: 'informant', - title: { - defaultMessage: "Informant's details", - description: 'Form section title for informants details', - id: 'form.section.informant.title' - }, - fields: [ - { - id: 'informant.relation', - type: 'SELECT', - required: true, - label: { - defaultMessage: 'Relationship to child', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.informant.field.relation.label' - }, - options: birthInformantTypeOptions - }, - ...appendConditionalsToFields({ - inputFields: getInformantFields('informant'), - newConditionals: [ - { - type: 'HIDE', - conditional: field('informant.relation').isUndefinedOrInArray([ - 'MOTHER', - 'FATHER' - ]) - } - ] - }), - { - id: 'informant.phoneNo', - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Phone number', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.informant.field.phoneNo.label' - } - }, - { - id: 'informant.email', - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Email', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.informant.field.email.label' - }, - options: { - type: 'email' - } - } - ] - }, - { - id: 'mother', - title: { - defaultMessage: "Mother's details", - description: 'Form section title for mothers details', - id: 'form.section.mother.title' - }, - fields: [ - { - id: 'mother.detailsNotAvailable', - type: 'CHECKBOX', - required: true, - label: { - defaultMessage: "Mother's details not available", - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.mother.field.detailsNotAvailable.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field('informant.relation').isInArray(['MOTHER']) - } - ] - }, - { - id: 'mother.reason', - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Reason', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.mother.field.reason.label' - }, - conditionals: [ - { - type: 'HIDE', - conditional: field( - 'mother.detailsNotAvailable' - ).isUndefinedOrInArray(['false']) - } - ] - }, - ...appendConditionalsToFields({ - inputFields: [ - ...getPersonInputFields('mother'), - { - id: 'mother.previousBirths', - type: 'TEXT', - required: false, - label: { - defaultMessage: 'No. of previous births', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.mother.field.previousBirths.label' - }, - conditionals: [] - } - ], - newConditionals: [ - { - type: 'HIDE', - conditional: and( - field('mother.detailsNotAvailable').isInArray(['true']), - field('informant.relation').isUndefinedOrNotInArray(['MOTHER']) - ) - } - ] - }) - ] - }, - { - id: 'father', - title: { - defaultMessage: "Father's details", - description: 'Form section title for fathers details', - id: 'form.section.father.title' - }, - fields: [ - { - id: 'father.detailsNotAvailable', - type: 'CHECKBOX', - required: true, - label: { - defaultMessage: "Father's details not available", - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.father.field.detailsNotAvailable.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field('informant.relation').isInArray(['FATHER']) - } - ] - }, - { - id: 'father.reason', - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Reason', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.father.field.reason.label' - }, - conditionals: [ - { - type: 'HIDE', - conditional: field( - 'father.detailsNotAvailable' - ).isUndefinedOrInArray(['false']) - } - ] - }, - ...appendConditionalsToFields({ - inputFields: getPersonInputFields('father'), - newConditionals: [ - { - type: 'HIDE', - conditional: and( - field('father.detailsNotAvailable').isInArray(['true']), - field('informant.relation').isUndefinedOrNotInArray(['FATHER']) - ) - } - ] - }) - ] - }, - { - id: 'documents', - title: { - defaultMessage: 'Upload supporting documents', - description: 'Form section title for documents', - id: 'form.section.documents.title' - }, - fields: [ - { - id: `documents.helper`, - type: 'PARAGRAPH', - label: { - defaultMessage: 'The following documents are required', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.documents.field.helper.label` - }, - options: { fontVariant: 'reg16' }, - conditionals: [] - }, - { - id: 'documents.proofOfBirth', - type: 'FILE', - required: false, - label: { - defaultMessage: 'Proof of birth', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.documents.field.proofOfBirth.label' - } - }, - { - id: 'documents.proofOfMother', - type: 'FILE', // @ToDo File upload with options - required: false, - label: { - defaultMessage: "Proof of mother's ID", - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.documents.field.proofOfMother.label' - } - }, - - { - id: 'documents.proofOfFather', - type: 'FILE', // @ToDo File upload with options - required: false, - label: { - defaultMessage: "Proof of father's ID", - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.documents.field.proofOfFather.label' - } - }, - - { - id: 'documents.proofOther', - type: 'FILE', // @ToDo File upload with options - required: false, - label: { - defaultMessage: 'Other', - description: 'This is the label for the field', - id: 'event.birth.action.declare.form.section.documents.field.proofOther.label' - } - } - ] - } - ] -}) - -export const BirthEvent = defineConfig({ - id: 'BIRTH', - label: { - defaultMessage: 'Birth declaration', - description: 'This is what this event is referred as in the system', - id: 'event.birth.label' - }, - summary: { - title: { - defaultMessage: '{applicant.firstname} {applicant.surname}', - description: 'This is the title of the summary', - id: 'event.birth.summary.title' - }, - fields: [] - }, - workqueues: [ - { - id: 'all', - title: { - defaultMessage: 'All birth events', - description: 'Label for all birth events workqueue', - id: 'event.birth.workqueue.all.label' - }, - fields: [ - { - id: 'child.firstname' - }, - { - id: 'child.surname' - } - ], - filters: [] - } - ], - actions: [ - { - type: 'DECLARE', - label: { - defaultMessage: 'Declare', - description: - 'This is shown as the action name anywhere the user can trigger the action from', - id: 'event.birth.action.declare.label' - }, - forms: [BIRTH_FORM], - allowedWhen: defineConditional(not(eventHasAction('DECLARE'))) - } - ] -}) diff --git a/src/form/V2/messageDescriptors.ts b/src/form/V2/messageDescriptors.ts deleted file mode 100644 index 2284cef85..000000000 --- a/src/form/V2/messageDescriptors.ts +++ /dev/null @@ -1,800 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ - -export const formMessageDescriptors = { - primaryAddress: { - defaultMessage: 'Usual place of residence', - description: 'Title of the primary adress', - id: 'form.field.label.primaryAddress' - }, - spouseSectionName: { - defaultMessage: 'Spouse details', - description: 'Title of the spouse section', - id: 'form.section.deceased.spouse.title' - }, - informantSecondaryAddress: { - defaultMessage: 'Secondary Address', - description: 'Title for the secondary address fields for the informant', - id: 'form.field.label.informantSecondaryAddress' - }, - secondaryAddress: { - defaultMessage: 'Secondary Address', - description: 'Title for the secondary address fields', - id: 'form.field.label.secondaryAddress' - }, - primaryAddressSameAsOtherPrimary: { - defaultMessage: "Same as mother's usual place of residence?", - description: - "Title for the radio button to select that the persons primary address is the same as the mother's primary address", - id: 'form.field.label.primaryAddressSameAsOtherPrimary' - }, - deceasedPrimaryAddress: { - defaultMessage: 'Usual place of residence', - description: 'Title for the primary address fields for the deceased', - id: 'form.field.label.deceasedPrimaryAddress' - }, - deceasedSecondaryAddress: { - defaultMessage: 'Secondary address?', - description: 'Title for the secondary address fields for the deceased', - id: 'form.field.label.deceasedSecondaryAddress' - }, - primaryAddressSameAsDeceasedsPrimary: { - defaultMessage: "Same as deceased's usual place of residence", - description: - "Label for informant's address to be same as deceased's usual place of residence", - id: 'form.field.label.primaryAddressSameAsDeceasedsPrimary' - }, - informantPrimaryAddress: { - defaultMessage: 'Usual place of residence', - description: 'Title for the primary address fields for the informant', - id: 'form.field.label.informantPrimaryAddress' - }, - attendantAtBirth: { - defaultMessage: 'Attendant at birth', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirth' - }, - formSelectPlaceholder: { - defaultMessage: 'Select', - description: 'Placeholder text for a select', - id: 'form.field.select.placeholder' - }, - physician: { - defaultMessage: 'Physician', - description: 'Label for form field: physician', - id: 'form.field.label.physician' - }, - attendantAtBirthNurse: { - defaultMessage: 'Nurse', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirthNurse' - }, - attendantAtBirthMidwife: { - defaultMessage: 'Midwife', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirthMidwife' - }, - attendantAtBirthOtherParamedicalPersonnel: { - defaultMessage: 'Other paramedical personnel', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attBirthOtherParaPers' - }, - attendantAtBirthLayperson: { - defaultMessage: 'Layperson', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirthLayperson' - }, - attendantAtBirthTraditionalBirthAttendant: { - defaultMessage: 'Traditional birth attendant', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirthTraditionalBirthAttendant' - }, - attendantAtBirthNone: { - defaultMessage: 'None', - description: 'Label for form field: Attendant at birth', - id: 'form.field.label.attendantAtBirthNone' - }, - birthTypeSingle: { - defaultMessage: 'Single', - description: 'Label for form field: Type of birth', - id: 'form.field.label.birthTypeSingle' - }, - birthTypeTwin: { - defaultMessage: 'Twin', - description: 'Label for form field: Type of birth', - id: 'form.field.label.birthTypeTwin' - }, - birthTypeTriplet: { - defaultMessage: 'Triplet', - description: 'Label for form field: Type of birth', - id: 'form.field.label.birthTypeTriplet' - }, - birthTypeQuadruplet: { - defaultMessage: 'Quadruplet', - description: 'Label for form field: Type of birth', - id: 'form.field.label.birthTypeQuadruplet' - }, - birthTypeHigherMultipleDelivery: { - defaultMessage: 'Higher multiple delivery', - description: 'Label for form field: Type of birth', - id: 'form.field.label.birthTypeHigherMultipleDelivery' - }, - weightAtBirth: { - defaultMessage: 'Weight at birth', - description: 'Label for form field: Weight at birth', - id: 'form.field.label.weightAtBirth' - }, - phoneNumber: { - defaultMessage: 'Phone number', - description: 'Input label for phone input', - id: 'form.field.label.phoneNumber' - }, - email: { - defaultMessage: 'Email', - description: 'Input label for email', - id: 'form.field.label.email' - }, - // email: {}, - iDTypeNationalID: { - defaultMessage: 'National ID number (in English)', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNationalID' - }, - nidVerified: { - defaultMessage: 'Authenticated', - description: 'label for unverified nid state', - id: 'form.field.nidVerified' - }, - nidNotVerified: { - defaultMessage: 'Authenticate', - description: 'label for verified nid state', - id: 'form.field.nidNotVerified' - }, - nidOffline: { - defaultMessage: - 'National ID authentication is currently not available offline.', - description: - 'Label for indicating offline status for the user. NID verification is not currently available offline.', - id: 'form.field.nidVerificationOngoing' - }, - educationAttainment: { - defaultMessage: 'Level of education', - description: 'Label for form field: Education Attainment', - id: 'form.field.label.educationAttainment' - }, - nameInEnglishPreviewGroup: { - defaultMessage: 'Full name', - description: 'Label for child name in english', - id: 'form.preview.group.label.english.name' - }, - dateOfBirth: { - defaultMessage: 'Date of birth', - description: 'Label for form field: Date of birth', - id: 'form.field.label.dateOfBirth' - }, - sex: { - defaultMessage: 'Sex', - description: 'Label for form field: Sex name', - id: 'form.field.label.sex' - }, - sexMale: { - defaultMessage: 'Male', - description: 'Option for form field: Sex name', - id: 'form.field.label.sexMale' - }, - sexFemale: { - defaultMessage: 'Female', - description: 'Option for form field: Sex name', - id: 'form.field.label.sexFemale' - }, - sexUnknown: { - defaultMessage: 'Unknown', - description: 'Option for form field: Sex name', - id: 'form.field.label.sexUnknown' - }, - familyName: { - defaultMessage: 'Last name', - description: 'Label for family name text input', - id: 'form.field.label.familyName' - }, - nationality: { - defaultMessage: 'Nationality', - description: 'Label for form field: Nationality', - id: 'form.field.label.nationality' - }, - previewName: { - defaultMessage: 'Preview', - description: 'Form section name for Preview', - id: 'register.form.section.preview.name' - }, - previewTitle: { - defaultMessage: 'Preview', - description: 'Form section title for Preview', - id: 'register.form.section.preview.title' - }, - reviewName: { - defaultMessage: 'Review', - description: 'Form section name for Review', - id: 'review.form.section.review.name' - }, - reviewTitle: { - defaultMessage: 'Review', - description: 'Form section title for Review', - id: 'review.form.section.review.title' - }, - placeOfBirthPreview: { - defaultMessage: 'Place of delivery', - description: 'Title for place of birth sub section', - id: 'form.field.label.placeOfBirthPreview' - }, - placeOfBirth: { - defaultMessage: 'Location', - description: 'Label for form field: Place of delivery', - id: 'form.field.label.placeOfBirth' - }, - healthInstitution: { - defaultMessage: 'Health Institution', - description: 'Select item for Health Institution', - id: 'form.field.label.healthInstitution' - }, - privateHome: { - defaultMessage: 'Residential address', - description: 'Select item for Private Home', - id: 'form.field.label.privateHome' - }, - otherInstitution: { - defaultMessage: 'Other', - description: 'Select item for Other location', - id: 'form.field.label.otherInstitution' - }, - informantsRelationWithChild: { - defaultMessage: 'Relationship to child', - description: 'Label for Relationship to child', - id: 'form.field.label.informantsRelationWithChild' - }, - relationshipPlaceHolder: { - defaultMessage: 'eg. Grandmother', - description: 'Relationship place holder', - id: 'form.field.label.relationshipPlaceHolder' - }, - reasonNA: { - defaultMessage: 'Reason', - description: 'Label for form field: reasonNotApplying', - id: 'form.field.label.reasonNotApplying' - }, - childTab: { - defaultMessage: 'Child', - description: 'Form section name for Child', - id: 'form.section.child.name' - }, - childTitle: { - defaultMessage: "Child's details", - description: 'Form section title for Child', - id: 'form.section.child.title' - }, - birthInformantTitle: { - defaultMessage: "Informant's details?", - description: 'Form section title for informants', - id: 'form.section.informant.title' - }, - ageOfInformant: { - defaultMessage: 'Age of informant', - description: 'Label for form field: Age of informant', - id: 'form.field.label.ageOfInformant' - }, - ageOfSpouse: { - defaultMessage: 'Age of spouse', - description: 'Label for form field: Age of spouse', - id: 'form.field.label.ageOfSpouse' - }, - motherName: { - defaultMessage: 'Mother', - description: 'Form section name for Mother', - id: 'form.section.mother.name' - }, - motherTitle: { - defaultMessage: "Mother's details", - description: 'Form section title for Mother', - id: 'form.section.mother.title' - }, - mothersDetailsExist: { - defaultMessage: "Mother's details are not available", - description: "Question to ask the user if they have the mother's details", - id: 'form.field.label.mothersDetailsExist' - }, - spouseDetailsExist: { - defaultMessage: "Spouse's details are not available", - description: "Question to ask the user if they have the spouse's details", - id: 'form.field.label.spouseDetailsExist' - }, - ageOfMother: { - defaultMessage: 'Age of mother', - description: 'Label for form field: Age of mother', - id: 'form.field.label.ageOfMother' - }, - fathersDetailsExist: { - defaultMessage: "Father's details are not available", - description: "Question to ask the user if they have the father's details", - id: 'form.field.label.fathersDetailsExist' - }, - ageOfFather: { - defaultMessage: 'Age of father', - description: 'Label for form field: Age of father', - id: 'form.field.label.ageOfFather' - }, - documentsName: { - defaultMessage: 'Documents', - description: 'Form section name for Documents', - id: 'form.section.documents.name' - }, - documentsParagraph: { - defaultMessage: 'The following documents are required', - description: 'Documents Paragraph text', - id: 'form.section.documents.birth.requirements' - }, - proofOfBirth: { - defaultMessage: 'Proof of birth', - description: 'Label for list item Proof of birth', - id: 'form.field.label.proofOfBirth' - }, - docTypeChildBirthProof: { - defaultMessage: 'Notification of birth', - description: 'Label for select option Notification of birth', - id: 'form.field.label.docTypeChildBirthProof' - }, - proofOfMothersID: { - defaultMessage: "Mother's identity", - description: 'Label for list item Mother ID Proof', - id: 'form.field.label.proofOfMothersID' - }, - docTypeNID: { - defaultMessage: 'National ID', - description: 'Label for select option radio option NID', - id: 'form.field.label.docTypeNID' - }, - docTypePassport: { - defaultMessage: 'Passport', - description: 'Label for radio option Passport', - id: 'form.field.label.docTypePassport' - }, - docTypeBirthCert: { - defaultMessage: 'Birth certificate', - description: 'Label for select option birth certificate', - id: 'form.field.label.docTypeBirthCert' - }, - docTypeOther: { - defaultMessage: 'Other', - description: 'Label for radio option Other', - id: 'form.field.label.docTypeOther' - }, - proofOfFathersID: { - defaultMessage: "Father's identity", - description: 'Label for list item Father ID Proof', - id: 'form.field.label.proofOfFathersID' - }, - proofOfInformantsID: { - defaultMessage: "Proof of informant's ID", - description: 'Option for radio group field: Type of Document To Upload', - id: 'form.field.label.proofOfInformantsID' - }, - otherBirthSupportingDocuments: { - defaultMessage: 'Other', - description: 'Option for other supporting documents', - id: 'form.field.label.otherBirthSupportingDocuments' - }, - legalGuardianProof: { - defaultMessage: 'Proof of legal guardianship', - description: 'Label for document option Proof of legal guardianship', - id: 'form.field.label.legalGuardianProof' - }, - assignedResponsibilityProof: { - defaultMessage: 'Proof of assigned responsibility', - description: 'Label for docuemnt option Proof of assigned responsibility', - id: 'form.field.label.assignedResponsibilityProof' - }, - // registrationName: {}, - // registrationTitle: {}, - registrationName: { - defaultMessage: 'Registration Name', - description: 'Label for registration name', - id: 'form.field.label.registrationName' - }, - informantTitle: { - defaultMessage: "Informant's details", - description: 'Label for informant details', - id: 'form.field.label.informantTitle' - }, - reviewLabelMainContact: { - defaultMessage: 'Main Contact', - description: 'Label for point of contact on the review page', - id: 'form.review.label.mainContact' - }, - selectContactPoint: { - defaultMessage: 'Who is the main point of contact for this declaration?', - description: 'Form section title for contact point', - id: 'register.SelectContactPoint.heading' - }, - deceasedName: { - defaultMessage: 'Deceased', - description: 'Form section name for Deceased', - id: 'form.section.deceased.name' - }, - relationshipToDeceased: { - defaultMessage: 'Relationship to deceased', - description: 'Relationship of applicant to the deceased person', - id: 'form.section.deceased.relationship' - }, - deceasedTitle: { - defaultMessage: 'What are the deceased details?', - description: 'Form section title for Deceased', - id: 'form.section.deceased.title' - }, - ageOfDeceased: { - defaultMessage: 'Age of deceased', - description: 'Label for form field: Age of deceased', - id: 'form.field.label.ageOfDeceased' - }, - firstName: { - defaultMessage: 'First name', - description: "Input label for certificate collector's first name", - id: 'form.field.label.firstName' - }, - maritalStatus: { - defaultMessage: 'Marital status', - description: 'Label for form field: Marital status', - id: 'form.field.label.maritalStatus' - }, - deathEventName: { - defaultMessage: 'Death event details', - description: 'Form section name for Death Event', - id: 'form.section.deathEvent.name' - }, - deathEventTitle: { - defaultMessage: 'Death details?', - description: 'Form section title for Death Event', - id: 'form.section.deathEvent.title' - }, - deathEventDate: { - defaultMessage: 'Date of death', - description: 'Form section title for date of Death Event', - id: 'form.section.deathEvent.date' - }, - manner: { - defaultMessage: 'Manner of death', - description: 'Label for form field: Manner of death', - id: 'form.field.label.mannerOfDeath' - }, - mannerNatural: { - defaultMessage: 'Natural causes', - description: 'Option for form field: Manner of death', - id: 'form.field.label.mannerOfDeathNatural' - }, - mannerAccident: { - defaultMessage: 'Accident', - description: 'Option for form field: Manner of death', - id: 'form.field.label.mannerOfDeathAccident' - }, - mannerSuicide: { - defaultMessage: 'Suicide', - description: 'Option for form field: Manner of death', - id: 'form.field.label.mannerOfDeathSuicide' - }, - mannerHomicide: { - defaultMessage: 'Homicide', - description: 'Option for form field: Manner of death', - id: 'form.field.label.mannerOfDeathHomicide' - }, - mannerUndetermined: { - defaultMessage: 'Manner undetermined', - description: 'Option for form field: Manner of death', - id: 'form.field.label.mannerOfDeathUndetermined' - }, - causeOfDeathEstablished: { - defaultMessage: 'Cause of death has been established', - description: 'Label for form field: Cause of Death Established', - id: 'form.field.label.causeOfDeathEstablished' - }, - causeOfDeathMethod: { - defaultMessage: 'Source of cause of death', - description: 'Source of cause of death', - id: 'form.field.label.causeOfDeathMethod' - }, - layReported: { - defaultMessage: 'Lay reported', - description: 'Label for form field: Lay reported', - id: 'form.field.label.layReported' - }, - verbalAutopsy: { - defaultMessage: 'Verbal autopsy', - description: 'Option for form field: verbalAutopsy', - id: 'form.field.label.verbalAutopsy' - }, - medicallyCertified: { - defaultMessage: 'Medically Certified Cause of Death', - description: 'Option for form field: Method of Cause of Death', - id: 'form.field.label.medicallyCertified' - }, - deathDescription: { - defaultMessage: 'Description', - description: - 'Description of cause of death by lay person or verbal autopsy', - id: 'form.field.label.deathDescription' - }, - placeOfDeath: { - defaultMessage: 'Where did the death occur?', - description: 'Label for form field: Place of occurrence of death', - id: 'form.field.label.placeOfDeath' - }, - placeOfDeathSameAsPrimary: { - defaultMessage: "Deceased's usual place of residence", - description: - 'Option for place of occurrence of death same as deceased primary address ', - id: 'form.field.label.placeOfDeathSameAsPrimary' - }, - informantName: { - defaultMessage: 'Informant', - description: 'Form section name for Informant', - id: 'form.section.informant.name' - }, - deathInformantTitle: { - defaultMessage: "Informant's details?", - description: 'Form section title for informants', - id: 'form.section.informant.title' - }, - documentsTitle: { - defaultMessage: 'Attach supporting documents', - description: 'Form section title for Documents', - id: 'form.section.documents.title' - }, - deceasedParagraph: { - defaultMessage: - 'For this death registration, the following documents are required:', - description: 'Documents Paragraph text', - id: 'form.field.label.deceasedDocumentParagraph' - }, - deceasedIDProof: { - defaultMessage: "Proof of deceased's ID", - description: 'Option for radio group field: Type of Document To Upload', - id: 'form.field.label.deceasedIDProof' - }, - deceasedDeathProof: { - defaultMessage: 'Proof of death of deceased', - description: 'Option for radio group field: Type of Document To Upload', - id: 'form.field.label.deceasedDeathProof' - }, - docTypeLetterOfDeath: { - defaultMessage: 'Attested letter of death', - description: 'Label for select option Attested Letter of Death', - id: 'form.field.label.docTypeLetterOfDeath' - }, - docTypePoliceCertificate: { - defaultMessage: 'Police certificate of death', - description: 'Label for select option Police death certificate', - id: 'form.field.label.docTypePoliceCertificate' - }, - docTypeHospitalDeathCertificate: { - defaultMessage: 'Hospital certificate of death', - description: 'Label for select option Hospital certificate of death', - id: 'form.field.label.docTypeHospitalDeathCertificate' - }, - docTypeCoronersReport: { - defaultMessage: "Coroner's report", - description: "Label for select option Coroner's report", - id: 'form.field.label.docTypeCoronersReport' - }, - docTypeCopyOfBurialReceipt: { - defaultMessage: 'Certified copy of burial receipt', - description: 'Label for select option Certified Copy of Burial Receipt', - id: 'form.field.label.docTypeCopyOfBurialReceipt' - }, - causeOfDeathProof: { - defaultMessage: 'Proof of cause of death', - description: 'Label for doc section: Proof of cause of death', - id: 'form.field.label.causeOfDeathProof' - }, - verbalAutopsyReport: { - defaultMessage: 'Verbal autopsy report', - description: 'Option for form field: verbalAutopsyReport', - id: 'form.field.label.verbalAutopsyReport' - }, - groomName: { - defaultMessage: 'Groom', - description: 'Form section name for Groom', - id: 'form.section.groom.name' - }, - groomTitle: { - defaultMessage: "Groom's details", - description: 'Form section title for Groom', - id: 'form.section.groom.title' - }, - ageOfGroom: { - defaultMessage: 'Age of groom', - description: 'Label for form field: Age of groom', - id: 'form.field.label.ageOfGroom' - }, - marriedLastName: { - defaultMessage: 'Married Last name (if different)', - description: 'Label for married last name text input', - id: 'form.field.label.marriedLastName' - }, - lastNameAtBirth: { - defaultMessage: 'Last name at birth (if different from above)', - description: 'Label for a different last name text input', - id: 'form.field.label.lastNameAtBirth' - }, - brideName: { - defaultMessage: 'Bride', - description: 'Form section name for Bride', - id: 'form.section.bride.name' - }, - brideTitle: { - defaultMessage: "Bride's details", - description: 'Form section title for Bride', - id: 'form.section.bride.title' - }, - ageOfBride: { - defaultMessage: 'Age of bride', - description: 'Label for form field: Age of bride', - id: 'form.field.label.ageOfBride' - }, - marriageEventName: { - defaultMessage: 'Marriage event details', - description: 'Form section name for Marriage Event', - id: 'form.section.marriageEvent.name' - }, - marriageEventTitle: { - defaultMessage: 'Marriage details?', - description: 'Form section title for Marriage Event', - id: 'form.section.marriageEvent.title' - }, - marriageEventDate: { - defaultMessage: 'Date of marriage', - description: 'Form section title for date of Marriage Event', - id: 'form.section.marriageEvent.date' - }, - typeOfMarriage: { - defaultMessage: 'Type of marriage', - description: 'Option for form field: Type of marriage', - id: 'form.field.label.typeOfMarriage' - }, - monogamy: { - defaultMessage: 'Monogamous', - description: 'Option for form field: Monogamy', - id: 'form.field.label.monogamy' - }, - polygamy: { - defaultMessage: 'Polygamous', - description: 'Option for form field: Polygamy', - id: 'form.field.label.polygamy' - }, - placeOfMarriage: { - defaultMessage: 'Place of marriage', - description: 'Label for form field: Place of occurrence of marriage', - id: 'form.field.label.placeOfMarriage' - }, - witnessOneName: { - defaultMessage: 'Witness 1', - description: 'Form section name for Witness one', - id: 'form.section.witnessOne.name' - }, - witnessTwoName: { - defaultMessage: 'Witness 2', - description: 'Form section name for Witness two', - id: 'form.section.witnessTwo.name' - }, - witnessOneTitle: { - defaultMessage: 'What are the witnesses one details?', - description: 'Form section title for witnesses', - id: 'form.section.witnessOne.title' - }, - relationshipToSpouses: { - defaultMessage: 'Relationship to spouses', - description: "Input label for witness's relationship with spouses", - id: 'form.field.label.relationshipToSpouses' - }, - headOfGroomFamily: { - defaultMessage: "Head of groom's family", - description: 'Form select option for witness relationship', - id: 'form.section.groom.headOfGroomFamily' - }, - other: { - defaultMessage: 'Other', - description: 'Option for form field: Other', - id: 'form.field.label.other' - }, - witnessTwoTitle: { - defaultMessage: 'What are the witnesses two details?', - description: 'Form section title for witnesses', - id: 'form.section.witnessTwo.title' - }, - headOfBrideFamily: { - defaultMessage: "Head of bride's family", - description: 'Form select option for witness relationship', - id: 'form.section.bride.headOfBrideFamily' - }, - proofOfMarriageNotice: { - defaultMessage: 'Notice of intention to marriage', - description: 'Label for list item notice of marriage', - id: 'form.field.label.proofOfMarriageNotice' - }, - docTypeMarriageNotice: { - defaultMessage: 'Notice of marriage', - description: 'Label for document section for marriage notice', - id: 'form.field.label.docTypeMarriageNotice' - }, - proofOfGroomsID: { - defaultMessage: "Proof of Groom's identity", - description: 'Label for list item Groom ID Proof', - id: 'form.field.label.proofOfGroomsID' - }, - proofOfBridesID: { - defaultMessage: "Proof of Bride's identity", - description: 'Label for list item Bride ID Proof', - id: 'form.field.label.proofOfBridesID' - }, - iDTypePassport: { - defaultMessage: 'Passport', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypePassport' - }, - iDTypeDrivingLicense: { - defaultMessage: 'Drivers License', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeDrivingLicense' - }, - iDTypeBRN: { - defaultMessage: 'Birth registration number (in English)', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeBRN' - }, - iDTypeRefugeeNumber: { - defaultMessage: 'Refugee Number', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeRefugeeNumber' - }, - iDTypeAlienNumber: { - defaultMessage: 'Alien Number', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeAlienNumber' - }, - iDTypeNoId: { - defaultMessage: 'No ID available', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNoID' - }, - iDTypeOther: { - defaultMessage: 'Other', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeOther' - }, - helperTextNID: { - defaultMessage: - 'The National ID can only be numeric and must be 10 digits long', - description: 'Helper text for nid input field', - id: 'form.field.helpertext.nid' - }, - tooltipNationalID: { - defaultMessage: - 'The National ID can only be numeric and must be 10 digits long', - description: 'Tooltip for form field: iD number', - id: 'form.field.tooltip.tooltipNationalID' - }, - iD: { - defaultMessage: 'ID Number', - description: 'Label for form field: ID Number', - id: 'form.field.label.iD' - }, - iDTypeDRN: { - defaultMessage: 'Death Registration Number', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeDRN' - } -} diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts deleted file mode 100644 index 9d797adb2..000000000 --- a/src/form/V2/person.ts +++ /dev/null @@ -1,620 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ - -import { FieldConfig, SelectOption } from '@opencrvs/toolkit/events' -import { field } from '@opencrvs/toolkit/conditionals' -import { appendConditionalsToFields } from './utils' - -const idTypeOptions: SelectOption[] = [ - { - value: 'NATIONAL_ID' as const, - label: { - defaultMessage: 'National ID', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNationalID' - } - }, - { - value: 'PASSPORT' as const, - label: { - defaultMessage: 'Passport', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypePassport' - } - }, - { - value: 'BIRTH_REGISTRATION_NUMBER' as const, - label: { - defaultMessage: 'Birth Registration Number', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeBRN' - } - }, - { - value: 'NONE' as const, - label: { - defaultMessage: 'None', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNone' - } - } -] - -export const getInformantFields = (person: string): FieldConfig[] => [ - { - id: `${person}.firstname`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'First name(s)', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.firstname.label` - }, - conditionals: [] - }, - { - id: `${person}.surname`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Last name', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.surname.label` - }, - conditionals: [] - }, - { - id: `${person}.dob`, - type: 'DATE', - required: true, - validation: [ - { - message: { - defaultMessage: 'Please enter a valid date', - description: 'This is the error message for invalid date', - id: `event.birth.action.declare.form.section.${person}.field.dob.error` - }, - validator: field(`${person}.dob`).isBeforeNow() - } - ], - label: { - defaultMessage: 'Date of birth', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.dob.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.dobUnknown`).isEqualTo('true') - } - ] - }, - { - id: `${person}.dobUnknown`, - type: 'CHECKBOX', - required: true, - label: { - defaultMessage: 'Exact date of birth unknown', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.age.label` - }, - conditionals: [] - }, - { - id: `${person}.age`, - type: 'TEXT', - required: true, - label: { - defaultMessage: `Age of ${person}`, - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.age.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.dobUnknown`).isUndefinedOrInArray([ - 'false' - ]) - } - ] - }, - { - id: `${person}.nationality`, - type: 'COUNTRY', - required: true, - label: { - defaultMessage: 'Nationality', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.nationality.label` - }, - conditionals: [] - }, - ...getIdFields(person), - { - id: `${person}.addressHelper`, - type: 'PARAGRAPH', - label: { - defaultMessage: 'Usual place of residence', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.addressHelper.label` - }, - options: { fontVariant: 'h3' }, - conditionals: [] - }, - ...getAddressFields(person) -] - -export const getPersonInputFields = (person: string): FieldConfig[] => [ - ...getInformantFields(person), - { - id: `${person}.maritalStatus`, - type: 'SELECT', - required: false, - label: { - defaultMessage: 'Marital Status', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.maritalStatus.label` - }, - options: maritalStatusOptions, - conditionals: [] - }, - { - id: `${person}.educationalAttainment`, - type: 'SELECT', - required: false, - label: { - defaultMessage: 'Level of education', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.educationalAttainment.label` - }, - options: educationalAttainmentOptions, - conditionals: [] - }, - { - id: `${person}.occupation`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Occupation', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.occupation.label` - }, - conditionals: [] - } -] - -const getIdFields = (person: string): FieldConfig[] => [ - { - id: `${person}.idType`, - type: 'SELECT', - required: true, - label: { - defaultMessage: 'Type of ID', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.idType.label` - }, - options: idTypeOptions, - conditionals: [] - }, - { - id: `${person}.nid`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'ID Number', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.nid.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ - 'NATIONAL_ID' - ]) - } - ] - }, - { - id: `${person}.passport`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'ID Number', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.passport.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ - 'PASSPORT' - ]) - } - ] - }, - { - id: `${person}.brn`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'ID Number', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.brn.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ - 'BIRTH_REGISTRATION_NUMBER' - ]) - } - ] - } -] - -const urbanRuralRadioOptions: SelectOption[] = [ - { - label: { - defaultMessage: 'Urban', - id: 'form.field.label.urban', - description: 'Label for form field checkbox option Urban' - }, - value: 'URBAN' - }, - { - label: { - defaultMessage: 'Rural', - id: 'form.field.label.rural', - description: 'Label for form field checkbox option Rural' - }, - value: 'RURAL' - } -] - -export const getAddressFields = (person: string): FieldConfig[] => { - // @Todo: Same as mother or deseased - const prefix = `${person}.address` - - const genericAddressFields: FieldConfig[] = [ - { - id: `${prefix}.other.state`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'State', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.state.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.district`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'District', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.district.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.town`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'City / Town', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.town.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.addressLine1`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Address Line 1', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine1.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.addressLine2`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Address Line 2', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine2.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.addressLine3`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Address Line 3', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine3.label` - }, - conditionals: [] - }, - { - id: `${prefix}.other.zipCode`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Postcode / Zip', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.other.zipCode.label` - }, - conditionals: [] - } - ] - - const urbanAddressFields: FieldConfig[] = [ - { - id: `${prefix}.town`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Town', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.town.label` - }, - conditionals: [] - }, - { - id: `${prefix}.residentialArea`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Residential Area', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.residentialArea.label` - }, - conditionals: [] - }, - { - id: `${prefix}.street`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Street', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.street.label` - }, - conditionals: [] - }, - { - id: `${prefix}.number`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Number', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.number.label` - }, - conditionals: [] - }, - { - id: `${prefix}.zipCode`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Postcode / Zip', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.zipCode.label` - }, - conditionals: [] - } - ] - const farajalandAddressFields: FieldConfig[] = [ - { - id: `${prefix}.province`, - type: 'LOCATION', - required: true, - label: { - defaultMessage: 'Province', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.province.label` - }, - options: { - type: 'ADMIN_STRUCTURE' - }, - conditionals: [] - }, - { - id: `${prefix}.district`, - type: 'LOCATION', - required: true, - label: { - defaultMessage: 'District', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.district.label` - }, - options: { - partOf: { - $data: `${prefix}.province` - }, - type: 'ADMIN_STRUCTURE' - }, - conditionals: [] - }, - { - id: `${prefix}.urbanOrRural`, - type: 'RADIO_GROUP', - options: urbanRuralRadioOptions, - flexDirection: 'row', - required: false, - label: { - defaultMessage: 'Urban or Rural', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.urbanOrRural.label` - }, - conditionals: [] - }, - ...appendConditionalsToFields({ - inputFields: urbanAddressFields, - newConditionals: [ - { - type: 'HIDE', - conditional: field(`${prefix}.urbanOrRural`).isUndefinedOrInArray([ - 'RURAL' - ]) - } - ] - }), - { - id: `${prefix}.village`, - type: 'TEXT', - required: false, - label: { - defaultMessage: 'Village', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.village.label` - }, - conditionals: [ - { - type: 'HIDE', - conditional: field(`${prefix}.urbanOrRural`).isUndefinedOrInArray([ - 'URBAN' - ]) - } - ] - } - ] - - return [ - { - id: `${prefix}.country`, - type: 'COUNTRY', - required: true, - label: { - defaultMessage: 'Country', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.country.label` - }, - conditionals: [] - }, - ...appendConditionalsToFields({ - inputFields: genericAddressFields, - newConditionals: [ - { - type: 'HIDE', - conditional: field(`${person}.address.country`).isUndefinedOrInArray([ - 'FAR' - ]) - } - ] - }), - ...appendConditionalsToFields({ - inputFields: farajalandAddressFields, - newConditionals: [ - { - type: 'HIDE', - conditional: field( - `${person}.address.country` - ).isUndefinedOrNotInArray(['FAR']) - } - ] - }) - ] -} - -export const maritalStatusOptions: SelectOption[] = [ - { - value: 'SINGLE', - label: { - defaultMessage: 'Single', - description: 'Option for form field: Marital status', - id: 'form.field.label.maritalStatusSingle' - } - }, - { - value: 'MARRIED', - label: { - defaultMessage: 'Married', - description: 'Option for form field: Marital status', - id: 'form.field.label.maritalStatusMarried' - } - }, - { - value: 'WIDOWED', - label: { - defaultMessage: 'Widowed', - description: 'Option for form field: Marital status', - id: 'form.field.label.maritalStatusWidowed' - } - }, - { - value: 'DIVORCED', - label: { - defaultMessage: 'Divorced', - description: 'Option for form field: Marital status', - id: 'form.field.label.maritalStatusDivorced' - } - }, - { - value: 'SEPARATED', - label: { - id: 'form.field.label.maritalStatusSeparated', - defaultMessage: 'Separated', - description: 'Option for form field: Marital status' - } - }, - { - value: 'NOT_STATED', - label: { - defaultMessage: 'Not stated', - description: 'Option for form field: Marital status', - id: 'form.field.label.maritalStatusNotStated' - } - } -] - -export const educationalAttainmentOptions: SelectOption[] = [ - { - value: 'NO_SCHOOLING', - label: { - defaultMessage: 'No schooling', - description: 'Option for form field: no education', - id: 'form.field.label.educationAttainmentNone' - } - }, - { - value: 'PRIMARY_ISCED_1', - label: { - defaultMessage: 'Primary', - description: 'Option for form field: ISCED1 education', - id: 'form.field.label.educationAttainmentISCED1' - } - }, - { - value: 'POST_SECONDARY_ISCED_4', - label: { - defaultMessage: 'Secondary', - description: 'Option for form field: ISCED4 education', - id: 'form.field.label.educationAttainmentISCED4' - } - }, - { - value: 'FIRST_STAGE_TERTIARY_ISCED_5', - label: { - defaultMessage: 'Tertiary', - description: 'Option for form field: ISCED5 education', - id: 'form.field.label.educationAttainmentISCED5' - } - } -] diff --git a/src/form/tennis-club-membership.ts b/src/form/tennis-club-membership.ts index a5271097e..ede50e298 100644 --- a/src/form/tennis-club-membership.ts +++ b/src/form/tennis-club-membership.ts @@ -21,7 +21,7 @@ import { field, deduplication } from '@opencrvs/toolkit/conditionals' -import { getAddressFields } from './V2/person' +import { getAddressFields } from './v2/person/address' const TENNIS_CLUB_FORM = defineForm({ label: { diff --git a/src/form/v2/birth/forms/child.ts b/src/form/v2/birth/forms/child.ts new file mode 100644 index 000000000..8a39b7e2b --- /dev/null +++ b/src/form/v2/birth/forms/child.ts @@ -0,0 +1,315 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { defineFormPage, TranslationConfig } from '@opencrvs/toolkit/events' +import { field } from '@opencrvs/toolkit/conditionals' +import { appendConditionalsToFields, createSelectOptions } from '../../utils' +import { getAddressFields } from '../../person/address' + +const GenderTypes = { + MALE: 'male', + FEMALE: 'female', + UNKNOWN: 'unknown' +} as const + +const TypeOfBirth = { + SINGLE: 'SINGLE', + TWIN: 'TWIN', + TRIPLET: 'TRIPLET', + QUADRUPLET: 'QUADRUPLET', + HIGHER_MULTIPLE_DELIVERY: 'HIGHER_MULTIPLE_DELIVERY' +} as const + +const AttendantAtBirth = { + PHYSICIAN: 'PHYSICIAN', + NURSE: 'NURSE', + MIDWIFE: 'MIDWIFE', + OTHER_PARAMEDICAL_PERSONNEL: 'OTHER_PARAMEDICAL_PERSONNEL', + LAYPERSON: 'LAYPERSON', + TRADITIONAL_BIRTH_ATTENDANT: 'TRADITIONAL_BIRTH_ATTENDANT', + NONE: 'NONE' +} as const + +const PlaceOfBirth = { + HEALTH_FACILITY: 'HEALTH_FACILITY', + PRIVATE_HOME: 'PRIVATE_HOME', + OTHER: 'OTHER' +} as const + +const genderMessageDescriptors = { + MALE: { + defaultMessage: 'Male', + description: 'Label for option male', + id: 'form.field.label.sexMale' + }, + FEMALE: { + defaultMessage: 'Female', + description: 'Label for option female', + id: 'form.field.label.sexFemale' + }, + UNKNOWN: { + defaultMessage: 'Unknown', + description: 'Label for option unknown', + id: 'form.field.label.sexUnknown' + } +} satisfies Record + +const typeOfBirthMessageDescriptors = { + SINGLE: { + defaultMessage: 'Single', + description: 'Label for single birth', + id: 'form.field.label.birthTypeSingle' + }, + TWIN: { + defaultMessage: 'Twin', + description: 'Label for twin birth', + id: 'form.field.label.birthTypeTwin' + }, + TRIPLET: { + defaultMessage: 'Triplet', + description: 'Label for triplet birth', + id: 'form.field.label.birthTypeTriplet' + }, + QUADRUPLET: { + defaultMessage: 'Quadruplet', + description: 'Label for quadruplet birth', + id: 'form.field.label.birthTypeQuadruplet' + }, + HIGHER_MULTIPLE_DELIVERY: { + defaultMessage: 'Higher multiple delivery', + description: 'Label for higher multiple delivery birth', + id: 'form.field.label.birthTypeHigherMultipleDelivery' + } +} satisfies Record + +const attendantAtBirthMessageDescriptors = { + PHYSICIAN: { + defaultMessage: 'Physician', + description: 'Label for physician attendant', + id: 'form.field.label.attendantAtBirthPhysician' + }, + NURSE: { + defaultMessage: 'Nurse', + description: 'Label for nurse attendant', + id: 'form.field.label.attendantAtBirthNurse' + }, + MIDWIFE: { + defaultMessage: 'Midwife', + description: 'Label for midwife attendant', + id: 'form.field.label.attendantAtBirthMidwife' + }, + OTHER_PARAMEDICAL_PERSONNEL: { + defaultMessage: 'Other paramedical personnel', + description: 'Label for other paramedical personnel', + id: 'form.field.label.attendantAtBirthOtherParamedicalPersonnel' + }, + LAYPERSON: { + defaultMessage: 'Layperson', + description: 'Label for layperson attendant', + id: 'form.field.label.attendantAtBirthLayperson' + }, + TRADITIONAL_BIRTH_ATTENDANT: { + defaultMessage: 'Traditional birth attendant', + description: 'Label for traditional birth attendant', + id: 'form.field.label.attendantAtBirthTraditionalBirthAttendant' + }, + NONE: { + defaultMessage: 'None', + description: 'Label for no attendant', + id: 'form.field.label.attendantAtBirthNone' + } +} satisfies Record + +const placeOfBirthMessageDescriptors = { + HEALTH_FACILITY: { + defaultMessage: 'Health Institution', + description: 'Select item for Health Institution', + id: 'form.field.label.healthInstitution' + }, + PRIVATE_HOME: { + 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 + +const genderOptions = createSelectOptions(GenderTypes, genderMessageDescriptors) + +const placeOfBirthOptions = createSelectOptions( + PlaceOfBirth, + placeOfBirthMessageDescriptors +) + +const typeOfBirthOptions = createSelectOptions( + TypeOfBirth, + typeOfBirthMessageDescriptors +) + +const attendantAtBirthOptions = createSelectOptions( + AttendantAtBirth, + attendantAtBirthMessageDescriptors +) + +export const childPage = defineFormPage({ + id: 'child', + title: { + defaultMessage: "Child's details", + description: 'Form section title for Child', + id: 'form.birth.child.title' + }, + fields: [ + { + id: 'child.firstname', + type: 'TEXT', + required: true, + label: { + defaultMessage: 'First name(s)', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.firstname.label' + } + }, + { + id: 'child.surname', + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Last name', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.surname.label' + } + }, + { + id: 'child.gender', + type: 'SELECT', + required: true, + label: { + defaultMessage: 'Sex', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.gender.label' + }, + options: genderOptions + }, + { + id: 'child.dob', + type: 'DATE', + required: true, + validation: [ + { + message: { + defaultMessage: 'Please enter a valid date', + description: 'This is the error message for invalid date', + id: 'event.birth.action.declare.form.section.child.field.dob.error' + }, + validator: field('child.dob').isBeforeNow() + } + ], + label: { + defaultMessage: 'Date of birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.dob.label' + } + }, + { + id: 'child.placeOfBirth', + type: 'SELECT', + required: true, + label: { + defaultMessage: 'Place of delivery', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.placeOfBirth.label' + }, + options: placeOfBirthOptions + }, + { + id: 'child.birthLocation', + type: 'LOCATION', + required: true, + label: { + defaultMessage: 'Health Institution', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.birthLocation.label' + }, + options: { + type: 'HEALTH_FACILITY' + }, + conditionals: [ + { + type: 'HIDE', + conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ + 'HEALTH_FACILITY' + ]) + } + ] + }, + ...appendConditionalsToFields({ + inputFields: getAddressFields('child.privateHome'), + newConditionals: [ + { + type: 'HIDE', + conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ + 'PRIVATE_HOME' + ]) + } + ] + }), + ...appendConditionalsToFields({ + inputFields: getAddressFields('child.other'), + newConditionals: [ + { + type: 'HIDE', + conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([ + 'OTHER' + ]) + } + ] + }), + { + id: 'child.attendantAtBirth', + type: 'SELECT', + required: false, + label: { + defaultMessage: 'Attendant at birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.attendantAtBirth.label' + }, + options: attendantAtBirthOptions + }, + { + id: 'child.birthType', + type: 'SELECT', + required: false, + label: { + defaultMessage: 'Type of birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.birthType.label' + }, + options: typeOfBirthOptions + }, + { + id: 'child.weightAtBirth', + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Weight at birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.weightAtBirth.label' + }, + options: { + type: 'number' + } + } + ] +}) diff --git a/src/form/v2/birth/forms/declare.ts b/src/form/v2/birth/forms/declare.ts new file mode 100644 index 000000000..e5506d616 --- /dev/null +++ b/src/form/v2/birth/forms/declare.ts @@ -0,0 +1,287 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { defineForm } from '@opencrvs/toolkit/events' +import { field, and } from '@opencrvs/toolkit/conditionals' +import { childPage } from './child' +import { informantPage, InformantTypes } from './informant' +import { appendConditionalsToFields } from '../../utils' +import { getPersonInputFields } from '../../person' + +export const BIRTH_DECLARE_FORM = defineForm({ + label: { + id: 'event.birth.action.declare.form.label', + defaultMessage: 'Birth decalration form', + description: 'This is what this form is referred as in the system' + }, + review: { + title: { + id: 'event.birth.action.declare.form.review.title', + defaultMessage: 'Birth declaration for {firstname} {surname}', + description: 'Title of the form to show in review page' + } + }, + active: true, + version: { + id: '1.0.0', + label: { + id: 'event.birth.action.declare.form.version.1', + defaultMessage: 'Version 1', + description: 'This is the first version of the form' + } + }, + pages: [ + { + id: 'introduction', + title: { + defaultMessage: + 'Introduce the birth registration process to the informant', + description: 'Event information title for the birth', + id: 'register.eventInfo.birth.title' + }, + fields: [ + { + type: 'BULLET_LIST', + id: 'form.section.information.birth.bulletList', + label: { + id: 'form.section.information.birth.bulletList.label', + defaultMessage: 'Birth Information', + description: 'Label for the birth information bullet list' + }, + items: [ + { + defaultMessage: + 'I am going to help you make a declaration of birth.', + description: 'Form information for birth', + id: 'form.section.information.birth.bullet1' + }, + { + defaultMessage: + 'As the legal Informant it is important that all the information provided by you is accurate.', + description: 'Form information for birth', + id: 'form.section.information.birth.bullet2' + }, + { + defaultMessage: + 'Once the declaration is processed you will receive an SMS to tell you when to visit the office to collect the certificate - Take your ID with you.', + description: 'Form information for birth', + id: 'form.section.information.birth.bullet3' + }, + { + defaultMessage: + 'Make sure you collect the certificate. A birth certificate is critical for this child, especially to make their life easy later on. It will help to access health services, school examinations and government benefits.', + description: 'Form information for birth', + id: 'form.section.information.birth.bullet4' + } + ], + font: 'reg16' + } + ] + }, + childPage, + informantPage, + { + id: 'mother', + title: { + defaultMessage: "Mother's details", + description: 'Form section title for mothers details', + id: 'form.section.mother.title' + }, + fields: [ + { + id: 'mother.detailsNotAvailable', + type: 'CHECKBOX', + required: true, + label: { + defaultMessage: "Mother's details not available", + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.mother.field.detailsNotAvailable.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field('informant.relation').isInArray([ + InformantTypes.MOTHER + ]) + } + ] + }, + { + id: 'mother.reason', + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Reason', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.mother.field.reason.label' + }, + conditionals: [ + { + type: 'HIDE', + conditional: field( + 'mother.detailsNotAvailable' + ).isUndefinedOrInArray(['false']) + } + ] + }, + ...appendConditionalsToFields({ + inputFields: [ + ...getPersonInputFields('mother'), + { + id: 'mother.previousBirths', + type: 'TEXT', + required: false, + label: { + defaultMessage: 'No. of previous births', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.mother.field.previousBirths.label' + } + } + ], + newConditionals: [ + { + type: 'HIDE', + conditional: and( + field('mother.detailsNotAvailable').isInArray(['true']), + field('informant.relation').isUndefinedOrNotInArray([ + InformantTypes.MOTHER + ]) + ) + } + ] + }) + ] + }, + + { + id: 'father', + title: { + defaultMessage: "Father's details", + description: 'Form section title for fathers details', + id: 'form.section.father.title' + }, + fields: [ + { + id: 'father.detailsNotAvailable', + type: 'CHECKBOX', + required: true, + label: { + defaultMessage: "Father's details not available", + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.father.field.detailsNotAvailable.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field('informant.relation').isInArray([ + InformantTypes.FATHER + ]) + } + ] + }, + { + id: 'father.reason', + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Reason', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.father.field.reason.label' + }, + conditionals: [ + { + type: 'HIDE', + conditional: field( + 'father.detailsNotAvailable' + ).isUndefinedOrInArray(['false']) + } + ] + }, + ...appendConditionalsToFields({ + inputFields: getPersonInputFields('father'), + newConditionals: [ + { + type: 'HIDE', + conditional: and( + field('father.detailsNotAvailable').isInArray(['true']), + field('informant.relation').isUndefinedOrNotInArray([ + InformantTypes.FATHER + ]) + ) + } + ] + }) + ] + }, + { + id: 'documents', + title: { + defaultMessage: 'Upload supporting documents', + description: 'Form section title for documents', + id: 'form.section.documents.title' + }, + fields: [ + { + id: `documents.helper`, + type: 'PARAGRAPH', + label: { + defaultMessage: 'The following documents are required', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.documents.field.helper.label` + }, + options: { fontVariant: 'reg16' } + }, + { + id: 'documents.proofOfBirth', + type: 'FILE', + required: false, + label: { + defaultMessage: 'Proof of birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.documents.field.proofOfBirth.label' + } + }, + { + id: 'documents.proofOfMother', + type: 'FILE', // @ToDo File upload with options + required: false, + label: { + defaultMessage: "Proof of mother's ID", + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.documents.field.proofOfMother.label' + } + }, + + { + id: 'documents.proofOfFather', + type: 'FILE', // @ToDo File upload with options + required: false, + label: { + defaultMessage: "Proof of father's ID", + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.documents.field.proofOfFather.label' + } + }, + + { + id: 'documents.proofOther', + type: 'FILE', // @ToDo File upload with options + required: false, + label: { + defaultMessage: 'Other', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.documents.field.proofOther.label' + } + } + ] + } + ] +}) diff --git a/src/form/v2/birth/forms/informant.ts b/src/form/v2/birth/forms/informant.ts new file mode 100644 index 000000000..8437c1121 --- /dev/null +++ b/src/form/v2/birth/forms/informant.ts @@ -0,0 +1,131 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { defineFormPage, TranslationConfig } from '@opencrvs/toolkit/events' +import { field } from '@opencrvs/toolkit/conditionals' +import { appendConditionalsToFields, createSelectOptions } from '../../utils' +import { getInformantFields } from '../../person' + +export const InformantTypes = { + MOTHER: 'MOTHER', + FATHER: 'FATHER', + OTHER: 'OTHER', + GRANDFATHER: 'GRANDFATHER', + GRANDMOTHER: 'GRANDMOTHER', + BROTHER: 'BROTHER', + SISTER: 'SISTER', + LEGAL_GUARDIAN: 'LEGAL_GUARDIAN' +} as const + +const informantMessageDescriptors = { + MOTHER: { + defaultMessage: 'Mother', + description: 'Label for option mother', + id: 'form.field.label.informantRelation.mother' + }, + FATHER: { + defaultMessage: 'Father', + description: 'Label for option father', + id: 'form.field.label.informantRelation.father' + }, + GRANDFATHER: { + defaultMessage: 'Grandfather', + description: 'Label for option Grandfather', + id: 'form.field.label.informantRelation.grandfather' + }, + GRANDMOTHER: { + defaultMessage: 'Grandmother', + description: 'Label for option Grandmother', + id: 'form.field.label.informantRelation.grandmother' + }, + BROTHER: { + defaultMessage: 'Brother', + description: 'Label for option brother', + id: 'form.field.label.informantRelation.brother' + }, + SISTER: { + defaultMessage: 'Sister', + description: 'Label for option Sister', + id: 'form.field.label.informantRelation.sister' + }, + LEGAL_GUARDIAN: { + defaultMessage: 'Legal guardian', + description: 'Label for option Legal Guardian', + id: 'form.field.label.informantRelation.legalGuardian' + }, + OTHER: { + defaultMessage: 'Someone else', + description: 'Label for option someone else', + id: 'form.field.label.informantRelation.others' + } +} satisfies Record + +const birthInformantTypeOptions = createSelectOptions( + InformantTypes, + informantMessageDescriptors +) + +export const informantPage = defineFormPage({ + id: 'informant', + title: { + defaultMessage: "Informant's details", + description: 'Form section title for informants details', + id: 'form.section.informant.title' + }, + fields: [ + { + id: 'informant.relation', + type: 'SELECT', + required: true, + label: { + defaultMessage: 'Relationship to child', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.informant.field.relation.label' + }, + options: birthInformantTypeOptions + }, + ...appendConditionalsToFields({ + inputFields: getInformantFields('informant'), + newConditionals: [ + { + type: 'HIDE', + conditional: field('informant.relation').isUndefinedOrInArray([ + InformantTypes.MOTHER, + InformantTypes.FATHER + ]) + } + ] + }), + { + id: 'informant.phoneNo', + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Phone number', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.informant.field.phoneNo.label' + } + }, + { + id: 'informant.email', + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Email', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.informant.field.email.label' + }, + options: { + type: 'email' + } + } + ] +}) diff --git a/src/form/v2/birth/index.ts b/src/form/v2/birth/index.ts new file mode 100644 index 000000000..ce0ff48e6 --- /dev/null +++ b/src/form/v2/birth/index.ts @@ -0,0 +1,67 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { defineConfig } from '@opencrvs/toolkit/events' +import { + defineConditional, + eventHasAction, + not +} from '@opencrvs/toolkit/conditionals' +import { BIRTH_DECLARE_FORM } from './forms/declare' + +export const birthEvent = defineConfig({ + id: 'BIRTH', + label: { + defaultMessage: 'Birth declaration', + description: 'This is what this event is referred as in the system', + id: 'event.birth.label' + }, + summary: { + title: { + defaultMessage: '{applicant.firstname} {applicant.surname}', + description: 'This is the title of the summary', + id: 'event.birth.summary.title' + }, + fields: [] + }, + workqueues: [ + { + id: 'all', + title: { + defaultMessage: 'All birth events', + description: 'Label for all birth events workqueue', + id: 'event.birth.workqueue.all.label' + }, + fields: [ + { + id: 'child.firstname' + }, + { + id: 'child.surname' + } + ], + filters: [] + } + ], + actions: [ + { + type: 'DECLARE', + label: { + defaultMessage: 'Declare', + description: + 'This is shown as the action name anywhere the user can trigger the action from', + id: 'event.birth.action.declare.label' + }, + forms: [BIRTH_DECLARE_FORM], + allowedWhen: defineConditional(not(eventHasAction('DECLARE'))) + } + ] +}) diff --git a/src/form/v2/person/address.ts b/src/form/v2/person/address.ts new file mode 100644 index 000000000..e244c9771 --- /dev/null +++ b/src/form/v2/person/address.ts @@ -0,0 +1,275 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { FieldConfig, TranslationConfig } from '@opencrvs/toolkit/events' +import { field } from '@opencrvs/toolkit/conditionals' +import { appendConditionalsToFields, createSelectOptions } from '../utils' + +const UrbanRuralTypes = { + URBAN: 'URBAN', + RURAL: 'RURAL' +} as const + +const urbanRuralMessageDescriptors = { + URBAN: { + defaultMessage: 'Urban', + id: 'form.field.label.urban', + description: 'Label for form field checkbox option Urban' + }, + RURAL: { + defaultMessage: 'Rural', + id: 'form.field.label.rural', + description: 'Label for form field checkbox option Rural' + } +} satisfies Record + +const urbanRuralRadioOptions = createSelectOptions( + UrbanRuralTypes, + urbanRuralMessageDescriptors +) + +export const getAddressFields = (person: string): FieldConfig[] => { + // @Todo: Same as mother or deseased + const prefix = `${person}.address` + + const genericAddressFields: FieldConfig[] = [ + { + id: `${prefix}.other.state`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'State', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.state.label` + } + }, + { + id: `${prefix}.other.district`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'District', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.district.label` + } + }, + { + id: `${prefix}.other.town`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'City / Town', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.town.label` + } + }, + { + id: `${prefix}.other.addressLine1`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Address Line 1', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.addressLine1.label` + } + }, + { + id: `${prefix}.other.addressLine2`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Address Line 2', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.addressLine2.label` + } + }, + { + id: `${prefix}.other.addressLine3`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Address Line 3', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.addressLine3.label` + } + }, + { + id: `${prefix}.other.zipCode`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Postcode / Zip', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.other.zipCode.label` + } + } + ] + + const urbanAddressFields: FieldConfig[] = [ + { + id: `${prefix}.town`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Town', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.town.label` + } + }, + { + id: `${prefix}.residentialArea`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Residential Area', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.residentialArea.label` + } + }, + { + id: `${prefix}.village`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Area / Ward / Mouja / Village', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.village.label` + } + }, + { + id: `${prefix}.number`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Number', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.number.label` + } + }, + { + id: `${prefix}.zipCode`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Postcode / Zip', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.zipCode.label` + } + } + ] + const farajalandAddressFields: FieldConfig[] = [ + { + id: `${prefix}.province`, + type: 'LOCATION', + required: true, + label: { + defaultMessage: 'Province', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.address.province.label` + }, + options: { + type: 'ADMIN_STRUCTURE' + } + }, + { + id: `${prefix}.district`, + type: 'LOCATION', + required: true, + label: { + defaultMessage: 'District', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.address.district.label` + }, + options: { + partOf: { + $data: `${prefix}.province` + }, + type: 'ADMIN_STRUCTURE' + } + }, + { + id: `${prefix}.urbanOrRural`, + type: 'RADIO_GROUP', + options: urbanRuralRadioOptions, + flexDirection: 'row', + required: false, + label: { + defaultMessage: 'Urban or Rural', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.address.urbanOrRural.label` + } + }, + ...appendConditionalsToFields({ + inputFields: urbanAddressFields, + newConditionals: [ + { + type: 'HIDE', + conditional: field(`${prefix}.urbanOrRural`).isUndefinedOrInArray([ + 'RURAL' + ]) + } + ] + }), + { + id: `${prefix}.village`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Village', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.address.village.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${prefix}.urbanOrRural`).isUndefinedOrInArray([ + 'URBAN' + ]) + } + ] + } + ] + + return [ + { + id: `${prefix}.country`, + type: 'COUNTRY', + required: true, + label: { + defaultMessage: 'Country', + description: 'This is the label for the field', + id: `event.action.declare.form.section.person.field.address.country.label` + } + }, + ...appendConditionalsToFields({ + inputFields: genericAddressFields, + newConditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.address.country`).isUndefinedOrInArray([ + 'FAR' + ]) + } + ] + }), + ...appendConditionalsToFields({ + inputFields: farajalandAddressFields, + newConditionals: [ + { + type: 'HIDE', + conditional: field( + `${person}.address.country` + ).isUndefinedOrNotInArray(['FAR']) + } + ] + }) + ] +} diff --git a/src/form/v2/person/index.ts b/src/form/v2/person/index.ts new file mode 100644 index 000000000..3855578f3 --- /dev/null +++ b/src/form/v2/person/index.ts @@ -0,0 +1,331 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { FieldConfig, TranslationConfig } from '@opencrvs/toolkit/events' +import { field } from '@opencrvs/toolkit/conditionals' +import { getAddressFields } from './address' +import { createSelectOptions } from '../utils' + +const IDTypes = { + NATIONAL_ID: 'NATIONAL_ID', + PASSPORT: 'PASSPORT', + BIRTH_REGISTRATION_NUMBER: 'BIRTH_REGISTRATION_NUMBER', + NONE: 'NONE' +} as const + +const MaritalStatus = { + SINGLE: 'SINGLE', + MARRIED: 'MARRIED', + WIDOWED: 'WIDOWED', + DIVORCED: 'DIVORCED', + SEPARATED: 'SEPARATED', + NOT_STATED: 'NOT_STATED' +} as const + +const EducationalAttainment = { + NO_SCHOOLING: 'NO_SCHOOLING', + PRIMARY_ISCED_1: 'PRIMARY_ISCED_1', + POST_SECONDARY_ISCED_4: 'POST_SECONDARY_ISCED_4', + FIRST_STAGE_TERTIARY_ISCED_5: 'FIRST_STAGE_TERTIARY_ISCED_5' +} as const + +const idTypeMessageDescriptors = { + NATIONAL_ID: { + defaultMessage: 'National ID', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeNationalID' + }, + PASSPORT: { + defaultMessage: 'Passport', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypePassport' + }, + BIRTH_REGISTRATION_NUMBER: { + defaultMessage: 'Birth Registration Number', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeBRN' + }, + NONE: { + defaultMessage: 'None', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeNone' + } +} satisfies Record + +const maritalStatusMessageDescriptors = { + SINGLE: { + defaultMessage: 'Single', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusSingle' + }, + MARRIED: { + defaultMessage: 'Married', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusMarried' + }, + WIDOWED: { + defaultMessage: 'Widowed', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusWidowed' + }, + DIVORCED: { + defaultMessage: 'Divorced', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusDivorced' + }, + SEPARATED: { + defaultMessage: 'Separated', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusSeparated' + }, + NOT_STATED: { + defaultMessage: 'Not stated', + description: 'Option for form field: Marital status', + id: 'form.field.label.maritalStatusNotStated' + } +} satisfies Record + +const educationalAttainmentMessageDescriptors = { + NO_SCHOOLING: { + defaultMessage: 'No schooling', + description: 'Option for form field: no education', + id: 'form.field.label.educationAttainmentNone' + }, + PRIMARY_ISCED_1: { + defaultMessage: 'Primary', + description: 'Option for form field: ISCED1 education', + id: 'form.field.label.educationAttainmentISCED1' + }, + POST_SECONDARY_ISCED_4: { + defaultMessage: 'Secondary', + description: 'Option for form field: ISCED4 education', + id: 'form.field.label.educationAttainmentISCED4' + }, + FIRST_STAGE_TERTIARY_ISCED_5: { + defaultMessage: 'Tertiary', + description: 'Option for form field: ISCED5 education', + id: 'form.field.label.educationAttainmentISCED5' + } +} satisfies Record + +const idTypeOptions = createSelectOptions(IDTypes, idTypeMessageDescriptors) + +const maritalStatusOptions = createSelectOptions( + MaritalStatus, + maritalStatusMessageDescriptors +) +const educationalAttainmentOptions = createSelectOptions( + EducationalAttainment, + educationalAttainmentMessageDescriptors +) + +const getIdFields = (person: string): FieldConfig[] => [ + { + id: `${person}.idType`, + type: 'SELECT', + required: true, + label: { + defaultMessage: 'Type of ID', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.idType.label` + }, + options: idTypeOptions + }, + { + id: `${person}.nid`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'ID Number', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.nid.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'NATIONAL_ID' + ]) + } + ] + }, + { + id: `${person}.passport`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'ID Number', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.passport.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'PASSPORT' + ]) + } + ] + }, + { + id: `${person}.brn`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'ID Number', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.brn.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'BIRTH_REGISTRATION_NUMBER' + ]) + } + ] + } +] + +export const getInformantFields = (person: string): FieldConfig[] => [ + { + id: `${person}.firstname`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'First name(s)', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.firstname.label` + } + }, + { + id: `${person}.surname`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Last name', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.surname.label` + } + }, + { + id: `${person}.dob`, + type: 'DATE', + required: true, + validation: [ + { + message: { + defaultMessage: 'Please enter a valid date', + description: 'This is the error message for invalid date', + id: `event.birth.action.declare.form.section.${person}.field.dob.error` + }, + validator: field(`${person}.dob`).isBeforeNow() + } + ], + label: { + defaultMessage: 'Date of birth', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.dob.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.dobUnknown`).isEqualTo('true') + } + ] + }, + { + id: `${person}.dobUnknown`, + type: 'CHECKBOX', + required: true, + label: { + defaultMessage: 'Exact date of birth unknown', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.age.label` + } + }, + { + id: `${person}.age`, + type: 'TEXT', + required: true, + label: { + defaultMessage: `Age of ${person}`, + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.age.label` + }, + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}.dobUnknown`).isUndefinedOrInArray([ + 'false' + ]) + } + ] + }, + { + id: `${person}.nationality`, + type: 'COUNTRY', + required: true, + label: { + defaultMessage: 'Nationality', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.nationality.label` + } + }, + ...getIdFields(person), + { + id: `${person}.addressHelper`, + type: 'PARAGRAPH', + label: { + defaultMessage: 'Usual place of residence', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.addressHelper.label` + }, + options: { fontVariant: 'h2' } + }, + ...getAddressFields(person) +] + +export const getPersonInputFields = (person: string): FieldConfig[] => [ + ...getInformantFields(person), + { + id: `${person}.maritalStatus`, + type: 'SELECT', + required: false, + label: { + defaultMessage: 'Marital Status', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.maritalStatus.label` + }, + options: maritalStatusOptions + }, + { + id: `${person}.educationalAttainment`, + type: 'SELECT', + required: false, + label: { + defaultMessage: 'Level of education', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.educationalAttainment.label` + }, + options: educationalAttainmentOptions + }, + { + id: `${person}.occupation`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Occupation', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.occupation.label` + } + } +] diff --git a/src/form/V2/utils.ts b/src/form/v2/utils.ts similarity index 53% rename from src/form/V2/utils.ts rename to src/form/v2/utils.ts index c9f8d933d..1e06f1e4f 100644 --- a/src/form/V2/utils.ts +++ b/src/form/v2/utils.ts @@ -9,7 +9,12 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { FieldConditional, FieldConfig } from '@opencrvs/toolkit/events' +import { + FieldConditional, + FieldConfig, + SelectOption, + TranslationConfig +} from '@opencrvs/toolkit/events' export const appendConditionalsToFields = ({ inputFields, @@ -18,10 +23,19 @@ export const appendConditionalsToFields = ({ inputFields: FieldConfig[] newConditionals: FieldConditional[] }): FieldConfig[] => - inputFields.map( - (inputField) => - ({ - ...inputField, - conditionals: [...inputField.conditionals, ...newConditionals] - } as FieldConfig) - ) + inputFields.map((inputField) => ({ + ...inputField, + conditionals: [...(inputField.conditionals || []), ...newConditionals] + })) + +export const createSelectOptions = < + T extends Record, + M extends Record +>( + options: T, + messageDescriptors: M +): SelectOption[] => + Object.entries(options).map(([key, value]) => ({ + value, + label: messageDescriptors[key as keyof T] + })) diff --git a/yarn.lock b/yarn.lock index e558c8c1f..2c8c34061 100644 --- a/yarn.lock +++ b/yarn.lock @@ -790,10 +790,10 @@ dependencies: "@octokit/openapi-types" "^18.0.0" -"@opencrvs/toolkit@0.0.13-events": - version "0.0.13-events" - resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.13-events.tgz#7b2c1fd73bba74c2cb6292a0ce4c6659e9711ee3" - integrity sha512-sdST83RXETbP6e1ETtM7VSUP2W+sYpz/DU9a8c036QlJ67I9306nuIqLePGU62pPggI8sI63fa2PL38bF3hAlg== +"@opencrvs/toolkit@0.0.14-events": + version "0.0.14-events" + resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.14-events.tgz#f99b2dc14c30ec925f373e19eea5ea731abb79b9" + integrity sha512-ZsSmmgB9anSVp2hxIquU/wfHVP8s//RydEVERmn7Dpr3S/6bVRsLS27P02lioJmCBMbEf8cNgstyMlgaE9XpAg== dependencies: ajv "^8.17.1"