Skip to content

Commit

Permalink
Merging master into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Amos Laboso committed Jul 3, 2024
2 parents 377813f + 6bea80e commit 830a284
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 29 deletions.
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

0 comments on commit 830a284

Please sign in to comment.