Skip to main content

WP-04 API spec

The module is in afia-api. Contract types: Account, Role, Clinic in contracts.md. Wire: exchange/admin.md.

Usage​

Admin HTTP lists accounts and assigns roles that already exist on Account. Clinic configuration is one resource with name and timezone. Paths stay under /api/v1/afia/admin.

Domain​

  • Clinic at health.afia.app.admin.Clinic. Contract Clinic.
  • Reuse Account and Role from identity. Do not redefine them.

Persistence​

ClinicEntity table clinic. One row is enough until WP-10. Directory reads Account through identity. No second user table.

HTTP DTOs​

  • AdminUserResponseDto outbound. Account fields the directory shows.
  • AssignRoleDto inbound. accountId, role.
  • ClinicRequestDto inbound. name, timezone.
  • ClinicResponseDto outbound. Same fields as contract Clinic.

Mappers​

ClinicMapper.toResponse(Clinic) -> ClinicResponseDto
ClinicMapper.toDomain(ClinicEntity) -> Clinic

Account listing maps with identity's AccountMapper or a package-local view that does not persist a copy.

Services​

AdminDirectoryService
listAccounts() -> Account[]
assignRole(accountId, role) -> Account
getClinic() -> Clinic
updateClinic(name, timezone) -> Clinic

Controllers​

  • AdminController on reserved /api/v1/afia/admin. Users, role assignment, and clinic on that prefix.

Does not do​

Identity persistence. afia-web pages. Patient, clinician, or diagnostics packages. Flutter types. Invented admin screens.