Skip to content

Commit

Permalink
Merge branch 'develop' into sainak/feat/app-version-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari authored Jun 5, 2024
2 parents 386b14e + 8790cde commit 0c7453f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 55 deletions.
16 changes: 0 additions & 16 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,22 +603,6 @@ def validate(self, attrs):
{"patient_no": "This field is required for admission."}
)

if (
suggestion == SuggestionChoices.A or patient_no
) and PatientConsultation.objects.filter(
patient_no=patient_no,
facility=(
self.instance.facility
if self.instance
else validated.get("patient").facility
),
).exists():
raise ValidationError(
{
"patient_no": "Consultation with this IP/OP number already exists within the facility."
}
)

if (
"suggestion" in validated
and validated["suggestion"] != SuggestionChoices.DD
Expand Down
2 changes: 1 addition & 1 deletion care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def get_queryset(self):
)
).order_by(
"-no_consultation_filed",
"modified_date",
"-modified_date",
)

return queryset
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.10 on 2024-06-03 05:54

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("facility", "0441_delete_patientteleconsultation"),
]

operations = [
migrations.RemoveConstraint(
model_name="patientconsultation",
name="unique_patient_no_within_facility",
),
]
5 changes: 0 additions & 5 deletions care/facility/models/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ class Meta:
| models.Q(referred_to__isnull=False)
| models.Q(referred_to_external__isnull=False),
),
models.UniqueConstraint(
fields=["patient_no", "facility"],
name="unique_patient_no_within_facility",
condition=models.Q(patient_no__isnull=False),
),
]

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions care/facility/static_data/icd11.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from django.core.paginator import Paginator
from redis_om import Field, Migrator
from redis_om.model.model import NotFoundError as RedisModelNotFoundError

from care.facility.models.icd11_diagnosis import ICD11Diagnosis
from care.utils.static_data.models.base import BaseRedisModel
Expand Down Expand Up @@ -61,7 +60,7 @@ def get_icd11_diagnosis_object_by_id(
try:
diagnosis = ICD11.get(diagnosis_id)
return diagnosis.get_representation() if as_dict else diagnosis
except RedisModelNotFoundError:
except Exception:
return None


Expand Down
31 changes: 1 addition & 30 deletions care/facility/tests/test_patient_consultation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def setUpTestData(cls) -> None:
"doctor", cls.district, home_facility=cls.facility, user_type=15
)
cls.patient1 = cls.create_patient(cls.district, cls.facility)
cls.patient2 = cls.create_patient(cls.district, cls.facility)

def get_default_data(self):
return {
Expand Down Expand Up @@ -569,36 +570,6 @@ def test_add_principal_edit_as_inactive_add_principal(self):
)
self.assertEqual(res.status_code, status.HTTP_201_CREATED)

def test_create_consultations_with_duplicate_patient_no_within_facility(self):
patient2 = self.create_patient(self.district, self.facility)
data = self.get_default_data().copy()
data.update(
{
"patient_no": "IP1234",
"patient": patient2.external_id,
"facility": self.facility.external_id,
"created_by": self.user.external_id,
"suggestion": SuggestionChoices.A,
}
)
res = self.client.post(self.get_url(), data, format="json")
self.assertEqual(res.status_code, status.HTTP_201_CREATED)

data.update(
{
"patient_no": "IP1234",
"patient": self.patient1.external_id,
"facility": self.facility.external_id,
"created_by": self.user.external_id,
}
)
res = self.client.post(self.get_url(), data, format="json")
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)

data.update({"suggestion": SuggestionChoices.A})
res = self.client.post(self.get_url(), data, format="json")
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_consultations_with_same_patient_no_in_different_facilities(self):
facility2 = self.create_facility(
self.super_user, self.district, self.local_body, name="bar"
Expand Down
12 changes: 12 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

import environ
from authlib.jose import JsonWebKey
from healthy_django.healthcheck.celery_queue_length import (
DjangoCeleryQueueLengthHealthCheck,
)
from healthy_django.healthcheck.django_cache import DjangoCacheHealthCheck
from healthy_django.healthcheck.django_database import DjangoDatabaseHealthCheck

Expand Down Expand Up @@ -415,6 +418,15 @@
"Database", slug="main_database", connection_name="default"
),
DjangoCacheHealthCheck("Cache", slug="main_cache", connection_name="default"),
DjangoCeleryQueueLengthHealthCheck(
"Celery Queue Length",
slug="celery_queue_length",
broker=REDIS_URL,
queue_name="celery",
info_length=50,
warning_length=0, # this skips the 300 status code
alert_length=200,
),
]

# Audit logs
Expand Down
4 changes: 3 additions & 1 deletion config/settings/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0),
profiles_sample_rate=env.float("SENTRY_PROFILES_SAMPLE_RATE", default=0),
integrations=[
LoggingIntegration(event_level=logging.WARNING),
LoggingIntegration(
event_level=env.int("SENTRY_EVENT_LEVEL", default=logging.ERROR)
),
DjangoIntegration(),
CeleryIntegration(monitor_beat_tasks=True),
RedisIntegration(),
Expand Down

0 comments on commit 0c7453f

Please sign in to comment.