Skip to content

Commit

Permalink
Merge pull request #1765 from coronasafe/master
Browse files Browse the repository at this point in the history
Production Release Dec Week 2
  • Loading branch information
gigincg authored Dec 11, 2023
2 parents 556d65b + e09e4c1 commit ced0618
Show file tree
Hide file tree
Showing 49 changed files with 8,621 additions and 4,186 deletions.
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 @@ def handle(self, *args, **options):
)

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")
management.call_command("load_medicines_data")
management.call_command("seed_data")
management.call_command("loaddata", self.BASE_URL + "users.json")
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(),
),
]
22 changes: 22 additions & 0 deletions care/facility/migrations/0394_alter_assetlocation_location_type.py
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

0 comments on commit ced0618

Please sign in to comment.