@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 fhir: <http://hl7.org/fhir/> .
@prefix fhir-ontology: <http://ggen.io/ontology/fhir#> .

# FHIR Patient Management Ontology
# Implements FHIR R4 Patient, Observation, Medication, Condition, Encounter resources
# Supports healthcare interoperability and HIPAA compliance

fhir-ontology:FHIRPatientManagement a owl:Ontology ;
    rdfs:label "FHIR Patient Management Ontology" ;
    rdfs:comment "Comprehensive FHIR R4 ontology for patient management" ;
    owl:versionInfo "1.0.0" ;
    fhir-ontology:conformsTo "FHIR R4 (4.0.1)" .

# ============================================================================
# FHIR Resource Base Classes
# ============================================================================

fhir-ontology:Resource a owl:Class ;
    rdfs:label "FHIR Resource" ;
    rdfs:comment "Base class for all FHIR resources" .

fhir-ontology:DomainResource a owl:Class ;
    rdfs:subClassOf fhir-ontology:Resource ;
    rdfs:label "Domain Resource" ;
    rdfs:comment "Resources with narrative and contained resources" .

# ============================================================================
# Patient Resource
# ============================================================================

fhir-ontology:Patient a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Patient" ;
    rdfs:comment "Demographics and administrative information about a person receiving care" .

fhir-ontology:identifier a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Identifier" ;
    rdfs:comment "Patient identifier (MRN, SSN, etc)" .

fhir-ontology:active a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range xsd:boolean ;
    rdfs:label "Active" ;
    rdfs:comment "Whether patient record is active" .

fhir-ontology:name a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:HumanName ;
    rdfs:label "Name" .

fhir-ontology:telecom a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:ContactPoint ;
    rdfs:label "Telecom" .

fhir-ontology:gender a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range xsd:string ;
    rdfs:label "Gender" ;
    rdfs:comment "male | female | other | unknown" .

fhir-ontology:birthDate a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range xsd:date ;
    rdfs:label "Birth Date" .

fhir-ontology:deceased a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:label "Deceased" ;
    rdfs:comment "Deceased indicator or date/time" .

fhir-ontology:address a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:Address ;
    rdfs:label "Address" .

fhir-ontology:maritalStatus a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Marital Status" .

fhir-ontology:contact a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:PatientContact ;
    rdfs:label "Contact" .

fhir-ontology:communication a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:PatientCommunication ;
    rdfs:label "Communication" .

fhir-ontology:generalPractitioner a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:Practitioner ;
    rdfs:label "General Practitioner" .

fhir-ontology:managingOrganization a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Patient ;
    rdfs:range fhir-ontology:Organization ;
    rdfs:label "Managing Organization" .

# ============================================================================
# Data Types
# ============================================================================

fhir-ontology:HumanName a owl:Class ;
    rdfs:label "Human Name" .

fhir-ontology:family a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:HumanName ;
    rdfs:range xsd:string ;
    rdfs:label "Family Name" .

fhir-ontology:given a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:HumanName ;
    rdfs:range xsd:string ;
    rdfs:label "Given Name" .

fhir-ontology:prefix a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:HumanName ;
    rdfs:range xsd:string ;
    rdfs:label "Prefix" .

fhir-ontology:suffix a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:HumanName ;
    rdfs:range xsd:string ;
    rdfs:label "Suffix" .

fhir-ontology:Address a owl:Class ;
    rdfs:label "Address" .

fhir-ontology:line a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Address ;
    rdfs:range xsd:string ;
    rdfs:label "Address Line" .

fhir-ontology:city a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Address ;
    rdfs:range xsd:string ;
    rdfs:label "City" .

fhir-ontology:state a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Address ;
    rdfs:range xsd:string ;
    rdfs:label "State" .

fhir-ontology:postalCode a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Address ;
    rdfs:range xsd:string ;
    rdfs:label "Postal Code" .

fhir-ontology:country a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Address ;
    rdfs:range xsd:string ;
    rdfs:label "Country" .

fhir-ontology:ContactPoint a owl:Class ;
    rdfs:label "Contact Point" .

fhir-ontology:system a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:ContactPoint ;
    rdfs:range xsd:string ;
    rdfs:label "System" ;
    rdfs:comment "phone | fax | email | pager | url | sms | other" .

fhir-ontology:value a owl:DatatypeProperty ;
    rdfs:label "Value" ;
    rdfs:range xsd:string .

fhir-ontology:use a owl:DatatypeProperty ;
    rdfs:label "Use" ;
    rdfs:comment "home | work | temp | old | mobile" .

fhir-ontology:CodeableConcept a owl:Class ;
    rdfs:label "Codeable Concept" .

fhir-ontology:coding a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:CodeableConcept ;
    rdfs:range fhir-ontology:Coding ;
    rdfs:label "Coding" .

fhir-ontology:text a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:CodeableConcept ;
    rdfs:range xsd:string ;
    rdfs:label "Text" .

fhir-ontology:Coding a owl:Class ;
    rdfs:label "Coding" .

fhir-ontology:systemUri a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Coding ;
    rdfs:range xsd:anyURI ;
    rdfs:label "System URI" .

fhir-ontology:code a owl:DatatypeProperty ;
    rdfs:label "Code" ;
    rdfs:range xsd:string .

fhir-ontology:display a owl:DatatypeProperty ;
    rdfs:label "Display" ;
    rdfs:range xsd:string .

# ============================================================================
# Observation Resource (Vital Signs, Lab Results)
# ============================================================================

fhir-ontology:Observation a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Observation" ;
    rdfs:comment "Measurements and simple assertions about a patient" .

fhir-ontology:status a owl:DatatypeProperty ;
    rdfs:label "Status" ;
    rdfs:range xsd:string ;
    rdfs:comment "registered | preliminary | final | amended | corrected | cancelled | entered-in-error | unknown" .

fhir-ontology:category a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Category" ;
    rdfs:comment "vital-signs | laboratory | exam | imaging | procedure | survey | social-history" .

fhir-ontology:observationCode a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Observation Code" ;
    rdfs:comment "Type of observation (LOINC code)" .

fhir-ontology:subject a owl:ObjectProperty ;
    rdfs:label "Subject" ;
    rdfs:range fhir-ontology:Patient ;
    rdfs:comment "Patient or group the observation is about" .

fhir-ontology:effectiveDateTime a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range xsd:dateTime ;
    rdfs:label "Effective Date Time" .

fhir-ontology:valueQuantity a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:Quantity ;
    rdfs:label "Value Quantity" .

fhir-ontology:valueCodeableConcept a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Value Codeable Concept" .

fhir-ontology:interpretation a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Interpretation" ;
    rdfs:comment "High, low, normal, etc" .

fhir-ontology:referenceRange a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Observation ;
    rdfs:range fhir-ontology:ReferenceRange ;
    rdfs:label "Reference Range" .

fhir-ontology:Quantity a owl:Class ;
    rdfs:label "Quantity" .

fhir-ontology:quantityValue a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Quantity ;
    rdfs:range xsd:decimal ;
    rdfs:label "Quantity Value" .

fhir-ontology:unit a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Quantity ;
    rdfs:range xsd:string ;
    rdfs:label "Unit" .

fhir-ontology:ReferenceRange a owl:Class ;
    rdfs:label "Reference Range" .

fhir-ontology:low a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:ReferenceRange ;
    rdfs:range fhir-ontology:Quantity ;
    rdfs:label "Low" .

fhir-ontology:high a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:ReferenceRange ;
    rdfs:range fhir-ontology:Quantity ;
    rdfs:label "High" .

# ============================================================================
# MedicationRequest Resource
# ============================================================================

fhir-ontology:MedicationRequest a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Medication Request" ;
    rdfs:comment "Prescription or order for medication" .

fhir-ontology:intent a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:MedicationRequest ;
    rdfs:range xsd:string ;
    rdfs:label "Intent" ;
    rdfs:comment "proposal | plan | order | original-order | reflex-order | filler-order | instance-order | option" .

fhir-ontology:medication a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:MedicationRequest ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Medication" .

fhir-ontology:authoredOn a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:MedicationRequest ;
    rdfs:range xsd:dateTime ;
    rdfs:label "Authored On" .

fhir-ontology:requester a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:MedicationRequest ;
    rdfs:range fhir-ontology:Practitioner ;
    rdfs:label "Requester" .

fhir-ontology:dosageInstruction a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:MedicationRequest ;
    rdfs:range fhir-ontology:Dosage ;
    rdfs:label "Dosage Instruction" .

fhir-ontology:Dosage a owl:Class ;
    rdfs:label "Dosage" .

fhir-ontology:timing a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Dosage ;
    rdfs:range fhir-ontology:Timing ;
    rdfs:label "Timing" .

fhir-ontology:doseAndRate a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Dosage ;
    rdfs:range fhir-ontology:DoseAndRate ;
    rdfs:label "Dose and Rate" .

# ============================================================================
# Condition Resource (Diagnoses, Problems)
# ============================================================================

fhir-ontology:Condition a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Condition" ;
    rdfs:comment "Diagnosis, problem, or clinical condition" .

fhir-ontology:clinicalStatus a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Condition ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Clinical Status" ;
    rdfs:comment "active | recurrence | relapse | inactive | remission | resolved" .

fhir-ontology:verificationStatus a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Condition ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Verification Status" ;
    rdfs:comment "unconfirmed | provisional | differential | confirmed | refuted | entered-in-error" .

fhir-ontology:severity a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Condition ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Severity" .

fhir-ontology:conditionCode a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Condition ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Condition Code" ;
    rdfs:comment "ICD-10, SNOMED CT code" .

fhir-ontology:onsetDateTime a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Condition ;
    rdfs:range xsd:dateTime ;
    rdfs:label "Onset Date Time" .

# ============================================================================
# Encounter Resource (Visits, Admissions)
# ============================================================================

fhir-ontology:Encounter a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Encounter" ;
    rdfs:comment "Interaction between patient and healthcare provider" .

fhir-ontology:encounterClass a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Encounter ;
    rdfs:range fhir-ontology:Coding ;
    rdfs:label "Encounter Class" ;
    rdfs:comment "inpatient | outpatient | ambulatory | emergency" .

fhir-ontology:type a owl:ObjectProperty ;
    rdfs:label "Type" ;
    rdfs:range fhir-ontology:CodeableConcept .

fhir-ontology:period a owl:ObjectProperty ;
    rdfs:label "Period" ;
    rdfs:range fhir-ontology:Period .

fhir-ontology:participant a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Encounter ;
    rdfs:range fhir-ontology:EncounterParticipant ;
    rdfs:label "Participant" .

fhir-ontology:Period a owl:Class ;
    rdfs:label "Period" .

fhir-ontology:start a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Period ;
    rdfs:range xsd:dateTime ;
    rdfs:label "Start" .

fhir-ontology:end a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:Period ;
    rdfs:range xsd:dateTime ;
    rdfs:label "End" .

# ============================================================================
# Practitioner Resource
# ============================================================================

fhir-ontology:Practitioner a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Practitioner" ;
    rdfs:comment "Healthcare professional" .

fhir-ontology:qualification a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Practitioner ;
    rdfs:range fhir-ontology:Qualification ;
    rdfs:label "Qualification" .

fhir-ontology:Qualification a owl:Class ;
    rdfs:label "Qualification" .

fhir-ontology:qualificationCode a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Qualification ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Qualification Code" .

# ============================================================================
# Organization Resource
# ============================================================================

fhir-ontology:Organization a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Organization" ;
    rdfs:comment "Healthcare organization" .

fhir-ontology:organizationType a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Organization ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Organization Type" .

# ============================================================================
# Security and Consent
# ============================================================================

fhir-ontology:securityLabel a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Resource ;
    rdfs:range fhir-ontology:Coding ;
    rdfs:label "Security Label" ;
    rdfs:comment "Confidentiality, sensitivity classification" .

fhir-ontology:Consent a owl:Class ;
    rdfs:subClassOf fhir-ontology:DomainResource ;
    rdfs:label "Consent" ;
    rdfs:comment "Patient consent and privacy preferences" .

fhir-ontology:scope a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Consent ;
    rdfs:range fhir-ontology:CodeableConcept ;
    rdfs:label "Scope" .

fhir-ontology:provision a owl:ObjectProperty ;
    rdfs:domain fhir-ontology:Consent ;
    rdfs:range fhir-ontology:ConsentProvision ;
    rdfs:label "Provision" .

fhir-ontology:ConsentProvision a owl:Class ;
    rdfs:label "Consent Provision" .

fhir-ontology:provisionType a owl:DatatypeProperty ;
    rdfs:domain fhir-ontology:ConsentProvision ;
    rdfs:range xsd:string ;
    rdfs:label "Provision Type" ;
    rdfs:comment "deny | permit" .
