Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Epilogue: The Full Picture

Three months later, Happy Paws had treated 847 animals. The system had caught 23 unsafe assignments, flagged 156 overdue vaccinations, and identified 4 at-risk animals that might have been missed. Dr. Reyes had performed 31 surgeries without a single scheduling error. And Pixel, now a healthy six-month-old, had been adopted by the receptionist.


What you’ve learned

Over ten chapters, you’ve built a complete ontology from scratch. Here’s what each chapter introduced:

ChapterFeatureWhy you needed it
1PackagesIdentity and metadata for the project
2Concepts & primitive typesDescribing real-world entities
3Properties & referencesConnecting concepts to each other
4EnumsControlled vocabularies instead of free text
5CardinalityConstraining how many values an attribute holds
6Multi-valued attributesLists, required collections, and promoting strings to concepts
7Inheritance (sub)Shared structure without duplication
8RulesAutomated reasoning and inference
9Constraints & quantifiersValidation and guard rails
10Prefixes & IRIsInteroperability with external systems

The complete ontology

Here is the full Happy Paws ontology, everything from every chapter, in one file:


# ============================================================
#  Happy Paws Veterinary Clinic: Complete Ontology
# ============================================================

prefix naho as <http://naho.gov/ontology/>
prefix fao as <http://fao.org/species/>
prefix schema as <http://schema.org/>

package <http://happypaws.com/clinic>:
  dolfin_version "1"
  version "1.0.0"
  author "Dr. Helen Portbridge"
  description "The Happy Paws veterinary clinic data model"

# ------------------------------------------------------------
# Enumerations
# ------------------------------------------------------------

concept Species:
  only values:
    Dog
    Cat
    Bird
    Rabbit
    Reptile
    Other

concept Urgency:
  only values:
    Routine
    Urgent
    Emergency

concept AppointmentStatus:
  only values:
    Scheduled
    InProgress
    Completed
    Cancelled

# ------------------------------------------------------------
# People
# ------------------------------------------------------------

concept Owner:
  has first_name: one string
  has last_name: one string
  has phone_numbers: at least 1 string
  has email: optional string
  has address: optional string
  has preferred_vet: optional Veterinarian

concept Veterinarian:
  has name: one string
  has license_number: one string
  has specialization: optional string

concept Surgeon:
  sub Veterinarian
  has surgery_count: one int
  has certified_procedures: at least 1 string

concept Dentist:
  sub Veterinarian
  has dental_certification: one string

concept Intern:
  sub Veterinarian
  has university: one string
  has year: one int

# ------------------------------------------------------------
# Medical records
# ------------------------------------------------------------

concept Vaccination:
  has vaccine_name: one string
  has date_administered: one string
  has batch_number: optional string

# ------------------------------------------------------------
# Animals
# ------------------------------------------------------------

concept Animal:
  has name: one string
  has species: one Species
  has age: optional int
  has weight: optional float
  has owner: optional Owner
  has vaccinations: Vaccination
  has allergies: string

concept Dog:
  sub Animal
  has breed: optional string
  has neutered: one boolean

concept Cat:
  sub Animal
  has indoor: one boolean

concept Bird:
  sub Animal
  has wingspan: optional float
  has can_fly: one boolean

# ------------------------------------------------------------
# Appointments
# ------------------------------------------------------------

concept Appointment:
  has animal: one Animal
  has date: one string
  has reason: one string
  has urgency: one Urgency
  has status: one AppointmentStatus
  has diagnosis: optional string
  has treatments: string
  has notes: optional string

# ------------------------------------------------------------
# Standalone properties
# ------------------------------------------------------------

property treatedBy:
  Animal -> Veterinarian

# ------------------------------------------------------------
# Flag concepts (created by rules)
# ------------------------------------------------------------

concept UnvaccinatedAnimal
concept UnsafeAssignment
concept OverweightAnimal
concept SeniorCat
concept InvalidSurgery
concept UnderVaccinatedDog
concept AtRiskAnimal

# ------------------------------------------------------------
# Inference rules
# ------------------------------------------------------------

rule flag_unvaccinated:
  match:
    ?animal a Animal
    ?animal vaccinations 0
  then:
    ?animal a UnvaccinatedAnimal

rule flag_intern_emergency:
  match:
    ?appt a Appointment
    ?appt urgency Emergency
    ?appt animal [ treatedBy [ a Intern ] ]
  then:
    ?appt a UnsafeAssignment

rule flag_overweight_dog:
  match:
    ?dog a Dog
    ?dog weight [ > 40.0 ]
  then:
    ?dog a OverweightAnimal

rule flag_senior_cat:
  match:
    ?cat a Cat
    ?cat age [ >= 10 ]
  then:
    ?cat a SeniorCat

rule assign_primary_vet:
  match:
    ?animal a Animal
    ?animal owner [ preferred_vet ?vet ]
  then:
    ?animal treatedBy ?vet

# ------------------------------------------------------------
# Validation rules
# ------------------------------------------------------------

rule validate_surgery_staff:
  match:
    ?appt a Appointment
    ?appt reason "surgery"
    among:
      ?appt animal [ treatedBy ?vet ]
    none:
      ?vet a Surgeon
  then:
    ?appt a InvalidSurgery

rule check_dog_vaccines:
  match:
    ?dog a Dog
    ?dog vaccinations 0
  then:
    ?dog a UnderVaccinatedDog

rule flag_at_risk:
  match:
    ?animal a Animal
    ?animal age [ > 15 ]
    ?animal weight [ < 2.0 ]
    ?animal vaccinations 0
  then:
    ?animal a AtRiskAnimal

Dr. Portbridge closed her laptop and looked around the clinic. The walls were covered in thank-you cards from pet owners. The system hummed quietly in the background, catching errors, inferring relationships, and speaking the language of the wider world. What had started as a napkin sketch on opening day was now a living, breathing data model.

Biscuit dozed at her feet. Pixel purred on the printer. All was well at Happy Paws.