Skip to content

fix: authorize note retrieve from the thread's encounter - #3741

Open
adarshx01 wants to merge 1 commit into
ohcnetwork:developfrom
adarshx01:fix/notes-detail-encounter-auth
Open

fix: authorize note retrieve from the thread's encounter#3741
adarshx01 wants to merge 1 commit into
ohcnetwork:developfrom
adarshx01:fix/notes-detail-encounter-auth

Conversation

@adarshx01

Copy link
Copy Markdown

Proposed Changes

  • NoteThread / NoteMessage detail now checks view permission against the thread's encounter, instead of only looking at ?encounter= on the request.
  • Encounter-scoped users can retrieve (and therefore update) a thread they can already list. Patient-level threads still require can_view_clinical_data.
  • Pulled the duplicated list/detail check into one helper.

Associated Issue

get_object had a leftover TODO (Authorise Based on encounter and permission) and just called super().get_object(), which goes through get_queryset. That queryset only treats encounter access when ?encounter= is present, so it never is on /thread/{id}/ or /notes/{id}/.

List with ?encounter= already returned 200 for can_read_encounter_clinical_data; GET on the same thread returned 403.

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Detail views only checked encounter access when ?encounter= was on
the request, so users who can list an encounter's notes got 403 on
the thread/message itself.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adarshx01
adarshx01 requested a review from a team as a code owner August 17, 2026 13:51
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant