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: December Week 4 #1786

Merged
merged 15 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ name = "pypi"
[packages]
argon2-cffi = "==23.1.0"
authlib = "==1.2.1"
boto3 = "==1.28.50"
boto3 = "==1.34.2"
celery = "==5.3.4"
django = "==4.2.5"
django = "==4.2.8"
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-maintenance-mode = "==0.21.0"
django-model-utils = "==4.3.1"
django-multiselectfield = "==0.1.12"
django-queryset-csv = "==1.1.0"
Expand All @@ -30,12 +30,12 @@ drf-spectacular = "==0.26.4"
"fhir.resources" = "==6.5.0"
gunicorn = "==21.2.0"
healthy-django = "==0.1.0"
jsonschema = "==4.19.0"
jsonschema = "==4.20.0"
jwcrypto = "==1.5.0"
littletable = "==2.2.3"
newrelic = "==9.0.0"
newrelic = "==9.3.0"
pillow = "==10.1.0"
psycopg = "==3.1.10"
psycopg = "==3.1.14"
pycryptodome = "==3.19.0"
pydantic = "==1.10.12" # fix for fhir.resources < 7.0.2
pyjwt = "==2.8.0"
Expand All @@ -48,7 +48,7 @@ whitenoise = "==6.5.0"

[dev-packages]
black = "==23.9.1"
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.28.50"}
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.34.2"}
coverage = "==7.3.1"
debugpy = "==1.7.0"
django-coverage-plugin = "==3.1.0"
Expand Down
384 changes: 193 additions & 191 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions care/abdm/utils/fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _careplan(self):
title="Care Plan",
description="This includes Treatment Summary, Prescribed Medication, General Notes and Special Instructions",
period=Period(
start=self.consultation.admission_date.isoformat(),
start=self.consultation.encounter_date.isoformat(),
end=self.consultation.discharge_date.isoformat()
if self.consultation.discharge_date
else None,
Expand Down Expand Up @@ -355,7 +355,7 @@ def _encounter(self, include_diagnosis=False):

id = str(self.consultation.external_id)
status = "finished" if self.consultation.discharge_date else "in-progress"
period_start = self.consultation.admission_date.isoformat()
period_start = self.consultation.encounter_date.isoformat()
period_end = (
self.consultation.discharge_date.isoformat()
if self.consultation.discharge_date
Expand Down Expand Up @@ -463,7 +463,7 @@ def _medication(self, name):
def _medication_request(self, medicine):
id = str(uuid())
prescription_date = (
self.consultation.admission_date.isoformat()
self.consultation.encounter_date.isoformat()
) # TODO: change to the time of prescription
status = "unknown" # TODO: get correct status active | on-hold | cancelled | completed | entered-in-error | stopped | draft | unknown
dosage_text = f"{medicine['dosage_new']} / {medicine['dosage']} for {medicine['days']} days"
Expand Down
5 changes: 1 addition & 4 deletions care/facility/api/serializers/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ def validate(self, attrs):
raise ValidationError(
{"end_date": "End date cannot be before the start date"}
)
if (
consultation.admission_date
and consultation.admission_date > current_start_date
):
if consultation.encounter_date > current_start_date:
raise ValidationError(
{"start_date": "Start date cannot be before the admission date"}
)
Expand Down
26 changes: 20 additions & 6 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
from care.facility.models.bed import Bed
from care.facility.models.daily_round import DailyRound
from care.facility.models.notification import Notification
from care.facility.models.patient_base import CURRENT_HEALTH_CHOICES, SYMPTOM_CHOICES
from care.facility.models.patient_base import (
CURRENT_HEALTH_CHOICES,
SYMPTOM_CHOICES,
SuggestionChoices,
)
from care.users.api.serializers.user import UserBaseMinimumSerializer
from care.utils.notification_handler import NotificationGenerator
from care.utils.queryset.consultation import get_consultation_queryset
Expand Down Expand Up @@ -180,14 +184,24 @@ def create(self, validated_data):
# Authorisation Checks End

with transaction.atomic():
consultation = get_object_or_404(
get_consultation_queryset(self.context["request"].user).filter(
id=validated_data["consultation"].id
)
)
if (
validated_data.get("rounds_type")
== DailyRound.RoundsType.TELEMEDICINE.value
and consultation.suggestion != SuggestionChoices.DC
):
raise ValidationError(
{
"rounds_type": "Telemedicine Rounds are only allowed for Domiciliary Care patients"
}
)
if "clone_last" in validated_data:
should_clone = validated_data.pop("clone_last")
if should_clone:
consultation = get_object_or_404(
get_consultation_queryset(self.context["request"].user).filter(
id=validated_data["consultation"].id
)
)
last_objects = DailyRound.objects.filter(
consultation=consultation
).order_by("-created_date")
Expand Down
34 changes: 12 additions & 22 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def create(self, validated_data):
and last_consultation.suggestion == SuggestionChoices.A
and last_consultation.discharge_date
and last_consultation.discharge_date + timedelta(days=30)
> consultation.admission_date
> consultation.encounter_date
):
consultation.is_readmission = True
consultation.save()
Expand Down Expand Up @@ -473,6 +473,13 @@ def validate_create_diagnoses(self, value):

return value

def validate_encounter_date(self, value):
if value > now():
raise ValidationError(
{"encounter_date": "This field value cannot be in the future."}
)
return value

def validate(self, attrs):
validated = super().validate(attrs)
# TODO Add Bed Authorisation Validation
Expand Down Expand Up @@ -524,17 +531,6 @@ def validate(self, attrs):
validated["referred_to"] = None
elif validated.get("referred_to"):
validated["referred_to_external"] = None
if validated["suggestion"] is SuggestionChoices.A:
if not validated.get("admission_date"):
raise ValidationError(
{
"admission_date": "This field is required as the patient has been admitted."
}
)
if validated["admission_date"] > now():
raise ValidationError(
{"admission_date": "This field value cannot be in the future."}
)

if "action" in validated:
if validated["action"] == PatientRegistration.ActionEnum.REVIEW:
Expand Down Expand Up @@ -634,13 +630,10 @@ def validate(self, attrs):
raise ValidationError(
{"death_datetime": "This field value cannot be in the future."}
)
if (
self.instance.admission_date
and attrs.get("death_datetime") < self.instance.admission_date
):
if attrs.get("death_datetime") < self.instance.encounter_date:
raise ValidationError(
{
"death_datetime": "This field value cannot be before the admission date."
"death_datetime": "This field value cannot be before the encounter date."
}
)
if not attrs.get("death_confirmed_doctor"):
Expand All @@ -654,13 +647,10 @@ def validate(self, attrs):
raise ValidationError(
{"discharge_date": "This field value cannot be in the future."}
)
elif (
self.instance.admission_date
and attrs.get("discharge_date") < self.instance.admission_date
):
elif attrs.get("discharge_date") < self.instance.encounter_date:
raise ValidationError(
{
"discharge_date": "This field value cannot be before the admission date."
"discharge_date": "This field value cannot be before the encounter date."
}
)
return attrs
Expand Down
56 changes: 0 additions & 56 deletions care/facility/api/serializers/prescription_supplier.py

This file was deleted.

8 changes: 2 additions & 6 deletions care/facility/api/viewsets/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ class DailyRoundsViewSet(
IsAuthenticated,
DRYPermissions,
)
queryset = (
DailyRound.objects.all()
.order_by("-id")
.select_related("created_by", "last_edited_by")
)
queryset = DailyRound.objects.all().select_related("created_by", "last_edited_by")
lookup_field = "external_id"
filterset_class = DailyRoundFilterSet

Expand All @@ -63,7 +59,7 @@ class DailyRoundsViewSet(
def get_queryset(self):
return self.queryset.filter(
consultation__external_id=self.kwargs["consultation_external_id"]
)
).order_by("-taken_at")

def get_serializer(self, *args, **kwargs):
if "data" in kwargs:
Expand Down
6 changes: 3 additions & 3 deletions care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def filter_by_category(self, queryset, name, value):
last_consultation_kasp_enabled_date = filters.DateFromToRangeFilter(
field_name="last_consultation__kasp_enabled_date"
)
last_consultation_admission_date = filters.DateFromToRangeFilter(
field_name="last_consultation__admission_date"
last_consultation_encounter_date = filters.DateFromToRangeFilter(
field_name="last_consultation__encounter_date"
)
last_consultation_discharge_date = filters.DateFromToRangeFilter(
field_name="last_consultation__discharge_date"
Expand Down Expand Up @@ -332,7 +332,7 @@ class PatientViewSet(
"date_declared_positive",
"date_of_result",
"last_vaccinated_date",
"last_consultation_admission_date",
"last_consultation_encounter_date",
"last_consultation_discharge_date",
"last_consultation_symptoms_onset_date",
]
Expand Down
89 changes: 0 additions & 89 deletions care/facility/api/viewsets/prescription_supplier.py

This file was deleted.

Loading
Loading