tusharnisal
08/01/2024, 7:12 AMjson
ProjectMembership {
User: {
reference: "Bot/123"
}
}
json
ProjectMembership {
User: {
reference: "ClientApplication/123"
}
}
- I would need to filter out these non-user references and only count resources like:
json
ProjectMembership {
User: {
reference: "User/123"
}
}
Concerns: Users can be deleted, but their ProjectMembership might not be, which could also cause count mismatches.
Neither approach seems ideal. Do you have any suggestions for achieving this goal without affecting performance?rahul1
08/01/2024, 2:39 PMprofile-type to exclude botstusharnisal
08/06/2024, 10:15 AMtusharnisal
08/08/2024, 10:49 AMLogin resources using the project ID and a date range:
typescript
const response: Bundle<any> = await this.medplumService.medplum.search(
'Login',
`_lastUpdated=ge${startDate}&_lastUpdated=le${endDate}&_elements=membership,project&_count=1000`,
);
- I then extract unique user IDs from the results to calculate the monthly active user count across all projects.
2. Project Admin:
- The Project Admin needs to see monthly active users within each organization.
- I'm doing this by fetching all Login resources within a date range.
- I extract ProjectMembership references from the Login resources and then:
- Fetch Patient and Practitioner resources linked to the organization. Patients are fetched using the managingOrganization parameter, and Practitioners are fetched via the PractitionerRole resource, filtered by the organization ID.
- Extract the corresponding user references of patients and practitioners from the ProjectMembership resources.
Example ProjectMembership structure:
typescript
ProjectMembership {
User: {
reference: 'User/abc'
},
Profile: {
reference: 'Patient/abc' or 'Practitioner/abc'
}
}
- Filter the fetched Login resources by user references from the ProjectMembership resource, and extract unique user IDs to determine the monthly active users.
While this approach works, the performance is not optimal. Could you please review this approach and suggest any more efficient alternatives?tusharnisal
08/09/2024, 8:53 AMrahul1
08/23/2024, 5:41 AMLogin resource is the core of your approachrahul1
08/23/2024, 5:44 AMMeasureReport resource to cache the metric of monthly active users. This means that you could compute the metric offline, rather than than on the fly when the user loads the dashboardtusharnisal
08/27/2024, 5:05 AMjgkendal
09/03/2024, 8:42 PMjgkendal
09/03/2024, 8:44 PM