@kenyaemr/esm-billing-app 5.4.7 → 5.4.8-pre.1663

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/1072.js +1 -1
  3. package/dist/1072.js.map +1 -1
  4. package/dist/2231.js +1 -1
  5. package/dist/2231.js.map +1 -1
  6. package/dist/2624.js +1 -1
  7. package/dist/2624.js.map +1 -1
  8. package/dist/2836.js +1 -0
  9. package/dist/2836.js.map +1 -0
  10. package/dist/301.js +1 -1
  11. package/dist/301.js.map +1 -1
  12. package/dist/3091.js +1 -1
  13. package/dist/3091.js.map +1 -1
  14. package/dist/3291.js +1 -0
  15. package/dist/3291.js.map +1 -0
  16. package/dist/3294.js +1 -1
  17. package/dist/3294.js.map +1 -1
  18. package/dist/3378.js +1 -1
  19. package/dist/3378.js.map +1 -1
  20. package/dist/3846.js +1 -0
  21. package/dist/3846.js.map +1 -0
  22. package/dist/4164.js +1 -0
  23. package/dist/4164.js.map +1 -0
  24. package/dist/5117.js +1 -1
  25. package/dist/5117.js.map +1 -1
  26. package/dist/5305.js +1 -0
  27. package/dist/5305.js.map +1 -0
  28. package/dist/5857.js +1 -0
  29. package/dist/5857.js.map +1 -0
  30. package/dist/6229.js +1 -0
  31. package/dist/6229.js.map +1 -0
  32. package/dist/6484.js +1 -0
  33. package/dist/6484.js.map +1 -0
  34. package/dist/6508.js +1 -1
  35. package/dist/6508.js.map +1 -1
  36. package/dist/6605.js +1 -1
  37. package/dist/6605.js.map +1 -1
  38. package/dist/7515.js +1 -1
  39. package/dist/7515.js.map +1 -1
  40. package/dist/8575.js +1 -0
  41. package/dist/8575.js.map +1 -0
  42. package/dist/9326.js +1 -1
  43. package/dist/9326.js.map +1 -1
  44. package/dist/9449.js +1 -1
  45. package/dist/9806.js +1 -1
  46. package/dist/9806.js.map +1 -1
  47. package/dist/9914.js +1 -0
  48. package/dist/9914.js.map +1 -0
  49. package/dist/kenyaemr-esm-billing-app.js +2 -2
  50. package/dist/kenyaemr-esm-billing-app.js.buildmanifest.json +278 -200
  51. package/dist/kenyaemr-esm-billing-app.js.map +1 -1
  52. package/dist/main.js +2 -2
  53. package/dist/main.js.map +1 -1
  54. package/dist/routes.json +1 -1
  55. package/package.json +3 -2
  56. package/src/billing-form/social-health-authority/type/index.ts +1 -0
  57. package/src/billing-tabs/billling-tabs.component.tsx +8 -1
  58. package/src/claims/claims-management/table/virtual-claim-preauth/utils/index.ts +3 -0
  59. package/src/claims/claims-wrap/claim-workspaces/attachements/claim-attachments-resource.ts +5 -2
  60. package/src/claims/claims-wrap/claim-workspaces/claim-submission/ClaimSubmitWorkspace.tsx +50 -12
  61. package/src/claims/claims-wrap/claim-workspaces/interventions/manage-interventions-workspace.tsx +1 -1
  62. package/src/claims/claims-wrap/claims-main-component.tsx +163 -33
  63. package/src/claims/claims-wrap/claims-main.resource.ts +12 -0
  64. package/src/claims/claims-wrap/claims-main.scss +16 -0
  65. package/src/claims/claims-wrap/type/index.ts +3 -0
  66. package/src/claims/overseas-referrals/overseas-referral-details.scss +13 -0
  67. package/src/claims/overseas-referrals/overseas-referral-details.workspace.tsx +85 -0
  68. package/src/claims/overseas-referrals/overseas-referral-form.scss +107 -0
  69. package/src/claims/overseas-referrals/overseas-referral-form.workspace.tsx +840 -0
  70. package/src/claims/overseas-referrals/overseas-referrals.component.tsx +336 -0
  71. package/src/claims/overseas-referrals/overseas-referrals.resource.test.ts +164 -0
  72. package/src/claims/overseas-referrals/overseas-referrals.resource.tsx +367 -0
  73. package/src/claims/overseas-referrals/overseas-referrals.scss +78 -0
  74. package/src/claims/overseas-referrals/overseas-referrals.utils.ts +31 -0
  75. package/src/claims/overseas-referrals/pending-referrals.component.tsx +337 -0
  76. package/src/claims/overseas-referrals/pending-referrals.test.tsx +157 -0
  77. package/src/claims/overseas-referrals/simple-table.component.tsx +83 -0
  78. package/src/index.ts +10 -0
  79. package/src/routes.json +10 -0
  80. package/src/visits/visits.resource.ts +15 -5
  81. package/translations/am.json +75 -0
  82. package/translations/en.json +78 -1
  83. package/translations/fr.json +75 -0
  84. package/translations/sw.json +75 -0
  85. package/dist/1187.js +0 -1
  86. package/dist/1187.js.map +0 -1
  87. package/dist/1346.js +0 -1
  88. package/dist/1346.js.map +0 -1
  89. package/dist/2034.js +0 -1
  90. package/dist/2034.js.map +0 -1
  91. package/dist/4156.js +0 -1
  92. package/dist/4156.js.map +0 -1
  93. package/dist/4266.js +0 -1
  94. package/dist/4266.js.map +0 -1
  95. package/dist/4818.js +0 -1
  96. package/dist/4818.js.map +0 -1
  97. package/dist/8332.js +0 -1
  98. package/dist/8332.js.map +0 -1
@@ -0,0 +1,367 @@
1
+ import { openmrsFetch, type FetchResponse } from '@openmrs/esm-framework';
2
+ import dayjs from 'dayjs';
3
+ import useSWR from 'swr';
4
+ import { virtualClaimBaseUrl } from '../claims-management/table/virtual-claim-preauth/constants';
5
+
6
+ /**
7
+ * The backend proxies these straight to Savannah (SHA) and returns its body unchanged.
8
+ *
9
+ * PROVISIONAL: no sample response was available when this was written, so the field names below are a best guess.
10
+ * Correct them against a real response; the list reads them in one place, `toOverseasReferralRow` in the component.
11
+ */
12
+ export interface OverseasReferral {
13
+ guid: string;
14
+ referral_number?: string;
15
+ beneficiary_id?: string;
16
+ beneficiary_name?: string;
17
+ intervention_code?: string;
18
+ intervention_name?: string;
19
+ destination_country?: string;
20
+ destination_facility?: string;
21
+ status?: string;
22
+ date_created?: string;
23
+ }
24
+
25
+ /** PROVISIONAL, see {@link OverseasReferral}. */
26
+ export interface OverseasIntervention {
27
+ intervention_code: string;
28
+ intervention_name?: string;
29
+ }
30
+
31
+ /** A page of results; assumed to be `{ count, results }` like the other SHA list endpoints. */
32
+ export interface OverseasPage<T> {
33
+ count?: number;
34
+ results?: Array<T>;
35
+ }
36
+
37
+ export const overseasReferralsUrl = `${virtualClaimBaseUrl}/referrals/overseas`;
38
+
39
+ /** One page of the facility's overseas referrals. `page` is 1-based. */
40
+ export const fetchOverseasReferralsPage = async (page: number, pageSize: number) => {
41
+ const response = await openmrsFetch<OverseasPage<OverseasReferral>>(
42
+ `${overseasReferralsUrl}?page=${page}&page_size=${pageSize}`,
43
+ );
44
+ return { results: response.data?.results ?? [], count: response.data?.count ?? 0 };
45
+ };
46
+
47
+ const FETCH_PAGE_SIZE = 100;
48
+ /** A guard against a response whose count never stops growing; 50 pages of 100 is far more than a facility has. */
49
+ const MAX_PAGES = 50;
50
+
51
+ /** Every page of the facility's overseas referrals, fetched page by page until the count is reached. */
52
+ export const fetchAllOverseasReferrals = async (): Promise<Array<OverseasReferral>> => {
53
+ const referrals: Array<OverseasReferral> = [];
54
+ for (let page = 1; page <= MAX_PAGES; page++) {
55
+ const { results, count } = await fetchOverseasReferralsPage(page, FETCH_PAGE_SIZE);
56
+ referrals.push(...results);
57
+ if (results.length < FETCH_PAGE_SIZE || referrals.length >= count) {
58
+ break;
59
+ }
60
+ }
61
+ return referrals;
62
+ };
63
+
64
+ /**
65
+ * All of the facility's overseas referrals, i.e. those submitted to SHA. The backend filters by neither status nor
66
+ * date, so the date filter works on the full list in the browser.
67
+ */
68
+ export const useAllOverseasReferrals = () => {
69
+ const { data, error, isLoading, isValidating, mutate } = useSWR<Array<OverseasReferral>>(
70
+ `${overseasReferralsUrl}?all`,
71
+ fetchAllOverseasReferrals,
72
+ );
73
+ return { referrals: data ?? [], error, isLoading, isValidating, mutate };
74
+ };
75
+
76
+ /** A patient a clinician recorded Type of Referral = Overseas for, on any form; from OpenMRS observations. */
77
+ export interface PendingOverseasReferral {
78
+ patient_uuid: string;
79
+ name: string;
80
+ gender: string;
81
+ age: number | null;
82
+ birthdate: string | null;
83
+ identifiers: Array<{ identifier: string; type: string; type_uuid: string }>;
84
+ obs_uuid: string;
85
+ /** e.g. `2026-11-20T10:15:00+0300`; parse with {@link parseObsDatetime}. */
86
+ obs_datetime: string | null;
87
+ location: string | null;
88
+ encounter_uuid: string | null;
89
+ encounter_type: string | null;
90
+ form: string | null;
91
+ visit_uuid: string | null;
92
+ /** Where the patient is in the overseas referral workflow. */
93
+ stage: OverseasReferralStage;
94
+ /** The latest claim episode's consent token (authorization code), when there is a claim. */
95
+ consent_token: string | null;
96
+ beneficiary_guid: string | null;
97
+ claim_uuid: string | null;
98
+ claim_state: string | null;
99
+ service_type: string | null;
100
+ invoice_number: string | null;
101
+ overseas_referral_guid: string | null;
102
+ overseas_referral_submitted_at: string | null;
103
+ }
104
+
105
+ /**
106
+ * The workflow stages, in order: flagged with no claim; elective preauth only, patient not checked in; visit claim
107
+ * not submitted; claim submitted, so the referral can be sent; referral sent. OTHER is a claim in some other state.
108
+ */
109
+ export const OVERSEAS_REFERRAL_STAGES = [
110
+ 'NO_CLAIM',
111
+ 'AWAITING_VISIT',
112
+ 'CLAIM_NOT_SUBMITTED',
113
+ 'READY_FOR_REFERRAL',
114
+ 'REFERRAL_SUBMITTED',
115
+ 'OTHER',
116
+ ] as const;
117
+
118
+ export type OverseasReferralStage = (typeof OVERSEAS_REFERRAL_STAGES)[number];
119
+
120
+ interface PendingOverseasReferralsResponse {
121
+ success: boolean;
122
+ total: number;
123
+ limit: number;
124
+ offset: number;
125
+ results: Array<PendingOverseasReferral>;
126
+ }
127
+
128
+ /** The backend's dates have an offset without a colon (`+0300`), which not every browser's `Date` parses. */
129
+ export const parseObsDatetime = (value?: string | null): Date | null => {
130
+ if (!value) {
131
+ return null;
132
+ }
133
+ const date = new Date(value.replace(/([+-]\d{2})(\d{2})$/, '$1:$2'));
134
+ return Number.isNaN(date.getTime()) ? null : date;
135
+ };
136
+
137
+ export interface PendingOverseasReferralsFilters {
138
+ fromDate?: Date | null;
139
+ toDate?: Date | null;
140
+ /** Only these stages; none means every stage but REFERRAL_SUBMITTED, which needs `includeSubmitted`. */
141
+ stages?: Array<OverseasReferralStage>;
142
+ includeSubmitted?: boolean;
143
+ }
144
+
145
+ /** The query for one page of pending referrals; `page` is 1-based. */
146
+ export const buildPendingReferralsQuery = (
147
+ { fromDate, toDate, stages = [], includeSubmitted = false }: PendingOverseasReferralsFilters,
148
+ page: number,
149
+ pageSize: number,
150
+ ) => {
151
+ const params = new URLSearchParams({ limit: String(pageSize), offset: String((page - 1) * pageSize) });
152
+ if (fromDate) {
153
+ params.set('from_date', dayjs(fromDate).format('YYYY-MM-DD'));
154
+ }
155
+ if (toDate) {
156
+ params.set('to_date', dayjs(toDate).format('YYYY-MM-DD'));
157
+ }
158
+ if (stages.length) {
159
+ params.set('stage', stages.join(','));
160
+ }
161
+ if (includeSubmitted) {
162
+ params.set('include_submitted', 'true');
163
+ }
164
+ return params;
165
+ };
166
+
167
+ /**
168
+ * Patients flagged for an overseas referral, with their workflow stage, one page at a time. The dates filter on
169
+ * the date the patient was flagged, both inclusive.
170
+ */
171
+ export const usePendingOverseasReferrals = ({
172
+ page,
173
+ pageSize,
174
+ ...filters
175
+ }: PendingOverseasReferralsFilters & { page: number; pageSize: number }) => {
176
+ const params = buildPendingReferralsQuery(filters, page, pageSize);
177
+ const { data, error, isLoading, isValidating, mutate } = useSWR<FetchResponse<PendingOverseasReferralsResponse>>(
178
+ `${overseasReferralsUrl}/pending-referrals?${params}`,
179
+ openmrsFetch,
180
+ { keepPreviousData: true },
181
+ );
182
+ return {
183
+ pendingReferrals: data?.data?.results ?? [],
184
+ total: data?.data?.total ?? 0,
185
+ error,
186
+ isLoading,
187
+ isValidating,
188
+ mutate,
189
+ };
190
+ };
191
+
192
+ /** More than any facility's flagged patients, so one call covers them all while volumes are small. */
193
+ const STAGE_COUNTS_LIMIT = 1000;
194
+
195
+ /** How many flagged patients are at each stage, from one unfiltered call that includes submitted referrals. */
196
+ export const useOverseasReferralStageCounts = () => {
197
+ const params = buildPendingReferralsQuery({ includeSubmitted: true }, 1, STAGE_COUNTS_LIMIT);
198
+ const { data, error, isLoading, mutate } = useSWR<FetchResponse<PendingOverseasReferralsResponse>>(
199
+ `${overseasReferralsUrl}/pending-referrals?${params}`,
200
+ openmrsFetch,
201
+ );
202
+ const counts = (data?.data?.results ?? []).reduce<Partial<Record<OverseasReferralStage, number>>>(
203
+ (acc, row) => ({ ...acc, [row.stage]: (acc[row.stage] ?? 0) + 1 }),
204
+ {},
205
+ );
206
+ return { counts, error, isLoading, mutate };
207
+ };
208
+
209
+ /** The overseas interventions a beneficiary can be referred for. Fetches nothing until `beneficiary` is set. */
210
+ export const useOverseasReferralInterventions = (beneficiary?: string) => {
211
+ const url = beneficiary?.trim()
212
+ ? `${overseasReferralsUrl}/interventions?beneficiary=${encodeURIComponent(beneficiary.trim())}`
213
+ : null;
214
+ const { data, error, isLoading, mutate } = useSWR<
215
+ FetchResponse<OverseasPage<OverseasIntervention> | Array<OverseasIntervention>>
216
+ >(url, openmrsFetch);
217
+ // PROVISIONAL: accepts a bare array as well as `{ results }` until the response shape is confirmed.
218
+ const body = data?.data;
219
+ const interventions = (Array.isArray(body) ? body : body?.results) ?? [];
220
+ return { interventions, error, isLoading, mutate };
221
+ };
222
+
223
+ /**
224
+ * The only `urgency`, `admission_type` and caregiver `relationship` values SHA has confirmed so far. Add the rest
225
+ * once backend/SHA share the full lists; don't guess them.
226
+ */
227
+ export const OVERSEAS_URGENCIES = ['URGENT'] as const;
228
+ export const OVERSEAS_ADMISSION_TYPES = ['INPATIENT'] as const;
229
+ export const CAREGIVER_RELATIONSHIPS = ['SPOUSE'] as const;
230
+
231
+ /** The documents an overseas referral is sent with, in the order they are offered for upload. */
232
+ export const OVERSEAS_REFERRAL_DOCUMENTS = [
233
+ { document_type: 'SHA_REFERRAL_FORM', document_title: 'SHA Referral Form' },
234
+ { document_type: 'KMPDC_REFERRAL_FORM', document_title: 'KMPDC Referral Form' },
235
+ { document_type: 'SPECIALIST_MEDICAL_REPORT', document_title: 'Specialist Medical Report' },
236
+ ] as const;
237
+
238
+ export interface OverseasReferralDoctor {
239
+ identification_number: string;
240
+ identification_type: 'registration_number';
241
+ regulation_body: string;
242
+ }
243
+
244
+ export interface OverseasReferralItem {
245
+ description: string;
246
+ unit_price: string;
247
+ quantity: string;
248
+ }
249
+
250
+ export interface OverseasReferralAttachment {
251
+ document_type: string;
252
+ document_title: string;
253
+ file: File;
254
+ }
255
+
256
+ /** A new overseas referral, in SHA's field names; built by the form and sent by {@link createOverseasReferral}. */
257
+ export interface NewOverseasReferral {
258
+ consent_token: string;
259
+ intervention_code: string;
260
+ urgency?: string;
261
+ admission_type?: string;
262
+ referral_reason?: string;
263
+ /** ISO-8601 with offset, e.g. `2026-12-01T08:00:00+03:00`. */
264
+ service_start?: string;
265
+ service_end?: string;
266
+ provider_notification_email?: string;
267
+ items: Array<OverseasReferralItem>;
268
+ referring_doctor?: OverseasReferralDoctor;
269
+ peer_reviewers: Array<OverseasReferralDoctor>;
270
+ clinical_information: {
271
+ diagnoses: Array<{ icd11_code: string; description: string }>;
272
+ planned_procedures: Array<{ procedure_code: string; description: string }>;
273
+ clinical_notes?: string;
274
+ };
275
+ caregiver?: { full_name: string; relationship: string; phone_number: string };
276
+ attachments: Array<OverseasReferralAttachment>;
277
+ }
278
+
279
+ /**
280
+ * The multipart body for `POST /referrals/overseas`. The structured fields go as JSON strings, not nested form fields.
281
+ * Files follow the preauth convention: each is appended under the repeated `attachments_files` field in the same
282
+ * order as the `attachments` metadata, which carries no `file_field_name`, as the backend assigns it.
283
+ */
284
+ export const buildOverseasReferralFormData = (referral: NewOverseasReferral): FormData => {
285
+ const form = new FormData();
286
+ const appendText = (name: string, value?: string) => {
287
+ if (value?.trim()) {
288
+ form.append(name, value.trim());
289
+ }
290
+ };
291
+
292
+ appendText('consent_token', referral.consent_token);
293
+ appendText('intervention_code', referral.intervention_code);
294
+ appendText('urgency', referral.urgency);
295
+ appendText('admission_type', referral.admission_type);
296
+ appendText('referral_reason', referral.referral_reason);
297
+ appendText('service_start', referral.service_start);
298
+ appendText('service_end', referral.service_end);
299
+ appendText('provider_notification_email', referral.provider_notification_email);
300
+
301
+ if (referral.items.length) {
302
+ form.append('items', JSON.stringify(referral.items));
303
+ }
304
+ if (referral.referring_doctor) {
305
+ form.append('referring_doctor', JSON.stringify(referral.referring_doctor));
306
+ }
307
+ form.append('peer_reviewers', JSON.stringify(referral.peer_reviewers));
308
+ form.append('clinical_information', JSON.stringify(referral.clinical_information));
309
+ if (referral.caregiver) {
310
+ form.append('caregiver', JSON.stringify(referral.caregiver));
311
+ }
312
+
313
+ if (referral.attachments.length) {
314
+ form.append(
315
+ 'attachments',
316
+ JSON.stringify(
317
+ referral.attachments.map(({ document_type, document_title }) => ({ document_type, document_title })),
318
+ ),
319
+ );
320
+ referral.attachments.forEach(({ file }) => form.append('attachments_files', file));
321
+ }
322
+ return form;
323
+ };
324
+
325
+ interface CreateOverseasReferralResponse {
326
+ success?: boolean;
327
+ error?: string;
328
+ referral?: OverseasReferral;
329
+ /** The new referral's SHA guid; also recorded on the claim, which takes the patient off the Pending tab. */
330
+ referral_guid?: string | null;
331
+ /** How many claims of the episode the referral was recorded on. */
332
+ claims_marked?: number;
333
+ upstream_error?: unknown;
334
+ }
335
+
336
+ /**
337
+ * Creates an overseas referral on SHA. The backend answers `{ success: true, referral }`, or `{ success: false,
338
+ * error, upstream_error }`, which is thrown with the body attached so `resolveShaError` can explain it.
339
+ */
340
+ export const createOverseasReferral = async (
341
+ referral: NewOverseasReferral,
342
+ idempotencyKey: string,
343
+ ): Promise<{ referral?: OverseasReferral; referralGuid: string | null }> => {
344
+ const response = await openmrsFetch<CreateOverseasReferralResponse>(overseasReferralsUrl, {
345
+ method: 'POST',
346
+ body: buildOverseasReferralFormData(referral),
347
+ headers: { 'Idempotency-Key': idempotencyKey },
348
+ });
349
+ if (response?.data?.success === false) {
350
+ const failure = new Error(response.data.error ?? 'Create overseas referral failed') as Error & {
351
+ responseBody?: unknown;
352
+ };
353
+ failure.responseBody = response.data;
354
+ throw failure;
355
+ }
356
+ return {
357
+ referral: response?.data?.referral,
358
+ referralGuid: response?.data?.referral_guid ?? response?.data?.referral?.guid ?? null,
359
+ };
360
+ };
361
+
362
+ /** One overseas referral by its Savannah guid. Fetches nothing until `guid` is set. */
363
+ export const useOverseasReferral = (guid?: string) => {
364
+ const url = guid ? `${overseasReferralsUrl}/${encodeURIComponent(guid)}` : null;
365
+ const { data, error, isLoading, mutate } = useSWR<FetchResponse<OverseasReferral>>(url, openmrsFetch);
366
+ return { referral: data?.data, error, isLoading, mutate };
367
+ };
@@ -0,0 +1,78 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/colors';
3
+
4
+ .container {
5
+ margin-top: layout.$spacing-03;
6
+ }
7
+
8
+ .tabsRow {
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ flex-wrap: wrap;
13
+ gap: layout.$spacing-03;
14
+ padding-right: layout.$spacing-05;
15
+ background-color: colors.$gray-10;
16
+ border-bottom: 1px solid colors.$gray-20;
17
+ }
18
+
19
+ .toolbar {
20
+ display: flex;
21
+ align-items: center;
22
+ gap: layout.$spacing-03;
23
+ padding: layout.$spacing-03 0;
24
+ }
25
+
26
+ .tagCount {
27
+ margin-left: layout.$spacing-03;
28
+ }
29
+
30
+ .tabPanel {
31
+ padding: 0;
32
+ }
33
+
34
+ .pending {
35
+ display: flex;
36
+ flex-direction: column;
37
+ }
38
+
39
+ .stageCounts {
40
+ display: flex;
41
+ flex-wrap: wrap;
42
+ gap: layout.$spacing-03;
43
+ padding: layout.$spacing-04 layout.$spacing-05 0;
44
+ }
45
+
46
+ .filters {
47
+ display: flex;
48
+ align-items: flex-end;
49
+ flex-wrap: wrap;
50
+ gap: layout.$spacing-06;
51
+ padding: layout.$spacing-04 layout.$spacing-05;
52
+ }
53
+
54
+ .stageFilter {
55
+ min-width: 16rem;
56
+ }
57
+
58
+ .actionGroup {
59
+ display: flex;
60
+ align-items: center;
61
+ gap: layout.$spacing-02;
62
+ }
63
+
64
+ .secondaryText {
65
+ color: colors.$gray-60;
66
+ }
67
+
68
+ // Looks disabled but still takes hover and focus, so its tooltip can explain why.
69
+ .ariaDisabled {
70
+ color: colors.$gray-50;
71
+ cursor: not-allowed;
72
+
73
+ &:hover,
74
+ &:focus {
75
+ background-color: transparent;
76
+ color: colors.$gray-50;
77
+ }
78
+ }
@@ -0,0 +1,31 @@
1
+ import { launchWorkspace2, navigate, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+ import { spaBasePath } from '../../constants';
3
+
4
+ export const OVERSEAS_REFERRAL_FORM_WORKSPACE = 'overseas-referral-form-workspace';
5
+ export const OVERSEAS_REFERRAL_DETAILS_WORKSPACE = 'overseas-referral-details-workspace';
6
+ export const CLAIM_SUBMISSION_WORKSPACE = 'claim-submission-workspace';
7
+
8
+ /** Opens the referral's details, as SHA has them, by its guid. */
9
+ export const launchOverseasReferralDetails = (referralGuid: string) =>
10
+ launchWorkspace2(OVERSEAS_REFERRAL_DETAILS_WORKSPACE, { referralGuid });
11
+
12
+ /**
13
+ * Opens the claims page of the patient's most recent open (PENDING) bill. The claims page is reached through a bill,
14
+ * not a claim, so this is how a claim with no invoice yet is opened to finish billing. Resolves to whether a bill
15
+ * was found.
16
+ */
17
+ export const openPatientClaims = async (patientUuid: string): Promise<boolean> => {
18
+ const params = new URLSearchParams({ patientUuid, status: 'PENDING', v: 'custom:(uuid,dateCreated)' });
19
+ const { data } = await openmrsFetch<{ results: Array<{ uuid: string; dateCreated: string }> }>(
20
+ `${restBaseUrl}/cashier/bill?${params}`,
21
+ );
22
+ const latest = (data?.results ?? []).reduce<{ uuid: string; dateCreated: string } | null>(
23
+ (current, bill) => (!current || new Date(bill.dateCreated) > new Date(current.dateCreated) ? bill : current),
24
+ null,
25
+ );
26
+ if (!latest) {
27
+ return false;
28
+ }
29
+ navigate({ to: `${spaBasePath}/accounting/patient/${patientUuid}/${latest.uuid}/claims` });
30
+ return true;
31
+ };