@unite-us/app-create-referral 0.2.4-crtb-readme-9ba541e → 0.2.4
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.
- package/README.md +26 -220
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
+
# App Create Referral
|
|
1
2
|
|
|
2
3
|
This project is intended to be used from a parent application like [unite-us/front-end](https://github.com/unite-us/front-end) or [unite-us/uniteus-emr](https://github.com/unite-us/uniteus-emr)
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
- [Table of Contents](#table-of-contents)
|
|
6
|
-
- [Setup](#setup)
|
|
7
|
-
- [For Frontend (WebApp) Parent project](#for-frontend-webapp-parent-project)
|
|
8
|
-
- [For SmartApp (EMR) Parent project](#for-smartapp-emr-parent-project)
|
|
9
|
-
- [Architecture](#architecture)
|
|
10
|
-
- [Usages in parent apps](#usages-in-parent-apps)
|
|
11
|
-
- [Testing](#testing)
|
|
12
|
-
- [Releases](#releases)
|
|
13
|
-
- [How to update `app-create-referral` version in parent apps](#how-to-update-app-create-referral-version-in-parent-apps)
|
|
14
|
-
- [When to update the version in parent apps?](#when-to-update-the-version-in-parent-apps)
|
|
5
|
+
[Technical Design Document](https://uniteus.atlassian.net/wiki/spaces/AppEng/pages/3819208813/Tech+Design+Create+Referral+Project) (in progress)
|
|
15
6
|
|
|
16
|
-
|
|
7
|
+
### Setup
|
|
17
8
|
To develop locally follow this steps:
|
|
18
9
|
|
|
19
10
|
1- Open a command line console:
|
|
@@ -22,233 +13,48 @@ To develop locally follow this steps:
|
|
|
22
13
|
|
|
23
14
|
$ npm i && npm link && npm run build:dist:watch
|
|
24
15
|
```
|
|
25
|
-
This
|
|
16
|
+
This install the packages, create a link for this project (to be consumed from a parent app) and starts the server in watch mode, all the changes you do will trigger a rebuild and you will have the latest version)
|
|
26
17
|
|
|
27
|
-
|
|
18
|
+
## For EMR Parent project
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
// open a new terminal
|
|
31
|
-
// from the folder in `front-end/packages/app-client`
|
|
32
|
-
$ npm link @unite-us/app-create-referral
|
|
33
|
-
$ npm start
|
|
34
|
-
```
|
|
35
|
-
- Go to http://localhost:8080 and log in as a user with the `uup-459-superset-phase-2` feature flag enabled (ex: `spero@perms.test`)
|
|
36
|
-
- Find the entrypoint you want to check, e.g from the Client Facesheet, click the Refer button, it should take you to the Search step and then land in the referral flow
|
|
37
|
-
|
|
38
|
-
### For SmartApp (EMR) Parent project
|
|
20
|
+
The branch we are using for development is **smrt-create-referral**:
|
|
39
21
|
|
|
40
22
|
```
|
|
41
|
-
// open a new terminal
|
|
42
23
|
// from the root folder in uniteus-emr project
|
|
43
24
|
$ npm i
|
|
25
|
+
$ git checkout smrt-create-referral
|
|
44
26
|
$ npm link @unite-us/app-create-referral
|
|
45
27
|
$ npm start
|
|
46
28
|
```
|
|
47
|
-
- Go to http://localhost:8081 and log in as a user with the `
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
## Architecture
|
|
51
|
-
|
|
52
|
-
Please find the [Technical Design Document](https://uniteus.atlassian.net/wiki/spaces/AppEng/pages/3819208813/Tech+Design+Create+Referral+Project) to know about the project.
|
|
53
|
-
|
|
54
|
-
The application includes it's own Router and React Query Client. This allows us to use React Testing Library with Mock Service Workers (MswJS) for testing as an standalone app.
|
|
55
|
-
|
|
56
|
-
- `__testUtils__/`: Testing utils and mock server
|
|
57
|
-
- `actions/`: Custom api calls
|
|
58
|
-
- `api/`: Default hooks and axios instances setup
|
|
59
|
-
- `common/`: Common components (this can be merged with the components folder)
|
|
60
|
-
- `components/`: Components
|
|
61
|
-
- `constants/`: Constants
|
|
62
|
-
- `context/`: App Context to serve as source of truth of the data.
|
|
63
|
-
- `hooks/`: Custom hooks
|
|
64
|
-
- `pages/`: Pages components that relates to each route
|
|
65
|
-
- `styles/`: Custom scss files
|
|
66
|
-
- `utils/`: Utils functions
|
|
67
|
-
|
|
68
|
-
`AppReferrals.js`: This is the main component (entry point) of the app with the Router
|
|
69
|
-
|
|
70
|
-
## Usages in parent apps
|
|
71
|
-
|
|
72
|
-
The AppReferrals component is wired up in AppClient and EMR in specific routes:
|
|
73
|
-
|
|
74
|
-
AppClient:
|
|
75
|
-
|
|
76
|
-
- `<Route path="referrals/2/*" component={Referrals} />`
|
|
77
|
-
- Points to: https://github.com/unite-us/front-end/blob/master/packages/app-client/src/pages/referrals/2/Referrals.jsx
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
<AppReferrals
|
|
81
|
-
// general settings, urls needed to build the axios instances
|
|
82
|
-
appSettings={
|
|
83
|
-
{
|
|
84
|
-
env: {
|
|
85
|
-
getAuthToken,
|
|
86
|
-
coreUrl: CORE_API,
|
|
87
|
-
employeeId: currentEmployee?.id,
|
|
88
|
-
providerId: currentEmployee?.provider.id,
|
|
89
|
-
sharesUrl: SHARES_URL,
|
|
90
|
-
consentUrl: CONSENT_APP_URL,
|
|
91
|
-
},
|
|
92
|
-
basename,
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// this will be set to the app context
|
|
97
|
-
appState={{
|
|
98
|
-
currentEmployee,
|
|
99
|
-
currentProvider,
|
|
100
|
-
enums,
|
|
101
|
-
source: 'app-client',
|
|
102
|
-
}}
|
|
103
|
-
|
|
104
|
-
// callbacks functions invoked in specific places throughout the app
|
|
105
|
-
callbacks={{
|
|
106
|
-
notify: {
|
|
107
|
-
error: (message) => Notifier.dispatch('error', message),
|
|
108
|
-
success: (message) => Notifier.dispatch('success', message),
|
|
109
|
-
warn: (message) => Notifier.dispatch('warning', message),
|
|
110
|
-
},
|
|
111
|
-
trackEventCallback: trackEvent,
|
|
112
|
-
consent: {
|
|
113
|
-
updateGlobalState,
|
|
114
|
-
},
|
|
115
|
-
onReferralCompleted: ({ hasOnlyOONReferrals }) => {
|
|
116
|
-
browserHistory.push({
|
|
117
|
-
pathname: hasOnlyOONReferrals ? '/dashboard/oon-cases/open' : '/dashboard/referrals/sent/all',
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
onSaveDraftReferral: () => {
|
|
121
|
-
browserHistory.push({
|
|
122
|
-
pathname: '/dashboard/referrals/sent/draft',
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
onSubmitConsent: async () => {
|
|
126
|
-
// refresh ClientHeader to refetch person to show new consent status
|
|
127
|
-
setShowHeader(false);
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
setShowHeader(true);
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
onDeselectProgram: dispatchRemoveProgram,
|
|
133
|
-
onClickSearchStep: (searchParams, selectedPrograms) => {
|
|
134
|
-
dispatchRemoveAllPrograms();
|
|
135
|
-
if (!isEmpty(selectedPrograms)) {
|
|
136
|
-
dispatchAddPrograms(selectedPrograms);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const serializedSearchParams = serializeQueryParams(omitBy(searchParams, isNil));
|
|
140
|
-
const search = serializedSearchParams ? `?${serializedSearchParams}` : '';
|
|
141
|
-
|
|
142
|
-
browserHistory.push({
|
|
143
|
-
pathname: '/referrals/create/add-resources',
|
|
144
|
-
search,
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
onClickBackFromBuilder: () => {
|
|
148
|
-
let backUrl = `/referrals/create/add-resources?person=${personId}`;
|
|
149
|
-
if (resourceListId) { backUrl += `&resource_list=${resourceListId}`; }
|
|
150
|
-
|
|
151
|
-
browserHistory.replace(`${backUrl}&from-referral=true`);
|
|
152
|
-
},
|
|
153
|
-
}}
|
|
154
|
-
|
|
155
|
-
// components as props to avoid adding dependencies inside the app-create-referral repo
|
|
156
|
-
components={{
|
|
157
|
-
consent: ConsentReferrals,
|
|
158
|
-
}}
|
|
159
|
-
/>
|
|
160
|
-
|
|
161
|
-
//...
|
|
162
|
-
```
|
|
163
|
-
EMR:
|
|
164
|
-
- `<Route path="referrals/2/*" components={Referrals} />`
|
|
165
|
-
- Points to: https://github.com/unite-us/uniteus-emr/blob/master/src/pages/%5Bsession_id%5D/2/referrals/Referrals.jsx
|
|
166
|
-
|
|
167
|
-
In both WebApp and SmartApp, where the user navigates to the referral flow, we need to set the `selectedPrograms`, as in `SupersetSearch.jsx`
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
...
|
|
171
|
-
const { dispatch } = useAppCreateReferralContext();
|
|
29
|
+
- Go to http://localhost:8081 and log in as a user with the `hint11EhrSearchApiCutover` feature flag enabled (ex: `costanza@uniteus.com`)
|
|
30
|
+
- Follow the steps to create a new referral clicking the Create Referral button.
|
|
31
|
+
- Then go to [How to create a new version](#how-to-create-a-new-version)
|
|
172
32
|
|
|
173
|
-
|
|
174
|
-
const programsToUse = Object.keys(programToServiceTypesDict)
|
|
175
|
-
.map((id) => ({ id, services: programToServiceTypesDict[id] }));
|
|
33
|
+
## How to create a new version
|
|
176
34
|
|
|
177
|
-
|
|
178
|
-
dispatch(
|
|
179
|
-
init({
|
|
180
|
-
selectedPrograms: programsToUse,
|
|
181
|
-
person: personId,
|
|
182
|
-
resourceListId,
|
|
183
|
-
}),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
browserHistory.push({
|
|
187
|
-
pathname: '/referrals/2/create/builder',
|
|
188
|
-
});
|
|
189
|
-
}
|
|
35
|
+
After you are done with your changes, create a PR and **AFTER** it's merged, a Github Action will bump the version for you automatically and will create a new commit in the history, just only need to wait for the action to finish and check the commits for one that looks like this, eg:
|
|
190
36
|
```
|
|
191
|
-
|
|
192
|
-
## Testing
|
|
193
|
-
|
|
194
|
-
The app uses React Testing Library and Mock Service Worker (MswJS) for unit testing and integration testing across components.
|
|
195
|
-
|
|
196
|
-
`/__testUtils__/`: Includes the custom `render` using React Testing Library and the Mock Server that intercepts http requests during the tests
|
|
197
|
-
|
|
198
|
-
`/pages/*/__tests__`: Each page includes a folder with the tests for the screen.
|
|
199
|
-
|
|
200
|
-
Please review the existing tests and follow along to keep adding more scenarios as new features are being added.
|
|
201
|
-
|
|
202
|
-
## Releases
|
|
203
|
-
|
|
204
|
-
There is Github Action configured for the `main` branch that will generate a new version after a PR has been merged into `main`, usually it's the latest commit in the history for the main branch, e.g:
|
|
37
|
+
Automated Version Bump [skip ci] bumps version to 0.1.21
|
|
205
38
|
```
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
The new version created is `0.1.85`
|
|
39
|
+
In this case, the new version is **0.1.21**
|
|
210
40
|
|
|
211
|
-
|
|
41
|
+
## How to make the parent app use your new version
|
|
212
42
|
|
|
213
|
-
|
|
214
|
-
1. Update the dependency in the corresponding `package.json`
|
|
215
|
-
2. Install the dependencies
|
|
216
|
-
3. Create the PR to merge the new version
|
|
43
|
+
You need to update the package.json in the parent app, eg: unite-us/uniteus-emr
|
|
217
44
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
Update the `package.json`: https://github.com/unite-us/front-end/blob/master/packages/app-client/package.json
|
|
45
|
+
for EMR: https://github.com/unite-us/uniteus-emr/blob/smrt-create-referral/package.json#L33
|
|
221
46
|
|
|
222
|
-
|
|
223
|
-
"@unite-us/app-create-referral": "0.1.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
$ yarn
|
|
229
|
-
```
|
|
230
|
-
This will update the `yarn.lock` file with the new version, your PR to bump the version should include the `package.json` and the `yarn.lock` file changes, e.g:
|
|
231
|
-
https://github.com/unite-us/front-end/pull/4522/files
|
|
232
|
-
|
|
233
|
-
- unite-us/uniteus-emr
|
|
234
|
-
|
|
235
|
-
Update the `package.json`: https://github.com/unite-us/uniteus-emr/blob/master/package.json
|
|
236
|
-
|
|
237
|
-
```
|
|
238
|
-
"@unite-us/app-create-referral": "0.1.85"
|
|
239
|
-
```
|
|
240
|
-
- Open the terminal
|
|
47
|
+
```
|
|
48
|
+
//"@unite-us/app-create-referral": "0.1.1",
|
|
49
|
+
"@unite-us/app-create-referral": "0.1.1"
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
- Open the terminal
|
|
241
53
|
```
|
|
242
54
|
$ npm i
|
|
243
55
|
```
|
|
244
|
-
This will update the
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
Finally, create a PR in the parent project to use the new version.
|
|
248
|
-
|
|
249
|
-
### When to update the version in parent apps?
|
|
250
|
-
It depends on the release cadence and the speed to verify the features by the team; one approach could be keeping the parent apps with the latest versions at all times, shipping faster but also brings the risk of "untested" features might go into production because in very small timeframes probably the tester doesn't have time to verified the feature; and any team can do a release of the parent app with a version that you still dont want to make it to production.
|
|
56
|
+
This will update the package-lock.json with the new dependency.
|
|
57
|
+
- Create a PR in the parent project to use the new version
|
|
251
58
|
|
|
252
|
-
Another more conservative approach could be to update the version only when the team is ready to test the features and ensured they will be tested in a short timeframe (before any team does a release) to avoid the risk mentioned above; this approach is potentially not as fast, but it should keep the production releases more controlled.
|
|
253
59
|
|
|
254
|
-
|
|
60
|
+
That's all Folks!
|