Api reference
components.fr_health_insurance_affiliation.public.beneficiary ¶
check_can_be_added_as_beneficiary ¶
check_can_be_added_as_beneficiary(
policy_id,
first_name,
birth_date,
ssn,
enrollment_type,
start_date,
)
Source code in components/fr_health_insurance_affiliation/public/beneficiary.py
components.fr_health_insurance_affiliation.public.blueprint ¶
fr_health_insurance_affiliation_blueprint
module-attribute
¶
fr_health_insurance_affiliation_blueprint = CustomBlueprint(
"fr_health_affiliation",
__name__,
cli_group="fr_affiliation",
)
record_once ¶
Recording email handler
Source code in components/fr_health_insurance_affiliation/public/blueprint.py
components.fr_health_insurance_affiliation.public.business_logic ¶
queries ¶
legacy_employment ¶
get_legacy_employment ¶
Returns the legacy employment active on effective date.
If no legacy employment is found on effective date, returns the legacy employment active on contract start date to bypass the fact that the legacy employment's start date has been truncated to match the company's contract with Alan NB: This function is mainly intended for bridging Employment Component code and legacy FR code that uses the public.employment table. Use other functions if your use case differs.
Source code in components/fr_health_insurance_affiliation/public/business_logic/queries/legacy_employment.py
get_legacy_employment_or_raise ¶
Returns the legacy employment active on effective date.
If no legacy employment is found on effective date, returns the legacy employment active on contract start date to bypass the fact that the legacy employment's start date has been truncated to match the company's contract with Alan.
Raises an error if no employment is found at all.
NB: This function is mainly intended for bridging Employment Component code and legacy FR code that uses the public.employment table. Use other functions if your use case differs.
Source code in components/fr_health_insurance_affiliation/public/business_logic/queries/legacy_employment.py
components.fr_health_insurance_affiliation.public.compatibility_instructions ¶
OldStackCompatibleBackFromUnpaidLeave
dataclass
¶
Bases: OldStackCompatibleInstruction
execute ¶
Source code in components/fr_health_insurance_affiliation/public/compatibility_instructions.py
OldStackCompatibleDeclareUnpaidLeave
dataclass
¶
OldStackCompatibleDeclareUnpaidLeave(
policy_id,
unpaid_leave_start_date,
unpaid_leave_return_date,
)
Bases: OldStackCompatibleInstruction
execute ¶
Source code in components/fr_health_insurance_affiliation/public/compatibility_instructions.py
OldStackCompatibleInstruction ¶
Bases: Instruction
OldStackCompatibleInviteEmployeeWithCoverByDefault
dataclass
¶
OldStackCompatibleInviteEmployeeWithCoverByDefault(
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
soft_onboarding_data,
end_date=None,
termination_type=None,
)
Bases: _OldStackCompatibleInviteEmployee
execute ¶
Source code in components/fr_health_insurance_affiliation/public/compatibility_instructions.py
OldStackCompatibleInviteExEmployee
dataclass
¶
OldStackCompatibleInviteExEmployee(
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
user_id,
)
Bases: _OldStackCompatibleInviteEmployee
execute ¶
Source code in components/fr_health_insurance_affiliation/public/compatibility_instructions.py
OldStackCompatibleInviteInUnpaidLeave
dataclass
¶
OldStackCompatibleInviteInUnpaidLeave(
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
user_id,
unpaid_leave_return_date,
unpaid_leave_mandatory_coverage,
invite_ssn,
invite_ntt,
)
Bases: _OldStackCompatibleInviteEmployee
execute ¶
Source code in components/fr_health_insurance_affiliation/public/compatibility_instructions.py
components.fr_health_insurance_affiliation.public.employment_consumer ¶
Note: Do not import local country code here, do it in the internal component after checking the country code.
fr_health_affiliation_employment_change_consumer ¶
Source code in components/fr_health_insurance_affiliation/public/employment_consumer.py
components.fr_health_insurance_affiliation.public.event_bus ¶
AffiliationEventBus ¶
Bases: AbstractEventBus[LifecycleEvent]
Source code in components/fr_health_insurance_affiliation/public/event_bus.py
components.fr_health_insurance_affiliation.public.events ¶
AdminInitiatedExemption
dataclass
¶
Bases: LifecycleEvent
Event triggered when an admin puts an employee in the exemption flow and wants to send the onboarding link
AniBeneficiariesRemoved
dataclass
¶
AniBeneficiariesRemoved(
primary_user_id,
policy_id,
end_date,
removed_beneficiaries_names,
kept_beneficiaries_names,
)
Bases: LifecycleEvent
Happens when optional beneficiaries are removed from a policy when the primary enters ANI.
AniShortenedToAffiliateToNewHealthCoverage
dataclass
¶
Bases: LifecycleEvent
BeneficiaryCancelled
dataclass
¶
Bases: LifecycleEvent
BeneficiaryRemoved
dataclass
¶
BeneficiaryResumed
dataclass
¶
Bases: LifecycleEvent
CoveredEmployeeTransferred
dataclass
¶
CoveredEmployeeTransferred(
old_employment_id,
new_employment_id,
old_policy_id,
new_policy_id,
new_start_date,
old_ccn_code,
old_professional_category,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_unpaid_leave_contract_id=None,
)
Bases: LifecycleEvent
EmployeeAffiliatedToHealthCoverage
dataclass
¶
Bases: LifecycleEvent
EmployeeCancelled
dataclass
¶
Bases: LifecycleEvent
EmployeeCreatedAndExempted
dataclass
¶
Bases: LifecycleEvent
Happens when an employee is created and directly exempted.
EmployeeHealthContractChanged
dataclass
¶
EmployeeHealthContractChanged(
employment_id,
old_policy_id,
new_policy_id,
new_start_date,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_unpaid_leave_contract_id=None,
)
Bases: LifecycleEvent
EmployeeInUnpaidLeaveAffiliatedToHealthCoverage
dataclass
¶
EmployeeInUnpaidLeaveAffiliatedToHealthCoverage(
employment_id,
old_policy_id,
new_policy_id,
new_start_date,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_unpaid_leave_contract_id=None,
notify=True,
)
Bases: LifecycleEvent
EmployeeInUnpaidLeaveResumed
dataclass
¶
Bases: LifecycleEvent
EmployeeInUnpaidLeaveSoftOnboarded
dataclass
¶
EmployeeInUnpaidLeaveSoftOnboarded(
employment_id,
old_policy_id,
new_policy_id,
new_start_date,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_unpaid_leave_contract_id=None,
)
Bases: LifecycleEvent
EmployeeInvited
dataclass
¶
EmployeeInvited(
user_id,
company_id,
employment_id,
start_date,
invite_email,
invited_as_ex_employee,
)
Bases: LifecycleEvent
Happens when an employee is invited to join the company, or when a new invitation should be sent.
The second case can happen if we: - have covered the employee (or created the employment) - have not been able to send out an invitation due to a missing invite_email - have now received the invite_email
EmployeePopulationChanged
dataclass
¶
EmployeePopulationChanged(
employment_id,
new_start_date,
new_policy_id,
old_ccn_code,
old_professional_category,
)
Bases: LifecycleEvent
Is not always synonym of a change of contract and policy. In that case, an EmployeeHealthContractChanged is published.
EmployeeRemoved
dataclass
¶
EmployeeRemoved(
employment_id,
employee_contract_end_date,
coverage_end_date_excluding_ani,
policy_id,
exemption_id,
)
Bases: LifecycleEvent
EmployeeResumed
dataclass
¶
EmployeeReturnedAfterAni
dataclass
¶
EmployeeReturnedAfterAni(
user_id,
company_id,
new_employment_id,
new_policy_id,
old_policy_id,
new_start_date,
)
Bases: LifecycleEvent
EmployeeReturningToWorkAffiliatedToHealthCoverage
dataclass
¶
EmployeeReturningToWorkAffiliatedToHealthCoverage(
employment_id,
old_policy_id,
new_policy_id,
new_start_date,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_unpaid_leave_contract_id=None,
notify=True,
)
Bases: LifecycleEvent
EmployeeSoftOnboarded
dataclass
¶
Bases: LifecycleEvent
EmployeeStartDateUpdated
dataclass
¶
Bases: LifecycleEvent
Happens when the start date of an employment is updated.
EmployeeUncancelled
dataclass
¶
Bases: LifecycleEvent
EmploymentFittedToHealthAffiliation
dataclass
¶
Bases: LifecycleEvent
Happens when manipulating health affiliation coverage (exemption, policy) and we want to make the employment fit the resulting affiiation periods. We're aiming at getting rid of this.
ExemptedEmployeeTransferred
dataclass
¶
ExemptedEmployeeTransferred(
old_employment_id,
new_employment_id,
old_exemption_id,
new_exemption_id,
new_start_date,
old_ccn_code,
old_professional_category,
)
Bases: LifecycleEvent
ExemptionCancelled
dataclass
¶
Bases: LifecycleEvent
ExemptionCreated
dataclass
¶
Bases: LifecycleEvent
ExemptionEndDateUpdated
dataclass
¶
Bases: LifecycleEvent
ExemptionInvalidatedToSoftOnboard
dataclass
¶
Bases: LifecycleEvent
ExemptionJustificationFileUploaded
dataclass
¶
Bases: LifecycleEvent
Event triggered when an exemption justification is uploaded
ExemptionJustificationReviewed
dataclass
¶
Bases: LifecycleEvent
Event triggered when an exemption justification has been reviewed. The event is published no matter whether the justification was deemed valid or not.
ExemptionRestarted
dataclass
¶
Bases: LifecycleEvent
ExemptionRestartedWithoutCreation
dataclass
¶
Bases: LifecycleEvent
Hack to manage the old exemption flow where we don't create a new exemption when restarting an exemption but invalidate the justifications instead
ExemptionResumed
dataclass
¶
Bases: LifecycleEvent
ExemptionStartDateUpdated
dataclass
¶
Bases: LifecycleEvent
ExemptionStarted
dataclass
¶
Bases: LifecycleEvent
ExemptionTerminated
dataclass
¶
Bases: LifecycleEvent
ExemptionUncancelled
dataclass
¶
Bases: LifecycleEvent
ExemptionValidityDateUpdated
dataclass
¶
Bases: LifecycleEvent
ExistingUserAffiliatedToHealthCoverage
dataclass
¶
Bases: LifecycleEvent
HealthCoverageAffiliationCreated
dataclass
¶
Bases: LifecycleEvent
HealthCoverageAffiliationCreatedForExEmployee
dataclass
¶
Bases: LifecycleEvent
IndividualHealthCoverageCancelled
dataclass
¶
Bases: LifecycleEvent
IndividualHealthCoverageTerminated
dataclass
¶
IndividualHealthCoverageTerminated(
user_id,
policy_id,
end_date,
contract_termination_type,
contract_termination_details,
)
Bases: LifecycleEvent
IndividualTerminatedAndCoveredAsEmployee
dataclass
¶
Bases: LifecycleEvent
LifecycleEvent
dataclass
¶
Bases: DataClassJsonMixin
__post_init__ ¶
get_user_id_from_policy_id ¶
Source code in components/fr_health_insurance_affiliation/public/events.py
OnboardingUnpaused
dataclass
¶
Bases: LifecycleEvent
PendingExemptionUpdated
dataclass
¶
PendingExemptionUpdated(
exemption_id,
new_exemption_type=None,
new_health_coverage_insurer_name=None,
new_health_coverage_end_date=None,
new_cdd_end_date=None,
)
Bases: LifecycleEvent
PolicyCancelled
dataclass
¶
PolicyCancelled(
policy_id,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_ani_contract_id=None,
policy_unpaid_leave_contract_id=None,
individual_health_contract_id=None,
)
Bases: LifecycleEvent
PolicyResumed
dataclass
¶
Bases: LifecycleEvent
PolicyStartDateUpdated
dataclass
¶
Bases: LifecycleEvent
PolicyTerminated
dataclass
¶
PolicyTerminated(
policy_id,
employee_contract_end_date=None,
coverage_end_date_excluding_ani=None,
policy_option_contract_id=None,
policy_direct_billing_contract_id=None,
policy_ani_contract_id=None,
policy_unpaid_leave_contract_id=None,
previous_end_date=None,
previous_ani_start_on=None,
previous_max_ani_end_on=None,
previous_termination_type=None,
is_latest_health_affiliation_for_employee=None,
notify=True,
)
Bases: LifecycleEvent
PolicyUncancelled
dataclass
¶
Bases: LifecycleEvent
SecondaryBeneficiaryAdded
dataclass
¶
SecondaryBeneficiaryAdded(
author_id,
new_beneficiary_user_id,
policy_id,
beneficiary_enrollment_id,
start_date,
enrollment_type,
)
Bases: LifecycleEvent
SignedSwornStatementFileProcessed
dataclass
¶
Bases: LifecycleEvent
Event triggered when an admin or UCE uploads a signed sworn statement for an exemption or a sworn statement is signed through hellosign
SwornStatementDocumentCreated
dataclass
¶
Bases: LifecycleEvent
Event triggered when a sworn statement document is created
UnpaidLeaveCancelled
dataclass
¶
Bases: LifecycleEvent
UnpaidLeaveDeclared
dataclass
¶
Bases: LifecycleEvent
UnpaidLeaveEndDateUpdated
dataclass
¶
Bases: LifecycleEvent
UnpaidLeaveStartDateUpdated
dataclass
¶
Bases: LifecycleEvent
UserAffiliatedToAlsaceMoselle
dataclass
¶
Bases: LifecycleEvent
components.fr_health_insurance_affiliation.public.instructions ¶
AddEmailToEmaillessEmployee
dataclass
¶
Bases: Instruction
AddExistingUserAsBeneficiary
dataclass
¶
AddSecondaryBeneficiary
dataclass
¶
AddSecondaryBeneficiary(
author_id,
first_name,
last_name,
birth_date,
policy_id,
start_date,
enrollment_type,
lang,
ssn=None,
referent_ssns=None,
birth_ranks=None,
)
Bases: Instruction
IF the member already exists and is in ANI, we stop it and affiliate the member to the new policy
AffiliateEmployeeInUnpaidLeaveToHealthCoverage
dataclass
¶
AffiliateEmployeeReturningToWorkToHealthCoverage
dataclass
¶
AffiliateEmployeeToAlsaceMoselle
dataclass
¶
Bases: Instruction
Instruction to affiliate an employee to the Alsace Moselle regime.
⚠️ This instruction bases itself on an employee: it only affiliates the primary for that employment.
it is only meant to be used when we are notified of changes from the Employment component.
Please use the AffiliateUserToAlsaceMoselle for any other usages
AffiliateExemptedEmployeeToHealthCoverage
dataclass
¶
AffiliateExemptedEmployeeToHealthCoverage(
employment_id,
start_date,
previous_beneficiaries_to_keep_enrollment_ids,
ssn=None,
ntt=None,
)
Bases: Instruction
Terminate or cancel the exemption and affiliates the employee to health coverage If start date equals to the exemption start date, the exemption is cancelled, otherwise it's terminated
:param previous_beneficiaries_to_keep_enrollment_ids When affiliating an employee that was covered by Alan before, we can add their former beneficiaries to the new coverage Note: neither beneficiaries nor employee will receive any communication on this (SecondaryBeneficiaryAdded event is not published)
previous_beneficiaries_to_keep_enrollment_ids
instance-attribute
¶
AffiliateInvitedEmployeeToHealthCoverage
dataclass
¶
AffiliateInvitedEmployeeToHealthCoverage(
employment_id,
ssn=None,
ntt=None,
previous_beneficiaries_to_keep_enrollment_ids=None,
)
Bases: Instruction
Create a health coverage for an invited employee
:param previous_beneficiaries_to_keep_enrollment_ids When affiliating an employee that was covered by Alan before, we can add their former beneficiaries to the new coverage Note: neither beneficiaries nor employee will receive any communication on this (SecondaryBeneficiaryAdded event is not published)
AffiliateUserToAlsaceMoselle
dataclass
¶
Bases: Instruction
Instruction to affiliate a User to the Alsace Moselle regime.
end_date
class-attribute
instance-attribute
¶
Defines when the Alsace Moselle affiliation should end. If none is provided, the enrollment's end date will be used.
enrollment_id
instance-attribute
¶
The ID of the User's enrollment we want to affiliate to Alsace Moselle.
start_date
class-attribute
instance-attribute
¶
Defines when the Alsace Moselle affiliation should start. If none is provided, the enrollment's start date will be used.
CancelBeneficiary
dataclass
¶
Bases: Instruction
CancelEmployee
dataclass
¶
CancelEmployeeHealthCoverage
dataclass
¶
Bases: Instruction
Cancel a policy, and the related employment but only if no other Exemption/Policy is linked to the Employment
CancelExemption
dataclass
¶
Bases: Instruction
Cancel an exemption, and the related employment but only if no other Exemption/Policy is linked to the Employment
CancelIndividualHealthCoverage
dataclass
¶
Bases: Instruction
CancelInvitedEmployee
dataclass
¶
Bases: Instruction
Cancel an Employee, must be invited only (no affiliation, active or past). If there's a pending exemption for this employment, it'll be cancelled as well.
CancelRemoveBeneficiary
dataclass
¶
Bases: Instruction
CancelUnpaidLeave
dataclass
¶
Bases: Instruction
Cancel unpaid leave by flagging it It cancels only if no health affiliation is linked
ChangeContractInCompany
dataclass
¶
Bases: Instruction
Used during contract split to change employee's contracts
ChangePopulation
dataclass
¶
Bases: Instruction
special cases: when updating population of an employee that is already ended - if the end date is in the past, we don't allow the change (raises a NotImplementedError) - if the end date is in the future - if the change date is before the end date -> we do the change - if the change date is after the end date -> we don't allow the change (raises an ErrorCode)
CoverFreelancerAsEmployee
dataclass
¶
CoverFreelancerAsEmployee(
freelancer_policy_id,
start_date,
company_id,
invite_email,
ccn_code,
professional_category,
ssn,
ntt,
previous_beneficiaries_to_keep_enrollment_ids,
end_date=None,
termination_type=None,
external_employee_id=None,
)
Bases: Instruction
⚠️ if previous_beneficiaries_to_keep_enrollment_ids is None, a missing_conditional_parameter error will be raised (this is part of the conflict solving mechanism for Marmot)
previous_beneficiaries_to_keep_enrollment_ids
instance-attribute
¶
CreateExemptionJustificationDocument
dataclass
¶
CreateExemptionJustificationDocument(
exemption_id,
last_override_author_id=None,
last_overridden_at=None,
reviewed_by_alan=None,
status=None,
end_date=None,
)
Bases: Instruction
Instruction to create an exemption justification document. This will be used to create an exemption justification document.
CreatePendingExemption
dataclass
¶
CreatePendingExemption(
employment_id,
start_date,
exemption_type=None,
end_date=None,
health_coverage_insurer_name=None,
health_coverage_end_date=None,
cdd_end_date=None,
previous_exemption_id=None,
is_admin_initiated_exemption=False,
)
Bases: Instruction
Create a pending exemption for a specific employment The exemption will be created with a pending status and will need to be started later on after the member has completed their onboarding
A few parameters are mandatory: - employment_id: the employment the exemption is linked to - start_date: the date the exemption will start
CreateSwornStatementDocument
dataclass
¶
Bases: Instruction
Instruction to create a sworn statement document for an exemption. HelloSign flow will create an unsigned document.
DeclareUnpaidLeave
dataclass
¶
DeclareUnpaidLeave(
employment_id,
unpaid_leave_start_date,
unpaid_leave_return_date=None,
unpaid_leave_mandatory_coverage=None,
bypass_past_date_check=False,
)
Bases: Instruction
unpaid_leave_mandatory_coverage
class-attribute
instance-attribute
¶
DeclareUnpaidLeaveReturnDate
dataclass
¶
Bases: Instruction
Update the end_date of the current or next UnpaidLeave
ExemptCoveredEmployee
dataclass
¶
Bases: Instruction
Create an exemption for a covered employee
ExemptExistingUser
dataclass
¶
ExemptExistingUser(
user_id,
company_id,
invite_email,
start_date,
exemption_type=None,
professional_category=None,
ccn_code=None,
external_employee_id=None,
)
ExemptInvitedEmployee
dataclass
¶
Bases: Instruction
Create an exemption for an invited employee
FlagExemptionJustificationAsInReview
dataclass
¶
Bases: Instruction
Flag exemption justifications as in review by setting the last_in_review_at field to the current datetime
INSTRUCTION_HANDLERS
module-attribute
¶
INSTRUCTION_HANDLERS = {
InviteEmployee: invite_employee,
InviteEmployeeWithCoverByDefault: invite_employee_with_cover_by_default,
InviteExEmployee: invite_ex_employee,
InviteInUnpaidLeave: invite_in_unpaid_leave,
AddEmailToEmaillessEmployee: add_email_to_emailless_employee,
CoverFreelancerAsEmployee: invite_and_cover_freelancer_as_employee,
RemoveEmployee: remove_employee,
TerminateAllHealthAffiliationsFromCompany: terminate_all_health_affiliations_from_company,
RemoveEmployeeWithoutLastCareCheck: remove_employee_without_last_care_check,
AddSecondaryBeneficiary: add_secondary_beneficiary,
AddExistingUserAsBeneficiary: add_existing_user_as_beneficiary,
RemoveBeneficiary: remove_beneficiary,
AffiliateInvitedEmployeeToHealthCoverage: affiliate_invited_employee_to_health_coverage,
AffiliateExemptedEmployeeToHealthCoverage: affiliate_exempted_employee_to_health_coverage,
AffiliateEmployeeInUnpaidLeaveToHealthCoverage: affiliate_employee_in_unpaid_leave_to_health_coverage,
AffiliateEmployeeReturningToWorkToHealthCoverage: affiliate_employee_returning_to_work_to_health_coverage,
ExemptInvitedEmployee: exempt_invited_employee,
ExemptCoveredEmployee: exempt_covered_employee,
ExemptExistingUser: exempt_existing_user,
MakeEmploymentFitAffiliations: make_employment_fit_affiliations,
CancelInvitedEmployee: cancel_invited_employee,
CancelEmployee: cancel_employee,
CancelExemption: cancel_exemption,
UncancelEmployee: uncancel_employee,
UpdateExemptionEndDate: update_exemption_end_date,
UpdateExemptionStartDate: update_exemption_start_date,
CreatePendingExemption: create_pending_exemption,
UpdatePendingExemption: update_pending_exemption,
StartExemption: start_exemption,
UpdateExemptionValidityDate: update_exemption_validity_date,
UpdateUnpaidLeaveStartDate: update_unpaid_leave_start_date,
UpdateUnpaidLeaveEndDate: update_unpaid_leave_end_date,
CancelUnpaidLeave: cancel_unpaid_leave_without_affiliation,
UpdateHealthCoverageAffiliationEndDate: update_health_coverage_affiliation_end_date,
UpdateHealthCoverageAffiliationStartDate: update_health_coverage_affiliation_start_date,
UpdateEmployeeTerminationType: update_employee_termination_type,
UpdateEmployeeStartDate: update_employee_start_date,
CancelBeneficiary: cancel_beneficiary,
CancelEmployeeHealthCoverage: cancel_employee_policy,
ResumeEmployeeInUnpaidLeave: resume_employee_in_unpaid_leave,
DeclareUnpaidLeave: declare_unpaid_leave,
TransferEmployee: transfer_employee,
MoveExemptedEmployeeToAnotherCompany: move_exempted_employee_to_another_company,
MoveCoveredEmployeeToAnotherCompany: move_covered_employee_to_another_company,
ChangeContractInCompany: change_contract_in_company,
ChangePopulation: change_population,
DeclareUnpaidLeaveReturnDate: declare_unpaid_leave_return_date,
ResumeBeneficiary: resume_beneficiary,
ResumeEmployee: resume_employee,
SoftOnboardEmployee: soft_onboard_employee,
SoftOnboardExemptedEmployee: soft_onboard_exempted_employee,
ScheduleSoftOnboarding: schedule_soft_onboarding,
ScheduleSoftOnboardingWithExemptionInvalidation: schedule_soft_onboarding_with_exemption_invalidation,
RestartExemptionProcess: restart_exemption_process,
TerminateIndividualHealthCoverage: terminate_individual_health_coverage,
CancelIndividualHealthCoverage: cancel_individual_health_coverage,
ResumeIndividualHealthCoverage: resume_individual_health_coverage,
InviteAndAffiliateToHealthCoverageIfPossible: affiliate_or_invite_existing_user,
SetViewedTermsAtForEmployee: set_viewed_terms_at_for_employee,
AffiliateEmployeeToAlsaceMoselle: affiliate_employee_to_alsace_moselle,
AffiliateUserToAlsaceMoselle: affiliate_user_to_alsace_moselle,
CreateSwornStatementDocument: create_sworn_statement_document,
UploadSignedSwornStatementFile: upload_signed_sworn_statement_file,
ProcessSignedSwornStatement: process_signed_sworn_statement,
ReviewExemptionJustification: review_exemption_justification,
ReviewExemptionJustificationForAdmin: review_exemption_justification_for_admin,
SetExemptionJustificationReviewEscalationLevel: set_exemption_justification_review_escalation_level,
FlagExemptionJustificationAsInReview: flag_exemption_justification_as_in_review,
CreateExemptionJustificationDocument: create_exemption_justification_document,
UploadExemptionJustificationFile: upload_exemption_justification_file,
}
Instruction ¶
Bases: DataClassJsonMixin
execute ¶
execute(
commit,
event_bus=None,
event_bus_provider=_default_event_bus_provider,
force_logs=False,
)
Source code in components/fr_health_insurance_affiliation/public/instructions.py
InstructionHandler ¶
InviteAndAffiliateToHealthCoverageIfPossible
dataclass
¶
InviteAndAffiliateToHealthCoverageIfPossible(
user_id,
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
ssn,
ntt,
previous_beneficiaries_to_keep_enrollment_ids,
external_employee_id=None,
)
Bases: Instruction
Affiliates an existing user to health coverage. If we can't, only invite them.
previous_beneficiaries_to_keep_enrollment_ids
instance-attribute
¶
InviteEmployee
dataclass
¶
InviteEmployee(
user_id,
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
ssn=None,
ntt=None,
external_employee_id=None,
)
Bases: Instruction
Does not cover the employee by default, only invites them to the company. If the employee is already covered in the company on start date, an ErrorCode is raised.
InviteEmployeeWithCoverByDefault
dataclass
¶
InviteEmployeeWithCoverByDefault(
user_id,
company_id,
start_date,
invite_email,
ccn_code,
professional_category,
ssn,
ntt,
end_date=None,
termination_type=None,
external_employee_id=None,
)
Bases: Instruction
InviteExEmployee
dataclass
¶
InviteInUnpaidLeave
dataclass
¶
InviteInUnpaidLeave(
user_id,
company_id,
start_date,
unpaid_leave_return_date,
invite_email,
ccn_code,
professional_category,
invite_ssn,
invite_ntt,
unpaid_leave_mandatory_coverage=False,
external_employee_id=None,
)
Bases: Instruction
unpaid_leave_mandatory_coverage
class-attribute
instance-attribute
¶
MakeEmploymentFitAffiliations
dataclass
¶
MoveCoveredEmployeeToAnotherCompany
dataclass
¶
MoveCoveredEmployeeToAnotherCompany(
employment_id,
destination_company_id,
move_date,
invite_email,
keep_admin,
destination_ccn_code,
destination_professional_category,
keep_ani,
previous_beneficiaries_to_keep_enrollment_ids=None,
external_employee_id=None,
)
Bases: Instruction
Move a covered employee to another company that is not necessarily part of the same group and cover member in the new company. This means it's not considered as a transfer, employee won't receive the dedicated emails nor keep their setup (options, direct billing...)
⚠️ if previous_beneficiaries_to_keep_enrollment_ids is None, a missing_conditional_parameter error will be raised (this is part of the conflict solving mechanism for Marmot)
previous_beneficiaries_to_keep_enrollment_ids
class-attribute
instance-attribute
¶
MoveExemptedEmployeeToAnotherCompany
dataclass
¶
MoveExemptedEmployeeToAnotherCompany(
employment_id,
destination_company_id,
move_date,
invite_email,
destination_ccn_code,
destination_professional_category,
exemption_type,
keep_admin,
external_employee_id=None,
)
Bases: Instruction
Move an exempted employee to another company that is not necessarily part of the same group and exempt member in the new company. This means it's not considered as a transfer, employee won't receive the dedicated emails
ProcessSignedSwornStatement
dataclass
¶
Bases: Instruction
Instruction to process a signed sworn statement for an exemption. This will start the exemption it if needed.
RemoveBeneficiary
dataclass
¶
RemoveBeneficiary(
enrollment_id,
end_date,
beneficiary_termination_reason=None,
beneficiary_termination_proof_link=None,
allow_mandatorily_covered_removal_without_proof=False,
)
Bases: Instruction
RemoveEmployee
dataclass
¶
RemoveEmployee(
employment_id,
end_date,
termination_type,
cancel_affiliations_after_end_date=False,
)
Bases: Instruction
Terminate an employee with automated computation of ANI if relevant.
end_date: termination date seen by the company
If there have been covered cares after end date, the coverage and the employment are extended until this last care. ANI computation is still based on the real end date.
If there is a new affiliation for the same (user, company) starting on end_date + 1d,
by default, we will NOT terminate the employment because we merge continuous employments.
To bypass this default, set cancel_affiliations_after_end_date to True,
this will cancel the new affiliation and terminate the employment.
RemoveEmployeeWithoutLastCareCheck
dataclass
¶
RemoveEmployeeWithoutLastCareCheck(
employment_id,
end_date,
termination_type,
reference_end_date_for_ani_end_computation=None,
bypass_ani_computation_and_force_end_date=False,
forced_max_ani_end_on=None,
)
Bases: Instruction
Terminate an employee with automated computation of ANI if relevant.
end_date: termination date seen by the company
reference_end_date_for_ani_end_computation: actual day the employee left the company
reference_end_date_for_ani_end_computation can be specified when we want
- to start ANI later than the actual departure of the employee
(this is the case when admin terminates the employee too late
and the employee had reimbursed cares after they left the company)
- but still end ANI based on the real departure date
In this case
- end_date should be the last day before ANI starts
- reference_end_date_for_ani_end_computation should be the actual day the employee left the company
note: if there's no ANI, reference_end_date_for_ani_end_computation is ignored
RestartExemptionProcess
dataclass
¶
Bases: Instruction
The goal is to allow member going again through the exemption onboarding. This is typically used when the exemption has been signed with a wrong start date or type. It can only be used on exemptions that already have a start date.
It cancels the current exemption and re-create one with new_start_date (or the current start_date if not specified) and an empty type
Make employment fit the exemption period if needed
ResumeBeneficiary
dataclass
¶
Bases: Instruction
ResumeEmployee
dataclass
¶
Bases: Instruction
ResumeEmployeeInUnpaidLeave
dataclass
¶
Bases: Instruction
This instruction is used to resume an ended policy which is followed by an unpaid leave (that we will cancel)
ResumeIndividualHealthCoverage
dataclass
¶
Bases: Instruction
ReviewExemptionJustification
dataclass
¶
ReviewExemptionJustification(
exemption_justification_id,
status,
exemption_justification_type,
rejection_reason,
rejection_reason_other_text,
end_date,
reviewer_id,
reviewed_by_alan,
)
ReviewExemptionJustificationForAdmin
dataclass
¶
ReviewExemptionJustificationForAdmin(
exemption_justification_id,
status,
reviewer_id,
reviewed_by_alan,
rejection_reason=None,
)
Bases: Instruction
Instruction to review an exemption justification when executed by an admin from the dashboard.
It has fewer parameters than ReviewExemptionJustification because only the status can be changed from the dashboard
ScheduleSoftOnboarding
dataclass
¶
Bases: Instruction
ScheduleSoftOnboardingWithExemptionInvalidation
dataclass
¶
ScheduleSoftOnboardingWithExemptionInvalidation(
employment_id, ssn=None, ntt=None, rejection_reason=None
)
Bases: Instruction
SetExemptionJustificationReviewEscalationLevel
dataclass
¶
SetExemptionJustificationReviewEscalationLevel(
exemption_justification_id,
escalation_level,
escalation_operator_id,
escalation_comment=None,
)
Bases: Instruction
Instruction to set the escalation level for an exemption review. This is used to escalate the review of an exemption justification to a higher level.
SetViewedTermsAtForEmployee
dataclass
¶
Bases: Instruction
SoftOnboardEmployee
dataclass
¶
Bases: Instruction
SoftOnboardExemptedEmployee
dataclass
¶
Bases: Instruction
StartExemption
dataclass
¶
TerminateAllHealthAffiliationsFromCompany
dataclass
¶
TerminateAllHealthAffiliationsFromCompany(
company_id, end_date, before_contract_termination=False
)
Bases: Instruction
Terminate all health affiliations from a company.
This should be called when a company churns their Health Insurance contract, and we want to make sure we terminate all Policies/Enrollments/Exemptions for that company.
When the parameter before_contract_termination is set to true
affiliations will be terminated even if there is a running contract
TerminateIndividualHealthCoverage
dataclass
¶
TerminateIndividualHealthCoverage(
policy_id,
end_date,
contract_termination_type,
contract_termination_details,
bypass_mandatory_termination_type_validation=False,
beneficiary_termination_reason=None,
)
Bases: Instruction
beneficiary_termination_reason
class-attribute
instance-attribute
¶
Termination type is mandatory for contracts that are less than one year old. But we do not ask for it from Marmot, so we accept to bypass the rule in that case.
The beneficiary_termination_reason is used to set the correct termination reason for all enrollments in the policy, enabling smart detection for dependent transfers.
bypass_mandatory_termination_type_validation
class-attribute
instance-attribute
¶
TransferEmployee
dataclass
¶
TransferEmployee(
employment_id,
destination_company_id,
transfer_date,
external_employee_id=None,
destination_ccn_code=None,
destination_professional_category=None,
end_date=None,
termination_type=None,
keep_existing_termination=False,
)
Bases: Instruction
Special cases: when transferring an employee that is already ended in the previous company - if the end date is in the past, we don't allow the transfer - if the end date is in the future - if the transfer date is before the end date -> we update the end date (shorten the first employment) - if the transfer date is after the end date -> we don't update the initial employment (there'll be a "hole" between the 2 employments)
NB: by default, the end date and ANI period (current or future) of the employment will not be kept. See the
keep_existing_termination parameter for more information.
destination_professional_category
class-attribute
instance-attribute
¶
end_date
class-attribute
instance-attribute
¶
This is the end date of the employee in the NEW company. See https://github.com/alan-eu/alan-apps/pull/16159 ⧉ for more details
This should only be used in case you want to transfer and terminate in the new company in a single instruction.
If you want to keep the termination information (end date + ANI period) of an employee when transferring them, use
keep_existing_termination instead.
Mutually exclusive with keep_existing_information.
keep_existing_termination
class-attribute
instance-attribute
¶
If set to True: - Employees currently in ANI will be transferred and keep their ANI status in the destination company. - Employees who have an end date in the original company will keep the end date in the destination company, along with the future ANI period (if any).
If set to False (default value): - Employees currently in ANI will be transferred and invited in the new company as a regular employee - The end date and future ANI period of employees in the original company will not be kept in the destination company.
Mutually exclusive with end_date/termination_type.
termination_type
class-attribute
instance-attribute
¶
To be used along with end_date: specifies the termination type of the employee in the new company.
Mutually exclusive with keep_existing_information.
UncancelEmployee
dataclass
¶
Bases: Instruction
Uncancel employment with the given affiliation.
For now, this instruction will only work for simple cases: one affiliation fully matching the employment. This is because complex situations are hard to handle and can lead to inconsistencies.
Exactly one of with_exemption_id and with_policy_id must be provided and it must exactly match the employment's dates.
To prevent leading to not compliant states, the exemption to uncancel must be signed.
UpdateEmployeeStartDate
dataclass
¶
Bases: Instruction
Update the start date of the employment and related health coverage/exemption affiliations
:param: restart_exemption_process: if True, the exemption process will be restarted This means the exemption will no longer be valid and a new sworn statement will have to be signed
⚠️ A few points to note: - DO NOT USE for - invited in ANI (will raise, because it has not been tested yet) - invited in unpaid leave (will raise an error ; it should be easy to implement but in theory, it doesn't make sense to update the start date in this case as it's supposed to match the company contract start date, so until we have a use case, we won't implement it) - It does the update regardless of covered cares during the period - It doesn't adapt ANI end even if in theory the new start date would have an impact on ANI computation
UpdateEmployeeTerminationType
dataclass
¶
Bases: Instruction
Update the termination type of an employee. It can update the termination dates if it changes the employee's ANI status.
UpdateExemptionEndDate
dataclass
¶
Bases: Instruction
Changes an exemption end date, if no conflict with other affiliation Doesn't change other affiliation
By default, after the end date update is done, the instruction will make_employment_fit_affiliations,
this can be avoided by using the make_employment_fit parameter
UpdateExemptionStartDate
dataclass
¶
Bases: Instruction
Changes an exemption start date, if no conflict with other affiliation
Doesn't change other affiliation
By default, after the end date update is done, the instruction will make_employment_fit_affiliations,
this can be avoided by using the make_employment_fit parameter
UpdateExemptionValidityDate
dataclass
¶
Bases: Instruction
Update the validity date of the exemption. The exemption model has 2 validity dates: cdd_end_date & health_coverage_end_date They are mutually exclusive, and depend on the exemption type.
UpdateHealthCoverageAffiliationEndDate
dataclass
¶
UpdateHealthCoverageAffiliationEndDate(
policy_id,
end_date,
termination_type,
keep_admin,
ani_start_on=None,
max_ani_end_on=None,
reference_end_date_for_ani_end_computation=None,
make_employment_fit=True,
)
Bases: Instruction
Changes a health coverage affiliation end date, if no conflict with other affiliation Doesn't change other affiliation Update employment end date if needed
Some details on parameters:
- basic usage is to use end_date and not ani_start_on/ max_ani_end_on
- ani_start_on/ max_ani_end_on can be used to force ANI dates
- end_date cannot be used with ani_start_on, unless you also specify max_ani_end_on to force the 3 dates.
- if max_ani_end_on is used with end_date, it is ignored, unless you also specify ani_start_on to force the 3 dates.
- reference_end_date_for_ani_end_computation is the actual day the employee left the company
- by default, after the end date update is done, the instruction will make_employment_fit_affiliations,
this can be avoided by using the make_employment_fit parameter
reference_end_date_for_ani_end_computation
class-attribute
instance-attribute
¶
UpdateHealthCoverageAffiliationStartDate
dataclass
¶
Bases: Instruction
Changes a health coverage affiliation start date, if no conflict with other affiliation Doesn't change other affiliation ⚠️ DO NOT USE unless you specifically want to update ONLY the policy, not the related employment - it'll be up to the caller to make sure the consistency between the employment and its affiliations If you're looking for updating a covered employee's start date, use UpdateEmployeeStartDate
UpdatePendingExemption
dataclass
¶
UpdatePendingExemption(
exemption_id,
exemption_type=None,
health_coverage_insurer_name=None,
health_coverage_end_date=None,
cdd_end_date=None,
)
Bases: Instruction
Update a pending exemption for a specific exemption The one or more proprieties of the exemption will be updated. The status will remain pending and the exemption will still need to be started later on after the member has completed their onboarding
Only one parameter is mandatory: - exemption_id: the id of the pending exemption to update "But at least one other parameter should be provided"
health_coverage_insurer_name
class-attribute
instance-attribute
¶
UpdateUnpaidLeaveEndDate
dataclass
¶
Bases: Instruction
Changes an unpaid leave end date It also updates the following health affiliation start date
UpdateUnpaidLeaveStartDate
dataclass
¶
Bases: Instruction
Changes an unpaid leave start date It also updates the preceding health affiliation end date and employment start if needed
UploadExemptionJustificationFile
dataclass
¶
UploadExemptionJustificationFile(
exemption_id,
file,
filename,
reviewed_by_alan=None,
status=None,
end_date=None,
)
Bases: Instruction
Instruction to upload an exemption justification file. This will be used to create an exemption justification document.
UploadSignedSwornStatementFile
dataclass
¶
Bases: Instruction
Instruction to upload a signed sworn statement file for an exemption. This will be used to create a sworn statement document, process the signed sworn statement file and start the exemption if needed.
components.fr_health_insurance_affiliation.public.side_effect_recorder ¶
SideEffectRecorder ¶
force_commit_to_record_side_effect
classmethod
¶
Intercept commit param of event handlers and set it to True if SideEffectRecorder is activated
WARNING: this should be used only for event handlers calling external functions decorated with
SideEffectRecorder.record(execute_function_in_new_stack_dry_run=False)
otherwise, the external function changes will be committed even in dry run mode