From 105b6246a3f9dea587a1bec31c41ed7d825311d0 Mon Sep 17 00:00:00 2001 From: sakshamgupta93 Date: Tue, 30 Jun 2020 01:25:24 +0530 Subject: [PATCH 1/3] 1. Added blood type field in patient 2. Added Blood Type in General Information 3. Added required translations --- src/patients/GeneralInformation.tsx | 22 +++++++++++++++++++ .../enUs/translations/blood-type/index.ts | 13 +++++++++++ src/shared/locales/enUs/translations/index.ts | 2 ++ .../enUs/translations/patient/index.ts | 1 + src/shared/model/Patient.ts | 1 + 5 files changed, 39 insertions(+) create mode 100644 src/shared/locales/enUs/translations/blood-type/index.ts diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index 5830d650ac..aeeda1bae1 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -73,6 +73,18 @@ const GeneralInformation = (props: Props): ReactElement => { { label: t('patient.types.private'), value: 'private' }, ] + const bloodTypeOptions: Option[] = [ + { label: t('bloodType.apositive'), value: 'A+'}, + { label: t('bloodType.anegative'), value: 'A-'}, + { label: t('bloodType.abpositive'), value: 'AB+'}, + { label: t('bloodType.abnegative'), value: 'AB-'}, + { label: t('bloodType.bpositive'), value: 'B+'}, + { label: t('bloodType.bnegative'), value: 'B-'}, + { label: t('bloodType.opositive'), value: 'O+'}, + { label: t('bloodType.onegative'), value: 'O-'}, + { label: t('bloodType.unknown'), value: 'unknown'}, + ] + return (
@@ -145,6 +157,16 @@ const GeneralInformation = (props: Props): ReactElement => { isEditable={isEditable} />
+
+ value === patient.bloodType)} + onChange={(values) => onFieldChange('bloodType', values[0])} + isEditable={isEditable} + /> +
diff --git a/src/shared/locales/enUs/translations/blood-type/index.ts b/src/shared/locales/enUs/translations/blood-type/index.ts new file mode 100644 index 0000000000..168dbc0d13 --- /dev/null +++ b/src/shared/locales/enUs/translations/blood-type/index.ts @@ -0,0 +1,13 @@ +export default { + bloodType: { + apositive: 'A+', + anegative: 'A-', + abpositive: 'AB+', + abnegative: 'AB-', + bpositive: 'B+', + bnegative: 'B-', + opositive: 'O+', + onegative: 'O-', + unknown: 'Unknown', + }, +} \ No newline at end of file diff --git a/src/shared/locales/enUs/translations/index.ts b/src/shared/locales/enUs/translations/index.ts index 55e5285113..0156382a63 100644 --- a/src/shared/locales/enUs/translations/index.ts +++ b/src/shared/locales/enUs/translations/index.ts @@ -9,6 +9,7 @@ import scheduling from './scheduling' import settings from './settings' import sex from './sex' import states from './states' +import bloodType from './blood-type' export default { ...actions, @@ -22,4 +23,5 @@ export default { ...labs, ...incidents, ...settings, + ...bloodType } diff --git a/src/shared/locales/enUs/translations/patient/index.ts b/src/shared/locales/enUs/translations/patient/index.ts index 0ed83fb712..035993aafe 100644 --- a/src/shared/locales/enUs/translations/patient/index.ts +++ b/src/shared/locales/enUs/translations/patient/index.ts @@ -13,6 +13,7 @@ export default { approximateAge: 'Approximate Age', placeOfBirth: 'Place of Birth', sex: 'Sex', + bloodType: 'Blood Type', contactInfoType: { label: 'Type', options: { diff --git a/src/shared/model/Patient.ts b/src/shared/model/Patient.ts index 2347a3a141..6703da59e9 100644 --- a/src/shared/model/Patient.ts +++ b/src/shared/model/Patient.ts @@ -21,4 +21,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati notes?: Note[] index: string carePlans: CarePlan[] + bloodType: string } From e25ceffbc838df90d27c3f4cc154346ccd12764b Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Mon, 29 Jun 2020 22:19:08 +0200 Subject: [PATCH 2/3] chore(lint): linting files --- src/patients/GeneralInformation.tsx | 18 +++++++++--------- .../enUs/translations/blood-type/index.ts | 2 +- src/shared/locales/enUs/translations/index.ts | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index aeeda1bae1..d9dbacd66c 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -74,15 +74,15 @@ const GeneralInformation = (props: Props): ReactElement => { ] const bloodTypeOptions: Option[] = [ - { label: t('bloodType.apositive'), value: 'A+'}, - { label: t('bloodType.anegative'), value: 'A-'}, - { label: t('bloodType.abpositive'), value: 'AB+'}, - { label: t('bloodType.abnegative'), value: 'AB-'}, - { label: t('bloodType.bpositive'), value: 'B+'}, - { label: t('bloodType.bnegative'), value: 'B-'}, - { label: t('bloodType.opositive'), value: 'O+'}, - { label: t('bloodType.onegative'), value: 'O-'}, - { label: t('bloodType.unknown'), value: 'unknown'}, + { label: t('bloodType.apositive'), value: 'A+' }, + { label: t('bloodType.anegative'), value: 'A-' }, + { label: t('bloodType.abpositive'), value: 'AB+' }, + { label: t('bloodType.abnegative'), value: 'AB-' }, + { label: t('bloodType.bpositive'), value: 'B+' }, + { label: t('bloodType.bnegative'), value: 'B-' }, + { label: t('bloodType.opositive'), value: 'O+' }, + { label: t('bloodType.onegative'), value: 'O-' }, + { label: t('bloodType.unknown'), value: 'unknown' }, ] return ( diff --git a/src/shared/locales/enUs/translations/blood-type/index.ts b/src/shared/locales/enUs/translations/blood-type/index.ts index 168dbc0d13..ef65d5c4b7 100644 --- a/src/shared/locales/enUs/translations/blood-type/index.ts +++ b/src/shared/locales/enUs/translations/blood-type/index.ts @@ -10,4 +10,4 @@ export default { onegative: 'O-', unknown: 'Unknown', }, -} \ No newline at end of file +} diff --git a/src/shared/locales/enUs/translations/index.ts b/src/shared/locales/enUs/translations/index.ts index 0156382a63..14672d5643 100644 --- a/src/shared/locales/enUs/translations/index.ts +++ b/src/shared/locales/enUs/translations/index.ts @@ -1,4 +1,5 @@ import actions from './actions' +import bloodType from './blood-type' import dashboard from './dashboard' import incidents from './incidents' import labs from './labs' @@ -9,7 +10,6 @@ import scheduling from './scheduling' import settings from './settings' import sex from './sex' import states from './states' -import bloodType from './blood-type' export default { ...actions, @@ -23,5 +23,5 @@ export default { ...labs, ...incidents, ...settings, - ...bloodType + ...bloodType, } From 1b58b79936c6a25396655557ef618fc8dc60701f Mon Sep 17 00:00:00 2001 From: sakshamgupta93 Date: Tue, 30 Jun 2020 18:06:30 +0530 Subject: [PATCH 3/3] Added test cases for blood type in patient information --- .../patients/GeneralInformation.test.tsx | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/__tests__/patients/GeneralInformation.test.tsx b/src/__tests__/patients/GeneralInformation.test.tsx index ecd1d1cc0d..2116f20d63 100644 --- a/src/__tests__/patients/GeneralInformation.test.tsx +++ b/src/__tests__/patients/GeneralInformation.test.tsx @@ -67,6 +67,7 @@ describe('General Information, without isEditable', () => { suffix: 'suffix', sex: 'male', type: 'charity', + bloodType: 'A-', dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), isApproximateDateOfBirth: false, occupation: 'occupation', @@ -141,6 +142,32 @@ describe('General Information, without isEditable', () => { expect(sexSelect.prop('options')[3].value).toEqual('unknown') }) + it('should render the blood type', () => { + const bloodTypeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'bloodType') + expect(bloodTypeSelect.prop('defaultSelected')[0].value).toEqual(patient.bloodType) + expect(bloodTypeSelect.prop('label')).toEqual('patient.bloodType') + expect(bloodTypeSelect.prop('isEditable')).toBeFalsy() + expect(bloodTypeSelect.prop('options')).toHaveLength(9) + expect(bloodTypeSelect.prop('options')[0].label).toEqual('bloodType.apositive') + expect(bloodTypeSelect.prop('options')[0].value).toEqual('A+') + expect(bloodTypeSelect.prop('options')[1].label).toEqual('bloodType.anegative') + expect(bloodTypeSelect.prop('options')[1].value).toEqual('A-') + expect(bloodTypeSelect.prop('options')[2].label).toEqual('bloodType.abpositive') + expect(bloodTypeSelect.prop('options')[2].value).toEqual('AB+') + expect(bloodTypeSelect.prop('options')[3].label).toEqual('bloodType.abnegative') + expect(bloodTypeSelect.prop('options')[3].value).toEqual('AB-') + expect(bloodTypeSelect.prop('options')[4].label).toEqual('bloodType.bpositive') + expect(bloodTypeSelect.prop('options')[4].value).toEqual('B+') + expect(bloodTypeSelect.prop('options')[5].label).toEqual('bloodType.bnegative') + expect(bloodTypeSelect.prop('options')[5].value).toEqual('B-') + expect(bloodTypeSelect.prop('options')[6].label).toEqual('bloodType.opositive') + expect(bloodTypeSelect.prop('options')[6].value).toEqual('O+') + expect(bloodTypeSelect.prop('options')[7].label).toEqual('bloodType.onegative') + expect(bloodTypeSelect.prop('options')[7].value).toEqual('O-') + expect(bloodTypeSelect.prop('options')[8].label).toEqual('bloodType.unknown') + expect(bloodTypeSelect.prop('options')[8].value).toEqual('unknown') + }) + it('should render the patient type select', () => { const typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type') expect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type) @@ -230,6 +257,7 @@ describe('General Information, isEditable', () => { familyName: 'familyName', suffix: 'suffix', sex: 'male', + bloodType: 'A-', type: 'charity', dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), isApproximateDateOfBirth: false, @@ -281,6 +309,7 @@ describe('General Information, isEditable', () => { { value: 'address C', type: undefined, id: '654' }, { value: 'address D', type: undefined, id: '321' }, ] + const expectedBloodType = 'unknown' it('should render the prefix', () => { const prefixInput = wrapper.findWhere((w: any) => w.prop('name') === 'prefix') @@ -360,6 +389,40 @@ describe('General Information, isEditable', () => { expect(sexSelect.prop('options')[3].value).toEqual('unknown') }) + it('should render the blood type select', () => { + const bloodTypeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'bloodType') + expect(bloodTypeSelect.prop('defaultSelected')[0].value).toEqual(patient.bloodType) + expect(bloodTypeSelect.prop('label')).toEqual('patient.bloodType') + expect(bloodTypeSelect.prop('isEditable')).toBeTruthy() + expect(bloodTypeSelect.prop('options')).toHaveLength(9) + expect(bloodTypeSelect.prop('options')[0].label).toEqual('bloodType.apositive') + expect(bloodTypeSelect.prop('options')[0].value).toEqual('A+') + expect(bloodTypeSelect.prop('options')[1].label).toEqual('bloodType.anegative') + expect(bloodTypeSelect.prop('options')[1].value).toEqual('A-') + expect(bloodTypeSelect.prop('options')[2].label).toEqual('bloodType.abpositive') + expect(bloodTypeSelect.prop('options')[2].value).toEqual('AB+') + expect(bloodTypeSelect.prop('options')[3].label).toEqual('bloodType.abnegative') + expect(bloodTypeSelect.prop('options')[3].value).toEqual('AB-') + expect(bloodTypeSelect.prop('options')[4].label).toEqual('bloodType.bpositive') + expect(bloodTypeSelect.prop('options')[4].value).toEqual('B+') + expect(bloodTypeSelect.prop('options')[5].label).toEqual('bloodType.bnegative') + expect(bloodTypeSelect.prop('options')[5].value).toEqual('B-') + expect(bloodTypeSelect.prop('options')[6].label).toEqual('bloodType.opositive') + expect(bloodTypeSelect.prop('options')[6].value).toEqual('O+') + expect(bloodTypeSelect.prop('options')[7].label).toEqual('bloodType.onegative') + expect(bloodTypeSelect.prop('options')[7].value).toEqual('O-') + expect(bloodTypeSelect.prop('options')[8].label).toEqual('bloodType.unknown') + expect(bloodTypeSelect.prop('options')[8].value).toEqual('unknown') + act(() => { + bloodTypeSelect.prop('onChange')([expectedBloodType]) + }) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ + ...patient, + bloodType: expectedBloodType, + }) + }) + it('should render the patient type select', () => { const typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type')