-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Input Schema #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Input Schema #207
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b5c8591
feat: Switch from fuzzy matching and data normalization of input file…
TiaTuinstra cb89142
remove internal link from getting_started.md
TiaTuinstra 4894d0e
switch to frictionless json instead of yaml; update test dataset with…
TiaTuinstra 2e5f249
Minimizing required columns (deriving where possible); switching to l…
TiaTuinstra f5189e0
change schema to use lower_snake_case; change test input to excel fil…
TiaTuinstra 4740629
client info completeness check; able to toggle whether address/client…
TiaTuinstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| { | ||
| "$schema": "https://datapackage.org/profiles/2.0/tableschema.json", | ||
| "title": "input_schema", | ||
| "description": "Schema for input file for automated notice generation.", | ||
| "fieldsMatch": ["subset"], | ||
| "fields": [ | ||
| { | ||
| "name": "school_name", | ||
| "type": "string", | ||
| "description": "School name with PHIX ID (if available) in format 'SCHOOL NAME - PHIX ID'", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "client_id", | ||
| "type": "string", | ||
| "description": "10-digit Panorama client identifier", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true, | ||
| "pattern": "^\\d{10}$" | ||
| } | ||
| }, | ||
| { | ||
| "name": "first_name", | ||
| "description": "Client first name", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "last_name", | ||
| "description": "Client last name", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "date_of_birth", | ||
| "description": "Client date of birth", | ||
| "type": "date", | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "street_address_line_1", | ||
| "description": "Client street address (line 1)", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "street_address_line_2", | ||
| "description": "Client street address (line 2)", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "city", | ||
| "description": "City of client address", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "province", | ||
| "description": "Province / territory of client address", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "postal_code", | ||
| "description": "Postal code of client address", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "overdue_disease", | ||
| "description": "Comma-separated list of overdue diseases for client", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "overdue_agent", | ||
| "description": "Comma-separated list of overdue agents for client", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "imms_given", | ||
| "description": "List of immunizations given to client, separated by ';'. Each list entry is in the format 'Mon Day, YYYY - <received vaccine>'. Optionally, each entry may also include validity status of the dose appended as '- <dose validity>'", | ||
| "type": "string", | ||
| "stripWhitespace": true, | ||
| "constraints": { | ||
| "required": true | ||
| } | ||
| }, | ||
| { | ||
| "name": "board_name", | ||
| "description": "School board name", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "board_id", | ||
| "description": "School board identifier", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| }, | ||
| { | ||
| "name": "school_id", | ||
| "description": "School identifier", | ||
| "type": "string" | ||
| }, | ||
| { | ||
| "name": "version_id", | ||
| "description": "Version identifier", | ||
| "type": "string", | ||
| "stripWhitespace": true | ||
| } | ||
| ], | ||
| "missingValues": [""] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from pathlib import Path | ||
| import json | ||
|
|
||
| SCHEMA_FILE = Path("config/input_schema.json") | ||
| OUTPUT_FILE = Path("docs/user_guide/input_schema.md") | ||
|
|
||
| schema = json.loads(SCHEMA_FILE.read_text()) | ||
|
|
||
| lines = [] | ||
|
|
||
| lines.append(f"# {schema.get('title', 'Schema')}\n\n") | ||
|
|
||
| if schema.get("description"): | ||
| lines.append(f"{schema['description']}\n\n") | ||
|
|
||
| lines.append("## Schema Information\n\n") | ||
| lines.append("| Property | Value |\n") | ||
| lines.append("|----------|-------|\n") | ||
| lines.append(f"| Fields | {len(schema['fields'])} |\n") | ||
| lines.append(f"| Field Matching | {', '.join(schema.get('fieldsMatch', []))} |\n") | ||
|
|
||
| missing_values = ", ".join(f"`{v}`" for v in schema.get("missingValues", [])) | ||
| lines.append(f"| Missing Values | {missing_values} |\n\n") | ||
|
|
||
| lines.append("## Field Summary\n\n") | ||
| lines.append("| Field | Type | Description |\n") | ||
| lines.append("|-------|------|-------------|\n") | ||
|
|
||
| for field in schema["fields"]: | ||
| description = field.get("description", "") | ||
| lines.append(f"| {field['name']} | {field['type']} | {description} |\n") | ||
|
|
||
| OUTPUT_FILE.write_text("".join(lines), encoding="utf-8") | ||
|
|
||
| print(f"Generated {OUTPUT_FILE}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,35 @@ uv run pre-commit install | |
|
|
||
| Input files must be `.xlsx` format with a single worksheet, extracted from [Panorama PEAR](https://accessonehealth.ca/). | ||
|
|
||
| The pipeline enforces a strict column schema — column names must match exactly (no fuzzy matching). The following columns are **required**: | ||
|
|
||
| | Column name | Notes | | ||
| |---|---| | ||
| | `school_name` | | | ||
| | `client_id` | 10-digit numeric string | | ||
| | `first_name` | | | ||
| | `last_name` | | | ||
| | `date_of_birth` | ISO 8601 date (`YYYY-MM-DD`) | | ||
| | `street_address_line_1` | | | ||
| | `street_address_line_2` | May be blank | | ||
| | `city` | | | ||
| | `province` | | | ||
| | `postal_code` | | | ||
| | `overdue_disease` | May be blank | | ||
| | `overdue_agent` | May be blank | | ||
| | `imms_given` | May be blank | | ||
|
|
||
| The following columns are **optional** and will be used when present: | ||
|
|
||
| | Column name | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Support optional "version" identifier (e.g. for multi-language support, A/B tests, etc) |
||
| |---| | ||
| | `board_name` | | ||
| | `board_id` | | ||
| | `school_id` | | ||
| | `version_id` | | ||
|
|
||
| The full schema is defined in `config/input_schema.json`. If the file is missing any required column, the pipeline will stop immediately with a clear error message listing the missing columns. | ||
|
|
||
| Place input files in the `input/` subdirectory (not tracked by Git): | ||
|
|
||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| school_name,client_id,first_name,last_name,date_of_birth,street_address_line_1,street_address_line_2,city,province,postal_code,overdue_disease,overdue_agent,imms_given,Disease(s)/Agent(s),Imms History by Agent | ||
| WHISKER ELEMENTARY-1009876543,1009876543,Squeak,McCheese,2013-06-15,14 Burrow Lane,,Cheddarville,Ontario,M1C3E5,"Varicella, HPV, Hepatitis B","Var, HPV-9, Men-C-ACYW-135,","Aug 20, 2013 - DTaP-IPV-Hib; Aug 20, 2013 - Pneu-C-13; Aug 20, 2013 - rota-unspecified; Nov 18, 2013 - DTaP-IPV-Hib; Nov 18, 2013 - Pneu-C-13; Jan 25, 2014 - DTaP-IPV-Hib; May 12, 2014 - MMR; May 12, 2014 - Men-C-C; Oct 3, 2014 - Var; Apr 14, 2024 - Tdap-IPV;",Varicella (Var),"[2013 AUG 20: DTaP-IPV-Hib, Pneu-C-13, rota-unspecified] [2013 NOV 18: DTaP-IPV-Hib, Pneu-C-13] [2014 JAN 25: DTaP-IPV-Hib] [2014 MAY 12: MMR, Men-C-C] [2014 OCT 03: Var] [2024 APR 14: Tdap-IPV, MMR-Var]" | ||
| CHEESE WHEEL ACADEMY-1009876544,1009876544,Nibble,Sharpcheddar,2014-04-22,22 Gouda St,,Fromage City,Ontario,C3H3Z9,"Measles,","MMR,","Jul 10, 2014 - DTaP-IPV-Hib; Jul 10, 2014 - Pneu-C-13; Sep 15, 2014 - DTaP-IPV-Hib; Nov 20, 2014 - rota-unspecified; Mar 2, 2015 - MMR; Mar 2, 2015 - Men-C-C; Aug 7, 2015 - Var; Oct 1, 2015 - DTaP-IPV-Hib; May 19, 2024 - Tdap-IPV;",Measles (MMR),"[2014 JUL 10: DTaP-IPV-Hib, Pneu-C-13] [2014 SEP 15: DTaP-IPV-Hib] [2014 NOV 20: rota-unspecified] [2015 MAR 02: MMR, Men-C-C] [2015 AUG 07: Var] [2015 OCT 01: DTaP-IPV-Hib] [2024 MAY 19: Tdap-IPV]" | ||
| BURROW PUBLIC SCHOOL-1009876545,1009876545,Scurry,Nutcracker,2012-11-30,7 Tunnel Road,Unit 2,Gnawtown,Ontario,G9N8R2,"Hepatitis B,","HB,","Jan 5, 2013 - DTaP-IPV-Hib; Jan 5, 2013 - rota-unspecified; Mar 7, 2013 - Pneu-C-13; May 9, 2013 - DTaP-IPV-Hib; Jun 11, 2013 - MMR; Oct 23, 2013 - Men-C-C; Feb 2, 2014 - Var; May 6, 2014 - Pneu-C-13; Sep 12, 2014 - DTaP-IPV-Hib; May 1, 2024 - Tdap-IPV;",Hepatitis B (HB),"[2013 JAN 05: DTaP-IPV-Hib, rota-unspecified] [2013 MAR 07: Pneu-C-13] [2013 MAY 09: DTaP-IPV-Hib] [2013 JUN 11: MMR] [2013 OCT 23: Men-C-C] [2014 FEB 02: Var] [2014 MAY 06: Pneu-C-13] [2014 SEP 12: DTaP-IPV-Hib] [2024 MAY 01: Tdap-IPV]" | ||
| TUNNEL ACADEMY-1009876546,1009876546,Whiskers,Greyfur,2013-09-10,88 Haystack Drive,,Burrowville,Ontario,H8Y6T5,"Mumps,","MMR,","Oct 15, 2013 - DTaP-IPV-Hib; Dec 12, 2013 - rota-unspecified; Jan 17, 2014 - Pneu-C-13; Apr 8, 2014 - DTaP-IPV-Hib; Jun 19, 2014 - MMR; Oct 22, 2014 - Men-C-C; Feb 4, 2015 - Var; Sep 9, 2015 - DTaP-IPV-Hib; Apr 10, 2024 - Tdap-IPV;",Mumps (MMR),[2013 OCT 15: DTaP-IPV-Hib] [2013 DEC 12: rota-unspecified] [2014 JAN 17: Pneu-C-13] [2014 APR 08: DTaP-IPV-Hib] [2014 JUN 19: MMR] [2014 OCT 22: Men-C-C] [2015 FEB 04: Var] [2015 SEP 09: DTaP-IPV-Hib] [2024 APR 10: Tdap-IPV] | ||
| NUTCRACKER ACADEMY-1009876547,1009876547,Chisel,Teetherson,2014-02-28,3 Acorn Ave,Suite 1,Hazelton,Ontario,N4U2L1,"HPV,","HPV-9,","Mar 12, 2014 - DTaP-IPV-Hib; Mar 12, 2014 - rota-unspecified; May 14, 2014 - Pneu-C-13; Jul 19, 2014 - DTaP-IPV-Hib; Sep 21, 2014 - MMR; Nov 25, 2014 - Men-C-C; Apr 17, 2015 - Var; Sep 13, 2015 - DTaP-IPV-Hib; May 5, 2024 - Tdap-IPV;",HPV (HPV-9),"[2014 MAR 12: DTaP-IPV-Hib, rota-unspecified] [2014 MAY 14: Pneu-C-13] [2014 JUL 19: DTaP-IPV-Hib] [2014 SEP 21: MMR] [2014 NOV 25: Men-C-C] [2015 APR 17: Var] [2015 SEP 13: DTaP-IPV-Hib] [2024 MAY 05: Tdap-IPV]" | ||
| NUTCRACKER ACADEMY-1009876547,1009876548,Ratty,Teetherson,2009-02-28,,,Hazelton,Ontario,N4U2L1,"HPV,","HPV-9,","Mar 12, 2014 - DTaP-IPV-Hib; Mar 12, 2014 - rota-unspecified; May 14, 2014 - Pneu-C-13; Jul 19, 2014 - DTaP-IPV-Hib; Sep 21, 2014 - MMR; Nov 25, 2014 - Men-C-C; Apr 17, 2015 - Var; Sep 13, 2015 - DTaP-IPV-Hib; May 5, 2024 - Tdap-IPV;",HPV (HPV-9),"[2014 MAR 12: DTaP-IPV-Hib, rota-unspecified] [2014 MAY 14: Pneu-C-13] [2014 JUL 19: DTaP-IPV-Hib] [2014 SEP 21: MMR] [2014 NOV 25: Men-C-C] [2015 APR 17: Var] [2015 SEP 13: DTaP-IPV-Hib] [2024 MAY 05: Tdap-IPV]" | ||
| TUNNEL ACADEMY-1009876550,1009876550,Cheddarina,Swiftpaws,2014-09-14,44 Hayloft Road,,Burrowville,Ontario,H8Y6T6,MMR,MMR,"Jan 10, 2015 - DTaP-IPV-Hib; Jan 29, 2015 - Pneu-C-13; Feb 18, 2015 - rota-unspecified; Mar 07, 2015 - DTaP-IPV-Hib; Mar 28, 2015 - MMR; Apr 15, 2015 - Men-C-C; May 02, 2015 - Var; May 27, 2015 - DTaP-IPV-Hib; Jun 16, 2015 - Pneu-C-13; Jul 09, 2015 - Influenza (IIV4); Aug 01, 2015 - Influenza (IIV4); Aug 29, 2015 - MMR; Sep 22, 2015 - Var; Oct 11, 2015 - DTaP-IPV-Hib; Nov 05, 2015 - Pneu-C-13; Dec 03, 2015 - Men-C-C; Jan 14, 2016 - MMR; Feb 06, 2016 - Influenza (IIV4); Mar 12, 2016 - Hep A; Apr 04, 2016 - Hep A booster; May 18, 2016 - Yellow Fever; Jun 07, 2016 - Rabies (pre-exposure); Jun 30, 2016 - Rabies (pre-exposure) dose 2; Jul 23, 2016 - Rabies (pre-exposure) dose 3; Aug 15, 2016 - Var; Sep 08, 2016 - DTaP-IPV-Hib; Oct 01, 2016 - Pneu-C-13; Oct 27, 2016 - Influenza (IIV4); Nov 19, 2016 - MMR; Dec 14, 2016 - Men-C-C; Jan 09, 2017 - Var; Feb 03, 2017 - DTaP-IPV-Hib; Mar 01, 2017 - Pneu-C-13; Mar 29, 2017 - MMR; Apr 18, 2017 - Influenza (IIV4); May 10, 2017 - COVID-19 (Pfizer Pediatric); Jun 02, 2017 - COVID-19 (Pfizer Pediatric) dose 2; Jun 28, 2017 - COVID-19 Booster; Jul 20, 2017 - Var; Aug 12, 2017 - Men-C-C; Sep 03, 2017 - Influenza (IIV4); Oct 25, 2017 - DTaP-IPV-Hib; Nov 16, 2017 - Pneu-C-13; Dec 08, 2017 - MMR; May 02, 2023 - Tdap; Jan 18, 2024 - Men-C-ACYW-135; May 01, 2024 - Tdap-IPV",Measles (MMR),[2015 JAN 10: DTaP-IPV-Hib] [2015 JAN 29: Pneu-C-13] [2015 FEB 18: rota-unspecified] [2015 MAR 07: DTaP-IPV-Hib] [2015 MAR 28: MMR] [2015 APR 15: Men-C-C] [2015 MAY 02: Var] [2015 MAY 27: DTaP-IPV-Hib] [2015 JUN 16: Pneu-C-13] [2015 JUL 09: Influenza (IIV4)] [2015 AUG 01: Influenza (IIV4)] [2015 AUG 29: MMR] [2015 SEP 22: Var] [2015 OCT 11: DTaP-IPV-Hib] [2015 NOV 05: Pneu-C-13] [2015 DEC 03: Men-C-C] [2016 JAN 14: MMR] [2016 FEB 06: Influenza (IIV4)] [2016 MAR 12: Hep A] [2016 APR 04: Hep A booster] [2016 MAY 18: Yellow Fever] [2016 JUN 07: Rabies (pre-exposure)] [2016 JUN 30: Rabies (pre-exposure) dose 2] [2016 JUL 23: Rabies (pre-exposure) dose 3] [2016 AUG 15: Var] [2016 SEP 08: DTaP-IPV-Hib] [2016 OCT 01: Pneu-C-13] [2016 OCT 27: Influenza (IIV4)] [2016 NOV 19: MMR] [2016 DEC 14: Men-C-C] [2017 JAN 09: Var] [2017 FEB 03: DTaP-IPV-Hib] [2017 MAR 01: Pneu-C-13] [2017 MAR 29: MMR] [2017 APR 18: Influenza (IIV4)] [2017 MAY 10: COVID-19 (Pfizer Pediatric)] [2017 JUN 02: COVID-19 (Pfizer Pediatric) dose 2] [2017 JUN 28: COVID-19 Booster] [2017 JUL 20: Var] [2017 AUG 12: Men-C-C] [2017 SEP 03: Influenza (IIV4)] [2017 OCT 25: DTaP-IPV-Hib] [2017 NOV 16: Pneu-C-13] [2017 DEC 08: MMR] [2023 MAY 02: Tdap] [2024 JAN 18: Men-C-ACYW-135] [2024 MAY 01: Tdap-IPV] |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that we want .xlsx over .csv? .xlsx can do some weird things with dates/formatting we may like to avoid dealing with at all, and incurs some xlsx handling dependencies. Perhaps this is a PEAR thing though - if more rows can be exported at a time in xlsx format vs csv?
I believe with PEAR you can export the report template definitions/schema which we could include in this repo once revised (in addition for PHU users to access the template from our collaboration folder in PEAR)