Skip to content

Occupational Health

Alan supports Prévenir, our Occupational Health service (also known as "médecine du travail" in France).

Prévenir provides occupational health services to several companies, some of them being insured at Alan for their health, and some not.

Relevant resources:

Local development

Generate mock data

After running flask data init, generate occupational health mock data (users, profiles, visits, and on-demand visit requests):

direnv exec backend env APP=fr_api flask occupational_health generate_daily_mock_data \
    --account-id 0e6d99b7-3c10-43e7-a835-401de6236420 \
    --company-id 3 \
    --admin-user-id 413603432 \
    --execute

This creates: - 3 mock users with global profiles, employments, and affiliations - 3 predictable visits linked to a health professional - 3 on-demand visit requests in TO_REVIEW state (visible at /marmot/fr/occupational-health/review-visit-requests)

The command can be re-run safely — visit requests are deleted and recreated each time.

Local account/company/admin IDs come from init_company_with_options.py (created by flask data init).

On-demand visit GSheet (dev)

When processing succeeds, the visit is appended to the dev on-demand GSheet ⧉ (used for local testing).

Testing visit request processing

When processing a visit request from the Marmot review page, you need a user ID. User IDs are dynamically generated, so find one with the right enrichment state:

# User with complete enrichment (SSN + birth_date) → processing succeeds
direnv exec backend psql -h localhost -d alan_backend -c "
  SELECT u.id, u.first_name, u.last_name FROM \"user\" u
  JOIN insurance_profile ip ON ip.user_id = u.id
  JOIN global_profile.user_profile_mapping upm ON upm.user_id = u.id::text
  JOIN global_profile.profile gp ON gp.id = upm.profile_id
  WHERE ip.ssn IS NOT NULL AND length(ip.ssn) >= 10 AND gp.birth_date IS NOT NULL
  LIMIT 1;
"

# User with incomplete enrichment → stays in TO_REVIEW
direnv exec backend psql -h localhost -d alan_backend -c "
  SELECT u.id, u.first_name, u.last_name FROM \"user\" u
  LEFT JOIN insurance_profile ip ON ip.user_id = u.id
  WHERE u.id > 0 AND (ip.ssn IS NULL OR ip.id IS NULL)
  LIMIT 1;
"