-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): data exchange for multiple forms (#471)
* feat(): data exchange for multiple forms * fix(tests): twilio
- Loading branch information
Showing
44 changed files
with
14,245 additions
and
12,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './pushFormResponseToHealthie' | ||
export * from './pushFormResponsesToHealthie' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...thie/actions/dataExchange/pushFormResponsesToHealthie/__mocks__/formDefinitionResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export const mockFormDefinitionOneResponse = { | ||
form: { | ||
questions: [ | ||
{ | ||
options: [], | ||
key: 'PATIENT_FN', | ||
id: 'PSpxniOv52vQ', | ||
definition_id: '4kLSm6MPL4RO', | ||
title: "What's the patient's first name?", | ||
dataPointValueType: 'STRING', | ||
questionType: 'INPUT', | ||
userQuestionType: 'SHORT_TEXT', | ||
metadata: '{"healthieCustomModuleId": "14460375"}', | ||
__typename: 'Question', | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export const mockFormDefinitionTwoResponse = { | ||
form: { | ||
questions: [ | ||
{ | ||
options: [], | ||
key: 'PATIENT_LN', | ||
id: 'ABOb9suU2dMc', | ||
definition_id: 'R9EjG3z4Yi3H', | ||
title: "What's the patient's last name?", | ||
dataPointValueType: 'STRING', | ||
questionType: 'INPUT', | ||
userQuestionType: 'SHORT_TEXT', | ||
metadata: '{"healthieCustomModuleId": "14460376"}', | ||
__typename: 'Question', | ||
}, | ||
], | ||
}, | ||
} |
27 changes: 27 additions & 0 deletions
27
...althie/actions/dataExchange/pushFormResponsesToHealthie/__mocks__/formResponseResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export const mockFormResponseOneResponse = { | ||
response: { | ||
answers: [ | ||
{ | ||
question_id: 'PSpxniOv52vQ', | ||
value: 'Nick', | ||
label: null, | ||
value_type: 'STRING', | ||
__typename: 'Answer', | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export const mockFormResponseTwoResponse = { | ||
response: { | ||
answers: [ | ||
{ | ||
question_id: 'ABOb9suU2dMc', | ||
value: 'Hellemans', | ||
label: null, | ||
value_type: 'STRING', | ||
__typename: 'Answer', | ||
}, | ||
], | ||
}, | ||
} |
3 changes: 3 additions & 0 deletions
3
extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/__mocks__/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './formDefinitionResponse' | ||
export * from './formResponseResponse' | ||
export * from './pathwayActivitiesResponse' |
89 changes: 89 additions & 0 deletions
89
...e/actions/dataExchange/pushFormResponsesToHealthie/__mocks__/pathwayActivitiesResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
export const mockPathwayActivitiesResponse = { | ||
success: true, | ||
activities: [ | ||
{ | ||
id: 'X74HeDQ4N0gtdaSEuzF8s', | ||
status: 'ACTIVE', | ||
date: '2024-09-11T22:56:59.607Z', | ||
object: { | ||
id: 'w1EgLnVu5ApP', | ||
type: 'PLUGIN_ACTION', | ||
}, | ||
context: { | ||
step_id: 'Xkn5dkyPA5uW', | ||
}, | ||
}, | ||
{ | ||
id: 'form_acitity_2', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:08.315Z', | ||
object: { | ||
id: 'form_2', | ||
type: 'FORM', | ||
}, | ||
context: { | ||
step_id: 'Xkn5dkyPA5uW', | ||
}, | ||
}, | ||
{ | ||
id: 'form_acitity_1', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:08.315Z', | ||
object: { | ||
id: 'form_1', | ||
type: 'FORM', | ||
}, | ||
context: { | ||
step_id: 'Xkn5dkyPA5uW', | ||
}, | ||
}, | ||
{ | ||
id: 'shkMEWqOzHQMsYrGS6yId', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:08.113Z', | ||
object: { | ||
id: 'Q3KUacz4qEmn', | ||
type: 'STEP', | ||
}, | ||
context: { | ||
step_id: 'Xkn5dkyPA5uW', | ||
}, | ||
}, | ||
{ | ||
id: 'f2IjXGjg7YoHZ7lEF0l5j', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:07.980Z', | ||
object: { | ||
id: 'Q3KUacz4qEmn', | ||
type: 'STEP', | ||
}, | ||
context: { | ||
step_id: 'Xkn5dkyPA5uW', | ||
}, | ||
}, | ||
{ | ||
id: 'IiEYazcYE04vhFiCL9tLG', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:07.910Z', | ||
object: { | ||
id: 'LTKNrxc5nt9o', | ||
type: 'TRACK', | ||
}, | ||
context: { | ||
step_id: null, | ||
}, | ||
}, | ||
{ | ||
id: 'Kp90kFg1PUTkszxVGEmOM', | ||
status: 'DONE', | ||
date: '2024-09-11T22:56:07.736Z', | ||
object: { | ||
id: 'PRjP57V2EA1n', | ||
type: 'PATHWAY', | ||
}, | ||
context: { | ||
step_id: null, | ||
}, | ||
}, | ||
], | ||
} |
8 changes: 8 additions & 0 deletions
8
extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/datapoints.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { type DataPointDefinition } from '@awell-health/extensions-core' | ||
|
||
export const datapoints = { | ||
formAnswerGroupId: { | ||
key: 'formAnswerGroupId', | ||
valueType: 'string', | ||
}, | ||
} satisfies Record<string, DataPointDefinition> |
24 changes: 24 additions & 0 deletions
24
extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FieldType, type Field } from '@awell-health/extensions-core' | ||
import z, { type ZodTypeAny } from 'zod' | ||
|
||
export const fields = { | ||
healthiePatientId: { | ||
id: 'healthiePatientId', | ||
label: 'Healthie patient ID', | ||
description: 'The ID of the patient in Healthie', | ||
type: FieldType.STRING, | ||
required: true, | ||
}, | ||
healthieFormId: { | ||
id: 'healthieFormId', | ||
label: 'Healthie form ID', | ||
description: 'The ID of the form in Healthie', | ||
type: FieldType.STRING, | ||
required: true, | ||
}, | ||
} satisfies Record<string, Field> | ||
|
||
export const FieldsValidationSchema = z.object({ | ||
healthiePatientId: z.string().min(1), | ||
healthieFormId: z.string().min(1), | ||
} satisfies Record<keyof typeof fields, ZodTypeAny>) |
2 changes: 2 additions & 0 deletions
2
extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { fields, FieldsValidationSchema } from './fields' | ||
export { datapoints } from './datapoints' |
1 change: 1 addition & 0 deletions
1
extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { pushFormResponsesToHealthie } from './pushFormResponsesToHealthie' |
79 changes: 79 additions & 0 deletions
79
...taExchange/pushFormResponsesToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { getSubActivityLogs, HealthieOmitType } from '.' | ||
|
||
describe('getMappingStatus', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
test('Should work when there are mapping errors', async () => { | ||
const data = [ | ||
{ | ||
questionId: 'question_1', | ||
reason: | ||
'No corresponding question definition found in the form definition', | ||
omitType: HealthieOmitType.QUESTION_NOT_FOUND_IN_FORM_DEFINITION, | ||
}, | ||
{ | ||
questionId: 'question_2', | ||
reason: | ||
'Unable to map this question to a Healthie question because it misses the `healthieCustomModuleId` metadata required for proper integration.', | ||
omitType: HealthieOmitType.MISSING_MAPPING, | ||
}, | ||
{ | ||
questionId: 'question_3', | ||
reason: 'Unknown error', | ||
omitType: HealthieOmitType.OTHER, | ||
}, | ||
{ | ||
questionId: 'question_4', | ||
reason: | ||
'Unable to map this question to a Healthie question because it misses the `healthieCustomModuleId` metadata required for proper integration.', | ||
omitType: HealthieOmitType.MISSING_MAPPING, | ||
}, | ||
] | ||
|
||
const res = getSubActivityLogs(data) | ||
|
||
expect(res).toEqual([ | ||
{ | ||
date: expect.any(String), | ||
text: { | ||
en: 'Missing mapping for the below questions: question_2, question_4', | ||
}, | ||
error: { | ||
category: 'MISSING_SETTINGS', | ||
message: | ||
'Missing mapping for the below questions: question_2, question_4', | ||
}, | ||
}, | ||
{ | ||
date: expect.any(String), | ||
text: { | ||
en: 'The following questions in the response could not be linked to a question definition in the form definition: question_1', | ||
}, | ||
error: { | ||
category: 'SERVER_ERROR', | ||
message: | ||
'The following questions in the response could not be linked to a question definition in the form definition: question_1', | ||
}, | ||
}, | ||
{ | ||
date: expect.any(String), | ||
text: { | ||
en: 'There was an unexpected error transforming the following Awell form answers to Healthie form answers: question_3: Unknown error', | ||
}, | ||
error: { | ||
category: 'SERVER_ERROR', | ||
message: | ||
'There was an unexpected error transforming the following Awell form answers to Healthie form answers: question_3: Unknown error', | ||
}, | ||
}, | ||
]) | ||
}) | ||
|
||
test('Should work when there are no mapping errors', async () => { | ||
const res = getSubActivityLogs([]) | ||
|
||
expect(res).toEqual([]) | ||
}) | ||
}) |
Oops, something went wrong.