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

WIP: fix(patients): allow the duplicate patient modal to show properly on … #2785

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2408e32
fix(patients): allow the duplicate patient modal to show properly on …
connordmccandless Oct 20, 2021
e3320ba
Merge branch 'master' into master
Oct 21, 2021
be8d51a
Merge branch 'master' into master
Oct 21, 2021
b141dd8
Merge branch 'master' into master
Oct 21, 2021
5667ce6
Merge branch 'master' into master
Oct 21, 2021
2345bd8
Merge branch 'master' into master
Oct 21, 2021
bd70338
Merge branch 'master' into master
Oct 21, 2021
784ffca
Merge branch 'master' into master
Oct 21, 2021
15e9521
Merge branch 'master' into master
Oct 21, 2021
1894dfe
Merge branch 'master' into master
Oct 21, 2021
86677d6
Merge branch 'master' into master
Oct 21, 2021
9a3af9e
Merge branch 'master' into master
Oct 21, 2021
ebab2fc
Merge branch 'master' into master
Oct 21, 2021
5e4a93f
Merge branch 'master' into master
Oct 21, 2021
8d1cbfa
style(newpatients.tsx): fixed linting issues with NewPatients.tsx
connordmccandless Oct 21, 2021
f8b2d40
Merge branch 'master' into master
Oct 22, 2021
9630eff
Merge branch 'master' into master
Oct 22, 2021
6fa2b7f
Merge branch 'master' into master
Oct 22, 2021
45de204
Merge branch 'master' into master
Oct 22, 2021
3199b20
Merge branch 'master' into master
Oct 22, 2021
14a309e
Merge branch 'master' into master
Oct 22, 2021
7161292
Merge branch 'master' into master
Nov 2, 2021
6ad240b
Merge branch 'master' into master
Nov 2, 2021
66928b0
Merge branch 'master' into master
Nov 2, 2021
2b0378b
Merge branch 'master' into master
Nov 2, 2021
a4212a1
Merge branch 'master' into master
Nov 2, 2021
c8ad8c1
Merge branch 'master' into master
Nov 2, 2021
4393729
Merge branch 'master' into master
Nov 2, 2021
098b0cd
Merge branch 'master' into master
Nov 3, 2021
f1f0ede
Merge branch 'master' into master
Nov 3, 2021
a9bfb5b
Merge branch 'master' into master
Nov 10, 2021
fb6a00e
Merge branch 'master' into master
Nov 10, 2021
901197b
Merge branch 'master' into master
Nov 12, 2021
a790852
Merge branch 'master' into master
Nov 12, 2021
858eacb
Merge branch 'master' into master
Nov 15, 2021
d65f269
Merge branch 'master' into master
Nov 17, 2021
5dd7e62
Merge branch 'master' into master
Nov 17, 2021
f656af5
Merge branch 'master' into master
Nov 17, 2021
6d6f405
Merge branch 'master' into master
Nov 17, 2021
0814a7a
Merge branch 'master' into master
Nov 17, 2021
b67335d
Merge branch 'master' into master
Nov 17, 2021
cff1759
Merge branch 'master' into master
Nov 17, 2021
8af07eb
Merge branch 'master' into master
Nov 18, 2021
06df982
Merge branch 'master' into master
Nov 19, 2021
2d66a70
Merge branch 'master' into master
Nov 19, 2021
db9352a
Merge branch 'master' into master
Nov 19, 2021
174ac3e
Merge branch 'master' into master
Nov 19, 2021
dc5387f
Merge branch 'master' into master
Nov 19, 2021
0db6f71
Merge branch 'master' into master
Nov 21, 2021
565397a
Merge branch 'master' into master
Nov 23, 2021
8c7890d
Merge branch 'master' into master
Nov 23, 2021
6622af6
Merge branch 'master' into master
Nov 23, 2021
b29a09d
Merge branch 'master' into master
Nov 25, 2021
80ae74f
Merge branch 'master' into master
Nov 25, 2021
e9301d5
Merge branch 'master' into master
Nov 29, 2021
dd13990
Merge branch 'master' into master
Dec 4, 2021
6660309
Merge branch 'master' into master
Dec 13, 2021
eafd3f9
Merge branch 'master' into master
Dec 13, 2021
e8d1420
Merge branch 'master' into master
Dec 17, 2021
5051e04
Merge branch 'master' into master
Dec 17, 2021
a8091d9
Merge branch 'master' into master
Dec 17, 2021
75db7b2
Merge branch 'master' into master
Dec 17, 2021
96b594b
Merge branch 'master' into master
Dec 17, 2021
f00bab9
Merge branch 'master' into master
Dec 17, 2021
da051a3
Merge branch 'master' into master
Dec 23, 2021
a52647c
Merge branch 'master' into master
Dec 27, 2021
dee0a12
Merge branch 'master' into master
Dec 27, 2021
7e39a4d
Merge branch 'master' into master
Dec 27, 2021
603a6d8
Merge branch 'master' into master
Dec 28, 2021
7d9aec3
Merge branch 'master' into master
Dec 28, 2021
ffe3a73
Merge branch 'master' into master
Dec 28, 2021
b7cff8a
Merge branch 'master' into master
Dec 28, 2021
dd89413
Merge branch 'master' into master
Dec 28, 2021
45caff0
Merge branch 'master' into master
Jan 2, 2022
c9f0364
Merge branch 'master' into master
Jan 2, 2022
3442d2c
Merge branch 'master' into master
Jan 2, 2022
7a8a918
Merge branch 'master' into master
Jan 4, 2022
202a02f
Merge branch 'master' into master
Jan 4, 2022
da153fc
Merge branch 'master' into master
Feb 12, 2022
4062ac9
Merge branch 'master' into master
Feb 12, 2022
2456d59
Merge branch 'master' into master
Feb 12, 2022
a447136
Merge branch 'master' into master
Feb 12, 2022
d15a7b2
Merge branch 'master' into master
Feb 12, 2022
eab5305
Merge branch 'master' into master
Feb 12, 2022
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
8 changes: 4 additions & 4 deletions src/patients/new/DuplicateNewPatientModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useTranslator from '../../shared/hooks/useTranslator'
import Patient from '../../shared/model/Patient'

interface Props {
duplicatePatient?: Patient
duplicatePatientList?: Patient[]
show: boolean
toggle: () => void
onCloseButtonClick: () => void
Expand All @@ -15,7 +15,7 @@ interface Props {

const DuplicateNewPatientModal = (props: Props) => {
const { t } = useTranslator()
const { duplicatePatient, show, toggle, onCloseButtonClick, onContinueButtonClick } = props
const { duplicatePatientList, show, toggle, onCloseButtonClick, onContinueButtonClick } = props

const body = (
<>
Expand All @@ -27,8 +27,8 @@ const DuplicateNewPatientModal = (props: Props) => {
<div className="row">
<div className="col-md-12">
{t('patients.possibleDuplicatePatient')}
{duplicatePatient !== undefined &&
Object.entries(duplicatePatient).map(([key, patient]) => (
{duplicatePatientList !== undefined &&
Object.entries(duplicatePatientList).map(([key, patient]) => (
<li key={key.toString()}>
<Link to={`/patients/${patient.id}`}>{patient.fullName}</Link>
</li>
Expand Down
17 changes: 10 additions & 7 deletions src/patients/new/NewPatient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import useTranslator from '../../shared/hooks/useTranslator'
import Patient from '../../shared/model/Patient'
import { RootState } from '../../shared/store'
import GeneralInformation from '../GeneralInformation'
import usePatients from '../hooks/usePatients'
import PatientSearchRequest from '../models/PatientSearchRequest'
import { createPatient } from '../patient-slice'
import { isPossibleDuplicatePatient } from '../util/is-possible-duplicate-patient'
import DuplicateNewPatientModal from './DuplicateNewPatientModal'
Expand All @@ -23,10 +25,11 @@ const NewPatient = () => {
const history = useHistory()
const dispatch = useDispatch()
const { createError } = useSelector((state: RootState) => state.patient)
const { patients } = Object(useSelector((state: RootState) => state.patients))
const [searchRequest] = useState<PatientSearchRequest>({ queryString: '' })
const { data } = usePatients(searchRequest)

const [patient, setPatient] = useState({} as Patient)
const [duplicatePatient, setDuplicatePatient] = useState<Patient | undefined>(undefined)
const [duplicatePatientList, setDuplicatePatientList] = useState<Patient[] | undefined>(undefined)
const [showDuplicateNewPatientModal, setShowDuplicateNewPatientModal] = useState<boolean>(false)

const testPatient = {
Expand Down Expand Up @@ -56,16 +59,16 @@ const NewPatient = () => {
}

const onSave = () => {
let duplicatePatients = []
if (patients !== undefined) {
duplicatePatients = patients.filter((existingPatient: any) =>
let duplicatePatients: Patient[] = []
if (data !== undefined && data.patients !== undefined) {
duplicatePatients = data.patients.filter((existingPatient: any) =>
isPossibleDuplicatePatient(patient, existingPatient),
)
}

if (duplicatePatients.length > 0) {
setShowDuplicateNewPatientModal(true)
setDuplicatePatient(duplicatePatients as Patient)
setDuplicatePatientList(duplicatePatients)
} else {
dispatch(createPatient(patient, onSuccessfulSave))
}
Expand Down Expand Up @@ -109,7 +112,7 @@ const NewPatient = () => {
</div>

<DuplicateNewPatientModal
duplicatePatient={duplicatePatient}
duplicatePatientList={duplicatePatientList}
show={showDuplicateNewPatientModal}
toggle={closeDuplicateNewPatientModal}
onContinueButtonClick={createDuplicateNewPatient}
Expand Down