Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move validate_data to base EMR viewset and add slot_type filter in availability query #2698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions care/emr/api/viewsets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ def clean_create_data(self, request_data):
def authorize_create(self, instance):
pass

def validate_data(self, instance, model_obj=None):
pass

def create(self, request, *args, **kwargs):
return Response(self.handle_create(request.data))

Expand Down Expand Up @@ -253,6 +250,9 @@ def get_object(self):
queryset, **{self.lookup_field: self.kwargs[self.lookup_field]}
)

def validate_data(self, instance, model_obj=None):
pass

Comment on lines +253 to +255
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider removing or elaborating this placeholder method.

Currently, validate_data does nothing and might mislead future maintainers. If it’s truly needed, please implement a real validation routine; otherwise, removing it might keep the codebase simpler.

def fetch_encounter_from_instance(self, instance):
return instance.encounter

Expand Down
3 changes: 2 additions & 1 deletion care/emr/api/viewsets/scheduling/availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def availability_stats(self, request, *args, **kwargs):
availabilities = {}
for schedule in schedules:
availabilities[schedule["id"]] = Availability.objects.filter(
schedule_id=schedule["id"]
schedule_id=schedule["id"],
slot_type=SlotTypeOptions.appointment.value,
).values()

availability_exceptions = AvailabilityException.objects.filter(
Expand Down
Loading