get conditions from api

This commit is contained in:
ipu 2025-08-05 00:20:37 +03:00
parent 0a41d9ba82
commit 2860cec1de

View file

@ -2,7 +2,7 @@ from datetime import date
from enum import Enum from enum import Enum
from typing import Optional from typing import Optional
from src.models import PHQ, Applicant, Plan, EstimationResponse, EstimationDetails, EstimationResult from src.models import PHQ, Applicant, Plan, EstimationResponse, EstimationDetails, EstimationResult
from src.cache.redis_cache import fetch_drug, get_plan_by_id, search_drug from src.cache.redis_cache import fetch_conditions, fetch_drug, get_plan_by_id, search_drug
from src.config import settings from src.config import settings
import httpx import httpx
@ -136,6 +136,9 @@ class EstimationService:
return False, "" return False, ""
def check_dtq(self, phq: PHQ) -> tuple[bool, str]: def check_dtq(self, phq: PHQ) -> tuple[bool, str]:
uninsurable_conditions_response = fetch_conditions()
uninsurable_conditions = [condition["key"] for condition in uninsurable_conditions_response]
if phq.pregnancy: if phq.pregnancy:
return True, "Pregnancy" return True, "Pregnancy"
@ -144,7 +147,12 @@ class EstimationService:
for detail in issue.details: for detail in issue.details:
if detail.key == "not_performed": if detail.key == "not_performed":
return True, "Surgery that was not performed" return True, "Surgery that was not performed"
# TODO: Add other DTQ conditions
for condition in phq.conditions:
if condition.key in uninsurable_conditions:
return True, f"Condition: {condition.key}"
# issues would be checked by AI
return False, None return False, None
def calculate_age(self, born): def calculate_age(self, born):