Skip to content

Commit

Permalink
Merge branch 'openmrs:main' into test/O3-2943
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijaykv5 authored Jun 24, 2024
2 parents 277a123 + 9380680 commit bab85f8
Show file tree
Hide file tree
Showing 56 changed files with 542 additions and 553 deletions.
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export const formCollapseToggle = getAsyncLifecycle(
);

export const deleteQuestionModal = getAsyncLifecycle(
() => import('./form-renderer/repeat/delete-question-modal.component'),
() => import('./form-renderer/repeat/delete-question.modal'),
options,
);
2 changes: 1 addition & 1 deletion packages/esm-generic-patient-widgets-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-allergies-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-allergies-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ export const allergyFormWorkspace = getAsyncLifecycle(
export const allergyTile = getSyncLifecycle(allergyTileComponent, options);

export const allergyDeleteConfirmationDialog = getAsyncLifecycle(
() => import('./allergies/delete-allergy-modal.component'),
() => import('./allergies/delete-allergy.modal'),
options,
);
2 changes: 1 addition & 1 deletion packages/esm-patient-attachments-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, ModalHeader, ModalBody, ModalFooter } from '@carbon/react';
import { type Attachment } from '@openmrs/esm-framework';
import styles from './delete-attachment-confirmation-modal.scss';
import styles from './delete-attachment.scss';

interface DeleteAttachmentConfirmationProps {
attachment: Attachment;
Expand Down
11 changes: 4 additions & 7 deletions packages/esm-patient-attachments-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ export const capturePhotoWidget = getAsyncLifecycle(() => import('./camera-media
moduleName,
});

export const deleteAttachmentModal = getAsyncLifecycle(
() => import('./attachments/delete-attachment-confirmation-modal.component'),
{
featureName: 'delete-attachment-modal',
moduleName,
},
);
export const deleteAttachmentModal = getAsyncLifecycle(() => import('./attachments/delete-attachment.modal'), {
featureName: 'delete-attachment-modal',
moduleName,
});
2 changes: 1 addition & 1 deletion packages/esm-patient-banner-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Tag, DefinitionTooltip } from '@carbon/react';
import { DefinitionTooltip, Tag } from '@carbon/react';
import { formatDatetime, parseDate } from '@openmrs/esm-framework';
import { useCauseOfDeath } from './useCauseOfDeath';
import styles from './deceased-patient-tag.scss';

interface DeceasedPatientBannerTagProps {
patient: Pick<fhir.Patient, 'deceasedDateTime'>;
patient: fhir.Patient;
}

const DeceasedPatientBannerTag: React.FC<DeceasedPatientBannerTagProps> = ({ patient }) => {
const { t } = useTranslation();
const isDeceased = Boolean(patient?.deceasedDateTime);
const { causeOfDeath } = useCauseOfDeath(patient?.id);

return (
isDeceased && (
Expand All @@ -18,7 +21,10 @@ const DeceasedPatientBannerTag: React.FC<DeceasedPatientBannerTagProps> = ({ pat
definition={
<div role="tooltip" className={styles.tooltipPadding}>
<h6 style={{ marginBottom: '0.5rem' }}>{t('deceased', 'Deceased')}</h6>
<span>{formatDatetime(parseDate(patient?.deceasedDateTime))}</span>
<span>
{formatDatetime(parseDate(patient?.deceasedDateTime))}
{causeOfDeath ? ` ${t('from_lower', 'from')} ${causeOfDeath}` : null}
</span>
</div>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { useReactToPrint } from 'react-to-print';
import { mockPatient } from 'tools';
import PrintIdentifierSticker from './print-identifier-sticker-modal.component';
import PrintIdentifierSticker from './print-identifier-sticker.modal';

const mockedCloseModal = jest.fn();
const mockedUseReactToPrint = jest.mocked(useReactToPrint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useReactToPrint } from 'react-to-print';
import { Button, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
import { age, displayName, showSnackbar, useConfig } from '@openmrs/esm-framework';
import { type ConfigObject } from '../config-schema';
import styles from './print-identifier-sticker-modal.scss';
import styles from './print-identifier-sticker.scss';

interface PrintIdentifierStickerProps {
closeModal: () => void;
Expand Down
28 changes: 28 additions & 0 deletions packages/esm-patient-banner-app/src/banner-tags/useCauseOfDeath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { openmrsFetch } from '@openmrs/esm-framework';
import { useMemo } from 'react';
import useSWR from 'swr';

interface CauseOfDeathResponse {
data: {
causeOfDeath: {
display: string;
};
};
}

export function useCauseOfDeath(patientUuid: string) {
const customRepresentation = 'custom:(causeOfDeath:(display)';
const url = `/ws/rest/v1/person/${patientUuid}?v=${customRepresentation}`;

const { data, error } = useSWR<CauseOfDeathResponse, Error>(patientUuid ? url : null, openmrsFetch);

const results = useMemo(
() => ({
causeOfDeath: data?.data?.causeOfDeath?.display,
error,
}),
[data?.data?.causeOfDeath, error],
);

return results;
}
2 changes: 1 addition & 1 deletion packages/esm-patient-banner-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const deceasedPatientTag = getSyncLifecycle(deceasedPatientTagComponent,
export const patientBanner = getSyncLifecycle(patientBannerComponent, options);

export const printIdentifierStickerModal = getAsyncLifecycle(
() => import('./banner-tags/print-identifier-sticker-modal.component'),
() => import('./banner-tags/print-identifier-sticker.modal'),
options,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-chart-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.menuitem {
max-width: none;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { showModal } from '@openmrs/esm-framework';
import styles from './action-button.scss';

interface AddPastVisitOverflowMenuItemProps {
patientUuid?: string;
Expand All @@ -13,29 +15,20 @@ const AddPastVisitOverflowMenuItem: React.FC<AddPastVisitOverflowMenuItemProps>
}) => {
const { t } = useTranslation();

const openModal = useCallback(() => {
const handleLaunchModal = useCallback(() => {
const dispose = showModal('start-visit-dialog', {
patientUuid,
launchPatientChart,
closeModal: () => dispose(),
launchPatientChart,
patientUuid,
});
}, [patientUuid, launchPatientChart]);

return (
<li className="cds--overflow-menu-options__option">
<button
className="cds--overflow-menu-options__btn"
role="menuitem"
title={t('addPastVisit', 'Add past visit')}
data-floating-menu-primary-focus
onClick={openModal}
style={{
maxWidth: '100vw',
}}
>
<span className="cds--overflow-menu-options__option-content">{t('addPastVisit', 'Add past visit')}</span>
</button>
</li>
<OverflowMenuItem
className={styles.menuitem}
itemText={t('addPastVisit', 'Add past visit')}
onClick={handleLaunchModal}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { useVisit, showModal } from '@openmrs/esm-framework';
import styles from './action-button.scss';

interface CancelVisitOverflowMenuItemProps {
patientUuid: string;
}

const CancelVisitOverflowMenuItem: React.FC<CancelVisitOverflowMenuItemProps> = ({ patientUuid }) => {
const { t } = useTranslation();

const { currentVisit } = useVisit(patientUuid);
const openModal = useCallback(() => {

const handleLaunchModal = useCallback(() => {
const dispose = showModal('cancel-visit-dialog', {
closeModal: () => dispose(),
patientUuid,
Expand All @@ -19,20 +21,11 @@ const CancelVisitOverflowMenuItem: React.FC<CancelVisitOverflowMenuItemProps> =

return (
currentVisit && (
<li className="cds--overflow-menu-options__option">
<button
className="cds--overflow-menu-options__btn"
role="menuitem"
title={t('cancelVisit', 'Cancel visit')}
data-floating-menu-primary-focus
onClick={openModal}
style={{
maxWidth: '100vw',
}}
>
<span className="cds--overflow-menu-options__option-content">{t('cancelVisit', 'Cancel visit')}</span>
</button>
</li>
<OverflowMenuItem
className={styles.menuitem}
itemText={t('cancelVisit', 'Cancel visit')}
onClick={handleLaunchModal}
/>
)
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import React, { useCallback } from 'react';
import { OverflowMenuItem } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { showModal } from '@openmrs/esm-framework';
import { usePatientDeceased } from '../deceased/deceased.resource';
import { usePatientDeceasedStatus } from '../data.resource';
import styles from './action-button.scss';

interface MarkPatientAliveOverflowMenuItemProps {
patientUuid?: string;
}

const MarkPatientAliveOverflowMenuItem: React.FC<MarkPatientAliveOverflowMenuItemProps> = ({ patientUuid }) => {
const { t } = useTranslation();
const { isDead, isLoading: isLoadingPatient } = usePatientDeceasedStatus(patientUuid);

const { isDead, isLoading: isPatientLoading } = usePatientDeceased(patientUuid);

const openModal = useCallback(() => {
const dispose = showModal('confirm-alive-modal', {
const handleLaunchModal = useCallback(() => {
const dispose = showModal('mark-patient-alive-modal', {
closeModal: () => dispose(),
patientUuid,
closeDialog: () => dispose(),
});
}, [patientUuid]);

return (
!isPatientLoading &&
!isLoadingPatient &&
isDead && (
<OverflowMenuItem
itemText={t('markAlive', 'Mark alive')}
onClick={openModal}
style={{
maxWidth: '100vw',
}}
className={styles.menuitem}
itemText={t('markPatientAlive', 'Mark patient alive')}
onClick={handleLaunchModal}
/>
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React, { useCallback } from 'react';
import { OverflowMenuItem } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import { usePatientDeceased } from '../deceased/deceased.resource';
import { usePatientDeceasedStatus } from '../data.resource';
import styles from './action-button.scss';

const MarkPatientDeceasedOverflowMenuItem = ({ patientUuid }) => {
const { t } = useTranslation();
const handleClick = useCallback(() => launchPatientWorkspace('mark-patient-deceased-workspace-form'), []);
const { isDead, isLoading: isPatientLoading } = usePatientDeceased(patientUuid);
const { isDead, isLoading: isPatientLoading } = usePatientDeceasedStatus(patientUuid);

const handleLaunchModal = useCallback(() => launchPatientWorkspace('mark-patient-deceased-workspace-form'), []);

return (
!isPatientLoading &&
!isDead && (
<OverflowMenuItem
itemText={t('markDeceased', 'Mark deceased')}
onClick={handleClick}
style={{
maxWidth: '100vw',
}}
className={styles.menuitem}
itemText={t('markPatientDeceased', 'Mark patient deceased')}
onClick={handleLaunchModal}
/>
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useCallback } from 'react';
import { OverflowMenuItem } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { OverflowMenuItem } from '@carbon/react';
import { showModal, useConfig, usePatient } from '@openmrs/esm-framework';
import styles from './action-button.scss';

interface PrintIdentifierStickerOverflowMenuItemProps {
patientUuid: string;
Expand All @@ -16,7 +17,7 @@ const PrintIdentifierStickerOverflowMenuItem: React.FC<PrintIdentifierStickerOve
externalModuleName: '@openmrs/esm-patient-banner-app',
});

const launchModal = useCallback(() => {
const handleLaunchModal = useCallback(() => {
const dispose = showModal('print-identifier-sticker-modal', {
closeModal: () => dispose(),
patient,
Expand All @@ -27,11 +28,9 @@ const PrintIdentifierStickerOverflowMenuItem: React.FC<PrintIdentifierStickerOve
patient &&
Boolean(showPrintIdentifierStickerButton) && (
<OverflowMenuItem
className={styles.menuitem}
itemText={t('printIdentifierSticker', 'Print identifier sticker')}
onClick={launchModal}
style={{
maxWidth: '100vw',
}}
onClick={handleLaunchModal}
/>
)
);
Expand Down
Loading

0 comments on commit bab85f8

Please sign in to comment.