Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use engagehf-models package #41

Merged
merged 22 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT
# Stanford Biodesign Digital Health ENGAGE-HF Web Frontend

[![Build and Test](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/build-and-test.yml)
[![Deployment](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/main.yml/badge.svg)](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/main.yml)
[![Deployment](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/deployment.yml/badge.svg)](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/actions/workflows/deployment.yml)
[![codecov](https://codecov.io/gh/StanfordBDHG/ENGAGE-HF-Web-Frontend/graph/badge.svg?token=PsKyNz7Woe)](https://codecov.io/gh/StanfordBDHG/ENGAGE-HF-Web-Frontend)

## How To Use ENGAGE-HF Web Frontend
Expand Down
2 changes: 1 addition & 1 deletion modules/firebase/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
import { useNavigate } from '@tanstack/react-router'
import { type ReactNode, useEffect } from 'react'
import { auth } from '@/modules/firebase/guards'
import { auth } from '@/modules/firebase/app'

Check warning on line 10 in modules/firebase/AuthProvider.ts

View check run for this annotation

Codecov / codecov/patch

modules/firebase/AuthProvider.ts#L10

Added line #L10 was not covered by tests
import { routes } from '@/modules/routes'
import { useAuthUser } from '@/packages/design-system/src/modules/auth/hooks'

Expand Down
2 changes: 1 addition & 1 deletion modules/firebase/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// SPDX-License-Identifier: MIT
//
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'
import { getCurrentUser } from '@/modules/firebase/guards'
import { getCurrentUser } from '@/modules/firebase/app'
import { getUserInfo } from '@/packages/design-system/src/modules/auth/user'

Check warning on line 10 in modules/firebase/UserProvider.tsx

View check run for this annotation

Codecov / codecov/patch

modules/firebase/UserProvider.tsx#L9-L10

Added lines #L9 - L10 were not covered by tests

export const currentUserQueryOptions = () =>
queryOptions({
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion modules/firebase/guards.tsx → modules/firebase/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
import { initializeApp } from '@firebase/app'
import { connectFunctionsEmulator, getFunctions } from '@firebase/functions'
import { type UserType } from '@stanfordbdhg/engagehf-models'
import { queryOptions } from '@tanstack/react-query'
import { redirect } from '@tanstack/react-router'
import { connectAuthEmulator, getAuth, OAuthProvider } from 'firebase/auth'
Expand All @@ -19,7 +20,6 @@ import {
getCollectionRefs,
getDocDataOrThrow,
getDocumentsRefs,
type UserType,
} from '@/modules/firebase/utils'

const firebaseApp = initializeApp(firebaseConfig)
Expand Down
2 changes: 1 addition & 1 deletion modules/firebase/localizedText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: MIT
//
import { isObject } from 'lodash'
import { type LocalizedText } from '@/modules/firebase/models/medication'
import { type LocalizedText } from '@/modules/firebase/models'

const locale = 'en'

Expand Down
62 changes: 62 additions & 0 deletions modules/firebase/medication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// This source file is part of the ENGAGE-HF project based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//
import { type FHIRMedicationRequest } from '@/modules/firebase/models'

export const getMedicationRequestData = (medication: {
medication: string
drug: string
frequencyPerDay: number
quantity: number
instructions: string
}): FHIRMedicationRequest => ({
id: null,
extension: null,
resourceType: 'MedicationRequest',
medicationReference: {
reference: `medications/${medication.medication}/drugs/${medication.drug}`,
type: null,
display: null,
identifier: null,
},
dosageInstruction: [
{
text: medication.instructions,
timing: {
code: null,
repeat: {
frequency: medication.frequencyPerDay,
period: 1,
periodUnit: 'd',
timeOfDay: null,
},
},
doseAndRate: [
{
type: null,
doseQuantity: {
code: '{tbl}',
system: 'http://unitsofmeasure.org',
unit: 'tbl.',
value: medication.quantity,
},
},
],
patientInstruction: null,
},
],
})

Check warning on line 52 in modules/firebase/medication.ts

View check run for this annotation

Codecov / codecov/patch

modules/firebase/medication.ts#L16-L52

Added lines #L16 - L52 were not covered by tests

export const getMedicationRequestMedicationIds = (
request: FHIRMedicationRequest,
) => {
const reference = request.medicationReference?.reference.split('/')
return {
medicationId: reference?.at(1),
drugId: reference?.at(3),
}
}

Check warning on line 62 in modules/firebase/medication.ts

View check run for this annotation

Codecov / codecov/patch

modules/firebase/medication.ts#L54-L62

Added lines #L54 - L62 were not covered by tests
63 changes: 63 additions & 0 deletions modules/firebase/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// This source file is part of the Stanford Biodesign Digital Health ENGAGE-HF open-source project
//
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
import type {
fhirAllergyIntoleranceConverter,
fhirAppointmentConverter,
fhirCodingConverter,
fhirElementConverter,
fhirMedicationRequestConverter,
fhirObservationConverter,
fhirResourceConverter,
InferEncoded,
invitationConverter,
medicationClassConverter,
organizationConverter,
userConverter,
} from '@stanfordbdhg/engagehf-models'

export type Organization = InferEncoded<typeof organizationConverter> & {
id: string
}

export type Invitation = InferEncoded<typeof invitationConverter>

export type User = InferEncoded<typeof userConverter> & { id: string }

export type FHIRElement = InferEncoded<typeof fhirElementConverter>
export const basicFhirElement: FHIRElement = {
id: null,
extension: null,
}

Check warning on line 35 in modules/firebase/models.ts

View check run for this annotation

Codecov / codecov/patch

modules/firebase/models.ts#L32-L35

Added lines #L32 - L35 were not covered by tests

export type FHIRResource = InferEncoded<typeof fhirResourceConverter>

export type FHIRCoding = InferEncoded<typeof fhirCodingConverter>
export const basicFhirCoding: FHIRCoding = {
...basicFhirElement,
system: null,
version: null,
code: null,
display: null,
userSelected: null,
}

Check warning on line 47 in modules/firebase/models.ts

View check run for this annotation

Codecov / codecov/patch

modules/firebase/models.ts#L40-L47

Added lines #L40 - L47 were not covered by tests

export type FHIRMedicationRequest = InferEncoded<
typeof fhirMedicationRequestConverter
>

export type MedicationClass = InferEncoded<typeof medicationClassConverter>

export type FHIRObservation = InferEncoded<typeof fhirObservationConverter>

export type FHIRAllergyIntolerance = InferEncoded<
typeof fhirAllergyIntoleranceConverter
>

export type FHIRAppointment = InferEncoded<typeof fhirAppointmentConverter>

export type LocalizedText = string | Record<string, string>
72 changes: 0 additions & 72 deletions modules/firebase/models/baseTypes.ts

This file was deleted.

Loading
Loading