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
DiagnosticKindathealth.afia.app.diagnostics.DiagnosticKind. ContractDiagnosticKind.DiagnosticOrderathealth.afia.app.diagnostics.DiagnosticOrder. ContractDiagnosticOrder.DiagnosticResultathealth.afia.app.diagnostics.DiagnosticResult. ContractDiagnosticResult.
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
CreateOrderDtoinbound.patientId,kind, optionalencounterId.OrderResponseDtooutbound. ContractDiagnosticOrderfields.SubmitResultDtoinbound.summary, optionalartifactUri.ResultResponseDtooutbound. ContractDiagnosticResultfields.
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
OrderControlleron reserved/api/v1/afia/orders.WorklistControlleron 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.