@awell-health/awell-extensions 1.0.13 → 1.0.15

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 (25) hide show
  1. package/dist/extensions/markdown.json +1 -1
  2. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.d.ts +33 -0
  3. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.js +126 -0
  4. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.js.map +1 -0
  5. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.test.d.ts +1 -0
  6. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.test.js +190 -0
  7. package/dist/extensions/wellinks/actions/checkForChat/checkForChat.test.js.map +1 -0
  8. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.d.ts +26 -0
  9. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.js +133 -0
  10. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.js.map +1 -0
  11. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.test.d.ts +1 -0
  12. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.test.js +221 -0
  13. package/dist/extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.test.js.map +1 -0
  14. package/dist/extensions/wellinks/actions/checkForOverride/checkForOverride.js +2 -2
  15. package/dist/extensions/wellinks/actions/checkForOverride/checkForOverride.js.map +1 -1
  16. package/dist/extensions/wellinks/actions/index.d.ts +111 -0
  17. package/dist/extensions/wellinks/actions/index.js +5 -1
  18. package/dist/extensions/wellinks/actions/index.js.map +1 -1
  19. package/dist/extensions/wellinks/gql/wellinksSdk.d.ts +252 -8
  20. package/dist/extensions/wellinks/gql/wellinksSdk.js +17 -1
  21. package/dist/extensions/wellinks/gql/wellinksSdk.js.map +1 -1
  22. package/dist/extensions/wellinks/graphql/queries.d.ts +1 -0
  23. package/dist/extensions/wellinks/graphql/queries.js +12 -1
  24. package/dist/extensions/wellinks/graphql/queries.js.map +1 -1
  25. package/package.json +1 -1
@@ -60,7 +60,7 @@
60
60
  "changelog": "# Twilio changelog\n\n## v2\n\nCompared to v1 (pre-beta release), the extension only has one custom action \"Send SMS\" instead of two. The Custom Action allows for:\n\n1. Sending a text message to a recipient (phone number) stored in a data point, including patient profile data points.\n2. Sending a text message to a fixed recipient (phone number).\n"
61
61
  },
62
62
  "wellinks": {
63
- "readme": "# Wellinks Extension\n\nThe purpose of this extension is to keep application logic out of the Pathways and Tracks. Some actions require interactions with the Healthie API, hence the need for the API URL and Key in the settings.\n\n## Extension Settings\n\nYou will need to provide the API URL and Key for the Wellinks Healthie instance.\n\n# Custom Actions\n\n## Check for Override\n\nChecks to see if the patient in Healthie has an active Override form.\n\n## Check for Scheduled Appointments\n\nChecks to see if the patient in Healthie has an appointment of a specific type scheduled in the future.",
63
+ "readme": "# Wellinks Extension\n\nThe purpose of this extension is to keep application logic out of the Pathways and Tracks. Some actions require interactions with the Healthie API, hence the need for the API URL and Key in the settings.\n\n## Extension Settings\n\nYou will need to provide the API URL and Key for the Wellinks Healthie instance.\n\n# Custom Actions\n\n## Check for Override\n\nChecks to see if the patient in Healthie has an active Override form.\n\n## Check for Scheduled Appointments\n\nChecks to see if the patient in Healthie has an appointment of a specific type scheduled in the future.\n\n## Check for Chat",
64
64
  "changelog": "# Wellinks Changelog\n\n## May 18th, 2023\n\nAdded the checkForOverride action.\n\n## May 19th, 2023\n\nAdded the checkForScheduledAppointment action.\n\n## May 25th, 2023\n\nAdded datapoints for actions"
65
65
  }
66
66
  }
@@ -0,0 +1,33 @@
1
+ import { FieldType, type Action } from '@awell-health/extensions-core';
2
+ import { type settings } from '../../settings';
3
+ declare const fields: {
4
+ patientId: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.STRING;
9
+ required: true;
10
+ };
11
+ coachId: {
12
+ id: string;
13
+ label: string;
14
+ description: string;
15
+ type: FieldType.STRING;
16
+ required: true;
17
+ };
18
+ appointmentTime: {
19
+ id: string;
20
+ label: string;
21
+ description: string;
22
+ type: FieldType.DATE;
23
+ required: true;
24
+ };
25
+ };
26
+ declare const dataPoints: {
27
+ messageSent: {
28
+ key: string;
29
+ valueType: "boolean";
30
+ };
31
+ };
32
+ export declare const checkForChat: Action<typeof fields, typeof settings, keyof typeof dataPoints>;
33
+ export {};
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkForChat = void 0;
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const extensions_core_2 = require("@awell-health/extensions-core");
6
+ const wellinksSdk_1 = require("../../gql/wellinksSdk");
7
+ const wellinksGraphqlClient_1 = require("../../wellinksGraphqlClient");
8
+ const lodash_1 = require("lodash");
9
+ const fields = {
10
+ patientId: {
11
+ id: 'patientId',
12
+ label: 'Patient ID',
13
+ description: 'The ID of the patient to check chats for.',
14
+ type: extensions_core_1.FieldType.STRING,
15
+ required: true,
16
+ },
17
+ coachId: {
18
+ id: 'coachId',
19
+ label: 'Coach ID',
20
+ description: 'The ID of the coach to check chats for.',
21
+ type: extensions_core_1.FieldType.STRING,
22
+ required: true,
23
+ },
24
+ appointmentTime: {
25
+ id: 'appointmentTime',
26
+ label: 'Appointment Time',
27
+ description: 'The appointment time to check against',
28
+ type: extensions_core_1.FieldType.DATE,
29
+ required: true,
30
+ },
31
+ };
32
+ const dataPoints = {
33
+ messageSent: {
34
+ key: 'messageSent',
35
+ valueType: 'boolean',
36
+ }
37
+ };
38
+ exports.checkForChat = {
39
+ key: 'checkForChat',
40
+ category: extensions_core_2.Category.SCHEDULING,
41
+ title: 'Check for Messages after Appointment',
42
+ description: 'Checks that a message has been sent 24 hours after the given Appointment',
43
+ fields,
44
+ dataPoints,
45
+ previewable: true,
46
+ onActivityCreated: async (payload, onComplete, onError) => {
47
+ var _a, _b;
48
+ const { fields, settings } = payload;
49
+ const { patientId, coachId, appointmentTime } = fields;
50
+ try {
51
+ const client = (0, wellinksGraphqlClient_1.initialiseClient)(settings);
52
+ if (!(0, lodash_1.isNil)(client)) {
53
+ const sdk = (0, wellinksSdk_1.getSdk)(client);
54
+ const { data } = await sdk.getConversationMemberships({
55
+ client_id: patientId
56
+ });
57
+ if (!(0, lodash_1.isNil)(data.conversationMemberships)) {
58
+ const conversationMemberships = data.conversationMemberships.filter((conversation) => { var _a; return ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.convo) === null || _a === void 0 ? void 0 : _a.dietitian_id) === coachId; });
59
+ for (const conversation of conversationMemberships) {
60
+ // check if dates are within 24 hours of each other
61
+ if (areDatesWithinDay(new Date((_b = (_a = conversation === null || conversation === void 0 ? void 0 : conversation.convo) === null || _a === void 0 ? void 0 : _a.updated_at) !== null && _b !== void 0 ? _b : ''), new Date(appointmentTime !== null && appointmentTime !== void 0 ? appointmentTime : ''))) {
62
+ await onComplete({
63
+ data_points: {
64
+ messageSent: 'true',
65
+ }
66
+ });
67
+ }
68
+ }
69
+ await onComplete({
70
+ data_points: {
71
+ messageSent: 'false',
72
+ }
73
+ });
74
+ }
75
+ else {
76
+ await onError({
77
+ events: [
78
+ {
79
+ date: new Date().toISOString(),
80
+ text: { en: 'conversationMemberships returned null or undefined' },
81
+ error: {
82
+ category: 'SERVER_ERROR',
83
+ message: 'conversationMemberships returned null or undefined',
84
+ },
85
+ },
86
+ ],
87
+ });
88
+ }
89
+ }
90
+ else {
91
+ await onError({
92
+ events: [
93
+ {
94
+ date: new Date().toISOString(),
95
+ text: { en: 'API client requires an API url and API key' },
96
+ error: {
97
+ category: 'MISSING_SETTINGS',
98
+ message: 'Missing api url or api key',
99
+ },
100
+ },
101
+ ],
102
+ });
103
+ }
104
+ }
105
+ catch (err) {
106
+ const error = err;
107
+ await onError({
108
+ events: [
109
+ {
110
+ date: new Date().toISOString(),
111
+ text: { en: 'There was in error checking for a recent Chat' },
112
+ error: {
113
+ category: 'SERVER_ERROR',
114
+ message: error.message,
115
+ },
116
+ },
117
+ ],
118
+ });
119
+ }
120
+ },
121
+ };
122
+ function areDatesWithinDay(date1, date2) {
123
+ const oneDay = 1000 * 60 * 60 * 24;
124
+ return date1.getTime() > (date2.getTime() + oneDay);
125
+ }
126
+ //# sourceMappingURL=checkForChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkForChat.js","sourceRoot":"","sources":["../../../../../extensions/wellinks/actions/checkForChat/checkForChat.ts"],"names":[],"mappings":";;;AAAA,mEAKwC;AACtC,mEAAwD;AACxD,uDAA+C;AAC/C,uEAA8D;AAE9D,mCAA8B;AAE9B,MAAM,MAAM,GAAG;IACb,SAAS,EAAE;QACP,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,eAAe,EAAE;QACf,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;KACf;CAC4B,CAAA;AAEjC,MAAM,UAAU,GAAG;IACjB,WAAW,EAAE;QACT,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,SAAS;KACrB;CAC0C,CAAA;AAElC,QAAA,YAAY,GAIrB;IACF,GAAG,EAAE,cAAc;IACnB,QAAQ,EAAE,0BAAQ,CAAC,UAAU;IAC7B,KAAK,EAAE,sCAAsC;IAC7C,WAAW,EAAE,0EAA0E;IACvF,MAAM;IACN,UAAU;IACV,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAA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{ value: true });
3
+ const wellinksSdk_1 = require("../../gql/wellinksSdk");
4
+ const wellinksSdk_2 = require("../../gql/__mocks__/wellinksSdk");
5
+ const checkForChat_1 = require("./checkForChat");
6
+ jest.mock('../../gql/wellinksSdk');
7
+ jest.mock('../../wellinksGraphqlClient');
8
+ describe('the checkForChat action', () => {
9
+ const onComplete = jest.fn();
10
+ const onError = jest.fn();
11
+ beforeAll(() => {
12
+ wellinksSdk_1.getSdk.mockImplementation(wellinksSdk_2.mockGetSdk);
13
+ });
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ });
17
+ // DEFINE TEST CASE
18
+ test('when given a null data return from the Healthie API', async () => {
19
+ wellinksSdk_1.getSdk.mockReturnValueOnce({
20
+ ...wellinksSdk_2.mockGetSdkReturn,
21
+ getConversationMemberships: wellinksSdk_2.mockGetSdkReturn.getConversationMemberships.mockReturnValueOnce({
22
+ data: {
23
+ conversationMemberships: null
24
+ }
25
+ })
26
+ });
27
+ await checkForChat_1.checkForChat.onActivityCreated({
28
+ pathway: {
29
+ id: 'pathway-id',
30
+ definition_id: 'pathway-definition-id'
31
+ },
32
+ activity: {
33
+ id: 'activity-id'
34
+ },
35
+ patient: { id: 'test-patient' },
36
+ fields: {
37
+ patientId: 'patientIdTest',
38
+ coachId: 'coachId',
39
+ appointmentTime: '2023-08-08'
40
+ },
41
+ settings: {
42
+ apiKey: 'apiKey',
43
+ apiUrl: 'test-url',
44
+ selectEventTypeQuestion: '2602707',
45
+ startSendingRemindersQuestions: '3860906',
46
+ memberEventFormId: '281216'
47
+ },
48
+ }, onComplete, onError);
49
+ // DO TESTS
50
+ expect(wellinksSdk_2.mockGetSdkReturn.getConversationMemberships).toHaveBeenCalled();
51
+ expect(onError).toBeCalledWith({
52
+ events: expect.arrayContaining([
53
+ expect.objectContaining({
54
+ error: {
55
+ category: 'SERVER_ERROR',
56
+ message: 'conversationMemberships returned null or undefined'
57
+ }
58
+ })
59
+ ])
60
+ });
61
+ });
62
+ // DEFINE TEST CASE
63
+ test('when given a list of conversationMemberships where there is a message sent 24 hours after the appointmentDate returns true', async () => {
64
+ wellinksSdk_1.getSdk.mockReturnValueOnce({
65
+ ...wellinksSdk_2.mockGetSdkReturn,
66
+ getConversationMemberships: wellinksSdk_2.mockGetSdkReturn.getConversationMemberships.mockReturnValueOnce({
67
+ data: {
68
+ conversationMemberships: [
69
+ {
70
+ "convo": {
71
+ "last_message_content": "Hi this is a message 24 hours after the appointment date",
72
+ "updated_at": "2023-05-30 15:00:00 -0500",
73
+ "dietitian_id": "coachId",
74
+ "patient_id": "37616"
75
+ }
76
+ },
77
+ {
78
+ "convo": {
79
+ "last_message_content": "\nHi Ash, after talking with you today I thought I’d share this resource with you, http://www.findhelp.org/.\nThis is a helpful way to find housing support in your area. By entering your zip code, you can find local resources. \nLet me know what you learn and what options you are considering. I’m excited to hear more. Talk to you soon.\n",
80
+ "updated_at": "2023-05-31 15:41:38 -0500",
81
+ "dietitian_id": null,
82
+ "patient_id": null
83
+ }
84
+ },
85
+ {
86
+ "convo": {
87
+ "last_message_content": "",
88
+ "updated_at": "2023-02-03 09:41:45 -0600",
89
+ "dietitian_id": null,
90
+ "patient_id": null
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ })
96
+ });
97
+ await checkForChat_1.checkForChat.onActivityCreated({
98
+ pathway: {
99
+ id: 'pathway-id',
100
+ definition_id: 'pathway-definition-id'
101
+ },
102
+ activity: {
103
+ id: 'activity-id'
104
+ },
105
+ patient: { id: 'test-patient' },
106
+ fields: {
107
+ patientId: 'patientIdTest',
108
+ coachId: 'coachId',
109
+ appointmentTime: '2023-05-28'
110
+ },
111
+ settings: {
112
+ apiKey: 'apiKey',
113
+ apiUrl: 'test-url',
114
+ selectEventTypeQuestion: '2602707',
115
+ startSendingRemindersQuestions: '3860906',
116
+ memberEventFormId: '281216'
117
+ },
118
+ }, onComplete, onError);
119
+ expect(wellinksSdk_2.mockGetSdkReturn.getConversationMemberships).toHaveBeenCalled();
120
+ expect(onComplete).toHaveBeenCalledWith({
121
+ data_points: {
122
+ messageSent: 'true'
123
+ }
124
+ });
125
+ });
126
+ test('when given a list of conversationMemberships where there is not a message sent 24 hours after the appointmentDate returns false', async () => {
127
+ wellinksSdk_1.getSdk.mockReturnValueOnce({
128
+ ...wellinksSdk_2.mockGetSdkReturn,
129
+ getConversationMemberships: wellinksSdk_2.mockGetSdkReturn.getConversationMemberships.mockReturnValueOnce({
130
+ data: {
131
+ conversationMemberships: [
132
+ {
133
+ "convo": {
134
+ "last_message_content": "There is no message within 24 hours of the appointment date",
135
+ "updated_at": "2023-05-30 15:00:00 -0500",
136
+ "dietitian_id": "coachId",
137
+ "patient_id": "37616"
138
+ }
139
+ },
140
+ {
141
+ "convo": {
142
+ "last_message_content": "\nHi Ash, after talking with you today I thought I’d share this resource with you, http://www.findhelp.org/.\nThis is a helpful way to find housing support in your area. By entering your zip code, you can find local resources. \nLet me know what you learn and what options you are considering. I’m excited to hear more. Talk to you soon.\n",
143
+ "updated_at": "2023-05-31 15:41:38 -0500",
144
+ "dietitian_id": null,
145
+ "patient_id": null
146
+ }
147
+ },
148
+ {
149
+ "convo": {
150
+ "last_message_content": "",
151
+ "updated_at": "2023-02-03 09:41:45 -0600",
152
+ "dietitian_id": null,
153
+ "patient_id": null
154
+ }
155
+ }
156
+ ]
157
+ }
158
+ })
159
+ });
160
+ await checkForChat_1.checkForChat.onActivityCreated({
161
+ pathway: {
162
+ id: 'pathway-id',
163
+ definition_id: 'pathway-definition-id'
164
+ },
165
+ activity: {
166
+ id: 'activity-id'
167
+ },
168
+ patient: { id: 'test-patient' },
169
+ fields: {
170
+ patientId: 'patientIdTest',
171
+ coachId: 'coachId',
172
+ appointmentTime: '2023-05-01'
173
+ },
174
+ settings: {
175
+ apiKey: 'apiKey',
176
+ apiUrl: 'test-url',
177
+ selectEventTypeQuestion: '2602707',
178
+ startSendingRemindersQuestions: '3860906',
179
+ memberEventFormId: '281216'
180
+ },
181
+ }, onComplete, onError);
182
+ expect(wellinksSdk_2.mockGetSdkReturn.getConversationMemberships).toHaveBeenCalled();
183
+ expect(onComplete).toHaveBeenCalledWith({
184
+ data_points: {
185
+ messageSent: 'false'
186
+ }
187
+ });
188
+ });
189
+ });
190
+ //# sourceMappingURL=checkForChat.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkForChat.test.js","sourceRoot":"","sources":["../../../../../extensions/wellinks/actions/checkForChat/checkForChat.test.ts"],"names":[],"mappings":";;AAAA,uDAA8C;AAC9C,iEAA8E;AAC9E,iDAA6C;AAE7C,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;AAClC,IAAI,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;AAGxC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAEzB,SAAS,CAAC,GAAG,EAAE;QACV,oBAAoB,CAAC,kBAAkB,CAAC,wBAAU,CAAC,CAAA;IAExD,CAAC,CAAC,CAAA;IAEF,UAAU,CAAC,GAAG,EAAE;QACZ,IAAI,CAAC,aAAa,EAAE,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,mBAAmB;IACnB,IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;QAClE,oBAAoB,CAAC,mBAAmB,CACrC;YACI,GAAG,8BAAgB;YACnB,0BAA0B,EAAE,8BAAgB,CAAC,0BAA0B,CAAC,mBAAmB,CAAC;gBACxF,IAAI,EAAE;oBACF,uBAAuB,EAAE,IAAI;iBAChC;aACJ,CAAC;SACL,CAAC,CAAA;QACN,MAAM,2BAAY,CAAC,iBAAiB,CAChC;YACI,OAAO,EAAE;gBACL,EAAE,EAAE,YAAY;gBAChB,aAAa,EAAE,uBAAuB;aACzC;YACD,QAAQ,EAAE;gBACN,EAAE,EAAE,aAAa;aACpB;YACD,OAAO,EAA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;wBACD;4BACI,OAAO,EAAE;gCACL,sBAAsB,EAAE,qVAAqV;gCAC7W,YAAY,EAAE,2BAA2B;gCACzC,cAAc,EAAE,IAAI;gCACpB,YAAY,EAAE,IAAI;6BACrB;yBACJ;wBACD;4BACI,OAAO,EAAE;gCACL,sBAAsB,EAAE,EAAE;gCAC1B,YAAY,EAAE,2BAA2B;gCACzC,cAAc,EAAE,IAAI;gCACpB,YAAY,EAAE,IAAI;6BACrB;yBACJ;qBACJ;iBACJ;aACJ,CAAC;SACL,CACJ,CAAA;QAED,MAAM,2BAAY,CAAC,iBAAiB,CAChC;YACI,OAAO,EAAE;gBACL,EAAE,EAAE,YAAY;gBAChB,aAAa,EAAE,uBAAuB;aACzC;YACD,QAAQ,EAAE;gBACN,EAAE,EAAE,aAAa;aACpB;YACD,OAAO,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE;YAC/B,MAAM,EAAE;gBACJ,SAAS,EAAE,eAAe;gBAC1B,OAAO,EAAE,SAAS;gBAClB,eAAe,EAAE,YAAY;aAChC;YACD,QAAQ,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,UAAU;gBAClB,uBAAuB,EAAE,SAAS;gBAClC,8BAA8B,EAAE,SAAS;gBACzC,iBAAiB,EAAE,QAAQ;aAC9B;SACJ,EACD,UAAU,EACV,OAAO,CACV,CAAA;QAED,MAAM,CAAC,8BAAgB,CAAC,0BAA0B,CAAC,CAAC,gBAAgB,EAAE,CAAA;QACtE,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACpC,WAAW,EAAE;gBACT,WAAW,EAAE,OAAO;aACvB;SACJ,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { FieldType, type Action } from '@awell-health/extensions-core';
2
+ import { type settings } from '../../settings';
3
+ declare const fields: {
4
+ patientId: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.STRING;
9
+ required: true;
10
+ };
11
+ appointmentTime: {
12
+ id: string;
13
+ label: string;
14
+ description: string;
15
+ type: FieldType.STRING;
16
+ required: true;
17
+ };
18
+ };
19
+ declare const dataPoints: {
20
+ activeOverride: {
21
+ key: string;
22
+ valueType: "boolean";
23
+ };
24
+ };
25
+ export declare const checkForCheckInOverride: Action<typeof fields, typeof settings, keyof typeof dataPoints>;
26
+ export {};
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkForCheckInOverride = void 0;
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const extensions_core_2 = require("@awell-health/extensions-core");
6
+ const wellinksSdk_1 = require("../../gql/wellinksSdk");
7
+ const wellinksGraphqlClient_1 = require("../../wellinksGraphqlClient");
8
+ const lodash_1 = require("lodash");
9
+ const fields = {
10
+ patientId: {
11
+ id: 'patientId',
12
+ label: 'Patient ID',
13
+ description: 'The ID of the patiet to check an override for.',
14
+ type: extensions_core_1.FieldType.STRING,
15
+ required: true,
16
+ },
17
+ appointmentTime: {
18
+ id: 'appointmentTime',
19
+ label: 'Appointment Time',
20
+ description: 'The time of the appointment to check against.',
21
+ type: extensions_core_1.FieldType.STRING,
22
+ required: true,
23
+ },
24
+ };
25
+ const dataPoints = {
26
+ activeOverride: {
27
+ key: 'activeOverride',
28
+ valueType: 'boolean',
29
+ }
30
+ };
31
+ exports.checkForCheckInOverride = {
32
+ key: 'checkForCheckInOverride',
33
+ category: extensions_core_2.Category.SCHEDULING,
34
+ title: 'Check if a patient has an active Override for Check In Automation',
35
+ description: 'Check if a patient has an Override form in Healthie for Check In Automation created after the appointment time.',
36
+ fields,
37
+ dataPoints,
38
+ previewable: true,
39
+ onActivityCreated: async (payload, onComplete, onError) => {
40
+ var _a, _b;
41
+ const { fields, settings } = payload;
42
+ const { patientId, appointmentTime } = fields;
43
+ try {
44
+ const client = (0, wellinksGraphqlClient_1.initialiseClient)(settings);
45
+ if (!(0, lodash_1.isNil)(client)) {
46
+ const sdk = (0, wellinksSdk_1.getSdk)(client);
47
+ const { data } = await sdk.getChartingItems({
48
+ user_id: patientId,
49
+ custom_module_form_id: settings.memberEventFormId,
50
+ });
51
+ if (!(0, lodash_1.isNil)(data.chartingItems)) {
52
+ const active = parseListOfForms(data.chartingItems, (_a = settings.selectEventTypeQuestion) !== null && _a !== void 0 ? _a : '', (_b = settings.startSendingRemindersQuestions) !== null && _b !== void 0 ? _b : '', appointmentTime !== null && appointmentTime !== void 0 ? appointmentTime : '');
53
+ if (active) {
54
+ await onComplete({
55
+ data_points: {
56
+ activeOverride: 'true'
57
+ },
58
+ });
59
+ }
60
+ else {
61
+ await onComplete({
62
+ data_points: {
63
+ activeOverride: 'false'
64
+ },
65
+ });
66
+ }
67
+ }
68
+ else {
69
+ await onError({
70
+ events: [
71
+ {
72
+ date: new Date().toISOString(),
73
+ text: {
74
+ en: 'There was in error processing the Charting Items',
75
+ },
76
+ error: {
77
+ category: 'WRONG_DATA',
78
+ message: 'Charting Items returned Null',
79
+ },
80
+ },
81
+ ],
82
+ });
83
+ }
84
+ }
85
+ else {
86
+ await onError({
87
+ events: [
88
+ {
89
+ date: new Date().toISOString(),
90
+ text: { en: 'API client requires an API url and API key' },
91
+ error: {
92
+ category: 'MISSING_SETTINGS',
93
+ message: 'Missing api url or api key',
94
+ },
95
+ },
96
+ ],
97
+ });
98
+ }
99
+ }
100
+ catch (err) {
101
+ const error = err;
102
+ await onError({
103
+ events: [
104
+ {
105
+ date: new Date().toISOString(),
106
+ text: { en: 'There was in error processing the Charting Items' },
107
+ error: {
108
+ category: 'SERVER_ERROR',
109
+ message: error.message,
110
+ },
111
+ },
112
+ ],
113
+ });
114
+ }
115
+ },
116
+ };
117
+ function parseListOfForms(data, eventTypeQuestionId, startDateQuestionId, appointmentTime) {
118
+ if ((0, lodash_1.isNil)(data) || (0, lodash_1.isNil)(appointmentTime) || (0, lodash_1.isNil)(eventTypeQuestionId) || (0, lodash_1.isNil)(startDateQuestionId)) {
119
+ return false;
120
+ }
121
+ else {
122
+ const overrideForms = data.filter((value) => { var _a, _b; return ((_b = (_a = value === null || value === void 0 ? void 0 : value.form_answer_group) === null || _a === void 0 ? void 0 : _a.form_answers.find((value) => value.custom_module_id === eventTypeQuestionId)) === null || _b === void 0 ? void 0 : _b.answer) === "Override check-in automation"; });
123
+ for (const form of overrideForms) {
124
+ if (!(0, lodash_1.isNil)(form) && !(0, lodash_1.isNil)(form.created_at)) {
125
+ if (new Date(form.created_at) > new Date(appointmentTime)) {
126
+ return true;
127
+ }
128
+ }
129
+ }
130
+ return false;
131
+ }
132
+ }
133
+ //# sourceMappingURL=checkForCheckInOverride.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkForCheckInOverride.js","sourceRoot":"","sources":["../../../../../extensions/wellinks/actions/checkForCheckInOverride/checkForCheckInOverride.ts"],"names":[],"mappings":";;;AAAA,mEAKwC;AACtC,mEAAwD;AACxD,uDAA0E;AAC1E,uEAA8D;AAE9D,mCAA8B;AAE9B,MAAM,MAAM,GAAG;IACb,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,gDAAgD;QAC7D,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,eAAe,EAAE;QACb,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,+CAA+C;QAC5D,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;CAC4B,CAAA;AAEjC,MAAM,UAAU,GAAG;IACjB,cAAc,EAAE;QACd,GAAG,EAAE,gBAAgB;QACrB,SAAS,EAAE,SAAS;KACrB;CAC4C,CAAA;AAElC,QAAA,uBAAuB,GAIhC;IACF,GAAG,EAAE,yBAAyB;IAC9B,QAAQ,EAAE,0BAAQ,CAAC,UAAU;IAC7B,KAAK,EAAE,mEAAmE;I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