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') diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index 5830d650ac..d9dbacd66c 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..ef65d5c4b7 --- /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', + }, +} diff --git a/src/shared/locales/enUs/translations/index.ts b/src/shared/locales/enUs/translations/index.ts index 55e5285113..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' @@ -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 }