From 280611e86fa282d55cb67acb372ddb66c592d21a Mon Sep 17 00:00:00 2001 From: ipu Date: Thu, 2 Oct 2025 16:46:16 +0300 Subject: [PATCH 01/10] fix alia greeting --- src/services/chat_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/chat_service.py b/src/services/chat_service.py index e563ca3..9f636ae 100644 --- a/src/services/chat_service.py +++ b/src/services/chat_service.py @@ -191,7 +191,8 @@ class ChatService: "answer": INIT_MESSAGES[0], } - last_message = self.get_last_chat_message_date(session_id) + last_message = await self.get_last_chat_message_date(session_id) + print(f"{uid}; {session_id}; {last_message}") if not last_message: return { "session_id": session_id, From 0e33063c99d36eca2baa1b53c87b3907ebbf4eab Mon Sep 17 00:00:00 2001 From: ipu Date: Thu, 2 Oct 2025 20:04:27 +0300 Subject: [PATCH 02/10] add isFirstVisit --- src/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models.py b/src/models.py index d3e8089..b49bc92 100644 --- a/src/models.py +++ b/src/models.py @@ -94,6 +94,7 @@ class InsuranceChatContext(BaseModel): application: dict | None = None applicationDTO: str | None = None name: UserNameContext | None = None + isFirstVisit: bool = True class InsuranceChatRequest(BaseModel): userId: str | int | None = None From 41fd8e3d1504332e4584942d48bc37f97fece8cf Mon Sep 17 00:00:00 2001 From: ipu Date: Thu, 2 Oct 2025 21:13:14 +0300 Subject: [PATCH 03/10] first_visit logic --- src/api/v1/router.py | 5 ++++- src/services/chat_service.py | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/v1/router.py b/src/api/v1/router.py index e145e9c..c0f96c2 100644 --- a/src/api/v1/router.py +++ b/src/api/v1/router.py @@ -57,8 +57,11 @@ async def init_chat(request: models.InitializeChatRequest): name = None if request.context and request.context.name: name = request.context.name.first_name + first_visit = True + if request.context: + first_visit = request.context.isFirstVisit - result = await chat_service.initialize_chat(str(request.userId), application, name) + result = await chat_service.initialize_chat(str(request.userId), application, name, first_visit) return models.InitializeChatResponse( session_id=result["session_id"], answer=result["answer"], diff --git a/src/services/chat_service.py b/src/services/chat_service.py index 9f636ae..7bfa83d 100644 --- a/src/services/chat_service.py +++ b/src/services/chat_service.py @@ -173,7 +173,7 @@ class ChatService: session.add(user_session) session.commit() - async def initialize_chat(self, uid: str, application, name): + async def initialize_chat(self, uid: str, application, name, first_visit): session_id = await self.get_user_session(uid) if not session_id or not await session_service.validate_session(session_id): session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) @@ -191,9 +191,7 @@ class ChatService: "answer": INIT_MESSAGES[0], } - last_message = await self.get_last_chat_message_date(session_id) - print(f"{uid}; {session_id}; {last_message}") - if not last_message: + if first_visit: return { "session_id": session_id, "answer": INIT_MESSAGES[0], From dd1b79f7e760a60635ff5cda7c101f7a5799ad66 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 3 Oct 2025 20:26:17 +0300 Subject: [PATCH 04/10] add show_page hook --- ...5_10_03_1608-4324550d9c83_add_user_page.py | 36 +++++++ src/api/v1/router.py | 8 +- src/database.py | 1 + src/models.py | 5 +- src/services/chat_service.py | 102 +++++++++++------- 5 files changed, 113 insertions(+), 39 deletions(-) create mode 100644 alembic/versions/2025_10_03_1608-4324550d9c83_add_user_page.py diff --git a/alembic/versions/2025_10_03_1608-4324550d9c83_add_user_page.py b/alembic/versions/2025_10_03_1608-4324550d9c83_add_user_page.py new file mode 100644 index 0000000..2f2ca3d --- /dev/null +++ b/alembic/versions/2025_10_03_1608-4324550d9c83_add_user_page.py @@ -0,0 +1,36 @@ +"""add user page + +Revision ID: 4324550d9c83 +Revises: 31359fcda8a7 +Create Date: 2025-10-03 16:08:13.898990 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '4324550d9c83' +down_revision: Union[str, Sequence[str], None] = '31359fcda8a7' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Upgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user_session', schema=None) as batch_op: + batch_op.add_column(sa.Column('page_id', sa.String(), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user_session', schema=None) as batch_op: + batch_op.drop_column('page_id') + + # ### end Alembic commands ### diff --git a/src/api/v1/router.py b/src/api/v1/router.py index c0f96c2..646442c 100644 --- a/src/api/v1/router.py +++ b/src/api/v1/router.py @@ -16,6 +16,7 @@ async def insurance_chat(request: models.InsuranceChatRequest): """Handle insurance chat requests""" try: current_page = None + page_id = None if request.context and request.context.page: page_id = str(request.context.page).lower() current_page = await get_page_description(page_id) @@ -32,6 +33,7 @@ async def insurance_chat(request: models.InsuranceChatRequest): uid=str(request.userId) if request.userId else None, current_page=current_page, application=application, + page_id=page_id ) return models.InsuranceChatResponse( @@ -61,7 +63,11 @@ async def init_chat(request: models.InitializeChatRequest): if request.context: first_visit = request.context.isFirstVisit - result = await chat_service.initialize_chat(str(request.userId), application, name, first_visit) + page_id = None + if request.context and request.context.page: + page_id = str(request.context.page).lower() + + result = await chat_service.initialize_chat(str(request.userId), application, name, first_visit, page_id) return models.InitializeChatResponse( session_id=result["session_id"], answer=result["answer"], diff --git a/src/database.py b/src/database.py index 8cbb5f1..0b6e9ef 100644 --- a/src/database.py +++ b/src/database.py @@ -40,6 +40,7 @@ class UserSession(Base): id = Column(BigInteger, primary_key=True, index=True) user_id = Column(String, index=True) session_id = Column(String) + page_id = Column(String, default=None, nullable=True) engine = create_engine(settings.DATABASE_URL) diff --git a/src/models.py b/src/models.py index b49bc92..c0ee547 100644 --- a/src/models.py +++ b/src/models.py @@ -125,9 +125,12 @@ class PlansParam(BaseModel): class ApplicantParam(BaseModel): applicants: list[Applicant] +class PageParam(BaseModel): + page: str + class ChatHook(BaseModel): tool: str - params: PlansParam | ApplicantParam + params: PlansParam | ApplicantParam | PageParam class AIChatResponse(BaseModel): answer: str diff --git a/src/services/chat_service.py b/src/services/chat_service.py index 7bfa83d..3585217 100644 --- a/src/services/chat_service.py +++ b/src/services/chat_service.py @@ -4,7 +4,7 @@ from typing import Dict, Any, List, Optional import httpx -from src.models import ApplicantParam, ChatHook, PlansParam +from src.models import ApplicantParam, ChatHook, PlansParam, PageParam from .session_service import session_service from ..api.v1.models import Source, HistoryItem from ..config import settings @@ -86,7 +86,16 @@ class ChatService: "chat_session_id": session_id, "message": f"I'm sorry, I'm experiencing technical difficulties. Please try again later. Error: {str(e)}" } - + + async def add_message_to_history(self, session_id: str, message: list): + async with await self.get_client() as client: + response = await client.post( + "/messages/", + params={"chat_session_id": session_id,}, + json={"content": message} + ) + return response.json() + async def get_chat_history(self, session_id: str) -> List[HistoryItem]: """Get chat history for a session and format it properly""" async with await self.get_client() as client: @@ -145,7 +154,6 @@ class ChatService: return None - def _extract_sources_from_response(self, response_text: str) -> List[Source]: """Extract sources from RAG search results if available""" # This is a placeholder - in a real implementation, you would: @@ -159,10 +167,10 @@ class ChatService: async def get_user_session(self, uid: str) -> str | None: with Session() as session: - session = session.query(UserSession).filter(UserSession.user_id == uid).first() - if not session: + user_session = session.query(UserSession).filter(UserSession.user_id == uid).first() + if not user_session: return None - return session.session_id + return user_session.session_id async def create_user_session(self, uid: str, session_id: str): with Session() as session: @@ -173,50 +181,62 @@ class ChatService: session.add(user_session) session.commit() - async def initialize_chat(self, uid: str, application, name, first_visit): - session_id = await self.get_user_session(uid) - if not session_id or not await session_service.validate_session(session_id): - session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) - try: - await self.create_user_session(uid, session_id) - except: - pass + async def update_user_page(self, uid: str, page_id: str | None): + with Session() as session: + user_session = session.query(UserSession).filter(UserSession.user_id == uid).first() + old_page_id = user_session.page_id + user_session.page_id = page_id + session.add(user_session) + session.commit() + return old_page_id + def get_welcome_message(self, application, name, first_visit): try: if not name: name = application["applicants"][0]["firstName"] except: - return { - "session_id": session_id, - "answer": INIT_MESSAGES[0], - } + return INIT_MESSAGES[0] if first_visit: - return { - "session_id": session_id, - "answer": INIT_MESSAGES[0], - } + return INIT_MESSAGES[0] try: applicant = application["applicants"][0] except: - return { - "session_id": session_id, - "answer": INIT_MESSAGES[2].format(name=name) - } + return INIT_MESSAGES[2].format(name=name) + if not applicant.get("gender") or not applicant.get("dob") or applicant.get("dob") == "-01-" or not applicant.get("weight") or applicant.get("heightFt") is None or applicant.get("heightIn") is None: - return { - "session_id": session_id, - "answer": INIT_MESSAGES[2].format(name=name) - } + return INIT_MESSAGES[2].format(name=name) + + return INIT_MESSAGES[1].format(name=name) + + + async def initialize_chat(self, uid: str, application, name, first_visit, page_id): + session_id = await self.get_user_session(uid) + if not session_id or not await session_service.validate_session(session_id): + session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) + try: + await self.create_user_session(uid, session_id) + except: + pass + await self.update_user_page(uid, page_id) + + welcome_msg = self.get_welcome_message(application, name, first_visit) + + msg_history_item = [ + {'parts': [{'content': 'Hi', 'part_kind': 'user-prompt'}],'kind': 'request'}, + {'parts': [{'content': welcome_msg, 'part_kind': 'text'}], 'kind': 'response'} + ] + + await self.add_message_to_history(session_id, msg_history_item) return { "session_id": session_id, - "answer": INIT_MESSAGES[1].format(name=name) + "answer": welcome_msg } - async def process_insurance_chat(self, message: str, session_id: Optional[str] = None, uid: Optional[str] = None, current_page: Optional[str] = None, application: Optional[dict] = None) -> Dict[str, Any]: + async def process_insurance_chat(self, message: str, session_id: Optional[str] = None, uid: Optional[str] = None, current_page: Optional[str] = None, application: Optional[dict] = None, page_id = None) -> Dict[str, Any]: """Process an insurance chat request""" try: if not session_id or not await session_service.validate_session(session_id): @@ -224,13 +244,14 @@ class ChatService: session_id = await self.get_user_session(uid) if not session_id or not await session_service.validate_session(session_id): session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) - try: - await self.create_user_session(uid, session_id) - except: - pass + try: + await self.create_user_session(uid, session_id) + except: + pass else: session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) + old_page_id = await self.update_user_page(uid, page_id) instructions = "" if uid: @@ -265,6 +286,7 @@ class ChatService: compare_plans = ai_response.get("compare_plans") show_plans = ai_response.get("show_plans") update_applicants = ai_response.get("update_applicants") + show_page = ai_response.get("show_page") hooks = [] if update_applicants: hooks.append(ChatHook( @@ -283,7 +305,13 @@ class ChatService: tool="show_plans", params=PlansParam(plans=show_plans) )) - + elif show_page and old_page_id: + hooks.append(ChatHook( + tool="show_page", + params=PageParam(page=old_page_id) + )) + + return { "session_id": session_id, "answer": ai_message, From 9b1a6340e84010b1585ef668fb52d2060e879829 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 3 Oct 2025 22:13:01 +0300 Subject: [PATCH 05/10] do not save page on /initialize --- src/services/chat_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/chat_service.py b/src/services/chat_service.py index 3585217..7ef7d0d 100644 --- a/src/services/chat_service.py +++ b/src/services/chat_service.py @@ -219,7 +219,7 @@ class ChatService: await self.create_user_session(uid, session_id) except: pass - await self.update_user_page(uid, page_id) + # await self.update_user_page(uid, page_id) welcome_msg = self.get_welcome_message(application, name, first_visit) From 13d9a76bedcd03965b54b6f39d5500c74015ef45 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 3 Oct 2025 22:53:17 +0300 Subject: [PATCH 06/10] new estimation data model --- src/api/v1/router.py | 2 +- src/models.py | 6 ++++-- src/services/estimation_service_v2.py | 14 ++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/api/v1/router.py b/src/api/v1/router.py index 646442c..81537c0 100644 --- a/src/api/v1/router.py +++ b/src/api/v1/router.py @@ -85,7 +85,7 @@ async def estimate(request: models.EstimationRequest): ) estimation_service = EstimationService() - estimation_response = await estimation_service.estimate_insurance(request.applicants, request.phq, request.plans) + estimation_response = await estimation_service.estimate_insurance(request.applicants, request.phq, request.plans, request.coverage) return estimation_response diff --git a/src/models.py b/src/models.py index c0ee547..7cff934 100644 --- a/src/models.py +++ b/src/models.py @@ -17,7 +17,7 @@ class Applicant(BaseModel): class Plan(BaseModel): id: int - priceId: int + priceId: int | None = None class Medication(BaseModel): applicant: int @@ -60,6 +60,7 @@ class Address(BaseModel): class EstimationRequest(BaseModel): userId: str | int | None = Field(None, description="Unique identifier") + coverage: int = 1 applicants: List[Applicant] plans: List[Plan] phq: PHQ @@ -69,7 +70,8 @@ class EstimationRequest(BaseModel): class EstimationDetails(BaseModel): dtq: bool reason: str - price_id: int + price_id: int = -1 + tier: str class EstimationResult(BaseModel): name: str diff --git a/src/services/estimation_service_v2.py b/src/services/estimation_service_v2.py index 553c85f..2f7da6c 100644 --- a/src/services/estimation_service_v2.py +++ b/src/services/estimation_service_v2.py @@ -458,7 +458,7 @@ class EstimationService: return None - async def estimate_insurance(self, applicants: list[Applicant], phq: PHQ, plans: list[Plan]): + async def estimate_insurance(self, applicants: list[Applicant], phq: PHQ, plans: list[Plan], plan_coverage: int): estimation_results = [] is_review = False review_reasons = [] @@ -478,7 +478,9 @@ class EstimationService: base_tier = tier break - plan_coverage = self.get_plan_coverage(plans[0]) + if not plan_coverage: + plan_coverage = self.get_plan_coverage(plans[0]) + rx_spend = 0 for applicant_id, applicant in enumerate(applicants): applicant_review_reasons = [] @@ -559,7 +561,7 @@ class EstimationService: message=final_reason, ) ) - + plan_price_id = self.get_plan_price(plans[0], base_tier, plan_coverage) if is_dtq: @@ -570,6 +572,7 @@ class EstimationService: dtq=is_dtq, reason=reason, price_id=plan_price_id, + tier=f"Tier {base_tier.value}", ), results=estimation_results ) @@ -582,6 +585,7 @@ class EstimationService: dtq=is_dtq, reason=reason, price_id=plan_price_id, + tier=f"Tier {base_tier.value}", ), results=estimation_results ) @@ -597,6 +601,7 @@ class EstimationService: dtq=True, reason=reason, price_id=plan_price_id, + tier=f"Tier {base_tier.value}", ), results=estimation_results ) @@ -614,6 +619,7 @@ class EstimationService: dtq=is_dtq, reason=reason, price_id=plan_price_id, + tier=f"Tier {base_tier.value}", ), results=estimation_results ) @@ -625,7 +631,7 @@ class EstimationService: dtq=is_dtq, reason=reason, price_id=plan_price_id, + tier=f"Tier {base_tier.value}", ), results=estimation_results ) - \ No newline at end of file From 25f091d02c68b4575d64f5a3178fb3d09da74f82 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 3 Oct 2025 23:03:06 +0300 Subject: [PATCH 07/10] new estimation data model --- src/models.py | 4 ++-- src/services/estimation_service_v2.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/models.py b/src/models.py index 7cff934..71037d0 100644 --- a/src/models.py +++ b/src/models.py @@ -70,7 +70,7 @@ class EstimationRequest(BaseModel): class EstimationDetails(BaseModel): dtq: bool reason: str - price_id: int = -1 + # price_id: int = -1 tier: str class EstimationResult(BaseModel): @@ -85,7 +85,7 @@ class EstimationResult(BaseModel): class EstimationResponse(BaseModel): status: str details: EstimationDetails - results: List[EstimationResult] + # results: List[EstimationResult] class UserNameContext(BaseModel): first_name: str diff --git a/src/services/estimation_service_v2.py b/src/services/estimation_service_v2.py index 2f7da6c..a5cecee 100644 --- a/src/services/estimation_service_v2.py +++ b/src/services/estimation_service_v2.py @@ -571,10 +571,10 @@ class EstimationService: details=EstimationDetails( dtq=is_dtq, reason=reason, - price_id=plan_price_id, + # price_id=plan_price_id, tier=f"Tier {base_tier.value}", ), - results=estimation_results + # results=estimation_results ) if is_review: @@ -584,10 +584,10 @@ class EstimationService: details=EstimationDetails( dtq=is_dtq, reason=reason, - price_id=plan_price_id, + # price_id=plan_price_id, tier=f"Tier {base_tier.value}", ), - results=estimation_results + # results=estimation_results ) new_tier, tier_reason = self.get_tier(plan_coverage, rx_spend) @@ -600,10 +600,10 @@ class EstimationService: details=EstimationDetails( dtq=True, reason=reason, - price_id=plan_price_id, + # price_id=plan_price_id, tier=f"Tier {base_tier.value}", ), - results=estimation_results + # results=estimation_results ) if new_tier > base_tier: @@ -618,10 +618,10 @@ class EstimationService: details=EstimationDetails( dtq=is_dtq, reason=reason, - price_id=plan_price_id, + # price_id=plan_price_id, tier=f"Tier {base_tier.value}", ), - results=estimation_results + # results=estimation_results ) else: reason = "\n".join(dtq_reasons) @@ -630,8 +630,8 @@ class EstimationService: details=EstimationDetails( dtq=is_dtq, reason=reason, - price_id=plan_price_id, + # price_id=plan_price_id, tier=f"Tier {base_tier.value}", ), - results=estimation_results + # results=estimation_results ) From f873b7e710084954139874c7f4341d94c1a136f2 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 3 Oct 2025 23:09:35 +0300 Subject: [PATCH 08/10] debug estimation request --- src/api/v1/router.py | 8 ++++++-- src/models.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api/v1/router.py b/src/api/v1/router.py index 81537c0..8aa867b 100644 --- a/src/api/v1/router.py +++ b/src/api/v1/router.py @@ -78,12 +78,16 @@ async def init_chat(request: models.InitializeChatRequest): async def estimate(request: models.EstimationRequest): """Handle insurance estimation requests""" try: - if not request.applicants or not request.plans: + if not request.applicants: raise HTTPException( status_code=400, detail="Missing required applicants or plans" ) - + + print("estimation request: ", request) + if not request.plans: + request.plans = list() + estimation_service = EstimationService() estimation_response = await estimation_service.estimate_insurance(request.applicants, request.phq, request.plans, request.coverage) diff --git a/src/models.py b/src/models.py index 71037d0..d8bfe05 100644 --- a/src/models.py +++ b/src/models.py @@ -62,7 +62,7 @@ class EstimationRequest(BaseModel): userId: str | int | None = Field(None, description="Unique identifier") coverage: int = 1 applicants: List[Applicant] - plans: List[Plan] + plans: List[Plan] | None = None phq: PHQ income: float address: Address From 7178369f4775320670ed4bf71f3cd11ea2f96eb1 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 10 Oct 2025 09:59:26 +0300 Subject: [PATCH 09/10] remove welcome page from storage --- src/services/chat_service.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/chat_service.py b/src/services/chat_service.py index 7ef7d0d..7d83e16 100644 --- a/src/services/chat_service.py +++ b/src/services/chat_service.py @@ -190,6 +190,12 @@ class ChatService: session.commit() return old_page_id + async def get_user_page(self, uid: str): + with Session() as session: + user_session = session.query(UserSession).filter(UserSession.user_id == uid).first() + old_page_id = user_session.page_id + return old_page_id + def get_welcome_message(self, application, name, first_visit): try: if not name: @@ -251,7 +257,10 @@ class ChatService: else: session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID) - old_page_id = await self.update_user_page(uid, page_id) + if page_id.lower() != 'welcome': + old_page_id = await self.update_user_page(uid, page_id) + else: + old_page_id = await self.get_user_page(uid) instructions = "" if uid: From c3135e1549efdcdf70a0b56764ceb9746f6fd1b1 Mon Sep 17 00:00:00 2001 From: ipu Date: Fri, 10 Oct 2025 09:59:41 +0300 Subject: [PATCH 10/10] new flow; remove plans from request --- src/api/v1/router.py | 24 +++++++++++++++++++++--- src/models.py | 2 -- src/services/estimation_service_v2.py | 9 +++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/api/v1/router.py b/src/api/v1/router.py index 8aa867b..09c1122 100644 --- a/src/api/v1/router.py +++ b/src/api/v1/router.py @@ -85,11 +85,29 @@ async def estimate(request: models.EstimationRequest): ) print("estimation request: ", request) - if not request.plans: - request.plans = list() + + has_primary = False + has_spouse = False + has_dependents = False + for applicant in request.applicants: + if applicant.applicant == 1: + has_primary = True + elif applicant.applicant == 2: + has_spouse = True + elif applicant.applicant == 3: + has_dependents = True + + if has_primary and not has_spouse and not has_dependents: + coverage = 1 + elif has_primary and has_spouse and not has_dependents: + coverage = 2 + elif has_primary and not has_spouse and has_dependents: + coverage = 3 + else: + coverage = 4 estimation_service = EstimationService() - estimation_response = await estimation_service.estimate_insurance(request.applicants, request.phq, request.plans, request.coverage) + estimation_response = await estimation_service.estimate_insurance(request.applicants, request.phq, coverage) return estimation_response diff --git a/src/models.py b/src/models.py index d8bfe05..3f56a35 100644 --- a/src/models.py +++ b/src/models.py @@ -60,9 +60,7 @@ class Address(BaseModel): class EstimationRequest(BaseModel): userId: str | int | None = Field(None, description="Unique identifier") - coverage: int = 1 applicants: List[Applicant] - plans: List[Plan] | None = None phq: PHQ income: float address: Address diff --git a/src/services/estimation_service_v2.py b/src/services/estimation_service_v2.py index a5cecee..a9f3552 100644 --- a/src/services/estimation_service_v2.py +++ b/src/services/estimation_service_v2.py @@ -458,7 +458,7 @@ class EstimationService: return None - async def estimate_insurance(self, applicants: list[Applicant], phq: PHQ, plans: list[Plan], plan_coverage: int): + async def estimate_insurance(self, applicants: list[Applicant], phq: PHQ, plan_coverage: int): estimation_results = [] is_review = False review_reasons = [] @@ -478,9 +478,6 @@ class EstimationService: base_tier = tier break - if not plan_coverage: - plan_coverage = self.get_plan_coverage(plans[0]) - rx_spend = 0 for applicant_id, applicant in enumerate(applicants): applicant_review_reasons = [] @@ -562,7 +559,7 @@ class EstimationService: ) ) - plan_price_id = self.get_plan_price(plans[0], base_tier, plan_coverage) + # plan_price_id = self.get_plan_price(plans[0], base_tier, plan_coverage) if is_dtq: reason = "\n".join(dtq_reasons) @@ -609,7 +606,7 @@ class EstimationService: if new_tier > base_tier: base_tier = new_tier - plan_price_id = self.get_plan_price(plans[0], base_tier, plan_coverage) + # plan_price_id = self.get_plan_price(plans[0], base_tier, plan_coverage) if base_tier is not None: reason = "\n".join(accept_reasons)