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

Production Release Dec Week 2 #1765

Merged
merged 30 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
033d085
Ensure Deterministic Ordering of Local Self Government and Ward Data …
Ashesh3 Dec 5, 2023
1489801
Refactor asset status check logic (#1750)
Ashesh3 Dec 7, 2023
df576b0
offload migrations to beat service (#1710)
sainak Dec 7, 2023
26d5a6d
Allow district admin to delete users (#1738)
Ashesh3 Dec 7, 2023
83b6495
show icu admission date in discharge summary pdf (#1736)
Pranshu1902 Dec 7, 2023
8720fe4
add management command to load skills (#1707)
sainak Dec 7, 2023
d481c90
pin dependencies in pipenv (#1705)
sainak Dec 7, 2023
46341e1
add DenominationValidator to validate dosage fields in Prescription m…
sainak Dec 7, 2023
261d024
add env vars to configure cors headers (#1703)
sainak Dec 7, 2023
84ead2a
Field to classify location as an ICU or Ward or Other (#1708)
GokulramGHV Dec 7, 2023
5563b48
Check if user uploading External results is from same district (#1747)
Pranshu1902 Dec 7, 2023
19d414f
Resolved Display Issues for Oxygen Cylinder Capacity in Facility Expo…
Ashesh3 Dec 7, 2023
e5409f7
Add More Facilities and patients to dummy data (#1748)
Ashesh3 Dec 7, 2023
79c734a
Add `resolved_middleware` JSON field to Asset Serializer. (#1741)
rithviknishad Dec 7, 2023
1ce8fdc
made patient notes consultation specific (#1727)
sainak Dec 7, 2023
940e0e7
bump pillow from 10.0.0 to 10.1.0 (#1677)
dependabot[bot] Dec 7, 2023
7663481
Restrict Admin from unlinking users from other district (#1157)
Pranshu1902 Dec 7, 2023
c30e5c6
Don't allow negative values for Doctor Count for facility (#1505)
Pranshu1902 Dec 7, 2023
2407f67
merge migrations (#1751)
sainak Dec 7, 2023
6ea03f9
merge migrations (#1752)
sainak Dec 7, 2023
0869c46
Bump werkzeug from 2.3.7 to 2.3.8 (#1753)
dependabot[bot] Dec 7, 2023
68c2487
cleanup dummy data
sainak Dec 8, 2023
560b3bd
fix
sainak Dec 8, 2023
3e635e9
fix data type error
Pranshu1902 Dec 9, 2023
026949a
add tests
Pranshu1902 Dec 9, 2023
8b529d2
refactor tests
Pranshu1902 Dec 10, 2023
09edf05
Merge pull request #1758 from coronasafe/sainak/fix/dummy-data
gigincg Dec 11, 2023
48e5468
Merge pull request #1762 from Pranshu1902/issue#1761
gigincg Dec 11, 2023
5c87480
rename skills with incorrect spelling
sainak Dec 11, 2023
e09e4c1
Merge pull request #1766 from coronasafe/sainka/fix/user-skill-name
gigincg Dec 11, 2023
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
boto:
patterns:
- "boto*"

- package-ecosystem: "docker"
directory: "/docker"
Expand Down
106 changes: 53 additions & 53 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,73 @@ verify_ssl = true
name = "pypi"

[packages]
argon2-cffi = "*"
authlib = "==1.2.*"
boto3 = "*"
celery = "==5.*"
"fhir.resources" = "==6.5.0"
django = "==4.2.*"
django-environ = "*"
django-cors-headers = "==4.*"
django-filter = "==23.*"
argon2-cffi = "==23.1.0"
authlib = "==1.2.1"
boto3 = "==1.28.50"
celery = "==5.3.4"
django = "==4.2.5"
django-environ = "==0.11.2"
django-cors-headers = "==4.2.0"
django-filter = "==23.2"
django-hardcopy = "==0.1.4"
django-maintenance-mode = "==0.18.0"
django-model-utils = "==4.3.*"
django-model-utils = "==4.3.1"
django-multiselectfield = "==0.1.12"
django-queryset-csv = "==1.1.0"
django-ratelimit = "==4.1.0"
django-redis = "==5.*"
django-redis = "==5.3.0"
django-rest-passwordreset = "==1.3.0"
django-simple-history = "==3.3.0"
djangoql = "==0.17.*"
djangorestframework = "==3.14.*"
djangorestframework-simplejwt = "==5.*"
djangoql = "==0.17.1"
djangorestframework = "==3.14.0"
djangorestframework-simplejwt = "==5.3.0"
dry-rest-permissions = "==0.1.10"
drf-nested-routers = "==0.93.*"
drf-spectacular = "*"
healthy-django = ">=0.1.0"
jsonschema = "==4.*"
drf-nested-routers = "==0.93.4"
drf-spectacular = "==0.26.4"
"fhir.resources" = "==6.5.0"
gunicorn = "==21.2.0"
healthy-django = "==0.1.0"
jsonschema = "==4.19.0"
jwcrypto = "==1.5.0"
littletable = "==2.*"
pillow = "*"
psycopg = "*"
pycryptodome = "==3.*"
pydantic = "==1.*" # fix for fhir.resources < 7.0.2
pyjwt = "==2.*"
python-slugify = "*"
littletable = "==2.2.3"
newrelic = "==9.0.0"
pillow = "==10.1.0"
psycopg = "==3.1.10"
pycryptodome = "==3.19.0"
pydantic = "==1.10.12" # fix for fhir.resources < 7.0.2
pyjwt = "==2.8.0"
python-slugify = "==8.0.1"
pywebpush = "==1.14.0"
redis = {extras = ["hiredis"] }
requests = "*"
whitenoise = "*"
gunicorn = "*"
newrelic = "*"
sentry-sdk = "*"
redis = {extras = ["hiredis"], version = "==5.0.0"}
requests = "==2.31.0"
sentry-sdk = "==1.30.0"
whitenoise = "==6.5.0"

[dev-packages]
black = "*"
boto3-stubs = {extras = ["s3", "boto3"], version = "*"}
coverage = "*"
debugpy = "*"
django-coverage-plugin = "*"
django-debug-toolbar = "*"
django-extensions = "*"
django-silk = "*"
django-stubs = "*"
djangorestframework-stubs = "*"
factory-boy = "*"
flake8 = "*"
isort = "*"
mypy = "*"
pre-commit = "*"
tblib = "*"
watchdog = "*"
werkzeug = "*"
freezegun = "*"
ipython = "*"
black = "==23.9.1"
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.28.50"}
coverage = "==7.3.1"
debugpy = "==1.7.0"
django-coverage-plugin = "==3.1.0"
django-debug-toolbar = "==4.2.0"
django-extensions = "==3.2.3"
django-silk = "==5.0.3"
django-stubs = "==4.2.4"
djangorestframework-stubs = "==3.14.2"
factory-boy = "==3.3.0"
flake8 = "==6.1.0"
freezegun = "==1.2.2"
ipython = "==8.15.0"
isort = "==5.12.0"
mypy = "==1.5.1"
pre-commit = "==3.4.0"
tblib = "==2.0.0"
watchdog = "==3.0.0"
werkzeug = "==2.3.8"

[docs]
furo = "*"
sphinx = "*"
furo = "==2023.9.10"
sphinx = "==7.2.6"

[requires]
python_version = "3.11"
1,299 changes: 697 additions & 602 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions aws/backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"name": "CSRF_TRUSTED_ORIGINS",
"value": "[\"http://care-django-staging\", \"https://care.coronasafe.in\", \"https://careapi.coronasafe.in\", \"https://care.ohc.network\", \"https://careapi.ohc.network\"]"
},
{
"name": "CORS_ALLOWED_ORIGINS",
"value": "[\"https://care.coronasafe.in\", \"https://careapi.coronasafe.in\", \"https://care.ohc.network\", \"https://careapi.ohc.network\", \"https://status.10bedicu.org\"]"
},
{
"name": "CURRENT_DOMAIN",
"value": "https://care.ohc.network"
Expand Down
19 changes: 18 additions & 1 deletion care/facility/api/serializers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.db import transaction
from django.shortcuts import get_object_or_404
from django.utils.timezone import now
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.serializers import (
Expand Down Expand Up @@ -40,6 +41,7 @@
class AssetLocationSerializer(ModelSerializer):
facility = FacilityBareMinimumSerializer(read_only=True)
id = UUIDField(source="external_id", read_only=True)
location_type = ChoiceField(choices=AssetLocation.RoomTypeChoices)

def validate_middleware_address(self, value):
value = (value or "").strip()
Expand Down Expand Up @@ -123,6 +125,20 @@ def update(self, instance, validated_data):
return updated_instance


@extend_schema_field(
{
"type": "object",
"properties": {
"hostname": {"type": "string"},
"source": {"type": "string", "enum": ["asset", "location", "facility"]},
},
"nullable": True,
}
)
class ResolvedMiddlewareField(serializers.JSONField):
pass


class AssetSerializer(ModelSerializer):
id = UUIDField(source="external_id", read_only=True)
status = ChoiceField(choices=StatusChoices, read_only=True)
Expand All @@ -132,11 +148,12 @@ class AssetSerializer(ModelSerializer):
last_service = AssetServiceSerializer(read_only=True)
last_serviced_on = serializers.DateField(write_only=True, required=False)
note = serializers.CharField(write_only=True, required=False, allow_blank=True)
resolved_middleware = ResolvedMiddlewareField(read_only=True)

class Meta:
model = Asset
exclude = ("deleted", "external_id", "current_location")
read_only_fields = TIMESTAMP_FIELDS
read_only_fields = TIMESTAMP_FIELDS + ("resolved_middleware",)

def validate_qr_code_id(self, value):
value = value or None # treat empty string as null
Expand Down
7 changes: 7 additions & 0 deletions care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ def save(self, **kwargs):
class PatientNotesSerializer(serializers.ModelSerializer):
facility = FacilityBasicInfoSerializer(read_only=True)
created_by_object = UserBaseMinimumSerializer(source="created_by", read_only=True)
consultation = ExternalIdSerializerField(
queryset=PatientConsultation.objects.all(),
required=False,
allow_null=True,
read_only=True,
)

def validate_empty_values(self, data):
if not data.get("note", "").strip():
Expand All @@ -501,6 +507,7 @@ class Meta:
fields = (
"note",
"facility",
"consultation",
"created_by_object",
"user_type",
"created_date",
Expand Down
7 changes: 7 additions & 0 deletions care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ def list(self, request, *args, **kwargs):
return super(PatientSearchViewSet, self).list(request, *args, **kwargs)


class PatientNotesFilterSet(filters.FilterSet):
consultation = filters.CharFilter(field_name="consultation__external_id")


class PatientNotesViewSet(
ListModelMixin, RetrieveModelMixin, CreateModelMixin, GenericViewSet
):
Expand All @@ -636,6 +640,8 @@ class PatientNotesViewSet(
)
serializer_class = PatientNotesSerializer
permission_classes = (IsAuthenticated, DRYPermissions)
filter_backends = (filters.DjangoFilterBackend,)
filterset_class = PatientNotesFilterSet

def get_queryset(self):
user = self.request.user
Expand Down Expand Up @@ -671,6 +677,7 @@ def perform_create(self, serializer):
instance = serializer.save(
facility=patient.facility,
patient=patient,
consultation=patient.last_consultation,
created_by=self.request.user,
)

Expand Down
6 changes: 6 additions & 0 deletions care/facility/api/viewsets/patient_external_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def bulk_upsert(self, request, *args, **kwargs):
raise ValidationError({"sample_tests": "No Data was provided"})
if not isinstance(request.data["sample_tests"], list):
raise ValidationError({"sample_tests": "Data should be provided as a list"})

# check if the user is from same district
for data in request.data["sample_tests"]:
if str(request.user.district) != data["district"]:
raise ValidationError({"Error": "User must belong to same district"})

errors = []
counter = 0
ser_objects = []
Expand Down
7 changes: 3 additions & 4 deletions care/facility/management/commands/load_dummy_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
)

try:
management.call_command("loaddata", self.BASE_URL + "users.json")
management.call_command("load_data", "kerala")
management.call_command("loaddata", self.BASE_URL + "states.json")
management.call_command("load_skill_data")

Check warning on line 26 in care/facility/management/commands/load_dummy_data.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_dummy_data.py#L25-L26

Added lines #L25 - L26 were not covered by tests
management.call_command("load_medicines_data")
management.call_command("seed_data")
management.call_command("loaddata", self.BASE_URL + "users.json")

Check warning on line 29 in care/facility/management/commands/load_dummy_data.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_dummy_data.py#L29

Added line #L29 was not covered by tests
management.call_command("loaddata", self.BASE_URL + "facility.json")
management.call_command("loaddata", self.BASE_URL + "cypress_users.json")
management.call_command("loaddata", self.BASE_URL + "facility_users.json")
except Exception as e:
raise CommandError(e)
24 changes: 24 additions & 0 deletions care/facility/migrations/0393_alter_hospitaldoctors_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.2 on 2023-10-20 10:15

from django.db import migrations, models
from django.db.models import F


def convert_negative_to_positive(apps, schema_editor):
HospitalDoctors = apps.get_model("facility", "HospitalDoctors")
HospitalDoctors.objects.filter(count__lt=0).update(count=F("count") * -1)


class Migration(migrations.Migration):
dependencies = [
("facility", "0392_alter_dailyround_consciousness_level"),
]

operations = [
migrations.RunPython(convert_negative_to_positive),
migrations.AlterField(
model_name="hospitaldoctors",
name="count",
field=models.PositiveIntegerField(),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.5 on 2023-11-13 08:56

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
(
"facility",
"0393_rename_diagnosis_patientconsultation_deprecated_diagnosis_and_more",
),
]

operations = [
migrations.AlterField(
model_name="assetlocation",
name="location_type",
field=models.IntegerField(
choices=[(1, "OTHER"), (10, "ICU"), (20, "WARD")], default=1
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Generated by Django 4.2.5 on 2023-12-06 13:06

from django.db import migrations, models

import care.utils.models.validators


class Migration(migrations.Migration):
dependencies = [
("facility", "0397_truncate_discharge_time"),
]

operations = [
migrations.AlterField(
model_name="prescription",
name="dosage",
field=models.CharField(
blank=True,
max_length=100,
null=True,
validators=[
care.utils.models.validators.DenominationValidator(
allow_floats=True,
max_amount=5000,
min_amount=0.0001,
precision=4,
units={"mg", "g", "ml", "tsp", "ampule(s)", "drop(s)"},
)
],
),
),
migrations.AlterField(
model_name="prescription",
name="max_dosage",
field=models.CharField(
blank=True,
max_length=100,
null=True,
validators=[
care.utils.models.validators.DenominationValidator(
allow_floats=True,
max_amount=5000,
min_amount=0.0001,
precision=4,
units={"mg", "g", "ml", "tsp", "ampule(s)", "drop(s)"},
)
],
),
),
]
Loading
Loading