/api/calc/testcode/{codeOrName}:
  post:
    tags: [Calculation]
    summary: Evaluate a configured calculation by test code or name and return the raw result map.
    security: []
    parameters:
      - name: codeOrName
        in: path
        required: true
        schema:
          type: string
        description: TestSiteCode or TestSiteName of the calculated test (case-insensitive).
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            description: Key-value pairs where keys match member tests used in the formula.
            additionalProperties:
              type: number
          example:
            TBIL: 5
            DBIL: 3
    responses:
      '200':
        description: Returns a single key/value pair with the canonical TestSiteCode or an empty object when the calculation is incomplete or missing.
        content:
          application/json:
            schema:
              type: object
            examples:
              success:
                value:
                  IBIL: 2.0
              incomplete:
                value: {}

/api/calc/testsite/{testSiteID}:
  post:
    tags: [Calculation]
    summary: Evaluate a calculation defined for a test site and return a structured result.
    security: []
    parameters:
      - name: testSiteID
        in: path
        required: true
        schema:
          type: integer
        description: Identifier for the test site whose definition should be evaluated.
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            description: Variable assignments required by the test site formula.
            additionalProperties:
              type: number
          example:
            result: 85
            gender: "female"
            age: 30
    responses:
      '200':
        description: Returns the calculated result, testSiteID, formula code, and echoed variables.
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                data:
                  type: object
                  properties:
                    result:
                      type: number
                    testSiteID:
                      type: integer
                    formula:
                      type: string
                    variables:
                      type: object
                      additionalProperties:
                        type: number
            examples:
              success:
                value:
                  status: success
                  data:
                    result: 92.4
                    testSiteID: 123
                    formula: "{result} * {factor} + {age}"
                    variables:
                      result: 85
                      gender: female
                      age: 30
      '404':
        description: No calculation defined for the requested test site.
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: failed
                message:
                  type: string
                  example: No calculation defined for this test site
