Skip to content

Commit

Permalink
Merge branch 'main' into fix/relation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jexsie committed Jun 29, 2023
2 parents 22b4768 + ac923c9 commit f7e3119
Show file tree
Hide file tree
Showing 82 changed files with 2,300 additions and 1,602 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
@@ -1,3 +1,4 @@
{
"git-blame.gitWebUrl": ""
"git-blame.gitWebUrl": "",
"angular.enable-strict-mode-prompt": false
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -65,7 +65,7 @@
"react-router-dom": "^6.3.0",
"rxjs": "^6.6.3",
"sass": "^1.54.3",
"swc-loader": "^0.1.15",
"swc-loader": "^0.2.3",
"swr": "^2.0.1",
"turbo": "^1.5.5",
"typescript": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/package.json
Expand Up @@ -40,7 +40,7 @@
"react-error-boundary": "^4.0.3"
},
"peerDependencies": {
"@openmrs/esm-framework": "4.x",
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-patient-common-lib": "4.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
26 changes: 6 additions & 20 deletions packages/esm-form-engine-app/src/index.ts
Expand Up @@ -2,34 +2,20 @@ import { defineConfigSchema, getAsyncLifecycle } from '@openmrs/esm-framework';
import { registerWorkspace } from '@openmrs/esm-patient-common-lib';
import { configSchema } from './config-schema';

declare var __VERSION__: string;
// __VERSION__ is replaced by Webpack with the version from package.json
const version = __VERSION__;
const moduleName = '@openmrs/esm-form-engine-app';

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

const backendDependencies = {
'webservices.rest': '^2.2.0',
const options = {
featureName: 'form-engine',
moduleName,
};

function setupOpenMRS() {
const moduleName = '@openmrs/esm-form-engine-app';

const options = {
featureName: 'form-engine',
moduleName,
};
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

export function startupApp() {
defineConfigSchema(moduleName, configSchema);
registerWorkspace({
name: 'patient-form-entry-workspace',
title: 'Clinical Form',
load: getAsyncLifecycle(() => import('./form-renderer/form-renderer.component'), options),
});

return {
extensions: [],
};
}

export { backendDependencies, importTranslation, setupOpenMRS, version };
8 changes: 8 additions & 0 deletions packages/esm-form-engine-app/src/routes.json
@@ -0,0 +1,8 @@
{
"$schema": "https://json.openmrs.org/routes.schema.json",
"backendDependencies": {
"webservices.rest": "^2.2.0"
},
"extensions": [],
"pages": []
}
3 changes: 2 additions & 1 deletion packages/esm-form-entry-app/package.json
Expand Up @@ -65,7 +65,7 @@
"zone.js": "~0.11.8"
},
"peerDependencies": {
"@openmrs/esm-framework": "4.x",
"@openmrs/esm-framework": "5.x",
"rxjs": "6.x",
"single-spa": "5.x"
},
Expand All @@ -81,6 +81,7 @@
"@types/jasminewd2": "~2.0.3",
"@types/webpack-env": "^1.17.0",
"codelyzer": "^6.0.0",
"copy-webpack-plugin": "^11.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.4",
Expand Down
28 changes: 4 additions & 24 deletions packages/esm-form-entry-app/src/index.ts
Expand Up @@ -5,15 +5,11 @@ import { defineConfigSchema, messageOmrsServiceWorker } from '@openmrs/esm-frame
import { configSchema } from './config-schema';
import { setupDynamicOfflineFormDataHandler, setupStaticDataOfflinePrecaching } from './app/offline/caching';

declare var __VERSION__: string;
// __VERSION__ is replaced by Webpack with the version from package.json
const version = __VERSION__;

const backendDependencies = { 'webservices.rest': '^2.24.0' };
const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
const moduleName = '@openmrs/esm-form-entry-app';

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

export function startupApp() {
setupStaticDataOfflinePrecaching();
setupDynamicOfflineFormDataHandler();

Expand Down Expand Up @@ -48,22 +44,6 @@ function setupOpenMRS() {
});

defineConfigSchema(moduleName, configSchema);

return {
extensions: [
{
name: 'form-widget',
slot: 'form-widget-slot',
load: () => import('./bootstrap'),
online: {
isOffline: false,
},
offline: {
isOffline: true,
},
},
],
};
}

export { backendDependencies, importTranslation, setupOpenMRS, version };
export const formWidget = () => import('./bootstrap');
15 changes: 15 additions & 0 deletions packages/esm-form-entry-app/src/routes.json
@@ -0,0 +1,15 @@
{
"$schema": "https://json.openmrs.org/routes.schema.json",
"backendDependencies": {
"webservices.rest": "^2.24.0"
},
"extensions": [
{
"name": "form-widget",
"component": "formWidget",
"slot": "form-widget-slot",
"online": true,
"offline": true
}
]
}
55 changes: 46 additions & 9 deletions packages/esm-form-entry-app/webpack.config.js
@@ -1,6 +1,25 @@
const { DefinePlugin, container } = require('webpack');
const { ModuleFederationPlugin } = container;
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const { existsSync, statSync } = require('fs');

function getFrameworkVersion() {
try {
const { version } = require('@openmrs/esm-framework/package.json');
return `^${version}`;
} catch {
return '5.x';
}
}

/**
* @param {string} name the name of the file
* @returns true if file exists and is a file
*/
function fileExistsSync(name) {
return existsSync(name) && statSync(name).isFile();
}

const path = require('path');
const { basename, dirname, resolve } = path;
Expand All @@ -11,18 +30,19 @@ const outDir = dirname(browser || main);
const srcFile = resolve(root, browser ? main : types);
const production = 'production';
const mode = process.env.NODE_ENV || production;
const frameworkVersion = getFrameworkVersion();
const routes = resolve(root, 'src', 'routes.json');
const hasRoutesDefined = fileExistsSync(routes);

function getFrameworkVersion() {
try {
const { version } = require('@openmrs/esm-framework/package.json');
return `^${version}`;
} catch {
return '4.x';
}
if (!hasRoutesDefined) {
console.error(
'This app does not define a routes.json. This file is required for this app to be used by the OpenMRS 3 App Shell.',
);
// key-smash error code
// so this (hopefully) doesn't interfere with Webpack-specific exit codes
process.exit(9819023573289);
}

const frameworkVersion = getFrameworkVersion();

module.exports = {
entry: resolve(__dirname, 'src/index.ts'),
target: 'web',
Expand Down Expand Up @@ -70,6 +90,23 @@ module.exports = {
chunks: true,
},
}),
hasRoutesDefined
? new CopyWebpackPlugin({
patterns: [
{
from: routes,
transform: {
transformer: (content) =>
JSON.stringify(
Object.assign({}, JSON.parse(content.toString()), {
version: mode === production ? version : inc(version, 'prerelease', 'local'),
}),
),
},
},
],
})
: {},
],
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss'],
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-generic-patient-widgets-app/package.json
Expand Up @@ -40,7 +40,7 @@
"lodash-es": "^4.17.15"
},
"peerDependencies": {
"@openmrs/esm-framework": "4.x",
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-patient-common-lib": "4.x",
"dayjs": "1.x",
"react": "^18.2.0",
Expand Down
36 changes: 8 additions & 28 deletions packages/esm-generic-patient-widgets-app/src/index.ts
@@ -1,37 +1,17 @@
import { defineConfigSchema, defineExtensionConfigSchema, getAsyncLifecycle } from '@openmrs/esm-framework';
import { defineExtensionConfigSchema, getAsyncLifecycle } from '@openmrs/esm-framework';
import { configSchema } from './config-schema';

declare var __VERSION__: string;
// __VERSION__ is replaced by Webpack with the version from package.json
const version = __VERSION__;
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
const moduleName = '@openmrs/esm-generic-patient-widgets-app';

const backendDependencies = {
fhir2: '^1.2.0',
const options = {
featureName: 'Generic widgets',
moduleName,
};

function setupOpenMRS() {
const moduleName = '@openmrs/esm-generic-patient-widgets-app';

const options = {
featureName: 'Generic widgets',
moduleName,
};
export const switchableObs = getAsyncLifecycle(() => import('./obs-switchable/obs-switchable.component'), options);

export function startupApp() {
defineExtensionConfigSchema(moduleName, configSchema);

return {
extensions: [
{
name: 'obs-by-encounter-widget',
load: getAsyncLifecycle(() => import('./obs-switchable/obs-switchable.component'), options),
meta: {
columnSpan: 4,
},
},
],
};
}

export { backendDependencies, importTranslation, setupOpenMRS, version };
17 changes: 17 additions & 0 deletions packages/esm-generic-patient-widgets-app/src/routes.json
@@ -0,0 +1,17 @@
{
"$schema": "https://json.openmrs.org/routes.schema.json",
"backendDependencies": {
"fhir2": "^1.2.0"
},
"extensions": [
{
"name": "obs-by-encounter-widget",
"component": "switchableObs",
"online": true,
"offline": true,
"meta": {
"columnSpan": 4
}
}
]
}
2 changes: 1 addition & 1 deletion packages/esm-patient-allergies-app/package.json
Expand Up @@ -38,7 +38,7 @@
"lodash-es": "^4.17.15"
},
"peerDependencies": {
"@openmrs/esm-framework": "4.x",
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-patient-common-lib": "4.x",
"dayjs": "1.x",
"react": "^18.2.0",
Expand Down
Expand Up @@ -22,10 +22,9 @@ import styles from './allergies-detailed-summary.scss';

interface AllergiesDetailedSummaryProps {
patient: fhir.Patient;
showAddAllergyButton: boolean;
}

const AllergiesDetailedSummary: React.FC<AllergiesDetailedSummaryProps> = ({ patient, showAddAllergyButton }) => {
const AllergiesDetailedSummary: React.FC<AllergiesDetailedSummaryProps> = ({ patient }) => {
const { t } = useTranslation();
const displayText = t('allergyIntolerances', 'allergy intolerances');
const headerTitle = t('allergies', 'Allergies');
Expand Down Expand Up @@ -79,16 +78,14 @@ const AllergiesDetailedSummary: React.FC<AllergiesDetailedSummaryProps> = ({ pat
<div className={styles.widgetCard}>
<CardHeader title={headerTitle}>
<span>{isValidating ? <InlineLoading /> : null}</span>
{showAddAllergyButton && (
<Button
kind="ghost"
renderIcon={(props) => <Add size={16} {...props} />}
iconDescription="Add allergies"
onClick={launchAllergiesForm}
>
{t('add', 'Add')}
</Button>
)}
<Button
kind="ghost"
renderIcon={(props) => <Add size={16} {...props} />}
iconDescription="Add allergies"
onClick={launchAllergiesForm}
>
{t('add', 'Add')}
</Button>
</CardHeader>
<DataTable rows={tableRows} headers={tableHeaders} isSortable useZebraStyles size={isTablet ? 'lg' : 'sm'}>
{({ rows, headers, getHeaderProps, getTableProps }) => (
Expand Down
Expand Up @@ -8,7 +8,6 @@ import AllergiesDetailedSummary from './allergies-detailed-summary.component';

const testProps = {
patient: mockPatient,
showAddAllergyButton: false,
};

const mockOpenmrsFetch = openmrsFetch as jest.Mock;
Expand Down
Expand Up @@ -29,10 +29,9 @@ import styles from './allergies-overview.scss';
interface AllergiesOverviewProps {
basePath: string;
patient: fhir.Patient;
showAddAllergyButton: boolean;
}

const AllergiesOverview: React.FC<AllergiesOverviewProps> = ({ patient, showAddAllergyButton, basePath }) => {
const AllergiesOverview: React.FC<AllergiesOverviewProps> = ({ patient }) => {
const { t } = useTranslation();
const displayText = t('allergyIntolerances', 'allergy intolerances');
const headerTitle = t('allergies', 'Allergies');
Expand Down Expand Up @@ -74,16 +73,14 @@ const AllergiesOverview: React.FC<AllergiesOverviewProps> = ({ patient, showAddA
<div className={styles.widgetCard}>
<CardHeader title={headerTitle}>
<span>{isValidating ? <InlineLoading /> : null}</span>
{showAddAllergyButton && (
<Button
kind="ghost"
renderIcon={(props) => <Add size={16} {...props} />}
iconDescription="Add allergies"
onClick={launchAllergiesForm}
>
{t('add', 'Add')}
</Button>
)}
<Button
kind="ghost"
renderIcon={(props) => <Add size={16} {...props} />}
iconDescription="Add allergies"
onClick={launchAllergiesForm}
>
{t('add', 'Add')}
</Button>
</CardHeader>
<DataTable rows={tableRows} headers={tableHeaders} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
{({ rows, headers, getHeaderProps, getTableProps }) => (
Expand Down

0 comments on commit f7e3119

Please sign in to comment.