diff --git a/functions/data/questionnaires.json b/functions/data/questionnaires.json index 3e8c3dbf..fe934bd0 100644 --- a/functions/data/questionnaires.json +++ b/functions/data/questionnaires.json @@ -729,7 +729,7 @@ { "valueCoding": { "id": "80df26e0-55a6-4d50-90de-b60cd851c4fb", - "code": "1", + "code": "5", "system": "urn:uuid:2b2f9a9a-e721-495a-82d6-fbc1b22a27b2", "display": "Extremely bothersome" } @@ -737,7 +737,7 @@ { "valueCoding": { "id": "473f99f2-b9d2-4e92-85ed-ca78f3e0141c", - "code": "2", + "code": "4", "system": "urn:uuid:2b2f9a9a-e721-495a-82d6-fbc1b22a27b2", "display": "Quite a bit bothersome" } @@ -753,7 +753,7 @@ { "valueCoding": { "id": "253f487a-f26b-442f-8757-8a2401465fed", - "code": "4", + "code": "2", "system": "urn:uuid:2b2f9a9a-e721-495a-82d6-fbc1b22a27b2", "display": "Slightly bothersome" } @@ -761,7 +761,7 @@ { "valueCoding": { "id": "7de45367-76b2-4b9b-8e4e-050bae6b309c", - "code": "5", + "code": "1", "system": "urn:uuid:2b2f9a9a-e721-495a-82d6-fbc1b22a27b2", "display": "Not at all bothersome" } @@ -769,7 +769,7 @@ { "valueCoding": { "id": "3d1a8f9b-e666-4ad4-9202-571313a2b5d1", - "code": "6", + "code": "0", "system": "urn:uuid:2b2f9a9a-e721-495a-82d6-fbc1b22a27b2", "display": "I've had no dizziness" } diff --git a/functions/src/functions/enrollUser.test.ts b/functions/src/functions/enrollUser.test.ts index 416b23a1..7d18a06e 100644 --- a/functions/src/functions/enrollUser.test.ts +++ b/functions/src/functions/enrollUser.test.ts @@ -143,9 +143,17 @@ describeWithEmulators('function: enrollUser', (env) => { } const userMessages = await env.collections.userMessages(authUser.uid).get() - expect(userMessages.docs.length).to.equal(1) - expect(userMessages.docs.at(0)?.data().type).to.equal( - UserMessageType.welcome, - ) + expect(userMessages.docs.length).to.equal(2) + expect( + userMessages.docs.find( + (message) => message.data().type == UserMessageType.welcome, + ), + ).to.exist + expect( + userMessages.docs.find( + (message) => + message.data().type == UserMessageType.symptomQuestionnaire, + ), + ).to.exist }) }) diff --git a/functions/src/services/trigger/triggerService.test.ts b/functions/src/services/trigger/triggerService.test.ts index 919f9e07..7d4eb202 100644 --- a/functions/src/services/trigger/triggerService.test.ts +++ b/functions/src/services/trigger/triggerService.test.ts @@ -57,7 +57,7 @@ describeWithEmulators('TriggerService', (env) => { const patientMessages = await env.collections .userMessages(patientId) .get() - expect(patientMessages.docs).to.have.length(3) + expect(patientMessages.docs).to.have.length(2) const preAppointmentMessages = patientMessages.docs.filter( (doc) => doc.data().type === UserMessageType.preAppointment, ) @@ -133,7 +133,7 @@ describeWithEmulators('TriggerService', (env) => { const patientMessages = await env.collections .userMessages(patientId) .get() - expect(patientMessages.docs).to.have.length(3) + expect(patientMessages.docs).to.have.length(2) const preAppointmentMessages = patientMessages.docs.filter( (doc) => doc.data().type === UserMessageType.preAppointment, ) diff --git a/functions/src/services/trigger/triggerService.ts b/functions/src/services/trigger/triggerService.ts index 320ca0e0..58009c2b 100644 --- a/functions/src/services/trigger/triggerService.ts +++ b/functions/src/services/trigger/triggerService.ts @@ -152,6 +152,20 @@ export class TriggerService { `TriggerService.userEnrolled(${user.id}): Adding welcome message failed due to ${String(error)}`, ) } + + try { + await this.factory.message().addMessage( + user.id, + UserMessage.createSymptomQuestionnaire({ + questionnaireReference: QuestionnaireReference.enUS, + }), + { notify: true }, + ) + } catch (error) { + logger.error( + `TriggerService.userEnrolled(${user.id}): Adding symptom questionnaire message failed due to ${String(error)}`, + ) + } } async userAllergyIntoleranceWritten(userId: string): Promise { @@ -601,7 +615,8 @@ export class TriggerService { ) if ( enrollmentDuration % (durationOfOneDayInMilliseconds * 14) < - durationOfOneDayInMilliseconds + durationOfOneDayInMilliseconds && + enrollmentDuration > durationOfOneDayInMilliseconds ) { await options.messageService.addMessage( user.id,