Skip to content

Commit

Permalink
Merge branch 'develop' into sainak/disable-asect-ratio-validation-for…
Browse files Browse the repository at this point in the history
…-images
  • Loading branch information
vigneshhari authored Sep 23, 2024
2 parents 95b2118 + 97e715d commit 8c67c2d
Show file tree
Hide file tree
Showing 50 changed files with 60 additions and 3,630 deletions.
34 changes: 0 additions & 34 deletions care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.conf import settings
from django.db import transaction
from django.db.models import Q
from django.utils.timezone import make_aware, now
from rest_framework import serializers

Expand Down Expand Up @@ -37,8 +36,6 @@
)
from care.facility.models.patient_consultation import PatientConsultation
from care.facility.models.patient_external_test import PatientExternalTest
from care.hcx.models.claim import Claim
from care.hcx.models.policy import Policy
from care.users.api.serializers.lsg import (
DistrictSerializer,
LocalBodySerializer,
Expand Down Expand Up @@ -94,37 +91,6 @@ class PatientListSerializer(serializers.ModelSerializer):

assigned_to_object = UserBaseMinimumSerializer(source="assigned_to", read_only=True)

# HCX
has_eligible_policy = serializers.SerializerMethodField(
"get_has_eligible_policy", read_only=True
)

def get_has_eligible_policy(self, patient):
eligible_policies = Policy.objects.filter(
(Q(error_text="") | Q(error_text=None)),
outcome="complete",
patient=patient.id,
)
return bool(len(eligible_policies))

approved_claim_amount = serializers.SerializerMethodField(
"get_approved_claim_amount", read_only=True
)

def get_approved_claim_amount(self, patient):
if patient.last_consultation is not None:
claim = (
Claim.objects.filter(
Q(error_text="") | Q(error_text=None),
consultation__external_id=patient.last_consultation.external_id,
outcome="complete",
total_claim_amount__isnull=False,
)
.order_by("-modified_date")
.first()
)
return claim.total_claim_amount if claim is not None else None

class Meta:
model = PatientRegistration
exclude = (
Expand Down
18 changes: 16 additions & 2 deletions care/facility/management/commands/load_redis_index.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from importlib import import_module

from django.core.cache import cache
from django.core.management import BaseCommand

from care.facility.static_data.icd11 import load_icd11_diagnosis
from care.facility.static_data.medibase import load_medibase_medicines
from care.hcx.static_data.pmjy_packages import load_pmjy_packages
from plug_config import manager


class Command(BaseCommand):
Expand All @@ -23,6 +25,18 @@ def handle(self, *args, **options):

load_icd11_diagnosis()
load_medibase_medicines()
load_pmjy_packages()

for plug in manager.plugs:
try:
module_path = f"{plug.name}.static_data"
module = import_module(module_path)

load_static_data = getattr(module, "load_static_data", None)
if load_static_data:
load_static_data()
except ModuleNotFoundError:
print(f"Module {module_path} not found")
except Exception as e:
print(f"Error loading static data for {plug.name}: {e}")

cache.delete("redis_index_loading")
17 changes: 15 additions & 2 deletions care/facility/tasks/redis_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from importlib import import_module
from logging import Logger

from celery import shared_task
Expand All @@ -6,8 +7,8 @@

from care.facility.static_data.icd11 import load_icd11_diagnosis
from care.facility.static_data.medibase import load_medibase_medicines
from care.hcx.static_data.pmjy_packages import load_pmjy_packages
from care.utils.static_data.models.base import index_exists
from plug_config import manager

logger: Logger = get_task_logger(__name__)

Expand All @@ -26,7 +27,19 @@ def load_redis_index():

load_icd11_diagnosis()
load_medibase_medicines()
load_pmjy_packages()

for plug in manager.plugs:
try:
module_path = f"{plug.name}.static_data"
module = import_module(module_path)

load_static_data = getattr(module, "load_static_data", None)
if load_static_data:
load_static_data()
except ModuleNotFoundError:
logger.info(f"Module {module_path} not found")
except Exception as e:
logger.info(f"Error loading static data for {plug.name}: {e}")

cache.delete("redis_index_loading")
logger.info("Redis Index Loaded")
Binary file modified care/facility/tests/sample_reports/sample2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion care/facility/tests/test_pdf_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def setUpTestData(cls) -> None:
suggestion="A",
)
cls.create_patient_sample(cls.patient, cls.consultation, cls.facility, cls.user)
cls.create_policy(patient=cls.patient, user=cls.user)
cls.create_encounter_symptom(cls.consultation, cls.user)
cls.patient_investigation_group = cls.create_patient_investigation_group()
cls.patient_investigation = cls.create_patient_investigation(
Expand Down
3 changes: 0 additions & 3 deletions care/facility/utils/reports/discharge_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
ConditionVerificationStatus,
)
from care.facility.static_data.icd11 import get_icd11_diagnosis_object_by_id
from care.hcx.models.policy import Policy

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -117,7 +116,6 @@ def get_discharge_summary_data(consultation: PatientConsultation):
samples = PatientSample.objects.filter(
patient=consultation.patient, consultation=consultation
)
hcx = Policy.objects.filter(patient=consultation.patient)
symptoms = EncounterSymptom.objects.filter(
consultation=consultation, onset_date__lt=consultation.encounter_date
).exclude(clinical_impression_status=ClinicalImpressionStatus.ENTERED_IN_ERROR)
Expand Down Expand Up @@ -181,7 +179,6 @@ def get_discharge_summary_data(consultation: PatientConsultation):
return {
"patient": consultation.patient,
"samples": samples,
"hcx": hcx,
"symptoms": symptoms,
"admitted_to": admitted_to,
"admission_duration": admission_duration,
Expand Down
Empty file removed care/hcx/__init__.py
Empty file.
98 changes: 0 additions & 98 deletions care/hcx/api/serializers/claim.py

This file was deleted.

41 changes: 0 additions & 41 deletions care/hcx/api/serializers/communication.py

This file was deleted.

38 changes: 0 additions & 38 deletions care/hcx/api/serializers/gateway.py

This file was deleted.

Loading

0 comments on commit 8c67c2d

Please sign in to comment.