@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dicom: <http://dicom.nema.org/> .
@prefix dicom-ontology: <http://ggen.io/ontology/dicom#> .

# DICOM Medical Imaging Ontology
# Implements DICOM standard for medical imaging metadata
# Supports PACS integration, WADO-RS, QIDO-RS, STOW-RS

dicom-ontology:DICOMOntology a owl:Ontology ;
    rdfs:label "DICOM Medical Imaging Ontology" ;
    rdfs:comment "DICOM standard ontology for medical imaging" ;
    owl:versionInfo "1.0.0" ;
    dicom-ontology:conformsTo "DICOM PS3.1-PS3.20" .

# ============================================================================
# DICOM Information Model Hierarchy
# ============================================================================

dicom-ontology:Patient a owl:Class ;
    rdfs:label "DICOM Patient" ;
    rdfs:comment "Top level of DICOM information model" .

dicom-ontology:Study a owl:Class ;
    rdfs:label "DICOM Study" ;
    rdfs:comment "Medical study (exam)" .

dicom-ontology:Series a owl:Class ;
    rdfs:label "DICOM Series" ;
    rdfs:comment "Series within a study (modality)" .

dicom-ontology:Instance a owl:Class ;
    rdfs:label "DICOM Instance" ;
    rdfs:comment "Individual image/frame" .

dicom-ontology:hasStudy a owl:ObjectProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range dicom-ontology:Study ;
    rdfs:label "Has Study" .

dicom-ontology:hasSeries a owl:ObjectProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range dicom-ontology:Series ;
    rdfs:label "Has Series" .

dicom-ontology:hasInstance a owl:ObjectProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range dicom-ontology:Instance ;
    rdfs:label "Has Instance" .

# ============================================================================
# Patient Level Attributes (0010,xxxx)
# ============================================================================

dicom-ontology:patientName a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Patient Name" ;
    dicom-ontology:tag "(0010,0010)" .

dicom-ontology:patientID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Patient ID" ;
    dicom-ontology:tag "(0010,0020)" .

dicom-ontology:patientBirthDate a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:date ;
    rdfs:label "Patient Birth Date" ;
    dicom-ontology:tag "(0010,0030)" .

dicom-ontology:patientSex a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Patient Sex" ;
    dicom-ontology:tag "(0010,0040)" ;
    rdfs:comment "M, F, O" .

dicom-ontology:patientAge a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Patient Age" ;
    dicom-ontology:tag "(0010,1010)" .

dicom-ontology:patientWeight a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:decimal ;
    rdfs:label "Patient Weight" ;
    dicom-ontology:tag "(0010,1030)" ;
    rdfs:comment "In kilograms" .

dicom-ontology:patientSize a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Patient ;
    rdfs:range xsd:decimal ;
    rdfs:label "Patient Size" ;
    dicom-ontology:tag "(0010,1020)" ;
    rdfs:comment "In meters" .

# ============================================================================
# Study Level Attributes (0020,xxxx and 0008,xxxx)
# ============================================================================

dicom-ontology:studyInstanceUID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:string ;
    rdfs:label "Study Instance UID" ;
    dicom-ontology:tag "(0020,000D)" .

dicom-ontology:studyDate a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:date ;
    rdfs:label "Study Date" ;
    dicom-ontology:tag "(0008,0020)" .

dicom-ontology:studyTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:time ;
    rdfs:label "Study Time" ;
    dicom-ontology:tag "(0008,0030)" .

dicom-ontology:accessionNumber a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:string ;
    rdfs:label "Accession Number" ;
    dicom-ontology:tag "(0008,0050)" .

dicom-ontology:studyID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:string ;
    rdfs:label "Study ID" ;
    dicom-ontology:tag "(0020,0010)" .

dicom-ontology:studyDescription a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:string ;
    rdfs:label "Study Description" ;
    dicom-ontology:tag "(0008,1030)" .

dicom-ontology:referringPhysicianName a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:string ;
    rdfs:label "Referring Physician Name" ;
    dicom-ontology:tag "(0008,0090)" .

dicom-ontology:numberOfStudyRelatedSeries a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:integer ;
    rdfs:label "Number of Study Related Series" ;
    dicom-ontology:tag "(0020,1206)" .

dicom-ontology:numberOfStudyRelatedInstances a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Study ;
    rdfs:range xsd:integer ;
    rdfs:label "Number of Study Related Instances" ;
    dicom-ontology:tag "(0020,1208)" .

# ============================================================================
# Series Level Attributes
# ============================================================================

dicom-ontology:seriesInstanceUID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Series Instance UID" ;
    dicom-ontology:tag "(0020,000E)" .

dicom-ontology:modality a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Modality" ;
    dicom-ontology:tag "(0008,0060)" ;
    rdfs:comment "CT, MR, US, XA, CR, DX, MG, PT, NM, etc" .

dicom-ontology:seriesNumber a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:integer ;
    rdfs:label "Series Number" ;
    dicom-ontology:tag "(0020,0011)" .

dicom-ontology:seriesDescription a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Series Description" ;
    dicom-ontology:tag "(0008,103E)" .

dicom-ontology:seriesDate a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:date ;
    rdfs:label "Series Date" ;
    dicom-ontology:tag "(0008,0021)" .

dicom-ontology:seriesTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:time ;
    rdfs:label "Series Time" ;
    dicom-ontology:tag "(0008,0031)" .

dicom-ontology:performingPhysicianName a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Performing Physician Name" ;
    dicom-ontology:tag "(0008,1050)" .

dicom-ontology:bodyPartExamined a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Body Part Examined" ;
    dicom-ontology:tag "(0018,0015)" .

dicom-ontology:protocolName a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:string ;
    rdfs:label "Protocol Name" ;
    dicom-ontology:tag "(0018,1030)" .

dicom-ontology:numberOfSeriesRelatedInstances a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Series ;
    rdfs:range xsd:integer ;
    rdfs:label "Number of Series Related Instances" ;
    dicom-ontology:tag "(0020,1209)" .

# ============================================================================
# Instance Level Attributes
# ============================================================================

dicom-ontology:sopInstanceUID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:string ;
    rdfs:label "SOP Instance UID" ;
    dicom-ontology:tag "(0008,0018)" .

dicom-ontology:sopClassUID a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:string ;
    rdfs:label "SOP Class UID" ;
    dicom-ontology:tag "(0008,0016)" ;
    rdfs:comment "Defines image type/storage class" .

dicom-ontology:instanceNumber a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Instance Number" ;
    dicom-ontology:tag "(0020,0013)" .

dicom-ontology:contentDate a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:date ;
    rdfs:label "Content Date" ;
    dicom-ontology:tag "(0008,0023)" .

dicom-ontology:contentTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:time ;
    rdfs:label "Content Time" ;
    dicom-ontology:tag "(0008,0033)" .

dicom-ontology:imageType a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:string ;
    rdfs:label "Image Type" ;
    dicom-ontology:tag "(0008,0008)" .

dicom-ontology:acquisitionDate a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:date ;
    rdfs:label "Acquisition Date" ;
    dicom-ontology:tag "(0008,0022)" .

dicom-ontology:acquisitionTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:time ;
    rdfs:label "Acquisition Time" ;
    dicom-ontology:tag "(0008,0032)" .

# ============================================================================
# Image Pixel Data Attributes
# ============================================================================

dicom-ontology:rows a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Rows" ;
    dicom-ontology:tag "(0028,0010)" .

dicom-ontology:columns a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Columns" ;
    dicom-ontology:tag "(0028,0011)" .

dicom-ontology:bitsAllocated a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Bits Allocated" ;
    dicom-ontology:tag "(0028,0100)" .

dicom-ontology:bitsStored a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Bits Stored" ;
    dicom-ontology:tag "(0028,0101)" .

dicom-ontology:samplesPerPixel a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:integer ;
    rdfs:label "Samples Per Pixel" ;
    dicom-ontology:tag "(0028,0002)" .

dicom-ontology:photometricInterpretation a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:string ;
    rdfs:label "Photometric Interpretation" ;
    dicom-ontology:tag "(0028,0004)" ;
    rdfs:comment "MONOCHROME1, MONOCHROME2, RGB, etc" .

dicom-ontology:pixelSpacing a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:string ;
    rdfs:label "Pixel Spacing" ;
    dicom-ontology:tag "(0028,0030)" ;
    rdfs:comment "Row spacing, column spacing in mm" .

dicom-ontology:sliceThickness a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:Instance ;
    rdfs:range xsd:decimal ;
    rdfs:label "Slice Thickness" ;
    dicom-ontology:tag "(0018,0050)" .

# ============================================================================
# Modality-Specific Attributes
# ============================================================================

dicom-ontology:CTModality a owl:Class ;
    rdfs:subClassOf dicom-ontology:Series ;
    rdfs:label "CT Modality" ;
    rdfs:comment "Computed Tomography specific attributes" .

dicom-ontology:kvp a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:CTModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "KVP" ;
    dicom-ontology:tag "(0018,0060)" ;
    rdfs:comment "Peak kilovoltage" .

dicom-ontology:exposureTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:CTModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "Exposure Time" ;
    dicom-ontology:tag "(0018,1150)" .

dicom-ontology:MRModality a owl:Class ;
    rdfs:subClassOf dicom-ontology:Series ;
    rdfs:label "MR Modality" ;
    rdfs:comment "Magnetic Resonance specific attributes" .

dicom-ontology:magneticFieldStrength a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:MRModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "Magnetic Field Strength" ;
    dicom-ontology:tag "(0018,0087)" ;
    rdfs:comment "In Tesla" .

dicom-ontology:scanningSequence a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:MRModality ;
    rdfs:range xsd:string ;
    rdfs:label "Scanning Sequence" ;
    dicom-ontology:tag "(0018,0020)" .

dicom-ontology:echoTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:MRModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "Echo Time" ;
    dicom-ontology:tag "(0018,0081)" .

dicom-ontology:repetitionTime a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:MRModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "Repetition Time" ;
    dicom-ontology:tag "(0018,0080)" .

dicom-ontology:USModality a owl:Class ;
    rdfs:subClassOf dicom-ontology:Series ;
    rdfs:label "Ultrasound Modality" .

dicom-ontology:transducerFrequency a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:USModality ;
    rdfs:range xsd:decimal ;
    rdfs:label "Transducer Frequency" ;
    dicom-ontology:tag "(0018,6030)" .

# ============================================================================
# DICOM Web Services (DICOMweb)
# ============================================================================

dicom-ontology:WADOEndpoint a owl:Class ;
    rdfs:label "WADO-RS Endpoint" ;
    rdfs:comment "Web Access to DICOM Objects" .

dicom-ontology:QIDOEndpoint a owl:Class ;
    rdfs:label "QIDO-RS Endpoint" ;
    rdfs:comment "Query based on ID for DICOM Objects" .

dicom-ontology:STOWEndpoint a owl:Class ;
    rdfs:label "STOW-RS Endpoint" ;
    rdfs:comment "Store Over the Web" .

dicom-ontology:baseUrl a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:WADOEndpoint ;
    rdfs:range xsd:anyURI ;
    rdfs:label "Base URL" .

# ============================================================================
# SOP Classes (Storage)
# ============================================================================

dicom-ontology:CTImageStorage a owl:Class ;
    rdfs:label "CT Image Storage" ;
    dicom-ontology:sopClassUID "1.2.840.10008.5.1.4.1.1.2" .

dicom-ontology:MRImageStorage a owl:Class ;
    rdfs:label "MR Image Storage" ;
    dicom-ontology:sopClassUID "1.2.840.10008.5.1.4.1.1.4" .

dicom-ontology:UltrasoundImageStorage a owl:Class ;
    rdfs:label "Ultrasound Image Storage" ;
    dicom-ontology:sopClassUID "1.2.840.10008.5.1.4.1.1.6.1" .

dicom-ontology:XRayImageStorage a owl:Class ;
    rdfs:label "X-Ray Image Storage" ;
    dicom-ontology:sopClassUID "1.2.840.10008.5.1.4.1.1.1" .

dicom-ontology:NuclearMedicineImageStorage a owl:Class ;
    rdfs:label "Nuclear Medicine Image Storage" ;
    dicom-ontology:sopClassUID "1.2.840.10008.5.1.4.1.1.20" .

# ============================================================================
# PACS Integration
# ============================================================================

dicom-ontology:PACSServer a owl:Class ;
    rdfs:label "PACS Server" ;
    rdfs:comment "Picture Archiving and Communication System" .

dicom-ontology:aeTitle a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:PACSServer ;
    rdfs:range xsd:string ;
    rdfs:label "AE Title" ;
    rdfs:comment "Application Entity Title" .

dicom-ontology:hostname a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:PACSServer ;
    rdfs:range xsd:string ;
    rdfs:label "Hostname" .

dicom-ontology:port a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:PACSServer ;
    rdfs:range xsd:integer ;
    rdfs:label "Port" ;
    rdfs:comment "DICOM port (usually 104 or 11112)" .

# ============================================================================
# Structured Reporting
# ============================================================================

dicom-ontology:StructuredReport a owl:Class ;
    rdfs:label "DICOM Structured Report" ;
    rdfs:comment "SR document with coded findings" .

dicom-ontology:completionFlag a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:StructuredReport ;
    rdfs:range xsd:string ;
    rdfs:label "Completion Flag" ;
    dicom-ontology:tag "(0040,A491)" ;
    rdfs:comment "PARTIAL, COMPLETE" .

dicom-ontology:verificationFlag a owl:DatatypeProperty ;
    rdfs:domain dicom-ontology:StructuredReport ;
    rdfs:range xsd:string ;
    rdfs:label "Verification Flag" ;
    dicom-ontology:tag "(0040,A493)" ;
    rdfs:comment "UNVERIFIED, VERIFIED" .
