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

fix: remove steps and add fields to others #14821

Merged
merged 10 commits into from
May 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
fatalAccident,
fatalAccidentAttachment,
fishingCompanyInfo,
hindrances,

Check warning on line 23 in libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts

View workflow job for this annotation

GitHub Actions / linting (application-system-form,application-template-api-modules,application-template-loader,app...

'hindrances' is defined but never used. Allowed unused vars must match /^_[a-zA-Z0-9]*$/u
injuredPersonInformation,
locationAndPurpose,
rescueSquadInfo,
Expand Down Expand Up @@ -48,6 +48,7 @@
getAccidentTypeOptions,
hideLocationAndPurpose,
isAgricultureAccident,
isDateOlderThanAYear,
isFatalAccident,
isFishermanAccident,
isGeneralWorkplaceAccident,
Expand All @@ -63,68 +64,13 @@
isWorkAccident,
} from '../../utils'
import { isHealthInsured } from '../../utils/isHealthInsured'
import { FormValue } from '@island.is/application/types'
import { isSportAccidentAndEmployee } from '../../utils/isSportAccidentAndEmployee'

export const aboutTheAccidentSection = buildSection({
id: 'accidentType.section',
title: accidentType.general.sectionTitle,
children: [
buildSubSection({
id: 'hindrances',
title: hindrances.general.sectionTitle,
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
children: [
buildMultiField({
id: 'timePassedHindrancesMultiField',
title: hindrances.timePassedHindrance.radioFieldTitle,
children: [
buildRadioField({
id: 'timePassedHindrance',
title: '',
options: [
{ value: YES, label: application.general.yesOptionLabel },
{ value: NO, label: application.general.noOptionLabel },
],
width: 'half',
largeButtons: true,
required: true,
}),
buildAlertMessageField({
id: 'timePassedHindranceFielAlertMessage',
title: hindrances.timePassedHindrance.errorTitle,
message: hindrances.timePassedHindrance.errorDescription,
alertType: 'info',
doesNotRequireAnswer: true,
condition: (formValue) => formValue.timePassedHindrance === YES,
}),
],
}),
buildMultiField({
id: 'carHindrancesMultiField',
title: hindrances.carAccident.radioFieldTitle,
children: [
buildRadioField({
title: '',
id: 'carAccidentHindrance',
options: [
{ value: YES, label: application.general.yesOptionLabel },
{ value: NO, label: application.general.noOptionLabel },
],
width: 'half',
largeButtons: true,
required: true,
}),
buildAlertMessageField({
id: 'carAccidentHindranceFielAlertMessage',
title: hindrances.carAccident.errorTitle,
message: hindrances.carAccident.errorDescription,
alertType: 'info',
doesNotRequireAnswer: true,
condition: (formValue) => formValue.carAccidentHindrance === YES,
}),
],
}),
],
}),

buildSubSection({
id: 'accidentType.section',
title: accidentType.general.subsectionTitle,
Expand Down Expand Up @@ -242,6 +188,14 @@
},
],
}),
buildAlertMessageField({
id: 'attachments.injuryCertificate.alert',
title: application.general.warningTitle,
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
message: application.general.warningMessage,
alertType: 'info',
doesNotRequireAnswer: true,
condition: (formValue) => isSportAccidentAndEmployee(formValue),
}),
],
}),

Expand Down Expand Up @@ -293,7 +247,9 @@
id: 'accidentLocation.generalWorkAccident',
title: accidentLocation.general.heading,
description: accidentLocation.general.description,
condition: (formValue) => isGeneralWorkplaceAccident(formValue),
condition: (formValue) =>
isGeneralWorkplaceAccident(formValue) ||
isSportAccidentAndEmployee(formValue),
children: [
buildRadioField({
id: 'accidentLocation.answer',
Expand Down Expand Up @@ -405,7 +361,9 @@
id: 'accidentLocation.professionalAthleteAccident',
title: accidentLocation.general.heading,
description: accidentLocation.general.description,
condition: (formValue) => isProfessionalAthleteAccident(formValue),
condition: (formValue) =>
isProfessionalAthleteAccident(formValue) &&
!isSportAccidentAndEmployee(formValue),
children: [
buildRadioField({
id: 'accidentLocation.answer',
Expand Down Expand Up @@ -518,7 +476,8 @@
title: workMachine.general.sectionTitle,
condition: (formValue) =>
isGeneralWorkplaceAccident(formValue) ||
isAgricultureAccident(formValue),
isAgricultureAccident(formValue) ||
isSportAccidentAndEmployee(formValue),
children: [
buildMultiField({
id: 'workMachine',
Expand Down Expand Up @@ -582,6 +541,15 @@
width: 'half',
format: '##:##',
}),
buildAlertMessageField({
id: 'accidentDetails.moreThanAYearAlertMessage',
title: accidentDetails.general.moreThanAYearAlertTitle,
message: accidentDetails.general.moreThanAYearAlertMessage,
width: 'full',
alertType: 'warning',
condition: (formValue) => isDateOlderThanAYear(formValue),
marginBottom: 0,
}),
buildAlertMessageField({
id: 'accidentDetails.notHealthInsuredAlertMessage',
title: accidentDetails.general.insuranceAlertTitle,
Expand All @@ -601,6 +569,37 @@
variant: 'textarea',
maxLength: 2000,
}),
buildTextField({
id: 'accidentDetails.accidentSymptoms',
title: accidentDetails.labels.symptoms,
placeholder: accidentDetails.placeholder.symptoms,
backgroundColor: 'blue',
required: true,
rows: 10,
variant: 'textarea',
maxLength: 2000,
}),
buildDescriptionField({
id: 'accidentDetails.descriptionField',
space: 'containerGutter',
titleVariant: 'h5',
title: accidentDetails.labels.doctorVisit,
width: 'full',
}),
buildCustomField({
id: 'accidentDetails.dateOfDoctorVisit',
title: accidentDetails.labels.date,
component: 'DateOfAccident',
width: 'half',
}),
buildTextField({
id: 'accidentDetails.timeOfDoctorVisit',
title: accidentDetails.labels.time,
placeholder: accidentDetails.placeholder.doctorVisitTime,
backgroundColor: 'blue',
width: 'half',
format: '##:##',
}),
],
}),
],
Expand Down Expand Up @@ -1403,3 +1402,6 @@
}),
],
})
function isProfessionalAthleteAndEmployee(formValue: FormValue): boolean {

Check warning on line 1405 in libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts

View workflow job for this annotation

GitHub Actions / linting (application-system-form,application-template-api-modules,application-template-loader,app...

Expected a function expression

Check warning on line 1405 in libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts

View workflow job for this annotation

GitHub Actions / linting (application-system-form,application-template-api-modules,application-template-loader,app...

'isProfessionalAthleteAndEmployee' is defined but never used. Allowed unused vars must match /^_[a-zA-Z0-9]*$/u
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('Function not implemented.')
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
buildAlertMessageField,
buildCheckboxField,
buildCustomField,
buildDescriptionField,
buildFileUploadField,
buildMultiField,
buildRadioField,
Expand Down Expand Up @@ -110,6 +111,21 @@ export const whoIsTheNotificationForSection = buildSection({
width: 'half',
variant: 'tel',
}),
buildDescriptionField({
id: 'accidentDetails.descriptionField',
space: 'containerGutter',
title: injuredPersonInformation.general.jobTitle,
description: injuredPersonInformation.general.jobTitleDescription,
width: 'full',
marginBottom: 2,
}),
buildTextField({
id: 'injuredPersonInformation.jobTitle',
title: injuredPersonInformation.labels.jobTitle,
backgroundColor: 'white',
width: 'full',
maxLength: 100,
}),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ export const accidentDetails = {
description:
'According to electronic information from the Director of Internal Revenue, you do not appear to have filled in the appropriate field on your tax return and are therefore not insured against household related accidents during the period in which the accident took place.',
},
moreThanAYearAlertTitle: {
id: 'an.application:accidentDetails.general.moreThanAYearAlertTitle',
defaultMessage: 'Athugið',
description: 'Alert',
},
moreThanAYearAlertMessage: {
id: 'an.application:accidentDetails.general.moreThanAYearAlertMessage',
defaultMessage:
'Öll slys skal að jafnaði tilkynna innan eins árs, en heimilt er að veita undanþágu frá þeirri reglu, að ákveðnum forsendum uppfylltum.',
description:
'The accident took place more than a year ago. It is necessary to contact the Insurance Fund for further instructions.',
},
}),
labels: defineMessages({
date: {
Expand All @@ -43,6 +55,16 @@ export const accidentDetails = {
defaultMessage: 'Ýtarleg lýsing á slysi',
description: 'Description of accident',
},
symptoms: {
id: 'an.application:accidentDetails.labels.symptoms',
defaultMessage: 'Lýsing á einkennum og afleiðingum slyss',
description: 'Accident symptoms',
},
doctorVisit: {
id: 'an.application:accidentDetails.labels.doctorVisit',
defaultMessage: 'Hvenær leitaðir þú fyrst til læknis?',
description: 'When did you first visit a doctor after the accident?',
},
}),
placeholder: defineMessages({
date: {
Expand All @@ -61,5 +83,15 @@ export const accidentDetails = {
description:
'Write here the outline, cause and circumstances of the accident',
},
symptoms: {
id: 'an.application:accidentDetails.placeholder.symptoms',
defaultMessage: 'Skrifaðu hér einkenni og afleiðingar slyssins',
description: 'Write here the symptoms and consequences of the accident',
},
doctorVisitTime: {
id: 'an.application:accidentDetails.placeholder.doctorVisit',
defaultMessage: 'Sláðu inn tíma heimsóknar',
description: 'Enter the time of the visit',
},
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const application = {
general: defineMessages({
name: {
id: 'an.application:general.name',
defaultMessage: 'Slysatilkynning til Sjúkratryggingar Íslands ',
defaultMessage: 'Slysatilkynning til Sjúkratrygginga Íslands ',
description: 'Accident notification to Sjúkratryggingar Íslands',
},
institutionName: {
Expand All @@ -22,6 +22,17 @@ export const application = {
defaultMessage: 'Nei',
description: 'No',
},
warningTitle: {
id: 'an.application:application.warningTitle',
defaultMessage: 'Athugið',
description: 'Warning',
},
warningMessage: {
id: 'an.application:application.warningDescription',
defaultMessage:
'Ef hinn slasaði þiggur greiðslur frá íþróttafélaginu þá er málið meðhöndlað sem vinnuslys.',
description: 'Warning description',
},
}),
deliveryOfData: defineMessages({
name: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ export const injuredPersonInformation = {
description:
'Description label for injured person information section when submitting for juridical person.',
},
jobTitle: {
id: 'an.application:injuredPersonInformation.general.jobTitle',
defaultMessage: 'Starfsheiti',
description: 'Job title',
},
jobTitleDescription: {
id: 'an.application:injuredPersonInformation.general.jobTitleDescription',
defaultMessage:
'Sláðu inn starfsheiti þess slasaða þegar slysið átti sér stað.',
description: 'Description for job title',
},
}),
labels: defineMessages({
name: {
Expand All @@ -47,6 +58,11 @@ export const injuredPersonInformation = {
defaultMessage: 'Símanúmer',
description: 'Telephone number',
},
jobTitle: {
id: 'an.application:injuredPersonInformation.labels.jobTitle',
defaultMessage: 'Starfsheiti',
description: 'Job title',
},
}),
upload: defineMessages({
uploadHeader: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { FormValue } from '@island.is/application/types'
import { AccidentTypeEnum, WorkAccidentTypeEnum } from '../types'
import exp from 'constants'
import { isSportAccidentAndEmployee } from './isSportAccidentAndEmployee'
import { accidentType } from '../lib/messages'

describe('isSportAccidentAndEmployee', () => {
const sportAccidentRadio: FormValue = {
accidentType: { radioButton: AccidentTypeEnum.SPORTS },
onPayRoll: { answer: 'yes' },
}

const someOtherAccident: FormValue = {
workAccident: { type: AccidentTypeEnum.HOMEACTIVITIES },
onPayRoll: { answer: 'yes' },
}

const notOnPayroll: FormValue = {
accidentType: { radioButton: AccidentTypeEnum.SPORTS },
onPayRoll: { answer: 'no' },
}

it('should return true for sport accidents where the person is also an employee of the sports club', () => {
expect(isSportAccidentAndEmployee(sportAccidentRadio)).toEqual(true)
})

it('should return false for other accidents', () => {
expect(isSportAccidentAndEmployee(someOtherAccident)).toEqual(false)
})

it('should return false if the person is not on payroll', () => {
expect(isSportAccidentAndEmployee(notOnPayroll)).toEqual(false)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Answer, FormValue } from '@island.is/application/types'
import { AccidentTypeEnum, YesOrNo } from '../types'
import { getValueViaPath } from '@island.is/application/core'

// When a person is hurt in a sports accident and is an employee of the sport, the accident
// is considered a work accident. This function checks if both conditions have been checked
export const isSportAccidentAndEmployee = (formValue: FormValue) => {
const workAccidentType = getValueViaPath(
formValue,
'accidentType.radioButton',
) as AccidentTypeEnum
const onPayRoll = getValueViaPath(formValue, 'onPayRoll.answer') as YesOrNo

if (workAccidentType === AccidentTypeEnum.SPORTS && onPayRoll === 'yes') {
return true
}

return false
}
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
Loading