new estimation data model
This commit is contained in:
parent
9b1a6340e8
commit
13d9a76bed
3 changed files with 15 additions and 7 deletions
|
|
@ -85,7 +85,7 @@ async def estimate(request: models.EstimationRequest):
|
||||||
)
|
)
|
||||||
|
|
||||||
estimation_service = EstimationService()
|
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
|
return estimation_response
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Applicant(BaseModel):
|
||||||
|
|
||||||
class Plan(BaseModel):
|
class Plan(BaseModel):
|
||||||
id: int
|
id: int
|
||||||
priceId: int
|
priceId: int | None = None
|
||||||
|
|
||||||
class Medication(BaseModel):
|
class Medication(BaseModel):
|
||||||
applicant: int
|
applicant: int
|
||||||
|
|
@ -60,6 +60,7 @@ class Address(BaseModel):
|
||||||
|
|
||||||
class EstimationRequest(BaseModel):
|
class EstimationRequest(BaseModel):
|
||||||
userId: str | int | None = Field(None, description="Unique identifier")
|
userId: str | int | None = Field(None, description="Unique identifier")
|
||||||
|
coverage: int = 1
|
||||||
applicants: List[Applicant]
|
applicants: List[Applicant]
|
||||||
plans: List[Plan]
|
plans: List[Plan]
|
||||||
phq: PHQ
|
phq: PHQ
|
||||||
|
|
@ -69,7 +70,8 @@ class EstimationRequest(BaseModel):
|
||||||
class EstimationDetails(BaseModel):
|
class EstimationDetails(BaseModel):
|
||||||
dtq: bool
|
dtq: bool
|
||||||
reason: str
|
reason: str
|
||||||
price_id: int
|
price_id: int = -1
|
||||||
|
tier: str
|
||||||
|
|
||||||
class EstimationResult(BaseModel):
|
class EstimationResult(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
|
|
|
||||||
|
|
@ -458,7 +458,7 @@ class EstimationService:
|
||||||
return None
|
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 = []
|
estimation_results = []
|
||||||
is_review = False
|
is_review = False
|
||||||
review_reasons = []
|
review_reasons = []
|
||||||
|
|
@ -478,7 +478,9 @@ class EstimationService:
|
||||||
base_tier = tier
|
base_tier = tier
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not plan_coverage:
|
||||||
plan_coverage = self.get_plan_coverage(plans[0])
|
plan_coverage = self.get_plan_coverage(plans[0])
|
||||||
|
|
||||||
rx_spend = 0
|
rx_spend = 0
|
||||||
for applicant_id, applicant in enumerate(applicants):
|
for applicant_id, applicant in enumerate(applicants):
|
||||||
applicant_review_reasons = []
|
applicant_review_reasons = []
|
||||||
|
|
@ -570,6 +572,7 @@ class EstimationService:
|
||||||
dtq=is_dtq,
|
dtq=is_dtq,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
price_id=plan_price_id,
|
price_id=plan_price_id,
|
||||||
|
tier=f"Tier {base_tier.value}",
|
||||||
),
|
),
|
||||||
results=estimation_results
|
results=estimation_results
|
||||||
)
|
)
|
||||||
|
|
@ -582,6 +585,7 @@ class EstimationService:
|
||||||
dtq=is_dtq,
|
dtq=is_dtq,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
price_id=plan_price_id,
|
price_id=plan_price_id,
|
||||||
|
tier=f"Tier {base_tier.value}",
|
||||||
),
|
),
|
||||||
results=estimation_results
|
results=estimation_results
|
||||||
)
|
)
|
||||||
|
|
@ -597,6 +601,7 @@ class EstimationService:
|
||||||
dtq=True,
|
dtq=True,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
price_id=plan_price_id,
|
price_id=plan_price_id,
|
||||||
|
tier=f"Tier {base_tier.value}",
|
||||||
),
|
),
|
||||||
results=estimation_results
|
results=estimation_results
|
||||||
)
|
)
|
||||||
|
|
@ -614,6 +619,7 @@ class EstimationService:
|
||||||
dtq=is_dtq,
|
dtq=is_dtq,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
price_id=plan_price_id,
|
price_id=plan_price_id,
|
||||||
|
tier=f"Tier {base_tier.value}",
|
||||||
),
|
),
|
||||||
results=estimation_results
|
results=estimation_results
|
||||||
)
|
)
|
||||||
|
|
@ -625,7 +631,7 @@ class EstimationService:
|
||||||
dtq=is_dtq,
|
dtq=is_dtq,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
price_id=plan_price_id,
|
price_id=plan_price_id,
|
||||||
|
tier=f"Tier {base_tier.value}",
|
||||||
),
|
),
|
||||||
results=estimation_results
|
results=estimation_results
|
||||||
)
|
)
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue