diff --git a/packages/esm-tb-app/README.md b/packages/esm-tb-app/README.md new file mode 100644 index 000000000..f2bf21b2f --- /dev/null +++ b/packages/esm-tb-app/README.md @@ -0,0 +1,4 @@ +# esm-tb-app + +The Tuberclosis app tracks and manages patients on TB treatment. It provides a clinical dashboard with an overall view of patients as well as patient workflows. + diff --git a/packages/esm-tb-app/package.json b/packages/esm-tb-app/package.json new file mode 100644 index 000000000..00d930cfc --- /dev/null +++ b/packages/esm-tb-app/package.json @@ -0,0 +1,49 @@ +{ + "name": "@ohri/openmrs-esm-ohri-tb-app", + "version": "2.0.2", + "description": "Tuberclosis microfrontend for OpenMRS HIV Reference Implementation (OHRI)", + "browser": "dist/openmrs-esm-ohri-tb-app.js", + "main": "src/index.ts", + "license": "MIT", + "homepage": "https://github.com/UCSF-IGHS/openmrs-esm-ohri#readme", + "scripts": { + "start": "openmrs develop", + "serve": "webpack serve --mode=development", + "debug": "npm run serve", + "build": "webpack --mode production", + "analyze": "webpack --mode=production --env.analyze=true", + "lint": "eslint src --ext tsx", + "typescript": "tsc", + "prepublishOnly": "npm run build", + "extract-translations": "i18next 'src/**/*.component.tsx'" + }, + "browserslist": [ + "extends browserslist-config-openmrs" + ], + "keywords": [ + "openmrs" + ], + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/UCSF-IGHS/openmrs-esm-ohri.git" + }, + "bugs": { + "url": "https://github.com/UCSF-IGHS/openmrs-esm-ohri/issues" + }, + "dependencies": { + "@carbon/react": "^1.13.0" + }, + "peerDependencies": { + "@openmrs/esm-framework": "5.x", + "@openmrs/esm-patient-common-lib": "5.x", + "dayjs": "^1.8.16", + "react": "^18.2.0", + "react-i18next": "^11.18.6" + }, + "devDependencies": { + "webpack": "^5.74.0" + } +} diff --git a/packages/esm-tb-app/src/constants.ts b/packages/esm-tb-app/src/constants.ts new file mode 100644 index 000000000..07b7450c4 --- /dev/null +++ b/packages/esm-tb-app/src/constants.ts @@ -0,0 +1 @@ +export const sampleConstant = 'xxxxxxxxxxxx'; diff --git a/packages/esm-tb-app/src/dashboard.meta.tsx b/packages/esm-tb-app/src/dashboard.meta.tsx new file mode 100644 index 000000000..6effacd75 --- /dev/null +++ b/packages/esm-tb-app/src/dashboard.meta.tsx @@ -0,0 +1,4 @@ +export const tuberclosisMeta = { + title: 'Tuberclosis', + slotName: 'tuberclosis-slot', +}; diff --git a/packages/esm-tb-app/src/dashboard.scss b/packages/esm-tb-app/src/dashboard.scss new file mode 100644 index 000000000..009007b57 --- /dev/null +++ b/packages/esm-tb-app/src/dashboard.scss @@ -0,0 +1,21 @@ +@import "./root.scss"; + +.noMarker { + list-style-type: none; +} + +.noMarker ul li a { + padding-left: 40px !important; + font: lighter; +} + +.currentNavItem > a { + background-color: #cecece !important; + color: #161616 !important; + border-left-color: var(--brand-01) !important; + font: bolder; +} + +.hide { + display: none; +} diff --git a/packages/esm-tb-app/src/declarations.d.tsx b/packages/esm-tb-app/src/declarations.d.tsx new file mode 100644 index 000000000..875203d56 --- /dev/null +++ b/packages/esm-tb-app/src/declarations.d.tsx @@ -0,0 +1,2 @@ +declare module '*.css'; +declare module '*.scss'; diff --git a/packages/esm-tb-app/src/index.ts b/packages/esm-tb-app/src/index.ts new file mode 100644 index 000000000..3f63eb40a --- /dev/null +++ b/packages/esm-tb-app/src/index.ts @@ -0,0 +1,17 @@ +import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework'; +import { createDashboardGroup, createDashboardLink } from '@openmrs/esm-patient-common-lib'; + +export const importTranslation = require.context('../translations', false, /.json$/, 'lazy'); + +require('./root.scss'); + +export const moduleName = '@ohri/openmrs-esm-ohri-tb-app'; + +const options = { + featureName: 'ohri-tb', + moduleName, +}; + +export function startupApp() { + defineConfigSchema(moduleName, {}); +} diff --git a/packages/esm-tb-app/src/root.scss b/packages/esm-tb-app/src/root.scss new file mode 100644 index 000000000..081ea1496 --- /dev/null +++ b/packages/esm-tb-app/src/root.scss @@ -0,0 +1,3 @@ +@use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@import '~@openmrs/esm-styleguide/src/vars'; diff --git a/packages/esm-tb-app/src/routes.json b/packages/esm-tb-app/src/routes.json new file mode 100644 index 000000000..50b1a5272 --- /dev/null +++ b/packages/esm-tb-app/src/routes.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.openmrs.org/routes.schema.json", + "backendDependencies": { + "webservices.rest": "^2.24.0" + }, + "pages": [ + ], + "extensions": [ + ] +} diff --git a/packages/esm-tb-app/src/setupTests.ts b/packages/esm-tb-app/src/setupTests.ts new file mode 100644 index 000000000..80d83f31c --- /dev/null +++ b/packages/esm-tb-app/src/setupTests.ts @@ -0,0 +1,15 @@ +import '@testing-library/jest-dom/extend-expect'; + +declare global { + interface Window { + openmrsBase: string; + spaBase: string; + } +} + +const { getComputedStyle } = window; +window.getComputedStyle = (element) => getComputedStyle(element); +window.openmrsBase = '/openmrs'; +window.spaBase = '/spa'; +window.getOpenmrsSpaBase = () => '/openmrs/spa/'; +window.HTMLElement.prototype.scrollIntoView = jest.fn(); diff --git a/packages/esm-tb-app/src/views/common.scss b/packages/esm-tb-app/src/views/common.scss new file mode 100644 index 000000000..3170a9b19 --- /dev/null +++ b/packages/esm-tb-app/src/views/common.scss @@ -0,0 +1,34 @@ +@use "@carbon/styles/scss/spacing"; +@import "../root.scss"; + +.widgetContainer { + background-color: $ui-background; +} + +.widgetHeaderContainer { + display: flex; + justify-content: space-between; + align-items: center; + padding: spacing.$spacing-04 0 spacing.$spacing-04 spacing.$spacing-05; +} + +.widgetHeaderContainer > h4:after { + content: ""; + display: block; + width: 2rem; + padding-top: 0.188rem; + border-bottom: 0.375rem solid var(--brand-01); +} + +.toggleButtons { + width: fit-content; + margin: 0 spacing.$spacing-03; +} + +.tabContainer div[role="tabpanel"] { + padding: 0 !important; +} + +.tabContainer li button { + width: 100% !important; +} diff --git a/packages/esm-tb-app/translations/en.json b/packages/esm-tb-app/translations/en.json new file mode 100644 index 000000000..bf0805bc6 --- /dev/null +++ b/packages/esm-tb-app/translations/en.json @@ -0,0 +1,3 @@ +{ + "tuberclosis": "Tuberclosis" +} diff --git a/packages/esm-tb-app/tsconfig.json b/packages/esm-tb-app/tsconfig.json new file mode 100644 index 000000000..db240ff83 --- /dev/null +++ b/packages/esm-tb-app/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "module": "esnext", + "allowSyntheticDefaultImports": true, + "jsx": "react", + "skipLibCheck": true, + "moduleResolution": "node", + "lib": [ + "dom", + "es5", + "scripthost", + "es2015", + "es2015.promise", + "es2016.array.include", + "es2018", + "es2020" + ], + "resolveJsonModule": true, + "noEmit": true, + "target": "esnext", + "paths": { + "@openmrs/*": [ + "./node_modules/@openmrs/*" + ] + } + } +} diff --git a/packages/esm-tb-app/webpack.config.js b/packages/esm-tb-app/webpack.config.js new file mode 100644 index 000000000..b15408968 --- /dev/null +++ b/packages/esm-tb-app/webpack.config.js @@ -0,0 +1,17 @@ +const path = require('path'); +const config = (module.exports = require('openmrs/default-webpack-config')); +config.scriptRuleConfig.exclude = + path.sep == '/' + ? /(node_modules[^\/@openmrs\/esm\-patient\-common\-lib])/ + : /(node_modules[^\\@openmrs\/esm\-patient\-common\-lib])/; + +// Temporary fix to resolve webpack issues with imports from the commons library +config.overrides.resolve = { + extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss'], + alias: { + '@openmrs/esm-framework': '@openmrs/esm-framework/src/internal', + '@ohri/openmrs-esm-ohri-commons-lib': path.resolve(__dirname, '../esm-commons-lib/src/index'), + '@openmrs/openmrs-form-engine-lib': '@openmrs/openmrs-form-engine-lib/src/index', + }, +}; +module.exports = config; diff --git a/yarn.lock b/yarn.lock index 05c42a023..bd936a67b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3770,6 +3770,21 @@ __metadata: languageName: unknown linkType: soft +"@ohri/openmrs-esm-ohri-tb-app@workspace:packages/esm-tb-app": + version: 0.0.0-use.local + resolution: "@ohri/openmrs-esm-ohri-tb-app@workspace:packages/esm-tb-app" + dependencies: + "@carbon/react": ^1.13.0 + webpack: ^5.74.0 + peerDependencies: + "@openmrs/esm-framework": 5.x + "@openmrs/esm-patient-common-lib": 5.x + dayjs: ^1.8.16 + react: ^18.2.0 + react-i18next: ^11.18.6 + languageName: unknown + linkType: soft + "@ohri/openmrs-esm-ohri@workspace:.": version: 0.0.0-use.local resolution: "@ohri/openmrs-esm-ohri@workspace:."