From 73677e2df83ef0032b9c3f1fe4a9da94d87b1e5b Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Wed, 4 Mar 2020 21:27:05 -0600 Subject: [PATCH] feat(patients): fixes notifactions for updating/creating patient --- .../patients/allergies/Allergies.test.tsx | 28 +++++++++ .../patients/diagnoses/Diagnoses.test.tsx | 31 ++++++++++ .../patients/new/NewPatient.test.tsx | 33 +++++++++++ src/__tests__/patients/patient-slice.test.ts | 58 +++++-------------- .../related-persons/RelatedPersons.test.tsx | 21 +++++++ src/locales/en-US/translation.json | 10 ++-- src/patients/allergies/Allergies.tsx | 10 ++-- src/patients/diagnoses/Diagnoses.tsx | 10 ++-- src/patients/edit/EditPatient.tsx | 9 ++- src/patients/new/NewPatient.tsx | 9 ++- src/patients/patient-slice.ts | 32 +++++----- .../related-persons/RelatedPersonTab.tsx | 8 ++- 12 files changed, 183 insertions(+), 76 deletions(-) diff --git a/src/__tests__/patients/allergies/Allergies.test.tsx b/src/__tests__/patients/allergies/Allergies.test.tsx index f3ed5e39e0..2bed7d2705 100644 --- a/src/__tests__/patients/allergies/Allergies.test.tsx +++ b/src/__tests__/patients/allergies/Allergies.test.tsx @@ -10,6 +10,7 @@ import { Router } from 'react-router' import { Provider } from 'react-redux' import Patient from 'model/Patient' import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components' +import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import { mocked } from 'ts-jest/utils' import PatientRepository from 'clients/db/PatientRepository' @@ -104,6 +105,33 @@ describe('Allergies', () => { patientSlice.updatePatientSuccess(expectedUpdatedPatient), ) }) + + it('should display a success message after the allergy is successfully added', async () => { + jest.spyOn(components, 'Toast') + const mockedComponents = mocked(components, true) + + const expectedAllergy = { name: 'name' } as Allergy + const expectedUpdatedPatient = { + ...expectedPatient, + allergies: [...(expectedPatient.allergies as any), expectedAllergy], + } as Patient + + const mockedPatientRepository = mocked(PatientRepository, true) + mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient) + + const wrapper = setup() + + await act(async () => { + const modal = wrapper.find(NewAllergyModal) + await modal.prop('onSave')(expectedAllergy) + }) + + expect(mockedComponents.Toast).toHaveBeenCalledWith( + 'success', + 'Success!', + 'patient.allergies.successfullyAdded', + ) + }) }) describe('allergy list', () => { diff --git a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx index 5660325a5a..c31af99c86 100644 --- a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx +++ b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx @@ -11,6 +11,7 @@ import { Router } from 'react-router' import { Provider } from 'react-redux' import Diagnoses from 'patients/diagnoses/Diagnoses' import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components' +import * as components from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import { mocked } from 'ts-jest/utils' import PatientRepository from 'clients/db/PatientRepository' @@ -102,6 +103,36 @@ describe('Diagnoses', () => { patientSlice.updatePatientSuccess(expectedUpdatedPatient), ) }) + + it('should display a success message when successfully added', async () => { + jest.spyOn(components, 'Toast') + const mockedComponents = mocked(components, true) + + const expectedDiagnosis = { + name: 'name', + diagnosisDate: new Date().toISOString(), + } as Diagnosis + const expectedUpdatedPatient = { + ...expectedPatient, + diagnoses: [...(expectedPatient.diagnoses as any), expectedDiagnosis], + } as Patient + + const mockedPatientRepository = mocked(PatientRepository, true) + mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient) + + const wrapper = setup() + + await act(async () => { + const modal = wrapper.find(AddDiagnosisModal) + await modal.prop('onSave')(expectedDiagnosis) + }) + + expect(mockedComponents.Toast).toHaveBeenCalledWith( + 'success', + 'Success!', + 'patient.diagnoses.successfullyAdded', + ) + }) }) describe('diagnoses list', () => { diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index e1af5011f4..bc9ee4b051 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -9,6 +9,7 @@ import { act } from 'react-dom/test-utils' import { Button } from '@hospitalrun/components' import configureMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' +import * as components from '@hospitalrun/components' import NewPatient from '../../../patients/new/NewPatient' import GeneralInformation from '../../../patients/GeneralInformation' @@ -126,6 +127,38 @@ describe('New Patient', () => { expect(store.getActions()).toContainEqual(patientSlice.createPatientSuccess()) }) + it('should navigate to /patients/:id and display a message after a new patient is successfully created', async () => { + jest.spyOn(components, 'Toast') + const mockedComponents = mocked(components, true) + let wrapper: any + await act(async () => { + wrapper = await setup() + }) + + const generalInformationForm = wrapper.find(GeneralInformation) + + act(() => { + generalInformationForm.prop('onFieldChange')('givenName', 'first') + }) + + wrapper.update() + + const saveButton = wrapper.find(Button).at(0) + const onClick = saveButton.prop('onClick') as any + expect(saveButton.text().trim()).toEqual('actions.save') + + await act(async () => { + await onClick() + }) + + expect(history.location.pathname).toEqual(`/patients/${patient.id}`) + expect(mockedComponents.Toast).toHaveBeenCalledWith( + 'success', + 'Success!', + `patients.successfullyCreated ${patient.fullName}`, + ) + }) + it('should navigate to /patients when cancel is clicked', async () => { let wrapper: any await act(async () => { diff --git a/src/__tests__/patients/patient-slice.test.ts b/src/__tests__/patients/patient-slice.test.ts index 461b8001fd..01f26c04fb 100644 --- a/src/__tests__/patients/patient-slice.test.ts +++ b/src/__tests__/patients/patient-slice.test.ts @@ -1,7 +1,6 @@ import '../../__mocks__/matchMediaMock' import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import { createMemoryHistory } from 'history' import * as components from '@hospitalrun/components' import patient, { @@ -113,7 +112,7 @@ describe('patients slice', () => { id: 'sliceId1', } as Patient - await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await createPatient(expectedPatient)(dispatch, getState, null) expect(dispatch).toHaveBeenCalledWith({ type: createPatientStart.type }) }) @@ -127,7 +126,7 @@ describe('patients slice', () => { id: 'sliceId2', } as Patient - await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await createPatient(expectedPatient)(dispatch, getState, null) expect(PatientRepository.save).toHaveBeenCalledWith(expectedPatient) }) @@ -141,29 +140,13 @@ describe('patients slice', () => { id: 'slideId3', } as Patient - await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await createPatient(expectedPatient)(dispatch, getState, null) expect(dispatch).toHaveBeenCalledWith({ type: createPatientSuccess.type }) }) - it('should navigate to the /patients/:id where id is the new patient id', async () => { - const expectedPatientId = 'sliceId4' - jest.spyOn(PatientRepository, 'save') - const mockedPatientRepository = mocked(PatientRepository, true) - mockedPatientRepository.save.mockResolvedValue({ id: expectedPatientId } as Patient) - const history = createMemoryHistory() - - const dispatch = jest.fn() - const getState = jest.fn() - const expectedPatient = {} as Patient - - await createPatient(expectedPatient, history)(dispatch, getState, null) - - expect(history.entries[1].pathname).toEqual(`/patients/${expectedPatientId}`) - }) - - it('should call the Toaster function with the correct data', async () => { - jest.spyOn(components, 'Toast') + it('should call the on success function', async () => { + const onSuccessSpy = jest.fn() const expectedPatientId = 'sliceId5' const expectedFullName = 'John Doe II' const expectedPatient = { @@ -173,18 +156,13 @@ describe('patients slice', () => { jest.spyOn(PatientRepository, 'save') const mockedPatientRepository = mocked(PatientRepository, true) mockedPatientRepository.save.mockResolvedValue(expectedPatient) - const mockedComponents = mocked(components, true) - const history = createMemoryHistory() const dispatch = jest.fn() const getState = jest.fn() - await createPatient(expectedPatient, history)(dispatch, getState, null) + await createPatient(expectedPatient, onSuccessSpy)(dispatch, getState, null) - expect(mockedComponents.Toast).toHaveBeenCalledWith( - 'success', - 'Success!', - `patients.successfullyCreated ${expectedFullName}`, - ) + expect(onSuccessSpy).toHaveBeenCalled() + expect(onSuccessSpy).toHaveBeenCalledWith(expectedPatient) }) }) @@ -248,7 +226,7 @@ describe('patients slice', () => { const mockedPatientRepository = mocked(PatientRepository, true) mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient) - await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await updatePatient(expectedPatient)(dispatch, getState, null) expect(dispatch).toHaveBeenCalledWith({ type: updatePatientStart.type }) }) @@ -262,7 +240,7 @@ describe('patients slice', () => { const mockedPatientRepository = mocked(PatientRepository, true) mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient) - await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await updatePatient(expectedPatient)(dispatch, getState, null) expect(PatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedPatient) }) @@ -276,7 +254,7 @@ describe('patients slice', () => { const mockedPatientRepository = mocked(PatientRepository, true) mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient) - await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null) + await updatePatient(expectedPatient)(dispatch, getState, null) expect(dispatch).toHaveBeenCalledWith({ type: updatePatientSuccess.type, @@ -284,7 +262,8 @@ describe('patients slice', () => { }) }) - it('should call the Toaster function with the correct data', async () => { + it('should call the onSuccess function', async () => { + const onSuccessSpy = jest.fn() jest.spyOn(components, 'Toast') const expectedPatientId = 'sliceId11' const fullName = 'John Doe II' @@ -294,18 +273,13 @@ describe('patients slice', () => { } as Patient const mockedPatientRepository = mocked(PatientRepository, true) mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient) - const mockedComponents = mocked(components, true) - const history = createMemoryHistory() const dispatch = jest.fn() const getState = jest.fn() - await updatePatient(expectedPatient, history)(dispatch, getState, null) + await updatePatient(expectedPatient, onSuccessSpy)(dispatch, getState, null) - expect(mockedComponents.Toast).toHaveBeenCalledWith( - 'success', - 'Success!', - `patients.successfullyUpdated ${fullName}`, - ) + expect(onSuccessSpy).toHaveBeenCalled() + expect(onSuccessSpy).toHaveBeenCalledWith(expectedPatient) }) }) }) diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx index 5d2efd819e..97b3aba0db 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx @@ -5,6 +5,8 @@ import { createMemoryHistory } from 'history' import { mount } from 'enzyme' import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab' import { Button, List, ListItem, Alert } from '@hospitalrun/components' +import * as components from '@hospitalrun/components' + import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal' import { act } from '@testing-library/react' import PatientRepository from 'clients/db/PatientRepository' @@ -26,8 +28,12 @@ describe('Related Persons Tab', () => { describe('Add New Related Person', () => { let patient: any let user: any + jest.spyOn(components, 'Toast') + let mockedComponents = mocked(components, true) beforeEach(() => { + jest.resetAllMocks() + mockedComponents = mocked(components, true) history = createMemoryHistory() patient = { @@ -150,6 +156,21 @@ describe('Related Persons Tab', () => { const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) expect(newRelatedPersonModal.prop('show')).toBeFalsy() }) + + it('should display a success message when the new related person is added', async () => { + await act(async () => { + const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const onSave = newRelatedPersonModal.prop('onSave') as any + await onSave({ patientId: 'testMessage', type: 'type' }) + }) + wrapper.update() + + expect(mockedComponents.Toast).toHaveBeenCalledWith( + 'success', + 'Success!', + 'patient.relatedPersons.successfullyAdded', + ) + }) }) describe('List', () => { diff --git a/src/locales/en-US/translation.json b/src/locales/en-US/translation.json index 60c3bc3513..2fdb15464a 100644 --- a/src/locales/en-US/translation.json +++ b/src/locales/en-US/translation.json @@ -44,7 +44,8 @@ "label": "Related Persons", "new": "New Related Person", "relationshipType": "Relationship Type", - "addRelatedPersonAbove": "Add a related person using the button above." + "addRelatedPersonAbove": "Add a related person using the button above.", + "successfullyAdded": "Successfully added a new related person!" }, "types": { "charity": "Charity", @@ -62,7 +63,8 @@ "warning": { "noAllergies": "No Allergies" }, - "addAllergyAbove": "Add an allergy using the button above." + "addAllergyAbove": "Add an allergy using the button above.", + "successfullyAdded": "Successfully added a new allergy!" }, "diagnoses": { "label": "Diagnoses", @@ -76,8 +78,8 @@ "nameRequired": "Diagnosis Name is required.", "dateRequired": "Diagnosis Date is required." }, - "addDiagnosisAbove": "Add a diagnosis using the button above." - + "addDiagnosisAbove": "Add a diagnosis using the button above.", + "successfullyAdded": "Successfully added a new diagnosis!" } }, "sex": { diff --git a/src/patients/allergies/Allergies.tsx b/src/patients/allergies/Allergies.tsx index 2f800fabbe..1857592eaf 100644 --- a/src/patients/allergies/Allergies.tsx +++ b/src/patients/allergies/Allergies.tsx @@ -1,13 +1,12 @@ import React, { useState } from 'react' import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' import Patient from 'model/Patient' -import { Button, List, ListItem, Alert } from '@hospitalrun/components' +import { Button, List, ListItem, Alert, Toast } from '@hospitalrun/components' import { useSelector, useDispatch } from 'react-redux' import { RootState } from 'store' import Permissions from 'model/Permissions' import { useTranslation } from 'react-i18next' import Allergy from 'model/Allergy' -import { useHistory } from 'react-router' import { updatePatient } from 'patients/patient-slice' import { getTimestampId } from 'patients/util/timestamp-id-generator' import NewAllergyModal from './NewAllergyModal' @@ -18,7 +17,6 @@ interface AllergiesProps { const Allergies = (props: AllergiesProps) => { const { t } = useTranslation() - const history = useHistory() const dispatch = useDispatch() const { patient } = props const { permissions } = useSelector((state: RootState) => state.user) @@ -32,6 +30,10 @@ const Allergies = (props: AllergiesProps) => { ] useAddBreadcrumbs(breadcrumbs) + const onAddAllergySuccess = () => { + Toast('success', t('Success!'), `${t('patient.allergies.successfullyAdded')}`) + } + const onAddAllergy = (allergy: Allergy) => { allergy.id = getTimestampId() const allergies = [] @@ -41,7 +43,7 @@ const Allergies = (props: AllergiesProps) => { allergies.push(allergy) const patientToUpdate = { ...patient, allergies } - dispatch(updatePatient(patientToUpdate, history)) + dispatch(updatePatient(patientToUpdate, onAddAllergySuccess)) } return ( diff --git a/src/patients/diagnoses/Diagnoses.tsx b/src/patients/diagnoses/Diagnoses.tsx index 6b117f794c..ae520fff89 100644 --- a/src/patients/diagnoses/Diagnoses.tsx +++ b/src/patients/diagnoses/Diagnoses.tsx @@ -4,12 +4,11 @@ import Patient from 'model/Patient' import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' import { useSelector, useDispatch } from 'react-redux' import Permissions from 'model/Permissions' -import { Button, List, ListItem, Alert } from '@hospitalrun/components' +import { Button, List, ListItem, Alert, Toast } from '@hospitalrun/components' import { useTranslation } from 'react-i18next' import Diagnosis from 'model/Diagnosis' import { getTimestampId } from 'patients/util/timestamp-id-generator' import { updatePatient } from 'patients/patient-slice' -import { useHistory } from 'react-router' import AddDiagnosisModal from './AddDiagnosisModal' interface Props { @@ -20,7 +19,6 @@ const Diagnoses = (props: Props) => { const { patient } = props const [showDiagnosisModal, setShowDiagnosisModal] = useState(false) - const history = useHistory() const dispatch = useDispatch() const { t } = useTranslation() const { permissions } = useSelector((state: RootState) => state.user) @@ -37,6 +35,10 @@ const Diagnoses = (props: Props) => { setShowDiagnosisModal(false) } + const onAddDiagnosisSuccess = () => { + Toast('success', t('Success!'), t('patient.diagnoses.successfullyAdded')) + } + const onDiagnosisSave = (diagnosis: Diagnosis) => { diagnosis.id = getTimestampId() const diagnoses = [] @@ -45,7 +47,7 @@ const Diagnoses = (props: Props) => { } diagnoses.push(diagnosis) const patientToUpdate = { ...patient, diagnoses } - dispatch(updatePatient(patientToUpdate, history)) + dispatch(updatePatient(patientToUpdate, onAddDiagnosisSuccess)) setShowDiagnosisModal(false) } diff --git a/src/patients/edit/EditPatient.tsx b/src/patients/edit/EditPatient.tsx index 5dc801c3f5..3b8778db89 100644 --- a/src/patients/edit/EditPatient.tsx +++ b/src/patients/edit/EditPatient.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react' import { useHistory, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { Spinner, Button } from '@hospitalrun/components' +import { Spinner, Button, Toast } from '@hospitalrun/components' import GeneralInformation from '../GeneralInformation' import useTitle from '../../page-header/useTitle' @@ -57,6 +57,11 @@ const EditPatient = () => { history.push(`/patients/${patient.id}`) } + const onSuccessfulSave = (updatedPatient: Patient) => { + history.push(`/patients/${updatedPatient.id}`) + Toast('success', t('Success!'), `${t('patients.successfullyUpdated')} ${patient.fullName}`) + } + const onSave = () => { if (!patient.givenName) { setErrorMessage(t('patient.errors.patientGivenNameRequired')) @@ -67,7 +72,7 @@ const EditPatient = () => { ...patient, fullName: getPatientName(patient.givenName, patient.familyName, patient.suffix), }, - history, + onSuccessfulSave, ), ) } diff --git a/src/patients/new/NewPatient.tsx b/src/patients/new/NewPatient.tsx index 527d3f764d..bde2f46f8a 100644 --- a/src/patients/new/NewPatient.tsx +++ b/src/patients/new/NewPatient.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react' import { useHistory } from 'react-router' import { useTranslation } from 'react-i18next' import { useDispatch } from 'react-redux' -import { Button } from '@hospitalrun/components' +import { Button, Toast } from '@hospitalrun/components' import GeneralInformation from '../GeneralInformation' import useTitle from '../../page-header/useTitle' @@ -31,6 +31,11 @@ const NewPatient = () => { history.push('/patients') } + const onSuccessfulSave = (newPatient: Patient) => { + history.push(`/patients/${newPatient.id}`) + Toast('success', t('Success!'), `${t('patients.successfullyCreated')} ${newPatient.fullName}`) + } + const onSave = () => { if (!patient.givenName) { setErrorMessage(t('patient.errors.patientGivenNameRequired')) @@ -41,7 +46,7 @@ const NewPatient = () => { ...patient, fullName: getPatientName(patient.givenName, patient.familyName, patient.suffix), }, - history, + onSuccessfulSave, ), ) } diff --git a/src/patients/patient-slice.ts b/src/patients/patient-slice.ts index 5d6519f859..26a6ce6456 100644 --- a/src/patients/patient-slice.ts +++ b/src/patients/patient-slice.ts @@ -1,9 +1,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { Toast } from '@hospitalrun/components' import Patient from '../model/Patient' import PatientRepository from '../clients/db/PatientRepository' import { AppThunk } from '../store' -import il8n from '../i18n' interface PatientState { isLoading: boolean @@ -59,28 +57,30 @@ export const fetchPatient = (id: string): AppThunk => async (dispatch) => { dispatch(fetchPatientSuccess(patient)) } -export const createPatient = (patient: Patient, history: any): AppThunk => async (dispatch) => { +export const createPatient = ( + patient: Patient, + onSuccess?: (patient: Patient) => void, +): AppThunk => async (dispatch) => { dispatch(createPatientStart()) const newPatient = await PatientRepository.save(patient) dispatch(createPatientSuccess()) - history.push(`/patients/${newPatient.id}`) - Toast( - 'success', - il8n.t('Success!'), - `${il8n.t('patients.successfullyCreated')} ${patient.fullName}`, - ) + + if (onSuccess) { + onSuccess(newPatient) + } } -export const updatePatient = (patient: Patient, history: any): AppThunk => async (dispatch) => { +export const updatePatient = ( + patient: Patient, + onSuccess?: (patient: Patient) => void, +): AppThunk => async (dispatch) => { dispatch(updatePatientStart()) const updatedPatient = await PatientRepository.saveOrUpdate(patient) dispatch(updatePatientSuccess(updatedPatient)) - history.push(`/patients/${updatedPatient.id}`) - Toast( - 'success', - il8n.t('Success!'), - `${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`, - ) + + if (onSuccess) { + onSuccess(updatedPatient) + } } export default patientSlice.reducer diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index f3451dae19..6132516b64 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react' -import { Button, Panel, List, ListItem, Alert, Spinner } from '@hospitalrun/components' +import { Button, Panel, List, ListItem, Alert, Spinner, Toast } from '@hospitalrun/components' import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal' import RelatedPerson from 'model/RelatedPerson' import { useTranslation } from 'react-i18next' @@ -66,6 +66,10 @@ const RelatedPersonTab = (props: Props) => { setShowRelatedPersonModal(false) } + const onAddRelatedPersonSuccess = () => { + Toast('success', t('Success!'), t('patient.relatedPersons.successfullyAdded')) + } + const onRelatedPersonSave = (relatedPerson: RelatedPerson) => { const newRelatedPersons: RelatedPerson[] = [] @@ -80,7 +84,7 @@ const RelatedPersonTab = (props: Props) => { relatedPersons: newRelatedPersons, } - dispatch(updatePatient(patientToUpdate, history)) + dispatch(updatePatient(patientToUpdate, onAddRelatedPersonSuccess)) closeNewRelatedPersonModal() }