Skip to content

Commit

Permalink
Replace usages of '/ws/rest/v1' with restBaseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnasambu committed Feb 13, 2024
1 parent 09a60a2 commit b91b610
Show file tree
Hide file tree
Showing 13 changed files with 689 additions and 689 deletions.
12 changes: 6 additions & 6 deletions __mocks__/allergies.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const mockAllergyResult = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/concept/162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl/concept/162298AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
],
},
Expand All @@ -28,7 +28,7 @@ export const mockAllergyResult = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/concept/1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl/concept/1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
],
},
Expand All @@ -41,7 +41,7 @@ export const mockAllergyResult = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/concept/143264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl/concept/143264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
],
},
Expand All @@ -54,18 +54,18 @@ export const mockAllergyResult = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/patient/011cffa0-7383-45ef-962c-d1976718b8d4',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl/patient/011cffa0-7383-45ef-962c-d1976718b8d4',
},
],
},
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/patient/011cffa0-7383-45ef-962c-d1976718b8d4/allergy/dbba59ef-c8a5-4967-b20a-5761b1954f6d',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl//patient/011cffa0-7383-45ef-962c-d1976718b8d4/allergy/dbba59ef-c8a5-4967-b20a-5761b1954f6d',
},
{
rel: 'full',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/ws/rest/v1/patient/011cffa0-7383-45ef-962c-d1976718b8d4/allergy/dbba59ef-c8a5-4967-b20a-5761b1954f6d?v=full',
uri: 'http://localhost:8090/openmrslocalhost:8080/openmrs/restBaseUrl/patient/011cffa0-7383-45ef-962c-d1976718b8d4/allergy/dbba59ef-c8a5-4967-b20a-5761b1954f6d?v=full',
},
],
resourceVersion: '1.8',
Expand Down
6 changes: 3 additions & 3 deletions __mocks__/programs.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const mockProgramsResponse = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrs/ws/rest/v1/program/64f950e6-1b07-4ac0-8e7e-f3e148f3463f',
uri: 'http://localhost:8090/openmrs/restBaseUrl/program/64f950e6-1b07-4ac0-8e7e-f3e148f3463f',
},
],
},
Expand All @@ -129,11 +129,11 @@ export const mockProgramsResponse = {
links: [
{
rel: 'self',
uri: 'http://localhost:8090/openmrs/ws/rest/v1/programenrollment/b033f8c3-7e0b-4118-aa1d-76c550f2978d',
uri: 'http://localhost:8090/openmrs/restBaseUrl/programenrollment/b033f8c3-7e0b-4118-aa1d-76c550f2978d',
},
{
rel: 'full',
uri: 'http://localhost:8090/openmrs/ws/rest/v1/programenrollment/b033f8c3-7e0b-4118-aa1d-76c550f2978d?v=full',
uri: 'http://localhost:8090/openmrs/restBaseUrl/programenrollment/b033f8c3-7e0b-4118-aa1d-76c550f2978d?v=full',
},
],
},
Expand Down
1,308 changes: 654 additions & 654 deletions __mocks__/visit-notes.mock.ts

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions __mocks__/visits.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/patient/b835eff8-98c9-4988-887b-d93da7fbd542',
uri: 'http://backend:8080/openmrs/restBaseUrl/patient/b835eff8-98c9-4988-887b-d93da7fbd542',
resourceAlias: 'patient',
},
],
Expand All @@ -381,7 +381,7 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/form/9e1a0c68-ca19-3482-9ffb-0a6b4e591c2a',
uri: 'http://backend:8080/openmrs/restBaseUrl/form/9e1a0c68-ca19-3482-9ffb-0a6b4e591c2a',
resourceAlias: 'form',
},
],
Expand All @@ -392,7 +392,7 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/encountertype/dd528487-82a5-4082-9c72-ed246bd49591',
uri: 'http://backend:8080/openmrs/restBaseUrl/encountertype/dd528487-82a5-4082-9c72-ed246bd49591',
resourceAlias: 'encountertype',
},
],
Expand All @@ -404,7 +404,7 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/obs/04d7d2a2-8ffd-418c-9a0c-1d20dec50231',
uri: 'http://backend:8080/openmrs/restBaseUrl/obs/04d7d2a2-8ffd-418c-9a0c-1d20dec50231',
resourceAlias: 'obs',
},
],
Expand All @@ -415,7 +415,7 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/obs/5ca0c815-2c47-4cda-8c46-1e118b593ea8',
uri: 'http://backend:8080/openmrs/restBaseUrl/obs/5ca0c815-2c47-4cda-8c46-1e118b593ea8',
resourceAlias: 'obs',
},
],
Expand All @@ -429,12 +429,12 @@ export const mockEncounters2 = [
links: [
{
rel: 'self',
uri: 'http://backend:8080/openmrs/ws/rest/v1/encounter/3b4daf81-7372-475c-ba5d-13c9c21d8ab1',
uri: 'http://backend:8080/openmrs/restBaseUrl/encounter/3b4daf81-7372-475c-ba5d-13c9c21d8ab1',
resourceAlias: 'encounter',
},
{
rel: 'full',
uri: 'http://backend:8080/openmrs/ws/rest/v1/encounter/3b4daf81-7372-475c-ba5d-13c9c21d8ab1?v=full',
uri: 'http://backend:8080/openmrs/restBaseUrl/encounter/3b4daf81-7372-475c-ba5d-13c9c21d8ab1?v=full',
resourceAlias: 'encounter',
},
],
Expand Down
2 changes: 1 addition & 1 deletion e2e/core/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function globalSetup() {
const token = Buffer.from(`${process.env.E2E_USER_ADMIN_USERNAME}:${process.env.E2E_USER_ADMIN_PASSWORD}`).toString(
'base64',
);
await requestContext.post(`${process.env.E2E_BASE_URL}/ws/rest/v1/session`, {
await requestContext.post(`${process.env.E2E_BASE_URL}/restBaseUrl/session`, {
data: {
sessionLocation: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID,
locale: 'en',
Expand Down
4 changes: 2 additions & 2 deletions 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 All @@ -15,7 +15,7 @@ import { APIRequestContext, PlaywrightWorkerArgs, WorkerFixture } from '@playwri
*/
export const api: WorkerFixture<APIRequestContext, PlaywrightWorkerArgs> = async ({ playwright }, use) => {
const ctx = await playwright.request.newContext({
baseURL: `${process.env.E2E_BASE_URL}/ws/rest/v1/`,
baseURL: `${process.env.E2E_BASE_URL}/restBaseUrl/`,
httpCredentials: {
username: process.env.E2E_USER_ADMIN_USERNAME,
password: process.env.E2E_USER_ADMIN_PASSWORD,
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-engine-app/src/hooks/useFormSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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 +107,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 +196,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 +206,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('/restBaseUrl/form/form-uuid?v=full');
}));

it('should make API call with correct URL when getFormMetaDataByUuid is invoked with v', fakeAsync(() => {
Expand All @@ -50,7 +50,7 @@ describe('FormResourceService Unit Tests', () => {

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

it('should return a form object when getFormMetaDataByUuid is invoked without v', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-entry-app/src/app/window-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export class WindowRef {
}

get openmrsRestBase(): string {
return this.nativeWindow.openmrsBase + '/ws/rest/v1/';
return this.nativeWindow.openmrsBase + '/restBaseUrl/';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useMemo } from 'react';
import { type FetchResponse, openmrsFetch, showSnackbar } from '@openmrs/esm-framework';
import { type TreeNode } from '../filter/filter-types';

const restBaseUrl = '/ws/rest/v1';
const restBaseUrl = '/restBaseUrl/';

function computeTrendlineData(treeNode: TreeNode): Array<TreeNode> {
const tests: Array<TreeNode> = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-medications-app/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type DrugOrderBasketItem } from '../types';

export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';

const restBaseUrl = '/ws/rest/v1';
const restBaseUrl = '/restBaseUrl/';

/**
* SWR-based data fetcher for patient orders.
Expand Down
12 changes: 6 additions & 6 deletions packages/esm-patient-orders-app/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useMutatePatientOrders(patientUuid: string) {
const mutateOrders = useCallback(
() =>
mutate((key) => {
return typeof key === 'string' && key.startsWith(`/ws/rest/v1/order?patient=${patientUuid}`);
return typeof key === 'string' && key.startsWith(`/restBaseUrl/order?patient=${patientUuid}`);
}),
[patientUuid, mutate],
);
Expand All @@ -29,14 +29,14 @@ export function useMutatePatientOrders(patientUuid: string) {
}

export function getPatientEncounterId(patientUuid: string, abortController: AbortController) {
return openmrsFetch(`/ws/rest/v1/encounter?patient=${patientUuid}&order=desc&limit=1&v=custom:(uuid)`, {
return openmrsFetch(`/restBaseUrl/encounter?patient=${patientUuid}&order=desc&limit=1&v=custom:(uuid)`, {
signal: abortController.signal,
});
}

export function getMedicationByUuid(abortController: AbortController, orderUuid: string) {
return openmrsFetch(
`/ws/rest/v1/order/${orderUuid}?v=custom:(uuid,route:(uuid,display),action,urgency,display,drug:(display,strength),frequency:(display),dose,doseUnits:(display),orderer,dateStopped,dateActivated,previousOrder,numRefills,duration,durationUnits:(display),dosingInstructions)`,
`/restBaseUrl/order/${orderUuid}?v=custom:(uuid,route:(uuid,display),action,urgency,display,drug:(display,strength),frequency:(display),dose,doseUnits:(display),orderer,dateStopped,dateActivated,previousOrder,numRefills,duration,durationUnits:(display),dosingInstructions)`,
{
signal: abortController.signal,
},
Expand Down Expand Up @@ -71,7 +71,7 @@ export function createEmptyEncounter(
obs: [],
};

return openmrsFetch<OpenmrsResource>('/ws/rest/v1/encounter', {
return openmrsFetch<OpenmrsResource>('/restBaseUrl/encounter', {
headers: {
'Content-Type': 'application/json',
},
Expand All @@ -82,7 +82,7 @@ export function createEmptyEncounter(
}

export function postOrder(body: OrderPost, abortController?: AbortController) {
return openmrsFetch(`/ws/rest/v1/order`, {
return openmrsFetch(`/restBaseUrl/order`, {
method: 'POST',
signal: abortController?.signal,
headers: { 'Content-Type': 'application/json' },
Expand All @@ -103,7 +103,7 @@ export function useOrderEncounter(patientUuid: string): {
const nowDateString = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
const todayEncounter = useSWR<FetchResponse<{ results: Array<OpenmrsResource> }>, Error>(
!isLoadingSystemVisitSetting && !systemVisitEnabled && patientUuid
? `/ws/rest/v1/encounter?patient=${patientUuid}&fromdate=${nowDateString}&limit=1`
? `/restBaseUrl/encounter?patient=${patientUuid}&fromdate=${nowDateString}&limit=1`
: null,
openmrsFetch,
);
Expand Down

0 comments on commit b91b610

Please sign in to comment.