@ampath/esm-dha-workflow-app 4.0.0-next.154 → 4.0.0-next.155

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.
@@ -0,0 +1,101 @@
1
+ import React from "react";
2
+ import { type HieClientEligibility } from "../../types";
3
+ import styles from './eligibility-details.scss';
4
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tag } from "@carbon/react";
5
+ import { getTagType } from "../../../shared/utils/get-tag-type";
6
+
7
+ interface EligibilityDetailsProps{
8
+ hieClientEligibility: HieClientEligibility
9
+ }
10
+
11
+ const EligibilityDetails: React.FC<EligibilityDetailsProps> = ({hieClientEligibility})=>{
12
+ return <>
13
+ <div className={styles.clientEligibilityDetailsLayout}>
14
+ <div className={styles.sectionHeader}>
15
+ <h4 className={styles.sectionTitle}>Patient Eligibilty Details</h4>
16
+ </div>
17
+ <div className={styles.sectionContent}>
18
+ <div className={styles.clientDetails}>
19
+ <div>
20
+ <div className={styles.detailData}>
21
+ <strong className={styles.detailText}>Full Name</strong>
22
+ <span>{hieClientEligibility.fullName}</span>
23
+ </div>
24
+ <div className={styles.detailData}>
25
+ <strong className={styles.detailText}>CR No</strong>
26
+ <span>{hieClientEligibility.memberCrNumber}</span>
27
+ </div>
28
+ <div className={styles.detailData}>
29
+ <strong className={styles.detailText}>Status</strong>
30
+ <span>{hieClientEligibility.statusDesc}</span>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ <div className={styles.schemeSection}>
35
+ <div className={styles.sectionHeader}>
36
+ <h4 className={styles.sectionTitle}>Scheme Details</h4>
37
+ </div>
38
+ <div className={styles.schemeTable}>
39
+ <Table>
40
+ <TableHead>
41
+ <TableRow>
42
+ <TableHeader>No</TableHeader>
43
+ <TableHeader>Name</TableHeader>
44
+ <TableHeader>Member Type</TableHeader>
45
+ <TableHeader>Policy</TableHeader>
46
+ <TableHeader>Coverage</TableHeader>
47
+ <TableHeader>Coverage Period</TableHeader>
48
+ <TableHeader>Coverage Status</TableHeader>
49
+ <TableHeader>Coverage Reason</TableHeader>
50
+ <TableHeader>Principal Contributor</TableHeader>
51
+ <TableHeader>Principal Contributor Employment Type</TableHeader>
52
+ </TableRow>
53
+ </TableHead>
54
+ <TableBody>
55
+ {hieClientEligibility.schemes.map((scheme, id) => {
56
+ return (
57
+ <TableRow key={id}>
58
+ <TableCell>{id + 1}</TableCell>
59
+ <TableCell>{scheme.schemeName}</TableCell>
60
+ <TableCell>{scheme.memberType}</TableCell>
61
+ <TableCell>
62
+ {scheme.policy ? (
63
+ <>
64
+ {scheme.policy.number} ({scheme.policy.startDate} - {scheme.policy.endDate})
65
+ </>
66
+ ) : (
67
+ <></>
68
+ )}
69
+ </TableCell>
70
+ <TableCell>
71
+ <Tag
72
+ className="some-class"
73
+ size="lg"
74
+ title="Status"
75
+ type={getTagType(scheme.coverage.status)}
76
+ >
77
+ {scheme.coverage.status === '1' ? 'Active' : 'Not Active'}
78
+ </Tag>
79
+ </TableCell>
80
+ <TableCell>
81
+ {scheme.coverage.startDate} - {scheme.coverage.endDate}
82
+ </TableCell>
83
+ <TableCell>{scheme.coverage.message}</TableCell>
84
+ <TableCell>{scheme.coverage.reason}</TableCell>
85
+ <TableCell>
86
+ {scheme.principalContributor.crNumber}
87
+ </TableCell>
88
+ <TableCell>{scheme.principalContributor.employmentType}</TableCell>
89
+ </TableRow>
90
+ );
91
+ })}
92
+ </TableBody>
93
+ </Table>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </>
99
+ }
100
+
101
+ export default EligibilityDetails;
@@ -99,11 +99,6 @@ const EligibilityTags: React.FC<EligibilityTags> = ({ crId, locationUuid }) => {
99
99
  </div>
100
100
  );
101
101
  })}
102
- <div>
103
- <Button kind="ghost" size="sm" onClick={showEligibilityDetailsModal}>
104
- View
105
- </Button>
106
- </div>
107
102
  </>
108
103
  ) : (
109
104
  <div>
@@ -118,18 +113,6 @@ const EligibilityTags: React.FC<EligibilityTags> = ({ crId, locationUuid }) => {
118
113
  )}
119
114
  </>
120
115
  )}
121
- {displayEligibilityDetailsModal ? (
122
- <>
123
- <ClientEligibilityDetailsModal
124
- onModalClose={handleModalClose}
125
- onSubmit={handleModalClose}
126
- open={displayEligibilityDetailsModal}
127
- hieClientEligibility={clientEligibility}
128
- />
129
- </>
130
- ) : (
131
- <></>
132
- )}
133
116
  </div>
134
117
  </>
135
118
  );
@@ -1,38 +0,0 @@
1
- .clientEligibilityDetailsLayout{
2
- display: flex;
3
- flex-direction: column;
4
- row-gap: 10px;
5
- width: 100%;
6
- padding: 15px 15px;
7
- .sectionHeader{
8
- display: flex;
9
- flex-direction: row;
10
- width: 100%;
11
- }
12
- .sectionContent{
13
- display: flex;
14
- flex-direction: column;
15
- row-gap: 10px;
16
- width: 100%;
17
- }
18
- }
19
-
20
- .clientDetails{
21
- display: grid;
22
- grid-template-columns: 1fr 1fr;
23
- gap: 1rem;
24
- }
25
- .detailData{
26
- display: flex;
27
- gap: 1rem;
28
- margin-bottom: 0.75rem
29
- }
30
- .detailText{
31
- min-width: 150px;
32
- }
33
- .schemeTable{
34
- display: flex;
35
- flex-direction: row;
36
- min-width: 80vw;
37
- overflow-x: scroll;
38
- }
@@ -3,6 +3,7 @@ import { type HieClientEligibility } from '../../types';
3
3
  import React from 'react';
4
4
  import styles from './eligibility-details.modal.scss';
5
5
  import { getTagType } from '../../../shared/utils/get-tag-type';
6
+ import EligibilityDetails from '../eligibility-details/eligibility-details';
6
7
 
7
8
  interface ClientEligibilityDetailsModalProps {
8
9
  hieClientEligibility: HieClientEligibility;
@@ -32,96 +33,9 @@ const ClientEligibilityDetailsModal: React.FC<ClientEligibilityDetailsModalProps
32
33
  secondaryButtonText="Cancel"
33
34
  >
34
35
  <ModalBody>
35
- <div className={styles.clientEligibilityDetailsLayout}>
36
- <div className={styles.sectionHeader}>
37
- <h4 className={styles.sectionTitle}>Patient Eligibilty Details</h4>
38
- </div>
39
- <div className={styles.sectionContent}>
40
- <div className={styles.clientDetails}>
41
- <div>
42
- <div className={styles.detailData}>
43
- <strong className={styles.detailText}>Full Name</strong>
44
- <span>{hieClientEligibility.fullName}</span>
45
- </div>
46
- <div className={styles.detailData}>
47
- <strong className={styles.detailText}>ID Number</strong>
48
- <span>{hieClientEligibility.requestIdNumber}</span>
49
- </div>
50
- <div className={styles.detailData}>
51
- <strong className={styles.detailText}>CR No</strong>
52
- <span>{hieClientEligibility.memberCrNumber}</span>
53
- </div>
54
- <div className={styles.detailData}>
55
- <strong className={styles.detailText}>Status</strong>
56
- <span>{hieClientEligibility.statusDesc}</span>
57
- </div>
58
- </div>
59
- </div>
60
- <div className={styles.schemeSection}>
61
- <div className={styles.sectionHeader}>
62
- <h4 className={styles.sectionTitle}>Scheme Details</h4>
63
- </div>
64
- <div className={styles.schemeTable}>
65
- <Table>
66
- <TableHead>
67
- <TableRow>
68
- <TableHeader>No</TableHeader>
69
- <TableHeader>Name</TableHeader>
70
- <TableHeader>Member Type</TableHeader>
71
- <TableHeader>Policy</TableHeader>
72
- <TableHeader>Coverage</TableHeader>
73
- <TableHeader>Coverage Period</TableHeader>
74
- <TableHeader>Coverage Status</TableHeader>
75
- <TableHeader>Coverage Reason</TableHeader>
76
- <TableHeader>Principal Contributor</TableHeader>
77
- <TableHeader>Principal Contributor Employment Type</TableHeader>
78
- </TableRow>
79
- </TableHead>
80
- <TableBody>
81
- {hieClientEligibility.schemes.map((scheme, id) => {
82
- return (
83
- <TableRow key={id}>
84
- <TableCell>{id + 1}</TableCell>
85
- <TableCell>{scheme.schemeName}</TableCell>
86
- <TableCell>{scheme.memberType}</TableCell>
87
- <TableCell>
88
- {scheme.policy ? (
89
- <>
90
- {scheme.policy.number} ({scheme.policy.startDate} - {scheme.policy.endDate})
91
- </>
92
- ) : (
93
- <></>
94
- )}
95
- </TableCell>
96
- <TableCell>
97
- <Tag
98
- className="some-class"
99
- size="lg"
100
- title="Status"
101
- type={getTagType(scheme.coverage.status)}
102
- >
103
- {scheme.coverage.status === '1' ? 'Active' : 'Not Active'}
104
- </Tag>
105
- </TableCell>
106
- <TableCell>
107
- {scheme.coverage.startDate} - {scheme.coverage.endDate}
108
- </TableCell>
109
- <TableCell>{scheme.coverage.message}</TableCell>
110
- <TableCell>{scheme.coverage.reason}</TableCell>
111
- <TableCell>
112
- {scheme.principalContributor.crNumber} : {scheme.principalContributor.name},
113
- {scheme.principalContributor.relationship}
114
- </TableCell>
115
- <TableCell>{scheme.principalContributor.employmentType}</TableCell>
116
- </TableRow>
117
- );
118
- })}
119
- </TableBody>
120
- </Table>
121
- </div>
122
- </div>
123
- </div>
124
- </div>
36
+ <EligibilityDetails
37
+ hieClientEligibility={hieClientEligibility}
38
+ />
125
39
  </ModalBody>
126
40
  </Modal>
127
41
  </>
@@ -1,12 +1,11 @@
1
1
  import { Modal, ModalBody, Tab, TabList, TabPanel, TabPanels, Tabs } from '@carbon/react';
2
- import { type HieClient } from '../../types';
3
- import React, { useState } from 'react';
2
+ import { type HieClientEligibility, type EligibilityFilterDto, type HieClient } from '../../types';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import styles from './client-details-modal.scss';
5
5
  import ClientDetails from '../../client-details/client-details';
6
- import PaymentOptionsComponent from '../../payment-details/payment-options/payment-options';
7
- import { type CreateClientPaymentModeDto, type HieClientPaymentMode, type PaymentMode } from '../../../shared/types';
8
- import { createClientPaymentMode } from '../../../shared/services/client-payment-mode.resource';
9
- import { showSnackbar } from '@openmrs/esm-framework';
6
+ import { showSnackbar, useSession } from '@openmrs/esm-framework';
7
+ import { getClientEligibityStatus } from '../../../shared/services/eligibility.resource';
8
+ import EligibilityDetails from '../../eligibility/eligibility-details/eligibility-details';
10
9
 
11
10
  interface ClientDetailsModalProps {
12
11
  client: HieClient;
@@ -23,9 +22,61 @@ const ClientDetailsModal: React.FC<ClientDetailsModalProps> = ({
23
22
  onSubmit,
24
23
  onSendClientToTriage,
25
24
  }) => {
25
+ const session = useSession();
26
+ const locationUuid = session.sessionLocation?.uuid;
27
+ const [clientEligibility, setClientEligibility] = useState<HieClientEligibility>();
28
+ useEffect(() => {
29
+ if (client && client.id) {
30
+ getPatientEligibilityStatus();
31
+ }
32
+ }, [client]);
26
33
  if (!client) {
27
34
  return <>No Client data</>;
28
35
  }
36
+ function generatePatientEligibilityPayload(): EligibilityFilterDto {
37
+ const payload: EligibilityFilterDto = {
38
+ requestIdNumber: '',
39
+ requestIdType: '',
40
+ locationUuid: locationUuid ?? '',
41
+ };
42
+
43
+ if (client && client.id) {
44
+ payload.requestIdNumber = client.id;
45
+ payload.requestIdType = '3';
46
+ }
47
+
48
+ return payload;
49
+ }
50
+
51
+ async function getPatientEligibilityStatus() {
52
+ const payload = generatePatientEligibilityPayload();
53
+ if (!isValidEligibilityPayload(payload)) {
54
+ return;
55
+ }
56
+ try {
57
+ const resp = await getClientEligibityStatus(payload);
58
+ setClientEligibility(resp);
59
+ } catch (error) {
60
+ showSnackbar({
61
+ kind: 'error',
62
+ title: 'Failed getting eligibility status',
63
+ subtitle: 'An error occurred while fetching eligibility status. Please try again or contact support',
64
+ });
65
+ }
66
+ }
67
+ function isValidEligibilityPayload(eligibilityFilterDto: EligibilityFilterDto): boolean {
68
+ if (!eligibilityFilterDto.locationUuid) {
69
+ return false;
70
+ }
71
+ if (!eligibilityFilterDto.requestIdNumber) {
72
+ return false;
73
+ }
74
+ if (!eligibilityFilterDto.requestIdType) {
75
+ return false;
76
+ }
77
+
78
+ return true;
79
+ }
29
80
  return (
30
81
  <>
31
82
  <Modal
@@ -46,11 +97,15 @@ const ClientDetailsModal: React.FC<ClientDetailsModalProps> = ({
46
97
  <Tabs>
47
98
  <TabList contained>
48
99
  <Tab>Patient Details</Tab>
100
+ <Tab>Eligibility Details</Tab>
49
101
  </TabList>
50
102
  <TabPanels>
51
103
  <TabPanel>
52
104
  <ClientDetails client={client} />
53
105
  </TabPanel>
106
+ <TabPanel>
107
+ {clientEligibility && <EligibilityDetails hieClientEligibility={clientEligibility} />}
108
+ </TabPanel>
54
109
  </TabPanels>
55
110
  </Tabs>
56
111
  </div>
@@ -4,7 +4,6 @@ export type IdentifierType = 'National ID' | 'Alien ID' | 'Passport' | 'Mandate
4
4
 
5
5
  export const IDENTIFIER_TYPES: IdentifierType[] = [
6
6
  'National ID',
7
- 'Birth Certificate',
8
7
  'Alien ID',
9
8
  'Mandate Number',
10
9
  'Refugee ID'