Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) U4X-741 : Add Feature in patient queues to toggle viewing of all patients queued in the parent location with tag clinical room #258

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ import StatusIcon from '../queue-entry-table-components/status-icon.component';
import { getOriginFromPathName } from './active-visits-table.resource';
import styles from './active-visits-table.scss';
import EditActionsMenu from './edit-action-menu.components';
import { usePatientQueuesList } from './patient-queues.resource';
import { useParentLocation, usePatientQueuesList } from './patient-queues.resource';
import PickPatientActionMenu from '../queue-entry-table-components/pick-patient-queue-entry-menu.component';
import ViewActionsMenu from './view-action-menu.components';
import NotesActionsMenu from './notes-action-menu.components';
import { PRIVILEGE_ENABLE_EDIT_DEMOGRAPHICS } from '../constants';
import PatientSearch from '../patient-search/patient-search.component';
import { QueueStatus } from '../utils/utils';
import MovetoNextPointAction from './move-patient-to-next-action-menu.components';

Expand All @@ -54,18 +53,18 @@ const ActiveVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) => {
const { t } = useTranslation();
const session = useSession();
const layout = useLayoutType();
const [isToggled, setIsToggled] = useState(false);

const { patientQueueEntries, isLoading } = usePatientQueuesList(
session?.sessionLocation?.uuid,
status,
session.user.systemId,
);
const handleToggleChange = () => {
setIsToggled(!isToggled);
};
const { location } = useParentLocation(session?.sessionLocation?.uuid);

const activeLocationUuid = isToggled ? location?.parentLocation?.uuid : session?.sessionLocation?.uuid;

const { patientQueueEntries, isLoading } = usePatientQueuesList(activeLocationUuid || '', status, isToggled);

const [showOverlay, setShowOverlay] = useState(false);
const [view, setView] = useState('');
const [viewState, setViewState] = useState<{ selectedPatientUuid: string }>(null);
const [searchTerm, setSearchTerm] = useState('');
const [overlayHeader, setOverlayTitle] = useState('');

const currentPathName: string = window.location.pathname;
const fromPage: string = getOriginFromPathName(currentPathName);
Expand Down Expand Up @@ -227,17 +226,34 @@ const ActiveVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) => {
>
{({ rows, headers, getHeaderProps, getTableProps, getRowProps }) => (
<TableContainer className={styles.tableContainer}>
<TableToolbar style={{ position: 'static', height: '3rem', overflow: 'visible', backgroundColor: 'color' }}>
<TableToolbarContent className={styles.toolbarContent}>
<Layer className={styles.toolbarContentLayer}>
<TableToolbarSearch
expanded
className={styles.search}
onChange={handleSearchInputChange}
placeholder={t('searchThisList', 'Search this list')}
size="sm"
/>
</Layer>
<TableToolbar
style={{
position: 'static',
overflow: 'visible',
backgroundColor: 'color',
}}
>
<TableToolbarContent
style={{
display: 'flex',
alignItems: 'center',
}}
>
<TableToolbarSearch
expanded
className={styles.search}
onChange={handleSearchInputChange}
placeholder={t('searchThisList', 'Search this list')}
size="sm"
/>
<Toggle
className={styles.toggle}
labelA="Off"
labelB="On"
id="toggle-1"
toggled={isToggled}
onToggle={handleToggleChange}
/>
</TableToolbarContent>
</TableToolbar>
<Table {...getTableProps()} className={styles.activeVisitsTable}>
Expand Down Expand Up @@ -292,16 +308,6 @@ const ActiveVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) => {
</TableContainer>
)}
</DataTable>
{showOverlay && (
<PatientSearch
view={view}
closePanel={() => setShowOverlay(false)}
viewState={{
selectedPatientUuid: viewState.selectedPatientUuid,
}}
headerTitle={overlayHeader}
/>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@
}
}

.tableFilter {
display: flex;
flex-direction: row;
margin: 4rem;
}

.toggle {
margin: 2rem;
}

.emptyRow {
padding: 0 1rem;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ export interface ChildLocation {
links: Link[];
}

export function usePatientQueuesList(currentQueueLocationUuid: string, status: string, provider: string) {
const apiUrl = `/ws/rest/v1/patientqueue?v=full&status=${status}&room=${currentQueueLocationUuid}`;
return usePatientQueueRequest(apiUrl, provider);
export function usePatientQueuesList(currentQueueLocationUuid: string, status: string, isToggled: boolean) {
let url = '';

if (isToggled) {
url = `/ws/rest/v1/patientqueue?v=full&status=${status}&parentLocation=${currentQueueLocationUuid}`;
} else {
url = `/ws/rest/v1/patientqueue?v=full&status=${status}&room=${currentQueueLocationUuid}`;
}
return usePatientQueueRequest(url);
}

export function usePatientQueueRequest(apiUrl: string, provider) {
export function usePatientQueueRequest(apiUrl: string) {
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: { results: Array<PatientQueue> } }, Error>(
apiUrl,
openmrsFetch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';

export function usePatientQueuesListByStatus(status: string) {
const apiUrl = `/ws/rest/v1/patientqueue?v=full&status=${status}`;
return usePatientQueueRequest(apiUrl, '');
return usePatientQueueRequest(apiUrl);
}

export function usePatientQueuesByParentLocation(status: string) {
Expand Down
Loading