Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat implement birth v2 #353

Merged
merged 35 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
52fce1c
chore: update yarn.lock
jamil314 Jan 1, 2025
5d4ca76
feat: wip: birth event v2
jamil314 Jan 1, 2025
6654398
feat: use select option in gender, attendantAtBirth and birthType
jamil314 Jan 1, 2025
d11abb6
fix: use number for weight at birth
jamil314 Jan 2, 2025
fc6587d
feat: person input wip
jamil314 Jan 3, 2025
78ba94b
Merge branch 'develop' into feat-birth-v2
jamil314 Jan 6, 2025
6015741
feat: show dob or age based on dobUnknown checkbox
jamil314 Jan 6, 2025
505a08e
chore: rename directory
jamil314 Jan 6, 2025
373323b
amend: import from renamed directory
jamil314 Jan 6, 2025
07be5e2
feat: add informant relation to birth form
jamil314 Jan 6, 2025
4acd8f7
Merge branch 'develop' into feat-birth-v2
jamil314 Jan 7, 2025
c05f0d9
feat: render informant fields based on relation to child
jamil314 Jan 7, 2025
15fe150
feat: separate the logic for concatenating field id
jamil314 Jan 7, 2025
2a3758a
feat: complete informant details apart form person inputs
jamil314 Jan 7, 2025
29b280a
feat: implement id and address
jamil314 Jan 8, 2025
ed40dd7
refactor: create utils
jamil314 Jan 8, 2025
2b184f9
fix: handle undefined values in conditionals
jamil314 Jan 9, 2025
64a65aa
chore: Merge branch "develop" into feat-birth-v2
jamil314 Jan 9, 2025
cd43a65
feat: implement father and mother details
jamil314 Jan 9, 2025
a177f5e
feat: implement upload supporting document
jamil314 Jan 9, 2025
9e8e724
fix: use simpler concat
jamil314 Jan 9, 2025
e360b7b
feat: use country field
jamil314 Jan 9, 2025
d9fbb68
feat: add place of birth
jamil314 Jan 9, 2025
fd1019a
fix: typo
jamil314 Jan 9, 2025
a0a48ba
fix: align label and required properties with legecy birth
jamil314 Jan 9, 2025
18b98a2
fix: font of bulletList
jamil314 Jan 10, 2025
540454a
feat: add helper texts
jamil314 Jan 10, 2025
b7852bc
chore: bump up @opencrvs/toolkit
jamil314 Jan 10, 2025
100370a
Merge branch develop into feat-birth-v2
jamil314 Jan 15, 2025
a215493
rename: BirthEvent to birthEvent
jamil314 Jan 15, 2025
ebbf8f1
chore: remove the messages that are not in use
jamil314 Jan 15, 2025
75278c5
chore: remove unused
jamil314 Jan 15, 2025
cbae59e
refactor: use informantType instead of hardcoding
jamil314 Jan 15, 2025
9511916
refactor: birth event
jamil314 Jan 16, 2025
fc1e9fe
chore: bump up toolkit
jamil314 Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "0.0.13-events",
"@opencrvs/toolkit": "0.0.14-events",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down
3 changes: 2 additions & 1 deletion src/api/custom-event/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import * as Hapi from '@hapi/hapi'
import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership'
import { EventDocument } from '@opencrvs/toolkit/events'
import { birthEvent } from '@countryconfig/form/v2/birth'

export function getCustomEventsHandler(
request: Hapi.Request,
h: Hapi.ResponseToolkit
) {
return h.response([tennisClubMembershipEvent]).code(200)
return h.response([tennisClubMembershipEvent, birthEvent]).code(200)
}

export function onRegisterHandler(
Expand Down
312 changes: 312 additions & 0 deletions src/form/v2/birth/forms/child.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { defineFormPage, TranslationConfig } from '@opencrvs/toolkit/events'
import { field } from '@opencrvs/toolkit/conditionals'
import { appendConditionalsToFields, createSelectOptions } from '../../utils'
import { getAddressFields } from '../../person/address'

const GenderTypes = {
MALE: 'male',
FEMALE: 'female',
UNKNOWN: 'unknown'
} as const

const TypeOfBirth = {
SINGLE: 'SINGLE',
TWIN: 'TWIN',
TRIPLET: 'TRIPLET',
QUADRUPLET: 'QUADRUPLET',
HIGHER_MULTIPLE_DELIVERY: 'HIGHER_MULTIPLE_DELIVERY'
} as const

const AttendantAtBirth = {
PHYSICIAN: 'PHYSICIAN',
NURSE: 'NURSE',
MIDWIFE: 'MIDWIFE',
OTHER_PARAMEDICAL_PERSONNEL: 'OTHER_PARAMEDICAL_PERSONNEL',
LAYPERSON: 'LAYPERSON',
TRADITIONAL_BIRTH_ATTENDANT: 'TRADITIONAL_BIRTH_ATTENDANT',
NONE: 'NONE'
} as const

const PlaceOfBirth = {
HEALTH_FACILITY: 'HEALTH_FACILITY',
PRIVATE_HOME: 'PRIVATE_HOME',
OTHER: 'OTHER'
} as const

const genderMessageDescriptors = {
MALE: {
defaultMessage: 'Male',
description: 'Label for option male',
id: 'form.field.label.sexMale'
},
FEMALE: {
defaultMessage: 'Female',
description: 'Label for option female',
id: 'form.field.label.sexFemale'
},
UNKNOWN: {
defaultMessage: 'Unknown',
description: 'Label for option unknown',
id: 'form.field.label.sexUnknown'
}
} satisfies Record<keyof typeof GenderTypes, TranslationConfig>

const typeOfBirthMessageDescriptors = {
SINGLE: {
defaultMessage: 'Single',
description: 'Label for single birth',
id: 'form.field.label.birthTypeSingle'
},
TWIN: {
defaultMessage: 'Twin',
description: 'Label for twin birth',
id: 'form.field.label.birthTypeTwin'
},
TRIPLET: {
defaultMessage: 'Triplet',
description: 'Label for triplet birth',
id: 'form.field.label.birthTypeTriplet'
},
QUADRUPLET: {
defaultMessage: 'Quadruplet',
description: 'Label for quadruplet birth',
id: 'form.field.label.birthTypeQuadruplet'
},
HIGHER_MULTIPLE_DELIVERY: {
defaultMessage: 'Higher multiple delivery',
description: 'Label for higher multiple delivery birth',
id: 'form.field.label.birthTypeHigherMultipleDelivery'
}
} satisfies Record<keyof typeof TypeOfBirth, TranslationConfig>

const attendantAtBirthMessageDescriptors = {
PHYSICIAN: {
defaultMessage: 'Physician',
description: 'Label for physician attendant',
id: 'form.field.label.attendantAtBirthPhysician'
},
NURSE: {
defaultMessage: 'Nurse',
description: 'Label for nurse attendant',
id: 'form.field.label.attendantAtBirthNurse'
},
MIDWIFE: {
defaultMessage: 'Midwife',
description: 'Label for midwife attendant',
id: 'form.field.label.attendantAtBirthMidwife'
},
OTHER_PARAMEDICAL_PERSONNEL: {
defaultMessage: 'Other paramedical personnel',
description: 'Label for other paramedical personnel',
id: 'form.field.label.attendantAtBirthOtherParamedicalPersonnel'
},
LAYPERSON: {
defaultMessage: 'Layperson',
description: 'Label for layperson attendant',
id: 'form.field.label.attendantAtBirthLayperson'
},
TRADITIONAL_BIRTH_ATTENDANT: {
defaultMessage: 'Traditional birth attendant',
description: 'Label for traditional birth attendant',
id: 'form.field.label.attendantAtBirthTraditionalBirthAttendant'
},
NONE: {
defaultMessage: 'None',
description: 'Label for no attendant',
id: 'form.field.label.attendantAtBirthNone'
}
} satisfies Record<keyof typeof AttendantAtBirth, TranslationConfig>

const placeOfBirthMessageDescriptors = {
HEALTH_FACILITY: {
defaultMessage: 'Health Institution',
description: 'Select item for Health Institution',
id: 'form.field.label.healthInstitution'
},
PRIVATE_HOME: {
defaultMessage: 'Residential address',
description: 'Select item for Private Home',
id: 'form.field.label.privateHome'
},
OTHER: {
defaultMessage: 'Other',
description: 'Select item for Other location',
id: 'form.field.label.otherInstitution'
}
} satisfies Record<keyof typeof PlaceOfBirth, TranslationConfig>

const genderOptions = createSelectOptions(GenderTypes, genderMessageDescriptors)

const placeOfBirthOptions = createSelectOptions(
PlaceOfBirth,
placeOfBirthMessageDescriptors
)

const typeOfBirthOptions = createSelectOptions(
TypeOfBirth,
typeOfBirthMessageDescriptors
)

const attendantAtBirthOptions = createSelectOptions(
AttendantAtBirth,
attendantAtBirthMessageDescriptors
)

export const childPage = defineFormPage({
id: 'child',
title: {
defaultMessage: "Child's details",
description: 'Form section title for Child',
id: 'form.birth.child.title'
},
fields: [
{
id: 'child.firstname',
type: 'TEXT',
required: true,
label: {
defaultMessage: 'First name(s)',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.firstname.label'
}
},
{
id: 'child.surname',
type: 'TEXT',
required: true,
label: {
defaultMessage: 'Last name',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.surname.label'
}
},
{
id: 'child.gender',
type: 'SELECT',
required: true,
label: {
defaultMessage: 'Sex',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.gender.label'
},
options: genderOptions
},
{
id: 'child.dob',
type: 'DATE',
required: true,
validation: [
{
message: {
defaultMessage: 'Please enter a valid date',
description: 'This is the error message for invalid date',
id: 'event.birth.action.declare.form.section.child.field.dob.error'
},
validator: field('child.dob').isBeforeNow()
}
],
label: {
defaultMessage: 'Date of birth',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.dob.label'
}
},
{
id: 'child.placeOfBirth',
type: 'SELECT',
required: true,
label: {
defaultMessage: 'Place of delivery',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.placeOfBirth.label'
},
options: placeOfBirthOptions
},
{
id: 'child.birthLocation',
type: 'TEXT', // @ToDo: select
required: true,
label: {
defaultMessage: 'Health Institution',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.birthLocation.label'
},
conditionals: [
{
type: 'HIDE',
conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([
'HEALTH_FACILITY'
])
}
]
},
...appendConditionalsToFields({
inputFields: getAddressFields('child.privateHome'),
newConditionals: [
{
type: 'HIDE',
conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([
'PRIVATE_HOME'
])
}
]
}),
...appendConditionalsToFields({
inputFields: getAddressFields('child.other'),
newConditionals: [
{
type: 'HIDE',
conditional: field('child.placeOfBirth').isUndefinedOrNotInArray([
'OTHER'
])
}
]
}),
{
id: 'child.attendantAtBirth',
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Attendant at birth',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.attendantAtBirth.label'
},
options: attendantAtBirthOptions
},
{
id: 'child.birthType',
type: 'SELECT',
required: false,
label: {
defaultMessage: 'Type of birth',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.birthType.label'
},
options: typeOfBirthOptions
},
{
id: 'child.weightAtBirth',
type: 'TEXT',
required: false,
label: {
defaultMessage: 'Weight at birth',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.child.field.weightAtBirth.label'
},
options: {
type: 'number'
}
}
]
})
Loading
Loading