Skip to content

Api reference

components.member_lifecycle.public.commands

generate_frontend_types_file

generate_frontend_typescript_types_files

generate_frontend_typescript_types_files(dry_run)

Use flask generate_frontend_typescript_types_files --execute to generate the frontend typescript types.

  • File: "frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts"
  • Types: all enums and entities
Source code in components/member_lifecycle/public/commands/generate_frontend_types_file.py
@member_lifecycle_commands.command()
@command_with_dry_run
def generate_frontend_typescript_types_files(dry_run: bool) -> None:
    """
    Use `flask generate_frontend_typescript_types_files --execute` to generate the frontend typescript types.

    - File: "frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts"
    - Types: all enums and entities
    """
    from shared.codegen.typescript import (
        generate_typescript_enums_and_interfaces,
    )

    generate_typescript_enums_and_interfaces(
        target_filename_path_from_git_root="frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts",
        types_to_generate=[
            # Enums
        ],
        dry_run=dry_run,
    )

components.member_lifecycle.public.consts

MEMBER_LIFECYCLE_COMPONENT_NAME module-attribute

MEMBER_LIFECYCLE_COMPONENT_NAME = 'member_lifecycle'

components.member_lifecycle.public.dependencies

AddDependentsDependency

AddDependentsDependency(price_provider)

AddDependentsDependency defines the interface that apps using the add_dependents subcomponent need to implement

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def __init__(self, price_provider: PriceProvider):
    self.price_provider = price_provider

can_add_dependents

can_add_dependents(user_id, start_date)

The method will return True if the user can add dependents

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def can_add_dependents(self, user_id: str, start_date: date) -> bool:
    """The method will return True if the user can add dependents"""
    raise NotImplementedError()

contract_allows_partner

contract_allows_partner(user_id, at_date)

The method will return True if the primary's contract allows to add a partner

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def contract_allows_partner(self, user_id: str, at_date: date) -> bool:
    """The method will return True if the primary's contract allows to add a partner"""
    raise NotImplementedError()

create_dependent

create_dependent(user_id, payload)

The method will create the dependent for the primary user. Returns: The insurance profile ID of the created dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def create_dependent(
    self,
    user_id: str,
    payload: CreateDependentPayload,
) -> UUID:
    """
    The method will create the dependent for the primary user.
    Returns:
        The insurance profile ID of the created dependent.
    """
    raise NotImplementedError()

get_age_boundaries_by_dependent_type

get_age_boundaries_by_dependent_type(user_id, at_date=None)

The method will return the age boundaries of a dependent for the user Boundaries are included, meaning the dependent age should be withing those boundaries, including the boundaries.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_age_boundaries_by_dependent_type(
    self, user_id: str, at_date: date | None = None
) -> DependentsAgeBoundaries:
    """
    The method will return the age boundaries of a dependent for the user
    Boundaries are included, meaning the dependent age should be withing those boundaries,
    including the boundaries.
    """
    raise NotImplementedError()

get_child_account_minimum_age

get_child_account_minimum_age()

Returns the minimum age required for a child dependent to have an Alan account. Returns None if child dependents are not allowed to have accounts.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_child_account_minimum_age(self) -> int | None:
    """
    Returns the minimum age required for a child dependent to have an Alan account.
    Returns None if child dependents are not allowed to have accounts.
    """
    raise NotImplementedError()

get_coverage_module_choices

get_coverage_module_choices(user_id, at_date)

The method will return the coverage module choices for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_coverage_module_choices(
    self, user_id: str, at_date: date
) -> list[CoverageModuleInfo]:
    """
    The method will return the coverage module choices for the user.
    """
    raise NotImplementedError()

get_default_coverage_module

get_default_coverage_module(user_id, at_date)

Returns the default coverage module that will be applied to new dependents

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_default_coverage_module(
    self, user_id: str, at_date: date
) -> CoverageModuleInfo | None:
    """
    Returns the default coverage module that will be applied to new dependents
    """
    raise NotImplementedError()

get_health_contract_info

get_health_contract_info(
    user_id, on_date, new_dependent_birth_date=None
)

The method will return the user's health contract info, including affiliation delay if present

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_health_contract_info(
    self,
    user_id: str,
    on_date: date | None,
    new_dependent_birth_date: date | None = None,
) -> HealthContractInfo:
    """The method will return the user's health contract info, including affiliation delay if present"""
    raise NotImplementedError()

get_immediate_coverage_in_first_months

get_immediate_coverage_in_first_months()

The method will return if the dependent will be covered immediately in the first months of the primary's coverage.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_immediate_coverage_in_first_months(self) -> bool:
    """
    The method will return if the dependent will be covered immediately in the first months of the primary's coverage.
    """
    raise NotImplementedError()

get_minimum_coverage_months

get_minimum_coverage_months()

The method will return the minimum number of months of coverage required for the dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_minimum_coverage_months(self) -> int | None:
    """
    The method will return the minimum number of months of coverage required for the dependent.
    """
    raise NotImplementedError()

get_past_dependents

get_past_dependents(user_id, on_date)

This method will return the past dependents of the user, relative to the start date of the current or next affiliation on on_date. It will exclude dependents that are active on or after on_date.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_past_dependents(self, user_id: str, on_date: date) -> list[PastDependent]:
    """
    This method will return the past dependents of the user, relative to the start
    date of the current or next affiliation on on_date.
    It will exclude dependents that are active on or after on_date.
    """
    raise NotImplementedError()

get_possible_start_dates

get_possible_start_dates(
    user_id,
    new_dependent_birth_date,
    at_date=None,
    existing_dependent_user_id=None,
)

The method will return the possible coverage start dates for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_possible_start_dates(
    self,
    user_id: str,
    new_dependent_birth_date: date,
    at_date: date | None = None,
    existing_dependent_user_id: str | None = None,
) -> list[date]:
    """
    The method will return the possible coverage start dates for the user.
    """
    raise NotImplementedError()

get_prices_and_conditions_config

get_prices_and_conditions_config(user_id)

The method will return the features enablement for prices and conditions

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_prices_and_conditions_config(
    self, user_id: str
) -> PricesAndConditionsConfig:
    """The method will return the features enablement for prices and conditions"""
    raise NotImplementedError()

has_existing_partner

has_existing_partner(user_id, at_date=None)

The method will return True if the user has an existing partner TODO Maybe we actually want to embed this kind of logic/model inside the price itself We might need to display other information such as the maximum age of the children, etc... Let's see how it grows..

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def has_existing_partner(
    self,
    user_id: str,
    at_date: date | None = None,
) -> bool:
    """
    The method will return True if the user has an existing partner
    TODO Maybe we actually want to embed this kind of logic/model inside the price itself
    We might need to display other information such as the maximum age of the children, etc...
    Let's see how it grows..
    """
    raise NotImplementedError()

price_provider instance-attribute

price_provider = price_provider

require_coverage_module_choice

require_coverage_module_choice(user_id)

The method will return wether the add dependent flow requires the choice of a coverage option for the dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def require_coverage_module_choice(self, user_id: str) -> bool:
    """
    The method will return wether the add dependent flow requires the choice of a coverage option for the dependent.
    """
    raise NotImplementedError()

require_coverage_start_date_choice

require_coverage_start_date_choice()

The method will return wether the add dependent flow requires the choice of a coverage start date for the dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def require_coverage_start_date_choice(self) -> bool:
    """
    The method will return wether the add dependent flow requires the choice of a coverage start date for the dependent.
    """
    raise NotImplementedError()

require_gender

require_gender()

The method will return wether the add dependent flow requires a gender to be provided.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def require_gender(self) -> bool:
    """
    The method will return wether the add dependent flow requires a gender to be provided.
    """
    raise NotImplementedError()

MemberLifecycleDependency

MemberLifecycleDependency(add_dependents)

MemberLifecycleDependency defines the interface that apps using the member_lifecycle component need to implement

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def __init__(self, add_dependents: AddDependentsDependency):
    self.add_dependents = add_dependents

add_dependents instance-attribute

add_dependents = add_dependents

merge_users

merge_users(
    source_user_id, target_user_id, actor_id, commit=True
)

The method will merge the source user into the target user and return some logs about the changes

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def merge_users(
    self,
    source_user_id: str,
    target_user_id: str,
    actor_id: str | None,
    commit: bool = True,
) -> list[str]:
    """The method will merge the source user into the target user and return some logs about the changes"""
    raise NotImplementedError()

PastDependent dataclass

PastDependent(user_id, profile_id)

Represents dependent user information returned by the get_past_dependents method

profile_id instance-attribute

profile_id

user_id instance-attribute

user_id

set_app_dependency

set_app_dependency(dependency)

Sets the member_lifecycle dependency to the app so it can be accessed within this component at runtime

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def set_app_dependency(dependency: MemberLifecycleDependency) -> None:
    """Sets the member_lifecycle dependency to the app so it can be accessed within this component at runtime"""
    from flask import current_app

    cast("CustomFlask", current_app).add_component_dependency(
        MEMBER_LIFECYCLE_COMPONENT_NAME, dependency
    )

components.member_lifecycle.public.entities

AffiliationDelay dataclass

AffiliationDelay(
    threshold_months,
    duration_months,
    new_dependent_coverage_start_date=None,
)

Bases: DataClassJsonMixin

duration_months instance-attribute

duration_months

new_dependent_coverage_start_date class-attribute instance-attribute

new_dependent_coverage_start_date = None

threshold_months instance-attribute

threshold_months

AgeBoundaries dataclass

AgeBoundaries(min, max)

Bases: DataClassJsonMixin

Represents the price of a dependent.

max instance-attribute

max

min instance-attribute

min

CoverageModuleInfo dataclass

CoverageModuleInfo(
    coverage_module_name,
    coverages,
    is_upgrade,
    partner_price=None,
    child_price=None,
)

Bases: DataClassJsonMixin

child_price class-attribute instance-attribute

child_price = None

coverage_module_name instance-attribute

coverage_module_name

coverages instance-attribute

coverages

is_upgrade instance-attribute

is_upgrade

partner_price class-attribute instance-attribute

partner_price = None

CoverageType

Bases: AlanBaseEnum

CoverageType describes each class of guarantee.

Note: "ambulatory" means "daily care" + "dental".

ASSISTANCE_ABROAD class-attribute instance-attribute

ASSISTANCE_ABROAD = 'assistance_abroad'

DAILY_CARE class-attribute instance-attribute

DAILY_CARE = 'ambulatory'

DENTAL class-attribute instance-attribute

DENTAL = 'dental'

HOSPITALIZATION class-attribute instance-attribute

HOSPITALIZATION = 'hospitalization'

PRE_POST class-attribute instance-attribute

PRE_POST = 'pre_post'

SEVERE_ILLNESS class-attribute instance-attribute

SEVERE_ILLNESS = 'severe_illness'

CreateDependentPayload dataclass

CreateDependentPayload(
    dependent_user_id,
    first_name,
    last_name,
    birth_date,
    gender,
    coverage_start_date,
    type,
    coverage_module_name,
)

birth_date instance-attribute

birth_date

coverage_module_name instance-attribute

coverage_module_name

coverage_start_date instance-attribute

coverage_start_date

dependent_user_id instance-attribute

dependent_user_id

first_name instance-attribute

first_name

gender class-attribute instance-attribute

gender = field(metadata={'by_value': True})

last_name instance-attribute

last_name

type instance-attribute

type

DependentSpecs dataclass

DependentSpecs(
    dependent_birthdate,
    dependent_type,
    dependent_coverage_module_name=None,
)

dependent_birthdate instance-attribute

dependent_birthdate

dependent_coverage_module_name class-attribute instance-attribute

dependent_coverage_module_name = None

dependent_type instance-attribute

dependent_type

DependentsAgeBoundaries dataclass

DependentsAgeBoundaries(partner, child)

Bases: DataClassJsonMixin

Represents the prices of dependents.

child instance-attribute

child

partner instance-attribute

partner

DependentsParticipation dataclass

DependentsParticipation(company_name, unit, partner, child)

Bases: DataClassJsonMixin

Represents the participation for each type of dependent.

child instance-attribute

child

company_name instance-attribute

company_name

partner instance-attribute

partner

unit instance-attribute

unit

DependentsPrices dataclass

DependentsPrices(partner, child)

Bases: DataClassJsonMixin

Represents the prices of dependents.

child instance-attribute

child

partner instance-attribute

partner

HealthContractInfo dataclass

HealthContractInfo(
    dependents_participation,
    waiting_period,
    affiliation_delay,
    primary_coverage_start_date,
    is_direct_billing,
)

Bases: DataClassJsonMixin

The fields will be None if the information cannot be matched to the expected dataclass.

affiliation_delay instance-attribute

affiliation_delay

dependents_participation instance-attribute

dependents_participation

is_direct_billing instance-attribute

is_direct_billing

primary_coverage_start_date instance-attribute

primary_coverage_start_date

waiting_period instance-attribute

waiting_period

NewDependentsPriceBreakdown dataclass

NewDependentsPriceBreakdown(
    total_policy_price, new_dependent_price
)

Bases: DataClassJsonMixin

Represents the price breakdown for a new dependent.

new_dependent_price instance-attribute

new_dependent_price

total_policy_price instance-attribute

total_policy_price

The total price of all the policy members + new dependent

Price dataclass

Price(
    currency, amount=None, min_amount=None, max_amount=None
)

Bases: DataClassJsonMixin

Source code in components/member_lifecycle/subcomponents/prices/internal/domain/entities/dependent_price.py
def __init__(
    self,
    currency: str,
    amount: Optional[AmountInCents] = None,
    min_amount: Optional[AmountInCents] = None,
    max_amount: Optional[AmountInCents] = None,
):
    if amount is not None:
        self.min_amount = self.max_amount = amount
    elif min_amount is not None and max_amount is not None:
        self.min_amount = min_amount
        self.max_amount = max_amount
    else:
        raise ValueError(
            "Provide either `amount` or both (`min_amount` and `max_amount`)."
        )
    self.currency = currency
    self.__post_init__()

__post_init__

__post_init__()
Source code in components/member_lifecycle/subcomponents/prices/internal/domain/entities/dependent_price.py
def __post_init__(self) -> None:
    self.is_fixed_price = self.min_amount == self.max_amount
    self.is_free = self.min_amount == 0 and self.max_amount == 0

currency instance-attribute

currency = currency

is_fixed_price class-attribute instance-attribute

is_fixed_price = field(init=False)

is_free class-attribute instance-attribute

is_free = field(init=False)

max_amount instance-attribute

max_amount

min_amount instance-attribute

min_amount

PricesAndConditionsConfig dataclass

PricesAndConditionsConfig(
    child_covered_until_max_age,
    membership,
    fr_social_security,
    be_social_security,
    be_fiscally_dependent_age,
)

Bases: DataClassJsonMixin

Configuration for the PricesAndConditions component.

be_fiscally_dependent_age instance-attribute

be_fiscally_dependent_age

be_social_security instance-attribute

be_social_security

child_covered_until_max_age instance-attribute

child_covered_until_max_age

fr_social_security instance-attribute

fr_social_security

membership instance-attribute

membership

WaitingPeriod dataclass

WaitingPeriod(
    duration_in_months,
    start_date=isodate_field(),
    end_date=isodate_field(),
)

Bases: DataClassJsonMixin

Represents the waiting period for health contract.

duration_in_months instance-attribute

duration_in_months

end_date class-attribute instance-attribute

end_date = isodate_field()

start_date class-attribute instance-attribute

start_date = isodate_field()

components.member_lifecycle.public.ports

PriceProvider

get_dependents_price_breakdown

get_dependents_price_breakdown(
    user_id, dependent_specs, on_date=None
)

Returns the price breakdown for a new dependent. This is used to display the prices when adding a new dependent.

Source code in components/member_lifecycle/subcomponents/prices/internal/domain/ports/price_provider.py
def get_dependents_price_breakdown(
    self,
    user_id: str,
    dependent_specs: DependentSpecs,
    on_date: Optional[date] = None,
) -> NewDependentsPriceBreakdown:
    """
    Returns the price breakdown for a new dependent.
    This is used to display the prices when adding a new dependent.
    """
    raise NotImplementedError()

get_dependents_prices

get_dependents_prices(user_id, on_date=None)

Returns the prices for all potential dependents of a user.

Source code in components/member_lifecycle/subcomponents/prices/internal/domain/ports/price_provider.py
def get_dependents_prices(
    self, user_id: str, on_date: Optional[date] = None
) -> DependentsPrices:
    """
    Returns the prices for all potential dependents of a user.
    """
    raise NotImplementedError()