Skip to content

Conversation

murugapl
Copy link
Contributor

@murugapl murugapl commented Aug 6, 2025

mavis stats vaccinations

Provides vaccination counts by programme and outcome with flexible filtering options.
Usage:

# All vaccinations (default table format)
mavis stats vaccinations

# Filter by programme and outcome, JSON output
mavis stats vaccinations --programme flu --outcome administered --format json

# Date range and organisation filtering, CSV output
mavis stats vaccinations --since 2023-09-01 --until 2024-07-23 --organisation XYZ123 --workgroup ABC123 --format csv

mavis stats organisations

Reports organisation statistics including cohorts, schools, communications, consents and vaccination rates.

# Organisation statistics (default table format)
mavis stats organisations --ods_code ABC123

# Filter by programme, JSON output
mavis stats organisations --ods_code ABC123 --programme flu --format json

# Filter by academic year
mavis stats organisations --ods_code ABC123 --academic_year 2023 --workgroup XYZ123 

mavis stats consents-by-school

Generates consent response statistics by school with date-based and days-since-request analyses in CSV format.

# All programmes for organisation
mavis stats consents-by-school --ods_code ABC123

# Specific programme only
mavis stats consents-by-school --ods_code ABC123 --programme flu

# Filter by academic year
mavis stats consents-by-school --ods_code ABC123 --academic_year 2023 --workgroup XYZ123

@murugapl murugapl marked this pull request as ready for review August 7, 2025 12:58
@murugapl murugapl requested a review from a team as a code owner August 7, 2025 12:58
Copy link
Contributor

@thomasleese thomasleese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good, nice to see these!

I'm wondering if it's worth extracting the logic related to generating the stats in to separate service classes which returns the data in a structure manner which is then used in these tools to output the data as CSV, JSON, human-readable text, etc. I'm thinking that might make the testing a bit easier and even allow us to get stats quickly in a Rails console. Not a blocker, as we can always refactor this later, but what do you think?

@murugapl
Copy link
Contributor Author

I've done a bit of refactor to be in line with generate, is that what you were thinking? @thomasleese

Copy link
Contributor

@thomasleese thomasleese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, definitely like the classes in lib/stats.

- Introduces a new CLI command to report vaccination counts by programme and outcome.
- Supports filtering by date range (`--since`, `--until`), output format (`--format`: table, json, csv), programme type, outcome, team name and organisation ODS code.

Example usage:

- All vaccinations, table output (default)
mavis_cli stats vaccinations

- Filter by programme and outcome, as JSON
mavis_cli stats vaccinations --programme flu --outcome administered --format json

- Filter by date range, team and organisation, as CSV
mavis_cli stats vaccinations --since 2023-09-01 --until 2024-07-23 --organisation XYZ123 --format csv --team_name "SAIS Org 1"
…lysis

    - Introduces a new CLI command to generate consent response statistics by school, providing both date-based and days-since-request analyses in CSV format.
    - Supports filtering by organisation ODS code (`--ods_code`), optional team name (`--team_name`), optional programme type (`--programme`: flu, hpv, menacwy, td_ipv), and academic year (`--academic_year`).
    - When programme is not specified, analyses all programmes within the organisation.
    - Outputs two CSV reports: consent responses by date and consent responses by days since request sent.

    Example usage:

    - All programmes for an organisation, specific team
    mavis stats consents-by-school --ods_code ABC123 --team_name "SAIS Org 1"

    - Specific programme only
    mavis stats consents-by-school --ods_code ABC123 --programme flu

    - Filter by academic year
    mavis stats consents-by-school --ods_code ABC123 --academic_year 2023
    - Introduces a new CLI command to report comprehensive organisation statistics including cohorts, schools, communications, consents and vaccination rates.
    - Supports filtering by organisation ODS code (`--ods_code`), team name (`--team_name`), programme type (`--programme`: flu, hpv, menacwy, td_ipv), academic year (`--academic_year`), and output format (`--format`: table, json).

    Example usage:

    - Organisation statistics, table output (default)
    mavis_cli stats organisations --ods_code ABC123 --team_name "SAIS Org 1"

    - Filter by programme, as JSON
    mavis_cli stats organisations --ods_code ABC123 --programme flu --format json

    - Filter by academic year
    mavis_cli stats organisations --ods_code ABC123 --academic_year 2023
Copy link

@murugapl murugapl merged commit 926c6bc into next Aug 14, 2025
13 checks passed
@murugapl murugapl deleted the mavis_cli-stats branch August 14, 2025 11:03
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.

3 participants