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

Fix validation while Shifting Bed #921

Merged
merged 2 commits into from
Jul 9, 2022

Conversation

Ashesh3
Copy link
Member

@Ashesh3 Ashesh3 commented Jul 9, 2022

Fixes coronasafe/care_fe#3072

The validation logic while shifting beds was recently updated in #731 , which included a query to check if any ConsultationBed exist and fetch the latest one.

This change fixes the way the existence of the object is checked.

exists() is a method of a QuerySet and hence would raise an Exception when called on latest object itself fetched from the .latest() method.

Now, the existence is checked first then the latest object is fetched, if exists.

qs = ConsultationBed.objects.filter(consultation=consultation)
# Validations based of the latest entry
if qs.exists():
    latest_qs = qs.latest("id")

@Ashesh3 Ashesh3 requested a review from a team as a code owner July 9, 2022 08:16
@codecov-commenter
Copy link

Codecov Report

Merging #921 (aa77f60) into master (65184e2) will decrease coverage by 1.39%.
The diff coverage is 10.00%.

@@            Coverage Diff             @@
##           master     #921      +/-   ##
==========================================
- Coverage   54.24%   52.85%   -1.40%     
==========================================
  Files         181      181              
  Lines        8810     8813       +3     
==========================================
- Hits         4779     4658     -121     
- Misses       4031     4155     +124     
Impacted Files Coverage Δ
care/facility/api/serializers/bed.py 40.70% <10.00%> (-0.37%) ⬇️
...e/utils/serializer/phonenumber_ispossible_field.py 50.00% <0.00%> (-43.75%) ⬇️
config/serializers.py 36.84% <0.00%> (-31.58%) ⬇️
care/audit_log/middleware.py 47.36% <0.00%> (-22.81%) ⬇️
care/users/models.py 73.75% <0.00%> (-16.32%) ⬇️
care/facility/models/mixins/permissions/base.py 45.00% <0.00%> (-15.00%) ⬇️
care/users/api/viewsets/users.py 43.50% <0.00%> (-12.34%) ⬇️
care/facility/api/viewsets/facility.py 58.10% <0.00%> (-12.17%) ⬇️
care/users/api/serializers/user.py 56.77% <0.00%> (-9.33%) ⬇️
care/facility/models/patient.py 88.09% <0.00%> (-6.75%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a796bd...aa77f60. Read the comment docs.

@vigneshhari vigneshhari merged commit 59b80de into coronasafe:master Jul 9, 2022
@Ashesh3 Ashesh3 deleted the fix-bed-check branch July 9, 2022 15:49
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.

Shifting Bed : Not working
3 participants