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.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.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()

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[untyped-decorator]
    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.crisis import (
        crisis_endpoint,
    )
    from components.customer_health_partner.public.controllers.hr_kit import (
        hr_kit_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(crisis_endpoint)

    api.add_endpoint(wellbeing_assessment_survey_endpoint)

crisis

AccountIdGetQuerySchema

Bases: Schema

account_id class-attribute instance-attribute
account_id = Str(
    required=True, validate=OwnerController(NoOwner)
)

CrisisRequestController

Bases: BaseController

get
get(query_args)
Source code in components/customer_health_partner/public/controllers/crisis.py
@view_method(
    auth_strategy=GlobalAuthorizationStrategies().authenticated(),
)
@obs.api_call()
@use_args(
    AccountIdGetQuerySchema(),
    location="query",
    unknown=EXCLUDE,
    arg_name="query_args",
)
def get(self, query_args: 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(query_args["account_id"]))

crisis_endpoint module-attribute

crisis_endpoint = Endpoint('/crisis_requests')

hr_kit

HrKitArticleController

Bases: BaseController

get
get(slug, query_args)
Source code in components/customer_health_partner/public/controllers/hr_kit.py
@view_method(auth_strategy=GlobalAuthorizationStrategies().open())
@obs.api_call()
@use_args(
    HrKitArticleGetQuerySchema(),
    location="query",
    unknown=EXCLUDE,
    arg_name="query_args",
)
def get(self, slug: str, query_args: 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=query_args.get("locale", DatoLocale.fr)
            )
        )
    except ArticleNotFound:
        return make_json_response({"error": "Article not found"}, code=404)

HrKitArticleGetQuerySchema

Bases: Schema

locale class-attribute instance-attribute
locale = Enum(
    DatoLocale,
    by_value=True,
    required=False,
    allow_none=True,
)

HrKitPageController

Bases: BaseController

Single page details retrieval controller

get
get(page_id, query_args, user=None)

GET endpoint to get a page sections for the current app, in the given locale

Source code in components/customer_health_partner/public/controllers/hr_kit.py
@view_method(auth_strategy=GlobalAuthorizationStrategies().open())
@obs.api_call()
@use_args(
    HrKitPageGetQuerySchema(),
    location="query",
    unknown=EXCLUDE,
    arg_name="query_args",
)
def get(
    self,
    page_id: str,
    query_args: dict,  # type: ignore[type-arg]
    user: BaseUser | None = None,
) -> Response:
    """GET endpoint to get a page sections for the current app, in the given locale"""
    from components.customer_health_partner.internal.business_logic.queries.hr_kit import (
        HrKitPageNotFound,
        get_hr_kit_page,
    )

    context_account_id: UUID | None = query_args.get("context_account_id")
    try:
        return make_json_response(
            get_hr_kit_page(
                page_id=page_id,
                locale=query_args.get("locale", DatoLocale.fr),
                is_key_account=_is_key_account(context_account_id, user),
            )
        )
    except HrKitPageNotFound:
        return make_json_response({"error": "Hr kit page not found"}, code=404)

HrKitPageGetQuerySchema

Bases: Schema

Single page details retrieval query payload

context_account_id class-attribute instance-attribute
context_account_id = UUID(required=False, allow_none=True)
locale class-attribute instance-attribute
locale = Enum(
    DatoLocale,
    by_value=True,
    required=False,
    allow_none=True,
)

HrKitPagesController

Bases: BaseController

Pages list retrieval controller

get
get(query_args, user=None)

GET endpoint to list pages for the current app, in the given locale

Source code in components/customer_health_partner/public/controllers/hr_kit.py
@view_method(auth_strategy=GlobalAuthorizationStrategies().open())
@obs.api_call()
@use_args(
    HrKitPagesGetQuerySchema(),
    location="query",
    unknown=EXCLUDE,
    arg_name="query_args",
)
def get(self, query_args: dict, user: BaseUser | None = None) -> Response:  # type: ignore[type-arg]
    """GET endpoint to list pages for the current app, in the given locale"""
    from components.customer_health_partner.internal.business_logic.queries.hr_kit import (
        get_hr_kit_pages,
    )

    context_account_id: UUID | None = query_args.get("context_account_id")
    return make_json_response(
        get_hr_kit_pages(
            app_name=get_current_app_name(),
            locale=query_args.get("locale", DatoLocale.fr),
            is_key_account=_is_key_account(context_account_id, user),
        )
    )

HrKitPagesGetQuerySchema

Bases: Schema

Pages list retrieval query payload

context_account_id class-attribute instance-attribute
context_account_id = UUID(required=False, allow_none=True)
locale class-attribute instance-attribute
locale = Enum(
    DatoLocale,
    by_value=True,
    required=False,
    allow_none=True,
)

hr_kit_endpoint module-attribute

hr_kit_endpoint = Endpoint('/hr_kit')

components.customer_health_partner.public.entities

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