{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://journalofbiohacking.com/data/evidence/v1/compounds.schema.json",
  "title": "Journal of Biohacking evidence dataset: compounds",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "dataset",
    "version",
    "releasedOn",
    "licence",
    "count",
    "items"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "dataset": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "releasedOn": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$"
    },
    "publisher": {
      "type": "string"
    },
    "author": {
      "type": "string"
    },
    "licence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "url"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "pattern": "^https://"
        }
      }
    },
    "notice": {
      "type": "string"
    },
    "documentation": {
      "type": "string",
      "pattern": "^https://"
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "shortName",
          "aliases",
          "kinds",
          "page",
          "pages",
          "evidence",
          "claimsDivergence",
          "bodySystems",
          "regulatoryStatus",
          "pmids",
          "sourcesCount",
          "publishedOn",
          "records"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string"
          },
          "shortName": {
            "type": "string"
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "page": {
            "type": "string",
            "pattern": "^https://"
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^https://"
            },
            "minItems": 1
          },
          "evidence": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "step",
              "stepRank",
              "stepName",
              "stepsDisagree",
              "labels"
            ],
            "properties": {
              "step": {
                "enum": [
                  "consistent-human-trials",
                  "human-trials-with-limits",
                  "early-human-studies",
                  "not-established-in-people",
                  "too-little-read"
                ]
              },
              "stepRank": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "stepName": {
                "enum": [
                  "Consistent human trials",
                  "Human trials with limits",
                  "Early human studies",
                  "Not established in people",
                  "Too little read to judge"
                ]
              },
              "stepsDisagree": {
                "type": "boolean"
              },
              "labels": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "system",
                    "value",
                    "label",
                    "shortLabel",
                    "record"
                  ],
                  "properties": {
                    "system": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "shortLabel": {
                      "type": "string"
                    },
                    "record": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "claimsDivergence": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "record",
                "value",
                "label"
              ],
              "properties": {
                "record": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "bodySystems": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "atlas",
              "journal"
            ],
            "properties": {
              "atlas": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "journal": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "regulatoryStatus": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "record",
                "text"
              ],
              "properties": {
                "record": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "pmids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          },
          "sourcesCount": {
            "type": "integer",
            "minimum": 0
          },
          "publishedOn": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$"
          },
          "records": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "source",
                "id",
                "name",
                "page",
                "scope",
                "evidence",
                "step",
                "claimsDivergence",
                "regulatoryStatus",
                "bodySystems",
                "publishedOn",
                "sources",
                "receipts"
              ],
              "properties": {
                "source": {
                  "enum": [
                    "library",
                    "pharmacology"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "page": {
                  "type": "string",
                  "pattern": "^https://"
                },
                "scope": {
                  "enum": [
                    "whole",
                    "shared"
                  ]
                },
                "evidence": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "system",
                    "value",
                    "label"
                  ],
                  "properties": {
                    "system": {
                      "enum": [
                        "compound-library",
                        "human-evidence-tier",
                        "dossier-grade",
                        "frontier-grade"
                      ]
                    },
                    "value": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    }
                  }
                },
                "step": {
                  "enum": [
                    "consistent-human-trials",
                    "human-trials-with-limits",
                    "early-human-studies",
                    "not-established-in-people",
                    "too-little-read"
                  ]
                },
                "claimsDivergence": {
                  "oneOf": [
                    {
                      "type": "null"
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "value",
                        "label"
                      ],
                      "properties": {
                        "value": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                },
                "regulatoryStatus": {
                  "type": "string"
                },
                "bodySystems": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "publishedOn": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$"
                },
                "sources": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "pmid",
                      "doi",
                      "url",
                      "citation",
                      "title",
                      "year"
                    ],
                    "properties": {
                      "pmid": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "pattern": "^\\d+$"
                      },
                      "doi": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "url": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "citation": {
                        "type": "string"
                      },
                      "title": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "year": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    }
                  }
                },
                "receipts": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "claims",
                    "checked",
                    "checkedOn",
                    "status",
                    "explained"
                  ],
                  "properties": {
                    "claims": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "checked": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "checkedOn": {
                      "oneOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "string",
                          "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "explained": {
                      "type": "string",
                      "pattern": "^https://"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
