Skip to content

Api reference

components.claims_guarantees.public.api

create_internal_care_type_and_process_changes

create_internal_care_type_and_process_changes(
    create_input,
    country,
    skip_mapping_update=False,
    commit=True,
)

Create a new internal care type and associate it with the given groups. It'll also trigger updates to the Internal care type to guarantee mapping.

Source code in components/claims_guarantees/public/api.py
def create_internal_care_type_and_process_changes(
    create_input: CreateInternalCareTypeInput,
    country: Country,
    skip_mapping_update: bool = False,
    commit: bool = True,
) -> None:
    """
    Create a new internal care type and associate it with the given groups.
    It'll also trigger updates to the Internal care type to guarantee mapping.
    """
    create_internal_care_type(create_input=create_input, country=country, commit=commit)

    if skip_mapping_update:
        current_logger.info("⚠️ Skipping mapping update")
        return

    load_claims_guarantees_mappings(country=country, commit=commit)

filter_guarantees_for_member_by_age

filter_guarantees_for_member_by_age(
    internal_health_guarantee_short_codes,
    age,
    country,
    on_date,
)

Return the subset of input short codes for which at least one of the guarantee's coverage mappings (active on on_date, in country) has age filters compatible with the given age.

Source code in components/claims_guarantees/public/api.py
def filter_guarantees_for_member_by_age(
    internal_health_guarantee_short_codes: list[str],
    age: int,
    country: Country,
    on_date: datetime.date,
) -> set[str]:
    """Return the subset of input short codes for which at least one of the
    guarantee's coverage mappings (active on `on_date`, in `country`) has age
    filters compatible with the given age.
    """
    return _filter_guarantees_for_member_by_age(
        internal_health_guarantee_short_codes=internal_health_guarantee_short_codes,
        age=age,
        country=country,
        on_date=on_date,
    )

get_care_type_short_codes_mapped_to_guarantees

get_care_type_short_codes_mapped_to_guarantees(
    guarantee_short_codes, country
)

Return the short codes of internal care types mapped to any of the given claims guarantees (any date).

Source code in components/claims_guarantees/public/api.py
def get_care_type_short_codes_mapped_to_guarantees(
    guarantee_short_codes: set[str], country: Country
) -> set[str]:
    """Return the short codes of internal care types mapped to any of the given
    claims guarantees (any date).
    """
    return get_all_care_type_short_codes_mapped_to_guarantees(
        guarantee_short_codes=guarantee_short_codes, country=country
    )

get_care_type_short_codes_with_filter_type_constraint

get_care_type_short_codes_with_filter_type_constraint(
    filter_type, country
)

Return all the short codes of internal care types that have at least one guarantee mapping carrying the given filter type (any value, any date).

Source code in components/claims_guarantees/public/api.py
def get_care_type_short_codes_with_filter_type_constraint(
    filter_type: MappingFilterType, country: Country
) -> set[str]:
    """Return all the short codes of internal care types that have at least one
    guarantee mapping carrying the given filter type (any value, any date).
    """
    return get_care_type_short_codes_with_filter_type(
        filter_type=filter_type, country=country
    )

get_claims_guarantees_for_care_type

get_claims_guarantees_for_care_type(
    internal_care_type_short_code,
    country,
    on_date,
    care_context,
)

Return claims guarantees mapped to a care type, valid on a given date and for a list of given filters.

Source code in components/claims_guarantees/public/api.py
def get_claims_guarantees_for_care_type(
    internal_care_type_short_code: str,
    country: Country,
    on_date: datetime.date,
    care_context: CareContext,
) -> ClaimsGuaranteeForInternalCareType:
    """Return claims guarantees mapped to a care type, valid on a given date and for a list of given filters."""
    return get_claims_guarantees_for_care_type_given_care_context(
        internal_care_type_short_code=internal_care_type_short_code,
        country=country,
        on_date=on_date,
        care_context=care_context,
    )

components.claims_guarantees.public.commands

components.claims_guarantees.public.dependencies

COMPONENT_NAME module-attribute

COMPONENT_NAME = 'claims_guarantees'

ClaimsGuaranteesDependency

Bases: ABC

Abstract dependency for the claims_guarantees component.

get_country_code abstractmethod

get_country_code()

Return the country code for the current app.

Source code in components/claims_guarantees/public/dependencies.py
@abstractmethod
def get_country_code(self) -> Country:
    """Return the country code for the current app."""

get_app_dependency

get_app_dependency()

Retrieve the claims_guarantees dependency from the current Flask app.

Source code in components/claims_guarantees/public/dependencies.py
def get_app_dependency() -> ClaimsGuaranteesDependency:
    """Retrieve the claims_guarantees dependency from the current Flask app."""
    from flask import current_app

    return cast("CustomFlask", current_app).get_component_dependency(COMPONENT_NAME)  # type: ignore[no-any-return]

set_app_dependency

set_app_dependency(dependency)

Register the claims_guarantees dependency on the current Flask app.

Source code in components/claims_guarantees/public/dependencies.py
def set_app_dependency(dependency: ClaimsGuaranteesDependency) -> None:
    """Register the claims_guarantees dependency on the current Flask app."""
    from flask import current_app

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

components.claims_guarantees.public.entities

CareContext dataclass

CareContext(
    *,
    age_on_care_date=None,
    is_reimbursed_by_secu=None,
    is_in_network=None,
    is_optam_or_secteur_1=None,
    practitioner=None,
    glasses_lens_complexity=None,
    treatment_mode=None,
    nature_de_soins=None,
    is_etablissement_conventionne=None,
    is_for_at_least_one_visible_tooth=None
)

Caller-provided context about a care act, used to filter guarantee mappings.

age_on_care_date class-attribute instance-attribute

age_on_care_date = None

glasses_lens_complexity class-attribute instance-attribute

glasses_lens_complexity = None

is_etablissement_conventionne class-attribute instance-attribute

is_etablissement_conventionne = None

is_for_at_least_one_visible_tooth class-attribute instance-attribute

is_for_at_least_one_visible_tooth = None

is_in_network class-attribute instance-attribute

is_in_network = None

is_optam_or_secteur_1 class-attribute instance-attribute

is_optam_or_secteur_1 = None

is_reimbursed_by_secu class-attribute instance-attribute

is_reimbursed_by_secu = None

nature_de_soins class-attribute instance-attribute

nature_de_soins = None

practitioner class-attribute instance-attribute

practitioner = None

treatment_mode class-attribute instance-attribute

treatment_mode = None

ClaimsGuaranteeForInternalCareType dataclass

ClaimsGuaranteeForInternalCareType(
    *,
    internal_care_type_short_code,
    country,
    claims_guarantees_short_codes,
    excluded_claims_guarantees
)

Claims guarantees mapped to an internal care type.

claims_guarantees_short_codes instance-attribute

claims_guarantees_short_codes

country instance-attribute

country

excluded_claims_guarantees instance-attribute

excluded_claims_guarantees

internal_care_type_short_code instance-attribute

internal_care_type_short_code

CreateInternalCareTypeInput dataclass

CreateInternalCareTypeInput(
    *,
    short_code,
    name,
    is_secondary,
    internal_care_type_group_short_codes,
    start_date=datetime.date.today(),
    end_date=None
)

Input for creating a new internal care type.

end_date class-attribute instance-attribute

end_date = None

internal_care_type_group_short_codes instance-attribute

internal_care_type_group_short_codes

is_secondary instance-attribute

is_secondary

name instance-attribute

name

short_code instance-attribute

short_code

start_date class-attribute instance-attribute

start_date = field(default_factory=today)

ExcludedClaimsGuarantee dataclass

ExcludedClaimsGuarantee(
    *,
    claims_guarantee_short_code,
    mismatch_filters,
    missing_data_filters
)

A guarantee excluded during filter matching.

claims_guarantee_short_code instance-attribute

claims_guarantee_short_code

mismatch_filters instance-attribute

mismatch_filters

missing_data_filters instance-attribute

missing_data_filters

components.claims_guarantees.public.enums

CLAIMS_GUARANTEES_SUPPORTED_COUNTRIES module-attribute

CLAIMS_GUARANTEES_SUPPORTED_COUNTRIES = [Ca, Fr]

GlassesLensComplexity

Bases: AlanBaseEnum

The complexity of glasses lenses.

one_complex_multifocal_one_very_complex class-attribute instance-attribute

one_complex_multifocal_one_very_complex = (
    "one_complex_multifocal_one_very_complex"
)

one_complex_one_very_complex class-attribute instance-attribute

one_complex_one_very_complex = (
    "one_complex_one_very_complex"
)

one_complex_unifocal_one_complex_multifocal class-attribute instance-attribute

one_complex_unifocal_one_complex_multifocal = (
    "one_complex_unifocal_one_complex_multifocal"
)

one_complex_unifocal_one_very_complex class-attribute instance-attribute

one_complex_unifocal_one_very_complex = (
    "one_complex_unifocal_one_very_complex"
)

one_simple_one_complex class-attribute instance-attribute

one_simple_one_complex = 'one_simple_one_complex'

one_simple_one_complex_multifocal class-attribute instance-attribute

one_simple_one_complex_multifocal = (
    "one_simple_one_complex_multifocal"
)

one_simple_one_complex_unifocal class-attribute instance-attribute

one_simple_one_complex_unifocal = (
    "one_simple_one_complex_unifocal"
)

one_simple_one_very_complex class-attribute instance-attribute

one_simple_one_very_complex = 'one_simple_one_very_complex'

two_complex class-attribute instance-attribute

two_complex = 'two_complex'

two_complex_multifocal class-attribute instance-attribute

two_complex_multifocal = 'two_complex_multifocal'

two_complex_unifocal class-attribute instance-attribute

two_complex_unifocal = 'two_complex_unifocal'

two_simple class-attribute instance-attribute

two_simple = 'two_simple'

two_very_complex class-attribute instance-attribute

two_very_complex = 'two_very_complex'

MappingFilterType

Bases: AlanBaseEnum

Type of filter applied to a care-type-to-guarantee mapping.

allowed_natures_de_soins class-attribute instance-attribute

allowed_natures_de_soins = 'allowed_natures_de_soins'

allowed_treatment_modes class-attribute instance-attribute

allowed_treatment_modes = 'allowed_treatment_modes'

glasses_lens_complexities class-attribute instance-attribute

glasses_lens_complexities = 'glasses_lens_complexities'

is_etablissement_conventionne class-attribute instance-attribute

is_etablissement_conventionne = (
    "is_etablissement_conventionne"
)

is_for_at_least_one_visible_tooth class-attribute instance-attribute

is_for_at_least_one_visible_tooth = (
    "is_for_at_least_one_visible_tooth"
)

is_in_network class-attribute instance-attribute

is_in_network = 'is_in_network'

is_optam_or_secteur_1 class-attribute instance-attribute

is_optam_or_secteur_1 = 'is_optam_or_secteur_1'

is_reimbursed_by_secu class-attribute instance-attribute

is_reimbursed_by_secu = 'is_reimbursed_by_secu'

max_age class-attribute instance-attribute

max_age = 'max_age'

min_age class-attribute instance-attribute

min_age = 'min_age'

practitioner class-attribute instance-attribute

practitioner = 'practitioner'

NatureDeSoins

Bases: AlanBaseEnum

The natures de soins group different DMT (Discipline Medico Tarifaire). This is used to map hospital guarantees more accurately # (eg. make the distinction between a CPC in hospi / maternity)

From https://docs.google.com/spreadsheets/d/1Q0eQyHvB1y0yu3P5CqPiICLOcn_jbmpBqCfOpTbZ4vY/edit#gid=1477303808 ⧉

autres class-attribute instance-attribute

autres = 'autres'

chirurgie class-attribute instance-attribute

chirurgie = 'chirurgie'

medecine class-attribute instance-attribute

medecine = 'medecine'

obstetrie class-attribute instance-attribute

obstetrie = 'obstetrie'

psychiatrie class-attribute instance-attribute

psychiatrie = 'psychiatrie'

ssr class-attribute instance-attribute

ssr = 'ssr'

Practitioner

Bases: AlanBaseEnum

One should be careful when adding a new value here. Question to ask ourself : does it create new guarantees mappings, does it create new display mappings, does it affect insurance documents that can be considered as from the same source ?

dental class-attribute instance-attribute

dental = 'dental'

hospital class-attribute instance-attribute

hospital = 'hospital'

maternity class-attribute instance-attribute

maternity = 'maternity'

other class-attribute instance-attribute

other = 'other'

TreatmentMode

Bases: AlanBaseEnum

List all the possible treatment modes

see https://docs.google.com/spreadsheets/d/1Q0eQyHvB1y0yu3P5CqPiICLOcn_jbmpBqCfOpTbZ4vY/edit#gid=1740869859 ⧉ and in the CDC https://www.ameli.fr/sites/default/files/Documents/CDC-NOEMIE-OC-version-mars-2024.pdf ⧉

MT03 class-attribute instance-attribute

MT03 = '03'

MT04 class-attribute instance-attribute

MT04 = '04'

MT05 class-attribute instance-attribute

MT05 = '05'

MT06 class-attribute instance-attribute

MT06 = '06'

MT07 class-attribute instance-attribute

MT07 = '07'

MT10 class-attribute instance-attribute

MT10 = '10'

MT11 class-attribute instance-attribute

MT11 = '11'

MT12 class-attribute instance-attribute

MT12 = '12'

MT13 class-attribute instance-attribute

MT13 = '13'

MT14 class-attribute instance-attribute

MT14 = '14'

MT15 class-attribute instance-attribute

MT15 = '15'

MT16 class-attribute instance-attribute

MT16 = '16'

MT17 class-attribute instance-attribute

MT17 = '17'

MT19 class-attribute instance-attribute

MT19 = '19'

MT20 class-attribute instance-attribute

MT20 = '20'

MT21 class-attribute instance-attribute

MT21 = '21'

MT22 class-attribute instance-attribute

MT22 = '22'

MT23 class-attribute instance-attribute

MT23 = '23'

MT24 class-attribute instance-attribute

MT24 = '24'

MT35 class-attribute instance-attribute

MT35 = '35'

MT37 class-attribute instance-attribute

MT37 = '37'

MT38 class-attribute instance-attribute

MT38 = '38'

MT39 class-attribute instance-attribute

MT39 = '39'

MT40 class-attribute instance-attribute

MT40 = '40'