diff --git a/package.json b/package.json
index dcc3afefaf..46c32a9b73 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"private": false,
"license": "MIT",
"dependencies": {
- "@hospitalrun/components": "~1.6.0",
+ "@hospitalrun/components": "~1.14.1",
"@reduxjs/toolkit": "~1.4.0",
"@types/escape-string-regexp": "~2.0.1",
"@types/pouchdb-find": "~6.3.4",
diff --git a/src/components/PageComponent.tsx b/src/components/PageComponent.tsx
index 2c7716a755..1d7654837b 100644
--- a/src/components/PageComponent.tsx
+++ b/src/components/PageComponent.tsx
@@ -18,7 +18,6 @@ const PageComponent = ({
pageNumber,
setPreviousPageRequest,
setNextPageRequest,
- onPageSizeChange,
}: any) => {
const { t } = useTranslation()
@@ -48,13 +47,7 @@ const PageComponent = ({
{t('actions.page')} {pageNumber}
-
+
)
diff --git a/src/components/input/LanguageSelector.tsx b/src/components/input/LanguageSelector.tsx
index 5fc90334b6..c6f55e05d6 100644
--- a/src/components/input/LanguageSelector.tsx
+++ b/src/components/input/LanguageSelector.tsx
@@ -1,32 +1,33 @@
-import _ from 'lodash'
-import React from 'react'
+import { sortBy } from 'lodash'
+import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import i18n, { resources } from '../../i18n'
-import SelectWithLabelFormGroup from './SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from './SelectWithLableFormGroup'
const LanguageSelector = () => {
const { t } = useTranslation()
+ const [selected, setSelected] = useState(i18n.language)
- let languageOptions = Object.keys(resources).map((abbr) => ({
+ let languageOptions: Option[] = Object.keys(resources).map((abbr) => ({
label: resources[abbr].name,
value: abbr,
}))
- languageOptions = _.sortBy(languageOptions, (o) => o.label)
+ languageOptions = sortBy(languageOptions, (o) => o.label)
- const onLanguageChange = (event: React.ChangeEvent) => {
- const selected = event.target.value
- i18n.changeLanguage(selected)
+ const onChange = (value: string) => {
+ i18n.changeLanguage(value)
+ setSelected(value)
}
return (
value === selected)}
+ onChange={(values) => onChange(values[0])}
+ isEditable
/>
)
}
diff --git a/src/components/input/SelectWithLableFormGroup.tsx b/src/components/input/SelectWithLableFormGroup.tsx
index c61cf415c7..e48f249bcd 100644
--- a/src/components/input/SelectWithLableFormGroup.tsx
+++ b/src/components/input/SelectWithLableFormGroup.tsx
@@ -6,28 +6,31 @@ interface Option {
value: string
}
+// todo: add feedback in next round
interface Props {
- value: string
- label?: string
name: string
+ label?: string
isRequired?: boolean
- isEditable?: boolean
options: Option[]
- onChange?: (event: React.ChangeEvent) => void
- feedback?: string
+ defaultSelected?: Option[]
+ onChange?: (values: string[]) => void
+ placeholder: string
+ multiple?: boolean
+ isEditable?: boolean
isInvalid?: boolean
}
const SelectWithLabelFormGroup = (props: Props) => {
const {
- value,
- label,
name,
- isEditable,
+ label,
+ isRequired,
options,
+ defaultSelected,
onChange,
- isRequired,
- feedback,
+ placeholder,
+ multiple,
+ isEditable,
isInvalid,
} = props
const id = `${name}Select`
@@ -35,27 +38,22 @@ const SelectWithLabelFormGroup = (props: Props) => {
{label && }
+ />
)
}
SelectWithLabelFormGroup.defaultProps = {
- value: '',
+ placeholder: '-- Choose --',
}
export default SelectWithLabelFormGroup
+export type { Option }
diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx
index 4cb0213561..4fe6d09a5f 100644
--- a/src/incidents/list/ViewIncidents.tsx
+++ b/src/incidents/list/ViewIncidents.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'
-import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup'
import Incident from '../../model/Incident'
import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider'
import useTitle from '../../page-header/useTitle'
@@ -48,11 +48,7 @@ const ViewIncidents = () => {
history.push(`incidents/${incident.id}`)
}
- const onFilterChange = (event: React.ChangeEvent) => {
- setSearchFilter(event.target.value as IncidentFilter)
- }
-
- const filterOptions = Object.values(IncidentFilter).map((filter) => ({
+ const filterOptions: Option[] = Object.values(IncidentFilter).map((filter) => ({
label: t(`incidents.status.${filter}`),
value: `${filter}`,
}))
@@ -63,11 +59,11 @@ const ViewIncidents = () => {
value === searchFilter)}
+ onChange={(values) => setSearchFilter(values[0] as IncidentFilter)}
+ isEditable
/>
@@ -86,9 +82,15 @@ const ViewIncidents = () => {
{incidents.map((incident: Incident) => (
onTableRowClick(incident)} key={incident.id}>
{incident.code} |
- {format(new Date(incident.date), 'yyyy-MM-dd hh:mm a')} |
+
+ {incident.date ? format(new Date(incident.date), 'yyyy-MM-dd hh:mm a') : ''}
+ |
{incident.reportedBy} |
- {format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')} |
+
+ {incident.reportedOn
+ ? format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')
+ : ''}
+ |
{incident.status} |
))}
diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx
index 8587ae4739..c8a724d240 100644
--- a/src/labs/ViewLabs.tsx
+++ b/src/labs/ViewLabs.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { useSelector, useDispatch } from 'react-redux'
import { useHistory } from 'react-router-dom'
-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'
import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'
import useDebounce from '../hooks/debounce'
import Lab from '../model/Lab'
@@ -15,7 +15,7 @@ import useTitle from '../page-header/useTitle'
import { RootState } from '../store'
import { searchLabs } from './labs-slice'
-type filter = 'requested' | 'completed' | 'canceled' | 'all'
+type LabFilter = 'requested' | 'completed' | 'canceled' | 'all'
const ViewLabs = () => {
const { t } = useTranslation()
@@ -26,7 +26,7 @@ const ViewLabs = () => {
const { permissions } = useSelector((state: RootState) => state.user)
const dispatch = useDispatch()
const { labs, isLoading } = useSelector((state: RootState) => state.labs)
- const [searchFilter, setSearchFilter] = useState('all')
+ const [searchFilter, setSearchFilter] = useState('all')
const [searchText, setSearchText] = useState('')
const debouncedSearchText = useDebounce(searchText, 500)
@@ -50,15 +50,6 @@ const ViewLabs = () => {
return buttons
}, [permissions, history, t])
- const setFilter = (filter: string) =>
- filter === 'requested'
- ? 'requested'
- : filter === 'completed'
- ? 'completed'
- : filter === 'canceled'
- ? 'canceled'
- : 'all'
-
useEffect(() => {
dispatch(searchLabs(debouncedSearchText, searchFilter))
}, [dispatch, debouncedSearchText, searchFilter])
@@ -76,21 +67,24 @@ const ViewLabs = () => {
history.push(`/labs/${lab.id}`)
}
- const onSelectChange = (event: React.ChangeEvent) => {
- setSearchFilter(setFilter(event.target.value))
- }
-
const onSearchBoxChange = (event: React.ChangeEvent) => {
setSearchText(event.target.value)
}
+ const filterOptions: Option[] = [
+ { label: t('labs.status.requested'), value: 'requested' },
+ { label: t('labs.status.completed'), value: 'completed' },
+ { label: t('labs.status.canceled'), value: 'canceled' },
+ { label: t('labs.filter.all'), value: 'all' },
+ ]
+
const listBody = (
{labs.map((lab) => (
onTableRowClick(lab)} key={lab.id}>
{lab.code} |
{lab.type} |
- {format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')} |
+ {lab.requestedOn ? format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a') : ''} |
{lab.status} |
))}
@@ -103,18 +97,11 @@ const ViewLabs = () => {
value === searchFilter)}
+ onChange={(values) => setSearchFilter(values[0] as LabFilter)}
isEditable
- options={[
- { label: t('labs.status.requested'), value: 'requested' },
- { label: t('labs.status.completed'), value: 'completed' },
- { label: t('labs.status.canceled'), value: 'canceled' },
- { label: t('labs.filter.all'), value: 'all' },
- ]}
- onChange={(event: React.ChangeEvent) => {
- onSelectChange(event)
- }}
/>
diff --git a/src/patients/ContactInfo.tsx b/src/patients/ContactInfo.tsx
index d6d491352c..7d3a9be3de 100644
--- a/src/patients/ContactInfo.tsx
+++ b/src/patients/ContactInfo.tsx
@@ -2,7 +2,7 @@ import { Spinner, Row, Column, Icon } from '@hospitalrun/components'
import React, { useEffect, ReactElement } from 'react'
import { useTranslation } from 'react-i18next'
-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'
import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup'
import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'
import { ContactInfoPiece } from '../model/ContactInformation'
@@ -30,7 +30,7 @@ const ContactInfo = (props: Props): ReactElement => {
}
}, [data, onChange])
- const typeOptions = Object.values(ContactInfoTypes).map((value) => ({
+ const typeOptions: Option[] = Object.values(ContactInfoTypes).map((value) => ({
label: t(`patient.contactInfoType.options.${value}`),
value: `${value}`,
}))
@@ -53,9 +53,8 @@ const ContactInfo = (props: Props): ReactElement => {
}
const Component = componentList[component]
- const onTypeChange = (event: React.ChangeEvent
, index: number) => {
+ const onTypeChange = (newType: string, index: number) => {
if (onChange) {
- const newType = event.currentTarget.value
const currentContact = { ...data[index], type: newType }
const newContacts = [...data]
newContacts.splice(index, 1, currentContact)
@@ -83,10 +82,10 @@ const ContactInfo = (props: Props): ReactElement => {
onTypeChange(event, i)}
+ defaultSelected={typeOptions.filter(({ value }) => value === entry.type)}
+ onChange={(values) => onTypeChange(values[0], i)}
+ isEditable={isEditable}
/>
diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx
index eca1ea70a2..decafea491 100644
--- a/src/patients/GeneralInformation.tsx
+++ b/src/patients/GeneralInformation.tsx
@@ -4,7 +4,7 @@ import React, { ReactElement } from 'react'
import { useTranslation } from 'react-i18next'
import DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup'
-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'
import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'
import { ContactInfoPiece } from '../model/ContactInformation'
import Patient from '../model/Patient'
@@ -59,6 +59,18 @@ const GeneralInformation = (props: Props): ReactElement => {
onFieldChange('isApproximateDateOfBirth', checked)
}
+ const sexOptions: Option[] = [
+ { label: t('sex.male'), value: 'male' },
+ { label: t('sex.female'), value: 'female' },
+ { label: t('sex.other'), value: 'other' },
+ { label: t('sex.unknown'), value: 'unknown' },
+ ]
+
+ const typeOptions: Option[] = [
+ { label: t('patient.types.charity'), value: 'charity' },
+ { label: t('patient.types.private'), value: 'private' },
+ ]
+
return (
@@ -115,28 +127,20 @@ const GeneralInformation = (props: Props): ReactElement => {
value === patient.sex)}
+ onChange={(values) => onFieldChange('sex', values[0])}
isEditable={isEditable}
- options={[
- { label: t('sex.male'), value: 'male' },
- { label: t('sex.female'), value: 'female' },
- { label: t('sex.other'), value: 'other' },
- { label: t('sex.unknown'), value: 'unknown' },
- ]}
- onChange={(event) => onFieldChange('sex', event.currentTarget.value)}
/>
value === patient.type)}
+ onChange={(values) => onFieldChange('type', values[0])}
isEditable={isEditable}
- options={[
- { label: t('patient.types.charity'), value: 'charity' },
- { label: t('patient.types.private'), value: 'private' },
- ]}
- onChange={(event) => onFieldChange('type', event.currentTarget.value)}
/>
diff --git a/src/patients/care-plans/CarePlanForm.tsx b/src/patients/care-plans/CarePlanForm.tsx
index 6a5a24e7d9..be517b45c7 100644
--- a/src/patients/care-plans/CarePlanForm.tsx
+++ b/src/patients/care-plans/CarePlanForm.tsx
@@ -1,9 +1,9 @@
import { Alert, Column, Row } from '@hospitalrun/components'
-import React from 'react'
+import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup'
-import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'
+import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup'
import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup'
import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup'
import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../model/CarePlan'
@@ -32,6 +32,10 @@ const CarePlanForm = (props: Props) => {
const { t } = useTranslation()
const { patient, carePlan, carePlanError, disabled, onChange } = props
+ const [condition, setCondition] = useState(carePlan.diagnosisId)
+ const [status, setStatus] = useState(carePlan.status)
+ const [intent, setIntent] = useState(carePlan.intent)
+
const onFieldChange = (name: string, value: string | CarePlanStatus | CarePlanIntent) => {
if (onChange) {
const newCarePlan = {
@@ -42,6 +46,13 @@ const CarePlanForm = (props: Props) => {
}
}
+ const conditionOptions: Option[] =
+ patient.diagnoses?.map((d) => ({ label: d.name, value: d.id })) || []
+
+ const statusOptions: Option[] = Object.values(CarePlanStatus).map((v) => ({ label: v, value: v }))
+
+ const intentOptions: Option[] = Object.values(CarePlanIntent).map((v) => ({ label: v, value: v }))
+
return (