Api reference
components.guarantee_catalog.public.commands ¶
sync_guarantee_catalog ¶
guarantee_catalog
module-attribute
¶
guarantee_catalog = AppGroup(
name="guarantee_catalog",
help="Main command group for the Guarantee Catalog component",
)
sync_guarantee_catalog ¶
Synchronize guarantee catalog from YAML configuration to database.
This command: 1. Reads the guarantee catalog configuration from guarantees.yaml 2. Validates the structure and relationships of the configuration 3. Clears existing guarantee catalog entries from the database 4. Stores the new configuration in the database
The --dry-run flag can be used to validate and test the sync without committing changes.
This command is typically run as a scheduled task to ensure the database reflects the latest guarantee catalog configuration.
Source code in components/guarantee_catalog/public/commands/sync_guarantee_catalog.py
components.guarantee_catalog.public.dependencies ¶
GuaranteeCatalogDependency ¶
Bases: ABC
get_country_code
abstractmethod
¶
get_guarantee_yaml_file_path
abstractmethod
¶
validate_coverage_relationship ¶
Validates the relationship between the source and target coverage rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
list[CoverageRule]
|
Coverage rules with index n-1 |
required |
target
|
list[CoverageRule]
|
Coverage rules with index n |
required |
Note: This method won't be called for the first coverage (index 0).
Each country has its own set of rules for coverage relationships. For example, in France, it is required that coverage n+1 provides better benefits than coverage n.
Returns:
| Type | Description |
|---|---|
list[GuaranteeCatalogError]
|
A list of GuaranteeCatalogError objects if validation fails. |
Source code in components/guarantee_catalog/public/dependencies.py
validate_coverage_rules ¶
Validates country-specific coverage rules for a given coverage against guarantee definitions.
Source code in components/guarantee_catalog/public/dependencies.py
get_app_dependency ¶
set_app_dependency ¶
components.guarantee_catalog.public.entities ¶
coverage_rules ¶
CoverageRule ¶
Bases: CoverageRuleBaseModel
Model representing an instantiated guarantee (coverage rule) with its chosen expression type, parameters and optional eligibility items.
CoverageRuleBaseModel ¶
CoverageRuleParameter ¶
Bases: CoverageRuleBaseModel
Model representing a parameter value for a coverage rule.
CoverageRuleValidationContext
dataclass
¶
CoverageRuleValidationContext(
guarantee_business_id=None,
bundle_choice_business_id=None,
category_business_id=None,
parameter_type=None,
)
Bases: DataClassJsonMixin
Context information for a coverage rule validation error.
InstantiatedBundleChoiceParameter ¶
InstantiatedCategoryParameter ¶
ValidateCoverageRulesRequest ¶
Bases: CoverageRuleBaseModel
Model representing a request to validate a set of coverage rules.
Includes: - List of coverage rules - Propagated parameters for bundle choices and categories - Aggregated limit parameters for bundle choices and categories - Selected category IDs to validate required coverage rules
errors ¶
GuaranteeCatalogError ¶
GuaranteeCatalogError(
error_type,
description,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
param_type=None,
**kwargs
)
Bases: BaseErrorCode
Error class for guarantee catalog validation failures.
Initialize a guarantee catalog error with type and description.
Source code in components/guarantee_catalog/public/entities/errors.py
bundle_choice_not_found
classmethod
¶
Create error for non-existent bundle choice.
Source code in components/guarantee_catalog/public/entities/errors.py
duplicate_guarantee
classmethod
¶
Create error for duplicate guarantee in bundle choice.
Source code in components/guarantee_catalog/public/entities/errors.py
duplicate_parameter
classmethod
¶
duplicate_parameter(
param_type,
level_name,
identifier,
is_limit=False,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for duplicate parameters within the same level.
Source code in components/guarantee_catalog/public/entities/errors.py
exactly_one_bundle_choice_required
classmethod
¶
Create error for incompatible bundle choice.
Source code in components/guarantee_catalog/public/entities/errors.py
fr_builder_coverage_lower_level_than_source
classmethod
¶
fr_builder_coverage_lower_level_than_source(
guarantee_id,
bundle_choice_id,
description,
missing_eligibility_items=None,
param_type=None,
)
Create error for target coverage less premium than source.
Source code in components/guarantee_catalog/public/entities/errors.py
fr_builder_coverage_lower_than_source
classmethod
¶
Create error for target coverage less premium than source.
Source code in components/guarantee_catalog/public/entities/errors.py
guarantee_from_unselected_category
classmethod
¶
Create error for guarantee from unselected category.
Source code in components/guarantee_catalog/public/entities/errors.py
guarantee_not_found
classmethod
¶
Create error for non-existent guarantee.
Source code in components/guarantee_catalog/public/entities/errors.py
guarantee_not_in_bundle_choice
classmethod
¶
Create error for guarantee that doesn't belong to the specified bundle choice.
Source code in components/guarantee_catalog/public/entities/errors.py
invalid_parameter_format
classmethod
¶
invalid_parameter_format(
param_type,
level_name,
identifier,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for invalid parameter format.
Source code in components/guarantee_catalog/public/entities/errors.py
mandatory_bundle_missing
classmethod
¶
Create error for missing mandatory bundle.
Source code in components/guarantee_catalog/public/entities/errors.py
missing_bundle_choice_guarantee
classmethod
¶
Create error for missing guarantee from bundle choice.
Source code in components/guarantee_catalog/public/entities/errors.py
missing_mandatory_eligibility_item
classmethod
¶
Create error for missing mandatory eligibility items.
Source code in components/guarantee_catalog/public/entities/errors.py
missing_parameter
classmethod
¶
missing_parameter(
missing_types,
level_name,
identifier,
param_type,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for missing required parameters.
Source code in components/guarantee_catalog/public/entities/errors.py
missing_propagated_limit
classmethod
¶
Create error for missing propagated limit parameter.
Source code in components/guarantee_catalog/public/entities/errors.py
multiple_bundle_choices
classmethod
¶
Create error for multiple bundle choices selected from same bundle.
Source code in components/guarantee_catalog/public/entities/errors.py
no_eligibility_items_selected
classmethod
¶
Create error if no eligibility items are selected.
Source code in components/guarantee_catalog/public/entities/errors.py
parameter_below_business_min
classmethod
¶
parameter_below_business_min(
param_type,
level_name,
identifier,
min_value,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for parameter below business minimum.
Source code in components/guarantee_catalog/public/entities/errors.py
parameter_below_pricer_min
classmethod
¶
parameter_below_pricer_min(
param_type,
level_name,
identifier,
min_value,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for parameter below pricer minimum.
Source code in components/guarantee_catalog/public/entities/errors.py
parameter_exceeds_business_max
classmethod
¶
parameter_exceeds_business_max(
param_type,
level_name,
identifier,
max_value,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for parameter exceeding business maximum.
Source code in components/guarantee_catalog/public/entities/errors.py
parameter_exceeds_fiscal_max
classmethod
¶
parameter_exceeds_fiscal_max(
param_type,
level_name,
identifier,
max_value,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for parameter exceeding fiscal maximum.
Source code in components/guarantee_catalog/public/entities/errors.py
parameter_exceeds_pricer_max
classmethod
¶
parameter_exceeds_pricer_max(
param_type,
level_name,
identifier,
max_value,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for parameter exceeding pricer maximum.
Source code in components/guarantee_catalog/public/entities/errors.py
unexpected_parameter
classmethod
¶
unexpected_parameter(
param_type,
level_name,
identifier,
guarantee_id=None,
bundle_choice_id=None,
category_id=None,
)
Create error for unexpected parameter that wasn't defined.
Source code in components/guarantee_catalog/public/entities/errors.py
unexpected_parameter_source
classmethod
¶
Create error for unexpected constant or propagated parameter.
Source code in components/guarantee_catalog/public/entities/errors.py
unknown_eligibility_item
classmethod
¶
Create error for unknown eligibility item.
Source code in components/guarantee_catalog/public/entities/errors.py
unsupported_expression_type
classmethod
¶
Create error for unsupported expression type.
Source code in components/guarantee_catalog/public/entities/errors.py
GuaranteeCatalogErrorType ¶
Bases: AlanBaseEnum
Error types for guarantee catalog validation.
bundle_choice_not_found
class-attribute
instance-attribute
¶
duplicate_guarantee
class-attribute
instance-attribute
¶
duplicate_parameter
class-attribute
instance-attribute
¶
exactly_one_bundle_choice_required
class-attribute
instance-attribute
¶
fr_builder_coverage_lower_level_than_source
class-attribute
instance-attribute
¶
fr_builder_coverage_lower_than_source
class-attribute
instance-attribute
¶
guarantee_from_unselected_category
class-attribute
instance-attribute
¶
guarantee_not_found
class-attribute
instance-attribute
¶
guarantee_not_in_bundle_choice
class-attribute
instance-attribute
¶
invalid_parameter_format
class-attribute
instance-attribute
¶
mandatory_bundle_missing
class-attribute
instance-attribute
¶
missing_bundle_choice_guarantee
class-attribute
instance-attribute
¶
missing_mandatory_eligibility_item
class-attribute
instance-attribute
¶
missing_propagated_limit
class-attribute
instance-attribute
¶
multiple_bundle_choices
class-attribute
instance-attribute
¶
no_eligibility_item_selected
class-attribute
instance-attribute
¶
parameter_below_business_min
class-attribute
instance-attribute
¶
parameter_below_pricer_min
class-attribute
instance-attribute
¶
parameter_exceeds_business_max
class-attribute
instance-attribute
¶
parameter_exceeds_fiscal_max
class-attribute
instance-attribute
¶
parameter_exceeds_pricer_max
class-attribute
instance-attribute
¶
unexpected_parameter
class-attribute
instance-attribute
¶
unexpected_parameter_source
class-attribute
instance-attribute
¶
unknown_eligibility_item
class-attribute
instance-attribute
¶
unsupported_expression_type
class-attribute
instance-attribute
¶
guarantee_definition ¶
Bundle
dataclass
¶
Bases: DataClassJsonMixin
A guarantee bundle.
Contains multiple bundle choices.
BundleChoice
dataclass
¶
BundleChoice(
*,
business_identifier,
guarantees,
display_name=None,
premiumness=None,
propagated_parameters=list(),
aggregated_limit_parameters=list(),
is_default,
status
)
Category
dataclass
¶
Category(
*,
business_identifier,
bundles,
display_name=None,
propagated_parameters=list(),
aggregated_limit_parameters=list()
)
Guarantee
dataclass
¶
Guarantee(
*,
business_identifier,
expressions,
display_name=None,
tax_bracket_tag=None,
metadata=None,
eligibility_items=list()
)
Bases: DataClassJsonMixin
A guarantee, ie a representation of a (Alan-defined) type of care.
Contains all information needed to define a guarantee including its expressions and eligibility items.
__post_init__ ¶
Dataclass post-initialization hook.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
eligibility_items
class-attribute
instance-attribute
¶
get_expression ¶
Get an expression by its type.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
GuaranteeCatalog
dataclass
¶
Bases: DataClassJsonMixin
A guarantee catalog.
Contains all guarantees.
- Guarantees are regrouped into categories->bundles->bundle_choices->guarantees.
- Each guarantee can be in several bundle_choices. However, a guarantee can be in only one bundle and only one category.
- By transition:
- Each bundle_choice is in exactly one bundle.
- Each bundle is in exactly one category.
__post_init__ ¶
Dataclass post-initialization hook.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
get_bundle_by_guarantee ¶
Get the bundle containing a given guarantee.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
get_bundle_choices_by_guarantee ¶
Get all bundle choices for a given guarantee.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
get_category_by_guarantee ¶
Get the category containing a given guarantee.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
get_guarantee ¶
Get a guarantee by its identifier.
Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
get_guarantee_or_none ¶
Get a guarantee by its identifier if it exists.
GuaranteeEligibilityItem
dataclass
¶
Bases: DataClassJsonMixin
An eligibility item for a guarantee.
Defines what the guarantee applies to.
An eligibility item can be optional (guarantee must cover it) or not (guarantee may or may not cover it).
GuaranteeExpression
dataclass
¶
Bases: DataClassJsonMixin
A guarantee expression.
Defines how a guarantee is reimbursed using a specific type and optional parameters.
GuaranteeParameter
dataclass
¶
GuaranteeParameter(
*,
type,
source,
business_min=None,
business_max=None,
fiscal_max=None,
pricer_min=None,
pricer_max=None,
pricer_step=None,
constant_value=None
)
Bases: DataClassJsonMixin
A parameter for a guarantee expression.
components.guarantee_catalog.public.enums ¶
guarantee_expression_type ¶
GuaranteeExpressionType ¶
Bases: AlanBaseEnum
Enumeration of all possible guarantee expression types. Defines how a guarantee's reimbursement is calculated.
cumulative_copayment
class-attribute
instance-attribute
¶
cumulative_limit_per_side
class-attribute
instance-attribute
¶
get_before_and_after_parameter_types
classmethod
¶
Returns the before and after parameter types (if any) for a given expression type.
Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
get_pricer_main_and_extra_param_types
classmethod
¶
Returns the main and extra parameter types used by the pricer for a given expression type.
The pricer uses these parameters as inputs to compute pure premiums for guarantees: - main_parameter_type: The primary parameter that affects the pure premium calculation - extra_parameter_type: An optional secondary parameter that may also influence the calculation
For example, for percent_reimbursement_ss: - main_parameter_type is percent_reimbursement_ss - no extra_parameter_type is needed The pure premium will depend only on the value of percent_reimbursement_ss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression_type
|
GuaranteeExpressionType
|
The type of guarantee expression |
required |
Returns:
| Type | Description |
|---|---|
GuaranteeParameterType
|
A tuple containing: |
Optional[GuaranteeParameterType]
|
|
tuple[GuaranteeParameterType, Optional[GuaranteeParameterType]]
|
|
Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
get_required_parameter_types
classmethod
¶
Returns set of required parameter types for a given expression type.
Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
max_reimbursement_per_care
class-attribute
instance-attribute
¶
max_reimbursement_per_care_before_after_count_limit
class-attribute
instance-attribute
¶
max_reimbursement_per_care_before_after_count_limit = (
"max_reimbursement_per_care_before_after_count_limit"
)
max_reimbursement_per_care_with_count_limit
class-attribute
instance-attribute
¶
max_reimbursement_per_care_with_count_limit_and_frame_amount
class-attribute
instance-attribute
¶
max_reimbursement_per_care_with_count_limit_and_frame_amount = "max_reimbursement_per_care_with_count_limit_and_frame_amount"
max_reimbursement_per_care_with_cumulative_limit
class-attribute
instance-attribute
¶
max_reimbursement_per_care_with_cumulative_limit = (
"max_reimbursement_per_care_with_cumulative_limit"
)
percent_reimbursement_ss
class-attribute
instance-attribute
¶
percent_reimbursement_ss_before_after_count_limit
class-attribute
instance-attribute
¶
percent_reimbursement_ss_before_after_count_limit = (
"percent_reimbursement_ss_before_after_count_limit"
)
percent_reimbursement_ss_with_count_limit
class-attribute
instance-attribute
¶
percent_reimbursement_ss_with_cumulative_limit
class-attribute
instance-attribute
¶
percent_reimbursement_ss_with_cumulative_limit = (
"percent_reimbursement_ss_with_cumulative_limit"
)
percent_reimbursement_total_cost
class-attribute
instance-attribute
¶
percent_reimbursement_total_cost_with_count_limit
class-attribute
instance-attribute
¶
percent_reimbursement_total_cost_with_count_limit = (
"percent_reimbursement_total_cost_with_count_limit"
)
percent_reimbursement_total_cost_with_cumulative_limit
class-attribute
instance-attribute
¶
percent_reimbursement_total_cost_with_cumulative_limit = (
"percent_reimbursement_total_cost_with_cumulative_limit"
)
percent_reimbursement_with_cumulative_and_count_limit_per_side
class-attribute
instance-attribute
¶
percent_reimbursement_with_cumulative_and_count_limit_per_side = "percent_reimbursement_with_cumulative_and_count_limit_per_side"
reimburse_full_cost
class-attribute
instance-attribute
¶
reimburse_full_cost_with_count_limit
class-attribute
instance-attribute
¶
reimburse_full_cost_with_count_limit_per_side
class-attribute
instance-attribute
¶
reimburse_full_cost_with_waiting_period
class-attribute
instance-attribute
¶
guarantee_parameter_type ¶
GuaranteeParameterType ¶
Bases: AlanBaseEnum
Enumeration of all possible guarantee parameter types.
always_reimburse_100_pct_ss
class-attribute
instance-attribute
¶
cumulative_copayment
class-attribute
instance-attribute
¶
format_value ¶
Format the provided value of the parameter according to its type.
get_limit_types
classmethod
¶
Returns set of parameter types that are limits.
Source code in components/guarantee_catalog/public/enums/guarantee_parameter_type.py
get_value_formatter
classmethod
¶
Return the type of the value for the parameter.
Source code in components/guarantee_catalog/public/enums/guarantee_parameter_type.py
max_reimbursement_per_care
class-attribute
instance-attribute
¶
max_reimbursement_per_care_after_count_limit_reached
class-attribute
instance-attribute
¶
max_reimbursement_per_care_after_count_limit_reached = (
"max_reimbursement_per_care_after_count_limit_reached"
)
percent_reimbursement_ss
class-attribute
instance-attribute
¶
percent_reimbursement_ss_after_count_limit_reached
class-attribute
instance-attribute
¶
percent_reimbursement_ss_after_count_limit_reached = (
"percent_reimbursement_ss_after_count_limit_reached"
)
percent_reimbursement_total_cost
class-attribute
instance-attribute
¶
post_duration_in_months
class-attribute
instance-attribute
¶
pre_duration_in_months
class-attribute
instance-attribute
¶
reimburse_full_cost
class-attribute
instance-attribute
¶
waiting_period_in_months
class-attribute
instance-attribute
¶
components.guarantee_catalog.public.queries ¶
guarantees_definition ¶
get_guarantee_catalog ¶
Returns all guarantee categories and their complete hierarchy for the given country.
Source code in components/guarantee_catalog/public/queries/guarantees_definition.py
validate_guarantee_catalog_from_yaml ¶
Validate the guarantee catalog YAML file for the current app.
This function validates the default guarantee catalog YAML file (as configured in app dependencies) without persisting any changes. Primarily used for testing to ensure the production YAML is well-formed and meets all validation rules.
Raises:
| Type | Description |
|---|---|
YAMLError
|
If the YAML file is malformed |
GuaranteeDefinitionError
|
If any validation fails (parameter constraints, references, uniqueness checks, etc.) |
Source code in components/guarantee_catalog/public/queries/guarantees_definition.py
validate_coverage_rules ¶
validate_coverage_relationship ¶
Validates the relationship between the source and target coverage rules, where each parameter represents the selected coverage rules for a given coverage
Source code in components/guarantee_catalog/public/queries/validate_coverage_rules.py
validate_coverage_rules ¶
Validates coverage rules for a given coverage against guarantee definitions.