From 52fce1c08837ec414511d44cbd0815363a709fab Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 1 Jan 2025 18:54:29 +0600 Subject: [PATCH 01/25] chore: update yarn.lock --- yarn.lock | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6d73f2987..ab2c56780 100644 --- a/yarn.lock +++ b/yarn.lock @@ -790,10 +790,12 @@ dependencies: "@octokit/openapi-types" "^18.0.0" -"@opencrvs/toolkit@^0.0.5": - version "0.0.5" - resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.5.tgz#dbd3395b561c1eb3527b8cfc28b6e1dd301671f3" - integrity sha512-Ex45aFUJ1iQwpYGMHhxVbhpuQFqVlmdSkNXz1phkM7KAzNtngL2KGIJCc6TFv4GKOHU/lLEfmGyrhIDCKlA7fQ== +"@opencrvs/toolkit@0.0.6-events": + version "0.0.6-events" + resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.6-events.tgz#48327b3e322bc82ae60ec13fc855e2e23300b298" + integrity sha512-wh4qaPJktG4Dnh+zFFbDv5b/oZ+bTSzQYRfOzLGS1KNqG7h2j6iZfvmSBtyL0rb/SrpIHcI+9eoqLfwg8cjfyQ== + dependencies: + ajv "^8.17.1" "@rollup/rollup-android-arm-eabi@4.24.0": version "4.24.0" @@ -1402,6 +1404,16 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^8.17.1: + version "8.17.1" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6" + integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g== + dependencies: + fast-deep-equal "^3.1.3" + fast-uri "^3.0.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + ansi-escapes@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" @@ -2532,6 +2544,11 @@ fast-safe-stringify@^2.1.1: resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== +fast-uri@^3.0.1: + version "3.0.3" + resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.3.tgz#892a1c91802d5d7860de728f18608a0573142241" + integrity sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw== + fastq@^1.6.0: version "1.13.0" resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" @@ -3331,6 +3348,11 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" @@ -4361,6 +4383,11 @@ repeat-string@^1.6.1: resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w== +require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" From 5d4ca76c89dd89b27ad3cf09e5d26ccaff1f3da6 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 1 Jan 2025 18:55:25 +0600 Subject: [PATCH 02/25] feat: wip: birth event v2 --- src/api/custom-event/handler.ts | 3 +- src/form/Legecy/birth.ts | 212 ++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 src/form/Legecy/birth.ts diff --git a/src/api/custom-event/handler.ts b/src/api/custom-event/handler.ts index ebc656b26..5b020deb4 100644 --- a/src/api/custom-event/handler.ts +++ b/src/api/custom-event/handler.ts @@ -10,10 +10,11 @@ */ import * as Hapi from '@hapi/hapi' import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership' +import { BirthEvent } from '@countryconfig/form/Legecy/birth' export const customEventHandler = ( request: Hapi.Request, h: Hapi.ResponseToolkit ) => { - return h.response([tennisClubMembershipEvent]).code(200) + return h.response([tennisClubMembershipEvent, BirthEvent]).code(200) } diff --git a/src/form/Legecy/birth.ts b/src/form/Legecy/birth.ts new file mode 100644 index 000000000..6670174c5 --- /dev/null +++ b/src/form/Legecy/birth.ts @@ -0,0 +1,212 @@ +/* + * 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 } from '@opencrvs/toolkit/events' +import { + defineConditional, + eventHasAction, + not, + field +} from '@opencrvs/toolkit/conditionals' + +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: 'h3' + } + ] + }, + { + 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', + 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: 'Surname', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.surname.label' + } + }, + { + id: 'child.gender', + type: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + required: true, + label: { + defaultMessage: 'Gender', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.gender.label' + } + }, + { + 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.attendantAtBirth', + type: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + required: true, + label: { + defaultMessage: 'Attendant at birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.attendantAtBirth.label' + } + }, + { + id: 'child.birthType', + type: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + required: true, + label: { + defaultMessage: 'Birth type', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.birthType.label' + } + }, + { + id: 'child.weightAtBirth', + type: 'TEXT', // @Todo: Change to NUMBER + required: true, + label: { + defaultMessage: 'Weight at birth', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.weightAtBirth.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: [], + actions: [ + { + type: 'DECLARE', + label: { + defaultMessage: 'Declare', + description: + 'This is shown as the action name anywhere the user can trigger the action from', + id: 'event.tennis-club-membership.action.declare.label' + }, + forms: [BIRTH_FORM], + allowedWhen: defineConditional(not(eventHasAction('DECLARE'))) + } + ] +}) From 66543987025ed3587ac5959c74523315093ef0fc Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 1 Jan 2025 20:38:55 +0600 Subject: [PATCH 03/25] feat: use select option in gender, attendantAtBirth and birthType --- src/form/Legecy/birth.ts | 881 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 873 insertions(+), 8 deletions(-) diff --git a/src/form/Legecy/birth.ts b/src/form/Legecy/birth.ts index 6670174c5..5dd6b05c4 100644 --- a/src/form/Legecy/birth.ts +++ b/src/form/Legecy/birth.ts @@ -9,13 +9,875 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { defineConfig, defineForm } from '@opencrvs/toolkit/events' +import { + defineConfig, + defineForm, + SelectOption +} from '@opencrvs/toolkit/events' import { defineConditional, eventHasAction, not, field } from '@opencrvs/toolkit/conditionals' +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' + } +} + +export const genderOptions: SelectOption[] = [ + { + value: 'male', + label: formMessageDescriptors.sexMale + }, + { + value: 'female', + label: formMessageDescriptors.sexFemale + }, + { + value: 'unknown', + label: formMessageDescriptors.sexUnknown + } +] + +export 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 + } +] + +export 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 BIRTH_FORM = defineForm({ label: { @@ -117,13 +979,14 @@ const BIRTH_FORM = defineForm({ }, { id: 'child.gender', - type: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + type: 'SELECT', required: true, label: { - defaultMessage: 'Gender', + 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', @@ -147,23 +1010,25 @@ const BIRTH_FORM = defineForm({ }, { id: 'child.attendantAtBirth', - type: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + type: 'SELECT', required: true, 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: 'TEXT', // @Todo: Change to SELECT_WITH_OPTIONS + type: 'SELECT', required: true, label: { defaultMessage: 'Birth type', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.child.field.birthType.label' - } + }, + options: typeOfBirthOptions }, { id: 'child.weightAtBirth', From d11abb6645027e9e487940de7a630c3bf3bfe283 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 2 Jan 2025 15:07:01 +0600 Subject: [PATCH 04/25] fix: use number for weight at birth --- src/form/Legecy/birth.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/form/Legecy/birth.ts b/src/form/Legecy/birth.ts index 5dd6b05c4..4ba41c32e 100644 --- a/src/form/Legecy/birth.ts +++ b/src/form/Legecy/birth.ts @@ -1032,12 +1032,15 @@ const BIRTH_FORM = defineForm({ }, { id: 'child.weightAtBirth', - type: 'TEXT', // @Todo: Change to NUMBER + type: 'TEXT', required: true, 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' } } ] @@ -1060,7 +1063,25 @@ export const BirthEvent = defineConfig({ }, fields: [] }, - workqueues: [], + 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', @@ -1068,7 +1089,7 @@ export const BirthEvent = defineConfig({ defaultMessage: 'Declare', description: 'This is shown as the action name anywhere the user can trigger the action from', - id: 'event.tennis-club-membership.action.declare.label' + id: 'event.birth.action.declare.label' }, forms: [BIRTH_FORM], allowedWhen: defineConditional(not(eventHasAction('DECLARE'))) From fc6587d5111f4f97567c23d9e6f53b9d99edcd5e Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 3 Jan 2025 12:22:43 +0600 Subject: [PATCH 05/25] feat: person input wip --- src/form/Legecy/birth.ts | 138 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 4 deletions(-) diff --git a/src/form/Legecy/birth.ts b/src/form/Legecy/birth.ts index 4ba41c32e..ac49027a2 100644 --- a/src/form/Legecy/birth.ts +++ b/src/form/Legecy/birth.ts @@ -12,6 +12,7 @@ import { defineConfig, defineForm, + FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { @@ -20,7 +21,7 @@ import { not, field } from '@opencrvs/toolkit/conditionals' -export const formMessageDescriptors = { +const formMessageDescriptors = { primaryAddress: { defaultMessage: 'Usual place of residence', description: 'Title of the primary adress', @@ -810,7 +811,7 @@ export const formMessageDescriptors = { } } -export const genderOptions: SelectOption[] = [ +const genderOptions: SelectOption[] = [ { value: 'male', label: formMessageDescriptors.sexMale @@ -825,7 +826,7 @@ export const genderOptions: SelectOption[] = [ } ] -export const typeOfBirthOptions: SelectOption[] = [ +const typeOfBirthOptions: SelectOption[] = [ { value: 'SINGLE', label: formMessageDescriptors.birthTypeSingle @@ -848,7 +849,7 @@ export const typeOfBirthOptions: SelectOption[] = [ } ] -export const attendantAtBirthOptions: SelectOption[] = [ +const attendantAtBirthOptions: SelectOption[] = [ { value: 'PHYSICIAN', label: formMessageDescriptors.physician @@ -879,6 +880,126 @@ export const attendantAtBirthOptions: SelectOption[] = [ } ] +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' + } + } +] + +const getPersonInputFields = (person: string): FieldConfig[] => [ + { + id: `${person}.firstname`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'First name', + 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: 'Surname', + 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: [] + }, + { + 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: `${person[0].toUpperCase() + person.slice(1)}'s age`, + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.age.label` + }, + conditionals: [ + { + type: 'SHOW', + conditional: field(`${person}.dobUnknown`).isEqualTo('true') + } + ] + }, + { + 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: [] + } +] + const BIRTH_FORM = defineForm({ label: { id: 'event.birth.action.declare.form.label', @@ -1044,6 +1165,15 @@ const BIRTH_FORM = defineForm({ } } ] + }, + { + id: 'informant', + title: { + defaultMessage: "Informant's details", + description: 'Form section title for informants', + id: 'form.section.informant.title' + }, + fields: [...getPersonInputFields('informant')] } ] }) From 6015741f79f51eb5e20e5f5e90e476501ef19ad8 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Mon, 6 Jan 2025 20:16:13 +0600 Subject: [PATCH 06/25] feat: show dob or age based on dobUnknown checkbox --- src/form/Legecy/birth.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/form/Legecy/birth.ts b/src/form/Legecy/birth.ts index ac49027a2..e60a9ee91 100644 --- a/src/form/Legecy/birth.ts +++ b/src/form/Legecy/birth.ts @@ -957,7 +957,12 @@ const getPersonInputFields = (person: string): FieldConfig[] => [ description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.dob.label` }, - conditionals: [] + conditionals: [ + { + type: 'HIDE', + conditional: field(`${person}____dobUnknown`).isEqualTo('true') + } + ] }, { id: `${person}.dobUnknown`, @@ -981,8 +986,8 @@ const getPersonInputFields = (person: string): FieldConfig[] => [ }, conditionals: [ { - type: 'SHOW', - conditional: field(`${person}.dobUnknown`).isEqualTo('true') + type: 'HIDE', + conditional: field(`${person}____dobUnknown`).isEqualTo('false') } ] }, From 505a08e4f7b87af3a1c4ef9acc6a8c696e51e41c Mon Sep 17 00:00:00 2001 From: jamil314 Date: Mon, 6 Jan 2025 20:21:27 +0600 Subject: [PATCH 07/25] chore: rename directory --- src/form/{Legecy => V2}/birth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/form/{Legecy => V2}/birth.ts (99%) diff --git a/src/form/Legecy/birth.ts b/src/form/V2/birth.ts similarity index 99% rename from src/form/Legecy/birth.ts rename to src/form/V2/birth.ts index e60a9ee91..26ecd0527 100644 --- a/src/form/Legecy/birth.ts +++ b/src/form/V2/birth.ts @@ -980,7 +980,7 @@ const getPersonInputFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: `${person[0].toUpperCase() + person.slice(1)}'s age`, + defaultMessage: `Age of ${person}`, description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.age.label` }, From 373323bf4a5d9a4cf1ede745127ebdef6e20c845 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Mon, 6 Jan 2025 20:34:51 +0600 Subject: [PATCH 08/25] amend: import from renamed directory --- src/api/custom-event/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/custom-event/handler.ts b/src/api/custom-event/handler.ts index 5b020deb4..313768dc3 100644 --- a/src/api/custom-event/handler.ts +++ b/src/api/custom-event/handler.ts @@ -10,7 +10,7 @@ */ import * as Hapi from '@hapi/hapi' import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership' -import { BirthEvent } from '@countryconfig/form/Legecy/birth' +import { BirthEvent } from '@countryconfig/form/V2/birth' export const customEventHandler = ( request: Hapi.Request, From 07be5e292584cdb45623b6c50d859cfc759f2dbd Mon Sep 17 00:00:00 2001 From: jamil314 Date: Mon, 6 Jan 2025 20:35:45 +0600 Subject: [PATCH 09/25] feat: add informant relation to birth form --- src/form/V2/birth.ts | 1045 +++++------------------------ src/form/V2/messageDescriptors.ts | 800 ++++++++++++++++++++++ src/form/V2/person.ts | 138 ++++ 3 files changed, 1096 insertions(+), 887 deletions(-) create mode 100644 src/form/V2/messageDescriptors.ts create mode 100644 src/form/V2/person.ts diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 26ecd0527..3941312e3 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -12,7 +12,6 @@ import { defineConfig, defineForm, - FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { @@ -21,793 +20,143 @@ import { not, field } from '@opencrvs/toolkit/conditionals' -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' - }, +import { formMessageDescriptors } from './messageDescriptors' +import { getPersonInputFields } from './person' + +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'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' + defaultMessage: 'Informant type', + description: 'Who is applying for birth registration', + id: 'register.selectInformant.birthInformantTitle' }, - ageOfSpouse: { - defaultMessage: 'Age of spouse', - description: 'Label for form field: Age of spouse', - id: 'form.field.label.ageOfSpouse' - }, - motherName: { + MOTHER: { 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' + 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: "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' + 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' }, - verbalAutopsyReport: { - defaultMessage: 'Verbal autopsy report', - description: 'Option for form field: verbalAutopsyReport', - id: 'form.field.label.verbalAutopsyReport' + marriageInformantTitle: { + defaultMessage: 'Who is applying for marriage registration?', + description: 'Who is applying for marriage registration', + id: 'register.selectInformant.marriageInformantTitle' }, - groomName: { + GROOM: { 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' + description: 'Label for option groom', + id: 'form.field.label.informantRelation.groom' }, - 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: { + BRIDE: { 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' + description: 'Label for option bride', + id: 'form.field.label.informantRelation.bride' } } @@ -880,131 +229,40 @@ const attendantAtBirthOptions: SelectOption[] = [ } ] -const idTypeOptions: SelectOption[] = [ +const birthInformantTypeOptions: SelectOption[] = [ { - value: 'NATIONAL_ID' as const, - label: { - defaultMessage: 'National ID', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNationalID' - } + value: informantTypes.MOTHER, + label: informantMessageDescriptors.MOTHER }, { - value: 'PASSPORT' as const, - label: { - defaultMessage: 'Passport', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypePassport' - } + value: informantTypes.FATHER, + label: informantMessageDescriptors.FATHER }, { - 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: informantTypes.GRANDFATHER, + label: informantMessageDescriptors.GRANDFATHER }, { - value: 'NONE' as const, - label: { - defaultMessage: 'None', - description: 'Option for form field: Type of ID', - id: 'form.field.label.iDTypeNone' - } - } -] - -const getPersonInputFields = (person: string): FieldConfig[] => [ - { - id: `${person}.firstname`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'First name', - description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.firstname.label` - }, - conditionals: [] + value: informantTypes.GRANDMOTHER, + label: informantMessageDescriptors.GRANDMOTHER }, { - id: `${person}.surname`, - type: 'TEXT', - required: true, - label: { - defaultMessage: 'Surname', - 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') - } - ] + value: informantTypes.BROTHER, + label: informantMessageDescriptors.BROTHER }, { - 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: [] + value: informantTypes.SISTER, + label: informantMessageDescriptors.SISTER }, { - 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`).isEqualTo('false') - } - ] + value: informantTypes.LEGAL_GUARDIAN, + label: informantMessageDescriptors.LEGAL_GUARDIAN }, { - 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: [] + value: informantTypes.OTHER, + label: informantMessageDescriptors.OTHER } ] - const BIRTH_FORM = defineForm({ label: { id: 'event.birth.action.declare.form.label', @@ -1178,7 +436,20 @@ const BIRTH_FORM = defineForm({ description: 'Form section title for informants', id: 'form.section.informant.title' }, - fields: [...getPersonInputFields('informant')] + 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 + }, + ...getPersonInputFields('informant') + ] } ] }) diff --git a/src/form/V2/messageDescriptors.ts b/src/form/V2/messageDescriptors.ts new file mode 100644 index 000000000..2284cef85 --- /dev/null +++ b/src/form/V2/messageDescriptors.ts @@ -0,0 +1,800 @@ +/* + * 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 new file mode 100644 index 000000000..44ea7ca75 --- /dev/null +++ b/src/form/V2/person.ts @@ -0,0 +1,138 @@ +/* + * 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' + +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 getPersonInputFields = (person: string): FieldConfig[] => [ + { + id: `${person}.firstname`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'First name', + 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: 'Surname', + 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`).isEqualTo('false') + } + ] + }, + { + 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: [] + } +] From c05f0d9e3fab6606dd4267bfbde72e29270ca573 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Tue, 7 Jan 2025 18:13:05 +0600 Subject: [PATCH 10/25] feat: render informant fields based on relation to child --- src/form/V2/birth.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 3941312e3..99dbbfd9e 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -12,6 +12,7 @@ import { defineConfig, defineForm, + FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { @@ -448,7 +449,22 @@ const BIRTH_FORM = defineForm({ }, options: birthInformantTypeOptions }, - ...getPersonInputFields('informant') + ...getPersonInputFields('informant').map( + (personInputField) => + ({ + ...personInputField, + conditionals: [ + ...personInputField.conditionals, + { + type: 'HIDE', + conditional: field('informant____relation').isInArray([ + 'MOTHER', + 'FATHER' + ]) + } + ] + } as FieldConfig) + ) ] } ] From 15fe150f92f2ed809fdb45682ce375e68a240df8 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Tue, 7 Jan 2025 18:23:20 +0600 Subject: [PATCH 11/25] feat: separate the logic for concatenating field id --- src/form/V2/birth.ts | 9 ++++----- src/form/V2/person.ts | 14 +++++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 99dbbfd9e..7565a5ef9 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -22,7 +22,7 @@ import { field } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' -import { getPersonInputFields } from './person' +import { concatFields, getPersonInputFields } from './person' const informantTypes = { SPOUSE: 'SPOUSE', @@ -457,10 +457,9 @@ const BIRTH_FORM = defineForm({ ...personInputField.conditionals, { type: 'HIDE', - conditional: field('informant____relation').isInArray([ - 'MOTHER', - 'FATHER' - ]) + conditional: field( + concatFields(['informant', 'relation']) + ).isInArray(['MOTHER', 'FATHER']) } ] } as FieldConfig) diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index 44ea7ca75..2b9363a6f 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -47,6 +47,10 @@ const idTypeOptions: SelectOption[] = [ } ] +export const concatFields = (fields: string[]) => { + return fields.join('____') +} + export const getPersonInputFields = (person: string): FieldConfig[] => [ { id: `${person}.firstname`, @@ -81,7 +85,7 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ 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() + validator: field(concatFields([person, 'dob'])).isBeforeNow() } ], label: { @@ -92,7 +96,9 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(`${person}____dobUnknown`).isEqualTo('true') + conditional: field(concatFields([person, 'dobUnknown'])).isEqualTo( + 'true' + ) } ] }, @@ -119,7 +125,9 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(`${person}____dobUnknown`).isEqualTo('false') + conditional: field(concatFields([person, 'dobUnknown'])).isEqualTo( + 'false' + ) } ] }, From 2a3758a25b842a7ea53c0c804e39d30891efeab5 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Tue, 7 Jan 2025 18:28:00 +0600 Subject: [PATCH 12/25] feat: complete informant details apart form person inputs --- src/form/V2/birth.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 7565a5ef9..75ae4a76a 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -463,7 +463,30 @@ const BIRTH_FORM = defineForm({ } ] } as FieldConfig) - ) + ), + { + id: 'informant.phoneNo', + type: 'TEXT', + required: true, + 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' + } + } ] } ] From 29b280a88c0059372a6b01ed96dc8bb0a58b17a5 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 8 Jan 2025 18:05:38 +0600 Subject: [PATCH 13/25] feat: implement id and address --- src/form/V2/birth.ts | 33 +- src/form/V2/countries.ts | 1513 ++++++++++++++++++++++++++++++++++++++ src/form/V2/person.ts | 294 +++++++- 3 files changed, 1822 insertions(+), 18 deletions(-) create mode 100644 src/form/V2/countries.ts diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 75ae4a76a..af8ba02c6 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -12,7 +12,6 @@ import { defineConfig, defineForm, - FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { @@ -22,7 +21,11 @@ import { field } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' -import { concatFields, getPersonInputFields } from './person' +import { + appendConditionalsToFields, + concatFields, + getPersonInputFields +} from './person' const informantTypes = { SPOUSE: 'SPOUSE', @@ -449,21 +452,17 @@ const BIRTH_FORM = defineForm({ }, options: birthInformantTypeOptions }, - ...getPersonInputFields('informant').map( - (personInputField) => - ({ - ...personInputField, - conditionals: [ - ...personInputField.conditionals, - { - type: 'HIDE', - conditional: field( - concatFields(['informant', 'relation']) - ).isInArray(['MOTHER', 'FATHER']) - } - ] - } as FieldConfig) - ), + ...appendConditionalsToFields({ + inputFields: getPersonInputFields('informant'), + newConditionals: [ + { + type: 'HIDE', + conditional: field( + concatFields(['informant', 'relation']) + ).isInArray(['MOTHER', 'FATHER']) + } + ] + }), { id: 'informant.phoneNo', type: 'TEXT', diff --git a/src/form/V2/countries.ts b/src/form/V2/countries.ts new file mode 100644 index 000000000..b1f1a908e --- /dev/null +++ b/src/form/V2/countries.ts @@ -0,0 +1,1513 @@ +/* + * 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 { SelectOption } from '@opencrvs/toolkit/events' + +const messages = { + AFG: { + id: 'countries.AFG', + defaultMessage: 'Afghanistan', + description: 'ISO Country: AFG' + }, + ALA: { + id: 'countries.ALA', + defaultMessage: 'Åland Islands', + description: 'ISO Country: ALA' + }, + ALB: { + id: 'countries.ALB', + defaultMessage: 'Albania', + description: 'ISO Country: ALB' + }, + DZA: { + id: 'countries.DZA', + defaultMessage: 'Algeria', + description: 'ISO Country: DZA' + }, + ASM: { + id: 'countries.ASM', + defaultMessage: 'American Samoa', + description: 'ISO Country: ASM' + }, + AND: { + id: 'countries.AND', + defaultMessage: 'Andorra', + description: 'ISO Country: AND' + }, + AGO: { + id: 'countries.AGO', + defaultMessage: 'Angola', + description: 'ISO Country: AGO' + }, + AIA: { + id: 'countries.AIA', + defaultMessage: 'Anguilla', + description: 'ISO Country: AIA' + }, + ATA: { + id: 'countries.ATA', + defaultMessage: 'Antarctica', + description: 'ISO Country: ATA' + }, + ATG: { + id: 'countries.ATG', + defaultMessage: 'Antigua and Barbuda', + description: 'ISO Country: ATG' + }, + ARG: { + id: 'countries.ARG', + defaultMessage: 'Argentina', + description: 'ISO Country: ARG' + }, + ARM: { + id: 'countries.ARM', + defaultMessage: 'Armenia', + description: 'ISO Country: ARM' + }, + ABW: { + id: 'countries.ABW', + defaultMessage: 'Aruba', + description: 'ISO Country: ABW' + }, + AUS: { + id: 'countries.AUS', + defaultMessage: 'Australia', + description: 'ISO Country: AUS' + }, + AUT: { + id: 'countries.AUT', + defaultMessage: 'Austria', + description: 'ISO Country: AUT' + }, + AZE: { + id: 'countries.AZE', + defaultMessage: 'Azerbaijan', + description: 'ISO Country: AZE' + }, + BHS: { + id: 'countries.BHS', + defaultMessage: 'Bahamas', + description: 'ISO Country: BHS' + }, + BHR: { + id: 'countries.BHR', + defaultMessage: 'Bahrain', + description: 'ISO Country: BHR' + }, + BGD: { + id: 'countries.BGD', + defaultMessage: 'Bangladesh', + description: 'ISO Country: BGD' + }, + BRB: { + id: 'countries.BRB', + defaultMessage: 'Barbados', + description: 'ISO Country: BRB' + }, + BLR: { + id: 'countries.BLR', + defaultMessage: 'Belarus', + description: 'ISO Country: BLR' + }, + BEL: { + id: 'countries.BEL', + defaultMessage: 'Belgium', + description: 'ISO Country: BEL' + }, + BLZ: { + id: 'countries.BLZ', + defaultMessage: 'Belize', + description: 'ISO Country: BLZ' + }, + BEN: { + id: 'countries.BEN', + defaultMessage: 'Benin', + description: 'ISO Country: BEN' + }, + BMU: { + id: 'countries.BMU', + defaultMessage: 'Bermuda', + description: 'ISO Country: BMU' + }, + BTN: { + id: 'countries.BTN', + defaultMessage: 'Bhutan', + description: 'ISO Country: BTN' + }, + BOL: { + id: 'countries.BOL', + defaultMessage: 'Bolivia (Plurinational State of)', + description: 'ISO Country: BOL' + }, + BES: { + id: 'countries.BES', + defaultMessage: 'Bonaire, Sint Eustatius and Saba', + description: 'ISO Country: BES' + }, + BIH: { + id: 'countries.BIH', + defaultMessage: 'Bosnia and Herzegovina', + description: 'ISO Country: BIH' + }, + BWA: { + id: 'countries.BWA', + defaultMessage: 'Botswana', + description: 'ISO Country: BWA' + }, + BVT: { + id: 'countries.BVT', + defaultMessage: 'Bouvet Island', + description: 'ISO Country: BVT' + }, + BRA: { + id: 'countries.BRA', + defaultMessage: 'Brazil', + description: 'ISO Country: BRA' + }, + IOT: { + id: 'countries.IOT', + defaultMessage: 'British Indian Ocean Territory', + description: 'ISO Country: IOT' + }, + VGB: { + id: 'countries.VGB', + defaultMessage: 'British Virgin Islands', + description: 'ISO Country: VGB' + }, + BRN: { + id: 'countries.BRN', + defaultMessage: 'Brunei Darussalam', + description: 'ISO Country: BRN' + }, + BGR: { + id: 'countries.BGR', + defaultMessage: 'Bulgaria', + description: 'ISO Country: BGR' + }, + BFA: { + id: 'countries.BFA', + defaultMessage: 'Burkina Faso', + description: 'ISO Country: BFA' + }, + BDI: { + id: 'countries.BDI', + defaultMessage: 'Burundi', + description: 'ISO Country: BDI' + }, + CPV: { + id: 'countries.CPV', + defaultMessage: 'Cabo Verde', + description: 'ISO Country: CPV' + }, + KHM: { + id: 'countries.KHM', + defaultMessage: 'Cambodia', + description: 'ISO Country: KHM' + }, + CMR: { + id: 'countries.CMR', + defaultMessage: 'Cameroon', + description: 'ISO Country: CMR' + }, + CAN: { + id: 'countries.CAN', + defaultMessage: 'Canada', + description: 'ISO Country: CAN' + }, + CYM: { + id: 'countries.CYM', + defaultMessage: 'Cayman Islands', + description: 'ISO Country: CYM' + }, + CAF: { + id: 'countries.CAF', + defaultMessage: 'Central African Republic', + description: 'ISO Country: CAF' + }, + TCD: { + id: 'countries.TCD', + defaultMessage: 'Chad', + description: 'ISO Country: TCD' + }, + CHL: { + id: 'countries.CHL', + defaultMessage: 'Chile', + description: 'ISO Country: CHL' + }, + CHN: { + id: 'countries.CHN', + defaultMessage: 'China', + description: 'ISO Country: CHN' + }, + HKG: { + id: 'countries.HKG', + defaultMessage: '"China, Hong Kong Special Administrative Region"', + description: 'ISO Country: HKG' + }, + MAC: { + id: 'countries.MAC', + defaultMessage: '"China, Macao Special Administrative Region"', + description: 'ISO Country: MAC' + }, + CXR: { + id: 'countries.CXR', + defaultMessage: 'Christmas Island', + description: 'ISO Country: CXR' + }, + CCK: { + id: 'countries.CCK', + defaultMessage: 'Cocos (Keeling) Islands', + description: 'ISO Country: CCK' + }, + COL: { + id: 'countries.COL', + defaultMessage: 'Colombia', + description: 'ISO Country: COL' + }, + COM: { + id: 'countries.COM', + defaultMessage: 'Comoros', + description: 'ISO Country: COM' + }, + COG: { + id: 'countries.COG', + defaultMessage: 'Congo', + description: 'ISO Country: COG' + }, + COK: { + id: 'countries.COK', + defaultMessage: 'Cook Islands', + description: 'ISO Country: COK' + }, + CRI: { + id: 'countries.CRI', + defaultMessage: 'Costa Rica', + description: 'ISO Country: CRI' + }, + CIV: { + id: 'countries.CIV', + defaultMessage: "Côte d'Ivoire", + description: 'ISO Country: CIV' + }, + HRV: { + id: 'countries.HRV', + defaultMessage: 'Croatia', + description: 'ISO Country: HRV' + }, + CUB: { + id: 'countries.CUB', + defaultMessage: 'Cuba', + description: 'ISO Country: CUB' + }, + CUW: { + id: 'countries.CUW', + defaultMessage: 'Curaçao', + description: 'ISO Country: CUW' + }, + CYP: { + id: 'countries.CYP', + defaultMessage: 'Cyprus', + description: 'ISO Country: CYP' + }, + CZE: { + id: 'countries.CZE', + defaultMessage: 'Czechia', + description: 'ISO Country: CZE' + }, + PRK: { + id: 'countries.PRK', + defaultMessage: "Democratic People's Republic of Korea", + description: 'PRK' + }, + COD: { + id: 'countries.COD', + defaultMessage: 'Democratic Republic of the Congo', + description: 'ISO Country: COD' + }, + DNK: { + id: 'countries.DNK', + defaultMessage: 'Denmark', + description: 'ISO Country: DNK' + }, + DJI: { + id: 'countries.DJI', + defaultMessage: 'Djibouti', + description: 'ISO Country: DJI' + }, + DMA: { + id: 'countries.DMA', + defaultMessage: 'Dominica', + description: 'ISO Country: DMA' + }, + DOM: { + id: 'countries.DOM', + defaultMessage: 'Dominican Republic', + description: 'ISO Country: DOM' + }, + ECU: { + id: 'countries.ECU', + defaultMessage: 'Ecuador', + description: 'ISO Country: ECU' + }, + EGY: { + id: 'countries.EGY', + defaultMessage: 'Egypt', + description: 'ISO Country: EGY' + }, + SLV: { + id: 'countries.SLV', + defaultMessage: 'El Salvador', + description: 'ISO Country: SLV' + }, + GNQ: { + id: 'countries.GNQ', + defaultMessage: 'Equatorial Guinea', + description: 'ISO Country: GNQ' + }, + ERI: { + id: 'countries.ERI', + defaultMessage: 'Eritrea', + description: 'ISO Country: ERI' + }, + EST: { + id: 'countries.EST', + defaultMessage: 'Estonia', + description: 'ISO Country: EST' + }, + SWZ: { + id: 'countries.SWZ', + defaultMessage: 'Eswatini', + description: 'ISO Country: SWZ' + }, + ETH: { + id: 'countries.ETH', + defaultMessage: 'Ethiopia', + description: 'ISO Country: ETH' + }, + FLK: { + id: 'countries.FLK', + defaultMessage: 'Falkland Islands (Malvinas)', + description: 'ISO Country: FLK' + }, + FAR: { + id: 'countries.FAR', + defaultMessage: 'Farajaland', + description: 'Fictional country for OpenCRSV demo' + }, + FRO: { + id: 'countries.FRO', + defaultMessage: 'Faroe Islands', + description: 'ISO Country: FRO' + }, + FJI: { + id: 'countries.FJI', + defaultMessage: 'Fiji', + description: 'ISO Country: FJI' + }, + FIN: { + id: 'countries.FIN', + defaultMessage: 'Finland', + description: 'ISO Country: FIN' + }, + FRA: { + id: 'countries.FRA', + defaultMessage: 'France', + description: 'ISO Country: FRA' + }, + GUF: { + id: 'countries.GUF', + defaultMessage: 'French Guiana', + description: 'ISO Country: GUF' + }, + PYF: { + id: 'countries.PYF', + defaultMessage: 'French Polynesia', + description: 'ISO Country: PYF' + }, + ATF: { + id: 'countries.ATF', + defaultMessage: 'French Southern Territories', + description: 'ISO Country: ATF' + }, + GAB: { + id: 'countries.GAB', + defaultMessage: 'Gabon', + description: 'ISO Country: GAB' + }, + GMB: { + id: 'countries.GMB', + defaultMessage: 'Gambia', + description: 'ISO Country: GMB' + }, + GEO: { + id: 'countries.GEO', + defaultMessage: 'Georgia', + description: 'ISO Country: GEO' + }, + DEU: { + id: 'countries.DEU', + defaultMessage: 'Germany', + description: 'ISO Country: DEU' + }, + GHA: { + id: 'countries.GHA', + defaultMessage: 'Ghana', + description: 'ISO Country: GHA' + }, + GIB: { + id: 'countries.GIB', + defaultMessage: 'Gibraltar', + description: 'ISO Country: GIB' + }, + GRC: { + id: 'countries.GRC', + defaultMessage: 'Greece', + description: 'ISO Country: GRC' + }, + GRL: { + id: 'countries.GRL', + defaultMessage: 'Greenland', + description: 'ISO Country: GRL' + }, + GRD: { + id: 'countries.GRD', + defaultMessage: 'Grenada', + description: 'ISO Country: GRD' + }, + GLP: { + id: 'countries.GLP', + defaultMessage: 'Guadeloupe', + description: 'ISO Country: GLP' + }, + GUM: { + id: 'countries.GUM', + defaultMessage: 'Guam', + description: 'ISO Country: GUM' + }, + GTM: { + id: 'countries.GTM', + defaultMessage: 'Guatemala', + description: 'ISO Country: GTM' + }, + GGY: { + id: 'countries.GGY', + defaultMessage: 'Guernsey', + description: 'ISO Country: GGY' + }, + GIN: { + id: 'countries.GIN', + defaultMessage: 'Guinea', + description: 'ISO Country: GIN' + }, + GNB: { + id: 'countries.GNB', + defaultMessage: 'Guinea-Bissau', + description: 'ISO Country: GNB' + }, + GUY: { + id: 'countries.GUY', + defaultMessage: 'Guyana', + description: 'ISO Country: GUY' + }, + HTI: { + id: 'countries.HTI', + defaultMessage: 'Haiti', + description: 'ISO Country: HTI' + }, + HMD: { + id: 'countries.HMD', + defaultMessage: 'Heard Island and McDonald Islands', + description: 'ISO Country: HMD' + }, + VAT: { + id: 'countries.VAT', + defaultMessage: 'Holy See', + description: 'ISO Country: VAT' + }, + HND: { + id: 'countries.HND', + defaultMessage: 'Honduras', + description: 'ISO Country: HND' + }, + HUN: { + id: 'countries.HUN', + defaultMessage: 'Hungary', + description: 'ISO Country: HUN' + }, + ISL: { + id: 'countries.ISL', + defaultMessage: 'Iceland', + description: 'ISO Country: ISL' + }, + IND: { + id: 'countries.IND', + defaultMessage: 'India', + description: 'ISO Country: IND' + }, + IDN: { + id: 'countries.IDN', + defaultMessage: 'Indonesia', + description: 'ISO Country: IDN' + }, + IRN: { + id: 'countries.IRN', + defaultMessage: 'Iran (Islamic Republic of)', + description: 'ISO Country: IRN' + }, + IRQ: { + id: 'countries.IRQ', + defaultMessage: 'Iraq', + description: 'ISO Country: IRQ' + }, + IRL: { + id: 'countries.IRL', + defaultMessage: 'Ireland', + description: 'ISO Country: IRL' + }, + IMN: { + id: 'countries.IMN', + defaultMessage: 'Isle of Man', + description: 'ISO Country: IMN' + }, + ISR: { + id: 'countries.ISR', + defaultMessage: 'Israel', + description: 'ISO Country: ISR' + }, + ITA: { + id: 'countries.ITA', + defaultMessage: 'Italy', + description: 'ISO Country: ITA' + }, + JAM: { + id: 'countries.JAM', + defaultMessage: 'Jamaica', + description: 'ISO Country: JAM' + }, + JPN: { + id: 'countries.JPN', + defaultMessage: 'Japan', + description: 'ISO Country: JPN' + }, + JEY: { + id: 'countries.JEY', + defaultMessage: 'Jersey', + description: 'ISO Country: JEY' + }, + JOR: { + id: 'countries.JOR', + defaultMessage: 'Jordan', + description: 'ISO Country: JOR' + }, + KAZ: { + id: 'countries.KAZ', + defaultMessage: 'Kazakhstan', + description: 'ISO Country: KAZ' + }, + KEN: { + id: 'countries.KEN', + defaultMessage: 'Kenya', + description: 'ISO Country: KEN' + }, + KIR: { + id: 'countries.KIR', + defaultMessage: 'Kiribati', + description: 'ISO Country: KIR' + }, + KWT: { + id: 'countries.KWT', + defaultMessage: 'Kuwait', + description: 'ISO Country: KWT' + }, + KGZ: { + id: 'countries.KGZ', + defaultMessage: 'Kyrgyzstan', + description: 'ISO Country: KGZ' + }, + LAO: { + id: 'countries.KGZ', + defaultMessage: "Lao People's Democratic Republic Republic", + description: 'ISO Country: LAO' + }, + LVA: { + id: 'countries.LVA', + defaultMessage: 'Latvia', + description: 'ISO Country: LVA' + }, + LBN: { + id: 'countries.LBN', + defaultMessage: 'Lebanon', + description: 'ISO Country: LBN' + }, + LSO: { + id: 'countries.LSO', + defaultMessage: 'Lesotho', + description: 'ISO Country: LSO' + }, + LBR: { + id: 'countries.LBR', + defaultMessage: 'Liberia', + description: 'ISO Country: LBR' + }, + LBY: { + id: 'countries.LBY', + defaultMessage: 'Libya', + description: 'ISO Country: LBY' + }, + LIE: { + id: 'countries.LIE', + defaultMessage: 'Liechtenstein', + description: 'ISO Country: LIE' + }, + LTU: { + id: 'countries.LTU', + defaultMessage: 'Lithuania', + description: 'ISO Country: LTU' + }, + LUX: { + id: 'countries.LUX', + defaultMessage: 'Luxembourg', + description: 'ISO Country: LUX' + }, + MDG: { + id: 'countries.MDG', + defaultMessage: 'Madagascar', + description: 'ISO Country: MDG' + }, + MWI: { + id: 'countries.MWI', + defaultMessage: 'Malawi', + description: 'ISO Country: MWI' + }, + MYS: { + id: 'countries.MYS', + defaultMessage: 'Malaysia', + description: 'ISO Country: MYS' + }, + MDV: { + id: 'countries.MDV', + defaultMessage: 'Maldives', + description: 'ISO Country: MDV' + }, + MLI: { + id: 'countries.MLI', + defaultMessage: 'Mali', + description: 'ISO Country: MLI' + }, + MLT: { + id: 'countries.MLT', + defaultMessage: 'Malta', + description: 'ISO Country: MLT' + }, + MHL: { + id: 'countries.MHL', + defaultMessage: 'Marshall Islands', + description: 'ISO Country: MHL' + }, + MTQ: { + id: 'countries.MTQ', + defaultMessage: 'Martinique', + description: 'ISO Country: MTQ' + }, + MRT: { + id: 'countries.MRT', + defaultMessage: 'Mauritania', + description: 'ISO Country: MRT' + }, + MUS: { + id: 'countries.MUS', + defaultMessage: 'Mauritius', + description: 'ISO Country: MUS' + }, + MYT: { + id: 'countries.MYT', + defaultMessage: 'Mayotte', + description: 'ISO Country: MYT' + }, + MEX: { + id: 'countries.MEX', + defaultMessage: 'Mexico', + description: 'ISO Country: MEX' + }, + FSM: { + id: 'countries.FSM', + defaultMessage: 'Micronesia (Federated States of)', + description: 'ISO Country: FSM' + }, + + MCO: { + id: 'countries.MCO', + defaultMessage: 'Monaco', + description: 'ISO Country: MCO' + }, + MNG: { + id: 'countries.MNG', + defaultMessage: 'Mongolia', + description: 'ISO Country: MNG' + }, + MNE: { + id: 'countries.MNE', + defaultMessage: 'Montenegro', + description: 'ISO Country: MNE' + }, + MSR: { + id: 'countries.MSR', + defaultMessage: 'Montserrat', + description: 'ISO Country: MSR' + }, + MAR: { + id: 'countries.MAR', + defaultMessage: 'Morocco', + description: 'ISO Country: MAR' + }, + MOZ: { + id: 'countries.MOZ', + defaultMessage: 'Mozambique', + description: 'ISO Country: MOZ' + }, + MMR: { + id: 'countries.MMR', + defaultMessage: 'Myanmar', + description: 'ISO Country: MMR' + }, + NAM: { + id: 'countries.NAM', + defaultMessage: 'Namibia', + description: 'ISO Country: NAM' + }, + NRU: { + id: 'countries.NRU', + defaultMessage: 'Nauru', + description: 'ISO Country: NRU' + }, + NPL: { + id: 'countries.NPL', + defaultMessage: 'Nepal', + description: 'ISO Country: NPL' + }, + NLD: { + id: 'countries.NLD', + defaultMessage: 'Netherlands', + description: 'ISO Country: NLD' + }, + NCL: { + id: 'countries.NCL', + defaultMessage: 'New Caledonia', + description: 'ISO Country: NCL' + }, + NZL: { + id: 'countries.NZL', + defaultMessage: 'New Zealand', + description: 'ISO Country: NZL' + }, + NIC: { + id: 'countries.NIC', + defaultMessage: 'Nicaragua', + description: 'ISO Country: NIC' + }, + NER: { + id: 'countries.NER', + defaultMessage: 'Niger', + description: 'ISO Country: NER' + }, + NGA: { + id: 'countries.NGA', + defaultMessage: 'Nigeria', + description: 'ISO Country: NGA' + }, + NIU: { + id: 'countries.NIU', + defaultMessage: 'Niue', + description: 'ISO Country: NIU' + }, + NFK: { + id: 'countries.NFK', + defaultMessage: 'Norfolk Island', + description: 'ISO Country: NFK' + }, + MNP: { + id: 'countries.MNP', + defaultMessage: 'Northern Mariana Islands', + description: 'ISO Country: MNP' + }, + NOR: { + id: 'countries.NOR', + defaultMessage: 'Norway', + description: 'ISO Country: NOR' + }, + OMN: { + id: 'countries.OMN', + defaultMessage: 'Oman', + description: 'ISO Country: OMN' + }, + PAK: { + id: 'countries.PAK', + defaultMessage: 'Pakistan', + description: 'ISO Country: PAK' + }, + PLW: { + id: 'countries.PLW', + defaultMessage: 'Palau', + description: 'ISO Country: PLW' + }, + PAN: { + id: 'countries.PAN', + defaultMessage: 'Panama', + description: 'ISO Country: PAN' + }, + PNG: { + id: 'countries.PNG', + defaultMessage: 'Papua New Guinea', + description: 'ISO Country: PNG' + }, + PRY: { + id: 'countries.PRY', + defaultMessage: 'Paraguay', + description: 'ISO Country: PRY' + }, + PER: { + id: 'countries.PER', + defaultMessage: 'Peru', + description: 'ISO Country: PER' + }, + PHL: { + id: 'countries.PHL', + defaultMessage: 'Philippines', + description: 'ISO Country: PHL' + }, + PCN: { + id: 'countries.PCN', + defaultMessage: 'Pitcairn', + description: 'ISO Country: PCN' + }, + POL: { + id: 'countries.POL', + defaultMessage: 'Poland', + description: 'ISO Country: POL' + }, + PRT: { + id: 'countries.PRT', + defaultMessage: 'Portugal', + description: 'ISO Country: PRT' + }, + PRI: { + id: 'countries.PRI', + defaultMessage: 'Puerto Rico', + description: 'ISO Country: PRI' + }, + QAT: { + id: 'countries.QAT', + defaultMessage: 'Qatar', + description: 'ISO Country: QAT' + }, + KOR: { + id: 'countries.KOR', + defaultMessage: 'Republic of Korea', + description: 'ISO Country: KOR' + }, + MDA: { + id: 'countries.MDA', + defaultMessage: 'Republic of Moldova', + description: 'ISO Country: MDA' + }, + REU: { + id: 'countries.REU', + defaultMessage: 'Réunion', + description: 'ISO Country: REU' + }, + ROU: { + id: 'countries.ROU', + defaultMessage: 'Romania', + description: 'ISO Country: ROU' + }, + RUS: { + id: 'countries.RUS', + defaultMessage: 'Russian Federation', + description: 'ISO Country: RUS' + }, + RWA: { + id: 'countries.RWA', + defaultMessage: 'Rwanda', + description: 'ISO Country: RWA' + }, + BLM: { + id: 'countries.BLM', + defaultMessage: 'Saint Barthélemy', + description: 'ISO Country: BLM' + }, + SHN: { + id: 'countries.SHN', + defaultMessage: 'Saint Helena', + description: 'ISO Country: SHN' + }, + KNA: { + id: 'countries.KNA', + defaultMessage: 'Saint Kitts and Nevis', + description: 'ISO Country: KNA' + }, + LCA: { + id: 'countries.LCA', + defaultMessage: 'Saint Lucia', + description: 'ISO Country: LCA' + }, + MAF: { + id: 'countries.MAF', + defaultMessage: 'Saint Martin (French Part)', + description: 'ISO Country: MAF' + }, + SPM: { + id: 'countries.SPM', + defaultMessage: 'Saint Pierre and Miquelon', + description: 'ISO Country: SPM' + }, + VCT: { + id: 'countries.VCT', + defaultMessage: 'Saint Vincent and the Grenadines', + description: 'ISO Country: VCT' + }, + WSM: { + id: 'countries.WSM', + defaultMessage: 'Samoa', + description: 'ISO Country: WSM' + }, + SMR: { + id: 'countries.SMR', + defaultMessage: 'San Marino', + description: 'ISO Country: SMR' + }, + STP: { + id: 'countries.STP', + defaultMessage: 'Sao Tome and Principe', + description: 'ISO Country: STP' + }, + SAU: { + id: 'countries.SAU', + defaultMessage: 'Saudi Arabia', + description: 'ISO Country: SAU' + }, + SEN: { + id: 'countries.SEN', + defaultMessage: 'Senegal', + description: 'ISO Country: SEN' + }, + SRB: { + id: 'countries.SRB', + defaultMessage: 'Serbia', + description: 'ISO Country: SRB' + }, + SYC: { + id: 'countries.SYC', + defaultMessage: 'Seychelles', + description: 'ISO Country: SYC' + }, + SLE: { + id: 'countries.SLE', + defaultMessage: 'Sierra Leone', + description: 'ISO Country: SLE' + }, + SGP: { + id: 'countries.SGP', + defaultMessage: 'Singapore', + description: 'ISO Country: SGP' + }, + SXM: { + id: 'countries.SXM', + defaultMessage: 'Sint Maarten (Dutch part)', + description: 'ISO Country: SXM' + }, + SVK: { + id: 'countries.SVK', + defaultMessage: 'Slovakia', + description: 'ISO Country: SVK' + }, + SVN: { + id: 'countries.SVN', + defaultMessage: 'Slovenia', + description: 'ISO Country: SVN' + }, + SLB: { + id: 'countries.SLB', + defaultMessage: 'Solomon Islands', + description: 'ISO Country: SLB' + }, + SOM: { + id: 'countries.SOM', + defaultMessage: 'Somalia', + description: 'ISO Country: SOM' + }, + ZAF: { + id: 'countries.ZAF', + defaultMessage: 'South Africa', + description: 'ISO Country: ZAF' + }, + SGS: { + id: 'countries.SGS', + defaultMessage: 'South Georgia and the South Sandwich Islands', + description: 'ISO Country: SGS' + }, + SSD: { + id: 'countries.SSD', + defaultMessage: 'South Sudan', + description: 'ISO Country: SSD' + }, + ESP: { + id: 'countries.ESP', + defaultMessage: 'Spain', + description: 'ISO Country: ESP' + }, + LKA: { + id: 'countries.LKA', + defaultMessage: 'Sri Lanka', + description: 'ISO Country: LKA' + }, + PSE: { + id: 'countries.PSE', + defaultMessage: 'State of Palestine', + description: 'ISO Country: PSE' + }, + SDN: { + id: 'countries.SDN', + defaultMessage: 'Sudan', + description: 'ISO Country: SDN' + }, + SUR: { + id: 'countries.SUR', + defaultMessage: 'Suriname', + description: 'ISO Country: SUR' + }, + SJM: { + id: 'countries.SJM', + defaultMessage: 'Svalbard and Jan Mayen Islands', + description: 'ISO Country: SJM' + }, + SWE: { + id: 'countries.SWE', + defaultMessage: 'Sweden', + description: 'ISO Country: SWE' + }, + CHE: { + id: 'countries.CHE', + defaultMessage: 'Switzerland', + description: 'ISO Country: CHE' + }, + SYR: { + id: 'countries.SYR', + defaultMessage: 'Syrian Arab Republic', + description: 'ISO Country: SYR' + }, + TJK: { + id: 'countries.TJK', + defaultMessage: 'Tajikistan', + description: 'ISO Country: TJK' + }, + THA: { + id: 'countries.THA', + defaultMessage: 'Thailand', + description: 'ISO Country: THA' + }, + MKD: { + id: 'countries.MKD', + defaultMessage: 'The former Yugoslav Republic of Macedonia', + description: 'ISO Country: MKD' + }, + TLS: { + id: 'countries.TLS', + defaultMessage: 'Timor-Leste', + description: 'ISO Country: TLS' + }, + TGO: { + id: 'countries.TGO', + defaultMessage: 'Togo', + description: 'ISO Country: TGO' + }, + TKL: { + id: 'countries.TKL', + defaultMessage: 'Tokelau', + description: 'ISO Country: TKL' + }, + TON: { + id: 'countries.TON', + defaultMessage: 'Tonga', + description: 'ISO Country: TON' + }, + TTO: { + id: 'countries.TTO', + defaultMessage: 'Trinidad and Tobago', + description: 'ISO Country: TTO' + }, + TUN: { + id: 'countries.TUN', + defaultMessage: 'Tunisia', + description: 'ISO Country: TUN' + }, + TUR: { + id: 'countries.TUR', + defaultMessage: 'Turkey', + description: 'ISO Country: TUR' + }, + TKM: { + id: 'countries.TKM', + defaultMessage: 'Turkmenistan', + description: 'ISO Country: TKM' + }, + TCA: { + id: 'countries.TCA', + defaultMessage: 'Turks and Caicos Islands', + description: 'ISO Country: TCA' + }, + TUV: { + id: 'countries.TUV', + defaultMessage: 'Tuvalu', + description: 'ISO Country: TUV' + }, + UGA: { + id: 'countries.UGA', + defaultMessage: 'Uganda', + description: 'ISO Country: UGA' + }, + UKR: { + id: 'countries.UKR', + defaultMessage: 'Ukraine', + description: 'ISO Country: UKR' + }, + ARE: { + id: 'countries.ARE', + defaultMessage: 'United Arab Emirates', + description: 'ISO Country: ARE' + }, + GBR: { + id: 'countries.GBR', + defaultMessage: 'United Kingdom of Great Britain and Northern Ireland', + description: 'ISO Country: GBR' + }, + TZA: { + id: 'countries.TZA', + defaultMessage: 'United Republic of Tanzania', + description: 'ISO Country: TZA' + }, + UMI: { + id: 'countries.UMI', + defaultMessage: 'United States Minor Outlying Islands', + description: 'ISO Country: UMI' + }, + USA: { + id: 'countries.USA', + defaultMessage: 'United States of America', + description: 'ISO Country: USA' + }, + VIR: { + id: 'countries.VIR', + defaultMessage: 'United States Virgin Islands', + description: 'ISO Country: VIR' + }, + URY: { + id: 'countries.URY', + defaultMessage: 'Uruguay', + description: 'ISO Country: URY' + }, + UZB: { + id: 'countries.UZB', + defaultMessage: 'Uzbekistan', + description: 'ISO Country: UZB' + }, + VUT: { + id: 'countries.VUT', + defaultMessage: 'Vanuatu', + description: 'ISO Country: VUT' + }, + VEN: { + id: 'countries.VEN', + defaultMessage: 'Venezuela (Bolivarian Republic of)', + description: 'ISO Country: VEN' + }, + VNM: { + id: 'countries.VNM', + defaultMessage: 'Viet Nam', + description: 'ISO Country: VNM' + }, + WLF: { + id: 'countries.WLF', + defaultMessage: 'Wallis and Futuna Islands', + description: 'ISO Country: WLF' + }, + ESH: { + id: 'countries.ESH', + defaultMessage: 'Western Sahara', + description: 'ISO Country: ESH' + }, + YEM: { + id: 'countries.YEM', + defaultMessage: 'Yemen', + description: 'ISO Country: YEM' + }, + ZMB: { + id: 'countries.ZMB', + defaultMessage: 'Zambia', + description: 'ISO Country: ZMB' + }, + ZWE: { + id: 'countries.ZWE', + defaultMessage: 'Zimbabwe', + description: 'ISO Country ZWE' + } +} + +export const countries = [ + { value: 'AFG', label: messages.AFG }, + { value: 'ALA', label: messages.ALA }, + { value: 'ALB', label: messages.ALB }, + { value: 'DZA', label: messages.DZA }, + { value: 'ASM', label: messages.ASM }, + { value: 'AND', label: messages.AND }, + { value: 'AGO', label: messages.AGO }, + { value: 'AIA', label: messages.AIA }, + { value: 'ATA', label: messages.ATA }, + { value: 'ATG', label: messages.ATG }, + { value: 'ARG', label: messages.ARG }, + { value: 'ARM', label: messages.ARM }, + { value: 'ABW', label: messages.ABW }, + { value: 'AUS', label: messages.AUS }, + { value: 'AUT', label: messages.AUT }, + { value: 'AZE', label: messages.AZE }, + { value: 'BHS', label: messages.BHS }, + { value: 'BHR', label: messages.BHR }, + { value: 'BGD', label: messages.BGD }, + { value: 'BRB', label: messages.BRB }, + { value: 'BLR', label: messages.BLR }, + { value: 'BEL', label: messages.BEL }, + { value: 'BLZ', label: messages.BLZ }, + { value: 'BEN', label: messages.BEN }, + { value: 'BMU', label: messages.BMU }, + { value: 'BTN', label: messages.BTN }, + { value: 'BOL', label: messages.BOL }, + { value: 'BES', label: messages.BES }, + { value: 'BIH', label: messages.BIH }, + { value: 'BWA', label: messages.BWA }, + { value: 'BVT', label: messages.BVT }, + { value: 'BRA', label: messages.BRA }, + { value: 'IOT', label: messages.IOT }, + { value: 'VGB', label: messages.VGB }, + { value: 'BRN', label: messages.BRN }, + { value: 'BGR', label: messages.BGR }, + { value: 'BFA', label: messages.BFA }, + { value: 'BDI', label: messages.BDI }, + { value: 'CPV', label: messages.CPV }, + { value: 'KHM', label: messages.KHM }, + { value: 'CMR', label: messages.CMR }, + { value: 'CAN', label: messages.CAN }, + { value: 'CYM', label: messages.CYM }, + { value: 'CAF', label: messages.CAF }, + { value: 'TCD', label: messages.TCD }, + { value: 'CHL', label: messages.CHL }, + { value: 'CHN', label: messages.CHN }, + { value: 'HKG', label: messages.HKG }, + { value: 'MAC', label: messages.MAC }, + { value: 'CXR', label: messages.CXR }, + { value: 'CCK', label: messages.CCK }, + { value: 'COL', label: messages.COL }, + { value: 'COM', label: messages.COM }, + { value: 'COG', label: messages.COG }, + { value: 'COK', label: messages.COK }, + { value: 'CRI', label: messages.CRI }, + { value: 'CIV', label: messages.CIV }, + { value: 'HRV', label: messages.HRV }, + { value: 'CUB', label: messages.CUB }, + { value: 'CUW', label: messages.CUW }, + { value: 'CYP', label: messages.CYP }, + { value: 'CZE', label: messages.CZE }, + { value: 'PRK', label: messages.PRK }, + { value: 'COD', label: messages.COD }, + { value: 'DNK', label: messages.DNK }, + { value: 'DJI', label: messages.DJI }, + { value: 'DMA', label: messages.DMA }, + { value: 'DOM', label: messages.DOM }, + { value: 'ECU', label: messages.ECU }, + { value: 'EGY', label: messages.EGY }, + { value: 'SLV', label: messages.SLV }, + { value: 'GNQ', label: messages.GNQ }, + { value: 'ERI', label: messages.ERI }, + { value: 'EST', label: messages.EST }, + { value: 'SWZ', label: messages.SWZ }, + { value: 'ETH', label: messages.ETH }, + { value: 'FAR', label: messages.FAR }, + { value: 'FLK', label: messages.FLK }, + { value: 'FRO', label: messages.FRO }, + { value: 'FJI', label: messages.FJI }, + { value: 'FIN', label: messages.FIN }, + { value: 'FRA', label: messages.FRA }, + { value: 'GUF', label: messages.GUF }, + { value: 'PYF', label: messages.PYF }, + { value: 'ATF', label: messages.ATF }, + { value: 'GAB', label: messages.GAB }, + { value: 'GMB', label: messages.GMB }, + { value: 'GEO', label: messages.GEO }, + { value: 'DEU', label: messages.DEU }, + { value: 'GHA', label: messages.GHA }, + { value: 'GIB', label: messages.GIB }, + { value: 'GRC', label: messages.GRC }, + { value: 'GRL', label: messages.GRL }, + { value: 'GRD', label: messages.GRD }, + { value: 'GLP', label: messages.GLP }, + { value: 'GUM', label: messages.GUM }, + { value: 'GTM', label: messages.GTM }, + { value: 'GGY', label: messages.GGY }, + { value: 'GIN', label: messages.GIN }, + { value: 'GNB', label: messages.GNB }, + { value: 'GUY', label: messages.GUY }, + { value: 'HTI', label: messages.HTI }, + { value: 'HMD', label: messages.HMD }, + { value: 'VAT', label: messages.VAT }, + { value: 'HND', label: messages.HND }, + { value: 'HUN', label: messages.HUN }, + { value: 'ISL', label: messages.ISL }, + { value: 'IND', label: messages.IND }, + { value: 'IDN', label: messages.IDN }, + { value: 'IRN', label: messages.IRN }, + { value: 'IRQ', label: messages.IRQ }, + { value: 'IRL', label: messages.IRL }, + { value: 'IMN', label: messages.IMN }, + { value: 'ISR', label: messages.ISR }, + { value: 'ITA', label: messages.ITA }, + { value: 'JAM', label: messages.JAM }, + { value: 'JPN', label: messages.JPN }, + { value: 'JEY', label: messages.JEY }, + { value: 'JOR', label: messages.JOR }, + { value: 'KAZ', label: messages.KAZ }, + { value: 'KEN', label: messages.KEN }, + { value: 'KIR', label: messages.KIR }, + { value: 'KWT', label: messages.KWT }, + { value: 'KGZ', label: messages.KGZ }, + { value: 'LAO', label: messages.LAO }, + { value: 'LVA', label: messages.LVA }, + { value: 'LBN', label: messages.LBN }, + { value: 'LSO', label: messages.LSO }, + { value: 'LBR', label: messages.LBR }, + { value: 'LBY', label: messages.LBY }, + { value: 'LIE', label: messages.LIE }, + { value: 'LTU', label: messages.LTU }, + { value: 'LUX', label: messages.LUX }, + { value: 'MDG', label: messages.MDG }, + { value: 'MWI', label: messages.MWI }, + { value: 'MYS', label: messages.MYS }, + { value: 'MDV', label: messages.MDV }, + { value: 'MLI', label: messages.MLI }, + { value: 'MLT', label: messages.MLT }, + { value: 'MHL', label: messages.MHL }, + { value: 'MTQ', label: messages.MTQ }, + { value: 'MRT', label: messages.MRT }, + { value: 'MUS', label: messages.MUS }, + { value: 'MYT', label: messages.MYT }, + { value: 'MEX', label: messages.MEX }, + { value: 'FSM', label: messages.FSM }, + { value: 'MCO', label: messages.MCO }, + { value: 'MNG', label: messages.MNG }, + { value: 'MNE', label: messages.MNE }, + { value: 'MSR', label: messages.MSR }, + { value: 'MAR', label: messages.MAR }, + { value: 'MOZ', label: messages.MOZ }, + { value: 'MMR', label: messages.MMR }, + { value: 'NAM', label: messages.NAM }, + { value: 'NRU', label: messages.NRU }, + { value: 'NPL', label: messages.NPL }, + { value: 'NLD', label: messages.NLD }, + { value: 'NCL', label: messages.NCL }, + { value: 'NZL', label: messages.NZL }, + { value: 'NIC', label: messages.NIC }, + { value: 'NER', label: messages.NER }, + { value: 'NGA', label: messages.NGA }, + { value: 'NIU', label: messages.NIU }, + { value: 'NFK', label: messages.NFK }, + { value: 'MNP', label: messages.MNP }, + { value: 'NOR', label: messages.NOR }, + { value: 'OMN', label: messages.OMN }, + { value: 'PAK', label: messages.PAK }, + { value: 'PLW', label: messages.PLW }, + { value: 'PAN', label: messages.PAN }, + { value: 'PNG', label: messages.PNG }, + { value: 'PRY', label: messages.PRY }, + { value: 'PER', label: messages.PER }, + { value: 'PHL', label: messages.PHL }, + { value: 'PCN', label: messages.PCN }, + { value: 'POL', label: messages.POL }, + { value: 'PRT', label: messages.PRT }, + { value: 'PRI', label: messages.PRI }, + { value: 'QAT', label: messages.QAT }, + { value: 'KOR', label: messages.KOR }, + { value: 'MDA', label: messages.MDA }, + { value: 'REU', label: messages.REU }, + { value: 'ROU', label: messages.ROU }, + { value: 'RUS', label: messages.RUS }, + { value: 'RWA', label: messages.RWA }, + { value: 'BLM', label: messages.BLM }, + { value: 'SHN', label: messages.SHN }, + { value: 'KNA', label: messages.KNA }, + { value: 'LCA', label: messages.LCA }, + { value: 'MAF', label: messages.MAF }, + { value: 'SPM', label: messages.SPM }, + { value: 'VCT', label: messages.VCT }, + { value: 'WSM', label: messages.WSM }, + { value: 'SMR', label: messages.SMR }, + { value: 'STP', label: messages.STP }, + { value: 'SAU', label: messages.SAU }, + { value: 'SEN', label: messages.SEN }, + { value: 'SRB', label: messages.SRB }, + { value: 'SYC', label: messages.SYC }, + { value: 'SLE', label: messages.SLE }, + { value: 'SGP', label: messages.SGP }, + { value: 'SXM', label: messages.SXM }, + { value: 'SVK', label: messages.SVK }, + { value: 'SVN', label: messages.SVN }, + { value: 'SLB', label: messages.SLB }, + { value: 'SOM', label: messages.SOM }, + { value: 'ZAF', label: messages.ZAF }, + { value: 'SGS', label: messages.SGS }, + { value: 'SSD', label: messages.SSD }, + { value: 'ESP', label: messages.ESP }, + { value: 'LKA', label: messages.LKA }, + { value: 'PSE', label: messages.PSE }, + { value: 'SDN', label: messages.SDN }, + { value: 'SUR', label: messages.SUR }, + { value: 'SJM', label: messages.SJM }, + { value: 'SWE', label: messages.SWE }, + { value: 'CHE', label: messages.CHE }, + { value: 'SYR', label: messages.SYR }, + { value: 'TJK', label: messages.TJK }, + { value: 'THA', label: messages.THA }, + { value: 'MKD', label: messages.MKD }, + { value: 'TLS', label: messages.TLS }, + { value: 'TGO', label: messages.TGO }, + { value: 'TKL', label: messages.TKL }, + { value: 'TON', label: messages.TON }, + { value: 'TTO', label: messages.TTO }, + { value: 'TUN', label: messages.TUN }, + { value: 'TUR', label: messages.TUR }, + { value: 'TKM', label: messages.TKM }, + { value: 'TCA', label: messages.TCA }, + { value: 'TUV', label: messages.TUV }, + { value: 'UGA', label: messages.UGA }, + { value: 'UKR', label: messages.UKR }, + { value: 'ARE', label: messages.ARE }, + { value: 'GBR', label: messages.GBR }, + { value: 'TZA', label: messages.TZA }, + { value: 'UMI', label: messages.UMI }, + { value: 'USA', label: messages.USA }, + { value: 'VIR', label: messages.VIR }, + { value: 'URY', label: messages.URY }, + { value: 'UZB', label: messages.UZB }, + { value: 'VUT', label: messages.VUT }, + { value: 'VEN', label: messages.VEN }, + { value: 'VNM', label: messages.VNM }, + { value: 'WLF', label: messages.WLF }, + { value: 'ESH', label: messages.ESH }, + { value: 'YEM', label: messages.YEM }, + { value: 'ZMB', label: messages.ZMB }, + { value: 'ZWE', label: messages.ZWE } + // Remove potentially null country values (Farajaland) +].filter((country): country is SelectOption => Boolean(country)) diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index 2b9363a6f..a2bf88b1d 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -9,8 +9,13 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { FieldConfig, SelectOption } from '@opencrvs/toolkit/events' +import { + FieldConditional, + FieldConfig, + SelectOption +} from '@opencrvs/toolkit/events' import { field } from '@opencrvs/toolkit/conditionals' +import { countries } from './countries' const idTypeOptions: SelectOption[] = [ { @@ -131,6 +136,23 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ } ] }, + { + id: `${person}.nationality`, + type: 'SELECT', + required: true, + label: { + defaultMessage: 'Nationality', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.nationality.label` + }, + options: countries, + conditionals: [] + }, + ...getIdFields(person), + ...getAddressFields(person) +] + +const getIdFields = (person: string): FieldConfig[] => [ { id: `${person}.idType`, type: 'SELECT', @@ -142,5 +164,275 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ }, options: idTypeOptions, conditionals: [] + }, + { + id: `${person}.nid`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'NID 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(concatFields([person, 'idType'])).isNotInArray([ + 'NATIONAL_ID' + ]) + } + ] + }, + { + id: `${person}.passport`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Passport 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(concatFields([person, 'idType'])).isNotInArray([ + 'PASSPORT' + ]) + } + ] + }, + { + id: `${person}.brn`, + type: 'TEXT', + required: true, + label: { + defaultMessage: 'Birth Registration 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(concatFields([person, 'idType'])).isNotInArray([ + 'BIRTH_REGISTRATION_NUMBER' + ]) + } + ] } ] + +const getAddressFields = (person: string): FieldConfig[] => { + const prefix = `${person}.address` + + const genericAddressFields: FieldConfig[] = [ + { + id: `${prefix}.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.state.label` + }, + conditionals: [] + }, + { + id: `${prefix}.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.district.label` + }, + conditionals: [] + }, + { + id: `${prefix}.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.town.label` + }, + conditionals: [] + }, + { + id: `${prefix}.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.addressLine1.label` + }, + conditionals: [] + }, + { + id: `${prefix}.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.addressLine2.label` + }, + conditionals: [] + }, + { + id: `${prefix}.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.addressLine3.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: 'TEXT', + 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` + }, + conditionals: [] + }, + { + id: `${prefix}.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.district.label` + }, + conditionals: [] + }, + { + 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}.village`, + type: 'TEXT', + required: false, + label: { + defaultMessage: 'Area / Ward / Mouja / Village', + description: 'This is the label for the field', + id: `event.birth.action.declare.form.section.${person}.field.address.village.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: [] + } + ] + + return [ + { + id: `${prefix}.country`, + type: 'SELECT', + 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` + }, + options: countries, + conditionals: [] + }, + ...appendConditionalsToFields({ + inputFields: genericAddressFields, + newConditionals: [ + { + type: 'HIDE', + conditional: field( + concatFields([person, 'address', 'country']) + ).isInArray(['FAR']) + } + ] + }), + ...appendConditionalsToFields({ + inputFields: farajalandAddressFields, + newConditionals: [ + { + type: 'HIDE', + conditional: field( + concatFields([person, 'address', 'country']) + ).isNotInArray(['FAR']) + } + ] + }) + ] +} + +export const appendConditionalsToFields = ({ + inputFields, + newConditionals +}: { + inputFields: FieldConfig[] + newConditionals: FieldConditional[] +}): FieldConfig[] => + inputFields.map( + (inputField) => + ({ + ...inputField, + conditionals: [...inputField.conditionals, ...newConditionals] + } as FieldConfig) + ) From ed40dd75ee8b242161288263d230bdadec2a5061 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 8 Jan 2025 18:11:38 +0600 Subject: [PATCH 14/25] refactor: create utils --- src/form/V2/birth.ts | 7 ++----- src/form/V2/person.ts | 26 ++------------------------ src/form/V2/utils.ts | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 src/form/V2/utils.ts diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index af8ba02c6..ec04d85dc 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -21,11 +21,8 @@ import { field } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' -import { - appendConditionalsToFields, - concatFields, - getPersonInputFields -} from './person' +import { getPersonInputFields } from './person' +import { appendConditionalsToFields, concatFields } from './utils' const informantTypes = { SPOUSE: 'SPOUSE', diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index a2bf88b1d..6f00ddd26 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -9,13 +9,10 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { - FieldConditional, - FieldConfig, - SelectOption -} from '@opencrvs/toolkit/events' +import { FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { field } from '@opencrvs/toolkit/conditionals' import { countries } from './countries' +import { appendConditionalsToFields, concatFields } from './utils' const idTypeOptions: SelectOption[] = [ { @@ -52,10 +49,6 @@ const idTypeOptions: SelectOption[] = [ } ] -export const concatFields = (fields: string[]) => { - return fields.join('____') -} - export const getPersonInputFields = (person: string): FieldConfig[] => [ { id: `${person}.firstname`, @@ -421,18 +414,3 @@ const getAddressFields = (person: string): FieldConfig[] => { }) ] } - -export const appendConditionalsToFields = ({ - inputFields, - newConditionals -}: { - inputFields: FieldConfig[] - newConditionals: FieldConditional[] -}): FieldConfig[] => - inputFields.map( - (inputField) => - ({ - ...inputField, - conditionals: [...inputField.conditionals, ...newConditionals] - } as FieldConfig) - ) diff --git a/src/form/V2/utils.ts b/src/form/V2/utils.ts new file mode 100644 index 000000000..fb376574c --- /dev/null +++ b/src/form/V2/utils.ts @@ -0,0 +1,31 @@ +/* + * 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 { FieldConditional, FieldConfig } from '@opencrvs/toolkit/events' + +export const appendConditionalsToFields = ({ + inputFields, + newConditionals +}: { + inputFields: FieldConfig[] + newConditionals: FieldConditional[] +}): FieldConfig[] => + inputFields.map( + (inputField) => + ({ + ...inputField, + conditionals: [...inputField.conditionals, ...newConditionals] + } as FieldConfig) + ) + +export const concatFields = (fields: string[]) => { + return fields.join('____') +} From 2b184f9f2f73aa452183fb904ee1a8dd45adf2ae Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 13:01:00 +0600 Subject: [PATCH 15/25] fix: handle undefined values in conditionals --- src/form/V2/birth.ts | 2 +- src/form/V2/person.ts | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index ec04d85dc..b688d97bd 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -456,7 +456,7 @@ const BIRTH_FORM = defineForm({ type: 'HIDE', conditional: field( concatFields(['informant', 'relation']) - ).isInArray(['MOTHER', 'FATHER']) + ).isUndefinedOrInArray(['MOTHER', 'FATHER']) } ] }), diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index 6f00ddd26..906651fb9 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -123,9 +123,9 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(concatFields([person, 'dobUnknown'])).isEqualTo( - 'false' - ) + conditional: field( + concatFields([person, 'dobUnknown']) + ).isUndefinedOrInArray(['false']) } ] }, @@ -170,9 +170,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(concatFields([person, 'idType'])).isNotInArray([ - 'NATIONAL_ID' - ]) + conditional: field( + concatFields([person, 'idType']) + ).isUndefinedOrNotInArray(['NATIONAL_ID']) } ] }, @@ -188,9 +188,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(concatFields([person, 'idType'])).isNotInArray([ - 'PASSPORT' - ]) + conditional: field( + concatFields([person, 'idType']) + ).isUndefinedOrNotInArray(['PASSPORT']) } ] }, @@ -206,9 +206,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(concatFields([person, 'idType'])).isNotInArray([ - 'BIRTH_REGISTRATION_NUMBER' - ]) + conditional: field( + concatFields([person, 'idType']) + ).isUndefinedOrNotInArray(['BIRTH_REGISTRATION_NUMBER']) } ] } @@ -397,7 +397,7 @@ const getAddressFields = (person: string): FieldConfig[] => { type: 'HIDE', conditional: field( concatFields([person, 'address', 'country']) - ).isInArray(['FAR']) + ).isUndefinedOrInArray(['FAR']) } ] }), @@ -408,7 +408,7 @@ const getAddressFields = (person: string): FieldConfig[] => { type: 'HIDE', conditional: field( concatFields([person, 'address', 'country']) - ).isNotInArray(['FAR']) + ).isUndefinedOrNotInArray(['FAR']) } ] }) From cd43a655613b2e3112d138a8a597231a40a29d45 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 14:35:01 +0600 Subject: [PATCH 16/25] feat: implement father and mother details --- src/form/V2/birth.ts | 146 ++++++++++++++++++++++++++++++++++++++++-- src/form/V2/person.ts | 128 +++++++++++++++++++++++++++++++++++- 2 files changed, 269 insertions(+), 5 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index b688d97bd..b324e515f 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -18,10 +18,11 @@ import { defineConditional, eventHasAction, not, - field + field, + and } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' -import { getPersonInputFields } from './person' +import { getInformantFields, getPersonInputFields } from './person' import { appendConditionalsToFields, concatFields } from './utils' const informantTypes = { @@ -434,7 +435,7 @@ const BIRTH_FORM = defineForm({ id: 'informant', title: { defaultMessage: "Informant's details", - description: 'Form section title for informants', + description: 'Form section title for informants details', id: 'form.section.informant.title' }, fields: [ @@ -450,7 +451,7 @@ const BIRTH_FORM = defineForm({ options: birthInformantTypeOptions }, ...appendConditionalsToFields({ - inputFields: getPersonInputFields('informant'), + inputFields: getInformantFields('informant'), newConditionals: [ { type: 'HIDE', @@ -484,6 +485,143 @@ const BIRTH_FORM = defineForm({ } } ] + }, + { + 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( + concatFields(['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( + concatFields(['mother', 'detailsNotAvailable']) + ).isUndefinedOrInArray(['false']) + } + ] + }, + ...appendConditionalsToFields({ + inputFields: [ + ...getPersonInputFields('mother'), + { + id: 'mother.previousBirths', + type: 'TEXT', + required: false, + label: { + defaultMessage: 'No. of previous birth', + 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( + concatFields(['mother', 'detailsNotAvailable']) + ).isInArray(['true']), + field( + concatFields(['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( + concatFields(['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( + concatFields(['father', 'detailsNotAvailable']) + ).isUndefinedOrInArray(['false']) + } + ] + }, + ...appendConditionalsToFields({ + inputFields: getPersonInputFields('father'), + newConditionals: [ + { + type: 'HIDE', + conditional: and( + field( + concatFields(['father', 'detailsNotAvailable']) + ).isInArray(['true']), + field( + concatFields(['informant', 'relation']) + ).isUndefinedOrNotInArray(['FATHER']) + ) + } + ] + }) + ] } ] }) diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index 906651fb9..b4f2bc863 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -49,7 +49,7 @@ const idTypeOptions: SelectOption[] = [ } ] -export const getPersonInputFields = (person: string): FieldConfig[] => [ +export const getInformantFields = (person: string): FieldConfig[] => [ { id: `${person}.firstname`, type: 'TEXT', @@ -145,6 +145,45 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ ...getAddressFields(person) ] +export const getPersonInputFields = (person: string): FieldConfig[] => [ + ...getInformantFields(person), + { + id: `${person}.maritalStatus`, + type: 'SELECT', + required: true, + 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`, @@ -215,6 +254,7 @@ const getIdFields = (person: string): FieldConfig[] => [ ] const getAddressFields = (person: string): FieldConfig[] => { + // @Todo: Same as mother or deseased const prefix = `${person}.address` const genericAddressFields: FieldConfig[] = [ @@ -414,3 +454,89 @@ const getAddressFields = (person: string): FieldConfig[] => { }) ] } + +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' + } + } +] From a177f5e179c1ed06137bdee044b8223a4a88bc83 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 14:59:17 +0600 Subject: [PATCH 17/25] feat: implement upload supporting document --- src/form/V2/birth.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index b324e515f..6d23b60db 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -622,6 +622,58 @@ const BIRTH_FORM = defineForm({ ] }) ] + }, + { + id: 'documents', + title: { + defaultMessage: 'Upload supporting documents', + description: 'Form section title for documents', + id: 'form.section.documents.title' + }, + fields: [ + { + id: 'documents.profOfBirth', + 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.profOfBirth.label' + } + }, + { + id: 'documents.profOfMother', + 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.profOfMother.label' + } + }, + + { + id: 'documents.profOfFather', + 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.profOfFather.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' + } + } + ] } ] }) From 9e8e724affa2374ccc7ebba1ef8d91e062ff7cec Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 19:50:12 +0600 Subject: [PATCH 18/25] fix: use simpler concat --- src/form/V2/birth.ts | 37 +++++++++++++------------------------ src/form/V2/person.ts | 40 +++++++++++++++++++--------------------- src/form/V2/utils.ts | 4 ---- 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 6d23b60db..159e6871a 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -23,7 +23,7 @@ import { } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' import { getInformantFields, getPersonInputFields } from './person' -import { appendConditionalsToFields, concatFields } from './utils' +import { appendConditionalsToFields } from './utils' const informantTypes = { SPOUSE: 'SPOUSE', @@ -455,9 +455,10 @@ const BIRTH_FORM = defineForm({ newConditionals: [ { type: 'HIDE', - conditional: field( - concatFields(['informant', 'relation']) - ).isUndefinedOrInArray(['MOTHER', 'FATHER']) + conditional: field('informant.relation').isUndefinedOrInArray([ + 'MOTHER', + 'FATHER' + ]) } ] }), @@ -506,9 +507,7 @@ const BIRTH_FORM = defineForm({ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields(['informant', 'relation']) - ).isInArray(['MOTHER']) + conditional: field('informant.relation').isInArray(['MOTHER']) } ] }, @@ -525,7 +524,7 @@ const BIRTH_FORM = defineForm({ { type: 'HIDE', conditional: field( - concatFields(['mother', 'detailsNotAvailable']) + 'mother.detailsNotAvailable' ).isUndefinedOrInArray(['false']) } ] @@ -549,12 +548,8 @@ const BIRTH_FORM = defineForm({ { type: 'HIDE', conditional: and( - field( - concatFields(['mother', 'detailsNotAvailable']) - ).isInArray(['true']), - field( - concatFields(['informant', 'relation']) - ).isUndefinedOrNotInArray(['MOTHER']) + field('mother.detailsNotAvailable').isInArray(['true']), + field('informant.relation').isUndefinedOrNotInArray(['MOTHER']) ) } ] @@ -581,9 +576,7 @@ const BIRTH_FORM = defineForm({ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields(['informant', 'relation']) - ).isInArray(['FATHER']) + conditional: field('informant.relation').isInArray(['FATHER']) } ] }, @@ -600,7 +593,7 @@ const BIRTH_FORM = defineForm({ { type: 'HIDE', conditional: field( - concatFields(['father', 'detailsNotAvailable']) + 'father.detailsNotAvailable' ).isUndefinedOrInArray(['false']) } ] @@ -611,12 +604,8 @@ const BIRTH_FORM = defineForm({ { type: 'HIDE', conditional: and( - field( - concatFields(['father', 'detailsNotAvailable']) - ).isInArray(['true']), - field( - concatFields(['informant', 'relation']) - ).isUndefinedOrNotInArray(['FATHER']) + field('father.detailsNotAvailable').isInArray(['true']), + field('informant.relation').isUndefinedOrNotInArray(['FATHER']) ) } ] diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index b4f2bc863..f1e477ccc 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -12,7 +12,7 @@ import { FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { field } from '@opencrvs/toolkit/conditionals' import { countries } from './countries' -import { appendConditionalsToFields, concatFields } from './utils' +import { appendConditionalsToFields } from './utils' const idTypeOptions: SelectOption[] = [ { @@ -83,7 +83,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [ description: 'This is the error message for invalid date', id: `event.birth.action.declare.form.section.${person}.field.dob.error` }, - validator: field(concatFields([person, 'dob'])).isBeforeNow() + validator: field(`${person}.dob`).isBeforeNow() } ], label: { @@ -94,9 +94,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field(concatFields([person, 'dobUnknown'])).isEqualTo( - 'true' - ) + conditional: field(`${person}.dobUnknown`).isEqualTo('true') } ] }, @@ -123,9 +121,9 @@ export const getInformantFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields([person, 'dobUnknown']) - ).isUndefinedOrInArray(['false']) + conditional: field(`${person}.dobUnknown`).isUndefinedOrInArray([ + 'false' + ]) } ] }, @@ -209,9 +207,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields([person, 'idType']) - ).isUndefinedOrNotInArray(['NATIONAL_ID']) + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'NATIONAL_ID' + ]) } ] }, @@ -227,9 +225,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields([person, 'idType']) - ).isUndefinedOrNotInArray(['PASSPORT']) + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'PASSPORT' + ]) } ] }, @@ -245,9 +243,9 @@ const getIdFields = (person: string): FieldConfig[] => [ conditionals: [ { type: 'HIDE', - conditional: field( - concatFields([person, 'idType']) - ).isUndefinedOrNotInArray(['BIRTH_REGISTRATION_NUMBER']) + conditional: field(`${person}.idType`).isUndefinedOrNotInArray([ + 'BIRTH_REGISTRATION_NUMBER' + ]) } ] } @@ -435,9 +433,9 @@ const getAddressFields = (person: string): FieldConfig[] => { newConditionals: [ { type: 'HIDE', - conditional: field( - concatFields([person, 'address', 'country']) - ).isUndefinedOrInArray(['FAR']) + conditional: field(`${person}.address.country`).isUndefinedOrInArray([ + 'FAR' + ]) } ] }), @@ -447,7 +445,7 @@ const getAddressFields = (person: string): FieldConfig[] => { { type: 'HIDE', conditional: field( - concatFields([person, 'address', 'country']) + `${person}.address.country` ).isUndefinedOrNotInArray(['FAR']) } ] diff --git a/src/form/V2/utils.ts b/src/form/V2/utils.ts index fb376574c..c9f8d933d 100644 --- a/src/form/V2/utils.ts +++ b/src/form/V2/utils.ts @@ -25,7 +25,3 @@ export const appendConditionalsToFields = ({ conditionals: [...inputField.conditionals, ...newConditionals] } as FieldConfig) ) - -export const concatFields = (fields: string[]) => { - return fields.join('____') -} From e360b7b76af705189523168b65329ab3f51059bd Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 20:09:23 +0600 Subject: [PATCH 19/25] feat: use country field --- src/form/V2/countries.ts | 1513 -------------------------------------- src/form/V2/person.ts | 7 +- 2 files changed, 2 insertions(+), 1518 deletions(-) delete mode 100644 src/form/V2/countries.ts diff --git a/src/form/V2/countries.ts b/src/form/V2/countries.ts deleted file mode 100644 index b1f1a908e..000000000 --- a/src/form/V2/countries.ts +++ /dev/null @@ -1,1513 +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 { SelectOption } from '@opencrvs/toolkit/events' - -const messages = { - AFG: { - id: 'countries.AFG', - defaultMessage: 'Afghanistan', - description: 'ISO Country: AFG' - }, - ALA: { - id: 'countries.ALA', - defaultMessage: 'Åland Islands', - description: 'ISO Country: ALA' - }, - ALB: { - id: 'countries.ALB', - defaultMessage: 'Albania', - description: 'ISO Country: ALB' - }, - DZA: { - id: 'countries.DZA', - defaultMessage: 'Algeria', - description: 'ISO Country: DZA' - }, - ASM: { - id: 'countries.ASM', - defaultMessage: 'American Samoa', - description: 'ISO Country: ASM' - }, - AND: { - id: 'countries.AND', - defaultMessage: 'Andorra', - description: 'ISO Country: AND' - }, - AGO: { - id: 'countries.AGO', - defaultMessage: 'Angola', - description: 'ISO Country: AGO' - }, - AIA: { - id: 'countries.AIA', - defaultMessage: 'Anguilla', - description: 'ISO Country: AIA' - }, - ATA: { - id: 'countries.ATA', - defaultMessage: 'Antarctica', - description: 'ISO Country: ATA' - }, - ATG: { - id: 'countries.ATG', - defaultMessage: 'Antigua and Barbuda', - description: 'ISO Country: ATG' - }, - ARG: { - id: 'countries.ARG', - defaultMessage: 'Argentina', - description: 'ISO Country: ARG' - }, - ARM: { - id: 'countries.ARM', - defaultMessage: 'Armenia', - description: 'ISO Country: ARM' - }, - ABW: { - id: 'countries.ABW', - defaultMessage: 'Aruba', - description: 'ISO Country: ABW' - }, - AUS: { - id: 'countries.AUS', - defaultMessage: 'Australia', - description: 'ISO Country: AUS' - }, - AUT: { - id: 'countries.AUT', - defaultMessage: 'Austria', - description: 'ISO Country: AUT' - }, - AZE: { - id: 'countries.AZE', - defaultMessage: 'Azerbaijan', - description: 'ISO Country: AZE' - }, - BHS: { - id: 'countries.BHS', - defaultMessage: 'Bahamas', - description: 'ISO Country: BHS' - }, - BHR: { - id: 'countries.BHR', - defaultMessage: 'Bahrain', - description: 'ISO Country: BHR' - }, - BGD: { - id: 'countries.BGD', - defaultMessage: 'Bangladesh', - description: 'ISO Country: BGD' - }, - BRB: { - id: 'countries.BRB', - defaultMessage: 'Barbados', - description: 'ISO Country: BRB' - }, - BLR: { - id: 'countries.BLR', - defaultMessage: 'Belarus', - description: 'ISO Country: BLR' - }, - BEL: { - id: 'countries.BEL', - defaultMessage: 'Belgium', - description: 'ISO Country: BEL' - }, - BLZ: { - id: 'countries.BLZ', - defaultMessage: 'Belize', - description: 'ISO Country: BLZ' - }, - BEN: { - id: 'countries.BEN', - defaultMessage: 'Benin', - description: 'ISO Country: BEN' - }, - BMU: { - id: 'countries.BMU', - defaultMessage: 'Bermuda', - description: 'ISO Country: BMU' - }, - BTN: { - id: 'countries.BTN', - defaultMessage: 'Bhutan', - description: 'ISO Country: BTN' - }, - BOL: { - id: 'countries.BOL', - defaultMessage: 'Bolivia (Plurinational State of)', - description: 'ISO Country: BOL' - }, - BES: { - id: 'countries.BES', - defaultMessage: 'Bonaire, Sint Eustatius and Saba', - description: 'ISO Country: BES' - }, - BIH: { - id: 'countries.BIH', - defaultMessage: 'Bosnia and Herzegovina', - description: 'ISO Country: BIH' - }, - BWA: { - id: 'countries.BWA', - defaultMessage: 'Botswana', - description: 'ISO Country: BWA' - }, - BVT: { - id: 'countries.BVT', - defaultMessage: 'Bouvet Island', - description: 'ISO Country: BVT' - }, - BRA: { - id: 'countries.BRA', - defaultMessage: 'Brazil', - description: 'ISO Country: BRA' - }, - IOT: { - id: 'countries.IOT', - defaultMessage: 'British Indian Ocean Territory', - description: 'ISO Country: IOT' - }, - VGB: { - id: 'countries.VGB', - defaultMessage: 'British Virgin Islands', - description: 'ISO Country: VGB' - }, - BRN: { - id: 'countries.BRN', - defaultMessage: 'Brunei Darussalam', - description: 'ISO Country: BRN' - }, - BGR: { - id: 'countries.BGR', - defaultMessage: 'Bulgaria', - description: 'ISO Country: BGR' - }, - BFA: { - id: 'countries.BFA', - defaultMessage: 'Burkina Faso', - description: 'ISO Country: BFA' - }, - BDI: { - id: 'countries.BDI', - defaultMessage: 'Burundi', - description: 'ISO Country: BDI' - }, - CPV: { - id: 'countries.CPV', - defaultMessage: 'Cabo Verde', - description: 'ISO Country: CPV' - }, - KHM: { - id: 'countries.KHM', - defaultMessage: 'Cambodia', - description: 'ISO Country: KHM' - }, - CMR: { - id: 'countries.CMR', - defaultMessage: 'Cameroon', - description: 'ISO Country: CMR' - }, - CAN: { - id: 'countries.CAN', - defaultMessage: 'Canada', - description: 'ISO Country: CAN' - }, - CYM: { - id: 'countries.CYM', - defaultMessage: 'Cayman Islands', - description: 'ISO Country: CYM' - }, - CAF: { - id: 'countries.CAF', - defaultMessage: 'Central African Republic', - description: 'ISO Country: CAF' - }, - TCD: { - id: 'countries.TCD', - defaultMessage: 'Chad', - description: 'ISO Country: TCD' - }, - CHL: { - id: 'countries.CHL', - defaultMessage: 'Chile', - description: 'ISO Country: CHL' - }, - CHN: { - id: 'countries.CHN', - defaultMessage: 'China', - description: 'ISO Country: CHN' - }, - HKG: { - id: 'countries.HKG', - defaultMessage: '"China, Hong Kong Special Administrative Region"', - description: 'ISO Country: HKG' - }, - MAC: { - id: 'countries.MAC', - defaultMessage: '"China, Macao Special Administrative Region"', - description: 'ISO Country: MAC' - }, - CXR: { - id: 'countries.CXR', - defaultMessage: 'Christmas Island', - description: 'ISO Country: CXR' - }, - CCK: { - id: 'countries.CCK', - defaultMessage: 'Cocos (Keeling) Islands', - description: 'ISO Country: CCK' - }, - COL: { - id: 'countries.COL', - defaultMessage: 'Colombia', - description: 'ISO Country: COL' - }, - COM: { - id: 'countries.COM', - defaultMessage: 'Comoros', - description: 'ISO Country: COM' - }, - COG: { - id: 'countries.COG', - defaultMessage: 'Congo', - description: 'ISO Country: COG' - }, - COK: { - id: 'countries.COK', - defaultMessage: 'Cook Islands', - description: 'ISO Country: COK' - }, - CRI: { - id: 'countries.CRI', - defaultMessage: 'Costa Rica', - description: 'ISO Country: CRI' - }, - CIV: { - id: 'countries.CIV', - defaultMessage: "Côte d'Ivoire", - description: 'ISO Country: CIV' - }, - HRV: { - id: 'countries.HRV', - defaultMessage: 'Croatia', - description: 'ISO Country: HRV' - }, - CUB: { - id: 'countries.CUB', - defaultMessage: 'Cuba', - description: 'ISO Country: CUB' - }, - CUW: { - id: 'countries.CUW', - defaultMessage: 'Curaçao', - description: 'ISO Country: CUW' - }, - CYP: { - id: 'countries.CYP', - defaultMessage: 'Cyprus', - description: 'ISO Country: CYP' - }, - CZE: { - id: 'countries.CZE', - defaultMessage: 'Czechia', - description: 'ISO Country: CZE' - }, - PRK: { - id: 'countries.PRK', - defaultMessage: "Democratic People's Republic of Korea", - description: 'PRK' - }, - COD: { - id: 'countries.COD', - defaultMessage: 'Democratic Republic of the Congo', - description: 'ISO Country: COD' - }, - DNK: { - id: 'countries.DNK', - defaultMessage: 'Denmark', - description: 'ISO Country: DNK' - }, - DJI: { - id: 'countries.DJI', - defaultMessage: 'Djibouti', - description: 'ISO Country: DJI' - }, - DMA: { - id: 'countries.DMA', - defaultMessage: 'Dominica', - description: 'ISO Country: DMA' - }, - DOM: { - id: 'countries.DOM', - defaultMessage: 'Dominican Republic', - description: 'ISO Country: DOM' - }, - ECU: { - id: 'countries.ECU', - defaultMessage: 'Ecuador', - description: 'ISO Country: ECU' - }, - EGY: { - id: 'countries.EGY', - defaultMessage: 'Egypt', - description: 'ISO Country: EGY' - }, - SLV: { - id: 'countries.SLV', - defaultMessage: 'El Salvador', - description: 'ISO Country: SLV' - }, - GNQ: { - id: 'countries.GNQ', - defaultMessage: 'Equatorial Guinea', - description: 'ISO Country: GNQ' - }, - ERI: { - id: 'countries.ERI', - defaultMessage: 'Eritrea', - description: 'ISO Country: ERI' - }, - EST: { - id: 'countries.EST', - defaultMessage: 'Estonia', - description: 'ISO Country: EST' - }, - SWZ: { - id: 'countries.SWZ', - defaultMessage: 'Eswatini', - description: 'ISO Country: SWZ' - }, - ETH: { - id: 'countries.ETH', - defaultMessage: 'Ethiopia', - description: 'ISO Country: ETH' - }, - FLK: { - id: 'countries.FLK', - defaultMessage: 'Falkland Islands (Malvinas)', - description: 'ISO Country: FLK' - }, - FAR: { - id: 'countries.FAR', - defaultMessage: 'Farajaland', - description: 'Fictional country for OpenCRSV demo' - }, - FRO: { - id: 'countries.FRO', - defaultMessage: 'Faroe Islands', - description: 'ISO Country: FRO' - }, - FJI: { - id: 'countries.FJI', - defaultMessage: 'Fiji', - description: 'ISO Country: FJI' - }, - FIN: { - id: 'countries.FIN', - defaultMessage: 'Finland', - description: 'ISO Country: FIN' - }, - FRA: { - id: 'countries.FRA', - defaultMessage: 'France', - description: 'ISO Country: FRA' - }, - GUF: { - id: 'countries.GUF', - defaultMessage: 'French Guiana', - description: 'ISO Country: GUF' - }, - PYF: { - id: 'countries.PYF', - defaultMessage: 'French Polynesia', - description: 'ISO Country: PYF' - }, - ATF: { - id: 'countries.ATF', - defaultMessage: 'French Southern Territories', - description: 'ISO Country: ATF' - }, - GAB: { - id: 'countries.GAB', - defaultMessage: 'Gabon', - description: 'ISO Country: GAB' - }, - GMB: { - id: 'countries.GMB', - defaultMessage: 'Gambia', - description: 'ISO Country: GMB' - }, - GEO: { - id: 'countries.GEO', - defaultMessage: 'Georgia', - description: 'ISO Country: GEO' - }, - DEU: { - id: 'countries.DEU', - defaultMessage: 'Germany', - description: 'ISO Country: DEU' - }, - GHA: { - id: 'countries.GHA', - defaultMessage: 'Ghana', - description: 'ISO Country: GHA' - }, - GIB: { - id: 'countries.GIB', - defaultMessage: 'Gibraltar', - description: 'ISO Country: GIB' - }, - GRC: { - id: 'countries.GRC', - defaultMessage: 'Greece', - description: 'ISO Country: GRC' - }, - GRL: { - id: 'countries.GRL', - defaultMessage: 'Greenland', - description: 'ISO Country: GRL' - }, - GRD: { - id: 'countries.GRD', - defaultMessage: 'Grenada', - description: 'ISO Country: GRD' - }, - GLP: { - id: 'countries.GLP', - defaultMessage: 'Guadeloupe', - description: 'ISO Country: GLP' - }, - GUM: { - id: 'countries.GUM', - defaultMessage: 'Guam', - description: 'ISO Country: GUM' - }, - GTM: { - id: 'countries.GTM', - defaultMessage: 'Guatemala', - description: 'ISO Country: GTM' - }, - GGY: { - id: 'countries.GGY', - defaultMessage: 'Guernsey', - description: 'ISO Country: GGY' - }, - GIN: { - id: 'countries.GIN', - defaultMessage: 'Guinea', - description: 'ISO Country: GIN' - }, - GNB: { - id: 'countries.GNB', - defaultMessage: 'Guinea-Bissau', - description: 'ISO Country: GNB' - }, - GUY: { - id: 'countries.GUY', - defaultMessage: 'Guyana', - description: 'ISO Country: GUY' - }, - HTI: { - id: 'countries.HTI', - defaultMessage: 'Haiti', - description: 'ISO Country: HTI' - }, - HMD: { - id: 'countries.HMD', - defaultMessage: 'Heard Island and McDonald Islands', - description: 'ISO Country: HMD' - }, - VAT: { - id: 'countries.VAT', - defaultMessage: 'Holy See', - description: 'ISO Country: VAT' - }, - HND: { - id: 'countries.HND', - defaultMessage: 'Honduras', - description: 'ISO Country: HND' - }, - HUN: { - id: 'countries.HUN', - defaultMessage: 'Hungary', - description: 'ISO Country: HUN' - }, - ISL: { - id: 'countries.ISL', - defaultMessage: 'Iceland', - description: 'ISO Country: ISL' - }, - IND: { - id: 'countries.IND', - defaultMessage: 'India', - description: 'ISO Country: IND' - }, - IDN: { - id: 'countries.IDN', - defaultMessage: 'Indonesia', - description: 'ISO Country: IDN' - }, - IRN: { - id: 'countries.IRN', - defaultMessage: 'Iran (Islamic Republic of)', - description: 'ISO Country: IRN' - }, - IRQ: { - id: 'countries.IRQ', - defaultMessage: 'Iraq', - description: 'ISO Country: IRQ' - }, - IRL: { - id: 'countries.IRL', - defaultMessage: 'Ireland', - description: 'ISO Country: IRL' - }, - IMN: { - id: 'countries.IMN', - defaultMessage: 'Isle of Man', - description: 'ISO Country: IMN' - }, - ISR: { - id: 'countries.ISR', - defaultMessage: 'Israel', - description: 'ISO Country: ISR' - }, - ITA: { - id: 'countries.ITA', - defaultMessage: 'Italy', - description: 'ISO Country: ITA' - }, - JAM: { - id: 'countries.JAM', - defaultMessage: 'Jamaica', - description: 'ISO Country: JAM' - }, - JPN: { - id: 'countries.JPN', - defaultMessage: 'Japan', - description: 'ISO Country: JPN' - }, - JEY: { - id: 'countries.JEY', - defaultMessage: 'Jersey', - description: 'ISO Country: JEY' - }, - JOR: { - id: 'countries.JOR', - defaultMessage: 'Jordan', - description: 'ISO Country: JOR' - }, - KAZ: { - id: 'countries.KAZ', - defaultMessage: 'Kazakhstan', - description: 'ISO Country: KAZ' - }, - KEN: { - id: 'countries.KEN', - defaultMessage: 'Kenya', - description: 'ISO Country: KEN' - }, - KIR: { - id: 'countries.KIR', - defaultMessage: 'Kiribati', - description: 'ISO Country: KIR' - }, - KWT: { - id: 'countries.KWT', - defaultMessage: 'Kuwait', - description: 'ISO Country: KWT' - }, - KGZ: { - id: 'countries.KGZ', - defaultMessage: 'Kyrgyzstan', - description: 'ISO Country: KGZ' - }, - LAO: { - id: 'countries.KGZ', - defaultMessage: "Lao People's Democratic Republic Republic", - description: 'ISO Country: LAO' - }, - LVA: { - id: 'countries.LVA', - defaultMessage: 'Latvia', - description: 'ISO Country: LVA' - }, - LBN: { - id: 'countries.LBN', - defaultMessage: 'Lebanon', - description: 'ISO Country: LBN' - }, - LSO: { - id: 'countries.LSO', - defaultMessage: 'Lesotho', - description: 'ISO Country: LSO' - }, - LBR: { - id: 'countries.LBR', - defaultMessage: 'Liberia', - description: 'ISO Country: LBR' - }, - LBY: { - id: 'countries.LBY', - defaultMessage: 'Libya', - description: 'ISO Country: LBY' - }, - LIE: { - id: 'countries.LIE', - defaultMessage: 'Liechtenstein', - description: 'ISO Country: LIE' - }, - LTU: { - id: 'countries.LTU', - defaultMessage: 'Lithuania', - description: 'ISO Country: LTU' - }, - LUX: { - id: 'countries.LUX', - defaultMessage: 'Luxembourg', - description: 'ISO Country: LUX' - }, - MDG: { - id: 'countries.MDG', - defaultMessage: 'Madagascar', - description: 'ISO Country: MDG' - }, - MWI: { - id: 'countries.MWI', - defaultMessage: 'Malawi', - description: 'ISO Country: MWI' - }, - MYS: { - id: 'countries.MYS', - defaultMessage: 'Malaysia', - description: 'ISO Country: MYS' - }, - MDV: { - id: 'countries.MDV', - defaultMessage: 'Maldives', - description: 'ISO Country: MDV' - }, - MLI: { - id: 'countries.MLI', - defaultMessage: 'Mali', - description: 'ISO Country: MLI' - }, - MLT: { - id: 'countries.MLT', - defaultMessage: 'Malta', - description: 'ISO Country: MLT' - }, - MHL: { - id: 'countries.MHL', - defaultMessage: 'Marshall Islands', - description: 'ISO Country: MHL' - }, - MTQ: { - id: 'countries.MTQ', - defaultMessage: 'Martinique', - description: 'ISO Country: MTQ' - }, - MRT: { - id: 'countries.MRT', - defaultMessage: 'Mauritania', - description: 'ISO Country: MRT' - }, - MUS: { - id: 'countries.MUS', - defaultMessage: 'Mauritius', - description: 'ISO Country: MUS' - }, - MYT: { - id: 'countries.MYT', - defaultMessage: 'Mayotte', - description: 'ISO Country: MYT' - }, - MEX: { - id: 'countries.MEX', - defaultMessage: 'Mexico', - description: 'ISO Country: MEX' - }, - FSM: { - id: 'countries.FSM', - defaultMessage: 'Micronesia (Federated States of)', - description: 'ISO Country: FSM' - }, - - MCO: { - id: 'countries.MCO', - defaultMessage: 'Monaco', - description: 'ISO Country: MCO' - }, - MNG: { - id: 'countries.MNG', - defaultMessage: 'Mongolia', - description: 'ISO Country: MNG' - }, - MNE: { - id: 'countries.MNE', - defaultMessage: 'Montenegro', - description: 'ISO Country: MNE' - }, - MSR: { - id: 'countries.MSR', - defaultMessage: 'Montserrat', - description: 'ISO Country: MSR' - }, - MAR: { - id: 'countries.MAR', - defaultMessage: 'Morocco', - description: 'ISO Country: MAR' - }, - MOZ: { - id: 'countries.MOZ', - defaultMessage: 'Mozambique', - description: 'ISO Country: MOZ' - }, - MMR: { - id: 'countries.MMR', - defaultMessage: 'Myanmar', - description: 'ISO Country: MMR' - }, - NAM: { - id: 'countries.NAM', - defaultMessage: 'Namibia', - description: 'ISO Country: NAM' - }, - NRU: { - id: 'countries.NRU', - defaultMessage: 'Nauru', - description: 'ISO Country: NRU' - }, - NPL: { - id: 'countries.NPL', - defaultMessage: 'Nepal', - description: 'ISO Country: NPL' - }, - NLD: { - id: 'countries.NLD', - defaultMessage: 'Netherlands', - description: 'ISO Country: NLD' - }, - NCL: { - id: 'countries.NCL', - defaultMessage: 'New Caledonia', - description: 'ISO Country: NCL' - }, - NZL: { - id: 'countries.NZL', - defaultMessage: 'New Zealand', - description: 'ISO Country: NZL' - }, - NIC: { - id: 'countries.NIC', - defaultMessage: 'Nicaragua', - description: 'ISO Country: NIC' - }, - NER: { - id: 'countries.NER', - defaultMessage: 'Niger', - description: 'ISO Country: NER' - }, - NGA: { - id: 'countries.NGA', - defaultMessage: 'Nigeria', - description: 'ISO Country: NGA' - }, - NIU: { - id: 'countries.NIU', - defaultMessage: 'Niue', - description: 'ISO Country: NIU' - }, - NFK: { - id: 'countries.NFK', - defaultMessage: 'Norfolk Island', - description: 'ISO Country: NFK' - }, - MNP: { - id: 'countries.MNP', - defaultMessage: 'Northern Mariana Islands', - description: 'ISO Country: MNP' - }, - NOR: { - id: 'countries.NOR', - defaultMessage: 'Norway', - description: 'ISO Country: NOR' - }, - OMN: { - id: 'countries.OMN', - defaultMessage: 'Oman', - description: 'ISO Country: OMN' - }, - PAK: { - id: 'countries.PAK', - defaultMessage: 'Pakistan', - description: 'ISO Country: PAK' - }, - PLW: { - id: 'countries.PLW', - defaultMessage: 'Palau', - description: 'ISO Country: PLW' - }, - PAN: { - id: 'countries.PAN', - defaultMessage: 'Panama', - description: 'ISO Country: PAN' - }, - PNG: { - id: 'countries.PNG', - defaultMessage: 'Papua New Guinea', - description: 'ISO Country: PNG' - }, - PRY: { - id: 'countries.PRY', - defaultMessage: 'Paraguay', - description: 'ISO Country: PRY' - }, - PER: { - id: 'countries.PER', - defaultMessage: 'Peru', - description: 'ISO Country: PER' - }, - PHL: { - id: 'countries.PHL', - defaultMessage: 'Philippines', - description: 'ISO Country: PHL' - }, - PCN: { - id: 'countries.PCN', - defaultMessage: 'Pitcairn', - description: 'ISO Country: PCN' - }, - POL: { - id: 'countries.POL', - defaultMessage: 'Poland', - description: 'ISO Country: POL' - }, - PRT: { - id: 'countries.PRT', - defaultMessage: 'Portugal', - description: 'ISO Country: PRT' - }, - PRI: { - id: 'countries.PRI', - defaultMessage: 'Puerto Rico', - description: 'ISO Country: PRI' - }, - QAT: { - id: 'countries.QAT', - defaultMessage: 'Qatar', - description: 'ISO Country: QAT' - }, - KOR: { - id: 'countries.KOR', - defaultMessage: 'Republic of Korea', - description: 'ISO Country: KOR' - }, - MDA: { - id: 'countries.MDA', - defaultMessage: 'Republic of Moldova', - description: 'ISO Country: MDA' - }, - REU: { - id: 'countries.REU', - defaultMessage: 'Réunion', - description: 'ISO Country: REU' - }, - ROU: { - id: 'countries.ROU', - defaultMessage: 'Romania', - description: 'ISO Country: ROU' - }, - RUS: { - id: 'countries.RUS', - defaultMessage: 'Russian Federation', - description: 'ISO Country: RUS' - }, - RWA: { - id: 'countries.RWA', - defaultMessage: 'Rwanda', - description: 'ISO Country: RWA' - }, - BLM: { - id: 'countries.BLM', - defaultMessage: 'Saint Barthélemy', - description: 'ISO Country: BLM' - }, - SHN: { - id: 'countries.SHN', - defaultMessage: 'Saint Helena', - description: 'ISO Country: SHN' - }, - KNA: { - id: 'countries.KNA', - defaultMessage: 'Saint Kitts and Nevis', - description: 'ISO Country: KNA' - }, - LCA: { - id: 'countries.LCA', - defaultMessage: 'Saint Lucia', - description: 'ISO Country: LCA' - }, - MAF: { - id: 'countries.MAF', - defaultMessage: 'Saint Martin (French Part)', - description: 'ISO Country: MAF' - }, - SPM: { - id: 'countries.SPM', - defaultMessage: 'Saint Pierre and Miquelon', - description: 'ISO Country: SPM' - }, - VCT: { - id: 'countries.VCT', - defaultMessage: 'Saint Vincent and the Grenadines', - description: 'ISO Country: VCT' - }, - WSM: { - id: 'countries.WSM', - defaultMessage: 'Samoa', - description: 'ISO Country: WSM' - }, - SMR: { - id: 'countries.SMR', - defaultMessage: 'San Marino', - description: 'ISO Country: SMR' - }, - STP: { - id: 'countries.STP', - defaultMessage: 'Sao Tome and Principe', - description: 'ISO Country: STP' - }, - SAU: { - id: 'countries.SAU', - defaultMessage: 'Saudi Arabia', - description: 'ISO Country: SAU' - }, - SEN: { - id: 'countries.SEN', - defaultMessage: 'Senegal', - description: 'ISO Country: SEN' - }, - SRB: { - id: 'countries.SRB', - defaultMessage: 'Serbia', - description: 'ISO Country: SRB' - }, - SYC: { - id: 'countries.SYC', - defaultMessage: 'Seychelles', - description: 'ISO Country: SYC' - }, - SLE: { - id: 'countries.SLE', - defaultMessage: 'Sierra Leone', - description: 'ISO Country: SLE' - }, - SGP: { - id: 'countries.SGP', - defaultMessage: 'Singapore', - description: 'ISO Country: SGP' - }, - SXM: { - id: 'countries.SXM', - defaultMessage: 'Sint Maarten (Dutch part)', - description: 'ISO Country: SXM' - }, - SVK: { - id: 'countries.SVK', - defaultMessage: 'Slovakia', - description: 'ISO Country: SVK' - }, - SVN: { - id: 'countries.SVN', - defaultMessage: 'Slovenia', - description: 'ISO Country: SVN' - }, - SLB: { - id: 'countries.SLB', - defaultMessage: 'Solomon Islands', - description: 'ISO Country: SLB' - }, - SOM: { - id: 'countries.SOM', - defaultMessage: 'Somalia', - description: 'ISO Country: SOM' - }, - ZAF: { - id: 'countries.ZAF', - defaultMessage: 'South Africa', - description: 'ISO Country: ZAF' - }, - SGS: { - id: 'countries.SGS', - defaultMessage: 'South Georgia and the South Sandwich Islands', - description: 'ISO Country: SGS' - }, - SSD: { - id: 'countries.SSD', - defaultMessage: 'South Sudan', - description: 'ISO Country: SSD' - }, - ESP: { - id: 'countries.ESP', - defaultMessage: 'Spain', - description: 'ISO Country: ESP' - }, - LKA: { - id: 'countries.LKA', - defaultMessage: 'Sri Lanka', - description: 'ISO Country: LKA' - }, - PSE: { - id: 'countries.PSE', - defaultMessage: 'State of Palestine', - description: 'ISO Country: PSE' - }, - SDN: { - id: 'countries.SDN', - defaultMessage: 'Sudan', - description: 'ISO Country: SDN' - }, - SUR: { - id: 'countries.SUR', - defaultMessage: 'Suriname', - description: 'ISO Country: SUR' - }, - SJM: { - id: 'countries.SJM', - defaultMessage: 'Svalbard and Jan Mayen Islands', - description: 'ISO Country: SJM' - }, - SWE: { - id: 'countries.SWE', - defaultMessage: 'Sweden', - description: 'ISO Country: SWE' - }, - CHE: { - id: 'countries.CHE', - defaultMessage: 'Switzerland', - description: 'ISO Country: CHE' - }, - SYR: { - id: 'countries.SYR', - defaultMessage: 'Syrian Arab Republic', - description: 'ISO Country: SYR' - }, - TJK: { - id: 'countries.TJK', - defaultMessage: 'Tajikistan', - description: 'ISO Country: TJK' - }, - THA: { - id: 'countries.THA', - defaultMessage: 'Thailand', - description: 'ISO Country: THA' - }, - MKD: { - id: 'countries.MKD', - defaultMessage: 'The former Yugoslav Republic of Macedonia', - description: 'ISO Country: MKD' - }, - TLS: { - id: 'countries.TLS', - defaultMessage: 'Timor-Leste', - description: 'ISO Country: TLS' - }, - TGO: { - id: 'countries.TGO', - defaultMessage: 'Togo', - description: 'ISO Country: TGO' - }, - TKL: { - id: 'countries.TKL', - defaultMessage: 'Tokelau', - description: 'ISO Country: TKL' - }, - TON: { - id: 'countries.TON', - defaultMessage: 'Tonga', - description: 'ISO Country: TON' - }, - TTO: { - id: 'countries.TTO', - defaultMessage: 'Trinidad and Tobago', - description: 'ISO Country: TTO' - }, - TUN: { - id: 'countries.TUN', - defaultMessage: 'Tunisia', - description: 'ISO Country: TUN' - }, - TUR: { - id: 'countries.TUR', - defaultMessage: 'Turkey', - description: 'ISO Country: TUR' - }, - TKM: { - id: 'countries.TKM', - defaultMessage: 'Turkmenistan', - description: 'ISO Country: TKM' - }, - TCA: { - id: 'countries.TCA', - defaultMessage: 'Turks and Caicos Islands', - description: 'ISO Country: TCA' - }, - TUV: { - id: 'countries.TUV', - defaultMessage: 'Tuvalu', - description: 'ISO Country: TUV' - }, - UGA: { - id: 'countries.UGA', - defaultMessage: 'Uganda', - description: 'ISO Country: UGA' - }, - UKR: { - id: 'countries.UKR', - defaultMessage: 'Ukraine', - description: 'ISO Country: UKR' - }, - ARE: { - id: 'countries.ARE', - defaultMessage: 'United Arab Emirates', - description: 'ISO Country: ARE' - }, - GBR: { - id: 'countries.GBR', - defaultMessage: 'United Kingdom of Great Britain and Northern Ireland', - description: 'ISO Country: GBR' - }, - TZA: { - id: 'countries.TZA', - defaultMessage: 'United Republic of Tanzania', - description: 'ISO Country: TZA' - }, - UMI: { - id: 'countries.UMI', - defaultMessage: 'United States Minor Outlying Islands', - description: 'ISO Country: UMI' - }, - USA: { - id: 'countries.USA', - defaultMessage: 'United States of America', - description: 'ISO Country: USA' - }, - VIR: { - id: 'countries.VIR', - defaultMessage: 'United States Virgin Islands', - description: 'ISO Country: VIR' - }, - URY: { - id: 'countries.URY', - defaultMessage: 'Uruguay', - description: 'ISO Country: URY' - }, - UZB: { - id: 'countries.UZB', - defaultMessage: 'Uzbekistan', - description: 'ISO Country: UZB' - }, - VUT: { - id: 'countries.VUT', - defaultMessage: 'Vanuatu', - description: 'ISO Country: VUT' - }, - VEN: { - id: 'countries.VEN', - defaultMessage: 'Venezuela (Bolivarian Republic of)', - description: 'ISO Country: VEN' - }, - VNM: { - id: 'countries.VNM', - defaultMessage: 'Viet Nam', - description: 'ISO Country: VNM' - }, - WLF: { - id: 'countries.WLF', - defaultMessage: 'Wallis and Futuna Islands', - description: 'ISO Country: WLF' - }, - ESH: { - id: 'countries.ESH', - defaultMessage: 'Western Sahara', - description: 'ISO Country: ESH' - }, - YEM: { - id: 'countries.YEM', - defaultMessage: 'Yemen', - description: 'ISO Country: YEM' - }, - ZMB: { - id: 'countries.ZMB', - defaultMessage: 'Zambia', - description: 'ISO Country: ZMB' - }, - ZWE: { - id: 'countries.ZWE', - defaultMessage: 'Zimbabwe', - description: 'ISO Country ZWE' - } -} - -export const countries = [ - { value: 'AFG', label: messages.AFG }, - { value: 'ALA', label: messages.ALA }, - { value: 'ALB', label: messages.ALB }, - { value: 'DZA', label: messages.DZA }, - { value: 'ASM', label: messages.ASM }, - { value: 'AND', label: messages.AND }, - { value: 'AGO', label: messages.AGO }, - { value: 'AIA', label: messages.AIA }, - { value: 'ATA', label: messages.ATA }, - { value: 'ATG', label: messages.ATG }, - { value: 'ARG', label: messages.ARG }, - { value: 'ARM', label: messages.ARM }, - { value: 'ABW', label: messages.ABW }, - { value: 'AUS', label: messages.AUS }, - { value: 'AUT', label: messages.AUT }, - { value: 'AZE', label: messages.AZE }, - { value: 'BHS', label: messages.BHS }, - { value: 'BHR', label: messages.BHR }, - { value: 'BGD', label: messages.BGD }, - { value: 'BRB', label: messages.BRB }, - { value: 'BLR', label: messages.BLR }, - { value: 'BEL', label: messages.BEL }, - { value: 'BLZ', label: messages.BLZ }, - { value: 'BEN', label: messages.BEN }, - { value: 'BMU', label: messages.BMU }, - { value: 'BTN', label: messages.BTN }, - { value: 'BOL', label: messages.BOL }, - { value: 'BES', label: messages.BES }, - { value: 'BIH', label: messages.BIH }, - { value: 'BWA', label: messages.BWA }, - { value: 'BVT', label: messages.BVT }, - { value: 'BRA', label: messages.BRA }, - { value: 'IOT', label: messages.IOT }, - { value: 'VGB', label: messages.VGB }, - { value: 'BRN', label: messages.BRN }, - { value: 'BGR', label: messages.BGR }, - { value: 'BFA', label: messages.BFA }, - { value: 'BDI', label: messages.BDI }, - { value: 'CPV', label: messages.CPV }, - { value: 'KHM', label: messages.KHM }, - { value: 'CMR', label: messages.CMR }, - { value: 'CAN', label: messages.CAN }, - { value: 'CYM', label: messages.CYM }, - { value: 'CAF', label: messages.CAF }, - { value: 'TCD', label: messages.TCD }, - { value: 'CHL', label: messages.CHL }, - { value: 'CHN', label: messages.CHN }, - { value: 'HKG', label: messages.HKG }, - { value: 'MAC', label: messages.MAC }, - { value: 'CXR', label: messages.CXR }, - { value: 'CCK', label: messages.CCK }, - { value: 'COL', label: messages.COL }, - { value: 'COM', label: messages.COM }, - { value: 'COG', label: messages.COG }, - { value: 'COK', label: messages.COK }, - { value: 'CRI', label: messages.CRI }, - { value: 'CIV', label: messages.CIV }, - { value: 'HRV', label: messages.HRV }, - { value: 'CUB', label: messages.CUB }, - { value: 'CUW', label: messages.CUW }, - { value: 'CYP', label: messages.CYP }, - { value: 'CZE', label: messages.CZE }, - { value: 'PRK', label: messages.PRK }, - { value: 'COD', label: messages.COD }, - { value: 'DNK', label: messages.DNK }, - { value: 'DJI', label: messages.DJI }, - { value: 'DMA', label: messages.DMA }, - { value: 'DOM', label: messages.DOM }, - { value: 'ECU', label: messages.ECU }, - { value: 'EGY', label: messages.EGY }, - { value: 'SLV', label: messages.SLV }, - { value: 'GNQ', label: messages.GNQ }, - { value: 'ERI', label: messages.ERI }, - { value: 'EST', label: messages.EST }, - { value: 'SWZ', label: messages.SWZ }, - { value: 'ETH', label: messages.ETH }, - { value: 'FAR', label: messages.FAR }, - { value: 'FLK', label: messages.FLK }, - { value: 'FRO', label: messages.FRO }, - { value: 'FJI', label: messages.FJI }, - { value: 'FIN', label: messages.FIN }, - { value: 'FRA', label: messages.FRA }, - { value: 'GUF', label: messages.GUF }, - { value: 'PYF', label: messages.PYF }, - { value: 'ATF', label: messages.ATF }, - { value: 'GAB', label: messages.GAB }, - { value: 'GMB', label: messages.GMB }, - { value: 'GEO', label: messages.GEO }, - { value: 'DEU', label: messages.DEU }, - { value: 'GHA', label: messages.GHA }, - { value: 'GIB', label: messages.GIB }, - { value: 'GRC', label: messages.GRC }, - { value: 'GRL', label: messages.GRL }, - { value: 'GRD', label: messages.GRD }, - { value: 'GLP', label: messages.GLP }, - { value: 'GUM', label: messages.GUM }, - { value: 'GTM', label: messages.GTM }, - { value: 'GGY', label: messages.GGY }, - { value: 'GIN', label: messages.GIN }, - { value: 'GNB', label: messages.GNB }, - { value: 'GUY', label: messages.GUY }, - { value: 'HTI', label: messages.HTI }, - { value: 'HMD', label: messages.HMD }, - { value: 'VAT', label: messages.VAT }, - { value: 'HND', label: messages.HND }, - { value: 'HUN', label: messages.HUN }, - { value: 'ISL', label: messages.ISL }, - { value: 'IND', label: messages.IND }, - { value: 'IDN', label: messages.IDN }, - { value: 'IRN', label: messages.IRN }, - { value: 'IRQ', label: messages.IRQ }, - { value: 'IRL', label: messages.IRL }, - { value: 'IMN', label: messages.IMN }, - { value: 'ISR', label: messages.ISR }, - { value: 'ITA', label: messages.ITA }, - { value: 'JAM', label: messages.JAM }, - { value: 'JPN', label: messages.JPN }, - { value: 'JEY', label: messages.JEY }, - { value: 'JOR', label: messages.JOR }, - { value: 'KAZ', label: messages.KAZ }, - { value: 'KEN', label: messages.KEN }, - { value: 'KIR', label: messages.KIR }, - { value: 'KWT', label: messages.KWT }, - { value: 'KGZ', label: messages.KGZ }, - { value: 'LAO', label: messages.LAO }, - { value: 'LVA', label: messages.LVA }, - { value: 'LBN', label: messages.LBN }, - { value: 'LSO', label: messages.LSO }, - { value: 'LBR', label: messages.LBR }, - { value: 'LBY', label: messages.LBY }, - { value: 'LIE', label: messages.LIE }, - { value: 'LTU', label: messages.LTU }, - { value: 'LUX', label: messages.LUX }, - { value: 'MDG', label: messages.MDG }, - { value: 'MWI', label: messages.MWI }, - { value: 'MYS', label: messages.MYS }, - { value: 'MDV', label: messages.MDV }, - { value: 'MLI', label: messages.MLI }, - { value: 'MLT', label: messages.MLT }, - { value: 'MHL', label: messages.MHL }, - { value: 'MTQ', label: messages.MTQ }, - { value: 'MRT', label: messages.MRT }, - { value: 'MUS', label: messages.MUS }, - { value: 'MYT', label: messages.MYT }, - { value: 'MEX', label: messages.MEX }, - { value: 'FSM', label: messages.FSM }, - { value: 'MCO', label: messages.MCO }, - { value: 'MNG', label: messages.MNG }, - { value: 'MNE', label: messages.MNE }, - { value: 'MSR', label: messages.MSR }, - { value: 'MAR', label: messages.MAR }, - { value: 'MOZ', label: messages.MOZ }, - { value: 'MMR', label: messages.MMR }, - { value: 'NAM', label: messages.NAM }, - { value: 'NRU', label: messages.NRU }, - { value: 'NPL', label: messages.NPL }, - { value: 'NLD', label: messages.NLD }, - { value: 'NCL', label: messages.NCL }, - { value: 'NZL', label: messages.NZL }, - { value: 'NIC', label: messages.NIC }, - { value: 'NER', label: messages.NER }, - { value: 'NGA', label: messages.NGA }, - { value: 'NIU', label: messages.NIU }, - { value: 'NFK', label: messages.NFK }, - { value: 'MNP', label: messages.MNP }, - { value: 'NOR', label: messages.NOR }, - { value: 'OMN', label: messages.OMN }, - { value: 'PAK', label: messages.PAK }, - { value: 'PLW', label: messages.PLW }, - { value: 'PAN', label: messages.PAN }, - { value: 'PNG', label: messages.PNG }, - { value: 'PRY', label: messages.PRY }, - { value: 'PER', label: messages.PER }, - { value: 'PHL', label: messages.PHL }, - { value: 'PCN', label: messages.PCN }, - { value: 'POL', label: messages.POL }, - { value: 'PRT', label: messages.PRT }, - { value: 'PRI', label: messages.PRI }, - { value: 'QAT', label: messages.QAT }, - { value: 'KOR', label: messages.KOR }, - { value: 'MDA', label: messages.MDA }, - { value: 'REU', label: messages.REU }, - { value: 'ROU', label: messages.ROU }, - { value: 'RUS', label: messages.RUS }, - { value: 'RWA', label: messages.RWA }, - { value: 'BLM', label: messages.BLM }, - { value: 'SHN', label: messages.SHN }, - { value: 'KNA', label: messages.KNA }, - { value: 'LCA', label: messages.LCA }, - { value: 'MAF', label: messages.MAF }, - { value: 'SPM', label: messages.SPM }, - { value: 'VCT', label: messages.VCT }, - { value: 'WSM', label: messages.WSM }, - { value: 'SMR', label: messages.SMR }, - { value: 'STP', label: messages.STP }, - { value: 'SAU', label: messages.SAU }, - { value: 'SEN', label: messages.SEN }, - { value: 'SRB', label: messages.SRB }, - { value: 'SYC', label: messages.SYC }, - { value: 'SLE', label: messages.SLE }, - { value: 'SGP', label: messages.SGP }, - { value: 'SXM', label: messages.SXM }, - { value: 'SVK', label: messages.SVK }, - { value: 'SVN', label: messages.SVN }, - { value: 'SLB', label: messages.SLB }, - { value: 'SOM', label: messages.SOM }, - { value: 'ZAF', label: messages.ZAF }, - { value: 'SGS', label: messages.SGS }, - { value: 'SSD', label: messages.SSD }, - { value: 'ESP', label: messages.ESP }, - { value: 'LKA', label: messages.LKA }, - { value: 'PSE', label: messages.PSE }, - { value: 'SDN', label: messages.SDN }, - { value: 'SUR', label: messages.SUR }, - { value: 'SJM', label: messages.SJM }, - { value: 'SWE', label: messages.SWE }, - { value: 'CHE', label: messages.CHE }, - { value: 'SYR', label: messages.SYR }, - { value: 'TJK', label: messages.TJK }, - { value: 'THA', label: messages.THA }, - { value: 'MKD', label: messages.MKD }, - { value: 'TLS', label: messages.TLS }, - { value: 'TGO', label: messages.TGO }, - { value: 'TKL', label: messages.TKL }, - { value: 'TON', label: messages.TON }, - { value: 'TTO', label: messages.TTO }, - { value: 'TUN', label: messages.TUN }, - { value: 'TUR', label: messages.TUR }, - { value: 'TKM', label: messages.TKM }, - { value: 'TCA', label: messages.TCA }, - { value: 'TUV', label: messages.TUV }, - { value: 'UGA', label: messages.UGA }, - { value: 'UKR', label: messages.UKR }, - { value: 'ARE', label: messages.ARE }, - { value: 'GBR', label: messages.GBR }, - { value: 'TZA', label: messages.TZA }, - { value: 'UMI', label: messages.UMI }, - { value: 'USA', label: messages.USA }, - { value: 'VIR', label: messages.VIR }, - { value: 'URY', label: messages.URY }, - { value: 'UZB', label: messages.UZB }, - { value: 'VUT', label: messages.VUT }, - { value: 'VEN', label: messages.VEN }, - { value: 'VNM', label: messages.VNM }, - { value: 'WLF', label: messages.WLF }, - { value: 'ESH', label: messages.ESH }, - { value: 'YEM', label: messages.YEM }, - { value: 'ZMB', label: messages.ZMB }, - { value: 'ZWE', label: messages.ZWE } - // Remove potentially null country values (Farajaland) -].filter((country): country is SelectOption => Boolean(country)) diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index f1e477ccc..a7aa9492a 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -11,7 +11,6 @@ import { FieldConfig, SelectOption } from '@opencrvs/toolkit/events' import { field } from '@opencrvs/toolkit/conditionals' -import { countries } from './countries' import { appendConditionalsToFields } from './utils' const idTypeOptions: SelectOption[] = [ @@ -129,14 +128,13 @@ export const getInformantFields = (person: string): FieldConfig[] => [ }, { id: `${person}.nationality`, - type: 'SELECT', + 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` }, - options: countries, conditionals: [] }, ...getIdFields(person), @@ -418,14 +416,13 @@ const getAddressFields = (person: string): FieldConfig[] => { return [ { id: `${prefix}.country`, - type: 'SELECT', + 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` }, - options: countries, conditionals: [] }, ...appendConditionalsToFields({ From d9fbb68b300315425de401871ffe2c54af18dd5d Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 20:27:35 +0600 Subject: [PATCH 20/25] feat: add place of birth --- src/form/V2/birth.ts | 72 ++++++++++++++++++++++++++++++++++++++++++- src/form/V2/person.ts | 2 +- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 159e6871a..66bea921c 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -22,7 +22,11 @@ import { and } from '@opencrvs/toolkit/conditionals' import { formMessageDescriptors } from './messageDescriptors' -import { getInformantFields, getPersonInputFields } from './person' +import { + getAddressFields, + getInformantFields, + getPersonInputFields +} from './person' import { appendConditionalsToFields } from './utils' const informantTypes = { @@ -265,6 +269,21 @@ const birthInformantTypeOptions: SelectOption[] = [ 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', @@ -394,6 +413,57 @@ const BIRTH_FORM = defineForm({ 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: 'TEXT', // @ToDo: select + required: true, + label: { + defaultMessage: 'Health Institute', + description: 'This is the label for the field', + id: 'event.birth.action.declare.form.section.child.field.birthLocation.label' + }, + 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', diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index a7aa9492a..a3576d964 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -249,7 +249,7 @@ const getIdFields = (person: string): FieldConfig[] => [ } ] -const getAddressFields = (person: string): FieldConfig[] => { +export const getAddressFields = (person: string): FieldConfig[] => { // @Todo: Same as mother or deseased const prefix = `${person}.address` From fd1019a8db7a6e73a1581c8c319f6614d5db44d0 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 20:29:21 +0600 Subject: [PATCH 21/25] fix: typo --- src/form/V2/birth.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 66bea921c..de3af7dd6 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -691,34 +691,34 @@ const BIRTH_FORM = defineForm({ }, fields: [ { - id: 'documents.profOfBirth', + 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.profOfBirth.label' + id: 'event.birth.action.declare.form.section.documents.field.proofOfBirth.label' } }, { - id: 'documents.profOfMother', + 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.profOfMother.label' + id: 'event.birth.action.declare.form.section.documents.field.proofOfMother.label' } }, { - id: 'documents.profOfFather', + 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.profOfFather.label' + id: 'event.birth.action.declare.form.section.documents.field.proofOfFather.label' } }, From a0a48bae414155d30ff007d1b86b446c49d1b686 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 9 Jan 2025 20:40:15 +0600 Subject: [PATCH 22/25] fix: align label and required properties with legecy birth --- src/form/V2/birth.ts | 18 +++++++++--------- src/form/V2/person.ts | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index de3af7dd6..88949edb6 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -367,7 +367,7 @@ const BIRTH_FORM = defineForm({ type: 'TEXT', required: true, label: { - defaultMessage: 'First name', + defaultMessage: 'First name(s)', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.child.field.firstname.label' } @@ -377,7 +377,7 @@ const BIRTH_FORM = defineForm({ type: 'TEXT', required: true, label: { - defaultMessage: 'Surname', + defaultMessage: 'Last name', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.child.field.surname.label' } @@ -429,7 +429,7 @@ const BIRTH_FORM = defineForm({ type: 'TEXT', // @ToDo: select required: true, label: { - defaultMessage: 'Health Institute', + defaultMessage: 'Health Institution', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.child.field.birthLocation.label' }, @@ -467,7 +467,7 @@ const BIRTH_FORM = defineForm({ { id: 'child.attendantAtBirth', type: 'SELECT', - required: true, + required: false, label: { defaultMessage: 'Attendant at birth', description: 'This is the label for the field', @@ -478,9 +478,9 @@ const BIRTH_FORM = defineForm({ { id: 'child.birthType', type: 'SELECT', - required: true, + required: false, label: { - defaultMessage: 'Birth type', + defaultMessage: 'Type of birth', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.child.field.birthType.label' }, @@ -489,7 +489,7 @@ const BIRTH_FORM = defineForm({ { id: 'child.weightAtBirth', type: 'TEXT', - required: true, + required: false, label: { defaultMessage: 'Weight at birth', description: 'This is the label for the field', @@ -535,7 +535,7 @@ const BIRTH_FORM = defineForm({ { id: 'informant.phoneNo', type: 'TEXT', - required: true, + required: false, label: { defaultMessage: 'Phone number', description: 'This is the label for the field', @@ -607,7 +607,7 @@ const BIRTH_FORM = defineForm({ type: 'TEXT', required: false, label: { - defaultMessage: 'No. of previous birth', + defaultMessage: 'No. of previous births', description: 'This is the label for the field', id: 'event.birth.action.declare.form.section.mother.field.previousBirths.label' }, diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index a3576d964..88ccdf5ce 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -54,7 +54,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: 'First name', + defaultMessage: 'First name(s)', description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.firstname.label` }, @@ -65,7 +65,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: 'Surname', + defaultMessage: 'Last name', description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.surname.label` }, @@ -146,7 +146,7 @@ export const getPersonInputFields = (person: string): FieldConfig[] => [ { id: `${person}.maritalStatus`, type: 'SELECT', - required: true, + required: false, label: { defaultMessage: 'Marital Status', description: 'This is the label for the field', @@ -198,7 +198,7 @@ const getIdFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: 'NID Number', + defaultMessage: 'ID Number', description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.nid.label` }, @@ -216,7 +216,7 @@ const getIdFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: 'Passport Number', + defaultMessage: 'ID Number', description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.passport.label` }, @@ -234,7 +234,7 @@ const getIdFields = (person: string): FieldConfig[] => [ type: 'TEXT', required: true, label: { - defaultMessage: 'Birth Registration Number', + defaultMessage: 'ID Number', description: 'This is the label for the field', id: `event.birth.action.declare.form.section.${person}.field.brn.label` }, @@ -261,7 +261,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'State', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.state.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.state.label` }, conditionals: [] }, @@ -272,7 +272,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'District', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.district.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.district.label` }, conditionals: [] }, @@ -283,7 +283,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'City / Town', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.town.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.town.label` }, conditionals: [] }, @@ -294,7 +294,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'Address Line 1', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.addressLine1.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine1.label` }, conditionals: [] }, @@ -305,7 +305,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'Address Line 2', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.addressLine2.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine2.label` }, conditionals: [] }, @@ -316,7 +316,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'Address Line 3', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.addressLine3.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.addressLine3.label` }, conditionals: [] }, @@ -327,7 +327,7 @@ export const getAddressFields = (person: string): FieldConfig[] => { label: { defaultMessage: 'Postcode / Zip', description: 'This is the label for the field', - id: `event.birth.action.declare.form.section.${person}.field.address.zipCode.label` + id: `event.birth.action.declare.form.section.${person}.field.address.other.zipCode.label` }, conditionals: [] } From 18b98a298cca8dd41299583b48d76bffbce17464 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 10 Jan 2025 13:08:03 +0600 Subject: [PATCH 23/25] fix: font of bulletList --- src/form/V2/birth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index 88949edb6..ea6868c0f 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -350,7 +350,7 @@ const BIRTH_FORM = defineForm({ id: 'form.section.information.birth.bullet4' } ], - font: 'h3' + font: 'reg16' } ] }, From 540454a865ec6802395bb53a142a83b620fccd14 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 10 Jan 2025 14:32:57 +0600 Subject: [PATCH 24/25] feat: add helper texts --- src/form/V2/birth.ts | 11 +++++++++++ src/form/V2/person.ts | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/form/V2/birth.ts b/src/form/V2/birth.ts index ea6868c0f..97044a980 100644 --- a/src/form/V2/birth.ts +++ b/src/form/V2/birth.ts @@ -690,6 +690,17 @@ const BIRTH_FORM = defineForm({ 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', diff --git a/src/form/V2/person.ts b/src/form/V2/person.ts index 88ccdf5ce..1df9d1097 100644 --- a/src/form/V2/person.ts +++ b/src/form/V2/person.ts @@ -138,6 +138,17 @@ export const getInformantFields = (person: string): FieldConfig[] => [ 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) ] From b7852bc21c8454dbc7fcddc23ce942b155afa4b4 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 10 Jan 2025 18:46:29 +0600 Subject: [PATCH 25/25] chore: bump up @opencrvs/toolkit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82124dad8..9f72ec857 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.9-events", + "@opencrvs/toolkit": "0.0.10-events", "@types/chalk": "^2.2.0", "@types/csv2json": "^1.4.0", "@types/fhir": "^0.0.30",