Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat: Added blood type info to patient #2190

Merged
merged 6 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/__tests__/patients/GeneralInformation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')

Expand Down
22 changes: 22 additions & 0 deletions src/patients/GeneralInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<Panel title={t('patient.basicInformation')} color="primary" collapsible>
Expand Down Expand Up @@ -145,6 +157,16 @@ const GeneralInformation = (props: Props): ReactElement => {
isEditable={isEditable}
/>
</div>
<div className="col">
<SelectWithLabelFormGroup
name="bloodType"
label={t('patient.bloodType')}
options={bloodTypeOptions}
defaultSelected={bloodTypeOptions.filter(({ value }) => value === patient.bloodType)}
onChange={(values) => onFieldChange('bloodType', values[0])}
isEditable={isEditable}
/>
</div>
saksham93 marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className="row">
<div className="col">
Expand Down
13 changes: 13 additions & 0 deletions src/shared/locales/enUs/translations/blood-type/index.ts
Original file line number Diff line number Diff line change
@@ -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',
},
}
2 changes: 2 additions & 0 deletions src/shared/locales/enUs/translations/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -22,4 +23,5 @@ export default {
...labs,
...incidents,
...settings,
...bloodType,
}
1 change: 1 addition & 0 deletions src/shared/locales/enUs/translations/patient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
approximateAge: 'Approximate Age',
placeOfBirth: 'Place of Birth',
sex: 'Sex',
bloodType: 'Blood Type',
contactInfoType: {
label: 'Type',
options: {
Expand Down
1 change: 1 addition & 0 deletions src/shared/model/Patient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati
notes?: Note[]
index: string
carePlans: CarePlan[]
bloodType: string
}