@prefix : <https://teamheka.github.io/meds-ontology#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <https://teamheka.github.io/meds-ontology#> .

<https://teamheka.github.io/meds-ontology> rdf:type owl:Ontology ;
                                            owl:versionIRI <https://teamheka.github.io/meds-ontology/1.0.2> ;
                                            <http://purl.org/dc/terms/abstract> """The MEDS Ontology is an OWL ontology that formally encodes the
Medical Event Data Standard (MEDS) conceptual data model.
It provides a semantic representation of medical event data
to support interoperability, validation, and machine-readable
analysis across datasets."""@en ;
                                            <http://purl.org/dc/terms/created> "2025-12-04"^^xsd:date ;
                                            <http://purl.org/dc/terms/creator> "Alberto Marfoglia" ;
                                            <http://purl.org/dc/terms/description> """This ontology provides a semantic framework for representing
key components of the Medical Event Data Standard (MEDS),
including subjects, clinical measurements, code metadata,
dataset-level provenance, subject splits, and prediction labels.

The ontology is accompanied by SHACL shapes that constrain
and validate data according to the MEDS conceptual model,
enabling consistent data representation and quality control
across implementations."""@en ;
                                            <http://purl.org/dc/terms/license> <https://creativecommons.org/licenses/by/4.0/> ;
                                            <http://purl.org/dc/terms/modified> "2025-12-19"^^xsd:date ;
                                            <http://purl.org/dc/terms/publisher> "HeKa Team"@en ;
                                            <http://purl.org/dc/terms/title> "MEDS Ontology"@en ;
                                            rdfs:label "MEDS Ontology"@en ;
                                            owl:versionInfo "1.0.2" .

#################################################################
#    Annotation properties
#################################################################

###  http://purl.org/dc/terms/abstract
<http://purl.org/dc/terms/abstract> rdf:type owl:AnnotationProperty .


###  http://purl.org/dc/terms/creator
<http://purl.org/dc/terms/creator> rdf:type owl:AnnotationProperty .


###  http://purl.org/dc/terms/description
<http://purl.org/dc/terms/description> rdf:type owl:AnnotationProperty .


###  http://purl.org/dc/terms/modified
<http://purl.org/dc/terms/modified> rdf:type owl:AnnotationProperty .


###  http://purl.org/dc/terms/publisher
<http://purl.org/dc/terms/publisher> rdf:type owl:AnnotationProperty .


###  http://www.w3.org/2002/07/owl#cardinality
owl:cardinality rdf:type owl:AnnotationProperty .


###  http://www.w3.org/2002/07/owl#maxCardinality
owl:maxCardinality rdf:type owl:AnnotationProperty .


#################################################################
#    Datatypes
#################################################################

###  http://www.w3.org/2001/XMLSchema#date
xsd:date rdf:type rdfs:Datatype .


#################################################################
#    Object Properties
#################################################################

###  http://purl.org/dc/terms/hasVersion
<http://purl.org/dc/terms/hasVersion> rdf:type owl:ObjectProperty .


###  http://www.w3.org/ns/dcat#distribution
<http://www.w3.org/ns/dcat#distribution> rdf:type owl:ObjectProperty .


###  http://www.w3.org/ns/prov#wasDerivedFrom
<http://www.w3.org/ns/prov#wasDerivedFrom> rdf:type owl:ObjectProperty .


###  http://www.w3.org/ns/prov#wasGeneratedBy
<http://www.w3.org/ns/prov#wasGeneratedBy> rdf:type owl:ObjectProperty .


###  https://teamheka.github.io/meds-ontology#assignedSplit
:assignedSplit rdf:type owl:ObjectProperty ;
               rdfs:domain :Subject ;
               rdfs:range :SubjectSplit ;
               rdfs:comment "Assign a subject to a split (train, tuning, held_out)." ;
               rdfs:label "assignedSplit" .


###  https://teamheka.github.io/meds-ontology#hasCode
:hasCode rdf:type owl:ObjectProperty ;
         rdfs:domain :Event ;
         rdfs:range :Code ;
         rdfs:comment "Link from a Event to a Code metadata entry. If no Code metadata file exists, codeString on Event is used." ;
         rdfs:label "hasCode" .


###  https://teamheka.github.io/meds-ontology#hasSubject
:hasSubject rdf:type owl:ObjectProperty ,
                     owl:FunctionalProperty ;
            rdfs:range :Subject ;
            rdfs:comment "Links a Event or LabelSample to its Subject (maps to subject_id)." ;
            rdfs:label "hasSubject" .


###  https://teamheka.github.io/meds-ontology#hasValueModality
:hasValueModality rdf:type owl:ObjectProperty ;
                  rdfs:domain :Event ;
                  rdfs:range :ValueModality ;
                  rdfs:comment "Attach additional value modalities (image, waveform, etc.) to a Event." ;
                  rdfs:label "hasValueModality" .


###  https://teamheka.github.io/meds-ontology#parentCode
:parentCode rdf:type owl:ObjectProperty ;
            rdfs:domain :Code ;
            rdfs:range :Code ;
            rdfs:comment "Ontological/aggregation parent relations between codes (maps to CodeMetadata.parent_codes)." ;
            rdfs:label "parentCode" .


#################################################################
#    Data properties
#################################################################

###  https://teamheka.github.io/meds-ontology#additionalValueModalityColumn
:additionalValueModalityColumn rdf:type owl:DatatypeProperty ;
                               rdfs:domain :DatasetMetadata ;
                               rdfs:range xsd:string ;
                               rdfs:comment "Column containing additional value modality (image, waveform, etc.). OPTIONAL. One triple per column. Matches MEDS: additional_value_modality_columns." ;
                               rdfs:label "additionalValueModalityColumn" .


###  https://teamheka.github.io/meds-ontology#booleanValue
:booleanValue rdf:type owl:DatatypeProperty ;
              rdfs:domain :LabelSample ;
              rdfs:range xsd:boolean ;
              rdfs:comment "Boolean label value (if applicable)." ;
              rdfs:label "booleanValue" .


###  https://teamheka.github.io/meds-ontology#categoricalValue
:categoricalValue rdf:type owl:DatatypeProperty ;
                  rdfs:domain :LabelSample ;
                  rdfs:range xsd:string ;
                  rdfs:comment "Categorical label encoded as a string." ;
                  rdfs:label "categoricalValue" .


###  https://teamheka.github.io/meds-ontology#codeDescription
:codeDescription rdf:type owl:DatatypeProperty ;
                 rdfs:domain :Code ;
                 rdfs:range xsd:string ;
                 rdfs:comment "Human readable description of the code." ;
                 rdfs:label "codeDescription" .


###  https://teamheka.github.io/meds-ontology#codeModifierColumn
:codeModifierColumn rdf:type owl:DatatypeProperty ;
                    rdfs:domain :DatasetMetadata ;
                    rdfs:range xsd:string ;
                    rdfs:comment "Column used to modify/augment code values. OPTIONAL. One triple per column. Matches MEDS: code_modifier_columns." ;
                    rdfs:label "codeModifierColumn" .


###  https://teamheka.github.io/meds-ontology#codeString
:codeString rdf:type owl:DatatypeProperty ;
            rdfs:domain :Code ;
            rdfs:range xsd:string ;
            rdfs:comment "Canonical textual code; functional for Code. Also present on Event when no Code metadata exists." ;
            rdfs:label "codeString" .


###  https://teamheka.github.io/meds-ontology#floatValue
:floatValue rdf:type owl:DatatypeProperty ;
            rdfs:domain :LabelSample ;
            rdfs:range xsd:double ;
            rdfs:comment "Float label value (continuous target)." ;
            rdfs:label "floatValue" .


###  https://teamheka.github.io/meds-ontology#integerValue
:integerValue rdf:type owl:DatatypeProperty ;
              rdfs:domain :LabelSample ;
              rdfs:range xsd:integer ;
              rdfs:comment "Integer label value (e.g., ordinal labels)." ;
              rdfs:label "integerValue" .


###  https://teamheka.github.io/meds-ontology#medsVersion
:medsVersion rdf:type owl:DatatypeProperty ;
             rdfs:domain :DatasetMetadata ;
             rdfs:range xsd:string ;
             rdfs:comment "Version of the MEDS schema used to generate the dataset. REQUIRED. Matches MEDS: meds_version." ;
             rdfs:label "medsVersion" .


###  https://teamheka.github.io/meds-ontology#numericValue
:numericValue rdf:type owl:DatatypeProperty ;
              rdfs:domain :Event ;
              rdfs:range xsd:double ;
              rdfs:comment "Numeric event value (optional in MEDS)." ;
              rdfs:label "numericValue" .


###  https://teamheka.github.io/meds-ontology#otherExtensionColumn
:otherExtensionColumn rdf:type owl:DatatypeProperty ;
                      rdfs:domain :DatasetMetadata ;
                      rdfs:range xsd:string ;
                      rdfs:comment "Other dataset-specific extension column not covered elsewhere. OPTIONAL. One triple per column. Matches MEDS: other_extension_columns." ;
                      rdfs:label "otherExtensionColumn" .


###  https://teamheka.github.io/meds-ontology#predictionTime
:predictionTime rdf:type owl:DatatypeProperty ;
                rdfs:domain :LabelSample ;
                rdfs:range xsd:dateTime ;
                rdfs:comment "Inclusive endpoint of the data usable for predicting the label (required for LabelSample)." ;
                rdfs:label "predictionTime" .


###  https://teamheka.github.io/meds-ontology#rawSourceIdColumn
:rawSourceIdColumn rdf:type owl:DatatypeProperty ;
                   rdfs:domain :DatasetMetadata ;
                   rdfs:range xsd:string ;
                   rdfs:comment "Raw source ID column before mapping to subject IDs. OPTIONAL. One triple per column. Matches MEDS: raw_source_id_columns." ;
                   rdfs:label "rawSourceIdColumn" .


###  https://teamheka.github.io/meds-ontology#siteIdColumn
:siteIdColumn rdf:type owl:DatatypeProperty ;
              rdfs:domain :DatasetMetadata ;
              rdfs:range xsd:string ;
              rdfs:comment "Column representing a site identifier. OPTIONAL. One triple per column. Previously siteIdColumns." ;
              rdfs:label "siteIdColumn" .


###  https://teamheka.github.io/meds-ontology#subjectId
:subjectId rdf:type owl:DatatypeProperty ,
                    owl:FunctionalProperty ;
           rdfs:domain :Subject ;
           rdfs:range xsd:string ;
           rdfs:comment "Unique identifier for a Subject; functional (= at most one value per Subject)." .


###  https://teamheka.github.io/meds-ontology#subjectIdColumn
:subjectIdColumn rdf:type owl:DatatypeProperty ;
                 rdfs:domain :DatasetMetadata ;
                 rdfs:range xsd:string ;
                 rdfs:comment "Column used as a subject identifier. REQUIRED. One triple per column. Previously subjectIdColumns." ;
                 rdfs:label "subjectIdColumn" .


###  https://teamheka.github.io/meds-ontology#textValue
:textValue rdf:type owl:DatatypeProperty ;
           rdfs:domain :Event ;
           rdfs:range xsd:string ;
           rdfs:comment "Text event value (optional in MEDS)." ;
           rdfs:label "textValue" .


###  https://teamheka.github.io/meds-ontology#time
:time rdf:type owl:DatatypeProperty ;
      rdfs:domain :Event ;
      rdfs:range xsd:dateTime ;
      rdfs:comment "Timestamp of the event. MEDS allows null for static events; modelled as 0..1 cardinality." ;
      rdfs:label "time" .


#################################################################
#    Classes
#################################################################

###  http://purl.org/dc/terms/LicenseDocument
<http://purl.org/dc/terms/LicenseDocument> rdf:type owl:Class .


###  http://www.w3.org/2000/01/rdf-schema#Resource
rdfs:Resource rdf:type owl:Class .


###  http://www.w3.org/ns/dcat#Dataset
<http://www.w3.org/ns/dcat#Dataset> rdf:type owl:Class .


###  http://www.w3.org/ns/dcat#Distribution
<http://www.w3.org/ns/dcat#Distribution> rdf:type owl:Class .


###  http://www.w3.org/ns/prov#Activity
<http://www.w3.org/ns/prov#Activity> rdf:type owl:Class .


###  http://www.w3.org/ns/prov#Entity
<http://www.w3.org/ns/prov#Entity> rdf:type owl:Class .


###  https://teamheka.github.io/meds-ontology#Code
:Code rdf:type owl:Class ;
      rdfs:subClassOf [ rdf:type owl:Restriction ;
                        owl:onProperty <http://www.w3.org/ns/prov#wasDerivedFrom> ;
                        owl:allValuesFrom :DatasetMetadata
                      ] ,
                      [ rdf:type owl:Restriction ;
                        owl:onProperty :codeString ;
                        owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                        owl:onDataRange xsd:string
                      ] ;
      rdfs:comment "Metadata/vocabulary entry describing a event code (code string, description, parent codes, external links)." ;
      rdfs:label "Code" .


###  https://teamheka.github.io/meds-ontology#DatasetMetadata
:DatasetMetadata rdf:type owl:Class ;
                 rdfs:subClassOf <http://www.w3.org/ns/dcat#Dataset> ,
                                 <http://www.w3.org/ns/prov#Entity> ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://purl.org/dc/terms/hasVersion> ;
                                   owl:allValuesFrom rdfs:Resource
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://purl.org/dc/terms/license> ;
                                   owl:allValuesFrom <http://purl.org/dc/terms/LicenseDocument>
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://www.w3.org/ns/dcat#distribution> ;
                                   owl:allValuesFrom <http://www.w3.org/ns/dcat#Distribution>
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://www.w3.org/ns/prov#wasGeneratedBy> ;
                                   owl:allValuesFrom <http://www.w3.org/ns/prov#Activity>
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://purl.org/dc/terms/created> ;
                                   owl:allValuesFrom xsd:string
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty <http://purl.org/dc/terms/title> ;
                                   owl:allValuesFrom xsd:string
                                 ] ,
                                 [ rdf:type owl:Restriction ;
                                   owl:onProperty :medsVersion ;
                                   owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                                   owl:onDataRange xsd:string
                                 ] ;
                 rdfs:comment "High-level provenance and conversion metadata for a MEDS dataset." ;
                 rdfs:label "DatasetMetadata" .


###  https://teamheka.github.io/meds-ontology#Event
:Event rdf:type owl:Class ;
       rdfs:subClassOf [ rdf:type owl:Restriction ;
                         owl:onProperty <http://www.w3.org/ns/prov#wasDerivedFrom> ;
                         owl:allValuesFrom :DatasetMetadata
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :hasSubject ;
                         owl:allValuesFrom :Subject
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :hasCode ;
                         owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                         owl:onClass :Code
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :codeString ;
                         owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                         owl:onDataRange xsd:string
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :numericValue ;
                         owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                         owl:onDataRange xsd:double
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :textValue ;
                         owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                         owl:onDataRange xsd:string
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :time ;
                         owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                         owl:onDataRange xsd:dateTime
                       ] ;
       owl:disjointWith :LabelSample ;
       rdfs:comment "A single observation/row in MEDS: (subject, time?, code, value modalities...). Time is nullable for static events." ;
       rdfs:label "Event" .


###  https://teamheka.github.io/meds-ontology#LabelSample
:LabelSample rdf:type owl:Class ;
             rdfs:subClassOf [ rdf:type owl:Restriction ;
                               owl:onProperty <http://www.w3.org/ns/prov#wasDerivedFrom> ;
                               owl:allValuesFrom :DatasetMetadata
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :hasSubject ;
                               owl:allValuesFrom :Subject
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :predictionTime ;
                               owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                               owl:onDataRange xsd:dateTime
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :booleanValue ;
                               owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                               owl:onDataRange xsd:boolean
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :categoricalValue ;
                               owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                               owl:onDataRange xsd:string
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :floatValue ;
                               owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                               owl:onDataRange xsd:double
                             ] ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :integerValue ;
                               owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                               owl:onDataRange xsd:integer
                             ] ;
             rdfs:comment "A prediction sample row: subject, prediction_time, and one label value (boolean/integer/float/categorical)." ;
             rdfs:label "LabelSample" .


###  https://teamheka.github.io/meds-ontology#Subject
:Subject rdf:type owl:Class ;
         rdfs:subClassOf [ rdf:type owl:Restriction ;
                           owl:onProperty <http://www.w3.org/ns/prov#wasDerivedFrom> ;
                           owl:allValuesFrom :DatasetMetadata
                         ] ;
         owl:hasKey ( :subjectId
                    ) ;
         rdfs:comment "Primary entity for which care observations are recorded. Maps to MEDS subject_id (patient or admission-level subject)." ;
         rdfs:label "Subject" .


###  https://teamheka.github.io/meds-ontology#SubjectSplit
:SubjectSplit rdf:type owl:Class ;
              rdfs:comment "An assignment of a subject to a named split (train, tuning, held_out)." ;
              rdfs:label "SubjectSplit" .


###  https://teamheka.github.io/meds-ontology#ValueModality
:ValueModality rdf:type owl:Class ;
               rdfs:comment "Generic holder for additional value modalities (image path, waveform id, etc.). Instances may contain modality-specific properties." ;
               rdfs:label "ValueModality" .


#################################################################
#    Individuals
#################################################################

###  https://teamheka.github.io/meds-ontology#heldOutSplit
:heldOutSplit rdf:type owl:NamedIndividual ,
                       :SubjectSplit ;
              rdfs:label "held_out"@en .


###  https://teamheka.github.io/meds-ontology#trainSplit
:trainSplit rdf:type owl:NamedIndividual ,
                     :SubjectSplit ;
            rdfs:label "train"@en .


###  https://teamheka.github.io/meds-ontology#tuningSplit
:tuningSplit rdf:type owl:NamedIndividual ,
                      :SubjectSplit ;
             rdfs:label "tuning"@en .


#################################################################
#    General axioms
#################################################################

[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :Code
                :Event
                :LabelSample
                :Subject
                :SubjectSplit
                :ValueModality
              )
] .


###  Generated by the OWL API (version 5.1.18) https://github.com/owlcs/owlapi/
