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

fix(patients): current patient can no longer be related person #1959

Merged
merged 23 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
08df8c5
fix(#1946): patients can also be related person
alti21 Apr 2, 2020
82f3c98
Merge branch 'master' into master
Apr 3, 2020
cdd1be8
Merge branch 'master' into master
Apr 3, 2020
c6d2b83
Merge branch 'master' into master
Apr 3, 2020
60e18fc
Merge branch 'master' into master
Apr 3, 2020
51771de
Merge branch 'master' into master
Apr 3, 2020
476de1a
Merge branch 'master' into master
Apr 3, 2020
534c9de
fix(patients): current patient can't be related person
alti21 Apr 4, 2020
2985c00
Merge branch 'master' of https://github.com/alti21/hospitalrun-frontend
alti21 Apr 4, 2020
32a568e
Merge branch 'master' into master
Apr 6, 2020
b4c31dc
Merge branch 'master' into master
Apr 6, 2020
666a9b8
Merge branch 'master' into master
Apr 7, 2020
46f72e9
Merge branch 'master' into master
Apr 8, 2020
3c403bc
Merge branch 'master' into master
Apr 8, 2020
4a168ed
Merge branch 'master' into master
Apr 8, 2020
27ad2b7
Merge branch 'master' into master
Apr 9, 2020
af67dac
Merge branch 'master' into master
Apr 9, 2020
fd195f2
fix(patients): added test for patient not showing in list
alti21 Apr 10, 2020
d36bcc0
Merge branch 'master' of https://github.com/alti21/hospitalrun-frontend
alti21 Apr 10, 2020
6ad726a
fix(patient): removed unnecessary comment
alti21 Apr 10, 2020
746b828
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
62dc561
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
5a8d701
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
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
25 changes: 20 additions & 5 deletions src/__tests__/components/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ describe('Navbar', () => {
})
it('should navigate to / when the header is clicked', () => {
act(() => {
header.first().props().onClick()
header
.first()
.props()
.onClick()
})
expect(history.location.pathname).toEqual('/')
})
Expand All @@ -45,13 +48,19 @@ describe('Navbar', () => {
})
it('should navigate to /patients when the list option is selected', () => {
act(() => {
patientsLinkList.first().props().children[0].props.onClick()
patientsLinkList
.first()
.props()
.children[0].props.onClick()
})
expect(history.location.pathname).toEqual('/patients')
})
it('should navigate to /patients/new when the list option is selected', () => {
act(() => {
patientsLinkList.first().props().children[1].props.onClick()
patientsLinkList
.first()
.props()
.children[1].props.onClick()
})
expect(history.location.pathname).toEqual('/patients/new')
})
Expand All @@ -72,14 +81,20 @@ describe('Navbar', () => {

it('should navigate to to /appointments when the appointment list option is selected', () => {
act(() => {
scheduleLinkList.first().props().children[0].props.onClick()
scheduleLinkList
.first()
.props()
.children[0].props.onClick()
})
expect(history.location.pathname).toEqual('/appointments')
})

it('should navigate to /appointments/new when the new appointment list option is selected', () => {
act(() => {
scheduleLinkList.first().props().children[1].props.onClick()
scheduleLinkList
.first()
.props()
.children[1].props.onClick()
})
expect(history.location.pathname).toEqual('/appointments/new')
})
Expand Down
49 changes: 42 additions & 7 deletions src/__tests__/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(1).text().trim()).toEqual('dashboard.label')
expect(
listItems
.at(1)
.text()
.trim(),
).toEqual('dashboard.label')
})

it('should be active when the current path is /', () => {
Expand Down Expand Up @@ -65,7 +70,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(2).text().trim()).toEqual('patients.label')
expect(
listItems
.at(2)
.text()
.trim(),
).toEqual('patients.label')
})

it('should be active when the current path is /', () => {
Expand Down Expand Up @@ -95,7 +105,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(4).text().trim()).toEqual('patients.patientsList')
expect(
listItems
.at(4)
.text()
.trim(),
).toEqual('patients.patientsList')
})

it('should be active when the current path is /patients', () => {
Expand Down Expand Up @@ -125,7 +140,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(3).text().trim()).toEqual('patients.newPatient')
expect(
listItems
.at(3)
.text()
.trim(),
).toEqual('patients.newPatient')
})

it('should be active when the current path is /patients/new', () => {
Expand Down Expand Up @@ -155,7 +175,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(3).text().trim()).toEqual('scheduling.label')
expect(
listItems
.at(3)
.text()
.trim(),
).toEqual('scheduling.label')
})

it('should be active when the current path is /appointments', () => {
Expand Down Expand Up @@ -185,7 +210,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(5).text().trim()).toEqual('scheduling.appointments.schedule')
expect(
listItems
.at(5)
.text()
.trim(),
).toEqual('scheduling.appointments.schedule')
})

it('should be active when the current path is /appointments', () => {
Expand Down Expand Up @@ -215,7 +245,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(4).text().trim()).toEqual('scheduling.appointments.new')
expect(
listItems
.at(4)
.text()
.trim(),
).toEqual('scheduling.appointments.new')
})

it('should be active when the current path is /appointments/new', () => {
Expand Down
19 changes: 14 additions & 5 deletions src/patients/related-persons/AddRelatedPersonModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelForm
import RelatedPerson from 'model/RelatedPerson'
import PatientRepository from 'clients/db/PatientRepository'
import Patient from 'model/Patient'
import { useSelector } from 'react-redux'
import { RootState } from '../../store'

interface Props {
show: boolean
Expand All @@ -21,6 +23,9 @@ const AddRelatedPersonModal = (props: Props) => {
patientId: '',
type: '',
})
const { patient } = useSelector((state: RootState) => state.patient)

const patientCode = () => patient.code

const onFieldChange = (key: string, value: string) => {
setRelatedPerson({
Expand All @@ -33,8 +38,8 @@ const AddRelatedPersonModal = (props: Props) => {
onFieldChange(fieldName, event.target.value)
}

const onPatientSelect = (patient: Patient[]) => {
setRelatedPerson({ ...relatedPerson, patientId: patient[0].id })
const onPatientSelect = (patients: Patient[]) => {
setRelatedPerson({ ...relatedPerson, patientId: patients[0].id })
}

const body = (
Expand All @@ -50,9 +55,13 @@ const AddRelatedPersonModal = (props: Props) => {
placeholder={t('patient.relatedPerson')}
onChange={onPatientSelect}
onSearch={async (query: string) => PatientRepository.search(query)}
renderMenuItemChildren={(patient: Patient) => (
<div>{`${patient.fullName} (${patient.code})`}</div>
)}
renderMenuItemChildren={(patients: Patient) => {
alti21 marked this conversation as resolved.
Show resolved Hide resolved
if (patientCode() === patients.code) {
alti21 marked this conversation as resolved.
Show resolved Hide resolved
return <div />
}

return <div>{`${patients.fullName} (${patients.code})`}</div>
alti21 marked this conversation as resolved.
Show resolved Hide resolved
}}
/>
</div>
</div>
Expand Down