{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openssom.org/schema/profile-deidentified-observation.json",
  "title": "SSOM De-identified Contribution Profile: Observation",
  "description": "An Observation with the identity of its owner removed. Every reference is an irreversible token. Every other string is a governed code, a version, or a time. Unknown properties are rejected.",
  "allOf": [
    {
      "$ref": "observation.json"
    }
  ],
  "type": "object",
  "required": [
    "record_id",
    "semantic_truth_state",
    "ssom_version",
    "subject_ref",
    "signal_ref",
    "metric",
    "value",
    "event_time",
    "quality",
    "provenance",
    "temporal_integrity",
    "contribution"
  ],
  "properties": {
    "record_id": {
      "type": "string",
      "pattern": "^urn:ssom:record:tok:[0-9a-f]{32,64}$"
    },
    "semantic_truth_state": {
      "const": "observation"
    },
    "ssom_version": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
    },
    "subject_ref": {
      "type": "string",
      "pattern": "^urn:ssom:asset:tok:[0-9a-f]{32,64}$"
    },
    "signal_ref": {
      "type": "string",
      "pattern": "^urn:ssom:signal:tok:[0-9a-f]{32,64}$"
    },
    "metric": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$"
    },
    "value": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        }
      ]
    },
    "event_time": {
      "type": "string",
      "format": "date-time"
    },
    "observation_interval": {
      "$ref": "common.json#/$defs/observationInterval"
    },
    "quality": {
      "type": "object",
      "required": [
        "status",
        "validation_status"
      ],
      "properties": {
        "status": {},
        "validation_status": {},
        "score": {
          "type": "number"
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          }
        }
      },
      "additionalProperties": false
    },
    "original_measurement": {
      "type": "object",
      "properties": {
        "source_value": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          ]
        },
        "source_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "source_unit_state": {},
        "source_timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "source_representation": {}
      },
      "additionalProperties": false
    },
    "canonical_measurement": {
      "type": "object",
      "properties": {
        "quantity_kind": {},
        "canonical_value": {
          "type": "number"
        },
        "canonical_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "conversion_lineage": {
      "type": "object",
      "properties": {
        "source_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "canonical_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "conversion_method": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "conversion_service": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
        },
        "conversion_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
        },
        "conversion_timestamp": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "measurement_quality": {
      "type": "object",
      "properties": {
        "quality_code": {},
        "communication_quality": {},
        "validity_status": {},
        "missing_data_state": {},
        "stale_data_state": {}
      },
      "additionalProperties": false
    },
    "comparability": {
      "type": "object",
      "properties": {
        "comparable": {},
        "comparable_view_eligible": {},
        "reason": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        }
      },
      "additionalProperties": false
    },
    "time_synchronization_context": {
      "type": "object",
      "properties": {
        "source_timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "ingestion_timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "ordering_state": {}
      },
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "properties": {
        "source_platform": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "source_authority_id": {
          "type": "string",
          "pattern": "^urn:ssom:source:tok:[0-9a-f]{32,64}$"
        },
        "source_reference": {
          "type": "string",
          "pattern": "^urn:ssom:point:tok:[0-9a-f]{32,64}$"
        },
        "lineage_id": {
          "type": "string",
          "pattern": "^urn:ssom:frame:tok:[0-9a-f]{32,64}$"
        },
        "ingest_time": {
          "type": "string",
          "format": "date-time"
        },
        "processing_time": {
          "type": "string",
          "format": "date-time"
        },
        "mapping_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
        },
        "adapter_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
        }
      },
      "additionalProperties": false
    },
    "temporal_integrity": {
      "type": "object",
      "properties": {
        "event_time": {
          "type": "string",
          "format": "date-time"
        },
        "source_time": {
          "type": "string",
          "format": "date-time"
        },
        "receive_time": {
          "type": "string",
          "format": "date-time"
        },
        "processing_time": {
          "type": "string",
          "format": "date-time"
        },
        "time_confidence": {
          "type": "number"
        },
        "delivery_classification": {}
      },
      "additionalProperties": false
    },
    "state_lineage": {
      "type": "object",
      "properties": {
        "valid_from": {
          "type": "string",
          "format": "date-time"
        },
        "valid_to": {
          "type": "string",
          "format": "date-time"
        },
        "correction_of_ref": {
          "type": "string",
          "pattern": "^urn:ssom:record:tok:[0-9a-f]{32,64}$"
        },
        "supersedes_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^urn:ssom:record:tok:[0-9a-f]{32,64}$"
          }
        },
        "superseded_by_ref": {
          "type": "string",
          "pattern": "^urn:ssom:record:tok:[0-9a-f]{32,64}$"
        }
      },
      "additionalProperties": false
    },
    "contribution": {
      "type": "object",
      "required": [
        "cohort_ref",
        "policy_decision_ref",
        "tokenization_version"
      ],
      "properties": {
        "cohort_ref": {
          "type": "string",
          "pattern": "^urn:ssom:cohort:tok:[0-9a-f]{32,64}$"
        },
        "policy_decision_ref": {
          "type": "string",
          "pattern": "^urn:ssom:decision:tok:[0-9a-f]{32,64}$"
        },
        "tokenization_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._@:+-]*$"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
