From 2860cec1de61920a2f1a68f5abe66082ec9238a0 Mon Sep 17 00:00:00 2001 From: ipu Date: Tue, 5 Aug 2025 00:20:37 +0300 Subject: [PATCH] get conditions from api --- src/services/estimation_service_v2.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/services/estimation_service_v2.py b/src/services/estimation_service_v2.py index 0bc5278..d0d38cf 100644 --- a/src/services/estimation_service_v2.py +++ b/src/services/estimation_service_v2.py @@ -2,7 +2,7 @@ from datetime import date from enum import Enum from typing import Optional 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 import httpx @@ -136,6 +136,9 @@ class EstimationService: return False, "" 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: return True, "Pregnancy" @@ -144,7 +147,12 @@ class EstimationService: for detail in issue.details: if detail.key == "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 def calculate_age(self, born):