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

(fix) O3-3661: Admission Requests List should include both Admission and Transfer requests #1255

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion packages/esm-ward-app/src/hooks/useInpatientRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import useWardLocation from './useWardLocation';
const defaultRep =
'custom:(dispositionLocation,dispositionType,disposition,dispositionEncounter:full,patient:default,dispositionObsGroup,visit)';

export function useInpatientRequest(dispositionType: Array<DispositionType> = ['ADMIT'], rep: string = defaultRep) {
export function useInpatientRequest(
dispositionType: Array<DispositionType> = ['ADMIT', 'TRANSFER'],
Copy link
Member Author

Choose a reason for hiding this comment

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

technically I didn't need to change the default value, but if we are going to have a default value seemed to make sense to have it equal to the only value we are currently passing in.

rep: string = defaultRep,
) {
const { location } = useWardLocation();
const searchParams = new URLSearchParams();
searchParams.set('dispositionType', dispositionType.join(','));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { Button, InlineNotification } from '@carbon/react';
import { ArrowRightIcon, isDesktop, launchWorkspace, useLayoutType } from '@openmrs/esm-framework';
import { useInpatientRequest } from '../hooks/useInpatientRequest';
import { useTranslation } from 'react-i18next';
import useWardLocation from '../hooks/useWardLocation';
import styles from './admission-requests.scss';

const AdmissionRequestsBar = () => {
const { inpatientRequests, isLoading, error } = useInpatientRequest(['ADMIT']);
const { inpatientRequests, isLoading, error } = useInpatientRequest(['ADMIT', 'TRANSFER']);
const { t } = useTranslation();
const layout = useLayoutType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import styles from './admission-requests-workspace.scss';
import AdmissionRequestCard from './admission-request-card.component';
import { getCoreTranslation, type DefaultWorkspaceProps } from '@openmrs/esm-framework';
import { useInpatientRequest } from '../hooks/useInpatientRequest';
import useWardLocation from '../hooks/useWardLocation';
import { Loading } from '@carbon/react';
import { InlineNotification } from '@carbon/react';
import { useTranslation } from 'react-i18next';

const AdmissionRequestsWorkspace: React.FC<DefaultWorkspaceProps> = () => {
const { t } = useTranslation();
const { inpatientRequests, isLoading, error } = useInpatientRequest();
const admissionRequests = inpatientRequests?.filter((request) => request.dispositionType == 'ADMIT');
Copy link
Member Author

Choose a reason for hiding this comment

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

We shouldn't have to filter here if we are only fetching types we want?

const { inpatientRequests, isLoading, error } = useInpatientRequest(['ADMIT', 'TRANSFER']);

if (isLoading) {
return <Loading />;
Expand All @@ -29,7 +27,7 @@ const AdmissionRequestsWorkspace: React.FC<DefaultWorkspaceProps> = () => {

return (
<div className={styles.admissionRequestsWorkspace}>
{admissionRequests.map((admissionRequest, indx) => (
{inpatientRequests.map((admissionRequest, indx) => (
<AdmissionRequestCard key={indx} patient={admissionRequest.patient} />
Copy link
Member

@denniskigen denniskigen Jul 30, 2024

Choose a reason for hiding this comment

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

Is there something in the response we could use as a key here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just like inpatient-request-workspace-card-${indx}.

@vasharma05 sorry we didn't catch this in the original PR with this change, but you can't just use an integer as a React key; it is very easy to wind up with duplicate keys that way. Duplicate keys can cause really bizarre and confusing bugs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<AdmissionRequestCard key={indx} patient={admissionRequest.patient} />
<AdmissionRequestCard key={`inpatient-request-workspace-card-${indx}`} patient={admissionRequest.patient} />

))}
</div>
Expand Down
Loading