Skip to content

Commit

Permalink
Fix move to next service queue (#266)
Browse files Browse the repository at this point in the history
Fix move to next service queue (#266)
  • Loading branch information
jabahum authored Nov 1, 2024
1 parent 6ad6f45 commit e87c616
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,17 @@ const ActiveClinicalVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status })
<div style={{ display: 'flex' }}>
{entry.status === 'PENDING' && (
<>
<PickPatientActionMenu queueEntry={entry} closeModal={() => true} />{' '}
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />
<PickPatientActionMenu queueEntry={entry} closeModal={() => true} />
</>
)}
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />

<NotesActionsMenu note={entry} />
{entry.status === 'SERVING' ||
(entry.status === 'PENDING' && isToggled && <MovetoNextPointAction patientUuid={entry?.patientUuid} />)}
</div>
),
},
}));
}, [filteredPatientQueueEntries, session.user, t, fromPage, isToggled]);
}, [filteredPatientQueueEntries, session.user, t, fromPage]);

if (isLoading) {
return <DataTableSkeleton role="progressbar" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const ActiveTriageVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) =
}, [paginatedQueueEntries, searchTerm, status]);

const tableRows = useMemo(() => {
return filteredPatientQueueEntries.map((entry) => ({
return filteredPatientQueueEntries.map((entry, index) => ({
...entry,
visitNumber: {
content: <span>{trimVisitNumber(entry.visitNumber)}</span>,
Expand Down Expand Up @@ -193,13 +193,19 @@ const ActiveTriageVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) =
{entry.status === 'PENDING' && (
<>
<PickPatientActionMenu queueEntry={entry} closeModal={() => true} />{' '}
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />
</>
)}

<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />

<NotesActionsMenu note={entry} />
{entry.status === 'SERVING' ||
(entry.status === 'PENDING' && isToggled && <MovetoNextPointAction patientUuid={entry?.patientUuid} />)}
(entry.status === 'PENDING' && isToggled && (
<MovetoNextPointAction
patient={filteredPatientQueueEntries[index]?.patientUuid}
entries={filteredPatientQueueEntries}
/>
))}
</div>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,11 @@ const ActiveVisitsTable: React.FC<ActiveVisitsTableProps> = ({ status }) => {
<ViewActionsMenu to={`\${openmrsSpaBase}/patient/${entry?.patientUuid}/chart`} from={fromPage} />

<NotesActionsMenu note={entry} />
{entry.status === 'SERVING' ||
(entry.status === 'PENDING' && isToggled && <MovetoNextPointAction patientUuid={entry?.patientUuid} />)}
</div>
),
},
}));
}, [filteredPatientQueueEntries, session.user, t, fromPage, isToggled]);
}, [filteredPatientQueueEntries, session.user, t, fromPage]);

if (isLoading) {
return <DataTableSkeleton role="progressbar" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const ChangeStatusMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid

// change to picked
const changeQueueStatus = useCallback(
(event: { preventDefault: () => void; target: { [x: string]: { value: string } } }) => {
(event) => {
event.preventDefault();

// check status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import { useTranslation } from 'react-i18next';
import { showModal } from '@openmrs/esm-framework';

interface MovetoNextPointActionProps {
patientUuid: string;
patient: string;
entries: [];
}

const MovetoNextPointAction: React.FC<MovetoNextPointActionProps> = ({ patientUuid }) => {
const MovetoNextPointAction: React.FC<MovetoNextPointActionProps> = ({ patient, entries }) => {
const { t } = useTranslation();

const openModal = useCallback(() => {
const dispose = showModal('queue-table-move-to-next-service-point-modal', {
patientUuid,
patient,
entries,
closeModal: () => dispose(),
});
}, [patientUuid]);
}, [patient, entries]);

return (
<Tooltip label="Re-Assign">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import { useQueueRoomLocations } from '../hooks/useQueueRooms';
import styles from './change-status-dialog.scss';
import { QueueStatus, extractErrorMessagesFromResponse } from '../utils/utils';
import { getCurrentPatientQueueByPatientUuid, useProviders } from './visit-form/queue.resource';
import { PatientQueue } from '../types/patient-queues';

interface ChangeStatusDialogProps {
patientUuid: string;
patient: string;
entries: PatientQueue[];
closeModal: () => void;
}

const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid, closeModal }) => {
const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patient, entries, closeModal }) => {
const { t } = useTranslation();

const sessionUser = useSession();
Expand Down Expand Up @@ -123,16 +125,15 @@ const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid,

// change to picked
const changeQueueStatus = useCallback(
(event: { preventDefault: () => void; target: { [x: string]: { value: string } } }) => {
(event) => {
event.preventDefault();

// check status
if (status === QueueStatus.Pending) {
const comment = event?.target['nextNotes']?.value ?? 'Not Set';
getCurrentPatientQueueByPatientUuid(patientUuid, sessionUser?.sessionLocation?.uuid).then(
(res) => {
const queues = res.data?.results[0]?.patientQueues;
const queueEntry = queues?.filter((item) => item?.patient?.uuid === patientUuid);
getCurrentPatientQueueByPatientUuid(patient, sessionUser?.sessionLocation?.uuid).then(
() => {
const queueEntry = entries?.filter((item) => item?.patient?.uuid === patient);

if (queueEntry.length > 0) {
updateQueueEntry(status, provider, queueEntry[0]?.uuid, 0, priorityComment, comment).then(() => {
Expand Down Expand Up @@ -171,10 +172,9 @@ const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid,
} else if (status === QueueStatus.Completed) {
const comment = event?.target['nextNotes']?.value ?? 'Not Set';

getCurrentPatientQueueByPatientUuid(patientUuid, sessionUser?.sessionLocation?.uuid).then(
(res) => {
const queues = res.data?.results[0]?.patientQueues;
const queueEntry = queues?.filter((item) => item?.patient?.uuid === patientUuid);
getCurrentPatientQueueByPatientUuid(patient, sessionUser?.sessionLocation?.uuid).then(
() => {
const queueEntry = entries?.filter((item) => item?.patient?.uuid === patient);

if (queueEntry.length > 0) {
updateQueueEntry(
Expand All @@ -189,7 +189,7 @@ const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid,
mutate();
addQueueEntry(
selectedNextQueueLocation,
patientUuid,
patient,
selectedProvider,
contentSwitcherIndex,
QueueStatus.Pending,
Expand Down Expand Up @@ -277,7 +277,7 @@ const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid,
mutate();
addQueueEntry(
selectedNextQueueLocation,
patientUuid,
patient,
selectedProvider,
contentSwitcherIndex,
QueueStatus.Pending,
Expand Down Expand Up @@ -368,13 +368,14 @@ const QueueTableMoveToNext: React.FC<ChangeStatusDialogProps> = ({ patientUuid,
closeModal,
contentSwitcherIndex,
mutate,
patientUuid,
patient,
priorityComment,
provider,
selectedNextQueueLocation,
selectedProvider,
sessionUser?.sessionLocation?.uuid,
status,
entries,
t,
],
);
Expand Down

0 comments on commit e87c616

Please sign in to comment.