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) O3-3677: Implement ability to add patient to a queue from lab app #1258

Merged
merged 23 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
91e79f4
(feat) Enhance Service Queue Management for sending back patient to …
its-kios09 Jul 29, 2024
6a5e5bb
(feat) retaining previous queue details from the queue
its-kios09 Jul 30, 2024
6551b5a
(chore) removed the overflow button and renamed the title
its-kios09 Jul 30, 2024
4237402
(refactor) added defualt value to be urgent
its-kios09 Jul 31, 2024
8549ac3
(refactor) passed wait and urgent conceptUuid as configurable
its-kios09 Jul 31, 2024
3a31c7c
(chore) renamed and lab defualt should be blank
its-kios09 Aug 1, 2024
9da6f5f
Merge branch 'main' into itskios-09/lab-modal-send
its-kios09 Aug 1, 2024
4e5ffc4
(chore) transferred all the service-queue into one place and made the…
its-kios09 Aug 2, 2024
b7d2086
(refactor) translation json
its-kios09 Aug 2, 2024
a92f267
(refactor) renaming of defualts values of configuration schemas
its-kios09 Aug 2, 2024
c7bc383
(refactor) renaming of the defualt view on config-schema.ts
its-kios09 Aug 2, 2024
f4f3e2d
(refactor) rename the filenames for send-back-patient-toqueue
its-kios09 Aug 3, 2024
d265571
(refactor) renaming of the button
its-kios09 Aug 5, 2024
0d118f0
(refactor) translation.json
its-kios09 Aug 5, 2024
3c936fb
(refactor) reused the transition component and pass the patient uuid
its-kios09 Aug 5, 2024
f25e9d6
(refactor) translation json
its-kios09 Aug 5, 2024
748b2bf
(refactor) The reduce method is used to iterate through the results a…
its-kios09 Aug 7, 2024
dad80e1
(refactor) translation.json
its-kios09 Aug 7, 2024
c4dc507
(chore)removed ResultReviewConceptUuid
its-kios09 Aug 7, 2024
91bf7a0
(refactor) resolve issues addressed from the PR
its-kios09 Aug 8, 2024
2eaad49
Merge branch 'main' into itskios-09/lab-modal-send
denniskigen Aug 8, 2024
a16a5a5
(refactor) updated the hook
its-kios09 Aug 21, 2024
a583c97
Merge branch 'main' into itskios-09/lab-modal-send
brandones Aug 22, 2024
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
8 changes: 4 additions & 4 deletions packages/esm-service-queues-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export const configSchema = {
_description: 'The UUID of the default status for attending a service in the queues eg In Service.',
_default: 'ca7494ae-437f-4fd0-8aae-b88b9a2ba47d',
},
systolicBloodPressureUuid: {
_type: Type.ConceptUuid,
_default: '5085AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
diastolicBloodPressureUuid: {
_type: Type.ConceptUuid,
_default: '5086AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
Expand Down Expand Up @@ -112,10 +116,6 @@ export const configSchema = {
_type: Type.ConceptUuid,
_default: '5242AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
systolicBloodPressureUuid: {
_type: Type.ConceptUuid,
_default: '5085AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
temperatureUuid: {
_type: Type.ConceptUuid,
_default: '5088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
Expand Down
7 changes: 7 additions & 0 deletions packages/esm-service-queues-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ export const addNewQueueServiceWorkspace = getAsyncLifecycle(
moduleName,
},
);
export const transitionPatientToLatestQueue = getAsyncLifecycle(
Copy link
Contributor

@ojwanganto ojwanganto Aug 22, 2024

Choose a reason for hiding this comment

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

should we rename this to 'transitionPatientToNewQueue'? @chibongho what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can go with the current naming.

() => import('./transition-latest-queue-entry/transition-latest-queue-entry.component'),
{
featureName: 'transition patient to new queue',
moduleName,
},
);

// t('addNewQueueServiceRoom', 'Add new queue service room')
export const addNewQueueServiceRoomWorkspace = getAsyncLifecycle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ import { convertTime12to24 } from '../../helpers/time-helpers';
interface TransitionQueueEntryModalProps {
queueEntry: QueueEntry;
closeModal: () => void;
modalTitle?: string;
}

const TransitionQueueEntryModal: React.FC<TransitionQueueEntryModalProps> = ({ queueEntry, closeModal }) => {
const TransitionQueueEntryModal: React.FC<TransitionQueueEntryModalProps> = ({
queueEntry,
closeModal,
modalTitle,
}) => {
const { t } = useTranslation();
return (
<QueueEntryActionModal
queueEntry={queueEntry}
closeModal={closeModal}
modalParams={{
modalTitle: t('transitionPatient', 'Transition patient'),
modalTitle: modalTitle || t('transitionPatient', 'Transition patient'),
modalInstruction: t(
'transitionPatientStatusOrQueue',
'Select a new status or queue for patient to transition to.',
Expand Down
4 changes: 4 additions & 0 deletions packages/esm-service-queues-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
"name": "transition-queue-entry-modal",
"component": "transitionQueueEntryModal"
},
{
"name": "transition-patient-to-latest-queue-modal",
"component": "transitionPatientToLatestQueue"
},
{
"name": "edit-queue-entry-modal",
"component": "editQueueEntryModal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useLatestQueueEntry } from './transition-latest-queue-entry.resource';
import TransitionQueueEntryModal from '../queue-table/queue-entry-actions/transition-queue-entry.modal';

interface TransitionLatestQueueEntryProps {
patientUuid: string;
closeModal: () => void;
modalTitle?: string;
}

const TransitionLatestQueueEntry: React.FC<TransitionLatestQueueEntryProps> = ({
closeModal,
patientUuid,
modalTitle,
}) => {
const { t } = useTranslation();
const { data: queueEntry, error, isLoading } = useLatestQueueEntry(patientUuid);

if (error || !queueEntry) {
return null;
}

return (
<TransitionQueueEntryModal
queueEntry={queueEntry}
closeModal={closeModal}
modalTitle={t('TransitionLatestQueueEntry', "Transition patient's latest queue")}
/>
);
};

export default TransitionLatestQueueEntry;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
type FetchResponse,
openmrsFetch,
type OpenmrsResource,
type Patient,
type Visit,
} from '@openmrs/esm-framework';
import useSWR from 'swr';
import useSWRImmutable from 'swr/immutable';
import { type QueueEntry } from '../types';
import { FetcherResponse } from 'swr/_internal';

export function useLatestQueueEntry(patientUuid: string) {
const customRepresentation =
'custom:(uuid,display,queue:(uuid,display,name,location:(uuid,display),service:(uuid,display),allowedPriorities:(uuid,display),allowedStatuses:(uuid,display)),status,patient:(uuid,display),visit:(uuid,display,startDatetime),priority,priorityComment,sortWeight,startedAt,endedAt,locationWaitingFor,queueComingFrom,providerWaitingFor,previousQueueEntry)';

const encodedRepresentation = encodeURIComponent(customRepresentation);
const url = `/ws/rest/v1/queue-entry?v=${encodedRepresentation}&patient=${patientUuid}&isEnded=false`;
const { data, error, isLoading, mutate } = useSWR<FetchResponse<{ results: QueueEntry[] }>>(url, openmrsFetch);

const queueEntry =
data?.data?.results?.reduce((latestEntry, currentEntry) => {
if (!latestEntry || new Date(currentEntry.startedAt) > new Date(latestEntry.startedAt)) {
return currentEntry;
}
return latestEntry;
}, null) || null;

return { data: queueEntry, error, isLoading, mutate };
}
1 change: 1 addition & 0 deletions packages/esm-service-queues-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
"today": "Today",
"totalPatients": "Total Patients",
"transition": "Transition",
"TransitionLatestQueueEntry": "Transition patient to latest queue",
its-kios09 marked this conversation as resolved.
Show resolved Hide resolved
"transitionPatient": "Transition patient",
"transitionPatientStatusOrQueue": "Select a new status or queue for patient to transition to.",
"triageForm": "Triage form",
Expand Down
Loading