> ## Documentation Index
> Fetch the complete documentation index at: https://hmis-docs.derrickmugabwa.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest laboratory results

> Submit normalized analyzer results to HMIS.

Identical messages are idempotent. Reusing a message identity with a changed payload returns a conflict for reconciliation.


## OpenAPI

````yaml POST /laboratory/integration/results
openapi: 3.1.0
info:
  title: HMIS API
  version: 1.0.0
  description: >-
    Versioned API for HMIS foundation resources and laboratory/radiology
    integrations. All operations use Laravel Sanctum bearer tokens with a
    dedicated ability per operation.
servers:
  - url: https://jaliprohmis.derrickmugabwa.dev/api/v1
    description: HMIS staging API
security:
  - bearerAuth: []
tags:
  - name: Foundation
    description: Authenticated HMIS context and reference data.
  - name: Laboratory integration
    description: Analyzer worklists and result ingestion.
  - name: Radiology integration
    description: PACS worklists and study ingestion.
paths:
  /laboratory/integration/results:
    post:
      tags:
        - Laboratory integration
      summary: Ingest analyzer results
      description: >-
        Ingests a normalized analyzer result message. The message identity is
        `instrument_code + message_id`; identical replays are idempotent and
        changed replays return a conflict. Requires `laboratory:results:write`.
        Rate limited to 120 requests per minute per authenticated user and IP.
      operationId: ingestLaboratoryResults
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LaboratoryResultRequest'
      responses:
        '200':
          description: Processed or duplicate message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LaboratoryResultResponse'
        '202':
          description: Message accepted for reconciliation or partially processed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LaboratoryResultResponse'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: Message identity was reused with a different payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LaboratoryResultResponse'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    LaboratoryResultRequest:
      type: object
      required:
        - message_id
        - instrument_code
        - specimen_number
        - received_at
        - results
      properties:
        message_id:
          type: string
          maxLength: 128
        instrument_code:
          type: string
          maxLength: 64
        specimen_number:
          type: string
          maxLength: 32
        received_at:
          type: string
          format: date-time
        results:
          type: array
          minItems: 1
          maxItems: 500
          items:
            $ref: '#/components/schemas/LaboratoryResultItem'
    LaboratoryResultResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - processed
            - partial
            - quarantined
            - duplicate
            - conflict
        message_id:
          type: string
        summary:
          type: array
          items:
            $ref: '#/components/schemas/LaboratoryResultSummaryItem'
        error:
          type:
            - string
            - 'null'
    LaboratoryResultItem:
      type: object
      required:
        - analyzer_test_code
        - value
      properties:
        analyzer_test_code:
          type: string
          maxLength: 64
        value:
          type:
            - string
            - number
            - integer
            - boolean
            - 'null'
        unit:
          type:
            - string
            - 'null'
          maxLength: 32
        flag:
          type:
            - string
            - 'null'
          maxLength: 32
        observed_at:
          type:
            - string
            - 'null'
          format: date-time
    LaboratoryResultSummaryItem:
      type: object
      properties:
        analyzer_test_code:
          type: string
        status:
          type: string
          enum:
            - imported
            - duplicate
            - rejected
        reason:
          type: string
    ErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: Unauthenticated.
      additionalProperties: true
    ValidationErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
      additionalProperties: true
  responses:
    Unauthenticated:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Bearer token is valid but lacks the required ability.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
    RateLimited:
      description: >-
        Integration endpoints are limited to 120 requests per minute per
        authenticated user and IP.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Sanctum personal access token
      description: >-
        Paste a Sanctum personal access token generated by a HMIS super
        administrator. Use only a token with the ability required by the
        selected operation.

````