Skip to content

Commit

Permalink
Clinician messages (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft authored Sep 11, 2024
1 parent b360708 commit 07a5681
Show file tree
Hide file tree
Showing 18 changed files with 555 additions and 274 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ In this section, we describe all user-related data to be stored. The security ru
|invitationCode|string|-|The invitationCode to be used when logging in to the app for the first time.|
|language|optional string|e.g. "en"|Following IETF BCP-47 / [FHIR ValueSet languages](https://hl7.org/fhir/R4B/valueset-languages.html).|
|receivesAppointmentReminders|optional boolean|true, false|Decides whether to send out appointment reminders one day before each appointment.|
|receivesInactivityReminders|optional boolean|true, false|Decides whether to send updates about inactivity.|
|receivesMedicationUpdates|optional boolean|true, false|Decides whether to send updates about current medication changes.|
|receivesQuestionnaireReminders|optional boolean|true, false|Decides whether to send reminders about filling out their questionnaire every 14 days.|
|receivesRecommendationUpdates|optional boolean|true, false|Decides whether to send updates about recommended medication changes.|
Expand Down
18 changes: 18 additions & 0 deletions functions/data/debug/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"user": {
"type": "admin",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -22,6 +23,7 @@
"user": {
"type": "admin",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -36,6 +38,7 @@
"type": "owner",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -50,6 +53,7 @@
"type": "owner",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -64,6 +68,7 @@
"type": "owner",
"organization": "jhu",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -78,6 +83,7 @@
"type": "owner",
"organization": "umich",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -92,6 +98,7 @@
"type": "owner",
"organization": "uw",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -106,6 +113,7 @@
"type": "clinician",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -120,6 +128,7 @@
"type": "clinician",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -134,6 +143,7 @@
"type": "clinician",
"organization": "jhu",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -148,6 +158,7 @@
"type": "clinician",
"organization": "umich",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -162,6 +173,7 @@
"type": "clinician",
"organization": "uw",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -176,6 +188,7 @@
"type": "patient",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -190,6 +203,7 @@
"type": "patient",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -204,6 +218,7 @@
"type": "patient",
"organization": "stanford",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -218,6 +233,7 @@
"type": "patient",
"organization": "jhu",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -232,6 +248,7 @@
"type": "patient",
"organization": "jhu",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
},
Expand All @@ -246,6 +263,7 @@
"type": "patient",
"organization": "jhu",
"dateOfEnrollment": "1970-01-01T00:00:00.000Z",
"lastActiveDate": "1970-01-01T00:00:00.000Z",
"invitationCode": ""
}
}
Expand Down
6 changes: 6 additions & 0 deletions functions/models/src/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ export const userConverter = new Lazy(
.extend({
dateOfEnrollment: dateConverter.schema,
invitationCode: z.string(),
lastActiveDate: dateConverter.schema,
})
.transform((values) => new User(values)),
encode: (object) => ({
...userRegistrationConverter.value.encode(object),
lastActiveDate: dateConverter.encode(object.lastActiveDate),
dateOfEnrollment: dateConverter.encode(object.dateOfEnrollment),
invitationCode: object.invitationCode,
}),
Expand All @@ -39,6 +41,7 @@ export class User extends UserRegistration {

readonly dateOfEnrollment: Date
readonly invitationCode: string
readonly lastActiveDate: Date

// Constructor

Expand All @@ -48,6 +51,7 @@ export class User extends UserRegistration {
dateOfBirth?: Date
clinician?: string
receivesAppointmentReminders: boolean
receivesInactivityReminders: boolean
receivesMedicationUpdates: boolean
receivesQuestionnaireReminders: boolean
receivesRecommendationUpdates: boolean
Expand All @@ -57,9 +61,11 @@ export class User extends UserRegistration {
timeZone?: string
dateOfEnrollment: Date
invitationCode: string
lastActiveDate: Date
}) {
super(input)
this.dateOfEnrollment = input.dateOfEnrollment
this.invitationCode = input.invitationCode
this.lastActiveDate = input.lastActiveDate
}
}
28 changes: 27 additions & 1 deletion functions/models/src/types/userMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum UserMessageType {
vitals = 'Vitals',
symptomQuestionnaire = 'SymptomQuestionnaire',
preAppointment = 'PreAppointment',
inactive = 'Inactive',
}

export const userMessageConverter = new Lazy(
Expand Down Expand Up @@ -67,6 +68,26 @@ export const userMessageConverter = new Lazy(
export class UserMessage {
// Static Functions

static createInactive(input: {
creationDate?: Date
reference?: string
isDismissible?: boolean
}): UserMessage {
return new UserMessage({
creationDate: input.creationDate ?? new Date(),
title: new LocalizedText({
en: 'Inactive',
}),
description: new LocalizedText({
en: 'You have been inactive for 7 days. Please log in to continue your care.',
}),
action: undefined,
type: UserMessageType.inactive,
isDismissible: input.isDismissible ?? false,
reference: input.reference,
})
}

static createMedicationChange(input: {
creationDate?: Date
reference: string
Expand All @@ -91,6 +112,7 @@ export class UserMessage {
static createMedicationUptitration(
input: {
creationDate?: Date
reference?: string
} = {},
): UserMessage {
return new UserMessage({
Expand All @@ -101,6 +123,7 @@ export class UserMessage {
description: new LocalizedText({
en: 'You may be eligible for med changes that may help your heart. Your care team will be sent this information. You can review med information on the Education Page.',
}),
reference: input.reference,
action: 'medications',
type: UserMessageType.medicationUptitration,
isDismissible: true,
Expand All @@ -111,6 +134,7 @@ export class UserMessage {
input: {
creationDate?: Date
reference?: string
isDismissible?: boolean
} = {},
): UserMessage {
return new UserMessage({
Expand All @@ -123,7 +147,7 @@ export class UserMessage {
}),
action: 'healthSummary',
type: UserMessageType.preAppointment,
isDismissible: false,
isDismissible: input.isDismissible ?? false,
reference: input.reference,
})
}
Expand Down Expand Up @@ -170,6 +194,7 @@ export class UserMessage {
static createWeightGain(
input: {
creationDate?: Date
reference?: string
} = {},
): UserMessage {
return new UserMessage({
Expand All @@ -181,6 +206,7 @@ export class UserMessage {
en: 'Your weight increased over 3 lbs. Your care team will be informed. Please follow any instructions about diuretic changes after weight increase on the Medication page.',
}),
action: 'medications',
reference: input.reference,
type: UserMessageType.weightGain,
isDismissible: true,
})
Expand Down
5 changes: 5 additions & 0 deletions functions/models/src/types/userRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const userRegistrationInputConverter = new Lazy(
dateOfBirth: optionalish(dateConverter.schema),
clinician: optionalish(z.string()),
receivesAppointmentReminders: optionalishDefault(z.boolean(), true),
receivesInactivityReminders: optionalishDefault(z.boolean(), true),
receivesMedicationUpdates: optionalishDefault(z.boolean(), true),
receivesQuestionnaireReminders: optionalishDefault(z.boolean(), true),
receivesRecommendationUpdates: optionalishDefault(z.boolean(), true),
Expand All @@ -37,6 +38,7 @@ export const userRegistrationInputConverter = new Lazy(
object.dateOfBirth ? dateConverter.encode(object.dateOfBirth) : null,
clinician: object.clinician ?? null,
receivesAppointmentReminders: object.receivesAppointmentReminders,
receivesInactivityReminders: object.receivesInactivityReminders,
receivesMedicationUpdates: object.receivesMedicationUpdates,
receivesQuestionnaireReminders: object.receivesQuestionnaireReminders,
receivesRecommendationUpdates: object.receivesRecommendationUpdates,
Expand Down Expand Up @@ -68,6 +70,7 @@ export class UserRegistration {
readonly clinician?: string

readonly receivesAppointmentReminders: boolean
readonly receivesInactivityReminders: boolean
readonly receivesMedicationUpdates: boolean
readonly receivesQuestionnaireReminders: boolean
readonly receivesRecommendationUpdates: boolean
Expand All @@ -85,6 +88,7 @@ export class UserRegistration {
dateOfBirth?: Date
clinician?: string
receivesAppointmentReminders: boolean
receivesInactivityReminders: boolean
receivesMedicationUpdates: boolean
receivesQuestionnaireReminders: boolean
receivesRecommendationUpdates: boolean
Expand All @@ -98,6 +102,7 @@ export class UserRegistration {
this.dateOfBirth = input.dateOfBirth
this.clinician = input.clinician
this.receivesAppointmentReminders = input.receivesAppointmentReminders
this.receivesInactivityReminders = input.receivesInactivityReminders
this.receivesMedicationUpdates = input.receivesMedicationUpdates
this.receivesQuestionnaireReminders = input.receivesQuestionnaireReminders
this.receivesRecommendationUpdates = input.receivesRecommendationUpdates
Expand Down
1 change: 1 addition & 0 deletions functions/src/functions/checkInvitationCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describeWithEmulators('function: checkInvitationCode', (env) => {
type: UserType.patient,
organization: 'stanford',
receivesAppointmentReminders: true,
receivesInactivityReminders: true,
receivesMedicationUpdates: true,
receivesQuestionnaireReminders: true,
receivesRecommendationUpdates: true,
Expand Down
3 changes: 3 additions & 0 deletions functions/src/functions/createInvitation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describeWithEmulators('function: createInvitation', (env) => {
type: UserType.clinician,
organization: 'stanford',
receivesAppointmentReminders: false,
receivesInactivityReminders: true,
receivesMedicationUpdates: true,
receivesQuestionnaireReminders: false,
receivesRecommendationUpdates: true,
Expand Down Expand Up @@ -57,6 +58,7 @@ describeWithEmulators('function: createInvitation', (env) => {
type: UserType.patient,
organization: 'stanford',
receivesAppointmentReminders: false,
receivesInactivityReminders: true,
receivesMedicationUpdates: true,
receivesQuestionnaireReminders: false,
receivesRecommendationUpdates: true,
Expand Down Expand Up @@ -87,6 +89,7 @@ describeWithEmulators('function: createInvitation', (env) => {
type: UserType.patient,
organization: 'stanford',
receivesAppointmentReminders: true,
receivesInactivityReminders: true,
receivesMedicationUpdates: true,
receivesQuestionnaireReminders: true,
receivesRecommendationUpdates: true,
Expand Down
Loading

0 comments on commit 07a5681

Please sign in to comment.