This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(imaging): add ability to search imaging requests #2522
Open
FanciestW
wants to merge
12
commits into
HospitalRun:master
Choose a base branch
from
FanciestW:feature-2491-imaging-search-filter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8bc3f78
feat: filter and search field added
FanciestW 6e9b6fb
Merge branch 'master' into feature-2491-imaging-search-filter
FanciestW 7168f5e
feat: added filter and search functionality
FanciestW dab885d
Merge branch 'master' into feature-2491-imaging-search-filter
FanciestW 04bd607
Merge branch 'master' into feature-2491-imaging-search-filter
matteovivona e8bd29f
feat: added test for component rendering
FanciestW 4c50d0b
Merge branch 'feature-2491-imaging-search-filter' of https://github.c…
FanciestW 589b376
feat: added tests for imaging filter and search fields
FanciestW 251b4e4
Merge branch 'master' into feature-2491-imaging-search-filter
matteovivona d9f3d22
Merge branch 'master' into feature-2491-imaging-search-filter
FanciestW 5484ce5
Merge branch 'feature-2491-imaging-search-filter' of https://github.c…
FanciestW 8229b83
Merge branch 'master' into feature-2491-imaging-search-filter
FanciestW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export type ImagingFilter = 'completed' | 'requested' | 'canceled' | 'all' | ||
|
||
export default interface ImagingSearchRequest { | ||
status: 'completed' | 'requested' | 'canceled' | 'all' | ||
status: ImagingFilter | ||
text: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { Button, Container, Row } from '@hospitalrun/components' | ||
import { Button, Container, Row, Column } from '@hospitalrun/components' | ||
import React, { useState, useEffect, useCallback } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { useHistory } from 'react-router-dom' | ||
|
||
import { useButtonToolbarSetter } from '../../page-header/button-toolbar/ButtonBarProvider' | ||
import { useUpdateTitle } from '../../page-header/title/TitleContext' | ||
import SelectWithLabelFormGroup, { | ||
Option, | ||
} from '../../shared/components/input/SelectWithLabelFormGroup' | ||
import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' | ||
import useDebounce from '../../shared/hooks/useDebounce' | ||
import useTranslator from '../../shared/hooks/useTranslator' | ||
import Permissions from '../../shared/model/Permissions' | ||
import { RootState } from '../../shared/store' | ||
import ImagingSearchRequest from '../model/ImagingSearchRequest' | ||
import ImagingSearchRequest, { ImagingFilter } from '../model/ImagingSearchRequest' | ||
import ImagingRequestTable from './ImagingRequestTable' | ||
|
||
const ViewImagings = () => { | ||
const [searchFilter, setSearchFilter] = useState<ImagingFilter>('all') | ||
const [searchText, setSearchText] = useState<string>('') | ||
const debouncedSearchText = useDebounce(searchText, 500) | ||
const { t } = useTranslator() | ||
const { permissions } = useSelector((state: RootState) => state.user) | ||
const history = useHistory() | ||
|
@@ -20,9 +28,17 @@ const ViewImagings = () => { | |
useEffect(() => { | ||
updateTitle(t('imagings.label')) | ||
}) | ||
|
||
const filterOptions: Option[] = [ | ||
{ label: t('imagings.status.requested'), value: 'requested' }, | ||
{ label: t('imagings.status.completed'), value: 'completed' }, | ||
{ label: t('imagings.status.canceled'), value: 'canceled' }, | ||
{ label: t('imagings.filter.all'), value: 'all' }, | ||
] | ||
|
||
const [searchRequest, setSearchRequest] = useState<ImagingSearchRequest>({ | ||
status: 'all', | ||
text: '', | ||
status: searchFilter, | ||
text: debouncedSearchText, | ||
}) | ||
|
||
const getButtons = useCallback(() => { | ||
|
@@ -46,8 +62,8 @@ const ViewImagings = () => { | |
}, [permissions, history, t]) | ||
|
||
useEffect(() => { | ||
setSearchRequest((previousRequest) => ({ ...previousRequest, status: 'all' })) | ||
}, []) | ||
setSearchRequest(() => ({ text: debouncedSearchText, status: searchFilter })) | ||
}, [searchFilter, debouncedSearchText]) | ||
|
||
useEffect(() => { | ||
setButtons(getButtons()) | ||
|
@@ -56,8 +72,34 @@ const ViewImagings = () => { | |
} | ||
}, [getButtons, setButtons]) | ||
|
||
const onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setSearchText(event.target.value) | ||
} | ||
|
||
return ( | ||
<Container> | ||
<Row> | ||
<Column md={3} lg={2}> | ||
<SelectWithLabelFormGroup | ||
name="type" | ||
label={t('imagings.filterTitle')} | ||
options={filterOptions} | ||
defaultSelected={filterOptions.filter(({ value }) => value === searchFilter)} | ||
onChange={(values) => setSearchFilter(values[0] as ImagingFilter)} | ||
isEditable | ||
/> | ||
</Column> | ||
<Column> | ||
<TextInputWithLabelFormGroup | ||
name="searchbox" | ||
label={t('imagings.search')} | ||
placeholder={t('imagings.searchPlaceholder')} | ||
value={searchText} | ||
isEditable | ||
onChange={onSearchBoxChange} | ||
/> | ||
Comment on lines
+93
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to add the following tests related to this field:
|
||
</Column> | ||
</Row> | ||
<Row> | ||
<ImagingRequestTable searchRequest={searchRequest} /> | ||
</Row> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add the following tests related to this field: