Skip to content

Commit

Permalink
Merge pull request #116 from Rugute/main
Browse files Browse the repository at this point in the history
Added patient Care-panel and HIE CR
  • Loading branch information
Rugute authored Jul 16, 2024
2 parents 3f99dfb + 261aa2a commit 5355df2
Show file tree
Hide file tree
Showing 73 changed files with 4,964 additions and 120 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"packages/*"
],
"scripts": {
"start": "openmrs develop --backend https://ngx.ampath.or.ke --sources packages/esm-report-app --api-url /amrs --spa-path /amrs/spa/ --port 8040",
"start": "openmrs develop --backend http://10.50.80.110:8084 --sources packages/esm-*-app --api-url /amrs --spa-path /amrs/spa/ --port 8040",
"dev": "openmrs develop --backend http://10.50.80.110:8084 --sources packages/esm-report-app --api-url /amrs --spa-path /amrs/spa/ --port 8040",
"start:core": "openmrs develop --backend https://ngx.ampath.or.ke --sources packages/esm-ampath-core-app --api-url /amrs --spa-path /amrs/spa/ --port 8030",
"start:core": "openmrs develop --backend http://10.50.80.110:8084 --sources packages/esm-ampath-core-app --api-url /amrs --spa-path /amrs/spa/ --port 8030",
"ci:publish": "yarn workspaces foreach --all --topological --exclude @ampath/esm-3.x-app npm publish --access public --tag latest",
"ci:prepublish": "yarn workspaces foreach --all --topological --exclude @ampath/esm-3.x-app npm publish --access public --tag next",
"release": "yarn workspaces foreach --all --topological version",
Expand Down Expand Up @@ -38,7 +38,7 @@
"@babel/core": "^7.11.6",
"@carbon/react": "~1.37.0",
"@ohri/openmrs-esm-ohri-commons-lib": "next",
"@openmrs/esm-framework": "^5.6.1-pre.1979",
"@openmrs/esm-framework": "^5.6.1-pre.2069",
"@openmrs/esm-patient-common-lib": "next",
"@playwright/test": "1.40.1",
"@swc/core": "^1.2.165",
Expand Down Expand Up @@ -75,7 +75,7 @@
"jest-cli": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.1",
"openmrs": "^5.6.1-pre.1979",
"openmrs": "^5.6.1-pre.2069",
"prettier": "^3.1.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-billing-app/src/routes.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.openmrs.org/routes.schema.json",
"backendDependencies": {
"amrscore": "^1.0.0",
"amrs": "^1.0.0",
"amrsreporting": "^1.0.0"
},
"pages": [
Expand Down
5 changes: 5 additions & 0 deletions packages/esm-care-panel-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
![Node.js CI](https://github.com/palladiumkenya/ampath-esm-3.x/workflows/Node.js%20CI/badge.svg)

# ESM Care Panel App

This repository provides a starting point for creating ampath patient care panels
1 change: 1 addition & 0 deletions packages/esm-care-panel-app/currentProphylaxisUsed/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions packages/esm-care-panel-app/hivStatus/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions packages/esm-care-panel-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const rootConfig = require('../../jest.config.js');

module.exports = rootConfig;
54 changes: 54 additions & 0 deletions packages/esm-care-panel-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@ampath/esm-care-panel-app",
"version": "5.2.0",
"description": "Patient care panels microfrontend for the OpenMRS SPA",
"browser": "dist/ampath-esm-care-panel-app.js",
"main": "src/index.ts",
"source": true,
"license": "MPL-2.0",
"homepage": "https://github.com/palladiumkenya/ampath-esm-core#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 ts,tsx",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js",
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests",
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js",
"coverage": "yarn test --coverage"
},
"browserslist": [
"extends browserslist-config-openmrs"
],
"keywords": [
"openmrs"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/palladiumkenya/ampath-esm-core#readme"
},
"bugs": {
"url": "https://github.com/palladiumkenya/ampath-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.42.1",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
"react-router-dom": "6.x",
"swr": "2.x"
},
"devDependencies": {
"webpack": "^5.74.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { Tabs, TabList, Tab, TabPanel, TabPanels, Layer, Tile } from '@carbon/react';
import { Dashboard, CloudMonitoring, Printer } from '@carbon/react/icons';
import { useTranslation } from 'react-i18next';
import CarePanel from '../care-panel/care-panel.component';
import CarePrograms from '../care-programs/care-programs.component';
import PatientSummary from '../patient-summary/patient-summary.component';

import styles from './care-panel-dashboard.scss';

type CarePanelDashboardProps = { patientUuid: string; formEntrySub: any; launchPatientWorkspace: Function };

const CarePanelDashboard: React.FC<CarePanelDashboardProps> = ({
formEntrySub,
patientUuid,
launchPatientWorkspace,
}) => {
const { t } = useTranslation();
return (
<Layer className={styles.container}>
<Tile>
<div className={styles.desktopHeading}>
<h4>{t('careProgramsEnrollement', 'Care panel')}</h4>
</div>
</Tile>
<div className={styles.tabs}>
<Tabs>
<TabList contained activation="manual" aria-label="List of care panels">
<Tab renderIcon={Dashboard}>{t('panelSummary', 'Panel summary')}</Tab>
<Tab renderIcon={CloudMonitoring}>{t('enrollments', 'Program enrollment')}</Tab>
</TabList>
<TabPanels>
<TabPanel>
<CarePanel
patientUuid={patientUuid}
formEntrySub={formEntrySub}
launchPatientWorkspace={launchPatientWorkspace}
/>
</TabPanel>
<TabPanel>
<CarePrograms patientUuid={patientUuid} />
</TabPanel>
</TabPanels>
</Tabs>
</div>
</Layer>
);
};

export default CarePanelDashboard;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@use '@carbon/layout';
@use '@carbon/type';
@use '@carbon/colors';
@import '~@openmrs/esm-styleguide/src/vars';

.container {
background-color: colors.$white;
}

.tabs {
margin: 0 layout.$spacing-05;
}

.desktopHeading,
.tabletHeading {
text-align: left;
text-transform: capitalize;

h4 {
@include type.type-style('heading-compact-02');
color: $text-02;

&:after {
content: '';
display: block;
width: 2rem;
padding-top: 3px;
border-bottom: 0.375rem solid;
@include brand-03(border-bottom-color);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { StructuredListSkeleton, ContentSwitcher, Switch } from '@carbon/react';
import styles from './care-panel.scss';
import { useEnrollmentHistory } from '../hooks/useEnrollmentHistory';
import ProgramSummary from '../program-summary/program-summary.component';
import ProgramEnrollment from '../program-enrollment/program-enrollment.component';
import { CardHeader, EmptyState } from '@openmrs/esm-patient-common-lib';
import RegimenHistory from '../regimen/regimen-history.component';
import first from 'lodash/first';
import sortBy from 'lodash/sortBy';
import { ErrorState } from '@openmrs/esm-framework';
import CarePrograms from '../care-programs/care-programs.component';

interface CarePanelProps {
patientUuid: string;
formEntrySub: any;
launchPatientWorkspace: Function;
}

type SwitcherItem = {
index: number;
name?: string;
text?: string;
};

const CarePanel: React.FC<CarePanelProps> = ({ patientUuid, formEntrySub, launchPatientWorkspace }) => {
const { t } = useTranslation();
const { isLoading, error, enrollments } = useEnrollmentHistory(patientUuid);
const switcherHeaders = sortBy(Object.keys(enrollments || {}));
const [switchItem, setSwitcherItem] = useState<SwitcherItem>({ index: 0 });
const patientEnrollments = useMemo(
() => (isLoading ? [] : enrollments[switchItem?.name || first(switcherHeaders)]),
[enrollments, isLoading, switchItem?.name, switcherHeaders],
);

if (isLoading) {
return (
<div className={styles.widgetCard}>
<StructuredListSkeleton role="progressbar" />
</div>
);
}

if (error) {
return <ErrorState error={error} headerTitle={t('carePanelError', 'Care panel')} />;
}

if (Object.keys(enrollments).length === 0) {
return (
<>
<EmptyState displayText={t('carePanel', 'care panel')} headerTitle={t('carePanel', 'Care panel')} />
</>
);
}

return (
<>
<div className={styles.widgetCard}>
<CardHeader title={t('carePanel', 'Care Panel')}>
<div className={styles.contextSwitcherContainer}>
<ContentSwitcher selectedIndex={switchItem?.index} onChange={setSwitcherItem}>
{switcherHeaders?.map((enrollment) => <Switch key={enrollment} name={enrollment} text={enrollment} />)}
</ContentSwitcher>
</div>
</CardHeader>
<div style={{ width: '100%', minHeight: '20rem' }}>
<ProgramSummary patientUuid={patientUuid} programName={switcherHeaders[switchItem?.index]} />
<RegimenHistory patientUuid={patientUuid} category={switcherHeaders[switchItem?.index]} />
<ProgramEnrollment
patientUuid={patientUuid}
programName={switcherHeaders[switchItem?.index]}
enrollments={patientEnrollments}
formEntrySub={formEntrySub}
/>
</div>
</div>
</>
);
};

export default CarePanel;
45 changes: 45 additions & 0 deletions packages/esm-care-panel-app/src/care-panel/care-panel.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@use '@carbon/styles/scss/type';
@use '@carbon/styles/scss/spacing';
@import '~@openmrs/esm-styleguide/src/vars';

.bodyShort01 {
@include type.type-style('body-compact-01');
}

.widgetCard {
background-color: $ui-background;
border: 1px solid $ui-03;
position: relative;
}

.contextSwitcherContainer {
width: 20rem;
min-width: 60%;
margin-right: 1rem;
}

.desktopContentSwitcher {
width: 100%;
}

.tabletContentSwitcher {
width: 100%;
}

.helperContainer {
color: $color-gray-70;
@extend .bodyShort01;
text-align: left;
padding-left: 1.3rem;
}

.labelRed {
color: $danger;
}

.careProgramContainer {
margin-top: spacing.$spacing-05;
& > div {
padding: 0;
}
}
Loading

0 comments on commit 5355df2

Please sign in to comment.