Skip to content

Commit

Permalink
Support custom providerName for Patients (#105)
Browse files Browse the repository at this point in the history
# Support custom providerName for Patients

## ♻️ Current situation & Problem
Closes #103 


## ⚙️ Release Notes 
* Support custom providerName for Patients


## ✅ Testing
Tested manually

⚠️ Do not merge this until models are updated to the latest version.


### 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 Jan 20, 2025
1 parent 5c1c16b commit 59dfc71
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prepush": "npm run lint:fix && tsc --noEmit"
},
"dependencies": {
"@stanfordbdhg/engagehf-models": "^0.5.0",
"@stanfordbdhg/engagehf-models": "^0.6.0",
"@stanfordspezi/spezi-web-design-system": "^0.3.0",
"@t3-oss/env-core": "^0.11.1",
"@tanstack/react-query": "^5.62.0",
Expand Down
22 changes: 21 additions & 1 deletion routes/~_dashboard/~patients/PatientForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const patientFormSchema = z.object({
displayName: z.string(),
clinician: z.string().min(1, 'Clinician is required'),
dateOfBirth: z.date().optional(),
providerName: z.preprocess(
(value) => (value === '' ? null : value),
z.string().nullable(),
),
})

export type PatientFormSchema = z.infer<typeof patientFormSchema>
Expand All @@ -43,7 +47,10 @@ interface PatientFormProps {
email: string | null
}>
userInfo?: Pick<UserInfo, 'email' | 'displayName' | 'uid'>
user?: Pick<User, 'organization' | 'clinician' | 'dateOfBirth'>
user?: Pick<
User,
'organization' | 'clinician' | 'dateOfBirth' | 'providerName'
>
onSubmit: (data: PatientFormSchema) => Promise<void>
clinicianPreselectId?: string
}
Expand All @@ -62,6 +69,7 @@ export const PatientForm = ({
displayName: userInfo?.displayName ?? '',
clinician: user?.clinician ?? clinicianPreselectId ?? '',
dateOfBirth: user?.dateOfBirth ? new Date(user.dateOfBirth) : undefined,
providerName: user?.providerName ?? '',
},
})

Expand Down Expand Up @@ -114,6 +122,18 @@ export const PatientForm = ({
</Select>
)}
/>
<Field
control={form.control}
name="providerName"
label="Provider name"
tooltip={
<div>
Displayed as "Provider" of the Health Report. <br />
If "Provider name" is not set, assigned clinician will be shown.
</div>
}
render={({ field }) => <Input {...field} value={field.value ?? ''} />}
/>
<Button type="submit" isPending={form.formState.isSubmitting}>
{isEdit ? 'Update' : 'Invite'} patient
</Button>
Expand Down
1 change: 1 addition & 0 deletions routes/~_dashboard/~patients/~$id/~index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const PatientPage = () => {
clinician: form.clinician,
organization: clinician.organization,
dateOfBirth: form.dateOfBirth?.toISOString() ?? null,
providerName: form.providerName,
}
if (resourceType === 'user') {
await callables.updateUserInformation({
Expand Down
1 change: 1 addition & 0 deletions routes/~_dashboard/~patients/~invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const InvitePatientPage = () => {
clinician: form.clinician,
organization: clinician.organization,
dateOfBirth: form.dateOfBirth?.toISOString(),
providerName: form.providerName,
},
})
toast.success('Patient has been successfully invited!')
Expand Down

0 comments on commit 59dfc71

Please sign in to comment.