-
Notifications
You must be signed in to change notification settings - Fork 125
/
CernerTransitioningFacilityAlert.jsx
145 lines (132 loc) · 5.22 KB
/
CernerTransitioningFacilityAlert.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/** This component is used to display an alert to users who are associated with a facility that is transitioning to Cerner.
The alert will display custom content that will have to be updated per facility.
"isCerner" flag that is contained in a facility object derived from the user profile is considered to be not fully reliable
during transition periods and may not be updated timely. Drupal CMS is currently the source of truth for this information.
Facility info is pulled from the drupalStaticData reducer.
The facility info is then compared to the user's facilities to determine if the user is associated with a transitioning facility.
Since neither Drupal nor user profile do not contain transition dates and those are flexible, the alert will be displayed based on the feature flag toggles.
Once the facility ehr is updated to 'cerner' in Drupal CMS, the facility is considered to be transitioned to Cerner and this alert will be disregarded regardless of the feature flag toggles.
After transitioning, need to ensure that CernerFacilityAlert is displayed to users who are associated with Cerner facilities.
*/
import React, { useMemo } from 'react';
import FEATURE_FLAG_NAMES from '@department-of-veterans-affairs/platform-utilities/featureFlagNames';
import { useSelector } from 'react-redux';
import { selectUser } from '@department-of-veterans-affairs/platform-user/selectors';
import { selectEhrDataByVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/selectors';
import { getVamcSystemNameFromVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/utils';
import { CernerTransitioningFacilities } from '../../util/constants';
const CernerTransitioningFacilityAlert = () => {
const user = useSelector(selectUser);
const { featureToggles } = useSelector(state => state);
const transitioningFacilityId =
CernerTransitioningFacilities.NORTH_CHICAGO.facilityId;
const cernerTransition556T30 = useMemo(
() => {
return featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T30]
? featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T30]
: false;
},
[featureToggles],
);
const cernerTransition556T5 = useMemo(
() => {
return featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T5]
? featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T5]
: false;
},
[featureToggles],
);
const userFacilities = user.profile.facilities;
const ehrFacilities = useSelector(selectEhrDataByVhaId);
const isTranstioningFacility = useMemo(
() => {
const transitioningFacility = ehrFacilities[transitioningFacilityId];
if (
userFacilities &&
transitioningFacility &&
transitioningFacility.ehr !== 'cerner' &&
userFacilities.some(
facility =>
parseInt(facility.facilityId, 10) ===
parseInt(transitioningFacility.vhaId, 10),
)
) {
return getVamcSystemNameFromVhaId(
ehrFacilities,
transitioningFacility.vhaId,
);
}
return null;
},
[userFacilities, ehrFacilities],
);
const contentT30 = useMemo(
() => {
return (
isTranstioningFacility && (
<va-alert status="warning" class="vads-u-margin-y--2" uswds>
<h1 slot="headline">
Your health facility is moving to My VA Health
</h1>
<div>
<p>
<strong>{isTranstioningFacility}</strong> is moving to our My VA
Health portal.
</p>
<ul>
<li>
Starting on <strong>March 4,</strong> you won’t be able to use
this My HealtheVet tool to send messages to care teams at this
facility.
</li>
<li>
Starting on <strong>March 9,</strong> you can use the new My
VA Health portal to send messages to these care teams.
</li>
</ul>
</div>
</va-alert>
)
);
},
[isTranstioningFacility],
);
const contentT5 = useMemo(
() => {
return (
isTranstioningFacility && (
<va-alert status="warning" class="vads-u-margin-y--2" uswds>
<h1 slot="headline">
You can’t send messages to some of your care teams right now
</h1>
<div>
<p>
We’re moving data for <strong>{isTranstioningFacility}</strong>{' '}
to our My VA Health portal. On March 9, you can start using My
VA Health to send messages to care teams at this facility.
</p>
<p>To contact your care team now, call your facility.</p>
<p>
<a href="/find-locations" target="_blank">
Find your VA health facility
</a>
</p>
</div>
</va-alert>
)
);
},
[isTranstioningFacility],
);
const content = () => {
if (cernerTransition556T5) {
return contentT5;
}
if (cernerTransition556T30) {
return contentT30;
}
return null;
};
return <>{content()}</>;
};
export default CernerTransitioningFacilityAlert;