{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.humancellatlas.org/module/biomaterial/9.5.0/medical_history",
  "description": "Information about the medical history of a donor.",
  "additionalProperties": false,
  "title": "Medical history",
  "name": "medical_history",
  "type": "object",
  "properties": {
    "describedBy": {
      "description": "The URL reference to the schema.",
      "type": "string",
      "pattern": "^(http|https)://schema.(.*?)humancellatlas.org/module/biomaterial/(([0-9]{1,}.[0-9]{1,}.[0-9]{1,})|([a-zA-Z]*?))/medical_history"
    },
    "schema_version": {
      "description": "The version number of the schema in major.minor.patch format.",
      "type": "string",
      "pattern": "^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$",
      "example": "4.6.1"
    },
    "alcohol_status": {
      "description": "Whether the individual is actively consuming, has formerly consumed or has never consumed alcohol beverages",
      "type": "string",
      "enum": [
        "active",
        "former",
        "never"
      ],
      "user_friendly": "Alcohol status",
      "example": "Should be one of: active, former, never.",
      "bionetworks": [
        "gut",
        "oral and craniofacial",
        "musculoskeletal",
        "liver"
      ]
    },
    "alcohol_type": {
      "description": "Types of alcoholic beverages the donor consumed.",
      "type": "array",
      "items": {
        "type": "string"
      },
      "user_friendly": "Alcohol type",
      "example": "beer; liquor; wine",
      "bionetworks": [
        "gut",
        "oral and craniofacial",
        "musculoskeletal",
        "liver"
      ]
    },
    "alcohol_units": {
      "description": "Alcohol consumption of donor in alcohol units per week (strength (ABV) x volume (ml) \u00f7 1,000).",
      "type": "number",
      "user_friendly": "Alcohol units",
      "minimum": 0,
      "example": "2.5; 15.2; 23",
      "bionetworks": [
        "gut",
        "oral and craniofacial",
        "musculoskeletal",
        "liver",
        "heart"
      ]
    },
    "alcohol_usage_duration": {
      "description": "Number of years in which the donor consumed alcohol.",
      "type": "integer",
      "user_friendly": "Alcohol usage duration",
      "minimum": 0,
      "example": 5,
      "bionetworks": [
        "gut",
        "oral and craniofacial",
        "musculoskeletal",
        "liver"
      ]
    },
    "medication": {
      "description": "Medication(s) the individual was taking at time of biomaterial collection.",
      "type": "array",
      "items": {
        "$ref": "https://schema.humancellatlas.org/module/ontology/2.0.0/medication_ontology"
      },
      "user_friendly": "Medication"
    },
    "smoking_status": {
      "description": "Whether the individual is actively, was formerly or never consumed smoking tobacco products like cigarettes, cigars, pipe etc.",
      "type": "string",
      "enum": [
        "active",
        "former",
        "never"
      ],
      "user_friendly": "Smoking status",
      "example": "Should be one of: active, former, never."
    },
    "smoking_pack_years": {
      "description": "Estimated number of packs (20 cigarettes) smoked per day multiplied by the number of years the individual was smoking.",
      "type": "number",
      "user_friendly": "Smoking pack years",
      "minimum": 0,
      "example": 4.55
    },
    "years_since_smoking_cessation": {
      "description": "If smoking status is 'former', specify the number of years since smoking cessation.",
      "type": "integer",
      "user_friendly": "Years since smoking cessation",
      "minimum": 0,
      "example": 12
    },
    "household_smoking_exposure": {
      "description": "If the donor is exposed to passive smoking in their household or not (excluding if they are the ones smoking).",
      "type": "boolean",
      "user_friendly": "Household smoking exposure",
      "example": "Should be one of: yes; no.",
      "bionetworks": [
        "lung",
        "oral and craniofacial"
      ]
    },
    "vaping_status": {
      "description": "Whether the individual is actively, was formerly or never vaped.",
      "type": "string",
      "enum": [
        "active",
        "former",
        "never"
      ],
      "user_friendly": "Vaping status",
      "example": "Should be one of: active, former, never.",
      "bionetworks": [
        "lung",
        "oral and craniofacial"
      ]
    },
    "marijuana_inhaled_status": {
      "description": "Whether the individual is actively, was formerly or never inhaled/smoked marijuana.",
      "type": "string",
      "enum": [
        "active",
        "former",
        "never"
      ],
      "user_friendly": "Inhaled marijuana status",
      "example": "Should be one of: active, former, never.",
      "bionetworks": [
        "lung",
        "oral and craniofacial"
      ]
    },
    "nutritional_state": {
      "description": "Nutritional state of individual at time of biomaterial collection.",
      "type": "string",
      "enum": [
        "normal",
        "fasting",
        "feeding tube removed"
      ],
      "user_friendly": "Nutritional state",
      "example": "Should be one of: normal, fasting, or feeding tube removed."
    },
    "fasting_time": {
      "description": "Duration of the donor's fasting period (in hours) prior to sample collection.",
      "type": "integer",
      "minimum": 0,
      "user_friendly": "Fasting time",
      "example": "2; 5; 8",
      "bionetworks": [
        "adipose"
      ]
    },
    "diet_meat_consumption": {
      "description": "Dietary patterns of donor - meat (chicken, seafood, fish, pork, lamb, beef, etc.) consumption versus meat-free diet - at time of sample collection. Fill yes if donor consumes meat or no if donor does not consumes meat.",
      "type": "boolean",
      "user_friendly": "Meat consumption",
      "example": "Should be one of: yes; no.",
      "bionetworks": [
        "genetic diversity"
      ]
    },
    "reproductive_history": {
      "description": "Reproductive history of the donor at the time of collection.",
      "type": "object",
      "user_friendly": "Reproductive history",
      "$ref": "https://schema.humancellatlas.org/module/biomaterial/1.4.0/reproductive_history"
    },
    "blood_test": {
      "description": "Results from blood tests performed on the individual.",
      "type": "object",
      "user_friendly": "Blood tests",
      "$ref": "https://schema.humancellatlas.org/module/biomaterial/2.0.0/blood_test"
    },
    "test_results": {
      "description": "Results from medical tests performed on the individual.",
      "type": "string",
      "user_friendly": "Test results",
      "example": "lipid panel shows normal level of LDL (124 mg/dL); HIV, HBV, HCV: Negative"
    },
    "treatment": {
      "description": "Treatments the individual has undergone prior to biomaterial collection.",
      "type": "string",
      "user_friendly": "Treatments",
      "example": "Patient treated with antibiotics for a urinary tract infection; Patient treated with chemotherapy (Epirubicin, cisplatin, capecitabine) to treat stomach cancer"
    },
    "previous_surgeries": {
      "description": "Previous surgeries the individual has undergone prior to biomaterial collection.",
      "type": "string",
      "user_friendly": "Previous surgeries",
      "example": "Appendectomy; Coleostomy; Vaginoplasty; LASIK; Abdominal surgery",
      "bionetworks": [
        "gut",
        "adipose",
        "eye",
        "musculoskeletal",
        "reproduction"
      ]
    },
    "defined_diet": {
      "description": "Whether the individual was following a defined diet at the time of biomaterial collection.",
      "type": "boolean",
      "user_friendly": "Defined diet",
      "guidelines": "Should be one of: yes, or no.",
      "example": "yes; no",
      "bionetworks": [
        "gut"
      ]
    },
    "diet_specific": {
      "description": "Defined diet the donor was on at the time of biomaterial collection.",
      "type": "array",
      "user_friendly": "Diet Specific",
      "example": "gluten_free; fodmap; baby_formula; breastfeeding; elimination; keto; paleo",
      "items": {
        "type": "string",
        "enum": [
          "vegan",
          "vegetarian",
          "omnivore",
          "gluten_free",
          "fodmap",
          "baby_formula",
          "breastfeeding",
          "elimination",
          "keto",
          "paleo"
        ]
      },
      "bionetworks": [
        "gut"
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "smoking_status": {
            "const": "active"
          }
        }
      },
      "then": {
        "properties": {
          "years_since_smoking_cessation": {
            "maximum": 0
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "smoking_status": {
            "const": "never"
          }
        }
      },
      "then": {
        "properties": {
          "years_since_smoking_cessation": {
            "type": "null"
          },
          "smoking_pack_years": {
            "maximum": 0
          }
        }
      }
    }
  ]
}
