Skip to content

Api reference

components.insurance_plan_catalog.public.api

InsurancePlanApi

Bases: CorePlanApi

Implements the CorePlan API for InsurancePlan.

can_plans_be_contractualized_together

can_plans_be_contractualized_together(plan_1, plan_2)
Source code in components/insurance_plan_catalog/public/api.py
@override
def can_plans_be_contractualized_together(
    self,
    plan_1: CorePlan,
    plan_2: CorePlan,
) -> bool:
    # TODO Implement for France Health based on plan.eligibility_function
    # Will need to have a method plan_type.get_dependency().can_plans_be_contractualized_together
    return True

get_plan

get_plan(plan_id)
Source code in components/insurance_plan_catalog/public/api.py
@override
def get_plan(self, plan_id: PlanId) -> CorePlan:
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    plan = repo.get_or_raise(plan_id)

    with insurance_plan_catalog_context(plan.plan_type):
        return InsurancePlanEligibilityPresenter.from_entity(plan)

get_pricing_functions_for_modules

get_pricing_functions_for_modules(plan_id, plan_module_ids)
Source code in components/insurance_plan_catalog/public/api.py
@override
def get_pricing_functions_for_modules(
    self, plan_id: PlanId, plan_module_ids: set[ModuleId]
) -> Mapping[ModuleId, PricingFunction]:
    all_pricing_functions = get_pricing_functions_for_plan(plan_id)
    result: dict[ModuleId, PricingFunction] = {}
    for module_id in plan_module_ids:
        pricing_function = all_pricing_functions.get(module_id)
        if pricing_function is None:
            raise BaseErrorCode.missing_resource(
                f"InsurancePlanModule '{module_id}' not found in plan '{plan_id}'"
            )
        result[module_id] = pricing_function
    return result

list_plans

list_plans(plan_ids)
Source code in components/insurance_plan_catalog/public/api.py
@override
def list_plans(self, plan_ids: list[PlanId]) -> list[CorePlan]:
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    internal_plans = repo.get_many(ids=plan_ids)

    plans: list[CorePlan] = []

    for plan in internal_plans:
        with insurance_plan_catalog_context(plan.plan_type):
            plans.append(InsurancePlanEligibilityPresenter.from_entity(plan))

    return plans

search_plans

search_plans(plan_type, account_ref, target_type)

Search plans matching provided filters

Source code in components/insurance_plan_catalog/public/api.py
def search_plans(
    self,
    plan_type: InsurancePlanType,
    account_ref: str | None,
    target_type: InsurancePlanTargetType,
) -> list[CorePlan]:
    """Search plans matching provided filters"""
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    if target_type == InsurancePlanTargetType.individual:
        raise NotImplementedError(
            "insurance search_plans does not support the 'individual' target type yet"
        )

    plans = InsurancePlanRepository().search(
        plan_type=plan_type,
        account_ref=account_ref,
        target_type=target_type,
    )

    # plan_type is a required filter, so every result shares it -> wrap once.
    with insurance_plan_catalog_context(plan_type):
        return [
            InsurancePlanEligibilityPresenter.from_entity(plan) for plan in plans
        ]

get_coverage_for_module

get_coverage_for_module(module_id)

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
def get_coverage_for_module(module_id: UUID) -> InsuranceCoveragePresenter:
    """Return the coverage associated with the provided module.

    Args:
        module_id: The identifier of the target module.

    Returns:
        The coverage presenter for this module.

    Raises:
        BaseErrorCode.missing_resource: If module not found.
    """
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    plan = repo.get_plan_by_module_id(module_id)

    module = one(
        plan.modules,
        predicate=lambda m: m.id == module_id,
        custom_error=BaseErrorCode.missing_resource(
            f"InsurancePlanModule '{module_id}' not found in plan '{plan.id}'"
        ),
    )

    coverage = one(
        plan.coverages,
        predicate=lambda c: c.id == module.coverage_id,
        custom_error=BaseErrorCode.missing_resource(
            f"InsuranceCoverage '{module.coverage_id}' not found in plan '{plan.id}'"
        ),
    )

    with insurance_plan_catalog_context(plan.plan_type):
        return InsuranceCoveragePresenter.from_entity(coverage)

get_full_plan

get_full_plan(plan_id)

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
@request_cached()
def get_full_plan(
    plan_id: UUID,
) -> InsurancePlanPresenter:
    """
    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.

    Args:
        plan_id: UUID of the insurance plan

    Returns: Detailed plan.

    Raises:
        BaseErrorCode.missing_resource: If plan not found.
    """
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    plan = repo.get_or_raise(plan_id)

    with insurance_plan_catalog_context(plan.plan_type):
        return InsurancePlanPresenter.from_entity(plan)

get_modules

get_modules(modules_ids)

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
def get_modules(
    modules_ids: set[UUID],
) -> list[InsurancePlanModulePresenter]:
    """
    Returns detailed modules information.
    Typical use case: shows details (eg coverage table) of the modules a member is enrolled to.

    Args:
        modules_ids: Identifiers of the modules to retrieve

    Returns:
        List of detailed modules

    Raises:
        BaseErrorCode.missing_resource: If one of the module is not found or if not all modules
            belong to the same plan.
    """
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )

    plan, modules = _get_internal_plan_and_modules(modules_ids)

    with insurance_plan_catalog_context(plan.plan_type):
        return [
            InsurancePlanModulePresenter.from_entity(module=m, plan=plan)
            for m in modules
        ]

get_plan_id_from_legacy_source_ref

get_plan_id_from_legacy_source_ref(legacy_plan_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
def get_plan_id_from_legacy_source_ref(legacy_plan_source_ref: str) -> UUID | None:
    """Return the ``InsurancePlan.id`` previously persisted for this legacy
    source ref, or ``None`` if no mapping row exists yet.
    """
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_legacy_source_mapping_repository import (
        InsurancePlanLegacySourceMappingRepository,
    )

    mapping = InsurancePlanLegacySourceMappingRepository().get_from_legacy_ref(
        legacy_plan_source_ref
    )
    return mapping.insurance_plan_id if mapping else None

get_plan_summary

get_plan_summary(plan_id)

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
def get_plan_summary(
    plan_id: UUID,
) -> InsurancePlanSummaryPresenter:
    """
    Returns summary of a plan.
    Typical use case: display plan identifier (name, bundle code, etc.), eg in a link allowing to get details.

    Args:
        plan_id: UUID of the insurance plan

    Returns: summary of the plan.

    Raises:
        BaseErrorCode.missing_resource: If plan not found.
    """
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    plan = repo.get_or_raise(plan_id)

    with insurance_plan_catalog_context(plan.plan_type):
        return InsurancePlanSummaryPresenter.from_entity(plan)

get_pricing_functions_for_plan

get_pricing_functions_for_plan(plan_id)

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
@cached_for(
    days=1,
    local_ram_cache_only=True,
    no_serialization=True,
    LRU_max_entries=2048,
)
def get_pricing_functions_for_plan(
    plan_id: PlanId,
) -> Mapping[ModuleId, PricingFunction]:
    """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).
    """
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
        insurance_plan_catalog_context,
    )
    from components.insurance_plan_catalog.internal.pricing_function.pricing_function import (
        ModulePricingFunction,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    plan = InsurancePlanRepository().get_or_raise(plan_id)
    modules_by_id = {module.id: module for module in plan.modules}

    with insurance_plan_catalog_context(plan.plan_type):
        currency = get_current_dependency().currency

        def _build(module_id: ModuleId) -> ModulePricingFunction:
            module = modules_by_id[module_id]
            relative_pricing_function = (
                _build(module.relative_pricing_module_id)
                if module.relative_pricing_module_id is not None
                else None
            )
            return ModulePricingFunction(
                module_id=module_id,
                price_structure=module.price_structure,
                price_rules=module.price_rules,
                currency=currency,
                relative_pricing_function=relative_pricing_function,
            )

        return {module_id: _build(module_id) for module_id in modules_by_id}

insurance_plan_api module-attribute

insurance_plan_api = InsurancePlanApi()

persist_plan_from_legacy_source

persist_plan_from_legacy_source(
    legacy_plan_source_ref, legacy_source=None
)

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
def persist_plan_from_legacy_source(
    legacy_plan_source_ref: str, legacy_source: str | None = None
) -> None:
    """
    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.

    Args:
        legacy_plan_source_ref: legacy id of the plan (e.g., ES health contract
            version id). Stored as a string to support legacy sources with
            non-UUID identifiers.
        legacy_source: Optional name of the legacy source (e.g., 'ES contract subscription').
    """
    from components.insurance_plan_catalog.internal.entities.insurance_plan_legacy_source_mapping import (
        InsurancePlanLegacySourceMapping,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_legacy_source_mapping_repository import (
        InsurancePlanLegacySourceMappingRepository,
    )
    from components.insurance_plan_catalog.internal.repositories.insurance_plan_repository import (
        InsurancePlanRepository,
    )

    repo = InsurancePlanRepository()
    try:
        # Today the only legacy source is ES (UUID-keyed); the local converter
        # in repo.get expects a UUID. When non-UUID legacy sources land (e.g.
        # FR int ids), the converter dispatch will need to widen.
        plan = repo.get(UUID(legacy_plan_source_ref))
        if plan is None:
            raise BaseErrorCode.missing_resource(
                f"InsurancePlan '{legacy_plan_source_ref}' not found (no source to dual-write)"
            )
        repo.create(plan)
        InsurancePlanLegacySourceMappingRepository().create(
            InsurancePlanLegacySourceMapping(
                id=uuid4(),
                legacy_plan_source_ref=legacy_plan_source_ref,
                insurance_plan_id=plan.id,
                plan_type=plan.plan_type,
            )
        )
    except Exception as e:
        current_logger.error(
            "Failed to dual-write InsurancePlan from legacy source",
            legacy_plan_source_ref=legacy_plan_source_ref,
            legacy_source=legacy_source,
            error=str(e),
            exc_info=True,
        )

components.insurance_plan_catalog.public.builder_translation

builder_coverage_rules_to_coverage_rules

builder_coverage_rules_to_coverage_rules(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
def builder_coverage_rules_to_coverage_rules(
    rules: list[BuilderCoverageRule],
) -> list[CoverageRule]:
    """
    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.
    """
    from components.insurance_plan_catalog.internal.business_logic.builder_product_translation import (
        _builder_coverage_rule_to_coverage_rule,
    )

    return [_builder_coverage_rule_to_coverage_rule(rule) for rule in rules]

get_builder_product_mapping

get_builder_product_mapping(
    builder_product_id, builder_product_version_id=None
)

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
def get_builder_product_mapping(
    builder_product_id: int,
    builder_product_version_id: int | None = None,
) -> BuilderProductMapping | None:
    """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.
    """
    from components.insurance_plan_catalog.internal.business_logic.builder_product_translation import (
        get_builder_product_mapping as _get_builder_product_mapping,
    )

    return _get_builder_product_mapping(
        builder_product_id=builder_product_id,
        builder_product_version_id=builder_product_version_id,
    )

insurance_plan_to_builder_product_stateless

insurance_plan_to_builder_product_stateless(
    plan_id, mapping=None
)

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
def insurance_plan_to_builder_product_stateless(
    plan_id: UUID, mapping: BuilderProductMapping | None = None
) -> BuilderProduct:
    """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.
    """
    from components.insurance_plan_catalog.internal.business_logic.builder_product_translation import (
        insurance_plan_to_builder_product_stateless as _stateless,
    )

    return _stateless(plan_id, mapping)

components.insurance_plan_catalog.public.entities

coverage_rule

AggregatedLimitParameter module-attribute

AggregatedLimitParameter = (
    CategoryParameter | BundleChoiceParameter
)

BundleChoiceParameter dataclass

BundleChoiceParameter(*, type, value, bundle_choice_ref)

Bases: CoverageRuleParameter

A bundle choice parameter and its associated value

bundle_choice_ref instance-attribute
bundle_choice_ref
to_guarantee_catalog_parameter
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
def to_guarantee_catalog_parameter(
    self,
) -> GuaranteeCatalogInstantiatedBundleChoiceParameter:
    """Convert to the guarantee_catalog instantiated bundle-choice parameter."""
    return GuaranteeCatalogInstantiatedBundleChoiceParameter(
        type=self.type,
        value=self.value,
        bundle_choice_business_id=self.bundle_choice_ref,
    )

CategoryParameter dataclass

CategoryParameter(*, type, value, category_ref)

Bases: CoverageRuleParameter

A category parameter and its associated value

category_ref instance-attribute
category_ref
to_guarantee_catalog_parameter
to_guarantee_catalog_parameter()

Convert to the guarantee_catalog instantiated category parameter.

Source code in components/insurance_plan_catalog/public/entities/coverage_rule.py
def to_guarantee_catalog_parameter(
    self,
) -> GuaranteeCatalogInstantiatedCategoryParameter:
    """Convert to the guarantee_catalog instantiated category parameter."""
    return GuaranteeCatalogInstantiatedCategoryParameter(
        type=self.type,
        value=self.value,
        category_business_id=self.category_ref,
    )

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

bundle_choice_ref instance-attribute
bundle_choice_ref
eligibility_items_refs instance-attribute
eligibility_items_refs
expression_type instance-attribute
expression_type
guarantee_ref instance-attribute
guarantee_ref
id instance-attribute
id
metadata class-attribute instance-attribute
metadata = None
parameters instance-attribute
parameters
to_guarantee_catalog_coverage_rule
to_guarantee_catalog_coverage_rule()

Convert the CoverageRule instance to a GuaranteeCatalogCoverageRule

Source code in components/insurance_plan_catalog/public/entities/coverage_rule.py
def to_guarantee_catalog_coverage_rule(self) -> GuaranteeCatalogCoverageRule:
    """Convert the CoverageRule instance to a GuaranteeCatalogCoverageRule"""
    return GuaranteeCatalogCoverageRule(
        guarantee_business_id=self.guarantee_ref,
        bundle_choice_business_id=self.bundle_choice_ref,
        expression_type=self.expression_type,
        parameters=[
            GuaranteeCatalogCoverageRuleParameter(type=p.type, value=p.value)
            for p in self.parameters
        ],
        eligibility_items=self.eligibility_items_refs,
    )

CoverageRuleParameter dataclass

CoverageRuleParameter(*, type, value)

Bases: DataClassJsonMixin

A coverage rule parameter and its associated value

type instance-attribute
type
value instance-attribute
value

PropagatedParameter module-attribute

PropagatedParameter = (
    CategoryParameter | BundleChoiceParameter
)

errors

PricingFunctionError

PricingFunctionError(
    error_type,
    description,
    member_id=None,
    input_type=None,
    **kwargs
)

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
def __init__(
    self,
    error_type: PricingFunctionErrorType,
    description: str,
    member_id: str | None = None,
    input_type: InputType | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a pricing function error with type and description."""
    super().__init__(None, error_type.value, description, **kwargs)
    self.member_id = member_id
    self.input_type = input_type
ambiguous_price_rule classmethod
ambiguous_price_rule(member_id, match_count)

Create error when multiple price rules match.

Source code in components/insurance_plan_catalog/public/entities/errors.py
@classmethod
def ambiguous_price_rule(
    cls,
    member_id: str | None,
    match_count: int,
) -> PricingFunctionError:
    """Create error when multiple price rules match."""
    return cls(
        error_type=PricingFunctionErrorType.ambiguous_price_rule,
        description=f"Ambiguous match: {match_count} candidates found, expected exactly one",
        member_id=member_id,
        match_count=match_count,
    )
component class-attribute instance-attribute
component = 'insurance_plan_catalog'
input_type instance-attribute
input_type = input_type
invalid_input_format classmethod
invalid_input_format(member_id, input_type, raw_value)

Create error for invalid input format.

Source code in components/insurance_plan_catalog/public/entities/errors.py
@classmethod
def invalid_input_format(
    cls,
    member_id: str | None,
    input_type: InputType,
    raw_value: str,
) -> PricingFunctionError:
    """Create error for invalid input format."""
    return cls(
        error_type=PricingFunctionErrorType.invalid_input_format,
        description=f"Invalid format for input '{input_type.value}': '{raw_value}'",
        member_id=member_id,
        input_type=input_type,
        raw_value=raw_value,
    )
member_id instance-attribute
member_id = member_id
missing_input classmethod
missing_input(member_id, input_type)

Create error for missing required input.

Source code in components/insurance_plan_catalog/public/entities/errors.py
@classmethod
def missing_input(
    cls,
    member_id: str | None,
    input_type: InputType,
) -> PricingFunctionError:
    """Create error for missing required input."""
    return cls(
        error_type=PricingFunctionErrorType.missing_input,
        description=f"Missing required input '{input_type.value}'",
        member_id=member_id,
        input_type=input_type,
    )
no_matching_price_rule classmethod
no_matching_price_rule(member_id, component_id=None)

Create error when no price rule matches.

Source code in components/insurance_plan_catalog/public/entities/errors.py
@classmethod
def no_matching_price_rule(
    cls,
    member_id: str | None,
    component_id: UUID | None = None,
) -> PricingFunctionError:
    """Create error when no price rule matches."""
    description = (
        f"No price rule for component '{component_id}'"
        if component_id
        else "No matching price rule found"
    )
    return cls(
        error_type=PricingFunctionErrorType.no_matching_price_rule,
        description=description,
        member_id=member_id,
        component_id=component_id,
    )

PricingFunctionErrorType

Bases: AlanBaseEnum

Error types for pricing function validation.

ambiguous_price_rule class-attribute instance-attribute
ambiguous_price_rule = 'ambiguous_price_rule'
invalid_input_format class-attribute instance-attribute
invalid_input_format = 'invalid_input_format'
missing_input class-attribute instance-attribute
missing_input = 'missing_input'
no_matching_price_rule class-attribute instance-attribute
no_matching_price_rule = 'no_matching_price_rule'

insurance_coverage

InsuranceCoverageCustomDataPresenter dataclass

InsuranceCoverageCustomDataPresenter()

Bases: ABC, Coercible['InsuranceCoverageCustomDataPresenter']

Additional data depending on the product type.

from_custom_entity abstractmethod staticmethod
from_custom_entity(custom_data)

Method of subclass implementing the actual conversion

Source code in components/insurance_plan_catalog/public/entities/insurance_coverage.py
@staticmethod
@abstractmethod
def from_custom_entity(
    custom_data: InsuranceCoverageCustomData,
) -> InsuranceCoverageCustomDataPresenter:
    """Method of subclass implementing the actual conversion"""
from_entity staticmethod
from_entity(custom_data)

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
@staticmethod
def from_entity(
    custom_data: InsuranceCoverageCustomData | None,
) -> InsuranceCoverageCustomDataPresenter | None:
    """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:
        Product-specific custom data presenter or None if no custom data
    """
    if custom_data is None:
        return None

    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    presenter_cls = dependency.coverage_custom_data_presenter_cls

    if presenter_cls is None:
        return None

    return presenter_cls.from_custom_entity(custom_data)

InsuranceCoveragePresenter dataclass

InsuranceCoveragePresenter(
    *,
    id,
    service_type,
    index,
    selected_categories,
    coverage_rules,
    aggregated_limit_parameters,
    custom_data
)

Coverage information containing coverage rules.

aggregated_limit_parameters instance-attribute
aggregated_limit_parameters
coverage_rules instance-attribute
coverage_rules
custom_data instance-attribute
custom_data
from_entity staticmethod
from_entity(coverage)

Convert internal insurance coverage entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_coverage.py
@staticmethod
def from_entity(coverage: InsuranceCoverage) -> InsuranceCoveragePresenter:
    """Convert internal insurance coverage entity to presenter."""
    return InsuranceCoveragePresenter(
        id=coverage.id,
        service_type=coverage.service_type,
        index=coverage.index,
        selected_categories=coverage.selected_categories,
        coverage_rules=coverage.coverage_rules,
        aggregated_limit_parameters=coverage.aggregated_limit_parameters,
        custom_data=InsuranceCoverageCustomDataPresenter.from_entity(
            coverage.custom_data
        ),
    )
id instance-attribute
id
index instance-attribute
index
selected_categories instance-attribute
selected_categories
service_type instance-attribute
service_type

insurance_plan

InsurancePlanCustomDataPresenter dataclass

InsurancePlanCustomDataPresenter()

Bases: ABC, Coercible['InsurancePlanCustomDataPresenter']

Additional data depending on the product type.

from_custom_entity abstractmethod staticmethod
from_custom_entity(custom_data)

Method of subclass implementing the actual conversion

Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
@staticmethod
@abstractmethod
def from_custom_entity(
    custom_data: InsurancePlanCustomData,
) -> InsurancePlanCustomDataPresenter:
    """Method of subclass implementing the actual conversion"""
from_entity staticmethod
from_entity(custom_data)

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
@staticmethod
def from_entity(
    custom_data: InsurancePlanCustomData | None,
) -> InsurancePlanCustomDataPresenter | None:
    """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:
        Product-specific custom data presenter or None if no custom data
    """
    if custom_data is None:
        return None

    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    presenter_cls = dependency.plan_custom_data_presenter_cls

    if presenter_cls is None:
        return None

    return presenter_cls.from_custom_entity(custom_data)

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.

eligibility_function instance-attribute
eligibility_function
from_entity staticmethod
from_entity(plan)

Convert internal insurance plan entity to summary presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
@staticmethod
def from_entity(plan: InsurancePlan) -> InsurancePlanEligibilityPresenter:
    """Convert internal insurance plan entity to summary presenter."""
    return InsurancePlanEligibilityPresenter(
        id=plan.id,
        insurer_name=plan.insurer_name,
        country=plan.country,
        type=plan.plan_type,
        business_id=plan.business_id,
        display_name=plan.display_name,
        modules=[
            InsurancePlanModuleEligibilityPresenter.from_entity(
                module=module, plan=plan
            )
            for module in plan.modules
        ],
        module_constraints=mandatory(plan.module_constraints),
        eligibility_function=mandatory(plan.eligibility_function),
    )
module_constraints instance-attribute
module_constraints
modules instance-attribute
modules

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.

coverages instance-attribute
coverages
custom_data instance-attribute
custom_data
from_entity staticmethod
from_entity(plan)

Convert internal insurance plan entity to full presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
@staticmethod
def from_entity(plan: InsurancePlan) -> InsurancePlanPresenter:
    """Convert internal insurance plan entity to full presenter."""
    return InsurancePlanPresenter(
        id=plan.id,
        insurer_name=plan.insurer_name,
        country=plan.country,
        type=plan.plan_type,
        business_id=plan.business_id,
        display_name=plan.display_name,
        segment=plan.segment,
        target_type=plan.target_type,
        targets=[InsurancePlanTargetPresenter.from_entity(t) for t in plan.targets],
        price_segments=[
            InsurancePriceSegmentPresenter.from_entity(s)
            for s in plan.price_segments
        ],
        coverages=[
            InsuranceCoveragePresenter.from_entity(c) for c in plan.coverages
        ],
        modules=[
            InsurancePlanModulePresenter.from_entity(module=m, plan=plan)
            for m in plan.modules
        ],
        module_constraints=mandatory(plan.module_constraints),
        eligibility_function=mandatory(plan.eligibility_function),
        custom_data=InsurancePlanCustomDataPresenter.from_entity(plan.custom_data),
    )
modules instance-attribute
modules
price_segments instance-attribute
price_segments
segment instance-attribute
segment
target_type instance-attribute
target_type
targets instance-attribute
targets

InsurancePlanSummaryPresenter dataclass

InsurancePlanSummaryPresenter(
    *,
    id,
    insurer_name,
    country,
    type,
    business_id,
    display_name
)

Summary of a plan, eg to display identification information, without details.

business_id instance-attribute
business_id
country instance-attribute
country
display_name instance-attribute
display_name
from_entity staticmethod
from_entity(plan)

Convert internal insurance plan entity to summary presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan.py
@staticmethod
def from_entity(plan: InsurancePlan) -> InsurancePlanSummaryPresenter:
    """Convert internal insurance plan entity to summary presenter."""
    return InsurancePlanSummaryPresenter(
        id=plan.id,
        insurer_name=plan.insurer_name,
        country=plan.country,
        type=plan.plan_type,
        business_id=plan.business_id,
        display_name=plan.display_name,
    )
id instance-attribute
id
insurer_name instance-attribute
insurer_name
type instance-attribute
type

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.

eligibility_function instance-attribute
eligibility_function
eligibility_lost_fallback_module_ids instance-attribute
eligibility_lost_fallback_module_ids
from_entity classmethod
from_entity(module, plan)

Convert internal insurance plan module entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan_module.py
@classmethod
def from_entity(
    cls, module: InsurancePlanModule, plan: InsurancePlan
) -> InsurancePlanModuleEligibilityPresenter:
    """Convert internal insurance plan module entity to presenter."""
    from components.insurance_plan_catalog.internal.business_logic.stable_slugs import (
        get_module_stable_slug,
    )

    coverage = one(
        coverage for coverage in plan.coverages if coverage.id == module.coverage_id
    )
    price_segment = one(
        price_segment
        for price_segment in plan.price_segments
        if price_segment.id == module.price_segment_id
    )
    return InsurancePlanModuleEligibilityPresenter(
        id=module.id,
        stable_plan_module_slug=get_module_stable_slug(
            coverage=coverage, price_segment=price_segment
        ),
        service_type=coverage.service_type,
        eligibility_function=module.eligibility_function,
        eligibility_lost_fallback_module_ids=module.eligibility_lost_fallback_module_ids,
    )
id instance-attribute
id
service_type instance-attribute
service_type
stable_plan_module_slug instance-attribute
stable_plan_module_slug

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.

coverage_id instance-attribute
coverage_id
from_entity classmethod
from_entity(module, plan)

Convert internal insurance plan module entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan_module.py
@classmethod
def from_entity(
    cls, module: InsurancePlanModule, plan: InsurancePlan
) -> InsurancePlanModulePresenter:
    """Convert internal insurance plan module entity to presenter."""
    from components.insurance_plan_catalog.internal.business_logic.stable_slugs import (
        get_module_stable_slug,
    )

    coverage = one(
        coverage for coverage in plan.coverages if coverage.id == module.coverage_id
    )
    price_segment = one(
        price_segment
        for price_segment in plan.price_segments
        if price_segment.id == module.price_segment_id
    )
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    return InsurancePlanModulePresenter(
        id=module.id,
        coverage_id=module.coverage_id,
        price_segment_id=module.price_segment_id,
        stable_plan_module_slug=get_module_stable_slug(
            coverage=coverage, price_segment=price_segment
        ),
        service_type=coverage.service_type,
        eligibility_function=module.eligibility_function,
        eligibility_lost_fallback_module_ids=module.eligibility_lost_fallback_module_ids,
        price_structure=PriceStructurePresenter.from_entity(module.price_structure),
        participation_rules=[
            ParticipationRulePresenter.from_entity(r)
            for r in module.participation_rules
        ],
        price_rules=[
            InsurancePriceRulePresenter.from_entity(r) for r in module.price_rules
        ],
        migration_tags=dependency.get_migration_tags(coverage),
    )
id instance-attribute
id
migration_tags instance-attribute
migration_tags
participation_rules instance-attribute
participation_rules
price_rules instance-attribute
price_rules
price_segment_id instance-attribute
price_segment_id
price_structure instance-attribute
price_structure

insurance_plan_target

InsurancePlanTargetCustomDataPresenter dataclass

InsurancePlanTargetCustomDataPresenter()

Bases: ABC, Coercible['InsurancePlanTargetCustomDataPresenter']

Additional data depending on the product type (of the plan) + target type.

from_custom_entity abstractmethod staticmethod
from_custom_entity(custom_data)

Method of subclass implementing the actual conversion

Source code in components/insurance_plan_catalog/public/entities/insurance_plan_target.py
@staticmethod
@abstractmethod
def from_custom_entity(
    custom_data: InsurancePlanTargetCustomData,
) -> InsurancePlanTargetCustomDataPresenter:
    """Method of subclass implementing the actual conversion"""
from_entity staticmethod
from_entity(custom_data)

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
@staticmethod
def from_entity(
    custom_data: InsurancePlanTargetCustomData | None,
) -> InsurancePlanTargetCustomDataPresenter | None:
    """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:
        Product-specific custom data presenter or None if no custom data
    """
    if custom_data is None:
        return None

    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    presenter_cls = dependency.plan_target_custom_data_presenter_cls

    if presenter_cls is None:
        return None

    return presenter_cls.from_custom_entity(custom_data)

InsurancePlanTargetPresenter dataclass

InsurancePlanTargetPresenter(
    *, id, display_name, prospect_ref, custom_data
)

Detailed properties of an entity (eg company) for which the plan was created.

custom_data instance-attribute
custom_data
display_name instance-attribute
display_name
from_entity staticmethod
from_entity(target)

Convert internal plan target entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_plan_target.py
@staticmethod
def from_entity(target: InsurancePlanTarget) -> InsurancePlanTargetPresenter:
    """Convert internal plan target entity to presenter."""
    return InsurancePlanTargetPresenter(
        id=target.id,
        display_name=target.display_name,
        prospect_ref=target.prospect_ref,
        custom_data=InsurancePlanTargetCustomDataPresenter.from_entity(
            target.custom_data
        ),
    )
id instance-attribute
id
prospect_ref instance-attribute
prospect_ref

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)

component_type instance-attribute
component_type
contribution_type instance-attribute
contribution_type
currency instance-attribute
currency
equivalent_price_absolute instance-attribute
equivalent_price_absolute
from_entity staticmethod
from_entity(component)

Convert internal price component entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
@staticmethod
def from_entity(
    component: InsurancePriceComponent,
) -> InsurancePriceComponentPresenter:
    """Convert internal price component entity to presenter."""
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()

    return InsurancePriceComponentPresenter(
        id=component.id,
        component_type=component.component_type,
        contribution_type=component.contribution_type,
        payor=component.payor,
        payee=component.payee,
        price_absolute=component.price_absolute,
        salary_rate=component.salary_rate,
        salary_type=component.salary_type,
        min_price_absolute=component.min_price_absolute,
        max_price_absolute=component.max_price_absolute,
        equivalent_price_absolute=component.equivalent_price_absolute,
        tax_rate=component.tax_rate,
        currency=dependency.currency,
    )
id instance-attribute
id
max_price_absolute instance-attribute
max_price_absolute
min_price_absolute instance-attribute
min_price_absolute
payee instance-attribute
payee
payor instance-attribute
payor
price_absolute instance-attribute
price_absolute
salary_rate instance-attribute
salary_rate
salary_type instance-attribute
salary_type
tax_rate instance-attribute
tax_rate

InsurancePriceRuleCustomDataPresenter dataclass

InsurancePriceRuleCustomDataPresenter()

Bases: ABC, Coercible['InsurancePriceRuleCustomDataPresenter']

Additional data depending on the product type.

from_custom_entity abstractmethod staticmethod
from_custom_entity(custom_data)

Method of subclass implementing the actual conversion

Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
@staticmethod
@abstractmethod
def from_custom_entity(
    custom_data: InsurancePriceRuleCustomData,
) -> InsurancePriceRuleCustomDataPresenter:
    """Method of subclass implementing the actual conversion"""
from_entity staticmethod
from_entity(custom_data)

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
@staticmethod
def from_entity(
    custom_data: InsurancePriceRuleCustomData | None,
) -> InsurancePriceRuleCustomDataPresenter | None:
    """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:
        Product-specific custom data presenter or None if no custom data
    """
    if custom_data is None:
        return None

    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    presenter_cls = dependency.price_rule_custom_data_presenter_cls

    if presenter_cls is None:
        return None

    return presenter_cls.from_custom_entity(custom_data)

InsurancePriceRulePresenter dataclass

InsurancePriceRulePresenter(
    *,
    id,
    price_structure_component_id,
    price_components,
    custom_data
)

Price breakdown for a given price structure component in a given module. The total price is computed by summing all its components.

custom_data instance-attribute
custom_data
from_entity staticmethod
from_entity(rule)

Convert internal price rule entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_price_rule.py
@staticmethod
def from_entity(rule: InsurancePriceRule) -> InsurancePriceRulePresenter:
    """Convert internal price rule entity to presenter."""
    return InsurancePriceRulePresenter(
        id=rule.id,
        price_structure_component_id=rule.price_structure_component_id,
        price_components=[
            InsurancePriceComponentPresenter.from_entity(c)
            for c in rule.price_components
        ],
        custom_data=InsurancePriceRuleCustomDataPresenter.from_entity(
            rule.custom_data
        ),
    )
id instance-attribute
id
price_components instance-attribute
price_components
price_structure_component_id instance-attribute
price_structure_component_id

insurance_price_segment

InsurancePriceSegmentPresenter dataclass

InsurancePriceSegmentPresenter(*, id, type)

Information about a price segment (subpopulation with specific pricing).

from_entity staticmethod
from_entity(segment)

Convert internal price segment entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/insurance_price_segment.py
@staticmethod
def from_entity(
    segment: InsurancePriceSegment,
) -> InsurancePriceSegmentPresenter:
    """Convert internal price segment entity to presenter."""
    return InsurancePriceSegmentPresenter(
        id=segment.id,
        type=segment.type,
    )
id instance-attribute
id
type instance-attribute
type

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
from_entity(rule)

Convert internal participation rule entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/participation_rule.py
@staticmethod
def from_entity(
    rule: ParticipationRule,
) -> ParticipationRulePresenter:
    """Convert internal participation rule entity to presenter."""
    return ParticipationRulePresenter(
        id=rule.id,
        price_structure_component_id=rule.price_structure_component_id,
        price_component_type=rule.price_component_type,
        participation_ratio=rule.participation_ratio,
        participation_absolute=rule.participation_absolute,
        max_participation_absolute=rule.max_participation_absolute,
    )
id instance-attribute
id
max_participation_absolute instance-attribute
max_participation_absolute
participation_absolute instance-attribute
participation_absolute
participation_ratio instance-attribute
participation_ratio
price_component_type instance-attribute
price_component_type
price_structure_component_id instance-attribute
price_structure_component_id

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.

coefficient instance-attribute
coefficient
from_entity staticmethod
from_entity(component)

Convert internal price structure component entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/price_structure.py
@staticmethod
def from_entity(
    component: AbstractPriceStructureComponent,
) -> PriceStructureComponentPresenter:
    """Convert internal price structure component entity to presenter."""
    return PriceStructureComponentPresenter(
        id=component.id,
        coefficient=component.coefficient,
        membership_types=component.membership_types,
        member_min_age_in_months=component.member_min_age_in_months,
        member_max_age_in_months=component.member_max_age_in_months,
        member_min_rank_inclusive=component.member_min_rank_inclusive,
        member_max_rank_inclusive=component.member_max_rank_inclusive,
        member_min_status_tenure_in_months=component.member_min_status_tenure_in_months,
        member_max_status_tenure_in_months=component.member_max_status_tenure_in_months,
    )
id instance-attribute
id
member_max_age_in_months instance-attribute
member_max_age_in_months
member_max_rank_inclusive instance-attribute
member_max_rank_inclusive
member_max_status_tenure_in_months instance-attribute
member_max_status_tenure_in_months
member_min_age_in_months instance-attribute
member_min_age_in_months
member_min_rank_inclusive instance-attribute
member_min_rank_inclusive
member_min_status_tenure_in_months instance-attribute
member_min_status_tenure_in_months
membership_types instance-attribute
membership_types

PriceStructurePresenter dataclass

PriceStructurePresenter(*, components, inferred_type)

Defines how we distribute the total average policy price between members.

components instance-attribute
components
from_entity staticmethod
from_entity(structure)

Convert internal price structure entity to presenter.

Source code in components/insurance_plan_catalog/public/entities/price_structure.py
@staticmethod
def from_entity(structure: AbstractPriceStructure) -> PriceStructurePresenter:
    """Convert internal price structure entity to presenter."""
    from components.insurance_plan_catalog.internal.insurance_plan_catalog_context import (
        get_current_dependency,
    )

    dependency = get_current_dependency()
    price_structure_type_cls = dependency.price_structure_type_cls

    return PriceStructurePresenter(
        components=[
            PriceStructureComponentPresenter.from_entity(c)
            for c in structure.components
        ],
        inferred_type=price_structure_type_cls.infer_from_components(
            structure.components
        ),
    )
inferred_type instance-attribute
inferred_type

components.insurance_plan_catalog.public.enums

insurance_plan_target_type

InsurancePlanTargetType

Bases: AlanBaseEnum

Type of targets for which the plan was created.

company class-attribute instance-attribute
company = 'company'
individual class-attribute instance-attribute
individual = 'individual'

insurance_plan_type

InsurancePlanType

Bases: BasePlanType

Supported insurance product types.

be_health class-attribute instance-attribute
be_health = 'be_health'
ca_health_life_and_disability class-attribute instance-attribute
ca_health_life_and_disability = (
    "ca_health_life_and_disability"
)
es_health class-attribute instance-attribute
es_health = 'es_health'
fr_health class-attribute instance-attribute
fr_health = 'fr_health'
fr_prevoyance class-attribute instance-attribute
fr_prevoyance = 'fr_prevoyance'
get_dependency
get_dependency()

Return the catalog dependency implementation for this plan type.

Source code in components/insurance_plan_catalog/public/enums/insurance_plan_type.py
def get_dependency(self) -> "InsurancePlanCatalogDependency":
    """Return the catalog dependency implementation for this plan type."""
    from components.insurance_plan_catalog.internal.product_custom_data.ca_health_life_and_disability.ca_health_life_and_disability_dependency import (
        CaHealthLifeAndDisabilityInsurancePlanCatalogDependency,
    )
    from components.insurance_plan_catalog.internal.product_custom_data.es_health.es_health_dependency import (
        EsHealthInsurancePlanCatalogDependency,
    )
    from components.insurance_plan_catalog.internal.product_custom_data.pet_insurance.pet_insurance_dependency import (
        PetInsurancePlanCatalogDependency,
    )

    dependencies = [
        EsHealthInsurancePlanCatalogDependency(),
        PetInsurancePlanCatalogDependency(),
        CaHealthLifeAndDisabilityInsurancePlanCatalogDependency(),
    ]
    for dependency in dependencies:
        if dependency.plan_type == self:
            return dependency
    raise ValueError(f"No dependency registered for plan_type={self}")
pet_insurance class-attribute instance-attribute
pet_insurance = 'pet_insurance'

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_from_components(components)

Infer price structure type from components. Product-specific subclasses should override.

Source code in components/insurance_plan_catalog/public/enums/price_structure_type.py
@classmethod
def infer_from_components(
    cls,
    components: Sequence[AbstractPriceStructureComponent],
) -> PriceStructureType:
    """Infer price structure type from components. Product-specific subclasses should override."""
    raise NotImplementedError

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
CaHealthLifeAndDisabilityInsurancePlanCustomDataPresenter(
    *, adjudicare_plan_id
)

Bases: InsurancePlanCustomDataPresenter

Plan-level custom data presenter for Canada health plans.

adjudicare_plan_id instance-attribute
adjudicare_plan_id
from_custom_entity staticmethod
from_custom_entity(custom_data)
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
@staticmethod
@override
def from_custom_entity(
    custom_data: InsurancePlanCustomData,
) -> CaHealthLifeAndDisabilityInsurancePlanCustomDataPresenter:
    coerced = CaHealthLifeAndDisabilityInsurancePlanCustomData.coerce(custom_data)
    return CaHealthLifeAndDisabilityInsurancePlanCustomDataPresenter(
        adjudicare_plan_id=coerced.adjudicare_plan_id
    )

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).

dental class-attribute instance-attribute
dental = 'dental'
extended_health_care class-attribute instance-attribute
extended_health_care = 'extended_health_care'
vision class-attribute instance-attribute
vision = 'vision'
ca_health_life_and_disability_insurer_name
CaHealthLifeAndDisabilityInsurerName

Bases: InsurerName

Canada health insurer names.

alan_canada class-attribute instance-attribute
alan_canada = 'alan_canada'
ca_health_life_and_disability_payee
CaHealthLifeAndDisabilityPayee

Bases: Payee

Canada health payees.

alan_canada class-attribute instance-attribute
alan_canada = 'alan_canada'
ca_health_life_and_disability_payor
CaHealthLifeAndDisabilityPayor

Bases: Payor

Canada health payors.

employer class-attribute instance-attribute
employer = 'employer'
member class-attribute instance-attribute
member = 'member'

es_health

entities

es_health_insurance_coverage_custom_data_presenter
EsHealthInsuranceCoverageCustomDataPresenter dataclass
EsHealthInsuranceCoverageCustomDataPresenter(
    *, coverage_type
)

Bases: InsuranceCoverageCustomDataPresenter

Custom data for ES health coverages

coverage_type instance-attribute
coverage_type
from_custom_entity staticmethod
from_custom_entity(custom_data)
Source code in components/insurance_plan_catalog/public/product_custom_data/es_health/entities/es_health_insurance_coverage_custom_data_presenter.py
@staticmethod
@override
def from_custom_entity(
    custom_data: InsuranceCoverageCustomData,
) -> EsHealthInsuranceCoverageCustomDataPresenter:
    coerced_data = EsHealthInsuranceCoverageCustomData.coerce(custom_data)
    return EsHealthInsuranceCoverageCustomDataPresenter(
        coverage_type=coerced_data.coverage_type
    )
es_health_insurance_plan_target_custom_data_presenter
EsHealthInsurancePlanCompanyTargetCustomDataPresenter dataclass
EsHealthInsurancePlanCompanyTargetCustomDataPresenter(
    *, postal_code
)

Bases: InsurancePlanTargetCustomDataPresenter

Custom data for ES health plan targets.

from_custom_entity staticmethod
from_custom_entity(custom_data)
Source code in components/insurance_plan_catalog/public/product_custom_data/es_health/entities/es_health_insurance_plan_target_custom_data_presenter.py
@staticmethod
@override
def from_custom_entity(
    custom_data: InsurancePlanTargetCustomData,
) -> EsHealthInsurancePlanCompanyTargetCustomDataPresenter:
    coerced_data = EsHealthInsurancePlanCompanyTargetCustomData.coerce(custom_data)
    return EsHealthInsurancePlanCompanyTargetCustomDataPresenter(
        postal_code=coerced_data.postal_code
    )
postal_code instance-attribute
postal_code

enums

es_coverage_type
EsCoverageType

Bases: AlanBaseEnum

ES coverage type

access class-attribute instance-attribute
access = 'access'
essential class-attribute instance-attribute
essential = 'essential'
health class-attribute instance-attribute
health = 'health'
es_health_insurance_service_type
EsHealthInsuranceServiceType

Bases: InsuranceServiceType

Spanish health insurance service types.

health class-attribute instance-attribute
health = 'health'
es_health_insurer_name
EsHealthInsurerName

Bases: InsurerName

Spanish health insurer names.

alan class-attribute instance-attribute
alan = 'alan'
es_health_payee
EsHealthPayee

Bases: Payee

Spanish health payees.

alan class-attribute instance-attribute
alan = 'alan'
es_health_payor
EsHealthPayor

Bases: Payor

Spanish health payors.

employer class-attribute instance-attribute
employer = 'employer'
member class-attribute instance-attribute
member = 'member'
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.

core_product class-attribute instance-attribute
core_product = 'es_core_product'
optical class-attribute instance-attribute
optical = 'es_optical'
pharmacy class-attribute instance-attribute
pharmacy = 'es_pharmacy'
physio_nutrition class-attribute instance-attribute
physio_nutrition = 'es_physio_nutrition'
physio_reimbursement class-attribute instance-attribute
physio_reimbursement = 'es_physio_reimbursement'
preexisting_conditions class-attribute instance-attribute
preexisting_conditions = 'preexisting_conditions'
premium_reimbursement class-attribute instance-attribute
premium_reimbursement = 'es_premium_reimbursement'
tax_rate property
tax_rate

Get the applicable tax rate for the price component type.

All ES price components have the same CCS tax rate.

TAX_RATE_CCS module-attribute
TAX_RATE_CCS = Decimal('0.0015')
es_health_price_structure_type
EsHealthPriceStructureType

Bases: PriceStructureType

Price structure types for Spain health

balanced class-attribute instance-attribute
balanced = 'balanced'
infer_from_components classmethod
infer_from_components(components)

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
@classmethod
@override
def infer_from_components(
    cls,
    components: Sequence[AbstractPriceStructureComponent],
) -> EsHealthPriceStructureType:
    """Balanced if all coefficients are equal, tailored otherwise."""
    if not components:
        return cls.balanced
    if len(set(c.coefficient for c in components)) == 1:
        return cls.balanced
    return cls.tailored
tailored class-attribute instance-attribute
tailored = 'tailored'

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
FrHealthPriceComponentType

Bases: PriceComponentType

Price component types for the French health insurance product.

non_responsible class-attribute instance-attribute
non_responsible = 'non_responsible'
responsible class-attribute instance-attribute
responsible = 'responsible'
price_segment_preset_type
FrHealthPriceSegmentPresetType

Bases: PriceSegmentPresetType

Fr Health standard price segments.

fr_active_employees_collective_mandatory class-attribute instance-attribute
fr_active_employees_collective_mandatory = (
    "fr_active_employees_collective_mandatory"
)
fr_ani_collective_mandatory class-attribute instance-attribute
fr_ani_collective_mandatory = 'fr_ani_collective_mandatory'
fr_individual_freelancer class-attribute instance-attribute
fr_individual_freelancer = 'fr_individual_freelancer'
fr_individual_private class-attribute instance-attribute
fr_individual_private = 'fr_individual_private'
fr_retirees_collective_facultative class-attribute instance-attribute
fr_retirees_collective_facultative = (
    "fr_retirees_collective_facultative"
)
fr_unpaid_leave_collective_mandatory class-attribute instance-attribute
fr_unpaid_leave_collective_mandatory = (
    "fr_unpaid_leave_collective_mandatory"
)
price_structure_type
FrHealthPriceStructureType

Bases: PriceStructureType

Price structure types for the French health insurance product.

balanced class-attribute instance-attribute
balanced = 'balanced'
children_included class-attribute instance-attribute
children_included = 'children_included'
family_price class-attribute instance-attribute
family_price = 'family_price'
price_per_child class-attribute instance-attribute
price_per_child = 'price_per_child'
primary_2x class-attribute instance-attribute
primary_2x = 'primary_2x'
primary_duo_family class-attribute instance-attribute
primary_duo_family = 'primary_duo_family'
primary_or_family class-attribute instance-attribute
primary_or_family = 'primary_or_family'
tailored class-attribute instance-attribute
tailored = 'tailored'

pet_insurance

entities

pet_insurance_plan_target_custom_data_presenter
PetInsurancePlanTargetCustomDataPresenter dataclass
PetInsurancePlanTargetCustomDataPresenter(*, pet_id)

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.

from_custom_entity staticmethod
from_custom_entity(custom_data)
Source code in components/insurance_plan_catalog/public/product_custom_data/pet_insurance/entities/pet_insurance_plan_target_custom_data_presenter.py
@staticmethod
@override
def from_custom_entity(
    custom_data: InsurancePlanTargetCustomData,
) -> PetInsurancePlanTargetCustomDataPresenter:
    coerced = PetInsurancePlanTargetCustomData.coerce(custom_data)
    return PetInsurancePlanTargetCustomDataPresenter(pet_id=coerced.pet_id)
pet_id instance-attribute
pet_id

enums

pet_insurance_service_type
PetInsuranceServiceType

Bases: InsuranceServiceType

Pet insurance service types.

pet_health class-attribute instance-attribute
pet_health = 'pet_health'
pet_insurer_name
PetInsurerName

Bases: InsurerName

Pet insurance insurer names.

alan class-attribute instance-attribute
alan = 'alan'
pet_payee
PetPayee

Bases: Payee

Pet insurance payees.

alan class-attribute instance-attribute
alan = 'alan'
pet_payor
PetPayor

Bases: Payor

Pet insurance payors.

pet_owner class-attribute instance-attribute
pet_owner = 'pet_owner'
pet_price_component_type
PetPriceComponentType

Bases: PriceComponentType

Pet insurance price component types.

pet_premium class-attribute instance-attribute
pet_premium = 'pet_premium'
pet_price_structure_type
PetPriceStructureType

Bases: PriceStructureType

Pet insurance price structure types.

fixed class-attribute instance-attribute
fixed = 'fixed'
infer_from_components classmethod
infer_from_components(components)

Pet plans always use a single fixed-price component.

Source code in components/insurance_plan_catalog/public/product_custom_data/pet_insurance/enums/pet_price_structure_type.py
@classmethod
@override
def infer_from_components(
    cls,
    components: Sequence[AbstractPriceStructureComponent],
) -> PetPriceStructureType:
    """Pet plans always use a single fixed-price component."""
    return cls.fixed