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-4183: Improve visit queue number attribute UUID handling in queue table #1366

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion __mocks__/wards.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ export const mockInpatientAdmissions: InpatientAdmission[] = [
encounterAssigningToCurrentInpatientLocation: null,
currentInpatientRequest: null,
firstAdmissionOrTransferEncounter: null,
currentInpatientLocation: mockLocationInpatientWard
currentInpatientLocation: mockLocationInpatientWard,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
handleSubmit,
control,
formState: { isDirty },
setValue
setValue,
} = useForm<BedAdministrationData>({
mode: 'all',
resolver: zodResolver(BedAdministrationSchema),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
import React from 'react';
import { type VisitAttributeQueueNumberColumnConfig } from '../../config-schema';
import { type QueueTableColumnFunction, type QueueEntry, type QueueTableCellComponentProps } from '../../types';
import { InlineNotification } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { type QueueTableColumnFunction, type QueueEntry } from '../../types';

export const queueTableVisitAttributeQueueNumberColumn: QueueTableColumnFunction = (
key,
header,
{ visitQueueNumberAttributeUuid }: VisitAttributeQueueNumberColumnConfig,
) => {
if (!visitQueueNumberAttributeUuid) {
console.error(
'No visit queue number attribute is configured, but the queue is configured to display the queue number.',
);
return null;
}

function getVisitQueueNumber(queueEntry: QueueEntry) {
return queueEntry.visit?.attributes?.find((e) => e?.attributeType?.uuid === visitQueueNumberAttributeUuid)?.value;
}

const QueueTableVisitAttributeQueueNumberCell = ({ queueEntry }: QueueTableCellComponentProps) => {
const { t } = useTranslation();

return (
<>
{visitQueueNumberAttributeUuid ? (
<span>{getVisitQueueNumber(queueEntry)}</span>
) : (
<InlineNotification lowContrast hideCloseButton>
{t('visitQueueNumberAttributeUuid not configured', 'visitQueueNumberAttributeUuid not configured')}
</InlineNotification>
)}
</>
);
const QueueTableVisitAttributeQueueNumberCell = ({ queueEntry }: { queueEntry: QueueEntry }) => {
return <span>{getVisitQueueNumber(queueEntry)}</span>;
};

return {
Expand Down
1 change: 0 additions & 1 deletion packages/esm-ward-app/src/hooks/useRestPatient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { openmrsFetch, restBaseUrl, type FetchResponse, type Patient } from '@op
import { useMemo } from 'react';
import useSWRImmutable from 'swr/immutable';


// prettier-ignore
const defaultRep =
'custom:(' +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Button, InlineNotification } from '@carbon/react';
import { Movement } from '@carbon/react/icons';
import { ArrowRightIcon, isDesktop, launchWorkspace, launchWorkspaceGroup, useAppContext, useLayoutType } from '@openmrs/esm-framework';
import {
ArrowRightIcon,
isDesktop,
launchWorkspace,
launchWorkspaceGroup,
useAppContext,
useLayoutType,
} from '@openmrs/esm-framework';
import React, { type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { type WardViewContext } from '../types';
Expand All @@ -11,7 +18,7 @@ interface AdmissionRequestsBarProps {
}

const AdmissionRequestsBar: React.FC<AdmissionRequestsBarProps> = ({ wardPendingPatients }) => {
const {wardPatientGroupDetails} = useAppContext<WardViewContext>('ward-view-context') ?? {};
const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
const { inpatientRequests, isLoading, error } = wardPatientGroupDetails?.inpatientRequestResponse ?? {};
const { t } = useTranslation();
const layout = useLayoutType();
Expand All @@ -31,9 +38,10 @@ const AdmissionRequestsBar: React.FC<AdmissionRequestsBarProps> = ({ wardPending
}

return (
<div className={`${styles.admissionRequestsContainer} ${
inpatientRequests?.length ? styles.blackBackground : styles.lightBlueBackground
}`}>
<div
className={`${styles.admissionRequestsContainer} ${
inpatientRequests?.length ? styles.blackBackground : styles.lightBlueBackground
}`}>
Copy link
Member

Choose a reason for hiding this comment

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

nit: Prefer using classnames here.

Copy link
Contributor Author

@jwnasambu jwnasambu Jan 19, 2025

Choose a reason for hiding this comment

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

@denniskigen Kindly, I am somehow confused. This is not part of my changes, though I don't mind fixing the issue. I made changes on one file and would like to know why I have 8 files changed.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like changes from linting

Copy link
Member

Choose a reason for hiding this comment

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

Resolved in this commit. For whatever reason, some files in the Ward app were not getting linted using our prettier config. I've fixed that. So all you need to do is rebase against main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@denniskigen Thanks for the fix and follow-up. I have fixed the merge conflicts, too.

<Movement className={styles.movementIcon} size="24" />
<span className={styles.content}>
{t('admissionRequestsCount', '{{count}} admission request', {
Expand All @@ -43,7 +51,7 @@ const AdmissionRequestsBar: React.FC<AdmissionRequestsBarProps> = ({ wardPending
<Button
onClick={() => {
launchWorkspaceGroup('ward-patient-admission-requests', {
state: {wardPendingPatients},
state: { wardPendingPatients },
workspaceToLaunch: {
name: 'admission-requests-workspace',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type CreateAdmissionEncounterWorkspaceProps } from './create-admission-
function CreateAdmissionRequestActionButton() {
const { t } = useTranslation();

// TODO: this is an attempt to save the previous search term for the
// TODO: this is an attempt to save the previous search term for the
// "Back to patient search" button, but it doesn't work. See:
// https://openmrs.atlassian.net/browse/O3-4300
const [searchTerm, setSearchTerm] = useState<string>('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ export default function PatientDischargeWorkspace(props: WardPatientWorkspacePro
closeWorkspaceWithSavedChanges();
wardPatientGroupDetails.mutate();
});
}, [
createEncounter,
wardPatient,
emrConfiguration,
t,
closeWorkspaceWithSavedChanges,
wardPatientGroupDetails,
]);
}, [createEncounter, wardPatient, emrConfiguration, t, closeWorkspaceWithSavedChanges, wardPatientGroupDetails]);

if (!wardPatientGroupDetails) return <></>;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ export default function PatientTransferForm({
hideCloseButton
/>
</div>
<AdmitPatientButton wardPatient={wardPatient} dispositionType={'ADMIT'} onAdmitPatientSuccess={closeWorkspaceWithSavedChanges} />
<AdmitPatientButton
wardPatient={wardPatient}
dispositionType={'ADMIT'}
onAdmitPatientSuccess={closeWorkspaceWithSavedChanges}
/>
</div>
);
}
Expand Down
Loading