Skip to content

Commit

Permalink
Add questionnaireResponses
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbachorski committed Oct 7, 2024
1 parent e14be18 commit c956710
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/firebase/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
type fhirElementConverter,
type fhirMedicationRequestConverter,
type fhirObservationConverter,
type fhirQuestionnaireResponseConverter,
type fhirResourceConverter,
type InferEncoded,
type invitationConverter,
Expand Down Expand Up @@ -67,4 +68,10 @@ export type UserMessage = InferEncoded<typeof userMessageConverter> & {
id: string
}

export type QuestionnaireResponse = InferEncoded<
typeof fhirQuestionnaireResponseConverter
> & {
id: string
}

export type LocalizedText = string | Record<string, string>
12 changes: 12 additions & 0 deletions modules/firebase/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const collectionNames = {
eGfrObservations: 'eGfrObservations',
potassiumObservations: 'potassiumObservations',
messages: 'messages',
questionnaireResponses: 'questionnaireResponses',
}

export type ResourceType = 'invitation' | 'user'
Expand Down Expand Up @@ -166,6 +167,17 @@ export const getCollectionRefs = (db: Firestore) => ({
db,
`/${collectionNames.users}/${userId}/${collectionNames.messages}`,
) as CollectionReference<UserMessage>,
questionnaireResponses: ({
userId,
resourceType,
}: {
userId: string
resourceType: ResourceType
}) =>
collection(
db,
`/${userPath(resourceType)}/${userId}/${collectionNames.questionnaireResponses}`,
) as CollectionReference<QuestionnaireResponse>,
})

export const getDocumentsRefs = (db: Firestore) => ({
Expand Down

0 comments on commit c956710

Please sign in to comment.