Skip to content

Commit

Permalink
Add functionality to allow deleting and editing an allergy
Browse files Browse the repository at this point in the history
(feat) O3-2760: Add a `closeWorkspaceWithSavedChanges` function to the workspace API (openmrs#1689)

* Added new function 'closeWorkspaceWithSavedChanges' to close workspace after form is saved

* Passing 'closeWorkspaceWithSavedChanges' as workspace props

(docs) Amend steps for updating core libraries in README (openmrs#1690)

(chore) Bump @openmrs/ngx-formentry (openmrs#1684)

(fix) O3 2804: Reuse the ResponsiveWrapper component from esm-framework (openmrs#1673)

* (feat) Reuse ResponsiveWrapper component from esm-framework

* feat: Added Layer in visit-notes-form

* Fix styleguide imports by bumping both openmrs tooling and framework

* Misc fixes

---------

Co-authored-by: Dennis Kigen <[email protected]>

(refactor) O3-2815: Replace usages of `/ws/rest/v1` with `restBaseUrl` (openmrs#1661)

* (Refactor)O3-2815: Replace usages of '/ws/rest/v1' with restBaseUrl

* Fixup

---------

Co-authored-by: jwnasambu <wamalwa1844.com>
Co-authored-by: Dennis Kigen <[email protected]>

(feat) Add ability to cancel orders (openmrs#1640)

* (feat) cancel order

* clean up

* pr changes, reload fixes and clean up

* translations

* wip cancel order via action

* mutate orders on cancel

* order mutations and pr comments

* fixes to labs

* button text change

* Fixup

* More tweaks

---------

Co-authored-by: Dennis Kigen <[email protected]>

(chore) Add generic slot to Visit Form (openmrs#1688)

* (chore) Add billing slot to Start Visit Form

* Add generic visit attribute slot

* remove slot from config

---------

Co-authored-by: CynthiaKamau <[email protected]>

(chore) Bump Angular form engine (openmrs#1694)

(feat) Makes orders widget expandable and adds detailed order view (openmrs#1696)

* (feat) Expandable orders widget

* adds order item cards when expanded

* changes button to tooltip

(fix) O3-2629: Submit button on Allergy Form remains disabled when filling allergen and severity before reactions (openmrs#1699)

fix the allergy reaction dependency

(feat) Hide bottom navigation on tablets and phones when workspace is active (openmrs#1695)

(feat) Relocate Load More button in visits section (openmrs#1702)

(chore) Relocate Load More button in visits section

add closeWorkspaceWithSavedChanges argument to Allergy form

parameterised allergy reaction should be checked correctly

maintain non-coded allergen array

remove test

(chore) Prettier should only list files that don't formatting config

(feat) Add config to handle bill submission in start visit form (openmrs#1700)

Upgrade peter-evans/create-pull-request

See peter-evans/create-pull-request#2790

(chore) Update translations from Transifex (openmrs#1683)

add test

fix added test
  • Loading branch information
jnsereko committed Mar 3, 2024
1 parent f9d9db4 commit 71affec
Show file tree
Hide file tree
Showing 314 changed files with 3,134 additions and 1,777 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tx-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
token: ${{ secrets.TRANSIFEX_TOKEN }}
args: pull --force --all
- name: Create PR if necessary
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6.0.1
with:
commit-message: "(chore) Update translations from Transifex"
title: "(chore) Update translations from Transifex"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ If you notice that your local version of the application is not working or that

```bash
# Upgrade core libraries
yarn up openmrs @openmrs/esm-framework
yarn up openmrs@next @openmrs/esm-framework@next

# Reset version specifiers to `next`. Don't commit actual version numbers.
git checkout package.json
Expand Down
15 changes: 15 additions & 0 deletions __mocks__/allergies.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,18 @@ export const mockAllergies = [
reactionSeverity: 'Severe',
},
];

export const mockAllergy = {
clinicalStatus: 'Active',
criticality: 'high',
display: 'ACE inhibitors',
id: 'acf497ae-1f75-436c-ad27-b8a0dec390cd',
lastUpdated: '2024-02-28T11:41:58.000+00:00',
note: 'sample allergy note',
reactionManifestations: ['Anaphylaxis', 'Headache'],
reactionSeverity: undefined,
reactionToSubstance: undefined,
recordedBy: 'Super User',
recordedDate: '2024-02-23T13:45:08+00:00',
recorderType: 'Practitioner',
};
2 changes: 1 addition & 1 deletion e2e/commands/patient-operations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIRequestContext, expect } from '@playwright/test';
import { type APIRequestContext, expect } from '@playwright/test';

export interface Patient {
uuid: string;
Expand Down
4 changes: 2 additions & 2 deletions e2e/commands/visit-operations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { APIRequestContext, expect } from '@playwright/test';
import { Visit } from '@openmrs/esm-framework';
import { type APIRequestContext, expect } from '@playwright/test';
import { type Visit } from '@openmrs/esm-framework';
import dayjs from 'dayjs';

export const startVisit = async (api: APIRequestContext, patientId: string): Promise<Visit> => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIRequestContext, PlaywrightWorkerArgs, WorkerFixture } from '@playwright/test';
import { type APIRequestContext, type PlaywrightWorkerArgs, type WorkerFixture } from '@playwright/test';

/**
* A fixture which initializes an [`APIRequestContext`](https://playwright.dev/docs/api/class-apirequestcontext)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ci:bump-form-engine-lib": "yarn up @openmrs/openmrs-form-engine-lib@next",
"release": "lerna version --no-git-tag-version",
"verify": "turbo lint typescript test --color --concurrency=5",
"prettier": "prettier --config prettier.config.js --write \"packages/**/*.{ts,tsx,css,scss}\" \"e2e/**/*.ts\"",
"prettier": "prettier --config prettier.config.js --write \"packages/**/*.{ts,tsx,css,scss}\" \"e2e/**/*.ts\" --list-different",
"postinstall": "husky install",
"test-e2e": "playwright test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const FormRenderer: React.FC<FormRendererProps> = ({
patientUuid,
visit,
closeWorkspace,
closeWorkspaceWithSavedChanges,
encounterUuid,
mode,
}) => {
Expand Down Expand Up @@ -52,7 +53,7 @@ const FormRenderer: React.FC<FormRendererProps> = ({
visit={visit}
formJson={schema}
handleClose={closeWorkspace}
onSubmit={() => closeWorkspace({ ignoreChanges: true })}
onSubmit={closeWorkspaceWithSavedChanges}
mode={mode}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('FormRenderer', () => {
formUuid: 'test-form-uuid',
patientUuid: 'test-patient-uuid',
closeWorkspace: jest.fn(),
closeWorkspaceWithSavedChanges: jest.fn(),
promptBeforeClosing: jest.fn(),
};

Expand Down
4 changes: 2 additions & 2 deletions packages/esm-form-engine-app/src/hooks/useFormSchema.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useSWR from 'swr';

import { openmrsFetch } from '@openmrs/esm-framework';
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { type OHRIFormSchema } from '@openmrs/openmrs-form-engine-lib';

/**
Expand All @@ -10,7 +10,7 @@ import { type OHRIFormSchema } from '@openmrs/openmrs-form-engine-lib';
* @returns An object containing the form schema, error, and loading state
*/
const useFormSchema = (formUuid: string) => {
const url = formUuid ? `/ws/rest/v1/o3/forms/${formUuid}` : null;
const url = formUuid ? `${restBaseUrl}/o3/forms/${formUuid}` : null;

const { data, error, isLoading } = useSWR<{ data: OHRIFormSchema }>(url, openmrsFetch);

Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"closeThisPanel": "关闭此面板",
"errorTitle": "此表单出现错误",
"loading": "加载中",
"or": "",
"or": "或者",
"thisList": "这个列表",
"tryAgainMessage": "尝试打开另一个表单 "
}
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/translations/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"closeThisPanel": "关闭此面板",
"errorTitle": "此表单出现错误",
"loading": "加载中",
"or": "",
"or": "或者",
"thisList": "这个列表",
"tryAgainMessage": "尝试打开另一个表单 "
}
11 changes: 6 additions & 5 deletions packages/esm-form-entry-app/src/app/offline/caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
messageOmrsServiceWorker,
omrsOfflineCachingStrategyHttpHeaderName,
openmrsFetch,
restBaseUrl,
setupDynamicOfflineDataHandler,
subscribePrecacheStaticDependencies,
} from '@openmrs/esm-framework';
Expand All @@ -12,8 +13,8 @@ import type { FormSchema } from '../types';
export function setupStaticDataOfflinePrecaching() {
subscribePrecacheStaticDependencies(async () => {
const urlsToCache = [
'/ws/rest/v1/location?q=&v=custom:(uuid,display)',
'/ws/rest/v1/provider?q=&v=custom:(uuid,display,person:(uuid))',
`${restBaseUrl}/location?q=&v=custom:(uuid,display)`,
`${restBaseUrl}/provider?q=&v=custom:(uuid,display,person:(uuid))`,
];

await Promise.all(
Expand Down Expand Up @@ -66,7 +67,7 @@ export function setupDynamicOfflineFormDataHandler() {
}

async function getCacheableFormUrls(formUuid: string) {
const getFormRes = await openmrsFetch<FormSchema>(`/ws/rest/v1/o3/forms/${formUuid}`);
const getFormRes = await openmrsFetch<FormSchema>(`${restBaseUrl}/o3/forms/${formUuid}`);
const form = getFormRes.data;

if (!form) {
Expand All @@ -78,11 +79,11 @@ async function getCacheableFormUrls(formUuid: string) {
// - https://github.com/openmrs/openmrs-esm-patient-chart/blob/415790e1ad9b8bdbd1201958d21a06fa93ec7237/packages/esm-form-entry-app/src/app/openmrs-api/form-resource.service.ts#L21
// - https://github.com/openmrs/openmrs-esm-patient-chart/blob/415790e1ad9b8bdbd1201958d21a06fa93ec7237/packages/esm-form-entry-app/src/app/form-schema/form-schema.service.ts#L31
// - https://github.com/openmrs/openmrs-esm-patient-chart/blob/415790e1ad9b8bdbd1201958d21a06fa93ec7237/packages/esm-form-entry-app/src/app/form-schema/form-schema.service.ts#L164
`/ws/rest/v1/form/${formUuid}?v=full`,
`${restBaseUrl}/form/${formUuid}?v=full`,

// Required by:
// - https://github.com/openmrs/openmrs-esm-patient-chart/blob/415790e1ad9b8bdbd1201958d21a06fa93ec7237/packages/esm-form-entry-app/src/app/openmrs-api/form-resource.service.ts#L10
// - https://github.com/openmrs/openmrs-esm-patient-chart/blob/415790e1ad9b8bdbd1201958d21a06fa93ec7237/packages/esm-form-entry-app/src/app/form-schema/form-schema.service.ts#L167
`/ws/rest/v1/o3/forms/${formUuid}`,
`${restBaseUrl}/o3/forms/${formUuid}`,
].filter(Boolean);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TestBed } from '@angular/core/testing';
import { EncounterResourceService } from './encounter-resource.service';
import { LocalStorageService } from '../local-storage/local-storage.service';
import { OpenmrsApiModule } from './openmrs-api.module';
import { restBaseUrl } from '@openmrs/esm-framework';

describe('EncounterResourceService', () => {
let httpMock: HttpTestingController;
Expand Down Expand Up @@ -97,7 +98,7 @@ describe('EncounterResourceService', () => {
links: [
{
rel: 'self',
uri: 'https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/location',
uri: `https://amrs.ampath.or.ke:8443/amrs${restBaseUrl}/location`,
},
],
},
Expand All @@ -107,7 +108,7 @@ describe('EncounterResourceService', () => {
links: [
{
rel: 'self',
uri: 'https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/encountertype',
uri: `https://amrs.ampath.or.ke:8443/amrs${restBaseUrl}/encountertype`,
},
],
},
Expand Down Expand Up @@ -196,7 +197,7 @@ describe('EncounterResourceService', () => {
display: '',
links: [
{
uri: 'https://test1.ampath.or.ke:8443/amrs/ws/rest/v1/',
uri: `https://test1.ampath.or.ke:8443/amrs${restBaseUrl}`,
rel: 'self',
},
],
Expand All @@ -206,7 +207,7 @@ describe('EncounterResourceService', () => {
display: 'Location-5',
links: [
{
uri: 'https://test1.ampath.or.ke:8443/amrs/ws/rest/v1',
uri: `https://test1.ampath.or.ke:8443/amrs${restBaseUrl}`,
rel: 'self',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('FormResourceService Unit Tests', () => {

const req = httpMock.expectOne(winRef.openmrsRestBase.trim() + 'form/' + uuid + '?v=full');
expect(req.request.method).toBe('GET');
expect(req.request.urlWithParams).toContain('/ws/rest/v1/form/form-uuid?v=full');
expect(req.request.urlWithParams).toContain(`/ws/rest/v1/form/form-uuid?v=full`);
}));

it('should make API call with correct URL when getFormMetaDataByUuid is invoked with v', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class FormResourceService {
}

public getFormMetaDataByUuid(uuid: string, v: string = null) {
const url = `${this.windowRef.openmrsRestBase}form/${uuid}`;
const url = `${this.windowRef.openmrsRestBase}/form/${uuid}`;
const params: HttpParams = new HttpParams().set('v', v && v.length > 0 ? v : 'full');
return this.http.get<FormMetadataObject>(url, { params });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http';
import { WindowRef } from '../window-ref';
import { Form } from '@openmrs/ngx-formentry';
import { MetaData } from '../types';
import { parseDate, showSnackbar } from '@openmrs/esm-framework';
import { parseDate, restBaseUrl, showSnackbar } from '@openmrs/esm-framework';
import { SingleSpaPropsService } from '../single-spa-props/single-spa-props.service';
import { EncounterResourceService } from './encounter-resource.service';
import dayjs from 'dayjs';
Expand All @@ -19,7 +19,7 @@ export class ProgramResourceService {
) {}

private programEnrollmentUrl(): string {
return `${this.windowRef.nativeWindow.openmrsBase}/ws/rest/v1/programenrollment`;
return `${this.windowRef.nativeWindow.openmrsBase}${restBaseUrl}/programenrollment`;
}

public handlePatientCareProgram(form: Form, encounterUuid: string): void {
Expand Down
3 changes: 2 additions & 1 deletion packages/esm-form-entry-app/src/app/window-ref.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { restBaseUrl } from '@openmrs/esm-framework';

function _window() {
// return the global native browser window object
Expand All @@ -14,6 +15,6 @@ export class WindowRef {
}

get openmrsRestBase(): string {
return this.nativeWindow.openmrsBase + '/ws/rest/v1/';
return this.nativeWindow.openmrsBase + restBaseUrl + '/';
}
}
18 changes: 9 additions & 9 deletions packages/esm-form-entry-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';
import 'zone.js';
import { defineConfigSchema, messageOmrsServiceWorker } from '@openmrs/esm-framework';
import { defineConfigSchema, fhirBaseUrl, messageOmrsServiceWorker, restBaseUrl } from '@openmrs/esm-framework';
import { setupDynamicOfflineFormDataHandler, setupStaticDataOfflinePrecaching } from './app/offline/caching';
import { configSchema } from './config-schema';

Expand All @@ -22,42 +22,42 @@ export function startupApp() {

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/fhir2/R4/Observation.+',
pattern: `.+${fhirBaseUrl}/Observation.+`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/obs.+',
pattern: `.+${restBaseUrl}/obs.+`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/session.*',
pattern: `.+${restBaseUrl}/session.*`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/provider.*',
pattern: `.+${restBaseUrl}/provider.*`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/location.*',
pattern: `.+${restBaseUrl}/location.*`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/person.*',
pattern: `.+${restBaseUrl}/person.*`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/form.*',
pattern: `.+${restBaseUrl}/form.*`,
});

messageOmrsServiceWorker({
type: 'registerDynamicRoute',
pattern: '.+/ws/rest/v1/o3/forms.*',
pattern: `.+${restBaseUrl}/o3/forms.*`,
});

defineConfigSchema(moduleName, configSchema);
Expand Down
68 changes: 68 additions & 0 deletions packages/esm-form-entry-app/translations/am.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"aDayAgo": "a day ago",
"aFewSecondsAgo": "a few seconds ago",
"aMinuteAgo": "a minute ago",
"aMonthAgo": "a month ago",
"aYearAgo": "a year ago",
"add": "Add",
"addHour": "Add a hour",
"addMinute": "Add a minute",
"addSecond": "Add a second",
"anHourAgo": "an hour ago",
"cancel": "Cancel",
"changeToMonthView": "Change to month view",
"chooseMonthAndYear": "Choose month and year",
"clearEntry": "Are you sure you want to clear this entry?",
"closeThisPanel": "Close this panel",
"componentLoadingFailed": "Component Loading failed...",
"daysAgo": " days ago",
"deleteEntry": "Are you sure you want to delete this item?",
"discardButton": "Discard",
"enterMoreCharacters": "Please enter 2 or more characters",
"errorFetchingFormData": "There was an error fetching form data. Details: {detail}",
"errorLoadingForm": "Error loading form",
"errorWithForm": "There was an error with this form",
"fix": "Fix",
"formSubmissionFailed": "An error has occurred while submitting the form. Error: {error}",
"formSubmittedSuccessfully": "The form has been submitted successfully.",
"from": "From",
"futureDateRestriction": "Future date is not allowed!",
"hoursAgo": " hours ago",
"invalidDate": "Provided date is invalid!",
"loading": "Loading...",
"loadingComponent": "Loading Component...",
"max": "Max value should be {max}",
"maxDate": "Max Date should be {maxDate}",
"maxEntries": "Cannot have more than {max} entries",
"maxLength": "Max Length should be {maxLength}",
"min": "Min value should be {min}",
"minDate": "Min Date should be {minDate}",
"minLength": "Min Length should be {minLength}",
"minusHour": "Minus a hour",
"minusMinute": "Minus a minute",
"minusSecond": "Minus a second",
"minutesAgo": " minutes ago",
"monthsAgo": " months ago",
"next": "Next",
"next21Years": "Next 21 years",
"nextMonth": "Next month",
"nextYear": "Next year",
"patientIdentifierDuplication": "Patient identifier duplication",
"patientIdentifierDuplicationDescription": "The identifier provided is already associated with an existing patient. Please check the identifier and try again.",
"previous": "Previous",
"previous21Years": "Previous 21 years",
"previousMonth": "Previous month",
"previousValue": "Previous Value",
"previousYear": "Previous year",
"remove": "Remove",
"requiredField": "This field is required!",
"saveAndCloseButton": "Save and close",
"selectWeeks": "Select Weeks",
"set": "Set",
"submitting": "Submitting",
"to": "To",
"tryOpeningAnotherForm": "Try opening another form",
"useValue": "Use Value",
"weeks": "Weeks",
"yearsAgo": " years ago"
}
Loading

0 comments on commit 71affec

Please sign in to comment.