diff --git a/packages/esm-patient-banner-app/src/hooks/useCauseOfDeath.ts b/packages/esm-patient-banner-app/src/hooks/useCauseOfDeath.ts index 94089f3307..4750fabb99 100644 --- a/packages/esm-patient-banner-app/src/hooks/useCauseOfDeath.ts +++ b/packages/esm-patient-banner-app/src/hooks/useCauseOfDeath.ts @@ -1,6 +1,6 @@ import { useMemo } from 'react'; import useSWR from 'swr'; -import { openmrsFetch } from '@openmrs/esm-framework'; +import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; interface CauseOfDeathResponse { data: { @@ -13,7 +13,7 @@ interface CauseOfDeathResponse { export function useCauseOfDeath(patientUuid: string) { const customRepresentation = 'custom:(causeOfDeath:(display),causeOfDeathNonCoded)'; - const url = `/ws/rest/v1/person/${patientUuid}?v=${customRepresentation}`; + const url = `${restBaseUrl}/person/${patientUuid}?v=${customRepresentation}`; const { data, error } = useSWR(patientUuid ? url : null, openmrsFetch); diff --git a/packages/esm-patient-chart-app/src/visit/hooks/useVisitAttributeType.tsx b/packages/esm-patient-chart-app/src/visit/hooks/useVisitAttributeType.tsx index 46ed1516a7..363f5d9482 100644 --- a/packages/esm-patient-chart-app/src/visit/hooks/useVisitAttributeType.tsx +++ b/packages/esm-patient-chart-app/src/visit/hooks/useVisitAttributeType.tsx @@ -36,7 +36,7 @@ const visitAttributeTypeCustomRepresentation = export function useVisitAttributeTypes() { const { data, error, isLoading } = useSWRImmutable, Error>( - `/ws/rest/v1/visitattributetype?v=${visitAttributeTypeCustomRepresentation}`, + `${restBaseUrl}/visitattributetype?v=${visitAttributeTypeCustomRepresentation}`, openmrsFetch, ); diff --git a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.test.tsx b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.test.tsx index c76723ef7e..f3122affca 100644 --- a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.test.tsx +++ b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.test.tsx @@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event'; import { getDefaultsFromConfigSchema, openmrsFetch, + restBaseUrl, saveVisit, showSnackbar, updateVisit, @@ -347,13 +348,13 @@ describe('Visit form', () => { expect.any(Object), ); - expect(mockOpenmrsFetch).toHaveBeenCalledWith(`/ws/rest/v1/visit/${visitUuid}/attribute`, { + expect(mockOpenmrsFetch).toHaveBeenCalledWith(`${restBaseUrl}/visit/${visitUuid}/attribute`, { method: 'POST', headers: { 'Content-type': 'application/json' }, body: { attributeType: visitAttributes.punctuality.uuid, value: '66cdc0a1-aa19-4676-af51-80f66d78d9eb' }, }); - expect(mockOpenmrsFetch).toHaveBeenCalledWith(`/ws/rest/v1/visit/${visitUuid}/attribute`, { + expect(mockOpenmrsFetch).toHaveBeenCalledWith(`${restBaseUrl}/visit/${visitUuid}/attribute`, { method: 'POST', headers: { 'Content-type': 'application/json' }, body: { attributeType: visitAttributes.insurancePolicyNumber.uuid, value: '183299' }, @@ -417,7 +418,7 @@ describe('Visit form', () => { ); expect(mockOpenmrsFetch).toHaveBeenCalledWith( - `/ws/rest/v1/visit/${visitUuid}/attribute/c98e66d7-7db5-47ae-b46f-91a0f3b6dda1`, + `${restBaseUrl}/visit/${visitUuid}/attribute/c98e66d7-7db5-47ae-b46f-91a0f3b6dda1`, { method: 'POST', headers: { 'Content-type': 'application/json' }, @@ -426,7 +427,7 @@ describe('Visit form', () => { ); expect(mockOpenmrsFetch).toHaveBeenCalledWith( - `/ws/rest/v1/visit/${visitUuid}/attribute/d6d7d26a-5975-4f03-8abb-db073c948897`, + `${restBaseUrl}/visit/${visitUuid}/attribute/d6d7d26a-5975-4f03-8abb-db073c948897`, { method: 'POST', headers: { 'Content-type': 'application/json' }, @@ -490,12 +491,12 @@ describe('Visit form', () => { ); expect(mockOpenmrsFetch).toHaveBeenCalledWith( - `/ws/rest/v1/visit/${visitUuid}/attribute/c98e66d7-7db5-47ae-b46f-91a0f3b6dda1`, + `${restBaseUrl}/visit/${visitUuid}/attribute/c98e66d7-7db5-47ae-b46f-91a0f3b6dda1`, { method: 'DELETE' }, ); expect(mockOpenmrsFetch).toHaveBeenCalledWith( - `/ws/rest/v1/visit/${visitUuid}/attribute/d6d7d26a-5975-4f03-8abb-db073c948897`, + `${restBaseUrl}/visit/${visitUuid}/attribute/d6d7d26a-5975-4f03-8abb-db073c948897`, { method: 'DELETE' }, ); diff --git a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/useTestTypes.test.ts b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/useTestTypes.test.ts index aa5b20cb46..1769cf2ac9 100644 --- a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/useTestTypes.test.ts +++ b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/useTestTypes.test.ts @@ -1,7 +1,7 @@ import { useEffect, useRef, useState } from 'react'; import useSWRImmutable from 'swr/immutable'; import { renderHook, waitFor } from '@testing-library/react'; -import { getDefaultsFromConfigSchema, openmrsFetch, useConfig } from '@openmrs/esm-framework'; +import { getDefaultsFromConfigSchema, openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework'; import { type ConfigObject, configSchema } from '../../config-schema'; import { useTestTypes } from './useTestTypes'; @@ -43,7 +43,7 @@ describe('useTestTypes is configurable', () => { it('should return all test concepts when no labOrderableConcepts are provided', async () => { const { result } = renderHook(() => useTestTypes()); expect(mockOpenrsFetch).toHaveBeenCalledWith( - '/ws/rest/v1/concept?class=Test?v=custom:(display,names:(display),uuid,setMembers:(display,uuid,names:(display),setMembers:(display,uuid,names:(display))))', + `${restBaseUrl}/concept?class=Test?v=custom:(display,names:(display),uuid,setMembers:(display,uuid,names:(display),setMembers:(display,uuid,names:(display))))`, ); await waitFor(() => expect(result.current.isLoading).toBeFalsy()); expect(result.current.error).toBeFalsy(); @@ -54,7 +54,7 @@ describe('useTestTypes is configurable', () => { const { result } = renderHook(() => useTestTypes()); expect(mockOpenrsFetch).toHaveBeenCalledWith( expect.stringContaining( - '/ws/rest/v1/concept?class=Test?v=custom:(display,names:(display),uuid,setMembers:(display,uuid,names:(display),setMembers:(display,uuid,names:(display))))', + `${restBaseUrl}/concept?class=Test?v=custom:(display,names:(display),uuid,setMembers:(display,uuid,names:(display),setMembers:(display,uuid,names:(display))))`, ), ); await waitFor(() => expect(result.current.isLoading).toBeFalsy());