Skip to content

feat(tables): add accent-free province columns to the clinic and patient static tables - #30

Merged
TatianaTchouakam merged 1 commit into
devfrom
feat/clinic-province-ascii
Nov 18, 2026
Merged

TatianaTchouakam merged 1 commit into
devfrom
feat/clinic-province-ascii

Conversation

@TatianaTchouakam

@TatianaTchouakam TatianaTchouakam commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Ticket 2.

Accent-free province columns

Follow-up to the question on #21. The official province name keeps its spelling ("Takéo"); a second column holds the same name without accents ("Takeo"), case and spaces kept. The accent-free copy is safe for joins, filters and maps that may not handle accented characters.

Table Official name New column
clinic_data_static clinic_province clinic_province_ascii
patient_data_static province province_ascii

Examples: "Takéo" → "Takeo", "Hà Nội" → "Ha Noi", "Đà Nẵng" → "Da Nang", "Bangkok" → "Bangkok".

Changes

  • src/a4d/tables/accents.py (new), shared by both tables:
    • fold_accents: NFKD normalisation, then combining marks removed; "đ"/"Đ" mapped by hand (they are letters of their own in Unicode, not "d" with an accent).
    • add_ascii_columns(df, columns): adds <column>_ascii for each listed column present in the frame.
  • src/a4d/tables/clinic.py: clinic_province_ascii added right after the forward fill, so every row already has its province. Columns listed in _ASCII_COLUMNS, so other name columns can be added later.
  • src/a4d/tables/patient.py: province_ascii added to patient_data_static, after the one-row-per-patient grouping.
  • Tests (invented IDs only):
    • tests/test_tables/test_accents.py (new): 3 tests for the shared functions.
    • tests/test_tables/test_patient.py: 1 test, the static table keeps province and adds province_ascii.

Checks

  • ruff format, ruff check: clean.
  • pytest: 1,405 passed, 66 skipped.
  • On the current clinic_data.xlsx (59 rows): clinic_province_ascii is present. No province in the clinic master data has an accent today, so both clinic columns are identical for now. The accented names appear in the patient table, where province holds the canonical names from allowed_provinces.yaml.

Before / after (local run on dev data)

Table Before After
patient_data_static 1,828 rows, 21 columns 1,828 rows, 22 columns (province_ascii added)
Rows with a province 1,788 1,788
Rows where province_ascii differs from province – 129 (36 provinces)
clinic_data_static 59 rows 59 rows (clinic_province_ascii added, identical for now, see Checks)

Examples from the data: "Takéo" → "Takeo", "Hồ Chí Minh*" → "Ho Chi Minh*", "Hà Nội*" → "Ha Noi*", "Đồng Nai" → "Dong Nai", "Kratié" → "Kratie". Case, spaces and * are kept. No row is added or removed, and no finding changes.

uv run pytest tests/test_tables: 36 passed.

@TatianaTchouakam
TatianaTchouakam force-pushed the feat/clinic-province-ascii branch from 52b40b9 to d163148 Compare October 28, 2026 11:53
The official name keeps its spelling ("Takéo"); a new <column>_ascii
column holds it without accents ("Takeo"), for joins, filters and maps:
clinic_province_ascii in clinic_data_static and province_ascii in
patient_data_static. Shared helpers in src/a4d/tables/accents.py.
Tests in test_accents.py and test_patient.py.
@TatianaTchouakam
TatianaTchouakam force-pushed the feat/clinic-province-ascii branch from d163148 to a6de9c1 Compare October 28, 2026 11:55
@TatianaTchouakam TatianaTchouakam changed the title Add accent-free province columns to the clinic and patient static tables feat(tables): add accent-free province columns to the clinic and patient static tables Oct 28, 2026

@pmayd pmayd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe provide some test results before/after and we are good to go

@TatianaTchouakam

Copy link
Copy Markdown
Collaborator Author

Before/after results added to the description (section "Before / after").

@TatianaTchouakam
TatianaTchouakam merged commit 4a2ec9c into dev Nov 18, 2026
2 checks passed
@TatianaTchouakam
TatianaTchouakam deleted the feat/clinic-province-ascii branch November 18, 2026 15:27
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.

2 participants