Add report generation/emailing to ICD-10 feature branch - #3223
Add report generation/emailing to ICD-10 feature branch#3223Jongmassey wants to merge 9 commits into
Conversation
1ddb522 to
b526bbf
Compare
- Queries a local db file for any codelists that flag either of the two warning banners - Writes pdfs with summary of issues and links to the codelists - Writes an example pdf with real OpenSAFELY codelists - Groups codelists into user and organisation codelists - For users outputs a csv with user email and pdf filename # Conflicts: # coding_systems/icd10/known_diffs.py
- Previous edition didn't have 5 character modifier codes - If someone has a code with children that exist in the new db but that don't in the old one, then we should notify them - There are some edge cases e.g. M45 as a 3 character code which has no 4 character children, but has 5th character modified codes like M45X0 - The script now requires you to pass the new db and the old db so it can find all modified codes that couldn't be found in the old data
Full list of all affected codelists along with full list of all affected codes
Fields now, type, email, org, codelist url and pdf filename. Also includes org codelists
Uses simplified format to match codelists
b526bbf to
96a5c2e
Compare
Use the full ehrql_codelists.json dump to allow finding inline codes affected by ICD10 issues. Write out condensed csv format for upload to GSheets.
Also strip out the code to map users to OCL orgs as that wasn't too useful
This uses mailgun with the same configuration as Anymail used elsewhere in OpenCodelists. It sends one email per user, for user-owned codelists only. Organisations with affected codelists will be emailed separately. User's `name`s are templated into the email body, and so they are added to the reporting csv output which the emailer consumes.
96a5c2e to
8ce27d5
Compare
|
@rw251 Do you want to do any further fettling/squishing etc. of commits here before merged into the feature branch? |
| # 429 codes are either rate exceeded (2 types), or too large | ||
| # https://documentation.mailgun.com/en/latest/api-sending.html#rate-limits | ||
| # with message "<why> limit exceeded, try again" where why=[bytes|request|recipient] | ||
| if response.status_code == "429": |
There was a problem hiding this comment.
response.status_code is an integer so I think this conditional is never true - but also I think the mailgun response has changed (https://documentation.mailgun.com/docs/mailgun/api-reference/api-overview#api-response-codes) and not sure it returns a "why" message. Might be easiest to just remove this
| continue | ||
| try: | ||
| if only_seeds and email.lower() not in seed_emails: | ||
| continue |
There was a problem hiding this comment.
nit - but currently in dry run it prints "would send.." for everyone even if a seeds list is given. We could either move this if only_seeds higher up, or add a print like "Actually not in seeds so wouldn't send"
| f"recipients.csv, summary.md, issues.json, and example.pdf." | ||
| ) | ||
| if args.send_emails: | ||
| send_emails( |
There was a problem hiding this comment.
I ran this locally and it didn't print out the dry run messages - I think the generator isn't being consumed?
Multiple lines of defence against sending emails by mistake: * default is to generate, not email * dry run by default * only to seed emails by default
8ce27d5 to
a8acb2b
Compare
No description provided.