-
Notifications
You must be signed in to change notification settings - Fork 329
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
Labs #2642
base: develop
Are you sure you want to change the base?
Labs #2642
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe changes introduce several new files and classes to enhance the functionality of the EMR system. Notable additions include Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2642 +/- ##
===========================================
+ Coverage 46.72% 47.59% +0.87%
===========================================
Files 313 328 +15
Lines 17697 18482 +785
Branches 1704 1775 +71
===========================================
+ Hits 8269 8797 +528
- Misses 9359 9616 +257
Partials 69 69 ☔ View full report in Codecov by Sentry. |
external_id=self.results_interpreter | ||
) | ||
|
||
obj.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont call this here, if this is needed create a new abstraction for this.
@coderabbitai reivew |
@vigneshhari: Sure, I'll take a look at your changes. ✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
🧹 Outside diff range and nitpick comments (15)
care/emr/signals/auto_create_specimen.py (2)
61-61
: Unnecessary return statement at the end of the functionThe return statement on line 61 may not be necessary, as signal receiver functions typically do not require returning a value.
Consider removing the
return specimen
statement to keep the code clean.
16-16
: Address the TODO commentThere's a TODO to change the trigger to when the billing is done. You might want to prioritize implementing this change to align with the intended workflow.
Would you like assistance in updating the trigger mechanism?
care/emr/models/diagnostic_report.py (1)
32-38
: You might want to useon_delete=models.SET_NULL
forperformer
andresults_interpreter
Using
on_delete=models.CASCADE
could lead to unintended deletion ofDiagnosticReport
records if aUser
is deleted. Settingon_delete=models.SET_NULL
would preserve theDiagnosticReport
while allowing theUser
to be removed.Apply the following diff to implement this suggestion:
performer = models.ForeignKey( User, - on_delete=models.CASCADE, + on_delete=models.SET_NULL, null=True, blank=True, related_name="performed_diagnostic_report", ) results_interpreter = models.ForeignKey( User, - on_delete=models.CASCADE, + on_delete=models.SET_NULL, null=True, blank=True, related_name="interpreted_diagnostic_report", )Also applies to: 39-45
care/emr/api/viewsets/specimen.py (1)
33-38
: Optimize Query inget_object
MethodThe
Q
objects in theget_object
method can be simplified for better readability.Consider simplifying the query like this:
return get_object_or_404( self.get_queryset(), - Q(external_id__iexact=self.kwargs[self.lookup_field]) - | Q(identifier=self.kwargs[self.lookup_field]) - | Q(accession_identifier=self.kwargs[self.lookup_field]), + Q( + external_id__iexact=self.kwargs[self.lookup_field], + identifier=self.kwargs[self.lookup_field], + accession_identifier=self.kwargs[self.lookup_field], + ), )care/emr/migrations/0020_servicerequest_location_specimen_condition_and_more.py (1)
11-120
: Consistent Use of Double Quotes PreferredStatic analysis indicates that single quotes are used, whereas double quotes are preferred according to the project's style guidelines. Replacing single quotes with double quotes will improve consistency.
Consider running an autoformatter or applying this diff:
- field=models.UUIDField(blank=True, null=True), + field=models.UUIDField(blank=True, null=True),(Note: The actual diff would be extensive due to many lines; using an autoformatter is recommended.)
🧰 Tools
🪛 Ruff (0.8.0)
11-11: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
11-11: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
18-18: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
38-38: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
43-43: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
44-44: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
45-45: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
48-48: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
49-49: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
53-53: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
54-54: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
55-55: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
58-58: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
59-59: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
60-60: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
60-60: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
63-63: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
64-64: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
65-65: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
65-65: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
68-68: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
69-69: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
70-70: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
73-73: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
74-74: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
75-75: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
75-75: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
78-78: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
79-79: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
80-80: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
83-83: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
84-84: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
85-85: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
85-85: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
88-88: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
89-89: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
90-90: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
90-90: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
93-93: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
94-94: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
95-95: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
95-95: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
98-98: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
99-99: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
100-100: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
103-103: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
104-104: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
105-105: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
105-105: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
108-108: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
109-109: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
110-110: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
113-113: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
114-114: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
115-115: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
115-115: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
118-118: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
119-119: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
120-120: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
120-120: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/resources/specimen/spec.py (1)
233-236
: Specify optional field types explicitly for clarityThe
note
field has a default value ofNone
, but its type isAnnotation
without indicating that it's optional. To enhance code clarity and prevent potential issues, consider specifying the field type asAnnotation | None
.Apply this diff to update the field type:
- note: Annotation = Field( + note: Annotation | None = Field( default=None, description="Comments made about the specimen while received at the laboratory", )care/emr/api/viewsets/service_request.py (1)
19-23
: Confirm user authentication before accessingexternal_id
Assigning
clean_data["requester"] = request.user.external_id
assumes that the user is authenticated. Although the viewset likely enforces authentication, it's prudent to ensure thatrequest.user
is indeed an authenticated user to prevent potential exceptions.Consider adding an assertion or condition:
def clean_create_data(self, request, *args, **kwargs): clean_data = super().clean_create_data(request, *args, **kwargs) + assert request.user.is_authenticated, "User must be authenticated" clean_data["requester"] = request.user.external_id return clean_data
care/emr/resources/diagnostic_report/valueset.py (1)
11-19
: I see we're being quite... generous with our code acceptanceWhile using the HL7 v2-0074 system is correct, the valueset accepts any code from it without constraints. It might be nice to specify which diagnostic report categories we actually support.
Consider adding specific codes to the include:
ValueSetInclude( system="http://terminology.hl7.org/CodeSystem/v2-0074", + concept=[ + {"code": "LAB", "display": "Laboratory"}, + {"code": "RAD", "display": "Radiology"} + ] )care/emr/resources/specimen/valueset.py (2)
13-15
: Mysterious SNOMED CT conceptsI see we're using SNOMED CT concept "123038009", but what does it mean? I'm sure everyone just memorizes SNOMED CT codes in their spare time, but maybe we could add a comment?
Consider adding a descriptive comment:
system="http://snomed.info/sct", -filter=[{"property": "concept", "op": "is-a", "value": "123038009"}], +# 123038009 represents "Specimen (specimen)" +filter=[{"property": "concept", "op": "is-a", "value": "123038009"}],
50-52
: Living dangerously with unversioned terminologyUsing HL7 terminology without version constraints? That's... brave. What could possibly go wrong?
Consider adding version constraints:
ValueSetInclude( system="http://terminology.hl7.org/CodeSystem/v2-0493", + version="2.9.0" # or whichever version you're targeting )
care/emr/models/service_request.py (1)
40-42
: That TODO comment looks quite comfortable thereThe TODO comment about making
location
a foreign key should probably be addressed sooner rather than later. Would you like me to help create an issue for tracking this?care/emr/resources/service_request/valueset.py (2)
33-39
: Ah, mysterious SNOMED CT codes without comments. How... cryptic.These SNOMED CT codes would benefit from comments explaining their meanings. Not everyone memorizes medical codes in their spare time.
concept=[ - {"code": "108252007"}, - {"code": "363679005"}, - {"code": "409063005"}, - {"code": "409073007"}, - {"code": "387713003"}, + {"code": "108252007"}, # Laboratory procedure + {"code": "363679005"}, # Imaging + {"code": "409063005"}, # Counseling + {"code": "409073007"}, # Education + {"code": "387713003"}, # Surgical procedure ],
13-14
: Three different places for the same URLs? How... interesting.Consider centralizing these system URLs in a constants file to avoid potential typos and make updates easier.
Create a new file
care/emr/constants.py
:class TerminologySystem: LOINC = "http://loinc.org" SNOMED = "http://snomed.info/sct"Also applies to: 32-32, 57-58
care/emr/migrations/0006_specimen.py (1)
31-31
: Add index tocollected_at
field for better query performance.Since
collected_at
is likely to be frequently queried for filtering and sorting specimens, it should be indexed.Apply this diff:
- ('collected_at', models.DateTimeField(blank=True, null=True)), + ('collected_at', models.DateTimeField(blank=True, db_index=True, null=True)),🧰 Tools
🪛 Ruff (0.8.0)
31-31: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/migrations/0005_servicerequest.py (1)
34-35
: Add indexes to datetime fields for query optimization.The
occurrence_datetime
andauthored_on
fields are likely to be frequently queried for filtering and sorting service requests. Consider adding indexes to improve query performance.Apply this diff:
- ('occurrence_datetime', models.DateTimeField(blank=True, null=True)), + ('occurrence_datetime', models.DateTimeField(blank=True, db_index=True, null=True)), - ('authored_on', models.DateTimeField(blank=True, null=True)), + ('authored_on', models.DateTimeField(blank=True, db_index=True, null=True)),Also applies to: 38-38
🧰 Tools
🪛 Ruff (0.8.0)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (23)
care/emr/api/viewsets/diagnostic_report.py
(1 hunks)care/emr/api/viewsets/service_request.py
(1 hunks)care/emr/api/viewsets/specimen.py
(1 hunks)care/emr/apps.py
(1 hunks)care/emr/fhir/resources/concept_map.py
(1 hunks)care/emr/fhir/utils.py
(1 hunks)care/emr/migrations/0005_servicerequest.py
(1 hunks)care/emr/migrations/0006_specimen.py
(1 hunks)care/emr/migrations/0018_merge_0006_specimen_0017_alter_questionnaire_slug.py
(1 hunks)care/emr/migrations/0019_diagnosticreport.py
(1 hunks)care/emr/migrations/0020_servicerequest_location_specimen_condition_and_more.py
(1 hunks)care/emr/models/diagnostic_report.py
(1 hunks)care/emr/models/service_request.py
(1 hunks)care/emr/models/specimen.py
(1 hunks)care/emr/resources/diagnostic_report/spec.py
(1 hunks)care/emr/resources/diagnostic_report/valueset.py
(1 hunks)care/emr/resources/service_request/spec.py
(1 hunks)care/emr/resources/service_request/valueset.py
(1 hunks)care/emr/resources/specimen/spec.py
(1 hunks)care/emr/resources/specimen/valueset.py
(1 hunks)care/emr/signals/__init__.py
(1 hunks)care/emr/signals/auto_create_specimen.py
(1 hunks)config/api_router.py
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- care/emr/signals/init.py
🧰 Additional context used
🪛 Ruff (0.8.0)
care/emr/migrations/0005_servicerequest.py
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
22-22: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
25-25: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
26-26: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
27-27: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
30-30: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
31-31: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
32-32: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
37-37: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
38-38: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
40-40: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
43-43: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
44-44: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
44-44: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
47-47: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/migrations/0006_specimen.py
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
22-22: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
25-25: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
26-26: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
27-27: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
30-30: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
31-31: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
32-32: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/migrations/0019_diagnosticreport.py
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
22-22: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
25-25: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
26-26: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
27-27: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
30-30: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
31-31: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
32-32: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
37-37: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
37-37: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
38-38: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
40-40: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
45-45: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/migrations/0020_servicerequest_location_specimen_condition_and_more.py
11-11: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
11-11: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
18-18: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
38-38: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
43-43: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
44-44: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
45-45: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
48-48: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
49-49: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
53-53: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
54-54: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
55-55: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
58-58: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
59-59: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
60-60: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
60-60: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
63-63: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
64-64: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
65-65: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
65-65: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
68-68: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
69-69: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
70-70: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
73-73: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
74-74: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
75-75: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
75-75: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
78-78: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
79-79: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
80-80: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
83-83: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
84-84: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
85-85: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
85-85: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
88-88: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
89-89: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
90-90: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
90-90: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
93-93: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
94-94: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
95-95: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
95-95: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
98-98: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
99-99: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
100-100: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
103-103: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
104-104: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
105-105: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
105-105: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
108-108: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
109-109: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
110-110: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
113-113: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
114-114: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
115-115: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
115-115: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
118-118: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
119-119: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
120-120: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
120-120: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/migrations/0018_merge_0006_specimen_0017_alter_questionnaire_slug.py
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
🔇 Additional comments (11)
care/emr/api/viewsets/diagnostic_report.py (1)
30-57
: LGTM
The observations
method is well implemented and correctly handles the creation of observations associated with the diagnostic report.
care/emr/migrations/0019_diagnosticreport.py (1)
1-48
: Ignore style warnings in auto-generated migration files
Static analysis suggests replacing single quotes with double quotes. While this is accurate, since this migration file is auto-generated by Django, it's advisable to leave it as is to avoid any unnecessary complications.
🧰 Tools
🪛 Ruff (0.8.0)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
12-12: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
13-13: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
19-19: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
21-21: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
22-22: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
23-23: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
24-24: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
25-25: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
26-26: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
27-27: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
28-28: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
29-29: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
30-30: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
31-31: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
32-32: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
33-33: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
34-34: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
35-35: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
36-36: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
37-37: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
37-37: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
38-38: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
39-39: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
40-40: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
41-41: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
42-42: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
45-45: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
care/emr/api/viewsets/specimen.py (1)
104-104
: Confirm Append Operation on specimen.note
Ensure that specimen.note
is initialized as a list before appending to it. If specimen.note
can be None
, this might raise an exception.
Double-check the initialization of specimen.note
to prevent a potential AttributeError
.
care/emr/resources/service_request/spec.py (2)
179-179
: Data Type Flexibility for code
Field
As previously mentioned, the code
field could accept a dict
in addition to a Coding
instance to provide flexibility in how the data is passed.
168-168
: Potential Issue with requester
Field Assignment
Ensure that self.requester
contains a valid UUID that corresponds to an existing User
. If self.requester
is not provided or invalid, this will raise an exception.
Confirm that self.requester
is always provided and valid, or add appropriate error handling.
care/emr/resources/diagnostic_report/spec.py (1)
149-166
: Avoid calling obj.save()
within perform_extra_deserialization
Calling obj.save()
inside perform_extra_deserialization
can lead to unexpected behavior, especially if this method is intended only for deserialization logic. It's better to handle object saving outside this method to maintain clean separation of concerns.
care/emr/apps.py (1)
9-10
: Import signals in ready
method cautiously
While importing care.emr.signals
in the ready
method registers your signal handlers appropriately, ensure that the import doesn't inadvertently execute code that should only run once or under specific conditions.
care/emr/resources/diagnostic_report/valueset.py (1)
29-37
: Oh, interesting choice with the LOINC system
Using LOINC is perfect for diagnostic report codes, but accepting any LOINC code might be a bit... adventurous. Perhaps we could be more specific about which codes are relevant to our use case?
Let's check if other parts of the codebase have any LOINC code restrictions:
Consider adding specific LOINC codes that are relevant to your diagnostic reports.
✅ Verification successful
Let's see if there are any specific LOINC code patterns or validations being enforced elsewhere in the codebase.
Well, it seems our LOINC implementation is... consistently unrestricted
Looking at the codebase, I notice we're quite... generous with our LOINC code acceptance everywhere. The pattern of unrestricted LOINC systems appears in observations, service requests, and diagnostic reports. While it's not technically wrong, it's just interesting how we're trusting all LOINC codes equally.
care/emr/resources/observation/valueset.py
uses unrestricted LOINCcare/emr/resources/service_request/valueset.py
follows the same patterncare/emr/signals/auto_create_specimen.py
does filter specific codes, but only for specimen creation
The current implementation aligns with the codebase's general approach, so while my suggestion about restricting codes remains valid for future improvements, it's not inconsistent with the existing patterns.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for LOINC code validations or restrictions
rg -i "loinc" --type py
Length of output: 889
Script:
#!/bin/bash
# Let's check if there are any specific LOINC codes being used or validated
rg -i "loinc.*code" -B 2 -A 2 --type py
# Also check for any code validation patterns
ast-grep --pattern 'system = "http://loinc.org"'
ast-grep --pattern 'system="http://loinc.org"'
Length of output: 1009
config/api_router.py (1)
164-168
: LGTM! The route registrations follow existing patterns.
The new routes for service requests, specimens, and diagnostic reports are properly registered with consistent naming conventions and URL patterns.
care/emr/migrations/0018_merge_0006_specimen_0017_alter_questionnaire_slug.py (2)
6-14
: LGTM! The merge migration looks... adequate.
The migration structure follows Django's conventions for merge migrations, with the expected empty operations list. I suppose we can't ask for more from an auto-generated file.
🧰 Tools
🪛 Ruff (0.8.0)
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
8-11
: Verify migration dependencies order
Let's make absolutely sure these migrations are in the correct order, shall we? We wouldn't want any... unfortunate surprises during deployment.
✅ Verification successful
Migration dependencies look... perfectly fine, actually
The dependencies form a clear, linear progression:
0006_specimen.py
depends on0005_servicerequest
0017_alter_questionnaire_slug.py
depends on0016_questionnaire_slug
- Both parent migrations exist and have their own valid dependency chains
- The merge migration
0018
correctly combines these two parallel branches
Perhaps the concern was unnecessary, but better safe than sorry, right?
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify migration dependencies and detect potential conflicts
# Check for any circular dependencies or ordering issues
fd --extension py . care/emr/migrations/ --exec grep -l "class Migration" {} \; | while read -r file; do
echo "=== $file ==="
grep -A 5 "dependencies = \[" "$file"
done
# Verify that both parent migrations exist
if ! [ -f "care/emr/migrations/0006_specimen.py" ]; then
echo "ERROR: Missing parent migration 0006_specimen.py"
fi
if ! [ -f "care/emr/migrations/0017_alter_questionnaire_slug.py" ]; then
echo "ERROR: Missing parent migration 0017_alter_questionnaire_slug.py"
fi
Length of output: 8581
🧰 Tools
🪛 Ruff (0.8.0)
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
9-9: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
10-10: Single quotes found but double quotes preferred
Replace single quotes with double quotes
(Q000)
…or list, retrieve, create and update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AuthZ missing, Add Tests and perform all coderabbit suggestions
report: DiagnosticReport = self.get_object() | ||
|
||
observations = [] | ||
for observation in data.observations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is observation valueset validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -43,8 +39,8 @@ def filter(self, qs, value): | |||
|
|||
class FacilityFilter(filters.FilterSet): | |||
name = filters.CharFilter(field_name="name", lookup_expr="icontains") | |||
facility_type = filters.NumberFilter(field_name="facility_type") | |||
organization = GeoOrganizationFilter() | |||
facility_type = filters.BaseInFilter(field_name="facility_type", lookup_expr="in") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves ohcnetwork/care_fe#8683
Frontend ohcnetwork/care_fe#9260
Added basic flow of creating a lab order till getting the results.
Still filters and permissions are pending.
Summary by CodeRabbit
Release Notes
New Features
DiagnosticReportViewSet
,ServiceRequestViewSet
, andSpecimenViewSet
to manage diagnostic reports, service requests, and specimens, respectively.Bug Fixes
Documentation
Database Migrations
DiagnosticReport
,ServiceRequest
, andSpecimen
, along with necessary fields and relationships.