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

Commit

Permalink
fix(patient): add DOB to add related person search
Browse files Browse the repository at this point in the history
Co-authored-by: Matteo Vivona <[email protected]>
  • Loading branch information
nischayv and matteovivona authored Jun 27, 2020
1 parent 74c8380 commit c1ffd82
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/patients/related-persons/AddRelatedPersonModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Modal, Alert, Typeahead, Label } from '@hospitalrun/components'
import format from 'date-fns/format'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
Expand Down Expand Up @@ -42,6 +43,11 @@ const AddRelatedPersonModal = (props: Props) => {
setRelatedPerson({ ...relatedPerson, patientId: p[0].id })
}

const onSearch = async (query: string) => {
const patients: Patient[] = await PatientRepository.search(query)
return patients.filter((p: Patient) => p.id !== patient.id)
}

const body = (
<form>
{relatedPersonError?.message && (
Expand All @@ -57,14 +63,12 @@ const AddRelatedPersonModal = (props: Props) => {
placeholder={t('patient.relatedPerson')}
onChange={onPatientSelect}
isInvalid={!!relatedPersonError?.relatedPerson}
onSearch={async (query: string) => PatientRepository.search(query)}
renderMenuItemChildren={(p: Patient) => {
if (patient.id === p.id) {
return <div />
}

return <div>{`${p.fullName} (${p.code})`}</div>
}}
onSearch={onSearch}
renderMenuItemChildren={(p: Patient) => (
<div>
{`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`}
</div>
)}
/>
{relatedPersonError?.relatedPerson && (
<div className="text-left ml-3 mt-1 text-small text-danger invalid-feedback d-block related-person-feedback">
Expand Down

1 comment on commit c1ffd82

@vercel
Copy link

@vercel vercel bot commented on c1ffd82 Jun 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.