Skip to content

Commit

Permalink
Extract UserObservationCollection to models package (#156)
Browse files Browse the repository at this point in the history
# Extract UserObservationCollection to models package

## ♻️ Current situation & Problem
`UserObservationCollection` is part of the FIREBASE repository, but it's
not part of the `models` package. It would beneficial to reference it
from dashboard.

## ⚙️ Release Notes 
* Extract UserObservationCollection to models package


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
arkadiuszbachorski authored Oct 8, 2024
1 parent bea1a30 commit 038e5ed
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
10 changes: 10 additions & 0 deletions functions/models/src/fhir/fhirObservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ import { optionalish } from '../helpers/optionalish.js'
import { SchemaConverter } from '../helpers/schemaConverter.js'
import { type Observation } from '../types/observation.js'

export enum UserObservationCollection {
bodyWeight = 'bodyWeightObservations',
bloodPressure = 'bloodPressureObservations',
creatinine = 'creatinineObservations',
dryWeight = 'dryWeightObservations',
eGfr = 'eGfrObservations',
heartRate = 'heartRateObservations',
potassium = 'potassiumObservations',
}

export enum FHIRObservationStatus {
registered = 'registered',
preliminary = 'preliminary',
Expand Down
2 changes: 1 addition & 1 deletion functions/src/functions/defaultSeed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
StaticDataComponent,
UserDebugDataComponent,
UserType,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { expect } from 'chai'
import { _defaultSeed } from './defaultSeed.js'
import { UserObservationCollection } from '../services/database/collections.js'
import { describeWithEmulators } from '../tests/functions/testEnvironment.js'

describeWithEmulators('function: defaultSeed', (env) => {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/functions/enrollUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
UserMessageType,
UserRegistration,
UserType,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { expect } from 'chai'
import { enrollUser } from './enrollUser.js'
import { UserObservationCollection } from '../services/database/collections.js'
import { describeWithEmulators } from '../tests/functions/testEnvironment.js'
import { expectError } from '../tests/helpers.js'

Expand Down
2 changes: 1 addition & 1 deletion functions/src/functions/onUserDocumentWritten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import {
fhirMedicationRequestConverter,
fhirQuestionnaireResponseConverter,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { onDocumentWritten } from 'firebase-functions/v2/firestore'
import { UserObservationCollection } from '../services/database/collections.js'
import { DatabaseConverter } from '../services/database/databaseConverter.js'
import { getServiceFactory } from '../services/factory/getServiceFactory.js'

Expand Down
11 changes: 1 addition & 10 deletions functions/src/services/database/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,12 @@ import {
userMessageConverter,
videoConverter,
videoSectionConverter,
type UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { type Firestore } from 'firebase-admin/firestore'
import { DatabaseConverter } from './databaseConverter.js'
import { historyChangeItemConverter } from '../history/historyService.js'

export enum UserObservationCollection {
bodyWeight = 'bodyWeightObservations',
bloodPressure = 'bloodPressureObservations',
creatinine = 'creatinineObservations',
dryWeight = 'dryWeightObservations',
eGfr = 'eGfrObservations',
heartRate = 'heartRateObservations',
potassium = 'potassiumObservations',
}

export class CollectionsService {
// Properties

Expand Down
2 changes: 1 addition & 1 deletion functions/src/services/patient/databasePatientService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {
type SymptomScore,
type UserMedicationRecommendation,
UserMedicationRecommendationType,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { type PatientService } from './patientService.js'
import { UserObservationCollection } from '../database/collections.js'
import {
type Document,
type DatabaseService,
Expand Down
6 changes: 2 additions & 4 deletions functions/src/services/seeding/debugData/debugDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ import {
type UserSeedingOptions,
userSeedingOptionsSchema,
VideoReference,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { type Auth } from 'firebase-admin/auth'
import { type CollectionReference } from 'firebase-admin/firestore'
import { type Storage } from 'firebase-admin/storage'
import { logger } from 'firebase-functions'
import {
type CollectionsService,
UserObservationCollection,
} from '../../database/collections.js'
import { type CollectionsService } from '../../database/collections.js'
import { type DatabaseService } from '../../database/databaseService.js'
import { SeedingService } from '../seedingService.js'

Expand Down
2 changes: 1 addition & 1 deletion functions/src/services/trigger/triggerService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
UserMessage,
UserMessageType,
UserType,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { expect } from 'chai'
import { describeWithEmulators } from '../../tests/functions/testEnvironment.js'
import { UserObservationCollection } from '../database/collections.js'

describeWithEmulators('TriggerService', (env) => {
describe('every15Minutes', () => {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/services/trigger/triggerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {
UserMessage,
UserMessageType,
VideoReference,
UserObservationCollection,
} from '@stanfordbdhg/engagehf-models'
import { logger } from 'firebase-functions'
import { UserObservationCollection } from '../database/collections.js'
import { type ServiceFactory } from '../factory/serviceFactory.js'
import { type PatientService } from '../patient/patientService.js'
import { type RecommendationVitals } from '../recommendation/recommendationService.js'
Expand Down

0 comments on commit 038e5ed

Please sign in to comment.