openapi: 3.1.0
info:
  title: CLQMS - Clinical Laboratory Quality Management System API
  description: |
    API for Clinical Laboratory Quality Management System supporting patient management,
    specimen tracking, test ordering, instrument integration, and laboratory operations.
    
    **IMPORTANT:** For OpenAPI tools (Swagger UI, Redoc, Postman, etc.), use the bundled file:
    `api-docs.bundled.yaml` which contains all paths and schemas merged into one file.
    
    This file (api-docs.yaml) contains schema references and is meant for development.
    The paths are defined in separate files in the `paths/` directory.
  version: 1.0.0
  contact:
    name: CLQMS API Support
  license:
    name: Proprietary

servers:
  - url: http://localhost/clqms01/
    description: Local development server
  - url: https://clqms01-api.services-summit.my.id/
    description: Production server

tags:
  - name: Authentication
    description: User authentication and session management
  - name: Patient
    description: Patient registration and management
  - name: Patient Visit
    description: Patient visit/encounter management
  - name: Organization
    description: Organization structure (accounts, sites, disciplines, departments, workstations)
  - name: Location
    description: Location management (rooms, wards, buildings)
  - name: Equipment
    description: Laboratory equipment and instrument management
  - name: Specimen
    description: Specimen and container management
  - name: Test
    description: Test definitions and test catalog
  - name: Rule
    description: Rule engine - rules can be linked to multiple tests via testrule mapping table
  - name: Calculation
    description: Lightweight calculator endpoint for retrieving computed values by code or name
  - name: Order
    description: Laboratory order management
  - name: Result
    description: Patient results reporting with auto-validation
  - name: Report
    description: Lab report generation (HTML view)
  - name: Edge API
    description: Instrument integration endpoints
  - name: Contact
    description: Contact management (doctors, practitioners, etc.)
  - name: ValueSet
    description: Value set definitions and items
  - name: User
    description: User management and administration
  - name: Demo
    description: Demo/test endpoints (no authentication)
  - name: Audit
    description: Audit log retrieval and filtering

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token from login endpoint
    cookieAuth:
      type: apiKey
      in: cookie
      name: token
      description: JWT token stored in HTTP-only cookie

  schemas:
    # Common schemas
    SuccessResponse:
      $ref: './components/schemas/common.yaml#/SuccessResponse'
    ErrorResponse:
      $ref: './components/schemas/common.yaml#/ErrorResponse'
    DashboardSummary:
      $ref: './components/schemas/common.yaml#/DashboardSummary'

    # Authentication schemas
    LoginRequest:
      $ref: './components/schemas/authentication.yaml#/LoginRequest'
    LoginResponse:
      $ref: './components/schemas/authentication.yaml#/LoginResponse'
    RegisterRequest:
      $ref: './components/schemas/authentication.yaml#/RegisterRequest'

    # Patient schemas
    Patient:
      $ref: './components/schemas/patient.yaml#/Patient'
    PatientIdentifier:
      $ref: './components/schemas/patient.yaml#/PatientIdentifier'
    LinkedPatient:
      $ref: './components/schemas/patient.yaml#/LinkedPatient'
    Custodian:
      $ref: './components/schemas/patient.yaml#/Custodian'
    PatAttEntry:
      $ref: './components/schemas/patient.yaml#/PatAttEntry'
    PatientListResponse:
      $ref: './components/schemas/patient.yaml#/PatientListResponse'

    # Patient Visit schemas
    PatientVisit:
      $ref: './components/schemas/patient-visit.yaml#/PatientVisit'
    PatVisitADT:
      $ref: './components/schemas/patient-visit.yaml#/PatVisitADT'

    # Organization schemas
    Account:
      $ref: './components/schemas/organization.yaml#/Account'
    Site:
      $ref: './components/schemas/organization.yaml#/Site'
    Discipline:
      $ref: './components/schemas/organization.yaml#/Discipline'
    Department:
      $ref: './components/schemas/organization.yaml#/Department'
    Workstation:
      $ref: './components/schemas/organization.yaml#/Workstation'
    HostApp:
      $ref: './components/schemas/organization.yaml#/HostApp'
    HostComPara:
      $ref: './components/schemas/organization.yaml#/HostComPara'
    CodingSys:
      $ref: './components/schemas/organization.yaml#/CodingSys'

    # Specimen schemas
    Specimen:
      $ref: './components/schemas/specimen.yaml#/Specimen'
    ContainerDef:
      $ref: './components/schemas/specimen.yaml#/ContainerDef'
    SpecimenPrep:
      $ref: './components/schemas/specimen.yaml#/SpecimenPrep'
    SpecimenStatus:
      $ref: './components/schemas/specimen.yaml#/SpecimenStatus'
    SpecimenCollection:
      $ref: './components/schemas/specimen.yaml#/SpecimenCollection'

    # Tests schemas
    TestDefinition:
      $ref: './components/schemas/tests.yaml#/TestDefinition'
    TestMap:
      $ref: './components/schemas/tests.yaml#/TestMap'

    # Orders schemas
    OrderTestList:
      $ref: './components/schemas/orders.yaml#/OrderTestList'
    OrderTest:
      $ref: './components/schemas/orders.yaml#/OrderTest'
    OrderItem:
      $ref: './components/schemas/orders.yaml#/OrderItem'

    # Edge API schemas
    EdgeResultRequest:
      $ref: './components/schemas/edge-api.yaml#/EdgeResultRequest'
    EdgeResultResponse:
      $ref: './components/schemas/edge-api.yaml#/EdgeResultResponse'
    EdgeOrder:
      $ref: './components/schemas/edge-api.yaml#/EdgeOrder'

    # ValueSets schemas
    ValueSetLibItem:
      $ref: './components/schemas/valuesets.yaml#/ValueSetLibItem'
    ValueSetDef:
      $ref: './components/schemas/valuesets.yaml#/ValueSetDef'
    ValueSetItem:
      $ref: './components/schemas/valuesets.yaml#/ValueSetItem'

    # Locations schemas
    Location:
      $ref: './components/schemas/master-data.yaml#/Location'

    # EquipmentList schemas
    EquipmentList:
      $ref: './components/schemas/equipmentlist.yaml#/EquipmentList'

    # User schemas
    User:
      $ref: './components/schemas/user.yaml#/User'
    UserCreate:
      $ref: './components/schemas/user.yaml#/UserCreate'
    UserUpdate:
      $ref: './components/schemas/user.yaml#/UserUpdate'
    UserListResponse:
      $ref: './components/schemas/user.yaml#/UserListResponse'

    # Rules schemas
    RuleDef:
      $ref: './components/schemas/rules.yaml#/RuleDef'
    RuleWithDetails:
      $ref: './components/schemas/rules.yaml#/RuleWithDetails'
    TestRule:
      $ref: './components/schemas/rules.yaml#/TestRule'  # Mapping table between rules and tests

# Paths are in separate files in the paths/ directory
# To view the complete API with all paths, use: api-docs.bundled.yaml
# To rebuild the bundle after changes: python bundle-api-docs.py
paths: {}
