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

Add serializer constraints to AssetBed #1018

Conversation

Krishna-Sivakumar
Copy link

@Krishna-Sivakumar Krishna-Sivakumar commented Sep 9, 2022

Fixes issue #934

Proposed Changes

AssetBed Serializer was updated to validate the following constraints:

  • HL7Monitor Assets can have only 1 Bed Associated with it.
  • Assets that are neither HL7Monitor nor ONVIFCamera should not have Bed Relations

@coronasafe/code-reviewers

Merge Checklist

  • Request for Peer Reviews
  • Completion of QA

* HL7Monitor Assets can have only 1 Bed Associated with it.

* Assets that are neither HL7Monitor nor ONVIFCamera should not have Bed Relations
@Krishna-Sivakumar Krishna-Sivakumar requested a review from a team as a code owner September 9, 2022 12:32
@sonarcloud
Copy link

sonarcloud bot commented Sep 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov-commenter
Copy link

Codecov Report

Merging #1018 (81d89fd) into master (6bd66bf) will decrease coverage by 0.24%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #1018      +/-   ##
==========================================
- Coverage   54.02%   53.78%   -0.25%     
==========================================
  Files         182      180       -2     
  Lines        8990     8921      -69     
  Branches        0     1523    +1523     
==========================================
- Hits         4857     4798      -59     
+ Misses       4133     4074      -59     
- Partials        0       49      +49     
Impacted Files Coverage Δ
care/facility/api/serializers/bed.py 39.31% <0.00%> (-1.40%) ⬇️
care/facility/api/viewsets/patient.py 48.07% <0.00%> (-0.17%) ⬇️
...re/facility/management/commands/scrape_icd_data.py 0.00% <0.00%> (ø)
care/facility/models/file_upload.py 68.88% <0.00%> (ø)
care/facility/models/json_schema/asset.py 100.00% <ø> (ø)
care/facility/models/patient.py 92.85% <ø> (-1.99%) ⬇️
care/facility/static_data/icd11.py 0.00% <0.00%> (ø)
care/users/api/viewsets/users.py 53.84% <0.00%> (-2.00%) ⬇️
care/utils/assetintegration/onvif.py 38.23% <ø> (+1.09%) ⬆️
...e/facility/api/serializers/patient_consultation.py 34.14% <11.11%> (-2.84%) ⬇️
... and 48 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sainak sainak changed the title AssetBed Serializer Update Add serializer constraints to AssetBed Sep 9, 2022
@sainak sainak linked an issue Sep 9, 2022 that may be closed by this pull request
@gigincg
Copy link
Member

gigincg commented Sep 15, 2022

@Krishna-Sivakumar Make sure that you specify the issue you're solving

elif (
asset.asset_class != "HL7MONITOR"
and asset.asset_class != "ONVIF"
and asset.bed_set.all().count() > 0
Copy link
Member

Choose a reason for hiding this comment

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

Not really sure why this condition is here.

@@ -82,6 +82,23 @@ def validate(self, attrs):
raise ValidationError(
{"asset": "Should be in the same facility as the bed"}
)

if asset.asset_class == "HL7MONITOR" and asset.bed_set.all().count() > 1:
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we also check for = 1 as well ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constraint: AssetBed Relations
5 participants