@unite-us/app-create-referral 0.2.4 → 0.2.5

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 (2) hide show
  1. package/README.md +220 -26
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,19 @@
1
- # App Create Referral
2
1
 
3
2
  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)
4
3
 
5
- [Technical Design Document](https://uniteus.atlassian.net/wiki/spaces/AppEng/pages/3819208813/Tech+Design+Create+Referral+Project) (in progress)
4
+ ## Table of Contents
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)
6
15
 
7
- ### Setup
16
+ ## Setup
8
17
  To develop locally follow this steps:
9
18
 
10
19
  1- Open a command line console:
@@ -13,48 +22,233 @@ To develop locally follow this steps:
13
22
 
14
23
  $ npm i && npm link && npm run build:dist:watch
15
24
  ```
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)
25
+ This installs the packages, creates a link for this project (to be consumed from a parent app) and starts the server in watch mode. Development changes will trigger a rebuild and refresh the browser.
17
26
 
18
- ## For EMR Parent project
27
+ ### For Frontend (WebApp) Parent project
19
28
 
20
- The branch we are using for development is **smrt-create-referral**:
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
21
39
 
22
40
  ```
41
+ // open a new terminal
23
42
  // from the root folder in uniteus-emr project
24
43
  $ npm i
25
- $ git checkout smrt-create-referral
26
44
  $ npm link @unite-us/app-create-referral
27
45
  $ npm start
28
46
  ```
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)
47
+ - Go to http://localhost:8081 and log in as a user with the `uup-459-superset-phase-2` feature flag enabled (ex: `costanza@uniteus.com`)
48
+ - Find the entry point you want to check (e.g click the "Create Referral" button); it should take you to the Search step. Once you select program(s), click the "Added Resources" button to open the drawer and click the "Create Referrals" button to land in the referral flow.
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:
32
75
 
33
- ## How to create a new version
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
34
78
 
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:
36
79
  ```
37
- Automated Version Bump [skip ci] bumps version to 0.1.21
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
+ //...
38
162
  ```
39
- In this case, the new version is **0.1.21**
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
40
166
 
41
- ## How to make the parent app use your new version
167
+ In both WebApp and SmartApp, where the user navigates to the referral flow, we need to set the `selectedPrograms`, as in `SupersetSearch.jsx`
42
168
 
43
- You need to update the package.json in the parent app, eg: unite-us/uniteus-emr
169
+ ```
170
+ ...
171
+ const { dispatch } = useAppCreateReferralContext();
44
172
 
45
- for EMR: https://github.com/unite-us/uniteus-emr/blob/smrt-create-referral/package.json#L33
173
+ const onClickNext = () => {
174
+ const programsToUse = Object.keys(programToServiceTypesDict)
175
+ .map((id) => ({ id, services: programToServiceTypesDict[id] }));
46
176
 
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
177
+ // this sets the selected programs needed inside the referral flow
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
+ }
190
+ ```
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:
205
+ ```
206
+ Automated Version Bump [skip ci] bumps version to 0.1.85
207
+ ```
208
+
209
+ The new version created is `0.1.85`
210
+
211
+ ### How to update `app-create-referral` version in parent apps
212
+
213
+ There are a few steps:
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
217
+
218
+ - unite-us/front-end
219
+
220
+ Update the `package.json`: https://github.com/unite-us/front-end/blob/master/packages/app-client/package.json
221
+
222
+ ```
223
+ "@unite-us/app-create-referral": "0.1.85"
224
+ ```
225
+ - Open the terminal
226
+ ```
227
+ // from the root folder of the front-end repo, run yarn:
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
53
241
  ```
54
242
  $ npm i
55
243
  ```
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
244
+ This will update the `package-lock.json` file with the new version, your PR to bump the version should include the `package.json` and the `package-lock.json` file changes, e.g:
245
+ https://github.com/unite-us/uniteus-emr/pull/1883/files
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.
58
251
 
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.
59
253
 
60
- That's all Folks!
254
+ It's up to the team to decide the cadence and speed of the releases.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unite-us/app-create-referral",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "main": "./dist/index.js",
5
5
  "author": "Alex Morales",
6
6
  "dependencies": {