@ampath/esm-dha-workflow-app 4.0.0-claim-workflows.310 → 4.0.0-claim-workflows.311

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 (61) hide show
  1. package/dist/1362.js +1 -1
  2. package/dist/1362.js.map +1 -1
  3. package/dist/1925.js +1 -1
  4. package/dist/1927.js +1 -1
  5. package/dist/2021.js +1 -1
  6. package/dist/2054.js +1 -1
  7. package/dist/2092.js +1 -1
  8. package/dist/2210.js +1 -1
  9. package/dist/2230.js +1 -1
  10. package/dist/2493.js +1 -1
  11. package/dist/262.js +2 -0
  12. package/dist/262.js.map +1 -0
  13. package/dist/3202.js +1 -1
  14. package/dist/347.js +1 -1
  15. package/dist/3771.js +1 -1
  16. package/dist/4003.js +1 -1
  17. package/dist/4205.js +1 -1
  18. package/dist/4231.js +1 -1
  19. package/dist/4454.js +1 -1
  20. package/dist/4674.js +1 -1
  21. package/dist/4986.js +1 -1
  22. package/dist/5225.js +1 -1
  23. package/dist/5576.js +1 -1
  24. package/dist/5851.js +1 -1
  25. package/dist/6028.js +1 -1
  26. package/dist/6182.js +1 -1
  27. package/dist/6264.js +1 -1
  28. package/dist/6730.js +1 -0
  29. package/dist/6730.js.map +1 -0
  30. package/dist/6824.js +1 -1
  31. package/dist/7521.js +1 -1
  32. package/dist/7549.js +1 -1
  33. package/dist/7557.js +1 -1
  34. package/dist/7830.js +1 -1
  35. package/dist/7941.js +1 -1
  36. package/dist/8558.js +1 -1
  37. package/dist/9043.js +1 -1
  38. package/dist/9091.js +1 -1
  39. package/dist/9093.js +1 -1
  40. package/dist/9338.js +1 -1
  41. package/dist/esm-dha-workflow-app.js +1 -1
  42. package/dist/esm-dha-workflow-app.js.buildmanifest.json +93 -93
  43. package/dist/esm-dha-workflow-app.js.map +1 -1
  44. package/dist/main.js +1 -1
  45. package/dist/main.js.map +1 -1
  46. package/dist/routes.json +1 -1
  47. package/package.json +1 -1
  48. package/src/billing/dashboard/v2/patient-bill-details/patient-bill-details.tsx +2 -2
  49. package/src/billing/dashboard/v2/patient-bill-details/payment-mode.ts +10 -3
  50. package/src/billing/dashboard/v3/claim-visits/claim-intervention-details/claim-intervention-details.component.tsx +86 -70
  51. package/src/billing/dashboard/v3/claim-visits/claim-visit-details/claim-visit-details.component.tsx +20 -1
  52. package/src/billing/dashboard/v3/patient-bill-details/bill-details/bill-details.tsx +1 -0
  53. package/src/billing/dashboard/v3/patient-bill-details/claim-details/patient-claim-details.component.tsx +1 -0
  54. package/src/billing/dashboard/v3/patient-bill-details/modals/add-claim-line/add-claim-line.modal.tsx +10 -2
  55. package/src/billing/dashboard/v3/patient-bill-details/patient-bill-details.tsx +2 -1
  56. package/dist/1234.js +0 -1
  57. package/dist/1234.js.map +0 -1
  58. package/dist/5555.js +0 -2
  59. package/dist/5555.js.map +0 -1
  60. package/src/billing/dashboard/v3/claim-visits/claim-intervention-details/claim-intervention-details.component.scss +0 -5
  61. /package/dist/{5555.js.LICENSE.txt → 262.js.LICENSE.txt} +0 -0
@@ -1,34 +1,51 @@
1
1
  import React from 'react';
2
2
  import { type PatientFacilityBillDetails, type VisitIntervention } from '../../types';
3
- import { Button, ButtonSet, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tag } from '@carbon/react';
3
+ import {
4
+ MenuButton,
5
+ MenuItem,
6
+ Table,
7
+ TableBody,
8
+ TableCell,
9
+ TableHead,
10
+ TableHeader,
11
+ TableRow,
12
+ Tag,
13
+ } from '@carbon/react';
4
14
  import { launchWorkspace, showSnackbar, useSession } from '@openmrs/esm-framework';
5
15
 
6
- import styles from './claim-intervention-details.component.scss';
7
16
  import { invalidatePreauthPreview, parseDocTypes, readSpecialtyFlags } from '../../../v2/preauth/preauth.resource';
17
+ import {
18
+ interventionHasBlockingPreauth,
19
+ usePreauthPreview,
20
+ } from '../../../../../claims/claims.resource';
8
21
 
9
22
  interface claimInterventionDetailsProps {
10
23
  claimInterventions: VisitIntervention[];
11
24
  patientBillDetails: PatientFacilityBillDetails;
12
25
  consentToken: string;
13
26
  visitUuid: string;
27
+ canSwitchIntervention?: boolean;
28
+ onSwitchSuccess?: () => void;
14
29
  }
30
+
31
+ const isActiveIntervention = (iv: VisitIntervention) => (iv.workflow_state ?? '').toUpperCase() === 'ACTIVE';
32
+
15
33
  const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
16
34
  claimInterventions,
17
35
  patientBillDetails,
18
36
  consentToken,
19
37
  visitUuid,
38
+ canSwitchIntervention = false,
39
+ onSwitchSuccess,
20
40
  }) => {
41
+ const session = useSession();
42
+ const locationUuid = session?.sessionLocation?.uuid;
43
+ const { preview: preauthPreview } = usePreauthPreview(consentToken, locationUuid);
44
+
21
45
  if (!claimInterventions || claimInterventions.length === 0) {
22
46
  return <>No Intervention data</>;
23
47
  }
24
- function formatPreAuthText(preAuth: boolean) {
25
- if (preAuth) {
26
- return 'YES';
27
- }
28
- return 'NO';
29
- }
30
- const session = useSession();
31
- const locationUuid = session?.sessionLocation?.uuid;
48
+
32
49
  const handleAddAttachment = (ci: any) => {
33
50
  launchWorkspace('upload-intervention-attachments-workspace', {
34
51
  consentToken: consentToken,
@@ -44,10 +61,11 @@ const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
44
61
  bill: patientBillDetails,
45
62
  });
46
63
  };
64
+
47
65
  const handleSwitchIntervention = (intervention: VisitIntervention) => {
48
- // if (!canSwitchIntervention) {
49
- // return;
50
- // }
66
+ if (!canSwitchIntervention || !isActiveIntervention(intervention)) {
67
+ return;
68
+ }
51
69
  launchWorkspace('switch-intervention-workspace', {
52
70
  consentToken: consentToken,
53
71
  currentInterventions: [intervention],
@@ -56,16 +74,23 @@ const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
56
74
  visitUuid: visitUuid,
57
75
  billDate: patientBillDetails?.bill_date,
58
76
  onSwitchSuccess: () => {
59
- // invalidateProviderClaimPreview();
77
+ onSwitchSuccess?.();
60
78
  },
61
79
  });
62
80
  };
63
81
 
82
+ const canActOnIntervention = (intervention: VisitIntervention) =>
83
+ canSwitchIntervention && isActiveIntervention(intervention);
84
+
85
+ const canRaisePreauthFor = (intervention: VisitIntervention) => {
86
+ const alreadyRaised = interventionHasBlockingPreauth(preauthPreview, intervention.intervention_code);
87
+ return canActOnIntervention(intervention) && Boolean(intervention.needs_preauth) && !alreadyRaised;
88
+ };
89
+
64
90
  const handleRaisePreauth = (intervention: VisitIntervention) => {
65
- // if (!canSwitchIntervention) {
66
- // return;
67
- // }
68
- // const consentToken = claimsVisit.authorization_code;
91
+ if (!canSwitchIntervention) {
92
+ return;
93
+ }
69
94
  if (!consentToken) {
70
95
  showSnackbar({
71
96
  kind: 'error',
@@ -74,9 +99,9 @@ const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
74
99
  });
75
100
  return;
76
101
  }
77
- // if (!intervention.needs_preauth) {
78
- // return;
79
- // }
102
+ if (!canRaisePreauthFor(intervention)) {
103
+ return;
104
+ }
80
105
 
81
106
  const requiredDocs = parseDocTypes(
82
107
  Array.isArray(intervention.required_preauth_document_types)
@@ -110,10 +135,11 @@ const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
110
135
  },
111
136
  onSuccess: async () => {
112
137
  await invalidatePreauthPreview(consentToken, locationUuid!);
113
- // invalidateProviderClaimPreview();
138
+ onSwitchSuccess?.();
114
139
  },
115
140
  });
116
141
  };
142
+
117
143
  return (
118
144
  <>
119
145
  <Table size="sm">
@@ -133,55 +159,45 @@ const ClaimInterventionDetails: React.FC<claimInterventionDetailsProps> = ({
133
159
  </TableHead>
134
160
  <TableBody>
135
161
  {claimInterventions &&
136
- claimInterventions.map((ci, index) => {
162
+ claimInterventions.map((ci) => {
163
+ const canAct = canActOnIntervention(ci);
164
+ const canRaise = canRaisePreauthFor(ci);
165
+ const hasAttachments = (ci.applicable_document_types ?? []).length > 0;
137
166
  return (
138
- <>
139
- <TableRow key={ci.id}>
140
- <TableCell>{ci.intervention_code}</TableCell>
141
- <TableCell>{ci.intervention_payment_mechanism}</TableCell>
142
- <TableCell>{ci.intervention_name}</TableCell>
143
- <TableCell>{ci.accrued_per_diem_amount}</TableCell>
144
- <TableCell>{ci.accrued_per_diem_days}</TableCell>
145
- <TableCell>{ci.workflow_state}</TableCell>
146
- <TableCell>{ci.sub_benefit_code}</TableCell>
147
- <TableCell>{ci.intervention_fund}</TableCell>
148
- <TableCell>
149
- {ci.applicable_document_types.length > 0 ? (
150
- <div className={styles.attachmentButtons}>
151
- <Button kind="primary" size="sm" onClick={() => handleGenerateAttachment(ci)}>
152
- Generate
153
- </Button>
154
-
155
- <Button kind="primary" size="sm" onClick={() => handleAddAttachment(ci)}>
156
- Upload
157
- </Button>
158
- </div>
159
- ) : (
160
- <Tag type="gray">Not Required</Tag>
161
- )}
162
- </TableCell>
163
- <TableCell>
164
- <div className={styles.attachmentButtons}>
165
- <Button
166
- size="sm"
167
- onClick={() => {
168
- handleRaisePreauth(ci);
169
- }}
170
- >
171
- Raise preauth
172
- </Button>
173
- <Button
174
- size="sm"
175
- onClick={() => {
176
- handleSwitchIntervention(ci);
177
- }}
178
- >
179
- Switch intervention
180
- </Button>
181
- </div>
182
- </TableCell>
183
- </TableRow>
184
- </>
167
+ <TableRow key={ci.id}>
168
+ <TableCell>{ci.intervention_code}</TableCell>
169
+ <TableCell>{ci.intervention_payment_mechanism}</TableCell>
170
+ <TableCell>{ci.intervention_name}</TableCell>
171
+ <TableCell>{ci.accrued_per_diem_amount}</TableCell>
172
+ <TableCell>{ci.accrued_per_diem_days}</TableCell>
173
+ <TableCell>{ci.workflow_state}</TableCell>
174
+ <TableCell>{ci.sub_benefit_code}</TableCell>
175
+ <TableCell>{ci.intervention_fund}</TableCell>
176
+ <TableCell>
177
+ {hasAttachments ? (
178
+ <MenuButton label="Attachments" kind="ghost" size="sm">
179
+ <MenuItem label="Generate" onClick={() => handleGenerateAttachment(ci)} />
180
+ <MenuItem label="Upload" onClick={() => handleAddAttachment(ci)} />
181
+ </MenuButton>
182
+ ) : (
183
+ <Tag type="gray">Not Required</Tag>
184
+ )}
185
+ </TableCell>
186
+ <TableCell>
187
+ <MenuButton label="Actions" kind="ghost" size="sm">
188
+ <MenuItem
189
+ label="Raise preauth"
190
+ onClick={() => handleRaisePreauth(ci)}
191
+ disabled={!canRaise}
192
+ />
193
+ <MenuItem
194
+ label="Switch intervention"
195
+ onClick={() => handleSwitchIntervention(ci)}
196
+ disabled={!canAct}
197
+ />
198
+ </MenuButton>
199
+ </TableCell>
200
+ </TableRow>
185
201
  );
186
202
  })}
187
203
  </TableBody>
@@ -14,17 +14,22 @@ 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
16
  import { VisitType } from '../../../../../claims';
17
+ import { canEditClaimContent } from '../../../v2/claim-statuses';
18
+
17
19
  interface claimVisitDetailsProps {
18
20
  claimsVisit: ClaimsVisit;
19
21
  locationUuid: string;
20
22
  patientBillDetails?: PatientFacilityBillDetails;
21
23
  onBillDetailsChange?: () => void;
24
+ /** True while claim preview is revalidating — stand down content edits. */
25
+ claimRefreshing?: boolean;
22
26
  }
23
27
  const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
24
28
  claimsVisit,
25
29
  locationUuid,
26
30
  patientBillDetails,
27
31
  onBillDetailsChange,
32
+ claimRefreshing = false,
28
33
  }) => {
29
34
  const [showCloseClaimModal, setShowCloseClaimModal] = useState<boolean>();
30
35
  const [showSubmitClaimModal, setSubmitCloseClaimModal] = useState<boolean>(false);
@@ -127,7 +132,16 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
127
132
  });
128
133
  };
129
134
 
135
+ // Same gates as v2: content edits only while claim is DRAFT / DRAFT_RESUBMIT and not refreshing.
136
+ const canSwitchIntervention = canEditClaimContent(claimsVisit.workflow_state) && !claimRefreshing;
137
+ const hasActiveIntervention = Boolean(
138
+ claimsVisit.interventions?.some((iv) => (iv.workflow_state ?? '').toUpperCase() === 'ACTIVE'),
139
+ );
140
+
130
141
  const handleSwitchIntervention = () => {
142
+ if (!canSwitchIntervention || !hasActiveIntervention) {
143
+ return;
144
+ }
131
145
  launchWorkspace('switch-intervention-workspace', {
132
146
  consentToken: claimsVisit.authorization_code,
133
147
  currentInterventions: claimsVisit.interventions,
@@ -158,7 +172,7 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
158
172
  <Button
159
173
  kind="tertiary"
160
174
  onClick={handleSwitchIntervention}
161
- disabled={!claimsVisit.interventions?.some((iv) => (iv.workflow_state ?? '').toUpperCase() === 'ACTIVE')}
175
+ disabled={!canSwitchIntervention || !hasActiveIntervention}
162
176
  >
163
177
  Switch Intervention
164
178
  </Button>
@@ -231,6 +245,11 @@ const ClaimVisitDetails: React.FC<claimVisitDetailsProps> = ({
231
245
  claimInterventions={claimsVisit.interventions}
232
246
  consentToken={claimsVisit.authorization_code}
233
247
  visitUuid={activeVisit?.uuid}
248
+ canSwitchIntervention={canSwitchIntervention}
249
+ onSwitchSuccess={() => {
250
+ invalidateProviderClaimPreview();
251
+ onBillDetailsChange?.();
252
+ }}
234
253
  />
235
254
  )}
236
255
  </div>
@@ -195,6 +195,7 @@ const BillDetails: React.FC<billDetailsProps> = ({ patientBillDetails, patientPa
195
195
  onClose={handleCloseAddClaimItemModal}
196
196
  onSuccess={onSuccess}
197
197
  locationUuid={locationUuid}
198
+ consentToken={consentToken}
198
199
  />
199
200
  }
200
201
  </div>
@@ -50,6 +50,7 @@ const PatientClaimDetails: React.FC<patientClaimDetailsProps> = ({
50
50
  claimsVisit={claimVisit}
51
51
  locationUuid={locationUuid}
52
52
  onBillDetailsChange={onBillDetailsChange}
53
+ claimRefreshing={isValidating}
53
54
  />
54
55
  )
55
56
  }
@@ -11,8 +11,16 @@ interface addClaimLineModalProps {
11
11
  onSuccess: () => void;
12
12
  billItem: PatientFacilityBillDetails;
13
13
  locationUuid: string;
14
+ consentToken?: string;
14
15
  }
15
- const AddClaimLineModal: React.FC<addClaimLineModalProps> = ({ open, onClose, onSuccess, billItem, locationUuid }) => {
16
+ const AddClaimLineModal: React.FC<addClaimLineModalProps> = ({
17
+ open,
18
+ onClose,
19
+ onSuccess,
20
+ billItem,
21
+ locationUuid,
22
+ consentToken: consentTokenProp,
23
+ }) => {
16
24
  const [loading,setLoading] = useState<boolean>(false);
17
25
  async function handleAddClaimLineItem() {
18
26
  setLoading(true);
@@ -46,7 +54,7 @@ const AddClaimLineModal: React.FC<addClaimLineModalProps> = ({ open, onClose, on
46
54
  }
47
55
  function getClaimLineDto(): AddClaimLineDto {
48
56
  return {
49
- consentToken: billItem.consent_token,
57
+ consentToken: (consentTokenProp || billItem.consent_token || '').trim(),
50
58
  interventionCode: billItem.intervention_code,
51
59
  unitPrice: String(billItem.item_price),
52
60
  quantity: String(billItem.item_quantity),
@@ -18,6 +18,7 @@ import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@carbon/react';
18
18
  import BillDetails from './bill-details/bill-details';
19
19
  import PatientClaimDetails from './claim-details/patient-claim-details.component';
20
20
  import { type AmrsVisitDiagnosisDto, type AmrsVisitDiagnosis,type AmrsMaternityDiagnosisDto } from '../../../types';
21
+ import { resolveConsentTokenFromBillLines } from '../../v2/patient-bill-details/payment-mode';
21
22
  interface patientBillDetailsProps {
22
23
  patientUuid: string;
23
24
  locationUuid: string;
@@ -60,7 +61,7 @@ const PatientBillDetails: React.FC<patientBillDetailsProps> = ({ patientUuid, lo
60
61
  const data = await fetchPatientFacilityBillDetails(patientBillPayload);
61
62
  if (data) {
62
63
  setPatientBillDetails(data);
63
- setConsentToken(data[0].consent_token);
64
+ setConsentToken(resolveConsentTokenFromBillLines(data));
64
65
  }
65
66
  } catch (error) {
66
67
  showSnackbar({