routes
HTTP routes for the reviews domain.
The reviews in force, and recording or removing one.
Module
Functions
add_patient_note
def add_patient_note( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, body: NoteRequest, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> ReviewTimelineEntry:Add a note to a patient for a trial.
The note stands on its own: it is not a review's note, so adding one records no verdict and changes nothing about the review in force. It joins the trial's timeline, attributed to the caller.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.body: The note to record.repository: The patient-data repository.user: The authenticated caller, recorded as the author.
Returns The note, as the timeline serves it.
Raises
HTTPException: 404 if the patient is not found.
delete_patient_note
def delete_patient_note( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, note_id: Annotated[str, Path(description="The note\'s ID, as the timeline serves it.")], repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> starlette.responses.Response:Delete one of a patient's notes for a trial.
The note is soft-deleted: hidden from every read rather than erased, with who deleted it and when. A note written with a review goes on its own — that review stays in force, unchanged.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.note_id: The note's ID.repository: The patient-data repository.user: The authenticated caller, recorded as having deleted it.
Returns An empty 204.
Raises
HTTPException: 404 if the patient is unknown, or that (patient, trial) has no live note with that ID.
get_patient_review
def get_patient_review( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> TrialReview:Return a patient's review in force for one trial.
The review as recorded: who reviewed it and when, and the analysis verdict
it overrode — None where the patient has no analysis row for the trial.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.repository: The patient-data repository.user: The authenticated caller.
Returns The review in force.
Raises
HTTPException: 404 if the site has not reviewed this patient for this trial.
get_review_timeline
def get_review_timeline( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> ReviewTimeline:Return a patient's history of reviews and notes for one trial.
Every review ever recorded — the decision, and its removal — and every note still standing, newest first. A note written with a review is served as one entry with it, which is how the site's timeline shows the two.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.repository: The patient-data repository.user: The authenticated caller.
Returns The entries, newest first; empty for a patient never reviewed here.
list_patient_reviews
def list_patient_reviews( bitfount_patient_id: BitfountPatientIdPath, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> PatientReviewList:List the reviews in force for a patient, one per reviewed trial.
Each review names its trial and the stage the site recorded for it, which is what groups a patient's trials into the site's own buckets. A newer review supersedes the one before it rather than joining this list.
Arguments
bitfount_patient_id: The Bitfount patient ID.repository: The patient-data repository.user: The authenticated caller.
Returns The reviews in force, ascending by trial id; empty for a patient the site has not reviewed.
list_trial_reviews
def list_trial_reviews( project_id: "Annotated[str, Path(description='The trial (project) ID whose reviews to list.')]", review_statuses: Annotated[list[ReviewStatus] | None, Query(description="Which review verdicts to include, repeated once per value (`?review_statuses=suitable_for_screening`). Omitted, every current review is included. Note these are the site\'s own verdicts, not the analysis verdicts `statuses` filters on.")] = None, page: Annotated[int, Query(ge=1, description=PAGE_DESCRIPTION)] = 1, page_size: Annotated[int, Query(ge=1, le=200, description=PAGE_SIZE_DESCRIPTION)] = 50, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> ReviewedPatientList:List one trial's reviews, most recent first, for the trial detail view.
The site's own verdicts on patients for the trial, newest first, each with the reviewer and when they reviewed. A review stands on its own trial, so a trial with no published eligibility still serves its reviews rather than an empty list.
Arguments
project_id: The trial (project) ID.review_statuses: Which review verdicts to include, one per repeatedreview_statusesquery param. Omitted, every current review is included.page: 1-indexed page number.page_size: Items per page (1–200, default 50).repository: The patient-data repository.user: The authenticated caller.
Returns
A ReviewedPatientList envelope: the requested page in items, and the
count of all matching reviews (before pagination) in total.
remove_patient_review
def remove_patient_review( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, remove_note: "Annotated[bool, Query(description='Also delete the note written with the review, rather than keeping it. Deleted softly, so its text is retained.')]" = False, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> starlette.responses.Response:Remove the review in force for a patient and trial.
The patient reverts to the analysis verdict for that trial. Removing a
review that is not in force has no effect. The note written with the review
is kept unless remove_note is set.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.remove_note: Delete the note written with the review too. Deleted softly, so its text is retained.repository: The patient-data repository.user: The authenticated caller, recorded as having removed it.
Returns An empty 204.
Raises
HTTPException: 404 if the patient is not found.
review_patient
def review_patient( bitfount_patient_id: BitfountPatientIdPath, project_id: ProjectIdPath, body: ReviewRequest, repository: PatientDataRepository = Depends(dependency=<function get_repository>, use_cache=True, scope=None), user: AuthenticatedUser = Depends(dependency=<function verify_jwt>, use_cache=True, scope=None),) ‑> TrialReview:Review a patient for a trial, replacing the review in force.
The review overrides the Bitfount verdict for this trial only. Reviews are immutable: reviewing again records a new one and keeps the earlier ones.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.body: The verdict to record, and any note to record with it.repository: The patient-data repository.user: The authenticated caller, recorded as the reviewer.
Returns The review now in force.
Raises
HTTPException: 404 if the patient is not found.