@openmrs/esm-stock-management-app 1.0.1-pre.348 → 1.0.1-pre.352

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ interface FHIRResponse {
41
41
 
42
42
  // getLocations
43
43
  export function useStockLocations(filter: LocationFilterCriteria) {
44
- const apiUrl = `ws/rest/v1/location${toQueryParams(filter, false)}`;
44
+ const apiUrl = `${restBaseUrl}/location${toQueryParams(filter, false)}`;
45
45
  const { data, error, isLoading } = useSWR<
46
46
  {
47
47
  data: PageableResult<OpenMRSLocation>;
@@ -76,7 +76,7 @@ export function useStockTagLocations() {
76
76
 
77
77
  // getLocationWithIdByUuid
78
78
  export function useLocationWithIdByUuid(id: string) {
79
- const apiUrl = `ws/rest/v1/stockmanagement/location/${id}`;
79
+ const apiUrl = `${restBaseUrl}/stockmanagement/location/${id}`;
80
80
  const { data, error, isLoading } = useSWR<
81
81
  {
82
82
  data: PageableResult<OpenMRSLocation>;
@@ -92,7 +92,7 @@ export function useLocationWithIdByUuid(id: string) {
92
92
 
93
93
  // deleteLocation
94
94
  export function deleteLocation(id: string) {
95
- const apiUrl = `ws/rest/v1/stockmanagement/location/${id}`;
95
+ const apiUrl = `${restBaseUrl}/stockmanagement/location/${id}`;
96
96
  const abortController = new AbortController();
97
97
  return openmrsFetch(apiUrl, {
98
98
  method: "DELETE",
@@ -105,7 +105,7 @@ export function deleteLocation(id: string) {
105
105
 
106
106
  // getLocationTags
107
107
  export function useLocationTags(q: string) {
108
- const apiUrl = `ws/rest/v1/locationtag?v=default${
108
+ const apiUrl = `${restBaseUrl}/locationtag?v=default${
109
109
  q && q.length > 0 ? "&q=" + encodeURIComponent(q) : ""
110
110
  }`;
111
111
  const { data, error, isLoading } = useSWR<
@@ -123,7 +123,7 @@ export function useLocationTags(q: string) {
123
123
 
124
124
  // getRoles
125
125
  export function useRoles(filter: ResourceFilterCriteria) {
126
- const apiUrl = `ws/rest/v1/role${toQueryParams(filter)}`;
126
+ const apiUrl = `${restBaseUrl}/role${toQueryParams(filter)}`;
127
127
  const { data, error, isLoading } = useSWR<
128
128
  {
129
129
  data: PageableResult<Role>;
@@ -139,7 +139,7 @@ export function useRoles(filter: ResourceFilterCriteria) {
139
139
 
140
140
  // getStockOperationTypes
141
141
  export function useStockOperationTypes() {
142
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationtype?v=default`;
142
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationtype?v=default`;
143
143
  const { data, isLoading, error } = useSWR<
144
144
  {
145
145
  data: PageableResult<StockOperationType>;
@@ -156,13 +156,13 @@ export function useStockOperationTypes() {
156
156
  export function getStockOperationTypes(): Promise<
157
157
  FetchResponse<PageableResult<StockOperationType>>
158
158
  > {
159
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationtype?v=default`;
159
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationtype?v=default`;
160
160
  return openmrsFetch(apiUrl);
161
161
  }
162
162
 
163
163
  // getUsers
164
164
  export function useUsers(filter: UserFilterCriteria) {
165
- const apiUrl = `ws/rest/v1/user${toQueryParams(filter)}`;
165
+ const apiUrl = `${restBaseUrl}/user${toQueryParams(filter)}`;
166
166
  const { data, error, isLoading } = useSWR<
167
167
  {
168
168
  data: PageableResult<User>;
@@ -178,7 +178,7 @@ export function useUsers(filter: UserFilterCriteria) {
178
178
 
179
179
  // getUser
180
180
  export function useUser(id: string) {
181
- const apiUrl = `ws/rest/v1/user${id}`;
181
+ const apiUrl = `${restBaseUrl}/user${id}`;
182
182
  const { data, error, isLoading } = useSWR<
183
183
  {
184
184
  data: User;
@@ -193,7 +193,7 @@ export function useUser(id: string) {
193
193
  }
194
194
 
195
195
  export function useConcept(conceptUuid: string) {
196
- const apiUrl = `ws/rest/v1/concept/${conceptUuid}`;
196
+ const apiUrl = `${restBaseUrl}/concept/${conceptUuid}`;
197
197
  const { data, error, isLoading } = useSWR<
198
198
  {
199
199
  data: Concept;
@@ -209,7 +209,7 @@ export function useConcept(conceptUuid: string) {
209
209
 
210
210
  // getParties
211
211
  export function useParties() {
212
- const apiUrl = `ws/rest/v1/stockmanagement/party?v=default`;
212
+ const apiUrl = `${restBaseUrl}/stockmanagement/party?v=default`;
213
213
  const { data, error, isLoading } = useSWR<
214
214
  {
215
215
  data: PageableResult<Party>;
@@ -224,13 +224,13 @@ export function useParties() {
224
224
  }
225
225
 
226
226
  export function getParties(): Promise<FetchResponse<PageableResult<Party>>> {
227
- const apiUrl = `ws/rest/v1/stockmanagement/party?v=default`;
227
+ const apiUrl = `${restBaseUrl}/stockmanagement/party?v=default`;
228
228
  return openmrsFetch(apiUrl);
229
229
  }
230
230
 
231
231
  // getDrugs
232
232
  export function useDrugs(filter: DrugFilterCriteria) {
233
- const apiUrl = `ws/rest/v1/drug${toQueryParams(filter)}`;
233
+ const apiUrl = `${restBaseUrl}/drug${toQueryParams(filter)}`;
234
234
  const { data, error, isLoading } = useSWR<
235
235
  {
236
236
  data: PageableResult<Drug>;
@@ -246,7 +246,7 @@ export function useDrugs(filter: DrugFilterCriteria) {
246
246
 
247
247
  // getConcepts
248
248
  export function useConcepts(filter: ConceptFilterCriteria) {
249
- const apiUrl = `ws/rest/v1/concept${toQueryParams(filter)}`;
249
+ const apiUrl = `${restBaseUrl}/concept${toQueryParams(filter)}`;
250
250
  const { data, error, isLoading } = useSWR<
251
251
  {
252
252
  data: PageableResult<Concept>;
@@ -262,7 +262,7 @@ export function useConcepts(filter: ConceptFilterCriteria) {
262
262
 
263
263
  // getPatients
264
264
  export function usePatients(filter: ConceptFilterCriteria) {
265
- const apiUrl = `ws/rest/v1/patient${toQueryParams(filter)}`;
265
+ const apiUrl = `${restBaseUrl}/patient${toQueryParams(filter)}`;
266
266
  const { data, error, isLoading } = useSWR<
267
267
  {
268
268
  data: PageableResult<Patient>;
@@ -1,4 +1,8 @@
1
- import { FetchResponse, openmrsFetch } from "@openmrs/esm-framework";
1
+ import {
2
+ FetchResponse,
3
+ openmrsFetch,
4
+ restBaseUrl,
5
+ } from "@openmrs/esm-framework";
2
6
  import useSWR from "swr";
3
7
  import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
4
8
  import { PageableResult } from "../core/api/types/PageableResult";
@@ -34,7 +38,7 @@ export interface StockItemInventoryFilter extends ResourceFilterCriteria {
34
38
 
35
39
  // getStockOperations
36
40
  export function useStockOperations(filter: StockOperationFilter) {
37
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation${toQueryParams(
41
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation${toQueryParams(
38
42
  filter
39
43
  )}`;
40
44
  const { data, error, isLoading } = useSWR<
@@ -51,7 +55,7 @@ export function useStockOperations(filter: StockOperationFilter) {
51
55
 
52
56
  // getStockOperationLinks
53
57
  export function useStockOperationLinks(filter: string) {
54
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationlink?v=default&q=${filter}`;
58
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationlink?v=default&q=${filter}`;
55
59
  const { data, error, isLoading } = useSWR<
56
60
  { data: PageableResult<StockOperationLinkDTO> },
57
61
  Error
@@ -65,7 +69,7 @@ export function useStockOperationLinks(filter: string) {
65
69
 
66
70
  // getStockOperation
67
71
  export function useStockOperation(id: string) {
68
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation/${id}`;
72
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation/${id}`;
69
73
  const { data, error, isLoading } = useSWR<{ data: StockOperationDTO }, Error>(
70
74
  apiUrl,
71
75
  openmrsFetch
@@ -79,14 +83,14 @@ export function useStockOperation(id: string) {
79
83
  export function getStockOperation(
80
84
  id: string
81
85
  ): Promise<FetchResponse<StockOperationDTO>> {
82
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation/${id}?v=full`;
86
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation/${id}?v=full`;
83
87
 
84
88
  return openmrsFetch(apiUrl);
85
89
  }
86
90
 
87
91
  // getStockOperationAndItems
88
92
  export function useStockOperationAndItems(id: string) {
89
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation/${id}?v=full`;
93
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation/${id}?v=full`;
90
94
  const { data, error, isLoading } = useSWR<{ data: StockOperationDTO }, Error>(
91
95
  apiUrl,
92
96
  openmrsFetch
@@ -108,7 +112,7 @@ export function deleteStockOperations(ids: string[]) {
108
112
  if (otherIds.length > 0) {
109
113
  otherIds = "?ids=" + otherIds;
110
114
  }
111
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation/${ids[0]}${otherIds}`;
115
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation/${ids[0]}${otherIds}`;
112
116
  const abortController = new AbortController();
113
117
  return openmrsFetch(apiUrl, {
114
118
  method: "DELETE",
@@ -121,7 +125,7 @@ export function deleteStockOperations(ids: string[]) {
121
125
 
122
126
  // deleteStockOperationItem
123
127
  export function deleteStockOperationItem(id: string) {
124
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationitem/${id}`;
128
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationitem/${id}`;
125
129
  const abortController = new AbortController();
126
130
  return openmrsFetch(apiUrl, {
127
131
  method: "DELETE",
@@ -134,7 +138,7 @@ export function deleteStockOperationItem(id: string) {
134
138
 
135
139
  // createStockOperation
136
140
  export function createStockOperation(item: StockOperationDTO) {
137
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation`;
141
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation`;
138
142
  const abortController = new AbortController();
139
143
  return openmrsFetch(apiUrl, {
140
144
  method: "POST",
@@ -148,7 +152,7 @@ export function createStockOperation(item: StockOperationDTO) {
148
152
 
149
153
  // updateStockOperation
150
154
  export function updateStockOperation(item: StockOperationDTO) {
151
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperation/${item.uuid}`;
155
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperation/${item.uuid}`;
152
156
  const abortController = new AbortController();
153
157
  return openmrsFetch(apiUrl, {
154
158
  method: "POST",
@@ -162,7 +166,7 @@ export function updateStockOperation(item: StockOperationDTO) {
162
166
 
163
167
  // executeStockOperationAction
164
168
  export function executeStockOperationAction(item: StopOperationAction) {
165
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationaction`;
169
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationaction`;
166
170
  const abortController = new AbortController();
167
171
  return openmrsFetch(apiUrl, {
168
172
  method: "POST",
@@ -179,7 +183,7 @@ export function updateStockOperationBatchNumbers(
179
183
  item: StockOperationDTO,
180
184
  uuid: string
181
185
  ) {
182
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationbatchnumbers/${uuid}`;
186
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationbatchnumbers/${uuid}`;
183
187
  const abortController = new AbortController();
184
188
  return openmrsFetch(apiUrl, {
185
189
  method: "POST",
@@ -193,7 +197,7 @@ export function updateStockOperationBatchNumbers(
193
197
 
194
198
  // get stock operation itemcosts
195
199
  export function getStockOperationItemsCost(filter: StockOperationFilter) {
196
- const apiUrl = `ws/rest/v1/stockmanagement/stockoperationitemcost?v=default&stockOperationUuid=${filter}`;
200
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationitemcost?v=default&stockOperationUuid=${filter}`;
197
201
  const abortController = new AbortController();
198
202
  return openmrsFetch(apiUrl, {
199
203
  method: "GET",
@@ -205,7 +209,7 @@ export function getStockOperationItemsCost(filter: StockOperationFilter) {
205
209
  }
206
210
  // get stockiteminvoentory
207
211
  export function getStockItemInventory(filter: StockItemInventoryFilter) {
208
- const apiUrl = `ws/rest/v1/stockmanagement/stockiteminventory${toQueryParams(
212
+ const apiUrl = `${restBaseUrl}/stockmanagement/stockiteminventory${toQueryParams(
209
213
  filter
210
214
  )}`;
211
215
  const abortController = new AbortController();
@@ -1,9 +1,8 @@
1
- import React, { useMemo } from "react";
1
+ import React, { useCallback, useMemo } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import {
4
4
  DataTable,
5
5
  DataTableSkeleton,
6
- Link,
7
6
  TabPanel,
8
7
  Pagination,
9
8
  Table,
@@ -17,14 +16,44 @@ import {
17
16
  TableToolbarContent,
18
17
  TableToolbarSearch,
19
18
  Tile,
19
+ Button,
20
20
  } from "@carbon/react";
21
- import styles from "./stock-reports.scss";
22
21
  import { isDesktop } from "@openmrs/esm-framework";
23
-
24
22
  import NewReportActionButton from "./new-report-button.component";
23
+ import styles from "./stock-reports.scss";
24
+ import { useGetReports } from "../stock-reports.resource";
25
+ import { URL_BATCH_JOB_ARTIFACT } from "../../constants";
26
+ import { formatDisplayDateTime } from "../../core/utils/datetimeUtils";
27
+ import {
28
+ BatchJobStatusCancelled,
29
+ BatchJobStatusCompleted,
30
+ BatchJobStatusExpired,
31
+ BatchJobStatusFailed,
32
+ BatchJobStatusPending,
33
+ BatchJobStatusRunning,
34
+ } from "../../core/api/types/BatchJob";
35
+ import {
36
+ CheckmarkOutline,
37
+ Copy,
38
+ Download,
39
+ IncompleteCancel,
40
+ MisuseOutline,
41
+ View,
42
+ WarningAltFilled,
43
+ } from "@carbon/react/icons";
25
44
 
26
45
  const StockReports: React.FC = () => {
27
46
  const { t } = useTranslation();
47
+ const {
48
+ reports,
49
+ isLoading,
50
+ currentPage,
51
+ pageSizes,
52
+ totalItems,
53
+ goTo,
54
+ currentPageSize,
55
+ setPageSize,
56
+ } = useGetReports();
28
57
  const tableHeaders = useMemo(
29
58
  () => [
30
59
  {
@@ -40,8 +69,8 @@ const StockReports: React.FC = () => {
40
69
  },
41
70
  {
42
71
  id: 2,
43
- header: t("DateRequested", "Date Requested"),
44
- key: "DateRequested",
72
+ header: t("dateRequested", "Date Requested"),
73
+ key: "dateRequested",
45
74
  },
46
75
  {
47
76
  id: 3,
@@ -62,9 +91,112 @@ const StockReports: React.FC = () => {
62
91
  []
63
92
  );
64
93
 
94
+ const onDownloadReportClick = useCallback(
95
+ (uuid: string, fileExit: string | undefined | null) => {
96
+ if (uuid) {
97
+ window.open(URL_BATCH_JOB_ARTIFACT(uuid, true), "_blank");
98
+ }
99
+ },
100
+ []
101
+ );
102
+
65
103
  const tableRows = useMemo(() => {
66
- return [];
67
- }, []);
104
+ return reports?.map((batchJob, index) => ({
105
+ ...batchJob,
106
+ checkbox: "isBatchJobActive",
107
+ id: batchJob?.uuid,
108
+ key: `key-${batchJob?.uuid}`,
109
+ uuid: `${batchJob?.uuid}`,
110
+ batchJobType: batchJob.batchJobType,
111
+ dateRequested: formatDisplayDateTime(batchJob.dateCreated),
112
+ parameters: "",
113
+ report: batchJob.description,
114
+ requestedBy: batchJob?.owners?.map((p, index) => (
115
+ <div
116
+ key={`${batchJob.uuid}-owner-${index}`}
117
+ >{`${p.ownerFamilyName} ${p.ownerGivenName}`}</div>
118
+ )),
119
+ status: (
120
+ <>
121
+ {batchJob.status === BatchJobStatusFailed && (
122
+ <WarningAltFilled
123
+ className="report-failed"
124
+ title={batchJob.status}
125
+ />
126
+ )}
127
+ {batchJob.status === BatchJobStatusCancelled && (
128
+ <MisuseOutline
129
+ className="report-cancelled"
130
+ title={batchJob.status}
131
+ />
132
+ )}
133
+ {batchJob.status === BatchJobStatusCompleted && (
134
+ <CheckmarkOutline
135
+ className="report-completed"
136
+ title={batchJob.status}
137
+ size={16}
138
+ />
139
+ )}
140
+ {batchJob.status === BatchJobStatusExpired && (
141
+ <IncompleteCancel
142
+ className="report-expired"
143
+ title={batchJob.status}
144
+ />
145
+ )}
146
+ </>
147
+ ),
148
+ actions: (
149
+ <div
150
+ key={`${batchJob?.uuid}-actions`}
151
+ style={{ display: "inline-block", whiteSpace: "nowrap" }}
152
+ >
153
+ {batchJob.outputArtifactViewable &&
154
+ batchJob.batchJobType === "hide" && (
155
+ <Button
156
+ key={`${batchJob?.uuid}-actions-view`}
157
+ type="button"
158
+ size="sm"
159
+ className="submitButton clear-padding-margin"
160
+ iconDescription={"Edit"}
161
+ kind="ghost"
162
+ renderIcon={View}
163
+ // onClick={(e) => onViewItem(batchJob.uuid, e)}
164
+ />
165
+ )}
166
+ <Button
167
+ type="button"
168
+ size="sm"
169
+ className="submitButton clear-padding-margin"
170
+ iconDescription={"Copy"}
171
+ kind="ghost"
172
+ renderIcon={Copy}
173
+ // onClick={() => onCloneReportClick(batchJob.uuid)}
174
+ />
175
+ {batchJob?.status === BatchJobStatusCompleted &&
176
+ (batchJob.outputArtifactSize ?? 0) > 0 && (
177
+ <Button
178
+ type="button"
179
+ size="sm"
180
+ className="submitButton clear-padding-margin"
181
+ iconDescription={"Download"}
182
+ kind="ghost"
183
+ renderIcon={Download}
184
+ onClick={() =>
185
+ onDownloadReportClick(
186
+ batchJob.uuid,
187
+ batchJob.outputArtifactFileExt
188
+ )
189
+ }
190
+ />
191
+ )}
192
+ </div>
193
+ ),
194
+ }));
195
+ }, [reports, onDownloadReportClick]);
196
+
197
+ if (isLoading) {
198
+ return <DataTableSkeleton role="progressbar" />;
199
+ }
68
200
 
69
201
  return (
70
202
  <div className={styles.tableOverride}>
@@ -76,7 +208,7 @@ const StockReports: React.FC = () => {
76
208
  <div className="right-filters"></div>
77
209
  </div>
78
210
  <DataTable
79
- rows={tableRows ?? []}
211
+ rows={tableRows}
80
212
  headers={tableHeaders}
81
213
  isSortable={true}
82
214
  useZebraStyles={true}
@@ -165,6 +297,21 @@ const StockReports: React.FC = () => {
165
297
  </TableContainer>
166
298
  )}
167
299
  ></DataTable>
300
+ <Pagination
301
+ page={currentPage}
302
+ pageSize={currentPageSize}
303
+ pageSizes={pageSizes}
304
+ totalItems={totalItems}
305
+ onChange={({ pageSize, page }) => {
306
+ if (pageSize !== currentPageSize) {
307
+ setPageSize(pageSize);
308
+ }
309
+ if (page !== currentPage) {
310
+ goTo(page);
311
+ }
312
+ }}
313
+ className={styles.paginationOverride}
314
+ />
168
315
  </div>
169
316
  );
170
317
  };
@@ -1,6 +1,11 @@
1
- import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
1
+ import {
2
+ openmrsFetch,
3
+ restBaseUrl,
4
+ usePagination,
5
+ } from "@openmrs/esm-framework";
2
6
  import useSWR from "swr";
3
7
  import { ReportType } from "./ReportType";
8
+ import { useState } from "react";
4
9
 
5
10
  export function useReportTypes() {
6
11
  const apiUrl = `${restBaseUrl}/stockmanagement/report?v=default`;
@@ -14,3 +19,31 @@ export function useReportTypes() {
14
19
  isError: error,
15
20
  };
16
21
  }
22
+ export function useGetReports() {
23
+ const apiUrl = `${restBaseUrl}/stockmanagement/batchjob?batchJobType=Report&v=default&limit=10&totalCount=true`;
24
+ const { data, error, isLoading } = useSWR<{ data: { results: any } }, Error>(
25
+ apiUrl,
26
+ openmrsFetch
27
+ );
28
+ const pageSizes = [10, 20, 30, 40, 50];
29
+ const [currentPageSize, setPageSize] = useState(10);
30
+
31
+ const {
32
+ goTo,
33
+ results: paginatedItems,
34
+ currentPage,
35
+ } = usePagination(data?.data?.results, currentPageSize);
36
+ return {
37
+ reports: data?.data?.results ?? [],
38
+ isLoading,
39
+ isError: error,
40
+ items: paginatedItems,
41
+ totalItems: data?.data?.results?.length,
42
+ currentPage,
43
+ currentPageSize,
44
+ paginatedItems,
45
+ goTo,
46
+ pageSizes,
47
+ setPageSize,
48
+ };
49
+ }
@@ -1,4 +1,4 @@
1
- import { openmrsFetch } from "@openmrs/esm-framework";
1
+ import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
2
2
  import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
3
3
  import useSWR from "swr";
4
4
  import { PageableResult } from "../core/api/types/PageableResult";
@@ -10,7 +10,7 @@ export interface StockSourceFilter extends ResourceFilterCriteria {
10
10
 
11
11
  // getStockSources
12
12
  export function useStockSources(filter: StockSourceFilter) {
13
- const apiUrl = `ws/rest/v1/stockmanagement/stocksource${toQueryParams(
13
+ const apiUrl = `${restBaseUrl}/stockmanagement/stocksource${toQueryParams(
14
14
  filter
15
15
  )}`;
16
16
 
@@ -28,7 +28,7 @@ export function useStockSources(filter: StockSourceFilter) {
28
28
 
29
29
  // getStockSource
30
30
  export function useStockSource(id: string) {
31
- const apiUrl = `ws/rest/v1/stockmanagement/stocksource/${id}`;
31
+ const apiUrl = `${restBaseUrl}/stockmanagement/stocksource/${id}`;
32
32
  const { data, error, isLoading } = useSWR<{ data: StockSource }, Error>(
33
33
  apiUrl,
34
34
  openmrsFetch
@@ -50,7 +50,7 @@ export function deleteStockSource(ids: string[]) {
50
50
  if (otherIds.length > 0) {
51
51
  otherIds = "?ids=" + otherIds;
52
52
  }
53
- const apiUrl = `ws/rest/v1/stockmanagement/stocksource/${ids[0]}${otherIds}`;
53
+ const apiUrl = `${restBaseUrl}/stockmanagement/stocksource/${ids[0]}${otherIds}`;
54
54
  const abortController = new AbortController();
55
55
  return openmrsFetch(apiUrl, {
56
56
  method: "DELETE",
@@ -65,7 +65,7 @@ export function deleteStockSource(ids: string[]) {
65
65
  export function createOrUpdateStockSource(item: StockSource) {
66
66
  const isNew = item.uuid != null;
67
67
 
68
- const apiUrl = `ws/rest/v1/stockmanagement/stocksource${
68
+ const apiUrl = `${restBaseUrl}/stockmanagement/stocksource${
69
69
  isNew ? "/" + item.uuid : ""
70
70
  }`;
71
71
  const abortController = new AbortController();
@@ -2,13 +2,13 @@ import useSWR from "swr";
2
2
  import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
3
3
  import { PageableResult } from "../core/api/types/PageableResult";
4
4
  import { UserRoleScope } from "../core/api/types/identity/UserRoleScope";
5
- import { openmrsFetch } from "@openmrs/esm-framework";
5
+ import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
6
6
 
7
7
  export type UserRoleScopeFilter = ResourceFilterCriteria;
8
8
 
9
9
  // getUserRoleScopes
10
10
  export function useUserRoleScopes(filter: UserRoleScopeFilter) {
11
- const apiUrl = `ws/rest/v1/stockmanagement/userrolescope${toQueryParams(
11
+ const apiUrl = `${restBaseUrl}/stockmanagement/userrolescope${toQueryParams(
12
12
  filter
13
13
  )}`;
14
14
  const { data, error, isLoading } = useSWR<
@@ -24,7 +24,7 @@ export function useUserRoleScopes(filter: UserRoleScopeFilter) {
24
24
 
25
25
  // getUserRoleScope
26
26
  export function useUserRoleScope(id: string) {
27
- const apiUrl = `ws/rest/v1/stockmanagement/userrolescope/${id}`;
27
+ const apiUrl = `${restBaseUrl}/stockmanagement/userrolescope/${id}`;
28
28
  const { data, error, isLoading } = useSWR<{ data: UserRoleScope }, Error>(
29
29
  apiUrl,
30
30
  openmrsFetch
@@ -46,7 +46,7 @@ export function deleteUserRoleScopes(ids: string[]) {
46
46
  if (otherIds.length > 0) {
47
47
  otherIds = "?ids=" + otherIds;
48
48
  }
49
- const apiUrl = `ws/rest/v1/stockmanagement/userrolescope/${ids[0]}${otherIds}`;
49
+ const apiUrl = `${restBaseUrl}/stockmanagement/userrolescope/${ids[0]}${otherIds}`;
50
50
  const abortController = new AbortController();
51
51
 
52
52
  return openmrsFetch(apiUrl, {
@@ -62,7 +62,7 @@ export function deleteUserRoleScopes(ids: string[]) {
62
62
  export function createOrUpdateUserRoleScope(item: UserRoleScope) {
63
63
  const abortController = new AbortController();
64
64
  const isNew = item.uuid != null;
65
- const apiUrl = `ws/rest/v1/stockmanagement/userrolescope${
65
+ const apiUrl = `${restBaseUrl}/stockmanagement/userrolescope${
66
66
  isNew ? "/" + item.uuid : ""
67
67
  }`;
68
68
  return openmrsFetch(apiUrl, {