Api reference
components.insurance_plan_catalog.public.api ¶
InsurancePlanApi ¶
Bases: CorePlanApi
Implements the CorePlan API for InsurancePlan.
can_plans_be_contractualized_together ¶
Source code in components/insurance_plan_catalog/public/api.py
get_plan ¶
Source code in components/insurance_plan_catalog/public/api.py
get_pricing_functions_for_modules ¶
Source code in components/insurance_plan_catalog/public/api.py
list_plans ¶
Source code in components/insurance_plan_catalog/public/api.py
search_plans ¶
Search plans matching provided filters
Source code in components/insurance_plan_catalog/public/api.py
get_coverage_for_module ¶
Return the coverage associated with the provided module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_id
|
UUID
|
The identifier of the target module. |
required |
Returns:
| Type | Description |
|---|---|
InsuranceCoveragePresenter
|
The coverage presenter for this module. |
Raises:
| Type | Description |
|---|---|
missing_resource
|
If module not found. |
Source code in components/insurance_plan_catalog/public/api.py
get_full_plan ¶
Returns comprehensive plan details including all coverages and price rules. Typical use cases: generate a contract/legal docs from the plan, shows the plan details to a company admin
Request-cached (GET only, RAM, 30s): plans are immutable catalog entries, so within a request the full aggregate is loaded once per plan_id. Collapses a per-member N+1 (~16 plan-catalog table reads per member) on the customer dashboard employee list / count, which read the plan through the ES legacy enrollment projection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan_id
|
UUID
|
UUID of the insurance plan |
required |
Returns: Detailed plan.
Raises:
| Type | Description |
|---|---|
missing_resource
|
If plan not found. |
Source code in components/insurance_plan_catalog/public/api.py
get_modules ¶
Returns detailed modules information. Typical use case: shows details (eg coverage table) of the modules a member is enrolled to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modules_ids
|
set[UUID]
|
Identifiers of the modules to retrieve |
required |
Returns:
| Type | Description |
|---|---|
list[InsurancePlanModulePresenter]
|
List of detailed modules |
Raises:
| Type | Description |
|---|---|
missing_resource
|
If one of the module is not found or if not all modules belong to the same plan. |
Source code in components/insurance_plan_catalog/public/api.py
get_plan_id_from_legacy_source_ref ¶
Return the InsurancePlan.id previously persisted for this legacy
source ref, or None if no mapping row exists yet.
Source code in components/insurance_plan_catalog/public/api.py
get_plan_summary ¶
Returns summary of a plan. Typical use case: display plan identifier (name, bundle code, etc.), eg in a link allowing to get details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan_id
|
UUID
|
UUID of the insurance plan |
required |
Returns: summary of the plan.
Raises:
| Type | Description |
|---|---|
missing_resource
|
If plan not found. |
Source code in components/insurance_plan_catalog/public/api.py
get_pricing_functions_for_plan ¶
Pricing function for every module of a plan, cached process-wide.
InsurancePlan is immutable (InsurancePlanRepository.update raises; an
edit mints a new plan with fresh ids via duplicated_from_insurance_plan_id),
so a plan's pricing functions never change — the cache needs no invalidation.
Caching here collapses the per-member re-resolution of the same company plan
in batch jobs (ES salary-in-kind priced the whole plan-catalog cascade once
per user, timing out on large companies). Local-RAM only: immutability makes
per-process duplication harmless and avoids serializing ModulePricingFunction
(recursive, protocol-typed).
Source code in components/insurance_plan_catalog/public/api.py
persist_plan_from_legacy_source ¶
Materialize an InsurancePlan from a legacy source into the catalog and record the legacy-ref ↔ plan-id mapping.
Used by dual-write hooks (e.g., ES proposal signature) so consumers can later fetch the persisted plan via the catalog public API.
Relies on InsurancePlanRepository.get() falling back to the local converter (e.g., EsHealthInsurancePlanRepository) when the plan is not yet persisted.
Best-effort: failures are logged with legacy_source for filtering and not re-raised,
so callers don't need to wrap this in a try/except.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
legacy_plan_source_ref
|
str
|
legacy id of the plan (e.g., ES health contract version id). Stored as a string to support legacy sources with non-UUID identifiers. |
required |
legacy_source
|
str | None
|
Optional name of the legacy source (e.g., 'ES contract subscription'). |
None
|
Source code in components/insurance_plan_catalog/public/api.py
components.insurance_plan_catalog.public.builder_translation ¶
builder_coverage_rules_to_coverage_rules ¶
Translate a list of offer_builder BuilderCoverageRule to a list of insurance_plan_catalog CoverageRule.
Note: This is a temporary method owned by @crew-global-claims-experience. It only exists to have the same exact data format as when the core-stack will be live. DO NOT USE THIS METHOD IN ANY OTHER PART OF THE CODE BASE.
Source code in components/insurance_plan_catalog/public/builder_translation.py
get_builder_product_mapping ¶
Return the BuilderProductMapping for a BuilderProduct, or None if no mapping exists.
By default returns the most recent mapping for builder_product_id. Pass
builder_product_version_id to look up the mapping for a specific version.
Source code in components/insurance_plan_catalog/public/builder_translation.py
insurance_plan_to_builder_product_stateless ¶
Translate a plan (frozen or draft) to an unpersisted BuilderProduct without mutating state.
When mapping is provided, mapping-only BuilderProduct fields are
populated from it, and mapping.is_frozen discriminates between the
InsurancePlan and DraftInsurancePlan repositories.
Source code in components/insurance_plan_catalog/public/builder_translation.py
components.insurance_plan_catalog.public.entities ¶
coverage_rule ¶
AggregatedLimitParameter
module-attribute
¶
BundleChoiceParameter
dataclass
¶
Bases: CoverageRuleParameter
A bundle choice parameter and its associated value
to_guarantee_catalog_parameter ¶
Convert to the guarantee_catalog instantiated bundle-choice parameter.
Source code in components/insurance_plan_catalog/public/entities/coverage_rule.py
CategoryParameter
dataclass
¶
Bases: CoverageRuleParameter
A category parameter and its associated value
to_guarantee_catalog_parameter ¶
Convert to the guarantee_catalog instantiated category parameter.
Source code in components/insurance_plan_catalog/public/entities/coverage_rule.py
CoverageRule
dataclass
¶
CoverageRule(
*,
id,
guarantee_ref,
bundle_choice_ref,
expression_type,
parameters,
eligibility_items_refs,
metadata=None
)
Bases: DataClassJsonMixin
A coverage rule with associated parameters, eligibility items and cost estimates
to_guarantee_catalog_coverage_rule ¶
Convert the CoverageRule instance to a GuaranteeCatalogCoverageRule
Source code in components/insurance_plan_catalog/public/entities/coverage_rule.py
CoverageRuleParameter
dataclass
¶
PropagatedParameter
module-attribute
¶
errors ¶
PricingFunctionError ¶
Bases: BaseErrorCode
Error class for pricing function failures.
Initialize a pricing function error with type and description.
Source code in components/insurance_plan_catalog/public/entities/errors.py
ambiguous_price_rule
classmethod
¶
Create error when multiple price rules match.
Source code in components/insurance_plan_catalog/public/entities/errors.py
invalid_input_format
classmethod
¶
Create error for invalid input format.
Source code in components/insurance_plan_catalog/public/entities/errors.py
missing_input
classmethod
¶
Create error for missing required input.
Source code in components/insurance_plan_catalog/public/entities/errors.py
no_matching_price_rule
classmethod
¶
Create error when no price rule matches.
Source code in components/insurance_plan_catalog/public/entities/errors.py
insurance_coverage ¶
InsuranceCoverageCustomDataPresenter
dataclass
¶
Bases: ABC, Coercible['InsuranceCoverageCustomDataPresenter']
Additional data depending on the product type.
from_custom_entity
abstractmethod
staticmethod
¶
Method of subclass implementing the actual conversion
Source code in components/insurance_plan_catalog/public/entities/insurance_coverage.py
from_entity
staticmethod
¶
Convert internal insurance coverage custom data entity to presenter using context.
This method uses the insurance_plan_catalog_context to determine which product-specific presenter class to use for conversion.
Returns:
| Type | Description |
|---|---|
InsuranceCoverageCustomDataPresenter | None
|
Product-specific custom data presenter or None if no custom data |
Source code in components/insurance_plan_catalog/public/entities/insurance_coverage.py
InsuranceCoveragePresenter
dataclass
¶
InsuranceCoveragePresenter(
*,
id,
service_type,
index,
selected_categories,
coverage_rules,
aggregated_limit_parameters,
custom_data
)
Coverage information containing coverage rules.
from_entity
staticmethod
¶
Convert internal insurance coverage entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_coverage.py
insurance_plan ¶
InsurancePlanCustomDataPresenter
dataclass
¶
Bases: ABC, Coercible['InsurancePlanCustomDataPresenter']
Additional data depending on the product type.
from_custom_entity
abstractmethod
staticmethod
¶
Method of subclass implementing the actual conversion
from_entity
staticmethod
¶
Convert internal insurance plan custom data entity to presenter using context.
This method uses the insurance_plan_catalog_context to determine which product-specific presenter class to use for conversion.
Returns:
| Type | Description |
|---|---|
InsurancePlanCustomDataPresenter | None
|
Product-specific custom data presenter or None if no custom data |
Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
InsurancePlanEligibilityPresenter
dataclass
¶
InsurancePlanEligibilityPresenter(
*,
id,
insurer_name,
country,
type,
business_id,
display_name,
modules,
module_constraints,
eligibility_function
)
Bases: CorePlan, InsurancePlanSummaryPresenter
Summary of a plan, eg to display identification information, without details.
from_entity
staticmethod
¶
Convert internal insurance plan entity to summary presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
InsurancePlanPresenter
dataclass
¶
InsurancePlanPresenter(
*,
id,
insurer_name,
country,
type,
business_id,
display_name,
modules,
module_constraints,
eligibility_function,
segment,
target_type,
targets,
price_segments,
coverages,
custom_data
)
Bases: InsurancePlanEligibilityPresenter
Comprehensive plan details - all information needed for legal docs, plan display, etc.
from_entity
staticmethod
¶
Convert internal insurance plan entity to full presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
InsurancePlanSummaryPresenter
dataclass
¶
Summary of a plan, eg to display identification information, without details.
from_entity
staticmethod
¶
Convert internal insurance plan entity to summary presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
insurance_plan_module ¶
InsurancePlanModuleEligibilityPresenter
dataclass
¶
InsurancePlanModuleEligibilityPresenter(
*,
id,
stable_plan_module_slug,
service_type,
eligibility_function,
eligibility_lost_fallback_module_ids
)
Bases: CorePlanModule
Pricing configuration for a (coverage, price_segment) pair.
from_entity
classmethod
¶
Convert internal insurance plan module entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan_module.py
InsurancePlanModulePresenter
dataclass
¶
InsurancePlanModulePresenter(
*,
id,
stable_plan_module_slug,
service_type,
eligibility_function,
eligibility_lost_fallback_module_ids,
coverage_id,
price_segment_id,
price_structure,
participation_rules,
price_rules,
migration_tags
)
Bases: InsurancePlanModuleEligibilityPresenter
Pricing configuration for a (coverage, price_segment) pair.
from_entity
classmethod
¶
Convert internal insurance plan module entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan_module.py
insurance_plan_target ¶
InsurancePlanTargetCustomDataPresenter
dataclass
¶
Bases: ABC, Coercible['InsurancePlanTargetCustomDataPresenter']
Additional data depending on the product type (of the plan) + target type.
from_custom_entity
abstractmethod
staticmethod
¶
Method of subclass implementing the actual conversion
Source code in components/insurance_plan_catalog/public/entities/insurance_plan_target.py
from_entity
staticmethod
¶
Convert internal insurance plan target custom data entity to presenter using context.
This method uses the insurance_plan_catalog_context to determine which product-specific presenter class to use for conversion.
Returns:
| Type | Description |
|---|---|
InsurancePlanTargetCustomDataPresenter | None
|
Product-specific custom data presenter or None if no custom data |
Source code in components/insurance_plan_catalog/public/entities/insurance_plan_target.py
InsurancePlanTargetPresenter
dataclass
¶
Detailed properties of an entity (eg company) for which the plan was created.
from_entity
staticmethod
¶
Convert internal plan target entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_plan_target.py
insurance_price_rule ¶
InsurancePriceComponentPresenter
dataclass
¶
InsurancePriceComponentPresenter(
*,
id,
component_type,
contribution_type,
payor,
payee,
price_absolute,
salary_rate,
salary_type,
min_price_absolute,
max_price_absolute,
equivalent_price_absolute,
tax_rate,
currency
)
Atomic piece of a price breakdown.
Remarks: - Taxes are modelled through the tax_rate field of each component, rather than in a separate component. - Absolue prices are expressed in currency minor unit (eg cents for euros)
from_entity
staticmethod
¶
Convert internal price component entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
InsurancePriceRuleCustomDataPresenter
dataclass
¶
Bases: ABC, Coercible['InsurancePriceRuleCustomDataPresenter']
Additional data depending on the product type.
from_custom_entity
abstractmethod
staticmethod
¶
Method of subclass implementing the actual conversion
Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
from_entity
staticmethod
¶
Convert internal insurance price rule custom data entity to presenter using context.
This method uses the insurance_plan_catalog_context to determine which product-specific presenter class to use for conversion.
Returns:
| Type | Description |
|---|---|
InsurancePriceRuleCustomDataPresenter | None
|
Product-specific custom data presenter or None if no custom data |
Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
InsurancePriceRulePresenter
dataclass
¶
Price breakdown for a given price structure component in a given module. The total price is computed by summing all its components.
from_entity
staticmethod
¶
Convert internal price rule entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
insurance_price_segment ¶
participation_rule ¶
ParticipationRulePresenter
dataclass
¶
ParticipationRulePresenter(
*,
id,
price_structure_component_id,
price_component_type,
participation_ratio,
participation_absolute,
max_participation_absolute
)
Rule defining the participation of an external payer (e.g. an employer for collective plans) for a given module and price structure component.
Remarks: - We don't support having different participation for a given component (eg if partner and children are priced in the same pack, the employer cannot contribute differently to this pack depending on the member it contains) - For now, this entity is only relevant for company plans for which an employer exists - it could be extended to support other types of external participations (eg funds) if needed
from_entity
staticmethod
¶
Convert internal participation rule entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/participation_rule.py
price_structure ¶
PriceStructureComponentPresenter
dataclass
¶
PriceStructureComponentPresenter(
*,
id,
coefficient,
membership_types,
member_min_age_in_months,
member_max_age_in_months,
member_min_rank_inclusive,
member_max_rank_inclusive,
member_min_status_tenure_in_months,
member_max_status_tenure_in_months
)
Individual component of a price structure, targeting a subset of members.
from_entity
staticmethod
¶
Convert internal price structure component entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/price_structure.py
PriceStructurePresenter
dataclass
¶
Defines how we distribute the total average policy price between members.
from_entity
staticmethod
¶
Convert internal price structure entity to presenter.
Source code in components/insurance_plan_catalog/public/entities/price_structure.py
components.insurance_plan_catalog.public.enums ¶
insurance_plan_target_type ¶
insurance_plan_type ¶
InsurancePlanType ¶
Bases: BasePlanType
Supported insurance product types.
ca_health_life_and_disability
class-attribute
instance-attribute
¶
get_dependency ¶
Return the catalog dependency implementation for this plan type.
Source code in components/insurance_plan_catalog/public/enums/insurance_plan_type.py
insurance_service_type ¶
InsuranceServiceType ¶
Bases: BaseServiceType
Base class for insurance coverage types.
Each product type will define a subclass of this enum with the supported values.
insurer_name ¶
InsurerName ¶
Bases: AlanBaseEnum
Base class for insurer names.
Each product type will define a subclass of this enum with the supported values.
price_structure_type ¶
PriceStructureType ¶
Bases: AlanBaseEnum
Base class for price structure types.
Each product type will define a subclass of this enum with the supported values.
infer_from_components
classmethod
¶
Infer price structure type from components. Product-specific subclasses should override.
Source code in components/insurance_plan_catalog/public/enums/price_structure_type.py
components.insurance_plan_catalog.public.product_custom_data ¶
ca_health_life_and_disability ¶
entities ¶
ca_health_life_and_disability_insurance_plan_custom_data_presenter ¶
CaHealthLifeAndDisabilityInsurancePlanCustomDataPresenter
dataclass
¶
Bases: InsurancePlanCustomDataPresenter
Plan-level custom data presenter for Canada health plans.
staticmethod
¶Source code in components/insurance_plan_catalog/public/product_custom_data/ca_health_life_and_disability/entities/ca_health_life_and_disability_insurance_plan_custom_data_presenter.py
enums ¶
ca_health_life_and_disability_insurance_service_type ¶
CaHealthLifeAndDisabilityInsuranceServiceType ¶
Bases: InsuranceServiceType
Canada health, life and disability insurance service types.
Maps the guarantee-catalog categories onto the distinct services offered: extended health care (hospitalization, medical services, mental health, paramedicals, drugs, out-of-province), dental, and vision. Life and disability are not modelled yet (no guarantees defined for them).
ca_health_life_and_disability_insurer_name ¶
CaHealthLifeAndDisabilityInsurerName ¶
ca_health_life_and_disability_payee ¶
es_health ¶
entities ¶
es_health_insurance_coverage_custom_data_presenter ¶
EsHealthInsuranceCoverageCustomDataPresenter
dataclass
¶
Bases: InsuranceCoverageCustomDataPresenter
Custom data for ES health coverages
staticmethod
¶Source code in components/insurance_plan_catalog/public/product_custom_data/es_health/entities/es_health_insurance_coverage_custom_data_presenter.py
es_health_insurance_plan_target_custom_data_presenter ¶
EsHealthInsurancePlanCompanyTargetCustomDataPresenter
dataclass
¶
Bases: InsurancePlanTargetCustomDataPresenter
Custom data for ES health plan targets.
staticmethod
¶Source code in components/insurance_plan_catalog/public/product_custom_data/es_health/entities/es_health_insurance_plan_target_custom_data_presenter.py
enums ¶
es_coverage_type ¶
es_health_insurance_service_type ¶
EsHealthInsuranceServiceType ¶
es_health_insurer_name ¶
EsHealthInsurerName ¶
es_health_payee ¶
es_health_payor ¶
es_health_price_component_type ¶
EsHealthPriceComponentType ¶
Bases: PriceComponentType
Spanish health insurance price component types.
Price components are identified by bundle type (one per catalog bundle): - core_product: core product bundle (health, access, essential + therapy_session, assistance) - optical / pharmacy / preexisting_conditions / premium_reimbursement / physio_nutrition: addon bundles
Spain applies a CCS (Consorcio de Compensación de Seguros) surcharge of 0.15% on insurance premiums to all components.
class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶property
¶Get the applicable tax rate for the price component type.
All ES price components have the same CCS tax rate.
es_health_price_structure_type ¶
EsHealthPriceStructureType ¶
Bases: PriceStructureType
Price structure types for Spain health
classmethod
¶Balanced if all coefficients are equal, tailored otherwise.
Source code in components/insurance_plan_catalog/public/product_custom_data/es_health/enums/es_health_price_structure_type.py
option_type_to_price_component ¶
Public mapping from Spanish health OptionType to the
EsHealthPriceComponentType carried by core_price PriceComponents.
Exposed publicly so cross-component consumers (notably the es core_stack
bridge) can group a PriceBreakdown's components per option type. The
mapping is many-to-one for products: ALAN_MANZANA / ALAN_OUTPATIENT
/ ALAN_FRESA all map to core_product — callers identify the actual
product from the contract module's option types, not from the breakdown.
OPTION_TYPE_TO_PRICE_COMPONENT_TYPE
module-attribute
¶
OPTION_TYPE_TO_PRICE_COMPONENT_TYPE = {
ALAN_MANZANA: core_product,
ALAN_OUTPATIENT: core_product,
ALAN_FRESA: core_product,
OPTICAL: optical,
PHARMACY: pharmacy,
PHYSIO_NUTRITION: physio_nutrition,
REIMBURSEMENTS: premium_reimbursement,
PRE_EXISTING_CONDITIONS: preexisting_conditions,
}
fr_health ¶
enums ¶
price_component_type ¶
price_segment_preset_type ¶
FrHealthPriceSegmentPresetType ¶
Bases: PriceSegmentPresetType
Fr Health standard price segments.
class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶class-attribute
instance-attribute
¶price_structure_type ¶
FrHealthPriceStructureType ¶
pet_insurance ¶
entities ¶
pet_insurance_plan_target_custom_data_presenter ¶
PetInsurancePlanTargetCustomDataPresenter
dataclass
¶
Bases: InsurancePlanTargetCustomDataPresenter
Custom data for pet insurance plan targets.
Pet plans are 1-to-1 with a (user × pet) target. pet_id links the
target to its PetProfile; pet name/species/breed are fetched from the
profile at render time.
staticmethod
¶Source code in components/insurance_plan_catalog/public/product_custom_data/pet_insurance/entities/pet_insurance_plan_target_custom_data_presenter.py
enums ¶
pet_insurance_service_type ¶
PetInsuranceServiceType ¶
pet_insurer_name ¶
PetInsurerName ¶
pet_payee ¶
pet_payor ¶
pet_price_component_type ¶
pet_price_structure_type ¶
PetPriceStructureType ¶
Bases: PriceStructureType
Pet insurance price structure types.
classmethod
¶Pet plans always use a single fixed-price component.