Skip to content

Api reference

components.customer_health_partner.public.business_logic

actions

create_demo_admin_health_partner_features

create_demo_admin_health_partner_features
create_demo_admin_health_partner_features(
    account, admin, employee_count
)
Source code in components/customer_health_partner/public/business_logic/actions/create_demo_admin_health_partner_features.py
def create_demo_admin_health_partner_features(  # noqa: D103
    account: Account, admin: User, employee_count: int
) -> None:
    from components.customer_health_partner.wellbeing_assessment.public.constants import (
        MINIMUM_WELLBEING_ASSESSMENT_PARTICIPANTS,
    )

    current_logger.info(
        "Creating demo admin health partner features for account %s", account.id
    )
    # Create a demo crisis request
    _create_crisis_request(account, admin)
    current_logger.info("Created a demo crisis request for account %s", account.id)
    # Create a demo wellbeing assessment
    if employee_count >= MINIMUM_WELLBEING_ASSESSMENT_PARTICIPANTS:
        _create_wellbeing_assessment(account, admin, employee_count)
        current_logger.info("Created a demo assessment for account %s", account.id)
faker module-attribute
faker = Faker('fr_FR')

queries

account

get_customer_success_manager_name_for_account
get_customer_success_manager_name_for_account(account_id)
Source code in components/customer_health_partner/public/business_logic/queries/account.py
def get_customer_success_manager_name_for_account(account_id: UUID) -> Optional[str]:  # noqa: D103
    query = (
        current_session.query(CompanyAccountsTuringData.customer_success_manager_name)  # noqa: ALN085
        .filter(CompanyAccountsTuringData.id == account_id)
        .one_or_none()
    )
    if not query:
        return None

    return query[0]  # type: ignore[no-any-return]
get_key_account_manager_name_for_account
get_key_account_manager_name_for_account(account_id)
Source code in components/customer_health_partner/public/business_logic/queries/account.py
def get_key_account_manager_name_for_account(account_id: UUID) -> Optional[str]:  # noqa: D103
    query = (
        current_session.query(CompanyAccountsTuringData.key_account_manager_name)  # noqa: ALN085
        .filter(CompanyAccountsTuringData.id == account_id)
        .one_or_none()
    )
    if not query:
        return None

    return query[0]  # type: ignore[no-any-return]

mobile_app

MobileAppUrls dataclass
MobileAppUrls(google_play_url, ios_url)

Bases: DataClassJsonMixin

google_play_url instance-attribute
google_play_url
ios_url instance-attribute
ios_url
get_mobile_app_urls
get_mobile_app_urls()
Source code in components/customer_health_partner/public/business_logic/queries/mobile_app.py
def get_mobile_app_urls() -> MobileAppUrls:  # noqa: D103
    app_name = get_current_app_name()
    match app_name:
        case AppName.ALAN_FR:
            return MobileAppUrls(
                ios_url="https://apps.apple.com/fr/app/alan-assurance-sant%C3%A9/id1277025964",
                google_play_url="https://play.google.com/store/apps/details?id=com.alanmobile&hl=fr",
            )
        case AppName.ALAN_BE:
            return MobileAppUrls(
                ios_url="https://apps.apple.com/be/app/alan-belgium-health-insurance/id1535009248",
                google_play_url="https://play.google.com/store/apps/details?id=com.alan.bemobile&hl=en",
            )
        case AppName.ALAN_ES:
            return MobileAppUrls(
                ios_url="https://apps.apple.com/es/app/alan-espa%C3%B1a-seguro-de-salud/id1521493863",
                google_play_url="https://play.google.com/store/apps/details?id=com.alan.esmobile&hl=es",
            )
        case _:
            raise NotImplementedError(
                f"can't find current_user_can_read_admin for app {current_app}"
            )

components.customer_health_partner.public.commands

app_group

customer_health_partner_commands module-attribute

customer_health_partner_commands = AppGroup(
    "customer_health_partner"
)

register_customer_health_partner_commands

register_customer_health_partner_commands()
Source code in components/customer_health_partner/public/commands/app_group.py
def register_customer_health_partner_commands() -> None:  # noqa: D103
    from components.customer_health_partner.badges.public.commands import (  # noqa: F401
        seed_badges,
    )
    from components.customer_health_partner.credits.public.commands import (  # noqa: F401
        reset_all_credit_counts,
    )
    from components.customer_health_partner.crisis.public.commands import (  # noqa: F401
        migrate_timestamps_to_utc,
    )
    from components.customer_health_partner.public.commands import (  # noqa: F401
        import_customer_priorities_survey_answers_from_typeform,
        seed_customer_priorities_survey_options,
    )
    from components.customer_health_partner.wellbeing_assessment.public.commands import (  # noqa: F401
        assessment_scores,
        common,
        fix_assessment_company_ids_with_account_company_ids,
    )
    from components.customer_health_partner.wellbeing_assessment.public.commands.wellbeing_assessment import (  # noqa: F401
        fill_assessments_entity_name,
        launch_assessments,
        send_assessment_report_events_to_notify_admins,
        update_assessment_admin_tracking_properties,
    )

    # Also register workshop commands
    from components.customer_health_partner.workshops.public.commands.register import (
        register_commands,
    )

    register_commands()

import_customer_priorities_survey_answers_from_typeform

import_customer_priorities_survey_answers_from_typeform

import_customer_priorities_survey_answers_from_typeform(
    form_id, dry_run, page_size, before=None
)
Source code in components/customer_health_partner/public/commands/import_customer_priorities_survey_answers_from_typeform.py
@customer_health_partner_commands.command(requires_authentication=False)
@command_with_dry_run
@click.argument("form_id", type=Typeform, required=True)
@click.option(
    "--page_size",
    type=int,
    required=True,
    help="Change the number of responses returned in each request max value is 1000",
)
@click.option(
    "--before",
    type=str,
    required=False,
    default=None,
    help="Use the before query parameter to paginate. The value for the before parameter should be the token value for the nth response",
)
def import_customer_priorities_survey_answers_from_typeform(  # noqa: D103
    form_id: Typeform, dry_run: bool, page_size: int, before: Optional[str] = None
) -> None:
    from components.customer_health_partner.internal.business_logic.actions.customer_priorities_survey import (
        import_customer_priorities_survey_answers_from_typeform as import_customer_priorities_survey_answers_from_typeform_action,
    )

    import_customer_priorities_survey_answers_from_typeform_action(
        form_id=form_id, before=before, page_size=page_size, save=not dry_run
    )

seed_customer_priorities_survey_options

seed_customer_priorities_survey_options

seed_customer_priorities_survey_options(dry_run)
Source code in components/customer_health_partner/public/commands/seed_customer_priorities_survey_options.py
@customer_health_partner_commands.command(requires_authentication=False)
@command_with_dry_run
def seed_customer_priorities_survey_options(dry_run: bool) -> None:  # noqa: D103
    from components.customer_health_partner.internal.business_logic.actions.customer_priorities_survey import (
        seed_survey_options as seed_survey_options_action,
    )

    seed_survey_options_action(not dry_run)

components.customer_health_partner.public.controllers

account

CustomerHealthPartnerAccountController

Bases: BaseController

accounts_endpoint module-attribute

accounts_endpoint = Endpoint('/accounts')

api

create_api

create_api(app_or_blueprint)
Source code in components/customer_health_partner/public/controllers/api.py
def create_api(app_or_blueprint: Flask | Blueprint) -> None:  # noqa: D103
    from shared.api.custom_api import CustomApi

    api = CustomApi(app_or_blueprint)

    @api.representation("application/json")  # type: ignore[misc]
    def output_json(data: dict, code: int, headers: dict) -> Response:  # type: ignore[type-arg]
        """Tells flask-restful to use the flask json serializer instead of json."""
        return make_response(jsonify(data), code, headers)

    from components.customer_health_partner.public.controllers.account import (
        accounts_endpoint,
    )
    from components.customer_health_partner.public.controllers.badge import (
        badges_endpoint,
    )
    from components.customer_health_partner.public.controllers.crisis import (
        crisis_endpoint,
    )
    from components.customer_health_partner.public.controllers.customer_metrics import (
        customer_metrics_endpoint,
    )
    from components.customer_health_partner.public.controllers.customer_priorities_survey import (
        customer_priorities_survey_endpoint,
    )
    from components.customer_health_partner.public.controllers.hr_kit import (
        hr_kit_endpoint,
    )
    from components.customer_health_partner.public.controllers.pre_renewal_insights import (
        pre_renewal_insights_endpoint,
    )
    from components.customer_health_partner.wellbeing_assessment.public.controllers.generate_wellbeing_assessment_participation_link import (
        wellbeing_assessment_participation_link_endpoint,
    )
    from components.customer_health_partner.wellbeing_assessment.public.controllers.wellbeing_assessment_survey import (
        wellbeing_assessment_survey_endpoint,
    )

    api.add_endpoint(accounts_endpoint)
    api.add_endpoint(hr_kit_endpoint)
    api.add_endpoint(customer_priorities_survey_endpoint)
    api.add_endpoint(crisis_endpoint)
    api.add_endpoint(badges_endpoint)
    api.add_endpoint(customer_metrics_endpoint)
    api.add_endpoint(pre_renewal_insights_endpoint)

    api.add_endpoint(wellbeing_assessment_participation_link_endpoint)
    api.add_endpoint(wellbeing_assessment_survey_endpoint)

badge

BadgesController

Bases: BaseController

badges_endpoint module-attribute

badges_endpoint = Endpoint('/badges')

crisis

CrisisRequestController

Bases: BaseController

get
get(params)
Source code in components/customer_health_partner/public/controllers/crisis.py
@view_method(
    auth_strategy=GlobalAuthorizationStrategies().authenticated(),
)
@request_argument(
    "account_id",
    type=str,
    required=True,
    owner_controller=NoOwner,
)
@obs.api_call()
def get(self, params: dict) -> "Response":  # type: ignore[type-arg]  # noqa: D102
    from components.customer_health_partner.crisis.public.business_logic.queries.crisis_request import (
        get_crisis_requests,
    )

    return make_json_response(get_crisis_requests(params["account_id"]))

crisis_endpoint module-attribute

crisis_endpoint = Endpoint('/crisis_requests')

customer_metrics

CustomerMetricsController

Bases: BaseController

customer_metrics_endpoint module-attribute

customer_metrics_endpoint = Endpoint('/customer_metrics')

customer_priorities_survey

CustomerPrioritiesSurveyController

Bases: BaseController

customer_priorities_survey_endpoint module-attribute

customer_priorities_survey_endpoint = Endpoint(
    "/customer_priorities_survey"
)

hr_kit

HrKitArticleController

Bases: BaseController

get
get(slug, params)
Source code in components/customer_health_partner/public/controllers/hr_kit.py
@view_method(auth_strategy=GlobalAuthorizationStrategies().open())
@request_argument("locale", type=DatoLocale, required=False)
@obs.api_call()
def get(self, slug: str, params: dict) -> Response:  # type: ignore[type-arg]  # noqa: D102
    from components.customer_health_partner.internal.business_logic.queries.hr_kit import (
        ArticleNotFound,
        get_hr_kit_article,
    )

    try:
        return make_json_response(
            get_hr_kit_article(
                slug=slug, locale=params.get("locale", DatoLocale.fr)
            )
        )
    except ArticleNotFound:
        return make_json_response({"error": "Article not found"}, code=404)

HrKitController

Bases: BaseController

get
get(params)
Source code in components/customer_health_partner/public/controllers/hr_kit.py
@view_method(auth_strategy=GlobalAuthorizationStrategies().open())
@request_argument("locale", type=DatoLocale, required=False)
@obs.api_call()
def get(self, params: dict) -> Response:  # type: ignore[type-arg]  # noqa: D102
    from components.customer_health_partner.internal.business_logic.queries.hr_kit import (
        HrKitPageNotFound,
        get_hr_kit_page,
    )

    try:
        return make_json_response(
            get_hr_kit_page(
                app_name=get_current_app_name(),
                locale=params.get("locale", DatoLocale.fr),
            )
        )
    except HrKitPageNotFound:
        return make_json_response({"error": "Hr kit page not found"}, code=404)

hr_kit_endpoint module-attribute

hr_kit_endpoint = Endpoint('/hr_kit')

pre_renewal_insights

PreRenewalInsightsController

Bases: BaseController

get
get(params)
Source code in components/customer_health_partner/public/controllers/pre_renewal_insights.py
@view_method(GlobalAuthorizationStrategies().authenticated())
@request_argument("account_id", type=str, required=True, owner_controller=NoOwner)
@obs.api_call()
def get(self, params: dict) -> Response:  # type: ignore[type-arg]  # noqa: D102
    from components.customer_health_partner.internal.business_logic.queries.pre_renewal_insights import (
        get_pre_renewal_insights,
    )

    ensure_admin_is_account_admin(g.current_user, params["account_id"])

    return make_json_response(
        get_pre_renewal_insights(
            account_id=params["account_id"], app_name=get_current_app_name()
        )
    )

pre_renewal_insights_endpoint module-attribute

pre_renewal_insights_endpoint = Endpoint(
    "/pre_renewal_insights"
)

components.customer_health_partner.public.entities

customer_priorities_survey

CustomerPrioritiesSurveyAnswer dataclass

CustomerPrioritiesSurveyAnswer(id, other_text, option)

Bases: DataClassJsonMixin

id instance-attribute
id
option instance-attribute
option
other_text instance-attribute
other_text

CustomerPrioritiesSurveyOption dataclass

CustomerPrioritiesSurveyOption(id, name)

Bases: DataClassJsonMixin

id instance-attribute
id
name instance-attribute
name

CustomerPrioritiesSurveySource

Bases: AlanBaseEnum

DASHBOARD class-attribute instance-attribute
DASHBOARD = 'dashboard'
EMAIL class-attribute instance-attribute
EMAIL = 'email'

Typeform

Bases: AlanBaseEnum

DEV class-attribute instance-attribute
DEV = 'Kezxmpib'
PROD class-attribute instance-attribute
PROD = 'yXFguPNU'

TypeformOptions

TypeformOptions(form_id)
Source code in components/customer_health_partner/public/entities/customer_priorities_survey.py
def __init__(self, form_id: Typeform) -> None:
    self.form_id = form_id
form_id instance-attribute
form_id = form_id
get_options
get_options()
Source code in components/customer_health_partner/public/entities/customer_priorities_survey.py
def get_options(self) -> dict:  # type: ignore[type-arg]  # noqa: D102
    match self.form_id:
        case Typeform.DEV:
            return {
                "Ig6mCOAidPry": "reduce_healthcare_costs",
                "FwjwD28on73x": "save_time_by_automation",
                "5EkDJJx8tiD5": "improve_salary_retention",
                "U9decxAqicHf": "reduce_absenteeism",
                "ttEeiFzFf96x": "improve_employer_brand",
                "other": "other",
            }
        case Typeform.PROD:
            return {
                "UKuzD8uzDRgU": "reduce_healthcare_costs",
                "z1DdH0WPHESW": "save_time_by_automation",
                "AjpfzBVA3kxu": "improve_salary_retention",
                "MhHSrgpGN42l": "reduce_absenteeism",
                "ovuYW0NtGew0": "improve_employer_brand",
                "other": "other",
            }
        case _:
            raise ValueError("Invalid form_id")

dashboard_state

DashboardState dataclass

DashboardState(
    assessment_id, company_ids, first_viewed_results_at
)

Bases: DataClassJsonMixin

assessment_id instance-attribute
assessment_id
company_ids instance-attribute
company_ids
dataclass_json_config class-attribute instance-attribute
dataclass_json_config = {'letter_case': CAMEL}
first_viewed_results_at instance-attribute
first_viewed_results_at

feature_summary

WellbeingAssessmentAvailability dataclass

WellbeingAssessmentAvailability(
    can_create_wellbeing_assessment=False,
    can_access_wellbeing_assessment=False,
    can_relaunch_wellbeing_assessment=False,
    has_wellbeing_assessment_results=False,
    has_seen_wellbeing_assessment_results=False,
    has_prevention_plan=False,
    has_seen_prevention_plan_report=False,
)

Bases: DataClassJsonMixin

can_access_wellbeing_assessment class-attribute instance-attribute
can_access_wellbeing_assessment = False
can_create_wellbeing_assessment class-attribute instance-attribute
can_create_wellbeing_assessment = False
can_relaunch_wellbeing_assessment class-attribute instance-attribute
can_relaunch_wellbeing_assessment = False
dataclass_json_config class-attribute instance-attribute
dataclass_json_config = {'letter_case': CAMEL}
has_prevention_plan class-attribute instance-attribute
has_prevention_plan = False
has_seen_prevention_plan_report class-attribute instance-attribute
has_seen_prevention_plan_report = False
has_seen_wellbeing_assessment_results class-attribute instance-attribute
has_seen_wellbeing_assessment_results = False
has_wellbeing_assessment_results class-attribute instance-attribute
has_wellbeing_assessment_results = False