Skip to content

⚠️ note: this document is mostly about the legacy/fr-only offer builder, while some concepts translate to the global offer builder; proceed with caution

Offer Builder

This package is used to build health and prevoyance offers.

An offer is made of:

  • A coverage, ie a list of guarantees with their corresponding reimbursement rules
  • A price

How to install

Load the builder tables data

The builder data are stored in csv and can be loaded with the loader commands β§‰:

flask load_all_builder_data --execute

Alternatively, you can load each table one by one (see the command's code).

In addition to that, some data lives in Turing and needs to be available for signature coverage related features.

  1. The demographics models, one for a company, one for an industry
  2. The signature coverages, one per CCN, per coverage level
  3. The signature coverages prices, one per price structure, per signature coverage

To import them:

# 1. You might need to update the demographics-model-version option.
flask load_demographics_model_from_turing --demographics-model-version=2023.12 --execute
flask load_nominal_demographics_from_turing --demographics-model-version=2023.12 --execute

# 2. It can take a while so you can specify one or many space-separated CCN codes.
flask load_signature_coverages --execute 1486

Note: Don't forget --use-kay=personal if you're working with your local kay.

To use the pricer (in the offer builder or end-to-end tests)

The easiest way to get the pre-calculated data from the production DB to be able to compute accurate prices is to load the pricer_pure_premium table in your Kay DB with this command:

flask kay refresh --profile standard

Alternatively, you can use the flask kay trigger_custom_import -i pricer_pure_premium command to load the pricer_pure_premium table, but it is slower than the above command.

If you want to use the latest version directly from Turing (which may return different prices than the current version in prod), you can use USE_TURING_IN_PRICER=true.

Concept pre-requisites

Generic guarantees set

The system is based on this important notion:
We have a list of guarantees (the "generic guarantees set") for which we have defined a fixed mapping with care types.

When we want to have two overlapping groups of care types (ex: CONTRACEPTION and PHARAMCY_NON_REIMBURSABLE), we create two guarantees and we enforce that we can't cover both on the same coverage.

This mapping is defined is the HEALTH_GUARANTEES_TO_MAPPINGS (in health_guarantees_to_mappings.py).

Formulas

A formula is a way to cover a guarantee (ex: we can cover either a percentage of the BRSS "Base de Remboursement de la SΓ©curitΓ© Sociale" or a forfait).

For each guarantee we define one only (at least for now) formula that we can use to cover this guarantee.

This definition is done in the table β§‰ BuilderGuaranteeAllowedFormula

Special case: selectable care types

There's one special case for which we couldn't follow the fixed guarantee - care type mapping.
For the alternative medicines, we want to be able to choose between 7 practitioners. Making one guarantee for each possible combination would create too many guarantees.

To manage this case, we introduced the notion of "selectable care types".
It's a boolean we set at the guarantee level (in the GenericHealthGuarantee table β§‰) to indicate that for this guarantee, the guarantee - care type mapping can vary.

Constraints

Each guarantee also has to follow a set of constraints on the amounts to be reimbursed (for a responsible constraint, or upper limits we do not wish to go above). The union of a guarantee, a formula and its constraints is stored inside the BuilderGuaranteeAllowedFormula table β§‰.

The constraints themselves are defined inside the builder_guarantee_allowed_formula.csv β§‰, and use this spreadsheet β§‰ as a source of truth.

Building Offers

The starting point is the BuilderProduct but the information is saved at version level in the BuilderProductVersion class.

A product version defines, via a relation to the BuilderCoverage table:

  • the list of guarantees it covers (from the generic guarantees set) with the associated coverage level (in the BuilderProductCoverageRule table β§‰)
  • the selected care types if any (in the BuilderProductSelectedCareType table β§‰)

For now, only the current (last) version is taken into account, the others are here only for traceability.

The pricer