{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/acuiq-com/json-schema/acuiq-com-search-result-response-schema.json",
  "title": "SearchResultResponse",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/acuiq-com-openapi.json#/components/schemas/SearchResultResponse",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/SearchResult"
    },
    "error": {
      "type": "string"
    },
    "code": {
      "type": "string"
    }
  },
  "$defs": {
    "Meridian": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "element": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "Protocol": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "ref": {
          "type": [
            "string",
            "null"
          ],
          "description": "Source reference"
        },
        "cred": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Credibility score"
        },
        "modality": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "needling",
              "electroacupuncture",
              "moxibustion",
              "acupressure",
              "press-needle",
              "teas",
              "laser",
              "embedding",
              "injection",
              "application",
              "bloodletting",
              "cupping"
            ]
          },
          "description": "How the source delivered the points; empty when it does not say"
        },
        "sessions": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Treatment sessions in the course the source ran"
        },
        "courseDays": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Calendar length of that course in days, follow-up excluded"
        },
        "outcome": {
          "type": "string",
          "enum": [
            "positive",
            "no-effect",
            "unreported",
            "not-tested"
          ],
          "description": "What the source reported for this arm; not-tested is a textbook or web indication. Search returns positive and not-tested rows, and no-effect rows whose comparator is sham"
        },
        "comparator": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "sham",
            "active",
            "usual-care",
            "waitlist",
            "none"
          ],
          "description": "What the arm was measured against; none is a single-arm before-and-after study. Null where the result has not been read"
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "description": "An erratum in the source, or how this row relates to sibling rows from the same paper"
        },
        "sex": {
          "type": [
            "string",
            "null"
          ]
        },
        "age": {
          "type": [
            "number",
            "null"
          ],
          "description": "Recorded cohort age, often a mean"
        },
        "symptoms": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Symptom"
          }
        },
        "protocolTreatments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProtocolTreatment"
          }
        }
      },
      "required": [
        "id",
        "protocol",
        "symptoms",
        "protocolTreatments"
      ]
    },
    "ProtocolMatch": {
      "type": "object",
      "properties": {
        "protocol": {
          "$ref": "#/$defs/Protocol"
        },
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Fuzzy match relevance score"
        },
        "sourceKind": {
          "type": "string",
          "enum": [
            "study",
            "text",
            "web",
            "unsourced"
          ],
          "description": "How the source reference was classified"
        },
        "source": {
          "type": "string",
          "description": "Human-readable source label"
        },
        "caveat": {
          "type": "string",
          "description": "Plain-language statement of what this row is"
        },
        "substantiation": {
          "type": "object",
          "description": "Which of this row's points a study-reported protocol for the same query also chose. On a study-reported row it compares against every OTHER study, matched on distinct reference so a paper carrying several prescriptions cannot corroborate itself; on any other row it compares against all of them. Absent when no study but this row's own covers the query (see studyBacked). An empty `points` array is meaningful: studies cover the query and none used any of these points. Two limits travel with it — a shared point is not an endorsement of the prescription, because no study tested it; and a second reference is not necessarily a second research group.",
          "properties": {
            "points": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Point codes shared with a study-reported protocol"
            },
            "study": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "description": "Present when the study is directly reachable"
                }
              },
              "required": [
                "label"
              ]
            }
          },
          "required": [
            "points",
            "study"
          ]
        }
      },
      "required": [
        "protocol",
        "score",
        "sourceKind",
        "source",
        "caveat"
      ]
    },
    "ProtocolTreatment": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "treatment": {
          "$ref": "#/$defs/Treatment"
        }
      },
      "required": [
        "id",
        "treatment"
      ]
    },
    "SearchResult": {
      "type": "object",
      "properties": {
        "matches": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProtocolMatch"
          }
        },
        "directMatches": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Treatment"
          },
          "description": "Points whose indications list the searched symptoms, returned only when no protocol matched. Index entries, not prescriptions."
        },
        "studyBacked": {
          "type": "boolean",
          "description": "Whether any study-reported protocol covers this query at all, decided over the whole ranked candidate set rather than the page returned. False means every prescription on offer comes from a clinical text or a website."
        },
        "query": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Normalized symptom names"
        },
        "queryAge": {
          "type": [
            "integer",
            "null"
          ]
        },
        "querySex": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "matches",
        "query"
      ]
    },
    "Symptom": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "Treatment": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "code": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        },
        "chineseName": {
          "type": [
            "string",
            "null"
          ]
        },
        "pinyin": {
          "type": [
            "string",
            "null"
          ]
        },
        "location": {
          "type": [
            "string",
            "null"
          ]
        },
        "warnings": {
          "type": [
            "string",
            "null"
          ]
        },
        "meridian": {
          "$ref": "#/$defs/Meridian"
        },
        "indications": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Symptom"
          }
        }
      },
      "required": [
        "id",
        "code",
        "type",
        "indications"
      ]
    }
  }
}