Aller au contenu principal

WP-07 API spec

The module is in afia-api. Contract types: DiagnosticKind, DiagnosticOrder, DiagnosticResult in contracts.md. Wire: exchange/diagnostics.md.

Usage​

POST /api/v1/afia/orders creates an order. GET /api/v1/afia/worklists?kind= returns orders for the caller role. POST /api/v1/afia/orders/{id}/results stores one result. A patient caller is rejected on write.

Domain​

  • DiagnosticKind at health.afia.app.diagnostics.DiagnosticKind. Contract DiagnosticKind.
  • DiagnosticOrder at health.afia.app.diagnostics.DiagnosticOrder. Contract DiagnosticOrder.
  • DiagnosticResult at health.afia.app.diagnostics.DiagnosticResult. Contract DiagnosticResult.

Imaging and lab share these types. kind is the only write-API split.

Persistence​

DiagnosticOrderEntity table diagnostic_order. DiagnosticResultEntity table diagnostic_result. One store. Patient reads go through WP-08. They do not copy rows.

HTTP DTOs​

  • CreateOrderDto inbound. patientId, kind, optional encounterId.
  • OrderResponseDto outbound. Contract DiagnosticOrder fields.
  • SubmitResultDto inbound. summary, optional artifactUri.
  • ResultResponseDto outbound. Contract DiagnosticResult fields.

Mappers​

DiagnosticOrderMapper.toResponse(DiagnosticOrder) -> OrderResponseDto
DiagnosticOrderMapper.toDomain(DiagnosticOrderEntity) -> DiagnosticOrder
DiagnosticResultMapper.toResponse(DiagnosticResult) -> ResultResponseDto
DiagnosticResultMapper.toDomain(DiagnosticResultEntity) -> DiagnosticResult

Services​

DiagnosticsService
createOrder(session, patientId, kind, encounterId?) -> DiagnosticOrder
worklist(session, kind) -> DiagnosticOrder[]
submitResult(session, orderId, result) -> DiagnosticResult
resultsForPatient(session, patientId) -> DiagnosticResult[]

resultsForPatient is the owner-package read. WP-08 projects it to the patient HTTP face.

Controllers​

  • OrderController on reserved /api/v1/afia/orders.
  • WorklistController on reserved /api/v1/afia/worklists.

Does not do​

health.afia.app.patient.results persistence. Appointment or encounter persistence. Two public APIs for imaging and lab. Flutter types. PACS viewers.