إنتقل إلى المحتوى الرئيسي

WP-05 API spec

The module is in afia-api. Contract type: Appointment in contracts.md. Wire: exchange/booking.md.

Usage​

A patient lists and requests appointments on /api/v1/afia/appointments. A clinician reads the same rows on /api/v1/afia/clinician/agenda. /api/v1/afia/clinician/patients lists patients who have an appointment with that clinician.

Domain​

  • Appointment at health.afia.app.patient.appointment.Appointment. Contract Appointment.
  • Agenda code in health.afia.app.clinician.agenda reads that type. It does not own a second appointment type.

Persistence​

One AppointmentEntity table appointment. Two HTTP faces. No second table in clinician.

HTTP DTOs​

  • AppointmentRequestDto inbound. clinicianId, slot.
  • AppointmentResponseDto outbound. Contract Appointment fields.
  • AgendaQueryDto inbound. day.
  • ClinicianPatientResponseDto outbound. patientId and display fields projected from the appointment join. Not a copy of PatientProfile storage.

Mappers​

AppointmentMapper.toResponse(Appointment) -> AppointmentResponseDto
AppointmentMapper.toDomain(AppointmentEntity) -> Appointment

Services​

BookingService
listAppointments(session) -> Appointment[]
requestAppointment(session, clinicianId, slot) -> Appointment

AgendaService
clinicianAgenda(session, day) -> Appointment[]
clinicianPatients(session) -> patient ids from Appointment rows

writeEncounterNote in the sketch belongs to WP-06, not this package.

Controllers​

  • AppointmentController on reserved /api/v1/afia/appointments.
  • ClinicianAgendaController on reserved /api/v1/afia/clinician/agenda and /api/v1/afia/clinician/patients.

Does not do​

Profile packages, encounter notes, or diagnostics. A second appointment table. Flutter types. Invented calendar widgets.