Aller au contenu principal

Contracts

Join types and invariants later agents must not redefine. Usage sketch: sketch.md. Package cut: ADR 0002.

Bodies stay unimplemented until a feature is requested.

Types​

TypeOwner packageFields
Accountidentityid, phone, email?, roles
RoleidentityPATIENT, CLINICIAN, IMAGING, LAB, ADMIN
Sessionidentityopaque token after verify
PatientProfilepatientaccountId, displayName, nni?, idCardUri?
ClinicianProfileclinicianaccountId, specialty
Appointmentpatient.appointmentid, patientId, clinicianId, slot, status, patientName, clinicianName
Encounterclinician.encounterid, appointmentId, notes
DiagnosticKinddiagnosticsIMAGING, LAB
DiagnosticOrderdiagnosticsid, encounterId?, patientId, kind, status, priority, patientName
DiagnosticResultdiagnosticsid, orderId, summary, artifactUri?
ConsentidentityaccountId, purpose, grantedAt
Clinicadminname, timezone

email is optional. afia-web/delete-account.html accepts a phone or an email. privacy.html names phone.

Invariants​

  • One Account row per login. Admin does not create a second user table.
  • A patient cannot write DiagnosticResult.
  • Patient reads of results are projections from diagnostics.
  • kind is the only imaging-versus-lab split on the write API.
  • Admin HTTP stays under /api/v1/afia/admin. Only the ADMIN role shell in afia-app opens it.
  • Validation happens at the HTTP DTO boundary. Domain types stay inside the package.
  • A context does not call another context's controller.

CCF business rules (RG)​

High-signal rules from the CCF §10.1 that apply to the first five modules (v1). Agents must not invent softer behaviour when implementing related flows. Full gap list: ccf-v1-gaps.md.

IdRule
RG-004Verify consent before a sensitive operation.
RG-006Keep patient and episode context on clinical actions.
RG-007A prescription is identifiable, dated, and attached to the encounter / patient.
RG-009A slot cannot be double-booked.
RG-011Notification channels are configured (not ad-hoc silent drops).
RG-012A teleconsultation closes only after the recording / compte-rendu step the product requires.

Facilitateur (paramédical actor in the CCF for modules 01–02) is not in the Role enum above. Treat it as an open product decision — do not invent a role, shell, or endpoints until an ADR says so.

HTTP envelope​

Reserved shape, not implemented: { data, status, message, errors }. WP-00 adds ApiEnvelope when the first write endpoint lands.

Auth​

docs/rationale.md still lists the identity model as open. The sketch uses OTP request and verify. WP-01 follows that sketch unless a later ADR replaces it.