Skip to content

Commit

Permalink
lint all files (#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak authored Sep 19, 2024
1 parent d5a2278 commit 30395b6
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 93 deletions.
146 changes: 82 additions & 64 deletions care/abdm/utils/fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def _procedure(self, procedure):
text=procedure["procedure"],
),
subject=self._reference(self._patient()),
performedDateTime=f"{procedure['time']}:00+05:30"
if not procedure["repetitive"]
else None,
performedString=f"Every {procedure['frequency']}"
if procedure["repetitive"]
else None,
performedDateTime=(
f"{procedure['time']}:00+05:30" if not procedure["repetitive"] else None
),
performedString=(
f"Every {procedure['frequency']}" if procedure["repetitive"] else None
),
)

self._procedure_profiles.append(procedure_profile)
Expand All @@ -213,9 +213,11 @@ def _careplan(self):
description="This includes Treatment Summary, Prescribed Medication, General Notes and Special Instructions",
period=Period(
start=self.consultation.encounter_date.isoformat(),
end=self.consultation.discharge_date.isoformat()
if self.consultation.discharge_date
else None,
end=(
self.consultation.discharge_date.isoformat()
if self.consultation.discharge_date
else None
),
),
note=[
Annotation(text=self.consultation.treatment_plan),
Expand Down Expand Up @@ -260,36 +262,46 @@ def _diagnostic_report(self):
return self._diagnostic_report_profile

def _observation(self, title, value, id, date):
if not value or (type(value) == dict and not value["value"]):
if not value or (isinstance(value, dict) and not value["value"]):
return

return Observation(
id=f"{id}.{title.replace(' ', '').replace('_', '-')}"
if id and title
else str(uuid()),
id=(
f"{id}.{title.replace(' ', '').replace('_', '-')}"
if id and title
else str(uuid())
),
status="final",
effectiveDateTime=date if date else None,
code=CodeableConcept(text=title),
valueQuantity=Quantity(value=str(value["value"]), unit=value["unit"])
if type(value) == dict
else None,
valueString=value if type(value) == str else None,
component=list(
map(
lambda component: ObservationComponent(
code=CodeableConcept(text=component["title"]),
valueQuantity=Quantity(
value=component["value"], unit=component["unit"]
)
if type(component) == dict
else None,
valueString=component if type(component) == str else None,
),
value,
valueQuantity=(
Quantity(value=str(value["value"]), unit=value["unit"])
if isinstance(value, dict)
else None
),
valueString=value if isinstance(value, str) else None,
component=(
list(
map(
lambda component: ObservationComponent(
code=CodeableConcept(text=component["title"]),
valueQuantity=(
Quantity(
value=component["value"], unit=component["unit"]
)
if isinstance(component, dict)
else None
),
valueString=(
component if isinstance(component, str) else None
),
),
value,
)
)
)
if type(value) == list
else None,
if isinstance(value, list)
else None
),
)

def _observations_from_daily_round(self, daily_round):
Expand Down Expand Up @@ -322,20 +334,22 @@ def _observations_from_daily_round(self, daily_round):
),
self._observation(
"Blood Pressure",
[
{
"title": "Systolic Blood Pressure",
"value": daily_round.bp["systolic"],
"unit": "mmHg",
},
{
"title": "Diastolic Blood Pressure",
"value": daily_round.bp["diastolic"],
"unit": "mmHg",
},
]
if "systolic" in daily_round.bp and "diastolic" in daily_round.bp
else None,
(
[
{
"title": "Systolic Blood Pressure",
"value": daily_round.bp["systolic"],
"unit": "mmHg",
},
{
"title": "Diastolic Blood Pressure",
"value": daily_round.bp["diastolic"],
"unit": "mmHg",
},
]
if "systolic" in daily_round.bp and "diastolic" in daily_round.bp
else None
),
id,
date,
),
Expand Down Expand Up @@ -369,21 +383,23 @@ def _encounter(self, include_diagnosis=False):
"class": Coding(code="IMP", display="Inpatient Encounter"),
"subject": self._reference(self._patient()),
"period": Period(start=period_start, end=period_end),
"diagnosis": list(
map(
lambda consultation_diagnosis: EncounterDiagnosis(
condition=self._reference(
self._condition(
consultation_diagnosis.diagnosis_id,
consultation_diagnosis.verification_status,
),
)
),
self.consultation.diagnoses.all(),
"diagnosis": (
list(
map(
lambda consultation_diagnosis: EncounterDiagnosis(
condition=self._reference(
self._condition(
consultation_diagnosis.diagnosis_id,
consultation_diagnosis.verification_status,
),
)
),
self.consultation.diagnoses.all(),
)
)
)
if include_diagnosis
else None,
if include_diagnosis
else None
),
}
)

Expand Down Expand Up @@ -655,10 +671,12 @@ def _immunization_composition(self):
else []
)
],
emptyReason=None
if self._immunization()
else CodeableConcept(
coding=[Coding(code="notasked", display="Not Asked")]
emptyReason=(
None
if self._immunization()
else CodeableConcept(
coding=[Coding(code="notasked", display="Not Asked")]
)
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
"""

from django.conf import settings
from django.db import migrations

Expand Down
8 changes: 5 additions & 3 deletions care/facility/api/serializers/patient_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ def update(self, instance, validated_data):
is_completed = validated_data.get("result") in [1, 2]
new_status = validated_data.get(
"status",
PatientSample.SAMPLE_TEST_FLOW_MAP["COMPLETED"]
if is_completed
else None,
(
PatientSample.SAMPLE_TEST_FLOW_MAP["COMPLETED"]
if is_completed
else None
),
)
choice = PatientSample.SAMPLE_TEST_FLOW_CHOICES[new_status - 1][1]
if is_completed:
Expand Down
16 changes: 10 additions & 6 deletions care/facility/migrations/0439_encounter_symptoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def backfill_symptoms_table(apps, schema_editor):
bulk.append(
EncounterSymptom(
symptom=symptom_id,
other_symptom=consultation.deprecated_other_symptoms
if symptom_id == 9 # Other symptom
else "",
other_symptom=(
consultation.deprecated_other_symptoms
if symptom_id == 9 # Other symptom
else ""
),
onset_date=consultation.deprecated_symptoms_onset_date
or consultation.encounter_date,
created_date=consultation.created_date,
Expand Down Expand Up @@ -85,9 +87,11 @@ def backfill_symptoms_table(apps, schema_editor):
bulk.append(
EncounterSymptom(
symptom=symptom_id,
other_symptom=daily_round.deprecated_other_symptoms
if symptom_id == 9 # Other symptom
else "",
other_symptom=(
daily_round.deprecated_other_symptoms
if symptom_id == 9 # Other symptom
else ""
),
onset_date=daily_round.created_date,
created_date=daily_round.created_date,
created_by=daily_round.created_by,
Expand Down
2 changes: 1 addition & 1 deletion care/facility/models/patient_external_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PatientExternalTest(FacilityBaseModel):
"sample_type": "Sample Type",
"result": "Final Result",
"sample_collection_date": "Sample Collection Date",
"source": "Source"
"source": "Source",
# "result_date": "",
}

Expand Down
6 changes: 3 additions & 3 deletions care/facility/utils/summarisation/facility_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def facility_capacity_summary():
capacity_summary[facility_obj.id]["features"] = list(
capacity_summary[facility_obj.id]["features"]
)
capacity_summary[facility_obj.id][
"actual_live_patients"
] = patients_in_facility.filter(is_active=True).count()
capacity_summary[facility_obj.id]["actual_live_patients"] = (
patients_in_facility.filter(is_active=True).count()
)
discharge_patients = patients_in_facility.filter(is_active=False)
capacity_summary[facility_obj.id][
"actual_discharged_patients"
Expand Down
6 changes: 3 additions & 3 deletions care/facility/utils/summarisation/tests_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def tests_summary():
if facility_test_summary.data != facility_tests_summarised_data:
facility_test_summary.data = facility_tests_summarised_data
latest_modification_date = timezone.now()
facility_test_summary.data[
"modified_date"
] = latest_modification_date.strftime("%d-%m-%Y %H:%M")
facility_test_summary.data["modified_date"] = (
latest_modification_date.strftime("%d-%m-%Y %H:%M")
)
facility_test_summary.save()
except ObjectDoesNotExist:
modified_date = timezone.now()
Expand Down
6 changes: 3 additions & 3 deletions care/hcx/utils/hcx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def createHeaders(self, recipientCode=None, correlationId=None):
.replace(microsecond=0)
.isoformat(),
"x-hcx-sender_code": self.participantCode,
"x-hcx-correlation_id": correlationId
if correlationId
else str(uuid.uuid4()),
"x-hcx-correlation_id": (
correlationId if correlationId else str(uuid.uuid4())
),
# "x-hcx-workflow_id": str(uuid.uuid4()),
"x-hcx-api_call_id": str(uuid.uuid4()),
# "x-hcx-status": "response.complete",
Expand Down
16 changes: 10 additions & 6 deletions care/users/management/commands/populate_investigations.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ def handle(self, *args, **options):
"name": investigation["name"],
"unit": investigation.get("unit", ""),
"ideal_value": investigation.get("ideal_value", ""),
"min_value": None
if investigation.get("min_value") is None
else float(investigation.get("min_value")),
"max_value": None
if investigation.get("max_value") is None
else float(investigation.get("max_value")),
"min_value": (
None
if investigation.get("min_value") is None
else float(investigation.get("min_value"))
),
"max_value": (
None
if investigation.get("max_value") is None
else float(investigation.get("max_value"))
),
"investigation_type": investigation["type"],
"choices": investigation.get("choices", ""),
}
Expand Down
1 change: 1 addition & 0 deletions config/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
https://docs.djangoproject.com/en/dev/howto/deployment/asgi/
"""

import os
import sys
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.
"""

import os
import sys
from pathlib import Path
Expand Down
1 change: 0 additions & 1 deletion locale/hi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ msgstr "आपके पासवर्ड में कम से कम 1 प
#: config/validators.py:66
msgid "The domain name is invalid. It should not start with scheme and should not end with a trailing slash."
msgstr "डोमेन नाम अमान्य है। इसे स्कीम से शुरू नहीं करना चाहिए और अंत में स्लैश से नहीं होना चाहिए।"

1 change: 0 additions & 1 deletion locale/kn/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ msgstr "ನಿಮ್ಮ ಪಾಸ್‌ವರ್ಡ್ ಕನಿಷ್ಠ 1 ಚ
#: config/validators.py:66
msgid "The domain name is invalid. It should not start with scheme and should not end with a trailing slash."
msgstr "ಡೊಮೇನ್ ಹೆಸರು ಅಮಾನ್ಯವಾಗಿದೆ. ಇದು ಸ್ಕೀಮ್‌ನೊಂದಿಗೆ ಪ್ರಾರಂಭವಾಗಬಾರದು ಮತ್ತು ಟ್ರೇಲಿಂಗ್ ಸ್ಲ್ಯಾಷ್‌ನೊಂದಿಗೆ ಕೊನೆಗೊಳ್ಳಬಾರದು."

1 change: 0 additions & 1 deletion locale/ml/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ msgstr "നിങ്ങളുടെ പാസ്‌വേഡിൽ കുറഞ
#: config/validators.py:66
msgid "The domain name is invalid. It should not start with scheme and should not end with a trailing slash."
msgstr "ഡൊമെയ്ൻ നാമം അസാധുവാണ്. ഇത് സ്കീമിൽ ആരംഭിക്കരുത്, ഒരു ട്രെയിലിംഗ് സ്ലാഷിൽ അവസാനിക്കരുത്."

1 change: 0 additions & 1 deletion locale/ta/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ msgstr "உங்கள் கடவுச்சொல்லில் குற
#: config/validators.py:66
msgid "The domain name is invalid. It should not start with scheme and should not end with a trailing slash."
msgstr "டொமைன் பெயர் தவறானது. இது திட்டத்துடன் தொடங்கக்கூடாது மற்றும் பின்னோக்கி சாய்வுடன் முடிவடையக்கூடாது."

0 comments on commit 30395b6

Please sign in to comment.