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

Merge master to dev 20240703 #1895

Merged
merged 30 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd0f24b
Added auth for publish to npm (#1775) (#1776)
alaboso Jan 19, 2024
16faa63
Dev merging into working (#1793)
alaboso Jan 31, 2024
0748556
auto refresh encounter list after form saving/editing (#1864)
kajambiya Jun 12, 2024
cd289a4
Updated spa-build-config json with versions for demo server
Jun 13, 2024
6164656
Updating package versions to 2.3.3 in preparation for release
Jun 13, 2024
a6400c8
Delete .github/workflows/node.dev.js.yml from master branch (#1867)
alaboso Jun 13, 2024
555becb
Merge branch 'working' into master
alaboso Jun 14, 2024
f583e23
Merge pull request #1870 from UCSF-IGHS/master
alaboso Jun 14, 2024
9dc5584
Updating ohri esms to publish (npmjs) a package tagged for staging e…
Jun 14, 2024
9537ae8
Removing duplicate tbPreventionDashboardMeta in packages/esm-tb-app/s…
Jun 14, 2024
41bc8c9
Updating workflow
Jun 14, 2024
ff7fc01
Updating changesetBaseRefs to include working
Jun 14, 2024
4bd90d0
Updated spa assemble - hivv packages have not been split in working …
Jun 14, 2024
79d713d
Update packages/esm-ohri-pmtct-app/package.json name from @ohri/openm…
Jun 14, 2024
287f662
Update yarn lock file to reflect renaming of pmtct app
Jun 14, 2024
d2f4955
Merge pull request #1878 from UCSF-IGHS/working
alaboso Jun 20, 2024
8363ab5
Clean Ohri commons lib, upgrade openmrs, framework and patient-common…
kajambiya Jun 20, 2024
28b3eb6
fix lodash
kajambiya Jun 20, 2024
611a6db
refresh encounter list after deleting encounter
kajambiya Jun 20, 2024
8c73cef
(fix) Clean Ohri commons lib, upgrade openmrs, framework and patient-…
kajambiya Jun 20, 2024
c7f79fc
Updates package versions in prep for 2.3.4 release
Jun 20, 2024
3573ce4
Add encounter list refactors
kajambiya Jun 25, 2024
433407b
Merge pull request #1886 from kajambiya/EncounterListRefactor
alaboso Jun 27, 2024
dcd9994
Update package version to 2.3.5 prep for release 2.3.5
Jun 27, 2024
d4d59dd
(fix) Fixed Workspace window error to use WorkspaceContainer
CynthiaKamau Jul 2, 2024
4de92d3
Merge pull request #1891 from UCSF-IGHS/cohort-workspace-fix
alaboso Jul 2, 2024
873f446
update the form engine version (#1893)
hadijahkyampeire Jul 2, 2024
6bea80e
Update package versions to 2.3.6 prep for release
Jul 2, 2024
830a284
Merging master into dev
Jul 3, 2024
d269c1c
Merging master into dev - update yarn lock deps
Jul 3, 2024
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
84 changes: 82 additions & 2 deletions .github/workflows/node.working.js.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: OHRI CI - @esm and Docker Image
name: OHRI CI - @esm and Docker Image Working/QA

on:
push:
Expand All @@ -11,8 +11,88 @@ on:
types: [opened, synchronize]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Run tests
run: yarn run test

- name: Run build
run: yarn turbo run build --color --concurrency=5 --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team="${{ github.repository_owner }}"

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: |
packages/**/dist

qa:
runs-on: ubuntu-latest
needs: build

if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/working' }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Version
run: yarn workspaces foreach --worktree --topological --exclude @ohri/openmrs-esm-ohri version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-qa.${{ github.run_number }}"

- name: Build
run: yarn turbo run build --color --concurrency=5

- name: qa
run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:qa
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: |
packages/**/dist

docker_workingserver_frontend:
runs-on: ubuntu-latest
needs: qa

steps:
- name: Wait for 5 min - Let @esms reflect on NPM registry
Expand All @@ -37,7 +117,7 @@ jobs:
file: ./frontend/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ohri-working-frontend:next,${{ secrets.DOCKERHUB_USERNAME }}/ohri-working-frontend:ci_${{ github.run_number }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ohri-working-frontend:qa,${{ secrets.DOCKERHUB_USERNAME }}/ohri-working-frontend:ci_${{ github.run_number }}
cache-from: type=inline,ref=user/app:buildcache
cache-to: type=inline,ref=user/app:buildcache,mode=max

Expand Down
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ changesetBaseRefs: [
"dev",
"origin/dev",
"upstream/dev",
"working",
"origin/working",
"upstream/working",
]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ohri/openmrs-esm-ohri",
"private": true,
"version": "2.3.1",
"version": "2.3.6",
"description": "OHRI MicroFrontend for OpenMRS SPA",
"workspaces": [
"packages/*"
Expand Down Expand Up @@ -30,6 +30,7 @@
"verify": "turbo run lint && turbo run typescript && yarn test --coverage",
"ci:prepublish": "yarn workspaces foreach --all --topological --exclude @ohri/openmrs-esm-ohri npm publish --access public --tag next",
"ci:publish": "yarn workspaces foreach --all --topological --exclude @ohri/openmrs-esm-ohri npm publish --access public --tag latest",
"ci:qa": "yarn workspaces foreach --all --topological --exclude @ohri/openmrs-esm-ohri npm publish --access public --tag qa",
"release": "yarn workspaces foreach --all --topological version",
"coverage": "yarn test --coverage",
"badges": "yarn coverage && yarn jest-coverage-badges --output './badges' ",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-cervical-cancer-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-cervical-cancer-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "Cervical cancer microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/openmrs-esm-ohri-cervical-cancer-app.js",
"main": "src/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-commons-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-commons-lib",
"version": "2.3.1",
"version": "2.3.6",
"description": "Commons library microfrontend of shared assets for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/ohri-commons-lib.js",
"main": "src/index.ts",
Expand Down Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@carbon/react": "^1.13.0",
"@openmrs/openmrs-form-engine-lib": "2.0.0-pre.1029",
"@openmrs/openmrs-form-engine-lib": "2.0.0-pre.1260",
"fuzzy": "^0.1.3",
"lodash-es": "^4.17.15",
"systemjs-webpack-interop": "^2.3.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { useEncounterRows } from '../../hooks/useEncounterRows';
import { type OpenmrsEncounter } from '../../types';
import { useFormsJson } from '../../hooks/useFormsJson';
import { usePatientDeathStatus } from '../../hooks/usePatientDeathStatus';
import { mutate } from 'swr';

import styles from './encounter-list.scss';

Expand Down Expand Up @@ -51,6 +50,7 @@ export interface EncounterListProps {
workspaceWindowSize?: 'minimized' | 'maximized';
};
filter?: (encounter: any) => boolean;
afterFormSaveAction?: () => void;
}

export const EncounterList: React.FC<EncounterListProps> = ({
Expand All @@ -62,6 +62,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
formList,
filter,
launchOptions,
afterFormSaveAction,
}) => {
const { t } = useTranslation();
const [paginatedRows, setPaginatedRows] = useState([]);
Expand All @@ -72,7 +73,12 @@ export const EncounterList: React.FC<EncounterListProps> = ({
const { isDead } = usePatientDeathStatus(patientUuid);
const formNames = useMemo(() => formList.map((form) => form.name), [formList]);
const { formsJson, isLoading: isLoadingFormsJson } = useFormsJson(formNames);
const { encounters, isLoading, onFormSave } = useEncounterRows(patientUuid, encounterType, filter);
const { encounters, isLoading, onFormSave } = useEncounterRows(
patientUuid,
encounterType,
filter,
afterFormSaveAction,
);
const { moduleName, workspaceWindowSize, displayText, hideFormLauncher } = launchOptions;

const defaultActions = useMemo(
Expand Down Expand Up @@ -114,9 +120,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
const abortController = new AbortController();
deleteEncounter(encounterUuid, abortController)
.then(() => {
mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/encounter'), undefined, {
revalidate: true,
});
onFormSave();
showSnackbar({
isLowContrast: true,
title: t('encounterDeleted', 'Encounter deleted'),
Expand All @@ -132,6 +136,10 @@ export const EncounterList: React.FC<EncounterListProps> = ({
kind: 'error',
});
});

// Update encounters after deletion
const updatedEncounters = encounters.filter((enc) => enc.uuid !== encounterUuid);
constructPaginatedTableRows(updatedEncounters, currentPage, pageSize);
close();
},
});
Expand Down Expand Up @@ -262,7 +270,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
});
setPaginatedRows(rows);
},
[columns, defaultActions, forms, moduleName, workspaceWindowSize, patientUuid, onFormSave, handleDeleteEncounter],
[columns, defaultActions, forms, moduleName, onFormSave, workspaceWindowSize, patientUuid, handleDeleteEncounter],
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ export function launchEncounterForm(
intent: string = '*',
workspaceWindowSize?: 'minimized' | 'maximized',
patientUuid?: string,
mutateform?: () => void,
) {
launchPatientWorkspace('patient-form-entry-workspace', {
workspaceTitle: form.name,
mutateform: mutateform,
mutateForm: onFormSave,
formInfo: {
encounterUuid,
formUuid: form.name,
Expand Down
22 changes: 15 additions & 7 deletions packages/esm-commons-lib/src/hooks/useEncounterRows.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { useCallback, useEffect, useState } from 'react';
import useSWRImmutable, { mutate } from 'swr';
import { type OpenmrsEncounter } from '../types';
import useSWR from 'swr';

import { useCallback, useEffect, useMemo, useState } from 'react';
import { openmrsFetch } from '@openmrs/esm-framework';
import { encounterRepresentation } from '../constants';
import { type OpenmrsEncounter } from '../types';

export function useEncounterRows(patientUuid: string, encounterType: string, encounterFilter: (encounter) => boolean) {
export function useEncounterRows(
patientUuid: string,
encounterType: string,
encounterFilter: (encounter) => boolean,
afterFormSaveAction: () => void,
) {
const [encounters, setEncounters] = useState([]);
const url = `/ws/rest/v1/encounter?encounterType=${encounterType}&patient=${patientUuid}&v=${encounterRepresentation}`;

const {
data: response,
error,
isLoading,
} = useSWRImmutable<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch);
mutate,
} = useSWR<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch);

useEffect(() => {
if (response) {
Expand All @@ -30,8 +37,9 @@ export function useEncounterRows(patientUuid: string, encounterType: string, enc
}, [encounterFilter, response]);

const onFormSave = useCallback(() => {
mutate(url);
}, [url]);
mutate();
afterFormSaveAction && afterFormSaveAction();
}, [afterFormSaveAction, mutate]);

return {
encounters,
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-covid-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-covid-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "COVID Microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/openmrs-esm-ohri-covid-app.js",
"main": "src/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-form-render-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-form-render-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "A Forms Rendering microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/openmrs-esm-ohri-form-render-app.js",
"main": "src/index.ts",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@carbon/react": "^1.13.0",
"@openmrs/openmrs-form-engine-lib": "2.0.0-pre.1029",
"@openmrs/openmrs-form-engine-lib": "2.0.0-pre.1260",
"ace-builds": "1.34.1",
"react-ace": "^9.4.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-hiv-prevention-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-hiv-prevention-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "HIV Prevention microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/openmrs-esm-ohri-hiv-prevention-app.js",
"main": "src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-ohri-core-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-core-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "A custom microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/ohri-core-app.js",
"main": "src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-ohri-pmtct-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-pmtct-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "PMTCT microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/ohri-pmtct-app.js",
"main": "src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-opd-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-opd-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "opd active visits",
"browser": "dist/openmrs-esm-ohri-opd-app.js",
"main": "src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-tb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ohri/openmrs-esm-ohri-tb-app",
"version": "2.3.1",
"version": "2.3.6",
"description": "Tuberclosis microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/openmrs-esm-ohri-tb-app.js",
"main": "src/index.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/esm-tb-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const tbClinicalViewDashboardLink = getSyncLifecycle(
createOHRIDashboardLink(tbClinicalViewDashboardMeta),
options,
);

export const tbCasesDashboardLink = getSyncLifecycle(createOHRIGroupedLink(tbCasesDashboardMeta), options);
export const tbCasesDashboard = getSyncLifecycle(rootComponent, options);

Expand Down
Loading
Loading