Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Jan 27, 2025
1 parent 8d62a30 commit be2f03c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 8 additions & 1 deletion care/emr/api/viewsets/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ def get_queryset(self):
qs = (
super()
.get_queryset()
.select_related("patient", "facility", "appointment","current_location" , "created_by" , "updated_by" )
.select_related(
"patient",
"facility",
"appointment",
"current_location",
"created_by",
"updated_by",
)
.order_by("-created_date")
)
if (
Expand Down
11 changes: 7 additions & 4 deletions care/security/authorization/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def can_view_encounter_obj(self, user, encounter):
"""
Check if the user has permission to read encounter under this facility
"""
orgs=[*encounter.facility_organization_cache]
orgs = [*encounter.facility_organization_cache]
if encounter.current_location:
orgs.extend(encounter.current_location.facility_organization_cache)

Expand All @@ -40,7 +40,7 @@ def can_submit_encounter_questionnaire_obj(self, user, encounter):
# Cannot write to a closed encounter
return False

orgs=[*encounter.facility_organization_cache]
orgs = [*encounter.facility_organization_cache]
if encounter.current_location:
orgs.extend(encounter.current_location.facility_organization_cache)

Expand All @@ -57,7 +57,7 @@ def can_update_encounter_obj(self, user, encounter):
if encounter.status in COMPLETED_CHOICES:
# Cannot write to a closed encounter
return False
orgs=[*encounter.facility_organization_cache]
orgs = [*encounter.facility_organization_cache]
if encounter.current_location:
orgs.extend(encounter.current_location.facility_organization_cache)
return self.check_permission_in_facility_organization(
Expand All @@ -77,7 +77,10 @@ def get_filtered_encounters(self, qs, user, facility):
user=user, organization__facility=facility, role_id__in=roles
).values_list("organization_id", flat=True)
)
return qs.filter(Q(facility_organization_cache__overlap=organization_ids) | Q(current_location__facility_organization_cache__overlap=organization_ids))
return qs.filter(
Q(facility_organization_cache__overlap=organization_ids)
| Q(current_location__facility_organization_cache__overlap=organization_ids)
)


AuthorizationController.register_internal_controller(EncounterAccess)
5 changes: 4 additions & 1 deletion care/security/authorization/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def find_roles_on_patient(self, user, patient):
encounters = (
Encounter.objects.filter(patient=patient)
.exclude(status__in=COMPLETED_CHOICES)
.values_list("facility_organization_cache" , "current_location__facility_organization_cache")
.values_list(
"facility_organization_cache",
"current_location__facility_organization_cache",
)
)
encounter_set = set()
for encounter in encounters:
Expand Down

0 comments on commit be2f03c

Please sign in to comment.