{ "openapi": "3.1.0", "info": { "title": "Pharma Field Force Reporting", "description": "Pharmaceutical field-force reporting \u2014 MVP. MRs file Daily Call Reports, ABMs review and approve them, and AGMs have a read-only overview.", "version": "0.1.0" }, "paths": { "/api/v1/auth/login": { "post": { "tags": [ "auth" ], "summary": "Login", "operationId": "login_api_v1_auth_login_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } }, "required": true }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenPair" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/auth/refresh": { "post": { "tags": [ "auth" ], "summary": "Refresh", "operationId": "refresh_api_v1_auth_refresh_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RefreshRequest" } } }, "required": true }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenPair" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/auth/logout": { "post": { "tags": [ "auth" ], "summary": "Logout", "operationId": "logout_api_v1_auth_logout_post", "responses": { "204": { "description": "Successful Response" } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/auth/me": { "get": { "tags": [ "auth" ], "summary": "Me", "operationId": "me_api_v1_auth_me_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CurrentUser" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/users/me/profile": { "get": { "tags": [ "users" ], "summary": "My Profile", "operationId": "my_profile_api_v1_users_me_profile_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MyProfile" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/users": { "get": { "tags": [ "users" ], "summary": "List Users", "operationId": "list_users_api_v1_users_get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "role", "in": "query", "required": false, "schema": { "anyOf": [ { "$ref": "#/components/schemas/Role" }, { "type": "null" } ], "title": "Role" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/UserRead" }, "title": "Response List Users Api V1 Users Get" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } }, "post": { "tags": [ "users" ], "summary": "Create User", "operationId": "create_user_api_v1_users_post", "security": [ { "HTTPBearer": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserCreate" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/users/{user_id}": { "patch": { "tags": [ "users" ], "summary": "Update User", "operationId": "update_user_api_v1_users__user_id__patch", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "user_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "User Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserUpdate" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/headquarters": { "get": { "tags": [ "organization" ], "summary": "List Headquarters", "description": "Scoped: an MR sees their own HQ, an ABM sees theirs, AGM/Admin see all.", "operationId": "list_headquarters_api_v1_headquarters_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "items": { "$ref": "#/components/schemas/HeadquartersRead" }, "type": "array", "title": "Response List Headquarters Api V1 Headquarters Get" } } } } }, "security": [ { "HTTPBearer": [] } ] }, "post": { "tags": [ "organization" ], "summary": "Create Headquarters", "operationId": "create_headquarters_api_v1_headquarters_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HeadquartersCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HeadquartersRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/headquarters/{headquarters_id}/area-manager": { "post": { "tags": [ "organization" ], "summary": "Assign Area Business Manager", "operationId": "assign_area_manager_api_v1_headquarters__headquarters_id__area_manager_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "headquarters_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Headquarters Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssignAreaManager" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AMHeadquartersRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/doctors": { "get": { "tags": [ "doctors" ], "summary": "List Doctors", "description": "S5 \u2014 an MR gets only their assigned doctors; managers get their HQ scope.", "operationId": "list_doctors_api_v1_doctors_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "items": { "$ref": "#/components/schemas/DoctorRead" }, "type": "array", "title": "Response List Doctors Api V1 Doctors Get" } } } } }, "security": [ { "HTTPBearer": [] } ] }, "post": { "tags": [ "doctors" ], "summary": "Create Doctor", "description": "A3 \u2014 an MR cannot create a doctor in the MVP. Confirm with client (Q3).", "operationId": "create_doctor_api_v1_doctors_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/doctors/{doctor_id}": { "patch": { "tags": [ "doctors" ], "summary": "Update Doctor", "operationId": "update_doctor_api_v1_doctors__doctor_id__patch", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "doctor_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Doctor Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorUpdate" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/doctors/{doctor_id}/assign": { "post": { "tags": [ "doctors" ], "summary": "Assign Doctor", "description": "An ABM may assign only within their own headquarters \u2014 enforced by data scope.", "operationId": "assign_doctor_api_v1_doctors__doctor_id__assign_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "doctor_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Doctor Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssignToMR" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/chemists": { "get": { "tags": [ "chemists" ], "summary": "List Chemists", "operationId": "list_chemists_api_v1_chemists_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "items": { "$ref": "#/components/schemas/ChemistRead" }, "type": "array", "title": "Response List Chemists Api V1 Chemists Get" } } } } }, "security": [ { "HTTPBearer": [] } ] }, "post": { "tags": [ "chemists" ], "summary": "Create Chemist", "operationId": "create_chemist_api_v1_chemists_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChemistCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChemistRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/chemists/{chemist_id}": { "patch": { "tags": [ "chemists" ], "summary": "Update Chemist", "operationId": "update_chemist_api_v1_chemists__chemist_id__patch", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "chemist_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Chemist Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChemistUpdate" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChemistRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/chemists/{chemist_id}/assign": { "post": { "tags": [ "chemists" ], "summary": "Assign Chemist", "operationId": "assign_chemist_api_v1_chemists__chemist_id__assign_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "chemist_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Chemist Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssignToMR" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr": { "get": { "tags": [ "reports" ], "summary": "List Reports", "description": "S2 (MR) and S6 (manager queue). Scope is applied in the service, never here.", "operationId": "list_reports_api_v1_dcr_get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "status", "in": "query", "required": false, "schema": { "anyOf": [ { "$ref": "#/components/schemas/DCRStatus" }, { "type": "null" } ], "title": "Status" } }, { "name": "date_from", "in": "query", "required": false, "schema": { "anyOf": [ { "type": "string", "format": "date" }, { "type": "null" } ], "title": "Date From" } }, { "name": "date_to", "in": "query", "required": false, "schema": { "anyOf": [ { "type": "string", "format": "date" }, { "type": "null" } ], "title": "Date To" } }, { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "maximum": 200, "minimum": 1, "default": 50, "title": "Limit" } }, { "name": "offset", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 0, "default": 0, "title": "Offset" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/DCRListItem" }, "title": "Response List Reports Api V1 Dcr Get" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } }, "post": { "tags": [ "reports" ], "summary": "Create Report", "operationId": "create_report_api_v1_dcr_post", "security": [ { "HTTPBearer": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRCreate" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/counts": { "get": { "tags": [ "reports" ], "summary": "Status Counts", "description": "Header counts \u2014 the deliberate, cheap replacement for the cut dashboards.", "operationId": "status_counts_api_v1_dcr_counts_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusCounts" } } } } }, "security": [ { "HTTPBearer": [] } ] } }, "/api/v1/dcr/{dcr_id}": { "get": { "tags": [ "reports" ], "summary": "Get Report", "operationId": "get_report_api_v1_dcr__dcr_id__get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } }, "patch": { "tags": [ "reports" ], "summary": "Update Report", "operationId": "update_report_api_v1_dcr__dcr_id__patch", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRUpdate" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/pdf": { "get": { "tags": [ "reports" ], "summary": "Download Pdf", "description": "SEC-7 \u2014 served through an authorised endpoint, never as a guessable static path.", "operationId": "download_pdf_api_v1_dcr__dcr_id__pdf_get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/calls/doctor": { "post": { "tags": [ "reports" ], "summary": "Add Doctor Call", "operationId": "add_doctor_call_api_v1_dcr__dcr_id__calls_doctor_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorCallCreate" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/calls/chemist": { "post": { "tags": [ "reports" ], "summary": "Add Chemist Call", "operationId": "add_chemist_call_api_v1_dcr__dcr_id__calls_chemist_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChemistCallCreate" } } } }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/calls/{call_id}": { "delete": { "tags": [ "reports" ], "summary": "Delete Call", "operationId": "delete_call_api_v1_dcr__dcr_id__calls__call_id__delete", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } }, { "name": "call_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Call Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/submit": { "post": { "tags": [ "reports" ], "summary": "Submit", "operationId": "submit_api_v1_dcr__dcr_id__submit_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/forward": { "post": { "tags": [ "reports" ], "summary": "Forward", "description": "The Area Business Manager forwards or returns \u2014 it does NOT approve (A4/Q4).", "operationId": "forward_api_v1_dcr__dcr_id__forward_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ForwardRequest" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/return": { "post": { "tags": [ "reports" ], "summary": "Return Report", "operationId": "return_report_api_v1_dcr__dcr_id__return_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReturnRequest" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/dcr/{dcr_id}/approve": { "post": { "tags": [ "reports" ], "summary": "Approve", "description": "AGM only. SEC-2: ADMIN is absent from this dependency by design.", "operationId": "approve_api_v1_dcr__dcr_id__approve_post", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApproveRequest" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DCRRead" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/audit": { "get": { "tags": [ "audit" ], "summary": "Get Audit History", "description": "Scoped audit history.\n\nFor a report, the caller must be able to view the report itself \u2014 the audit log is\nnot a side door around the data-scope rules.", "operationId": "get_audit_history_api_v1_audit_get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "entity_type", "in": "query", "required": true, "schema": { "$ref": "#/components/schemas/EntityType" } }, { "name": "entity_id", "in": "query", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Entity Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/AuditLogRead" }, "title": "Response Get Audit History Api V1 Audit Get" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/v1/audit/dcr/{dcr_id}/approval-history": { "get": { "tags": [ "audit" ], "summary": "Approval History", "description": "\"Approval history\" is a filtered view over audit_log, not a second table.", "operationId": "approval_history_api_v1_audit_dcr__dcr_id__approval_history_get", "security": [ { "HTTPBearer": [] } ], "parameters": [ { "name": "dcr_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid", "title": "Dcr Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/ApprovalHistoryItem" }, "title": "Response Approval History Api V1 Audit Dcr Dcr Id Approval History Get" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/health": { "get": { "tags": [ "meta" ], "summary": "Health", "operationId": "health_health_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "additionalProperties": { "type": "string" }, "type": "object", "title": "Response Health Health Get" } } } } } } } }, "components": { "schemas": { "AMHeadquartersRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "area_manager_user_id": { "type": "string", "format": "uuid", "title": "Area Business Manager User Id" }, "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "effective_from": { "type": "string", "format": "date", "title": "Effective From" }, "effective_to": { "anyOf": [ { "type": "string", "format": "date" }, { "type": "null" } ], "title": "Effective To" } }, "type": "object", "required": [ "id", "area_manager_user_id", "headquarters_id", "effective_from", "effective_to" ], "title": "AMHeadquartersRead" }, "ApprovalHistoryItem": { "properties": { "action": { "$ref": "#/components/schemas/AuditAction" }, "actor_name": { "type": "string", "title": "Actor Name" }, "actor_role": { "type": "string", "title": "Actor Role" }, "comment": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Comment" }, "at": { "type": "string", "format": "date-time", "title": "At" } }, "type": "object", "required": [ "action", "actor_name", "actor_role", "comment", "at" ], "title": "ApprovalHistoryItem", "description": "The approval trail as shown on S7 and printed in the PDF." }, "ApproveRequest": { "properties": { "comment": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Comment" } }, "type": "object", "title": "ApproveRequest" }, "AssignAreaManager": { "properties": { "area_manager_user_id": { "type": "string", "format": "uuid", "title": "Area Business Manager User Id" }, "effective_from": { "anyOf": [ { "type": "string", "format": "date" }, { "type": "null" } ], "title": "Effective From" } }, "type": "object", "required": [ "area_manager_user_id" ], "title": "AssignAreaManager" }, "AssignToMR": { "properties": { "mr_user_id": { "type": "string", "format": "uuid", "title": "Mr User Id" }, "effective_from": { "anyOf": [ { "type": "string", "format": "date" }, { "type": "null" } ], "title": "Effective From" } }, "type": "object", "required": [ "mr_user_id" ], "title": "AssignToMR" }, "AuditAction": { "type": "string", "enum": [ "CREATE", "UPDATE", "DELETE", "SUBMIT", "FORWARD", "RETURN", "APPROVE", "ASSIGN", "LOGIN", "DEACTIVATE" ], "title": "AuditAction" }, "AuditLogRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "actor_user_id": { "type": "string", "format": "uuid", "title": "Actor User Id" }, "entity_type": { "$ref": "#/components/schemas/EntityType" }, "entity_id": { "type": "string", "format": "uuid", "title": "Entity Id" }, "action": { "$ref": "#/components/schemas/AuditAction" }, "comment": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Comment" }, "before_data": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "title": "Before Data" }, "after_data": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "title": "After Data" }, "ip_address": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Ip Address" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" } }, "type": "object", "required": [ "id", "actor_user_id", "entity_type", "entity_id", "action", "comment", "before_data", "after_data", "ip_address", "created_at" ], "title": "AuditLogRead" }, "CallOutcome": { "type": "string", "enum": [ "MET", "NOT_AVAILABLE", "RESCHEDULED" ], "title": "CallOutcome" }, "ChemistCallCreate": { "properties": { "chemist_id": { "type": "string", "format": "uuid", "title": "Chemist Id" }, "visit_time": { "type": "string", "format": "time", "title": "Visit Time" }, "remarks": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Remarks" } }, "type": "object", "required": [ "chemist_id", "visit_time" ], "title": "ChemistCallCreate" }, "ChemistCallRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "chemist_id": { "type": "string", "format": "uuid", "title": "Chemist Id" }, "chemist_name": { "type": "string", "title": "Chemist Name" }, "visit_time": { "type": "string", "format": "time", "title": "Visit Time" }, "remarks": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Remarks" } }, "type": "object", "required": [ "id", "chemist_id", "chemist_name", "visit_time", "remarks" ], "title": "ChemistCallRead" }, "ChemistCreate": { "properties": { "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "name": { "type": "string", "maxLength": 200, "minLength": 2, "title": "Name" }, "shop_address": { "type": "string", "maxLength": 500, "minLength": 2, "title": "Shop Address" }, "contact_number": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Contact Number" } }, "type": "object", "required": [ "headquarters_id", "name", "shop_address" ], "title": "ChemistCreate" }, "ChemistRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "name": { "type": "string", "title": "Name" }, "shop_address": { "type": "string", "title": "Shop Address" }, "contact_number": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Contact Number" }, "is_active": { "type": "boolean", "title": "Is Active" } }, "type": "object", "required": [ "id", "headquarters_id", "name", "shop_address", "contact_number", "is_active" ], "title": "ChemistRead" }, "ChemistUpdate": { "properties": { "name": { "anyOf": [ { "type": "string", "maxLength": 200, "minLength": 2 }, { "type": "null" } ], "title": "Name" }, "shop_address": { "anyOf": [ { "type": "string", "maxLength": 500, "minLength": 2 }, { "type": "null" } ], "title": "Shop Address" }, "contact_number": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Contact Number" }, "is_active": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "title": "Is Active" } }, "type": "object", "title": "ChemistUpdate" }, "ConversionStatus": { "type": "string", "enum": [ "NOT_STARTED", "IN_PROGRESS", "CONVERTED", "LOST" ], "title": "ConversionStatus", "description": "Core-doctor conversion. Stored as a column on doctor_call, not a table." }, "CurrentUser": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "email": { "type": "string", "title": "Email" }, "full_name": { "type": "string", "title": "Full Name" }, "employee_code": { "type": "string", "title": "Employee Code" }, "role": { "$ref": "#/components/schemas/Role" }, "headquarters_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Headquarters Id" }, "is_active": { "type": "boolean", "title": "Is Active" } }, "type": "object", "required": [ "id", "email", "full_name", "employee_code", "role", "headquarters_id", "is_active" ], "title": "CurrentUser" }, "DCRCreate": { "properties": { "report_date": { "type": "string", "format": "date", "title": "Report Date" }, "mr_remarks": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Mr Remarks" }, "doctor_calls": { "items": { "$ref": "#/components/schemas/DoctorCallCreate" }, "type": "array", "title": "Doctor Calls" }, "chemist_calls": { "items": { "$ref": "#/components/schemas/ChemistCallCreate" }, "type": "array", "title": "Chemist Calls" } }, "type": "object", "required": [ "report_date" ], "title": "DCRCreate" }, "DCRListItem": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "report_date": { "type": "string", "format": "date", "title": "Report Date" }, "status": { "$ref": "#/components/schemas/DCRStatus" }, "mr_user_id": { "type": "string", "format": "uuid", "title": "Mr User Id" }, "mr_name": { "type": "string", "title": "Mr Name" }, "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "headquarters_name": { "type": "string", "title": "Headquarters Name" }, "doctor_call_count": { "type": "integer", "title": "Doctor Call Count" }, "chemist_call_count": { "type": "integer", "title": "Chemist Call Count" }, "submitted_at": { "anyOf": [ { "type": "string", "format": "date-time" }, { "type": "null" } ], "title": "Submitted At" }, "approved_at": { "anyOf": [ { "type": "string", "format": "date-time" }, { "type": "null" } ], "title": "Approved At" }, "returned_by_role": { "anyOf": [ { "$ref": "#/components/schemas/Role" }, { "type": "null" } ] } }, "type": "object", "required": [ "id", "report_date", "status", "mr_user_id", "mr_name", "headquarters_id", "headquarters_name", "doctor_call_count", "chemist_call_count", "submitted_at", "approved_at", "returned_by_role" ], "title": "DCRListItem", "description": "Row for S2/S6 \u2014 the list screens that replaced the cut dashboards." }, "DCRRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "mr_user_id": { "type": "string", "format": "uuid", "title": "Mr User Id" }, "mr_name": { "type": "string", "title": "Mr Name" }, "employee_code": { "type": "string", "title": "Employee Code" }, "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "headquarters_name": { "type": "string", "title": "Headquarters Name" }, "report_date": { "type": "string", "format": "date", "title": "Report Date" }, "status": { "$ref": "#/components/schemas/DCRStatus" }, "is_locked": { "type": "boolean", "title": "Is Locked" }, "mr_remarks": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Mr Remarks" }, "return_reason": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Return Reason" }, "returned_by_role": { "anyOf": [ { "$ref": "#/components/schemas/Role" }, { "type": "null" } ] }, "submitted_at": { "anyOf": [ { "type": "string", "format": "date-time" }, { "type": "null" } ], "title": "Submitted At" }, "approved_at": { "anyOf": [ { "type": "string", "format": "date-time" }, { "type": "null" } ], "title": "Approved At" }, "doctor_calls": { "items": { "$ref": "#/components/schemas/DoctorCallRead" }, "type": "array", "title": "Doctor Calls" }, "chemist_calls": { "items": { "$ref": "#/components/schemas/ChemistCallRead" }, "type": "array", "title": "Chemist Calls" } }, "type": "object", "required": [ "id", "mr_user_id", "mr_name", "employee_code", "headquarters_id", "headquarters_name", "report_date", "status", "is_locked", "mr_remarks", "return_reason", "returned_by_role", "submitted_at", "approved_at", "doctor_calls", "chemist_calls" ], "title": "DCRRead" }, "DCRStatus": { "type": "string", "enum": [ "DRAFT", "PENDING_ABM", "PENDING_GM", "RETURNED", "APPROVED" ], "title": "DCRStatus", "description": "5 states, down from the 7 originally proposed.\n\n- \"Returned by ABM\" and \"Returned by AGM\" collapse into RETURNED; who returned it\n is stored in `returned_by_role`, which is data, not state.\n- \"Finally Approved\" and \"Locked\" collapse into APPROVED. Immutability is a\n property of APPROVED enforced in one guard, not a second status." }, "DCRUpdate": { "properties": { "mr_remarks": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Mr Remarks" } }, "type": "object", "title": "DCRUpdate" }, "DoctorCallCreate": { "properties": { "doctor_id": { "type": "string", "format": "uuid", "title": "Doctor Id" }, "visit_time": { "type": "string", "format": "time", "title": "Visit Time" }, "call_outcome": { "$ref": "#/components/schemas/CallOutcome" }, "conversion_status": { "anyOf": [ { "$ref": "#/components/schemas/ConversionStatus" }, { "type": "null" } ] }, "remarks": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Remarks" } }, "type": "object", "required": [ "doctor_id", "visit_time", "call_outcome" ], "title": "DoctorCallCreate" }, "DoctorCallRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "doctor_id": { "type": "string", "format": "uuid", "title": "Doctor Id" }, "doctor_name": { "type": "string", "title": "Doctor Name" }, "doctor_speciality": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Doctor Speciality" }, "is_core_doctor": { "type": "boolean", "title": "Is Core Doctor" }, "visit_time": { "type": "string", "format": "time", "title": "Visit Time" }, "call_outcome": { "$ref": "#/components/schemas/CallOutcome" }, "conversion_status": { "anyOf": [ { "$ref": "#/components/schemas/ConversionStatus" }, { "type": "null" } ] }, "remarks": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Remarks" } }, "type": "object", "required": [ "id", "doctor_id", "doctor_name", "doctor_speciality", "is_core_doctor", "visit_time", "call_outcome", "conversion_status", "remarks" ], "title": "DoctorCallRead" }, "DoctorCreate": { "properties": { "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "name": { "type": "string", "maxLength": 200, "minLength": 2, "title": "Name" }, "clinic_address": { "type": "string", "maxLength": 500, "minLength": 2, "title": "Clinic Address" }, "speciality": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "Speciality" }, "qualification": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "Qualification" }, "contact_number": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Contact Number" }, "is_core_doctor": { "type": "boolean", "title": "Is Core Doctor", "default": false } }, "type": "object", "required": [ "headquarters_id", "name", "clinic_address" ], "title": "DoctorCreate" }, "DoctorRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "headquarters_id": { "type": "string", "format": "uuid", "title": "Headquarters Id" }, "name": { "type": "string", "title": "Name" }, "clinic_address": { "type": "string", "title": "Clinic Address" }, "speciality": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Speciality" }, "qualification": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Qualification" }, "contact_number": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Contact Number" }, "is_core_doctor": { "type": "boolean", "title": "Is Core Doctor" }, "is_active": { "type": "boolean", "title": "Is Active" }, "assigned_mr_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Assigned Mr Name" } }, "type": "object", "required": [ "id", "headquarters_id", "name", "clinic_address", "speciality", "qualification", "contact_number", "is_core_doctor", "is_active" ], "title": "DoctorRead" }, "DoctorUpdate": { "properties": { "name": { "anyOf": [ { "type": "string", "maxLength": 200, "minLength": 2 }, { "type": "null" } ], "title": "Name" }, "clinic_address": { "anyOf": [ { "type": "string", "maxLength": 500, "minLength": 2 }, { "type": "null" } ], "title": "Clinic Address" }, "speciality": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "Speciality" }, "qualification": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "Qualification" }, "contact_number": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Contact Number" }, "is_core_doctor": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "title": "Is Core Doctor" }, "is_active": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "title": "Is Active" } }, "type": "object", "title": "DoctorUpdate" }, "EntityType": { "type": "string", "enum": [ "user", "headquarters", "doctor", "chemist", "dcr" ], "title": "EntityType" }, "ForwardRequest": { "properties": { "comment": { "anyOf": [ { "type": "string", "maxLength": 2000 }, { "type": "null" } ], "title": "Comment" } }, "type": "object", "title": "ForwardRequest" }, "HTTPValidationError": { "properties": { "detail": { "items": { "$ref": "#/components/schemas/ValidationError" }, "type": "array", "title": "Detail" } }, "type": "object", "title": "HTTPValidationError" }, "HeadquartersCreate": { "properties": { "code": { "type": "string", "maxLength": 20, "minLength": 1, "title": "Code" }, "name": { "type": "string", "maxLength": 200, "minLength": 2, "title": "Name" }, "district": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "District" }, "state": { "anyOf": [ { "type": "string", "maxLength": 100 }, { "type": "null" } ], "title": "State" } }, "type": "object", "required": [ "code", "name" ], "title": "HeadquartersCreate" }, "HeadquartersRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "company_id": { "type": "string", "format": "uuid", "title": "Company Id" }, "code": { "type": "string", "title": "Code" }, "name": { "type": "string", "title": "Name" }, "district": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "District" }, "state": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "State" }, "is_active": { "type": "boolean", "title": "Is Active" } }, "type": "object", "required": [ "id", "company_id", "code", "name", "district", "state", "is_active" ], "title": "HeadquartersRead" }, "LoginRequest": { "properties": { "email": { "type": "string", "format": "email", "title": "Email" }, "password": { "type": "string", "minLength": 1, "title": "Password" } }, "type": "object", "required": [ "email", "password" ], "title": "LoginRequest" }, "MyProfile": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "full_name": { "type": "string", "title": "Full Name" }, "employee_code": { "type": "string", "title": "Employee Code" }, "email": { "type": "string", "title": "Email" }, "role": { "$ref": "#/components/schemas/Role" }, "phone": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Phone" }, "headquarters_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Headquarters Id" }, "headquarters_code": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Headquarters Code" }, "headquarters_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Headquarters Name" }, "reporting_manager_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Reporting Manager Id" }, "reporting_manager_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Reporting Manager Name" } }, "type": "object", "required": [ "id", "full_name", "employee_code", "email", "role", "phone", "headquarters_id", "headquarters_code", "headquarters_name", "reporting_manager_id", "reporting_manager_name" ], "title": "MyProfile", "description": "S4 \u2014 the MR profile screen. Includes the DERIVED reporting Area Business Manager." }, "RefreshRequest": { "properties": { "refresh_token": { "type": "string", "title": "Refresh Token" } }, "type": "object", "required": [ "refresh_token" ], "title": "RefreshRequest" }, "ReturnRequest": { "properties": { "reason": { "type": "string", "maxLength": 2000, "minLength": 10, "title": "Reason" } }, "type": "object", "required": [ "reason" ], "title": "ReturnRequest", "description": "V8 \u2014 a manager must say WHY. This reason is what makes the audit trail useful." }, "Role": { "type": "string", "enum": [ "ADMIN", "AGM", "ABM", "MR" ], "title": "Role", "description": "Operational roles (MR/ABM/AGM) plus the technical ADMIN role.\n\nADMIN sits OUTSIDE the business hierarchy. It provisions users and masters, may monitor and read reports, but can never approve one (report \u00a78, SEC-2)." }, "StatusCounts": { "properties": { "DRAFT": { "type": "integer", "title": "Draft", "default": 0 }, "PENDING_ABM": { "type": "integer", "title": "Pending Am", "default": 0 }, "PENDING_GM": { "type": "integer", "title": "Pending Gm", "default": 0 }, "RETURNED": { "type": "integer", "title": "Returned", "default": 0 }, "APPROVED": { "type": "integer", "title": "Approved", "default": 0 } }, "type": "object", "title": "StatusCounts", "description": "Header counts on the list screens \u2014 the cheap replacement for dashboards." }, "TokenPair": { "properties": { "access_token": { "type": "string", "title": "Access Token" }, "refresh_token": { "type": "string", "title": "Refresh Token" }, "token_type": { "type": "string", "title": "Token Type", "default": "bearer" }, "expires_in": { "type": "integer", "title": "Expires In" } }, "type": "object", "required": [ "access_token", "refresh_token", "expires_in" ], "title": "TokenPair" }, "UserCreate": { "properties": { "email": { "type": "string", "format": "email", "title": "Email" }, "password": { "type": "string", "maxLength": 128, "minLength": 8, "title": "Password" }, "full_name": { "type": "string", "maxLength": 200, "minLength": 2, "title": "Full Name" }, "employee_code": { "type": "string", "maxLength": 50, "minLength": 1, "title": "Employee Code" }, "role": { "$ref": "#/components/schemas/Role" }, "phone": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Phone" }, "headquarters_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Headquarters Id" } }, "type": "object", "required": [ "email", "password", "full_name", "employee_code", "role" ], "title": "UserCreate" }, "UserRead": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, "email": { "type": "string", "title": "Email" }, "full_name": { "type": "string", "title": "Full Name" }, "employee_code": { "type": "string", "title": "Employee Code" }, "role": { "$ref": "#/components/schemas/Role" }, "phone": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Phone" }, "headquarters_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Headquarters Id" }, "is_active": { "type": "boolean", "title": "Is Active" } }, "type": "object", "required": [ "id", "email", "full_name", "employee_code", "role", "phone", "headquarters_id", "is_active" ], "title": "UserRead" }, "UserUpdate": { "properties": { "full_name": { "anyOf": [ { "type": "string", "maxLength": 200, "minLength": 2 }, { "type": "null" } ], "title": "Full Name" }, "phone": { "anyOf": [ { "type": "string", "maxLength": 20 }, { "type": "null" } ], "title": "Phone" }, "headquarters_id": { "anyOf": [ { "type": "string", "format": "uuid" }, { "type": "null" } ], "title": "Headquarters Id" }, "is_active": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "title": "Is Active" } }, "type": "object", "title": "UserUpdate" }, "ValidationError": { "properties": { "loc": { "items": { "anyOf": [ { "type": "string" }, { "type": "integer" } ] }, "type": "array", "title": "Location" }, "msg": { "type": "string", "title": "Message" }, "type": { "type": "string", "title": "Error Type" }, "input": { "title": "Input" }, "ctx": { "type": "object", "title": "Context" } }, "type": "object", "required": [ "loc", "msg", "type" ], "title": "ValidationError" } }, "securitySchemes": { "HTTPBearer": { "type": "http", "scheme": "bearer" } } } }