Skip to content

Conversation

Copy link

Copilot AI commented Oct 3, 2025

Summary

Fixes #284 by enabling clinician notifications to be seeded when specifying specific user IDs via the userData parameter in the defaultSeed function.

Problem

Previously, when seeding data for specific user IDs using the userData array parameter, the code unconditionally called _seedPatientCollections() for all users. This meant that clinician users would not receive their notification messages (which are generated based on their assigned patients), breaking the seeding functionality for clinicians.

// Before: Always assumed userData entries were patients
for (const userData of data.userData) {
  await _seedPatientCollections({
    userId: userData.userId,
    components: userData.only,
    date: data.date,
  });
}

Solution

Modified the userData seeding loop to check the user type and call the appropriate seeding function:

  • For patients: Continue calling _seedPatientCollections() (preserving existing behavior)
  • For clinicians: Fetch their assigned patients and call _seedClinicianCollections() to properly seed notification messages
// After: Check user type and call appropriate seeding function
const user = await userService.getUser(userData.userId);
if (user?.content.type === UserType.patient) {
  await _seedPatientCollections({ ... });
} else if (user?.content.type === UserType.clinician) {
  // Fetch clinician's patients and seed their messages
  const clinicianPatients = allPatients.filter(
    (patient) => patient.content.clinician === user.id
  );
  await _seedClinicianCollections({ userId, patients, ... });
}

This implementation mirrors the logic already present in the standard seed flow (when seeding all users), ensuring consistency across both seeding paths.

Changes

  • functions/src/functions/defaultSeed.ts: Updated userData loop to support both patient and clinician user types
  • functions/src/functions/defaultSeed.test.ts: Added test case to verify clinician messages are seeded correctly for specific userIds

Testing

Added a new test case that:

  1. Seeds standard users (including clinicians and patients)
  2. Calls defaultSeed again with a specific clinician userId
  3. Verifies that clinician notification messages are properly created

The implementation passes all linting and build checks.

Related to PR #142

Original prompt

This section details on the original issue you should resolve

<issue_title>Support sending clinician notifications when specifically seeding certain userIds</issue_title>
<issue_description>### Problem

Currently, clinician notifications are sent only for standard seed data. Seed is not happening when specifying certain user ids.

Solution

Seed clinician notifications when specifying certain user ids.

Additional context

#142

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #147

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Support sending clinician notifications when specifically seeding certain userIds Support sending clinician notifications when seeding specific userIds Oct 3, 2025
Copilot finished work on behalf of pauljohanneskraft October 3, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sending clinician notifications when specifically seeding certain userIds

2 participants