Api reference
components.occupational_health.public.dependencies ¶
OCCUPATIONAL_HEALTH_COMPONENT_NAME
module-attribute
¶
OccupationalHealthDependency ¶
Bases: ABC
Dependency interface for occupational_health component to access country-specific functionality.
This interface abstracts away direct dependencies on country-specific components, allowing the occupational_health component to work with different country implementations.
create_profile_with_user
abstractmethod
¶
get_account_admins_profile_ids
abstractmethod
¶
get_account_id
abstractmethod
¶
get_account_id_and_siret
abstractmethod
¶
get_account_id_customers_2025
abstractmethod
¶
get_account_name
abstractmethod
¶
get_company_admins_profile_ids
abstractmethod
¶
get_company_display_name_and_account_id
abstractmethod
¶
Get company display name and associated account ID.
get_company_from_siret
abstractmethod
¶
get_company_ids_in_account
abstractmethod
¶
get_company_names_by_ids
abstractmethod
¶
get_company_siren
abstractmethod
¶
get_company_siret
abstractmethod
¶
Get company SIRET, optionally forcing a specific NIC.
get_global_profile_id
abstractmethod
¶
get_user_id_by_global_profile_mapping
abstractmethod
¶
Get global profile ID -> user ID mapping from global health profile IDs.
Source code in components/occupational_health/public/dependencies.py
get_user_id_from_global_profile_id
abstractmethod
¶
get_user_id_mapping_from_user_ids
abstractmethod
¶
Get global profile ID -> user ID mapping from user IDs.
get_work_stoppages_for_users
abstractmethod
¶
Get work stoppages for users.
Source code in components/occupational_health/public/dependencies.py
set_ssn_ntt_on_user
abstractmethod
¶
ProfileData
dataclass
¶
ProfileData(
email=None,
first_name=None,
last_name=None,
birth_date=None,
language=None,
phone_number=None,
gender=None,
)
The profile data used to create a user and profile.
get_app_dependency ¶
Retrieves the occupational_health dependency
Source code in components/occupational_health/public/dependencies.py
set_app_dependency ¶
Sets the occupational_health dependency to the app
Source code in components/occupational_health/public/dependencies.py
components.occupational_health.public.employment ¶
employment_consumer ¶
Note: Do not import local country code here, do it in the internal component after checking the country code.
occupational_health_employment_change_consumer ¶
Source code in components/occupational_health/public/employment/employment_consumer.py
requires_siret_information ¶
requires_siret_information ¶
Return whether the given account ID requires SIRET information to be provided when tracking employment movements.
Source code in components/occupational_health/public/employment/requires_siret_information.py
components.occupational_health.public.entities ¶
billing ¶
BillingStrategy ¶
CustomerAddress
dataclass
¶
CustomerData
dataclass
¶
Customer data needed for billing purposes.
InvoiceToGenerateData
dataclass
¶
InvoiceToGenerateData(
*,
billing_period,
billing_year,
contract_type,
contract_ref,
contract_yearly_price_per_employee_in_cents,
contract_needs_installment_plan_for_employees_count,
references_of_employees_affiliated_over_the_year
)
Data needed to generate an invoice for a customer.
billing_year
instance-attribute
¶
The year of the billing period. END_OF_YEAR_REGUL invoices are issued on 01/01 of the year Y+1 but will hold the original year Y in billing_year.
contract_needs_installment_plan
property
¶
Whether the contract needs an installment plan.
contract_needs_installment_plan_for_employees_count
instance-attribute
¶
contract_yearly_price_per_employee_in_cents
instance-attribute
¶
references_of_employees_affiliated_over_the_year
instance-attribute
¶
List of opaque references of all employees affiliated on this subscription/contract, during the entire year of the billing period (not just the specified billing period).
OccupationalHealthBillingPeriod ¶
Bases: AlanBaseEnum
Billing period for occupational health services.
dmst ¶
CurriculumLaboris
dataclass
¶
Bases: DataClassJsonMixin
Member curriculum laboris (work information): previous job, description of work, tasks, etc.
Keep in sync with: frontend/apps/medical-software/app/hooks/useProfileDmstQuery.ts
Used in the HP medical app (DMST) for the "Professional" tab
Dmst
dataclass
¶
Dmst(
*,
occupational_health_profile_id,
first_name,
last_name,
gender,
birthdate,
curriculum_laboris
)
Bases: DataClassJsonMixin
Information about a member, such as their name, gender, birthdate, etc.
Keep in sync with: frontend/apps/medical-software/app/hooks/useProfileDmstQuery.ts
Used in the HP medical app (DMST)
MemberJob
dataclass
¶
Bases: DataClassJsonMixin
Represents a single job held by a member, including employment details and duration.
Keep in sync with: frontend/apps/medical-software/app/hooks/useProfileDmstQuery.ts
Used in the HP medical app (DMST) for the "Professional" tab
member_info ¶
MemberInfo
dataclass
¶
MemberInfo(
*,
occupational_health_profile_id,
user_id,
member_first_name,
member_last_name,
member_gender,
member_birthdate
)
Bases: DataClassJsonMixin
Information about a member, such as their name, gender, birthdate, etc.
Note: we'll be using other structures for the rest of the data e.g. MemberActivity, etc.
Used in the HP medical app.
visit ¶
VisitInfo
dataclass
¶
VisitInfo(
*,
member_first_name,
member_last_name,
member_gender,
member_birthdate,
visit_date,
visit_type,
health_professional_name,
health_professional_id,
visit_status
)
Bases: DataClassJsonMixin
Information about a visit scheduled for a specific date.
Used in the HP medical app.
components.occupational_health.public.enums ¶
AffiliationDecision ¶
Bases: AlanBaseEnum
Possible decisions for occupational health affiliation.
components.occupational_health.public.events ¶
subscription ¶
subscribe_to_events ¶
All event subscriptions for the occupational health component should be done here.
Source code in components/occupational_health/public/events/subscription.py
components.occupational_health.public.marmot ¶
actions ¶
Actions for use in Marmot controllers.
affiliate_new_member_for_marmot ¶
affiliate_new_member_for_marmot(
*,
user_id,
account_id,
start_date,
end_date=None,
actor_user_id=None
)
Affiliate a new member to occupational health.
Source code in components/occupational_health/public/marmot/actions.py
cancel_affiliation_for_marmot ¶
Cancel an affiliation for a profile.
This is a wrapper around cancel_affiliation that adds logging.
Source code in components/occupational_health/public/marmot/actions.py
change_affiliation_decision ¶
Change the decision of an affiliation decision. If the decision is to affiliate, the profile will be affiliated.
Source code in components/occupational_health/public/marmot/actions.py
reprocess_affiliation_decision_for_marmot ¶
Reprocess an affiliation decision for Marmot. This will trigger a new affiliation decision based on the same employment change payload.
Source code in components/occupational_health/public/marmot/actions.py
terminate_affiliation_for_marmot ¶
terminate_affiliation_for_marmot(
account_id,
profile_id,
end_date,
termination_type,
actor_user_id,
)
Terminate an affiliation for a profile. This is a wrapper around terminate_member_affiliation that adds logging.
Source code in components/occupational_health/public/marmot/actions.py
entities ¶
AffiliatedMemberEmploymentDataForMarmot
dataclass
¶
AffiliatedMemberForMarmot
dataclass
¶
AffiliatedMemberForMarmot(
affiliation_id,
start_date,
end_date,
is_cancelled,
user_id,
occupational_health_profile_id,
global_profile_id,
first_name,
last_name,
birth_date,
email,
phone_number,
is_vip,
employments,
account_id,
)
Bases: DataClassJsonMixin
Represent a member affiliated to Prévenir, to be displayed in Marmot
AffiliationMovementForMarmot
dataclass
¶
AffiliationMovementForMarmot(
movement_id,
account_id,
profile_id,
movement_type,
date_of_movement,
first_name,
last_name,
birth_date,
created_at,
decision_id,
company_id,
company_name,
company_name_enriched_from_dsn,
)
Bases: DataClassJsonMixin
Represent an affiliation movement for display in Marmot
OccupationalHealthAffiliationDecisionForMarmot
dataclass
¶
OccupationalHealthAffiliationDecisionForMarmot(
id,
created_at,
decision,
employment_change_payload,
core_employment_id,
rule_id,
rule_name,
)
Bases: DataClassJsonMixin
Affiliation decision data for display in Marmot.
OccupationalHealthAffiliationDecisionWithProfileForMarmot
dataclass
¶
OccupationalHealthAffiliationDecisionWithProfileForMarmot(
id,
created_at,
decision,
manual_decision,
employment_change_payload,
core_employment_id,
rule_id,
rule_name,
first_name,
last_name,
birth_date,
company_id,
company_name,
company_name_enriched_from_dsn,
)
Bases: DataClassJsonMixin
Affiliation decision data with profile information for display in Marmot.
OccupationalHealthProfileData
dataclass
¶
OccupationalHealthProfileData(
profile_id,
visits,
affiliations,
affiliation_decisions,
next_visit_result,
)
Bases: DataClassJsonMixin
All occupational health data for a profile
OccupationalHealthVisitForMarmot
dataclass
¶
OccupationalHealthVisitForMarmot(
id,
visit_date,
visit_type,
visit_setup,
managed_by_prevenir,
took_place,
cancellation_reason,
work_stoppage_reason,
health_professional_first_name,
health_professional_last_name,
)
Bases: DataClassJsonMixin
Represent a visit for display in Marmot
enums ¶
MovementType ¶
Bases: AlanBaseEnum
The recorded movement: either an affiliation, or a termination, or a cancellation.
Transfers are composed by a termination and an affiliation, if they moved between two distinct accounts.
queries ¶
Queries for use in Marmot controllers.
get_affiliated_members_for_marmot ¶
Return the list of affiliated members (including past ones) for display in Marmot.
Source code in components/occupational_health/public/marmot/queries.py
get_affiliation_decisions_for_marmot ¶
get_affiliation_decisions_for_marmot(
profile_service,
account_id,
decision=None,
not_older_than=None,
)
Return the list of affiliation decisions, optionally filtered by decision type and date.
Source code in components/occupational_health/public/marmot/queries.py
get_occupational_health_profile_data_for_marmot ¶
Return all occupational health data for a profile, for display in Marmot.
Source code in components/occupational_health/public/marmot/queries.py
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get_recent_affiliation_movements ¶
Return the list of affiliation decisions made since the given date for the given account.
Source code in components/occupational_health/public/marmot/queries.py
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 | |
components.occupational_health.public.queries ¶
billing ¶
Set of queries used by the Billing stack.
See https://github.com/alan-eu/Topics/discussions/30344?sort=old#discussioncomment-14080373 ⧉
ContractRefNotFound ¶
Bases: Exception
A contract reference was not found.
UnableToDetermineCustomerToBill ¶
Bases: Exception
Unable to determine which customer to bill.
build_invoices_data_for_period ¶
Build the data required to generate all invoices for the given billing period and invoice year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
billing_period
|
OccupationalHealthBillingPeriod
|
The billing period to build data for. |
required |
billing_year
|
int
|
The year of the billing period to build data for. |
required |
The data is not guaranteed to be stable over time for past billing periods, as retroactive affiliation changes can occur.
Returns:
| Type | Description |
|---|---|
list[InvoiceToGenerateData]
|
list[InvoiceToGenerateData]: The data about all invoices to generate for the given period. |
Source code in components/occupational_health/public/queries/billing.py
build_invoices_data_for_period_and_account ¶
Build the data required to generate all invoices for the given billing period, invoice year and account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
billing_period
|
OccupationalHealthBillingPeriod
|
The billing period to build data for. |
required |
billing_year
|
int
|
The year of the billing period to build data for. |
required |
account_id
|
UUID
|
The account ID to build invoices for. |
required |
The data is not guaranteed to be stable over time for past billing periods, as retroactive affiliation changes can occur.
Returns:
| Type | Description |
|---|---|
list[InvoiceToGenerateData]
|
list[InvoiceToGenerateData]: The data about all invoices to generate for the given period. |
Source code in components/occupational_health/public/queries/billing.py
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 | |
check_data ¶
Temporary function to display the data produced by Occupational Health.
Source code in components/occupational_health/public/queries/billing.py
get_customer_data ¶
Fetch customer data for the billing system.
Until we decide how to store this customer data (on the Billing side?), here is a query to serve it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contract_ref
|
str
|
The contract reference to look up customer data for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CustomerData |
CustomerData
|
The customer data for the given contract reference |
Raises:
| Type | Description |
|---|---|
ContractRefNotFound
|
If the contract reference is not found in the customer data mapping |
Source code in components/occupational_health/public/queries/billing.py
has_active_occupational_health_contract ¶
has_active_occupational_health_contract ¶
Return whether the given account ID has an active occupational health contract at the moment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_id
|
UUID
|
The ID of the account to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the account has an active occupational health contract, False otherwise. |
Source code in components/occupational_health/public/queries/has_active_occupational_health_contract.py
is_currently_affiliated_to_prevenir ¶
is_currently_affiliated_to_occupational_health ¶
Check if the user is currently affiliated to Prevenir.
Will create a OccupationalHealthProfile if it doesn't exist, hence the commit parameter.
Returns True if the user has active affiliations, otherwise False.