Skip to content

Commit

Permalink
(refactor)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 27, 2024
1 parent c8bfa67 commit c981c38
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { openmrsFetch } from "@openmrs/esm-framework";
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
import useSWR from "swr";

export interface EncounterResponse {
Expand Down Expand Up @@ -276,7 +276,7 @@ export interface Encounter {
}

export function useGetEncounterById(encounterUuid: string) {
const apiUrl = `/ws/rest/v1/encounter/${encounterUuid}?v=full`;
const apiUrl = `${restBaseUrl}/encounter/${encounterUuid}?v=full`;
const { data, error, isLoading } = useSWR<{ data: EncounterResponse }, Error>(
apiUrl,
openmrsFetch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDate, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { formatDate, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/patient-chart/patient-laboratory-order-results.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·formatDate,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··formatDate,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`
import useSWR from "swr";

export interface LaboratoryResponse {
Expand Down Expand Up @@ -461,7 +461,7 @@ export function usePatientLaboratoryOrders(filter: LaboratoryOrderFilter) {
const config = useConfig();
const { laboratoryEncounterTypeUuid } = config;

const apiUrl = `/ws/rest/v1/encounter?patient=${filter.patientUuid}&encounterType=${laboratoryEncounterTypeUuid}&v=${filter.v}&totalCount=true`;
const apiUrl = `${restBaseUrl}/encounter?patient=${filter.patientUuid}&encounterType=${laboratoryEncounterTypeUuid}&v=${filter.v}&totalCount=true`;
const { data, error, isLoading } = useSWR<
{ data: LaboratoryResponse },
Error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { openmrsFetch } from "@openmrs/esm-framework";
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
import { ObsMetaInfo } from "@openmrs/esm-patient-common-lib";

import useSWR from "swr";
Expand Down Expand Up @@ -161,7 +161,7 @@ export function assessValue(
}

export function useGetConceptById(conceptUuid: string) {
const apiUrl = `/ws/rest/v1/concept/${conceptUuid}?v=full`;
const apiUrl = `${restBaseUrl}/concept/${conceptUuid}?v=full`;
const { data, error, isLoading } = useSWR<{ data: ConceptResponse }, Error>(
apiUrl,
openmrsFetch
Expand All @@ -176,7 +176,7 @@ export function useGetConceptById(conceptUuid: string) {
export async function GetPatientByUuid(uuid: string) {
const abortController = new AbortController();

return openmrsFetch(`/ws/rest/v1/patient/${uuid}`, {
return openmrsFetch(`${restBaseUrl}/patient/${uuid}`, {
headers: {
"Content-Type": "application/json",
},
Expand Down
4 changes: 2 additions & 2 deletions src/patient-chart/results-summary/results/results.resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/patient-chart/results-summary/results/results.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`
import useSWR from "swr";

export interface LabTestResultResponse {
Expand Down Expand Up @@ -36,7 +36,7 @@ export interface Link {
}

export function useGetLabEncounterTests(encounterUuid: string) {
const apiUrl = `/ws/rest/v1/encountertestresults?encounterUuid=${encounterUuid}`;
const apiUrl = `${restBaseUrl}/encountertestresults?encounterUuid=${encounterUuid}`;

const { data, error, isLoading } = useSWR<
{ data: LabTestResultResponse },
Expand Down
14 changes: 7 additions & 7 deletions src/queue-list/lab-dialogs/add-to-worklist-dialog.resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/queue-list/lab-dialogs/add-to-worklist-dialog.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`
import { useMemo } from "react";
import useSWR from "swr";
import useSWRImmutable from "swr/immutable";
Expand Down Expand Up @@ -83,7 +83,7 @@ export interface ParentLocation {

// get queue rooms
export function useQueueRoomLocations(currentQueueLocation: string) {
const apiUrl = `/ws/rest/v1/location/${currentQueueLocation}?v=full`;
const apiUrl = `${restBaseUrl}/location/${currentQueueLocation}?v=full`;
const { data, error, isLoading } = useSWR<{ data: QueueRoomsResponse }>(
apiUrl,
openmrsFetch
Expand All @@ -106,7 +106,7 @@ export function useQueueRoomLocations(currentQueueLocation: string) {
export function useReferralLocations() {
const config = useConfig();
const { laboratoryReferalDestinationUuid } = config;
const apiUrl = `/ws/rest/v1/concept/${laboratoryReferalDestinationUuid}`;
const apiUrl = `${restBaseUrl}/concept/${laboratoryReferalDestinationUuid}`;
const { data, error, isLoading } = useSWRImmutable<FetchResponse>(
apiUrl,
openmrsFetch
Expand All @@ -123,7 +123,7 @@ export function useSpecimenTypes() {
const config = useConfig();
const { laboratorySpecimenTypeConcept } = config;

const apiUrl = `/ws/rest/v1/concept/${laboratorySpecimenTypeConcept}`;
const apiUrl = `${restBaseUrl}/concept/${laboratorySpecimenTypeConcept}`;
const { data, error, isLoading } = useSWRImmutable<FetchResponse>(
apiUrl,
openmrsFetch
Expand All @@ -147,7 +147,7 @@ export function useSpecimenTypes() {
// generate specimen id
export async function GenerateSpecimenId(uuid: string) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/generatesampleId?uuid=${uuid}`, {
return openmrsFetch(`${restBaseUrl}/generatesampleId?uuid=${uuid}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand All @@ -159,7 +159,7 @@ export async function GenerateSpecimenId(uuid: string) {
// update Order
export async function UpdateOrder(uuid: string, body: any) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/accessionorder/${uuid}`, {
return openmrsFetch(`${restBaseUrl}/accessionorder/${uuid}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -171,7 +171,7 @@ export async function UpdateOrder(uuid: string, body: any) {

export async function GetOrderByUuid(uuid: string) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/order/${uuid}`, {
return openmrsFetch(`${restBaseUrl}/order/${uuid}`, {
headers: {
"Content-Type": "application/json",
},
Expand Down
4 changes: 2 additions & 2 deletions src/queue-list/lab-tests/lab-tests.resource.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/queue-list/lab-tests/lab-tests.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`
import useSWR from "swr";
import { EncounterResponse } from "../../patient-chart/laboratory-item/view-laboratory-item.resource";
export function useGetLabOrders(encounterUuid: string) {
const apiUrl = `/ws/rest/v1/encounter/${encounterUuid}?v=full`;
const apiUrl = `${restBaseUrl}/encounter/${encounterUuid}?v=full`;

const { data, error, isLoading } = useSWR<{ data: EncounterResponse }, Error>(
apiUrl,
Expand Down
4 changes: 2 additions & 2 deletions src/queue-list/laboratory-patient-list.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PatientQueue, UuidDisplay } from "../types/patient-queues";
import dayjs from "dayjs";
import useSWR from "swr";

import { formatDate, openmrsFetch, parseDate } from "@openmrs/esm-framework";
import { formatDate, openmrsFetch, parseDate, restBaseUrl } from "@openmrs/esm-framework";

Check failure on line 5 in src/queue-list/laboratory-patient-list.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·formatDate,·openmrsFetch,·parseDate,·restBaseUrl·` with `⏎··formatDate,⏎··openmrsFetch,⏎··parseDate,⏎··restBaseUrl,⏎`

export interface MappedPatientQueueEntry {
id: string;
Expand All @@ -29,7 +29,7 @@ export function usePatientQueuesList(
currentQueueRoomLocationUuid: string,
status: string
) {
const apiUrl = `/ws/rest/v1/patientqueue?v=full&room=${currentQueueRoomLocationUuid}&status=${status}`;
const apiUrl = `${restBaseUrl}/patientqueue?v=full&room=${currentQueueRoomLocationUuid}&status=${status}`;
return usePatientQueueRequest(apiUrl);
}

Expand Down
4 changes: 2 additions & 2 deletions src/reject-order/reject-order-dialog.resource.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/reject-order/reject-order-dialog.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`

export async function RejectOrder(uuid: string, body: any) {
const abortController = new AbortController();

return openmrsFetch(`/ws/rest/v1/order/${uuid}/fulfillerdetails/`, {
return openmrsFetch(`${restBaseUrl}/order/${uuid}/fulfillerdetails/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
12 changes: 6 additions & 6 deletions src/results/result-form.resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { openmrsFetch } from "@openmrs/esm-framework";
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
import useSWR from "swr";

export interface ConceptResponse {
Expand Down Expand Up @@ -305,7 +305,7 @@ export interface ObPayload {
// get order concept
export async function GetOrderConceptByUuid(uuid: string) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/concept/${uuid}?v=full`, {
return openmrsFetch(`${restBaseUrl}/concept/${uuid}?v=full`, {
headers: {
"Content-Type": "application/json",
},
Expand All @@ -314,7 +314,7 @@ export async function GetOrderConceptByUuid(uuid: string) {
}

export function useGetOrderConceptByUuid(uuid: string) {
const apiUrl = `/ws/rest/v1/concept/${uuid}?v=custom:(uuid,display,name,datatype,set,answers,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units,setMembers:(uuid,display,answers,datatype,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units))`;
const apiUrl = `${restBaseUrl}/concept/${uuid}?v=custom:(uuid,display,name,datatype,set,answers,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units,setMembers:(uuid,display,answers,datatype,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units))`;

const { data, error, isLoading, isValidating, mutate } = useSWR<
{ data: ConceptResponse },
Expand All @@ -331,7 +331,7 @@ export function useGetOrderConceptByUuid(uuid: string) {

export async function UpdateEncounter(uuid: string, payload: any) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/encounter/${uuid}`, {
return openmrsFetch(`${restBaseUrl}/encounter/${uuid}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -348,7 +348,7 @@ export async function UpdateOrderResult(
orderPayload: any
) {
const abortController = new AbortController();
const updateOrderCall = await openmrsFetch(`/ws/rest/v1/order`, {
const updateOrderCall = await openmrsFetch(`${restBaseUrl}/order`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -358,7 +358,7 @@ export async function UpdateOrderResult(
});

if (updateOrderCall.status === 201) {
return await openmrsFetch(`/ws/rest/v1/encounter/${encounterUuid}`, {
return await openmrsFetch(`${restBaseUrl}/encounter/${encounterUuid}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
4 changes: 2 additions & 2 deletions src/review-list/dialog/review-item.resource.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FetchResponse, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl, useConfig } from "@openmrs/esm-framework";

Check failure on line 1 in src/review-list/dialog/review-item.resource.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl,·useConfig·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎··useConfig,⏎`

export async function ApproverOrder(body: any) {
const abortController = new AbortController();

return openmrsFetch(`/ws/rest/v1/approveorder`, {
return openmrsFetch(`${restBaseUrl}/approveorder`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
8 changes: 4 additions & 4 deletions src/summary-tiles/laboratory-summary.resource.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useSWR from "swr";
import useSWRImmutable from "swr/immutable";
import { FetchResponse, openmrsFetch } from "@openmrs/esm-framework";
import { FetchResponse, openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";

Check failure on line 3 in src/summary-tiles/laboratory-summary.resource.tsx

View workflow job for this annotation

GitHub Actions / build

Replace `·FetchResponse,·openmrsFetch,·restBaseUrl·` with `⏎··FetchResponse,⏎··openmrsFetch,⏎··restBaseUrl,⏎`
import { Result } from "../work-list/work-list.resource";

export function useMetrics() {
Expand All @@ -11,7 +11,7 @@ export function useMetrics() {
completed: 6,
};
const { data, error } = useSWR<{ data: { results: {} } }, Error>(
`/ws/rest/v1/queue?`,
`${restBaseUrl}/queue?`,
openmrsFetch
);

Expand All @@ -24,7 +24,7 @@ export function useMetrics() {

export function useServices() {
const serviceConceptSetUuid = "330c0ec6-0ac7-4b86-9c70-29d76f0ae20a";
const apiUrl = `/ws/rest/v1/concept/${serviceConceptSetUuid}`;
const apiUrl = `${restBaseUrl}/concept/${serviceConceptSetUuid}`;
const { data } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);

return {
Expand All @@ -36,7 +36,7 @@ export function useServices() {

// worklist
export function useLabTestsStats(fulfillerStatus: string) {
const apiUrl = `/ws/rest/v1/order?orderTypes=52a447d3-a64a-11e3-9aeb-50e549534c5e&isStopped=false&fulfillerStatus=${fulfillerStatus}&v=full
const apiUrl = `${restBaseUrl}/order?orderTypes=52a447d3-a64a-11e3-9aeb-50e549534c5e&isStopped=false&fulfillerStatus=${fulfillerStatus}&v=full
`;
const { data, error, isLoading } = useSWR<
{ data: { results: Array<Result> } },
Expand Down
4 changes: 2 additions & 2 deletions src/utils/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { openmrsFetch } from "@openmrs/esm-framework";
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
import useSWR from "swr";

export const trimVisitNumber = (visitNumber: string) => {
Expand Down Expand Up @@ -233,7 +233,7 @@ export interface Creator {
}

export function useGetPatientByUuid(uuid: string) {
const apiUrl = `/ws/rest/v1/patient/${uuid}?v=full`;
const apiUrl = `${restBaseUrl}/patient/${uuid}?v=full`;
const { data, error, isLoading } = useSWR<{ data: PatientResource }, Error>(
apiUrl,
openmrsFetch
Expand Down
4 changes: 2 additions & 2 deletions src/work-list/work-list.resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { openmrsFetch } from "@openmrs/esm-framework";
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
import useSWR from "swr";

export interface Result {
Expand Down Expand Up @@ -120,7 +120,7 @@ export function useGetOrdersWorklist(
activatedOnOrAfterDate: string,
fulfillerStatus: string
) {
const apiUrl = `/ws/rest/v1/order?orderTypes=52a447d3-a64a-11e3-9aeb-50e549534c5e&activatedOnOrAfterDate=${activatedOnOrAfterDate}&isStopped=false&fulfillerStatus=${fulfillerStatus}&v=full
const apiUrl = `${restBaseUrl}/order?orderTypes=52a447d3-a64a-11e3-9aeb-50e549534c5e&activatedOnOrAfterDate=${activatedOnOrAfterDate}&isStopped=false&fulfillerStatus=${fulfillerStatus}&v=full
`;

const { data, error, isLoading } = useSWR<
Expand Down

0 comments on commit c981c38

Please sign in to comment.