@ampath/esm-dha-workflow-app 4.0.0-claim-workflows.415 → 4.0.0-claim-workflows.417

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.
@@ -5,7 +5,7 @@ import ClaimInvoiceDetails from '../claim-invoice-details/claim-invoice-details.
5
5
  import ClaimInterventionDetails from '../claim-intervention-details/claim-intervention-details.component';
6
6
  import ClaimDiagnosisDetails from '../claim-diagnosis-details/claim-diagnosis-details.component';
7
7
  import { formatDate, launchWorkspace, parseDate, showSnackbar, useVisit } from '@openmrs/esm-framework';
8
- import { Button, InlineLoading, Tile } from '@carbon/react';
8
+ import { Button, InlineLoading, Modal, TextInput, Tile } from '@carbon/react';
9
9
  import CloseClaimModal from '../modal/close-claim/close-claim.modal';
10
10
  import SubmitClaimModal from '../modal/submit-claim/submit-claim.modal';
11
11
  import { endVisit, useInvalidateProviderClaimPreview, usePayerClaimPreview } from '../../../../billing-claims.resource';
@@ -13,11 +13,12 @@ import ClaimDocuments from '../claim-documents/claim-documents';
13
13
  import ClaimDoctors from '../claim-doctors/claim-doctors';
14
14
  import AddClaimDoctorModal from '../modal/claim-doctors/add-claim-doctor/add-claim-doctor.modal';
15
15
  import { VisitTypeUuids } from '../../../../../shared/constants/visit-types';
16
- import { VisitType } from '../../../../../claims';
16
+ import { type VisitType } from '../../../../../claims';
17
17
  import { canEditClaimContent } from '../../../v2/claim-statuses';
18
18
  import { interventionHasBlockingPreauth, usePreauthPreview } from '../../../../../claims/claims.resource';
19
19
  import PayerPreviewTile from '../payer-preview/payer-preview-tile.component';
20
20
  import { Renew } from '@carbon/react/icons';
21
+ import SubmitEmergencyClaimModal from '../modal/submit-emergency-claim/submit-emergency-claim.component';
21
22
 
22
23
  interface claimVisitDetailsProps {
23
24
  claimsVisit: ClaimsVisit;
@@ -41,6 +42,7 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
41
42
  const [showAddDoctorModal, setShowAddDoctorModal] = useState<boolean>(false);
42
43
  const [triggerEndVisit, setTriggerEndVisit] = useState<boolean>(false);
43
44
  const { activeVisit } = useVisit(patientBillDetails?.patient_uuid);
45
+ const [showSubmitEmergencyModal, setshowSubmitEmergencyModal] = useState<boolean>(false);
44
46
 
45
47
  const invoiceNumber = useMemo(() => {
46
48
  if (patientBillDetails) {
@@ -100,7 +102,11 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
100
102
  function handleCloseClaimModal() {
101
103
  setShowCloseClaimModal(false);
102
104
  }
103
- function displayCloseSubmitClaimModal() {
105
+ async function displayCloseSubmitClaimModal() {
106
+ if (claimsVisit.service_type === 'EMERGENCY') {
107
+ setshowSubmitEmergencyModal(true);
108
+ return;
109
+ }
104
110
  setSubmitCloseClaimModal(true);
105
111
  }
106
112
  function handleCloseSubmitClaimModal() {
@@ -173,7 +179,7 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
173
179
 
174
180
  const handleRefresh = () => {
175
181
  invalidateProviderClaimPreview();
176
- }
182
+ };
177
183
 
178
184
  return (
179
185
  <>
@@ -199,9 +205,7 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
199
205
  </div>
200
206
  </div>
201
207
 
202
- <Tile
203
- id="provider-preview"
204
- >
208
+ <Tile id="provider-preview">
205
209
  <div className={styles.tileHeader}>
206
210
  <dd>Provider preview</dd>
207
211
  <Button size="sm" kind="ghost" renderIcon={Renew} onClick={handleRefresh} disabled={claimRefreshing}>
@@ -338,6 +342,15 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
338
342
  consentToken={claimsVisit.authorization_code}
339
343
  />
340
344
  )}
345
+ {showSubmitEmergencyModal && (
346
+ <SubmitEmergencyClaimModal
347
+ consentToken={claimsVisit.authorization_code}
348
+ invoiceNumber={claimsVisit.invoices[0]?.invoice_number}
349
+ open={showSubmitEmergencyModal}
350
+ onClose={() => setshowSubmitEmergencyModal(false)}
351
+ locationUuid={locationUuid}
352
+ />
353
+ )}
341
354
  </>
342
355
  );
343
356
  };
@@ -0,0 +1,91 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import styles from './submit-emergency.scss';
4
+ import { InlineLoading, Modal, TextArea, TextInput } from '@carbon/react';
5
+ import { showSnackbar } from '@openmrs/esm-framework';
6
+ import { submitEmergencyClaim } from '../../../../../../registry/emergency/emergency.resource';
7
+
8
+ interface SubmitEmergencyClaimModalProps {
9
+ consentToken: string;
10
+ invoiceNumber: string;
11
+ open: boolean;
12
+ onClose: () => void;
13
+ locationUuid: string;
14
+ }
15
+
16
+ const SubmitEmergencyClaimModal: React.FC<SubmitEmergencyClaimModalProps> = ({
17
+ consentToken,
18
+ invoiceNumber,
19
+ open,
20
+ onClose,
21
+ locationUuid,
22
+ }) => {
23
+ const [reasonForUnknownPatient, setReasonForUnknownPatient] = useState('');
24
+ const [isSubmitting, setIsSubmitting] = useState(false);
25
+
26
+ async function postEmergencyClaim() {
27
+ if (isSubmitting) {
28
+ return;
29
+ }
30
+
31
+ setIsSubmitting(true);
32
+ try {
33
+ const res = await submitEmergencyClaim(
34
+ consentToken,
35
+ invoiceNumber,
36
+ locationUuid,
37
+ reasonForUnknownPatient.trim() || undefined,
38
+ );
39
+ if (res?.error) {
40
+ showSnackbar({
41
+ title: res['error'] ?? 'Error Submitting Claim',
42
+ kind: 'error',
43
+ subtitle: res['message'] ?? 'An error occurred while submitting the claim. Kindy retry or contact support',
44
+ });
45
+ return;
46
+ }
47
+
48
+ showSnackbar({
49
+ title: 'Success Submitting Claim',
50
+ kind: 'success',
51
+ subtitle: 'Claim submitted successfully',
52
+ });
53
+ onClose();
54
+ } finally {
55
+ setIsSubmitting(false);
56
+ }
57
+ }
58
+ return (
59
+ <>
60
+ <Modal
61
+ aria-label="Modal content"
62
+ modalHeading="Submit Emergency Claim"
63
+ onRequestClose={onClose}
64
+ onRequestSubmit={postEmergencyClaim}
65
+ onSecondarySubmit={onClose}
66
+ open={open}
67
+ primaryButtonDisabled={isSubmitting}
68
+ primaryButtonText={isSubmitting ? 'Submitting...' : 'Submit'}
69
+ secondaryButtonText="Cancel"
70
+ >
71
+ <div className={styles.addClaimLineModalRow}>
72
+ <TextInput id="invoice-number" labelText="Invoice Number" value={invoiceNumber} readOnly={true} />
73
+ </div>
74
+ {/* <div className={styles.addClaimLineModalRow}>
75
+ <TextInput id="consent-token" labelText="Consent Token" value={consentToken} readOnly={true} />
76
+ </div> */}
77
+ <div className={styles.addClaimLineModalRow}>
78
+ <TextArea
79
+ id="reason-for-unknown-patient"
80
+ labelText="Reason for unknown patient (Optional)"
81
+ value={reasonForUnknownPatient}
82
+ onChange={(event) => setReasonForUnknownPatient(event.target.value)}
83
+ />
84
+ </div>
85
+ {isSubmitting && <InlineLoading status="active" description="Submitting emergency claim..." />}
86
+ </Modal>
87
+ </>
88
+ );
89
+ };
90
+
91
+ export default SubmitEmergencyClaimModal;
@@ -0,0 +1,14 @@
1
+ .addClaimLineModalLayout{
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ row-gap: 10px;
6
+ width: 100%;
7
+ .addClaimLineModalRow{
8
+ display: flex;
9
+ flex-direction: row;
10
+ width: 100%;
11
+ column-gap: 5px;
12
+ padding: 5px 5px;
13
+ }
14
+ }
@@ -25,9 +25,9 @@ import { type TagColor } from 'src/types/types';
25
25
  interface facilityBillsProps {
26
26
  billingDate: string;
27
27
  locationUuid: string;
28
- onRefresh?: (value: string) => void;
28
+ onDateChange?: (value: string) => void;
29
29
  }
30
- const FacilityBillsV3: React.FC<facilityBillsProps> = ({ billingDate, locationUuid, onRefresh }) => {
30
+ const FacilityBillsV3: React.FC<facilityBillsProps> = ({ billingDate, locationUuid, onDateChange }) => {
31
31
  const [facilityBills, setFacilityBills] = useState<PatientBill[]>([]);
32
32
  const [currentView, setCurrentView] = useState<BillingView>(BillingView.Bills);
33
33
  const [selectedPatientUuid, setSelectedPatientUuid] = useState<string>('');
@@ -179,7 +179,6 @@ const FacilityBillsV3: React.FC<facilityBillsProps> = ({ billingDate, locationUu
179
179
  }
180
180
  function handleRefresh(){
181
181
  getFacilityBills();
182
- handleRefresh();
183
182
  }
184
183
 
185
184
  return (
@@ -1,9 +1,10 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Modal, ModalBody, TextInput } from '@carbon/react';
3
3
  import styles from './add-claim-line.modal.scss';
4
- import { type AddClaimLineDto, type PatientFacilityBillDetails } from '../../../types';
4
+ import { type AddProtocalDto, type AddClaimLineDto, type PatientFacilityBillDetails } from '../../../types';
5
5
  import { addClaimItem } from '../../../../../billing-claims.resource';
6
6
  import { showSnackbar } from '@openmrs/esm-framework';
7
+ import { addEmergencyProtocal } from '../../../../../../registry/emergency/emergency.resource';
7
8
 
8
9
  interface addClaimLineModalProps {
9
10
  open: boolean;
@@ -21,60 +22,105 @@ const AddClaimLineModal: React.FC<addClaimLineModalProps> = ({
21
22
  locationUuid,
22
23
  consentToken: consentTokenProp,
23
24
  }) => {
24
- const [loading,setLoading] = useState<boolean>(false);
25
+ const [loading, setLoading] = useState<boolean>(false);
26
+ const [unitPrice, setUnitPrice] = useState(String(billItem.item_price));
25
27
  async function handleAddClaimLineItem() {
26
28
  setLoading(true);
27
29
  const addClaimLineDto = getClaimLineDto();
28
- try{
29
- const resp = await addClaimItem(addClaimLineDto);
30
- if(resp['error']){
31
- showSnackbar({
32
- title: resp['error'] ?? 'Error Adding Claim Line',
33
- kind: 'error',
34
- subtitle: resp['message'] ?? 'An error occurred while adding the claim line. Kindy retry or contact support'
35
- })
36
- onSuccess();
37
- }else{
38
- showSnackbar({
39
- title: 'Sucess Adding Claim Line',
40
- kind: 'success',
41
- subtitle: 'Claim Item added successfully'
42
- });
43
- onSuccess();
44
- }
45
- }catch(error: any){
46
- showSnackbar({
30
+ try {
31
+ const resp = await addClaimItem(addClaimLineDto);
32
+ if (resp['error']) {
33
+ showSnackbar({
34
+ title: resp['error'] ?? 'Error Adding Claim Line',
35
+ kind: 'error',
36
+ subtitle: resp['message'] ?? 'An error occurred while adding the claim line. Kindy retry or contact support',
37
+ });
38
+ onSuccess();
39
+ } else {
40
+ showSnackbar({
41
+ title: 'Success Adding Claim Line',
42
+ kind: 'success',
43
+ subtitle: 'Claim Item added successfully',
44
+ });
45
+ onSuccess();
46
+ }
47
+ } catch (error: any) {
48
+ showSnackbar({
47
49
  kind: 'error',
48
50
  title: 'Error Adding Claim Line',
49
- subtitle: error ?? 'An error occurred while adding the claim line. Kindy retry or contact support'
50
- });
51
- }finally{
52
- setLoading(false);
51
+ subtitle: error ?? 'An error occurred while adding the claim line. Kindy retry or contact support',
52
+ });
53
+ } finally {
54
+ setLoading(false);
55
+ }
56
+ }
57
+
58
+ async function handleAddProtocal() {
59
+ setLoading(true);
60
+ const addProtocalDto = getProtocalDto();
61
+ try {
62
+ const resp = await addEmergencyProtocal(addProtocalDto);
63
+ if (resp['error']) {
64
+ showSnackbar({
65
+ title: resp['error'] ?? 'Error Adding Protocol',
66
+ kind: 'error',
67
+ subtitle: resp['message'] ?? 'An error occurred while adding the protocol. Kindy retry or contact support',
68
+ });
69
+ onSuccess();
70
+ } else {
71
+ showSnackbar({
72
+ title: 'Success Adding Protocol',
73
+ kind: 'success',
74
+ subtitle: 'Protocol added successfully',
75
+ });
76
+ onSuccess();
77
+ }
78
+ } catch (error: any) {
79
+ showSnackbar({
80
+ kind: 'error',
81
+ title: 'Error Adding Protocol',
82
+ subtitle: error ?? 'An error occurred while adding the protocol. Kindy retry or contact support',
83
+ });
84
+ } finally {
85
+ setLoading(false);
53
86
  }
54
87
  }
55
88
  function getClaimLineDto(): AddClaimLineDto {
56
89
  return {
57
90
  consentToken: (consentTokenProp || billItem.consent_token || '').trim(),
58
91
  interventionCode: billItem.intervention_code,
59
- unitPrice: String(billItem.item_price),
92
+ unitPrice,
60
93
  quantity: String(billItem.item_quantity),
61
94
  locationUuid: locationUuid,
62
95
  orderNo: String(billItem.order_no ?? ''),
63
96
  };
64
97
  }
65
- function holderFunction(){
98
+
99
+ function getProtocalDto(): AddProtocalDto {
100
+ return {
101
+ consentToken: (consentTokenProp || billItem.consent_token || '').trim(),
102
+ protocolCode: String(billItem.protocal_code ?? ''),
103
+ interventionCode: billItem.intervention_code,
104
+ unitPrice: Number(unitPrice),
105
+ quantity: billItem.item_quantity,
106
+ locationUuid: locationUuid,
107
+ };
108
+ }
109
+ function holderFunction() {
66
110
  return;
67
111
  }
112
+ const isEmergency = billItem.service_type === 'EMERGENCY';
113
+
68
114
  return (
69
115
  <>
70
116
  <Modal
71
- modalHeading="Add Claim Line"
117
+ modalHeading={isEmergency ? 'Add Protocol' : 'Add Claim Line'}
72
118
  open={open}
73
119
  size="md"
74
120
  onSecondarySubmit={onClose}
75
121
  onRequestClose={onClose}
76
- onRequestSubmit={loading ? holderFunction : handleAddClaimLineItem}
77
- primaryButtonText={loading ? 'Adding...': 'Add'}
122
+ onRequestSubmit={loading ? holderFunction : isEmergency ? handleAddProtocal : handleAddClaimLineItem}
123
+ primaryButtonText={loading ? 'Adding...' : isEmergency ? 'Add Protocol' : 'Add Claim Line'}
78
124
  secondaryButtonText="Close"
79
125
  >
80
126
  <ModalBody>
@@ -90,18 +136,16 @@ const AddClaimLineModal: React.FC<addClaimLineModalProps> = ({
90
136
  <div className={styles.addClaimLineModalRow}>
91
137
  <TextInput
92
138
  id="bill-item-amount"
93
- labelText="Unit Price"
94
- value={`Ksh ${billItem.item_price}`}
95
- readOnly={true}
139
+ labelText="Unit Price (Ksh)"
140
+ type="number"
141
+ min="0"
142
+ step="any"
143
+ value={unitPrice}
144
+ onChange={(event) => setUnitPrice(event.target.value)}
96
145
  />
97
146
  </div>
98
147
  <div className={styles.addClaimLineModalRow}>
99
- <TextInput
100
- id="bill-item-amount"
101
- labelText="Quantity"
102
- value={billItem.item_quantity}
103
- readOnly={true}
104
- />
148
+ <TextInput id="bill-item-amount" labelText="Quantity" value={billItem.item_quantity} readOnly={true} />
105
149
  </div>
106
150
  </div>
107
151
  </ModalBody>
@@ -58,6 +58,7 @@ export type PatientFacilityBillDetails = {
58
58
  requires_oncology_preauth?: boolean | number | string;
59
59
  requires_radiology_preauth?: boolean | number | string;
60
60
  requires_optical_preauth?: boolean | number | string;
61
+ protocal_code?: string;
61
62
  };
62
63
 
63
64
  export type PatientFacilityBillDetailsResponse = {
@@ -292,6 +293,17 @@ export type AddClaimLineDto = {
292
293
  preauthCode?: string;
293
294
  };
294
295
 
296
+ export type AddProtocalDto = {
297
+ consentToken: string;
298
+ interventionCode: string;
299
+ unitPrice: number;
300
+ quantity: number;
301
+ locationUuid: string;
302
+ protocolCode: string;
303
+ /** Best-effort; hie-saf may not forward yet */
304
+ preauthCode?: string;
305
+ };
306
+
295
307
  export type RemoveClaimLineDto = {
296
308
  consentToken: string;
297
309
  lineGuid: string;
@@ -394,7 +406,7 @@ export type PatientBillVisit = {
394
406
 
395
407
  export type ClaimsDashboardStatsDataResp = {
396
408
  result: ClaimsDashboardStatsData;
397
- }
409
+ };
398
410
 
399
411
  export type ClaimsDashboardStatsData = {
400
412
  draft: number | null;
@@ -416,7 +428,7 @@ export enum ClaimProviderStatus {
416
428
  TimeBarred = 'TIME_BARRED',
417
429
  Closed = 'CLOSED',
418
430
  Submitted = 'SUBMITTED',
419
- FailedToSubmit = 'FAILED_TO_SUBMIT'
431
+ FailedToSubmit = 'FAILED_TO_SUBMIT',
420
432
  }
421
433
  export enum ClaimPayerStatus {
422
434
  Paid = 'PAID',
@@ -424,11 +436,11 @@ export enum ClaimPayerStatus {
424
436
  Approved = 'APPROVED',
425
437
  SentForPaymentProcessing = 'SENT_FOR_PAYMENT_PROCESSING',
426
438
  Appealed = 'APPEALED',
427
- TimeBarred = 'TIME_BARRED'
439
+ TimeBarred = 'TIME_BARRED',
428
440
  }
429
441
  export enum ClaimServiceType {
430
442
  Capitation = 'CAPITATION',
431
443
  Inpatient = 'INPATIENT',
432
444
  OutPatient = 'OUTPATIENT',
433
- Emergency = 'EMERGENCY'
445
+ Emergency = 'EMERGENCY',
434
446
  }
@@ -1,5 +1,6 @@
1
- import { openmrsFetch } from '@openmrs/esm-framework';
1
+ import { openmrsFetch, showSnackbar } from '@openmrs/esm-framework';
2
2
  import { getEtlBaseUrl, getHieBaseUrl } from '../../shared/utils/get-base-url';
3
+ import { type AddProtocalDto } from '../../billing/dashboard/v3/types';
3
4
 
4
5
  export const fetchEmergencyInterventions = async () => {
5
6
  const hieBaseUrl = await getHieBaseUrl();
@@ -145,39 +146,24 @@ export async function fetchEmergencyProtocals(interventionCode: string, location
145
146
  return data;
146
147
  }
147
148
 
148
- export async function addEmergencyProtocal(
149
- consentToken: string,
150
- protocalCode: string,
151
- interventionCode: string,
152
- unitPrice: number,
153
- quantity: number,
154
- locationUuid: string,
155
- ): Promise<any> {
149
+ export async function addEmergencyProtocal(addProtocalDto: AddProtocalDto): Promise<any> {
156
150
  const hieBaseUrl = await getHieBaseUrl();
157
151
 
158
- const payload = {
159
- consentToken: [consentToken],
160
- protocalCode: protocalCode,
161
- interventionCode: interventionCode,
162
- unitPrice: unitPrice,
163
- quantity: quantity,
164
- locationUuid: locationUuid,
165
- };
166
- const url = `${hieBaseUrl}/emergency/claim/protocals`;
152
+ const url = `${hieBaseUrl}/emergency/claim/protocols`;
167
153
  const response = await openmrsFetch(url, {
168
154
  method: 'POST',
169
155
  headers: {
170
156
  Accept: 'application/json',
171
157
  'Content-Type': 'application/json',
172
158
  },
173
- body: JSON.stringify(payload),
159
+ body: JSON.stringify(addProtocalDto),
174
160
  });
175
161
 
176
162
  const data = await response.json();
177
163
 
178
164
  if (!response.ok) {
179
165
  const errorText = data.message || 'Failed to created claim protocal';
180
- throw new Error(`Request failed with ${response.status}: ${errorText}`);
166
+ return data;
181
167
  }
182
168
 
183
169
  return data;
@@ -249,18 +235,18 @@ export async function deleteEmergencyClaimDoctor(consentToken: string, locationU
249
235
  export async function submitEmergencyClaim(
250
236
  consentToken: string,
251
237
  invoiceNumber: string,
252
- reasonForUnknown: string,
253
238
  locationUuid: string,
239
+ reasonForUnknownPatient?: string,
254
240
  ): Promise<any> {
255
241
  const hieBaseUrl = await getHieBaseUrl();
256
242
 
257
243
  const payload = {
258
- consentToken: [consentToken],
259
- invoiceNumber: invoiceNumber,
260
- reasonForUnknown: reasonForUnknown,
261
- locationUuid: locationUuid,
244
+ consentToken,
245
+ invoiceNumber,
246
+ ...(reasonForUnknownPatient !== undefined && { reasonForUnknownPatient }),
247
+ locationUuid,
262
248
  };
263
- const url = `${hieBaseUrl}/emergency/claim/unidentified/submit`;
249
+ const url = `${hieBaseUrl}/claim/unidentified/submit`;
264
250
  const response = await openmrsFetch(url, {
265
251
  method: 'POST',
266
252
  headers: {
@@ -274,7 +260,7 @@ export async function submitEmergencyClaim(
274
260
 
275
261
  if (!response.ok) {
276
262
  const errorText = data.message || 'Failed to submit emergency claim';
277
- throw new Error(`Request failed with ${response.status}: ${errorText}`);
263
+ return data;
278
264
  }
279
265
 
280
266
  return data;
@@ -545,7 +545,7 @@ const RegistryComponent: React.FC<RegistryComponentProps> = () => {
545
545
  elective_preauth: Boolean(interventionResult?.needsManualPreauthApproval && electivePreauth),
546
546
  patient_uuid: amrsPatient?.uuid,
547
547
  ...(details?.protocolCode && {
548
- protocol_code: details.protocolCode,
548
+ protocal_code: details.protocolCode,
549
549
  }),
550
550
  ...(applicableDocumentTypes.length > 0 && {
551
551
  applicable_document_types: applicableDocumentTypes.join(','),