Skip to content

refactor(reports): standardise names, flatten admin (reports+datasets), gate sensitive reports (2.50.11)#522

Open
julianam-w wants to merge 7 commits into
2.50from
2.50-report-name-consistency
Open

refactor(reports): standardise names, flatten admin (reports+datasets), gate sensitive reports (2.50.11)#522
julianam-w wants to merge 7 commits into
2.50from
2.50-report-name-consistency

Conversation

@julianam-w

Copy link
Copy Markdown
Collaborator

Overview

The largest of the set — 2.50 still had the old admin/ report folder. Flattens reports and datasets into standard/, standardises report naming, requires a root-level name, and disables sensitive reports by default. Bumps to 2.50.11.

Changes

Flatten admin reports + standardise names + root-level name (536bb36)

  • Flatten models/reports/{config,sql}/admin/admin-* (14 reports) → standard/, dropping the admin- prefix; removed the reports admin tag block from dbt_project.yml.
  • Renames: audit-patient-details-edits-line-listaudit-patient-details-edit, audit-patient-views-line-listaudit-patient-views, audit-outpatient-appointments-line-listaudit-outpatient-appointments, user-audit-reportuser-audit-line-list (+ sensitive- counterparts).
  • Added missing root-level name and normalised display names (sentence case; dropped "Current"/"report"; "Registered birth" → "Registered births"; sensitive = "Sensitive ").
  • Schema: root name now required; legacy queryOptions.name deprecated. Docs updated. validate_report_configs.py recurses subfolders (rglob).
  • Version 2.50.102.50.11; dbt_utils 1.3.31.4.0.

Flatten admin datasets (7b43532)

  • Folder-only move of all 23 models/datasets/admin/* into models/datasets/standard/; dropped the datasets admin tag block. Model names unchanged.

Gate sensitive reports (540ce13)

Also includes compiled-asset build commits (Update) and a .maui submodule bump made on the branch.

Verification

  • validate_report_configs.py → all 58 report configs valid.

Note

The compiled Update commits were built before the has_sensitive_facility gate (540ce13) was added, so the bundled compiled/v2.50.11 may still include sensitive reports. Re-run scripts/build_reporting_assets.py with the flag in place to refresh.

🤖 Generated with Claude Code

julianam-w and others added 7 commits June 25, 2026 16:13
…ames, require root-level name (2.50.11)

Brings report structure and naming in line with the convention adopted on
2.45/2.49/2.54 and makes a root-level `name` mandatory.

Flatten admin -> standard (config + sql):
- move all 14 models/reports/{config,sql}/admin/admin-* reports into
  standard/, dropping the `admin-` prefix
- drop the now-unused reports `admin` tag block from dbt_project.yml
  (the datasets `admin` tag block is unaffected)

Renames (config + sql, standard + sensitive):
- (admin) audit-patient-details-edits-line-list -> audit-patient-details-edit
- (admin) audit-patient-views-line-list -> audit-patient-views
- audit-outpatient-appointments-line-list -> audit-outpatient-appointments
- user-audit-report -> user-audit-line-list

Report names:
- add missing root-level `name` (deceased-patients-line-list,
  incomplete-referrals, registered-patients-by-dob-line-list,
  audit-outpatient-appointments)
- normalise display names (sentence case; drop "Current"/"report";
  "Registered birth" -> "Registered births"); sensitive = "Sensitive <standard>"

Schema/docs:
- report-config-schema.json: root `name` now required (minLength 1);
  queryOptions.name marked deprecated
- tamanu-report-configuration-schema.md: document required root `name`,
  add Recommended Field Ordering, flag nested name as legacy, fix example
- validate_report_configs.py: recurse into standard/sensitive subfolders
  (rglob) so configs are actually validated

Version/deps:
- bump 2.50.10 -> 2.50.11 (dbt_project.yml, pyproject.toml)
- dbt_utils 1.3.3 -> 1.4.0

list_tamanu_reports.md regenerated; all 58 report configs validate.
Compiled assets (compiled/v2.50.11) to be regenerated via the release build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Folder-only move of all 23 models/datasets/admin/* files into
models/datasets/standard/, and drop the now-dead datasets `admin` tag block
from dbt_project.yml. Model names (ds__*) are unchanged, so ref()s are
unaffected; the models lose the path-based dbt `admin` tag. Internal yml
metadata (meta.domain, tags) is left untouched.

Rides on the pending version bump (compiled assets regenerated by the
release build).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…(false)

Ports PR #425 to this branch so sensitive (restricted-tagged) reports are not
emitted by default.

- dbt_project.yml: add `has_sensitive_facility: false` var
- report_utils.py: exclude `restricted`-tagged nodes from
  generate_project_reports() and generate_reporting_schema_script() when the
  flag is false (read from dbt_project.yml via get_dbt_project_vars())
- README: document the flag

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @julianam-w's task in 5m 25s —— View job


PR Review: standardise report names, flatten admin, gate sensitive reports

Verdict: looks good to merge — well-structured, low-risk refactor (mostly renames + a cleanly-documented gating feature). 0 blockers in source code, 1 action-required on the build artifacts (already acknowledged in the PR body), a few minor suggestions.

  • Read review guidelines & repo AGENT.md
  • Analyse the diff (names, flatten, gating, schema)
  • Verify report config validity (all 58 have a root-level name)
  • Check standard↔sensitive + config↔sql parity
  • Post review

Findings

🟡 1. Compiled assets predate the gating commit (action required before release)

You already flagged this in the PR body, but it's the most important item so I'm surfacing it. compiled/v2.50.11/ was built on 639208f (before 540ce13 added has_sensitive_facility), so the shipped reporting-schema / analytics-metadata / import bundle may still contain the sensitive (restricted) reports — meaning the "disabled by default" behaviour is not reflected in the artifact deployments actually consume. Re-run scripts/build_reporting_assets.py with the flag in place and re-commit compiled/v2.50.11/ before merge/release.

🟢 2. Root-level name requirement is a genuine correctness fix (not just cosmetic)

Worth calling out as a positive: importReports reads json.name at the root (scripts/utils/report_utils.py:148), and compile_report writes the config verbatim into the output (report_utils.py:46). Any config that previously only had queryOptions.name would have imported with an undefined name. Making root name required + deprecating queryOptions.name aligns the schema with the actual consumer. I confirmed all 58 configs now carry a root-level name and none retain a leftover nested queryOptions.name.

🟡 3. Gating cross-tier dependency assumption — documented, fails loud, OK

generate_reporting_schema_script() excludes restricted nodes from nodes but the topological loop (report_utils.py:213-220) would stall and exit with the "no progress" error if a non-restricted model ever depended on a restricted one. The inline comment documents this assumption and it fails loudly rather than silently dropping data, which is the right trade-off. No change needed — just confirm no standard dataset/report references a sensitive//restricted model (none do today).

🔵 4. Field-ordering doc vs. example inconsistency (nit)

The new "Recommended Field Ordering" (documentations/tamanu-report-configuration-schema.md) lists root order as query → name → status → notes → dbSchema, but several configs (e.g. models/reports/config/standard/medication-dispensed-summary.json) order them query → name → notes → status → dbSchema. Harmless, but the convention you're documenting in the same PR isn't followed by the examples. Fix this →

🔵 5. dbt_utils 1.3.3 → 1.4.0 bump unexplained (nit)

packages.yml bumps dbt_utils a minor version with no note on why it's needed for this PR. If it's incidental, consider splitting it out; if a macro here needs it, a one-line note in the PR body would help future bisects.


What I verified ✅

  • Flatten complete: no admin/ dirs remain under models/reports or models/datasets; the admin +tags block is fully removed from dbt_project.yml; no stale references to old report slugs (audit-*-line-list, user-audit-report, admin-*) outside .maui/.
  • Parity: standard 38 configs ↔ 38 SQL, sensitive 20 ↔ 20; every sensitive-* report has its standard/ counterpart; sensitive display names follow Sensitive <standard>.
  • validate_report_configs.py: rglob change correctly recurses the new subfolder layout (couldn't execute Python in this sandbox, but reviewed the schema + all 58 configs by hand — all valid against the updated required-name schema).
  • get_dbt_project_vars() returns the vars dict and the YAML false resolves to Python False, so the default-off gating is correct.

Regression checklist (run before merge)

python scripts/validate_report_configs.py
dbt compile --profiles-dir config
python scripts/build_reporting_assets.py   # re-emit compiled/v2.50.11 WITH the gate
sqlfluff lint models/reports models/datasets/standard

· branch 2.50-report-name-consistency

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.

1 participant