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) Preload most extensions and pages #1461

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions packages/esm-generic-patient-widgets-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineExtensionConfigSchema, getAsyncLifecycle } from '@openmrs/esm-framework';
import { defineExtensionConfigSchema, getSyncLifecycle } from '@openmrs/esm-framework';
import { configSchema } from './config-schema';
import obsSwitchableComponent from './obs-switchable/obs-switchable.component';

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

Expand All @@ -10,7 +11,7 @@ const options = {
moduleName,
};

export const switchableObs = getAsyncLifecycle(() => import('./obs-switchable/obs-switchable.component'), options);
export const switchableObs = getSyncLifecycle(obsSwitchableComponent, options);

export function startupApp() {
defineExtensionConfigSchema(moduleName, configSchema);
Expand Down
23 changes: 7 additions & 16 deletions packages/esm-patient-allergies-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {
defineConfigSchema,
fhirBaseUrl,
getAsyncLifecycle,
getSyncLifecycle,
messageOmrsServiceWorker,
} from '@openmrs/esm-framework';
import { defineConfigSchema, fhirBaseUrl, getSyncLifecycle, messageOmrsServiceWorker } from '@openmrs/esm-framework';
import { createDashboardLink } from '@openmrs/esm-patient-common-lib';
import { configSchema } from './config-schema';
import { dashboardMeta } from './dashboard.meta';
import allergiesDetailedSummaryComponent from './allergies/allergies-detailed-summary.component';
import allergyFormComponent from './allergies/allergies-form/allergy-form.component';
import allergyTileComponent from './allergies/allergies-tile.component';

const moduleName = '@openmrs/esm-patient-allergies-app';

Expand Down Expand Up @@ -37,10 +34,7 @@ export function startupApp() {
defineConfigSchema(moduleName, configSchema);
}

export const allergiesDetailedSummary = getAsyncLifecycle(
() => import('./allergies/allergies-detailed-summary.component'),
options,
);
export const allergiesDetailedSummary = getSyncLifecycle(allergiesDetailedSummaryComponent, options);

// t('Allergies', 'Allergies')
export const allergiesDashboardLink = getSyncLifecycle(
Expand All @@ -51,9 +45,6 @@ export const allergiesDashboardLink = getSyncLifecycle(
options,
);

export const allergiesForm = getAsyncLifecycle(
() => import('./allergies/allergies-form/allergy-form.component'),
options,
);
export const allergiesForm = getSyncLifecycle(allergyFormComponent, options);

export const allergyTile = getAsyncLifecycle(() => import('./allergies/allergies-tile.component'), options);
export const allergyTile = getSyncLifecycle(allergyTileComponent, options);
20 changes: 7 additions & 13 deletions packages/esm-patient-appointments-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import { createDashboardLink, getPatientSummaryOrder } from '@openmrs/esm-patient-common-lib';
import { createDashboardLink } from '@openmrs/esm-patient-common-lib';
import { dashboardMeta } from './dashboard.meta';
import appointmentsOverviewComponent from './appointments/appointments-overview.component';
import appointmentsDetailedSummaryComponent from './appointments/appointments-detailed-summary.component';
import upcomingAppointmentsWidgetComponent from './appointments/upcoming-appointments-card.component';

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

Expand All @@ -15,15 +18,9 @@ export function startupApp() {
defineConfigSchema(moduleName, {});
}

export const appointmentsOverview = getAsyncLifecycle(
() => import('./appointments/appointments-overview.component'),
options,
);
export const appointmentsOverview = getSyncLifecycle(appointmentsOverviewComponent, options);

export const appointmentsDetailedSummary = getAsyncLifecycle(
() => import('./appointments/appointments-detailed-summary.component'),
options,
);
export const appointmentsDetailedSummary = getSyncLifecycle(appointmentsDetailedSummaryComponent, options);

// t('Appointments', 'Appointments')
export const appointmentsSummaryDashboardLink = getSyncLifecycle(
Expand All @@ -41,7 +38,4 @@ export const appointmentsCancelConfirmationDialog = getAsyncLifecycle(
options,
);

export const upcomingAppointmentsWidget = getAsyncLifecycle(
() => import('./appointments/upcoming-appointments-card.component'),
options,
);
export const upcomingAppointmentsWidget = getSyncLifecycle(upcomingAppointmentsWidgetComponent, options);
3 changes: 2 additions & 1 deletion packages/esm-patient-attachments-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createDashboardLink } from '@openmrs/esm-patient-common-lib';
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import { attachmentsConfigSchema } from './attachments-config-schema';
import { dashboardMeta } from './dashboard.meta';
import attachmentsOverviewComponent from './attachments/attachments-overview.component';

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

Expand All @@ -11,7 +12,7 @@ export function startupApp() {
defineConfigSchema(moduleName, attachmentsConfigSchema);
}

export const attachmentsOverview = getAsyncLifecycle(() => import('./attachments/attachments-overview.component'), {
export const attachmentsOverview = getSyncLifecycle(attachmentsOverviewComponent, {
featureName: 'patient-attachments',
moduleName,
});
Expand Down
14 changes: 7 additions & 7 deletions packages/esm-patient-banner-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { defineConfigSchema, getAsyncLifecycle, messageOmrsServiceWorker } from '@openmrs/esm-framework';
import { defineConfigSchema, getSyncLifecycle, messageOmrsServiceWorker } from '@openmrs/esm-framework';
import { configSchema } from './config-schema';
import visitTagComponent from './banner-tags/visit-tag.component';
import deceasedPatientTagComponent from './banner-tags/deceased-patient-tag.component';
import patientBannerComponent from './banner/patient-banner.component';

const moduleName = '@openmrs/esm-patient-banner-app';

Expand All @@ -19,11 +22,8 @@ export function startupApp() {
defineConfigSchema(moduleName, configSchema);
}

export const visitTag = getAsyncLifecycle(() => import('./banner-tags/visit-tag.component'), options);
export const visitTag = getSyncLifecycle(visitTagComponent, options);

export const deceasedPatientTag = getAsyncLifecycle(
() => import('./banner-tags/deceased-patient-tag.component'),
options,
);
export const deceasedPatientTag = getSyncLifecycle(deceasedPatientTagComponent, options);

export const patientBanner = getAsyncLifecycle(() => import('./banner/patient-banner.component'), options);
export const patientBanner = getSyncLifecycle(patientBannerComponent, options);
156 changes: 72 additions & 84 deletions packages/esm-patient-chart-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ import { summaryDashboardMeta, encountersDashboardMeta } from './dashboard.meta'
import { setupOfflineVisitsSync, setupCacheableRoutes } from './offline';
import { genericDashboardConfigSchema } from './side-nav/generic-dashboard.component';
import { genericNavGroupConfigSchema } from './side-nav/generic-nav-group.component';
import patientChartPageComponent from './root.component';
import markPatientAliveActionButtonComponent from './actions-buttons/mark-patient-alive.component';
import markPatientDeceasedActionButtonComponent from './actions-buttons/mark-patient-deceased.component';
import startVisitActionButtonComponent from './actions-buttons/start-visit.component';
import stopVisitActionButtonComponent from './actions-buttons/stop-visit.component';
import cancelVisitActionButtonComponent from './actions-buttons/cancel-visit.component';
import addPastVisitActionButtonComponent from './actions-buttons/add-past-visit.component';
import currentVisitSummaryComponent from './visit/visits-widget/current-visit-summary.component';
import pastVisitsDetailOverviewComponent from './visit/past-visit-overview.component';
import pastVisitsOverviewComponent from './visit/visits-widget/visit-detail-overview.component';
import patientDetailsTileComponent from './patient-details-tile/patient-details-tile.component';
import visitAttributeTagsComponent from './patient-banner-tags/visit-attribute-tags.component';
import genericNavGroupComponent from './side-nav/generic-nav-group.component';
import genericDashboardComponent from './side-nav/generic-dashboard.component';
import startVisitFormComponent from './visit/visit-form/visit-form.component';

// This allows @openmrs/esm-patient-common-lib to be accessed by modules that are not
// using webpack. This is used for ngx-formentry.
Expand Down Expand Up @@ -72,7 +87,7 @@ export function startupApp() {
);
}

export const root = getAsyncLifecycle(() => import('./root.component'), { featureName: 'patient-chart', moduleName });
export const root = getSyncLifecycle(patientChartPageComponent, { featureName: 'patient-chart', moduleName });

export const patientSummaryDashboardLink =
// t('Patient Summary', 'Patient Summary')
Expand All @@ -87,65 +102,55 @@ export const patientSummaryDashboardLink =
},
);

export const startVisitActionButton = getAsyncLifecycle(() => import('./actions-buttons/start-visit.component'), {
export const markPatientAliveActionButton = getSyncLifecycle(markPatientAliveActionButtonComponent, {
featureName: 'patient-actions-slot',
moduleName,
});

export const stopVisitActionButton = getAsyncLifecycle(() => import('./actions-buttons/stop-visit.component'), {
featureName: 'patient-actions-slot',
export const markPatientDeceasedActionButton = getSyncLifecycle(markPatientDeceasedActionButtonComponent, {
featureName: 'patient-actions-slot-deceased-button',
moduleName,
});

export const markPatientAliveActionButton = getAsyncLifecycle(
() => import('./actions-buttons/mark-patient-alive.component'),
{
featureName: 'patient-actions-slot',
moduleName,
},
);
export const startVisitActionButton = getSyncLifecycle(startVisitActionButtonComponent, {
featureName: 'patient-actions-slot',
moduleName,
});

export const stopVisitPatientSearchActionButton = getAsyncLifecycle(
() => import('./actions-buttons/stop-visit.component'),
{
featureName: 'patient-actions-slot',
moduleName,
},
);
export const stopVisitActionButton = getSyncLifecycle(stopVisitActionButtonComponent, {
featureName: 'patient-actions-slot',
moduleName,
});

export const cancelVisitActionButton = getAsyncLifecycle(() => import('./actions-buttons/cancel-visit.component'), {
export const cancelVisitActionButton = getSyncLifecycle(cancelVisitActionButtonComponent, {
featureName: 'patient-actions-slot',
moduleName,
});

export const markPatientDeceasedActionButton = getAsyncLifecycle(
() => import('./actions-buttons/mark-patient-deceased.component'),
{
featureName: 'patient-actions-slot-deceased-button',
moduleName,
},
);
export const addPastVisitActionButton = getSyncLifecycle(addPastVisitActionButtonComponent, {
featureName: 'patient-actions-slot-add-past-visit-button',
moduleName,
});

export const cancelVisitPatientSearchActionButton = getAsyncLifecycle(
() => import('./actions-buttons/cancel-visit.component'),
{
featureName: 'patient-actions-slot-cancel-visit-button',
moduleName,
},
);
export const startVisitPatientSearchActionButton = getSyncLifecycle(startVisitActionButtonComponent, {
featureName: 'start-visit-button-patient-search',
moduleName,
});

export const addPastVisitActionButton = getAsyncLifecycle(() => import('./actions-buttons/add-past-visit.component'), {
featureName: 'patient-actions-slot-add-past-visit-button',
export const stopVisitPatientSearchActionButton = getSyncLifecycle(stopVisitActionButtonComponent, {
featureName: 'patient-actions-slot',
moduleName,
});

export const addPastVisitPatientSearchActionButton = getAsyncLifecycle(
() => import('./actions-buttons/add-past-visit.component'),
{
featureName: 'patient-search-actions-slot-add-past-visit-button',
moduleName,
},
);
export const cancelVisitPatientSearchActionButton = getSyncLifecycle(cancelVisitActionButtonComponent, {
featureName: 'patient-actions-slot-cancel-visit-button',
moduleName,
});

export const addPastVisitPatientSearchActionButton = getSyncLifecycle(addPastVisitActionButtonComponent, {
featureName: 'patient-search-actions-slot-add-past-visit-button',
moduleName,
});

export const encountersSummaryDashboardLink =
// t('Visits', 'Visits')
Expand All @@ -157,47 +162,51 @@ export const encountersSummaryDashboardLink =
{ featureName: 'encounter', moduleName },
);

export const pastVisitsDetailOverview = getAsyncLifecycle(
() => import('./visit/visits-widget/visit-detail-overview.component'),
{
featureName: 'visits-detail-slot',
moduleName,
},
);
export const currentVisitSummary = getSyncLifecycle(currentVisitSummaryComponent, {
featureName: 'current-visit-summary',
moduleName,
});

export const pastVisitsOverview = getAsyncLifecycle(() => import('./visit/past-visit-overview.component'), {
export const pastVisitsOverview = getSyncLifecycle(pastVisitsDetailOverviewComponent, {
featureName: 'past-visits-overview',
moduleName,
});

export const startVisitForm = getAsyncLifecycle(() => import('./visit/visit-form/visit-form.component'), {
featureName: 'start-visit-form',
export const pastVisitsDetailOverview = getSyncLifecycle(pastVisitsOverviewComponent, {
featureName: 'visits-detail-slot',
moduleName,
});

export const markPatientDeceasedForm = getAsyncLifecycle(() => import('./deceased/deceased-form.component'), {
featureName: 'mark-patient-deceased-form',
export const patientDetailsTile = getSyncLifecycle(patientDetailsTileComponent, {
featureName: 'patient-details-tile',
moduleName,
});

export const patientDetailsTile = getAsyncLifecycle(
() => import('./patient-details-tile/patient-details-tile.component'),
{
featureName: 'patient-details-tile',
moduleName,
},
);
export const visitAttributeTags = getSyncLifecycle(visitAttributeTagsComponent, {
featureName: 'visit-attribute-tags',
moduleName,
});

export const genericNavGroup = getAsyncLifecycle(() => import('./side-nav/generic-nav-group.component'), {
export const genericNavGroup = getSyncLifecycle(genericNavGroupComponent, {
featureName: 'Nav group',
moduleName,
});

export const genericDashboard = getAsyncLifecycle(() => import('./side-nav/generic-dashboard.component'), {
export const genericDashboard = getSyncLifecycle(genericDashboardComponent, {
featureName: 'Dashboard',
moduleName,
});

export const startVisitForm = getSyncLifecycle(startVisitFormComponent, {
featureName: 'start-visit-form',
moduleName,
});

export const markPatientDeceasedForm = getAsyncLifecycle(() => import('./deceased/deceased-form.component'), {
featureName: 'mark-patient-deceased-form',
moduleName,
});

export const cancelVisitDialog = getAsyncLifecycle(() => import('./visit/visit-prompt/cancel-visit-dialog.component'), {
featureName: 'cancel visit',
moduleName,
Expand All @@ -223,31 +232,10 @@ export const confirmAliveDialog = getAsyncLifecycle(() => import('./deceased/mar
moduleName,
});

export const startVisitButtonPatientSearch = getAsyncLifecycle(() => import('./visit/start-visit-button.component'), {
featureName: 'start-visit-button-patient-search',
moduleName,
});

export const visitAttributeTags = getAsyncLifecycle(
() => import('./patient-banner-tags/visit-attribute-tags.component'),
{
featureName: 'visit-attribute-tags',
moduleName,
},
);

export const deleteEncounterModal = getAsyncLifecycle(
() => import('./visit/visits-widget/past-visits-components/delete-encounter-modal.component'),
{
featureName: 'delete-encounter-modal',
moduleName,
},
);

export const currentVisitSummary = getAsyncLifecycle(
() => import('./visit/visits-widget/current-visit-summary.component'),
{
featureName: 'current-visit-summary',
moduleName,
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export function DashboardView({ dashboard, patientUuid, patient }: DashboardView
Promise.resolve(dashboard.title()).then(setResolvedTitle);
} else if (typeof dashboard?.title === 'string') {
setResolvedTitle(dashboard.title);
} else {
setResolvedTitle(undefined);
}
}, [dashboard]);

Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-chart-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
{
"name": "start-visit-button-patient-search",
"slot": "start-visit-button-slot",
"component": "startVisitButtonPatientSearch",
"component": "startVisitPatientSearchActionButton",
"online": true,
"offline": true
},
Expand Down
Loading
Loading