116 lines
3.1 KiB
Python
116 lines
3.1 KiB
Python
"""Domain enumerations.
|
|
|
|
Roles are a fixed enum on `user.role`, not a `role` table — with 4 roles that never
|
|
change at runtime a lookup table adds a join to every request and buys nothing.
|
|
(See report §13.2.)
|
|
"""
|
|
|
|
from enum import StrEnum
|
|
|
|
|
|
class Role(StrEnum):
|
|
"""Operational roles (MR/AM/GM) plus the technical ADMIN role.
|
|
|
|
ADMIN sits OUTSIDE the business hierarchy. It provisions users and masters but
|
|
can never approve a report or read report content (report §8, SEC-2).
|
|
"""
|
|
|
|
ADMIN = "ADMIN"
|
|
GM = "GM"
|
|
AM = "AM"
|
|
MR = "MR"
|
|
#: Senior Field Executive: does an MR's work (daily reports, forms, doctors, chemists) and
|
|
#: reports to the same Area Manager, but may cover several headquarters.
|
|
SFE = "SFE"
|
|
|
|
|
|
#: The roles that do field work and file reports; everywhere "an MR" is checked, an SFE counts too.
|
|
FIELD_ROLES: frozenset[Role] = frozenset({Role.MR, Role.SFE})
|
|
|
|
|
|
class DCRStatus(StrEnum):
|
|
"""MR submits, the Area Manager approves or returns it.
|
|
|
|
`RETURNED` captures the correction loop, and `APPROVED` remains terminal and
|
|
immutable. There is no General Manager step.
|
|
"""
|
|
|
|
DRAFT = "DRAFT"
|
|
PENDING_AM = "PENDING_AM"
|
|
RETURNED = "RETURNED"
|
|
APPROVED = "APPROVED"
|
|
|
|
|
|
class ReportType(StrEnum):
|
|
"""An MR files two reports a day, each approved by the Area Manager on its own.
|
|
|
|
PLAN — in the morning: which doctors and chemists the MR intends to visit, and when.
|
|
ACTUAL — at the end of the day: the visits that happened, plus a short note for every
|
|
planned visit that did not. It can be started only once the plan is approved.
|
|
SELF — an Area Manager's own end-of-day report of the visits they made. It needs no
|
|
plan and no approval: submitting it makes it final.
|
|
"""
|
|
|
|
PLAN = "PLAN"
|
|
ACTUAL = "ACTUAL"
|
|
SELF = "SELF"
|
|
|
|
|
|
#: Statuses in which the owning MR may still change report data (V9).
|
|
EDITABLE_STATUSES: frozenset[DCRStatus] = frozenset(
|
|
{DCRStatus.DRAFT, DCRStatus.RETURNED}
|
|
)
|
|
|
|
|
|
class WorkflowAction(StrEnum):
|
|
SUBMIT = "SUBMIT"
|
|
RETURN = "RETURN"
|
|
APPROVE = "APPROVE"
|
|
|
|
|
|
class CallOutcome(StrEnum):
|
|
MET = "MET"
|
|
NOT_AVAILABLE = "NOT_AVAILABLE"
|
|
RESCHEDULED = "RESCHEDULED"
|
|
|
|
|
|
class ConversionStatus(StrEnum):
|
|
"""Core-doctor conversion. Stored as a column on doctor_call, not a table."""
|
|
|
|
NOT_STARTED = "NOT_STARTED"
|
|
IN_PROGRESS = "IN_PROGRESS"
|
|
CONVERTED = "CONVERTED"
|
|
LOST = "LOST"
|
|
|
|
|
|
class MasterApproval(StrEnum):
|
|
"""A doctor or chemist an MR adds waits for their Area Manager before anyone can use it."""
|
|
|
|
PENDING = "PENDING"
|
|
APPROVED = "APPROVED"
|
|
REJECTED = "REJECTED"
|
|
|
|
|
|
class AuditAction(StrEnum):
|
|
CREATE = "CREATE"
|
|
UPDATE = "UPDATE"
|
|
DELETE = "DELETE"
|
|
SUBMIT = "SUBMIT"
|
|
FORWARD = "FORWARD"
|
|
RETURN = "RETURN"
|
|
APPROVE = "APPROVE"
|
|
ASSIGN = "ASSIGN"
|
|
LOGIN = "LOGIN"
|
|
DEACTIVATE = "DEACTIVATE"
|
|
|
|
|
|
class EntityType(StrEnum):
|
|
USER = "user"
|
|
HEADQUARTERS = "headquarters"
|
|
DOCTOR = "doctor"
|
|
CHEMIST = "chemist"
|
|
DCR = "dcr"
|
|
PRODUCT = "product"
|
|
#: A row of a company form (the table is named in the entry's data).
|
|
FORM_ROW = "form_row"
|