Raid v2 improvments - #1054
Conversation
Marc-Andrieu
left a comment
There was a problem hiding this comment.
Looks promising! That's a clean start about the medical data issue
88021b7 to
d3331a4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1054 +/- ##
==========================================
- Coverage 84.99% 84.95% -0.05%
==========================================
Files 220 220
Lines 16273 16308 +35
==========================================
+ Hits 13831 13854 +23
- Misses 2442 2454 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if not security_file.consent_given: | ||
| raise HTTPException( | ||
| status_code=400, | ||
| detail="Consent must be given to register medical data", | ||
| ) | ||
|
|
There was a problem hiding this comment.
❓ Could replace this with consent_given: Literal[True] in the schema ?
There was a problem hiding this comment.
Not sure to get it either
There was a problem hiding this comment.
You are doing schema validation in the endpoint
you could replace this snippet by tightening the schema validator
There was a problem hiding this comment.
At this point, why even bother to put it in the schema, just put it at True no matter what
There was a problem hiding this comment.
I disagree with this point. Putting Literal[True] would return a 422 validation error.
In this endpoint, a value False should be accepted (in term of schema validation). It should however return a "400 Consent must be given to register medical data", as it violates a business rules: we can not proceed given a falsy consent. When receving this error, the frontend will explain to the user why it can not proceed
| hyperion_security_logger.info( | ||
| "Medical data access", | ||
| extra={ | ||
| "accessed_by_user_id": user.id, | ||
| "edition_id": str(edition.id), | ||
| "access_type": "download", | ||
| }, | ||
| ) |
There was a problem hiding this comment.
💡 Archi wise, get_all_security_files_zip should own the logging for me, not the endpoint, it is the one doing the critical step
This way, we futureproof it and won't forget to log elsewhere
I would also have put the permission check in it
There was a problem hiding this comment.
I don't see any loggers in cruds, except those for a db error, so I stuck to that architecture, maybe need the opinion of someone with more knowledge on the backend, at least on my side
There was a problem hiding this comment.
@armanddidierjean Any advice on this one will be welcomed
| emergency_person_name: Mapped[str | None] | ||
| emergency_person_phone: Mapped[str | None] | ||
| file_id: Mapped[str | None] | ||
| consent_given: Mapped[bool] = mapped_column(default=False) |
There was a problem hiding this comment.
🛑 consent_given as a boolean doesn't represent a consent for me
First, it is mandatory to fill in the mandatory security sheet so not free at all (in set_security_file)
Second, we could have wanted a timestamp and/or a version number of the consent text. Here, we don't know what the user consented to nor when
Retractation doesn't seem to be handled that well, especially considering we have no historization
There was a problem hiding this comment.
Something along the lines of MyPayment
https://github.com/aeecleclair/Hyperion/blob/acba6e2/app/core/mypayment/models_mypayment.py#L244
There was a problem hiding this comment.
It doesn't handle retractation either but it would be a step in the right direction
There was a problem hiding this comment.
What do we do if a user rectract after the data are exported ?
There was a problem hiding this comment.
And does versioning suppose to had their respective text in db as well ? If we change the text during a registering, what does happen, do we just remove registered info because the participant did not consent with the latest version, or do we consider that consenting to one imply consenting to all the following ones ?
There was a problem hiding this comment.
Well, it seems like medical consent is a freaking pain in the ass, who would have thought ?
There was a problem hiding this comment.
I agree, storing the datetime the consent was given at would be a good addition. I think automatic retractation is out of scope of this PR. I propose we start with manual suppression of data (including the deletion of files that were downloaded by the RAID association) if someone ask ECLAIR/the RAID for its data to be removed
There was a problem hiding this comment.
I added the date, how would you design the retractation feature ? a simple endpoint marking consent as false and clearing the data ?
Given the time constraint and the time taken to review and merge a PR, I decided to put all the changes in one. I acknowledge that it will be a bit harder to read, that's why I ensure to produce really thin commit to allow a good review |
d3331a4 to
64ecdb5
Compare
38100f3 to
8d80f96
Compare
8d80f96 to
08471eb
Compare
72f76e7 to
ef26b01
Compare
ef26b01 to
c53ee18
Compare
Description
Summary
Updating Raid to match the first points for data security
Changes Made
Additional Notes
First step toward a better security data handling.
Classification
Type of Change
Impact & Scope
Testing
Documentation
"Docstrings#Inline comments