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

HCX Plug #2399

Merged
merged 13 commits into from
Sep 23, 2024
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(
anroopak marked this conversation as resolved.
Show resolved Hide resolved
"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

Check warning on line 1 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L1

Added line #L1 was not covered by tests

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

Check warning on line 8 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L8

Added line #L8 was not covered by tests


class Command(BaseCommand):
Expand All @@ -23,6 +25,18 @@

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)

Check warning on line 32 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L30-L32

Added lines #L30 - L32 were not covered by tests

load_static_data = getattr(module, "load_static_data", None)

Check warning on line 34 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L34

Added line #L34 was not covered by tests
if load_static_data:
load_static_data()

Check warning on line 36 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L36

Added line #L36 was not covered by tests
except ModuleNotFoundError:
print(f"Module {module_path} not found")
except Exception as e:
print(f"Error loading static data for {plug.name}: {e}")

Check warning on line 40 in care/facility/management/commands/load_redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_redis_index.py#L38-L40

Added lines #L38 - L40 were not covered by tests

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 @@

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)

Check warning on line 34 in care/facility/tasks/redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/tasks/redis_index.py#L32-L34

Added lines #L32 - L34 were not covered by tests

load_static_data = getattr(module, "load_static_data", None)

Check warning on line 36 in care/facility/tasks/redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/tasks/redis_index.py#L36

Added line #L36 was not covered by tests
if load_static_data:
load_static_data()

Check warning on line 38 in care/facility/tasks/redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/tasks/redis_index.py#L38

Added line #L38 was not covered by tests
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}")

Check warning on line 42 in care/facility/tasks/redis_index.py

View check run for this annotation

Codecov / codecov/patch

care/facility/tasks/redis_index.py#L40-L42

Added lines #L40 - L42 were not covered by tests

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,
Copy link
Member

@sainak sainak Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should think of a way to allow apps to expose discharge summary template sections and data

cc: @vigneshhari

"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