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 eighteen 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
8FactsAsserting real instances: actual animals, owners, appointments
9Temporal typesReal dates, times, and durations instead of strings
10RulesAutomated reasoning and inference over facts
11Units & quantitiesMeasurements that carry their unit and compare across units
12Constraints & quantifiersValidation and guard rails
13Prefixes & IRIsInteroperability with external systems
14JSON mappingsBulk-loading instances from a JSON export
15XML mappingsBulk-loading instances from an XML feed
16Spreadsheet mappingsBulk-loading instances from an Excel or LibreOffice workbook
17Filters, value tables, slug(), quantity castsLoading a national catalogue with only the rows and values the clinic needs
18QueriesAsking questions of the data, translated to SPARQL

The complete ontology

Here is the full Happy Paws ontology, everything from every chapter, in two files: the package manifest and the ontology itself.


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

# ============================================================
#  clinic.dlf: Happy Paws Veterinary Clinic, Complete Ontology
# ============================================================

# ------------------------------------------------------------
# Schema: concepts, enums, and properties (Chapters 4-9)
# ------------------------------------------------------------

concept Species:
  one of:
    Dog
    Cat
    Bird
    Rabbit
    Reptile
    Other

concept Urgency:
  one of:
    Routine
    Urgent
    Emergency

concept AppointmentStatus:
  one of:
    Scheduled
    InProgress
    Completed
    Cancelled

concept Owner:
  has firstName: one string
  has lastName: one string
  has phoneNumbers: at least 1 string
  has email: optional string
  has address: optional string
  has preferredVet: optional Veterinarian

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

concept Surgeon:
  sub Veterinarian
  has surgeryCount: one int
  has certifiedProcedures: at least 1 string

concept Dentist:
  sub Veterinarian
  has dentalCertification: one string

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

concept Vaccination:
  has vaccineName: one string
  has dateAdministered: one string
  has batchNumber: optional string

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 canFly: one boolean

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

property treatedBy: Animal -> Veterinarian

# ------------------------------------------------------------
# Binding to the outside world (Chapter 13)
# ------------------------------------------------------------

concept DomesticDog:
  @iri_name <http://fao.org/species/CanineDomestic>
  sub Dog

# ------------------------------------------------------------
# Flag concepts and inference rules (Chapter 10)
# ------------------------------------------------------------

concept UnvaccinatedAnimal
concept UnsafeAssignment
concept OverweightAnimal

rule flag_unvaccinated:
  match:
    ?animal a Animal
    count ?shot as ?shots
      ?animal vaccinations ?shot
    ?shots [ = 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 assign_primary_vet:
  match:
    ?animal a Animal
    ?animal owner [ preferred_vet ?vet ]
  then:
    ?animal treatedBy ?vet

# ------------------------------------------------------------
# Unit-aware weight thresholds (Chapter 11)
# ------------------------------------------------------------

concept OverweightCat

rule flag_overweight_dog:
  match:
    ?dog a Dog
    ?dog weight [ > quantity(40 kg) ]
  then:
    ?dog a OverweightAnimal

rule flag_overweight_cat:
  match:
    ?cat a Cat
    ?cat weight [ > quantity(6 kg) ]
  then:
    ?cat a OverweightCat

# ------------------------------------------------------------
# Guard rails: validation concepts and rules (Chapter 12)
# ------------------------------------------------------------

concept SeniorCat
concept InvalidSurgery
concept UnderVaccinatedDog
concept AtRiskAnimal

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

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

rule check_dog_vaccines:
  match:
    ?dog a Dog
    count ?shot as ?shots
      ?dog vaccinations ?shot
    ?shots [ = 0 ]
  then:
    ?dog a UnderVaccinatedDog

rule flag_at_risk:
  match:
    ?animal a Animal
    ?animal age [ > 15 ]
    ?animal weight [ < quantity(2 kg) ]
    count ?shot as ?shots
      ?animal vaccinations ?shot
    ?shots [ = 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.