Skip to content

Add HealthMeasurement shape (Schema.org Health-Lifesci subset)#63

Draft
jeswr wants to merge 3 commits intosolid:mainfrom
jeswr:feat/health-measurement-shape
Draft

Add HealthMeasurement shape (Schema.org Health-Lifesci subset)#63
jeswr wants to merge 3 commits intosolid:mainfrom
jeswr:feat/health-measurement-shape

Conversation

@jeswr
Copy link
Copy Markdown
Member

@jeswr jeswr commented Apr 23, 2026

Adds a SHACL shape for a single health / fitness measurement on a Solid Pod, covering the common cases an Apple Health / Google Fit / Strava export emits.

Ontology basis

Schema.org Health-Lifesci extensionMedicalEntity + Observation + QuantitativeValue provide the foundation. For activity / fitness specifically, the shape composes with Schema.org ExerciseAction, Distance, Duration, and Energy. FHIR Observation maps cleanly to this for clinical use cases but is intentionally not depended on — that's a separate, heavier-duty modelling effort.

Scope

A focused per-measurement shape — heart rate, steps, sleep, weight, distance, duration, calories. Constraints:

  • schema:value (xsd:decimal)
  • schema:unitCode (UN/CEFACT or QUDT — kept open via sh:IRIOrLiteral so existing exporters' choices still pass)
  • schema:observationDate (xsd:dateTime)
  • schema:about (the WebID / agent the measurement belongs to)
  • measurement type linked to schema.org-defined codes where possible
  • schema:measurementMethod documented

The pending Schema.org Observation modelling refresh is referenced in the shape's comment block — when it lands, this shape can tighten without breaking consumers.

Consumer use cases

  • Health Dashboard app on the priority list at https://github.com/jeswr/solid-workspace
  • The Apple Health import flow (Apple Health XML → these triples)
  • The Strava integration (planned)
  • The Google Takeout integration's Fit module (planned)

Self-review

Reviewed locally with roborev review --local before opening. Two follow-up commits address its findings (sh:IRIOrLiteral for unitCode flexibility; loosened value and observationDate datatype constraints to match real-world exporters; tightened measurementMethod).

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

jeswr and others added 3 commits April 23, 2026 02:35
Adds a SHACL shape for schema:Observation focused on the common
health and fitness measurements emitted by Apple Health, Google Fit,
and Strava exports — heart rate, steps, sleep duration, body weight,
distance, exercise duration, and energy burned. Constrains
schema:value, schema:unitCode, schema:unitText, schema:observationDate,
schema:observationAbout, schema:measuredProperty, and
schema:measurementMethod. Cites HL7 FHIR Observation as a heavier
clinical alternative without depending on it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- schema:value: accept xsd:decimal, xsd:integer, xsd:double, or
  xsd:float so that integer step counts and double-precision sensor
  readings are not rejected by the exact sh:datatype match.
- schema:observationDate: accept either xsd:dateTime or xsd:date so
  daily aggregates (weight, daily step total) validate alongside
  instantaneous readings.
- schema:measurementMethod: add sh:maxCount 1 and an IRI-or-literal
  node-kind constraint so it matches the rest of the shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- schema:unitCode and schema:measurementMethod: replace the longhand
  sh:or node-kind disjunctions with the built-in sh:IRIOrLiteral so
  language-tagged strings are accepted and intent is clearer.
- Top-level sh:description now flags that schema:Observation and the
  schema:observation* properties currently sit in the Schema.org
  pending area and that consumer-health exporters do not emit them
  natively (an importer is expected to map proprietary formats to
  this shape).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 23, 2026 02:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new SHACL NodeShape intended to validate a single health/fitness measurement represented as a Schema.org Observation, to support importing common consumer health exports into Solid Pods.

Changes:

  • Introduces HealthMeasurementShape targeting schema:Observation.
  • Adds property constraints for numeric schema:value, unit fields, observation timestamp/date, subject (observationAbout), measured property, and method/device.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +15
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix vs: <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

@prefix health_measurement_shape: <https://solidproject.org/shapes/health_measurement#> .

health_measurement_shape:HealthMeasurementShape
a sh:NodeShape ;
sh:targetClass schema:Observation ;
sh:name "Health Measurement Shape" ;
sh:description "SHACL shape for a single health or fitness measurement modelled as a Schema.org Observation. The intended representation for the common cases consumer health and fitness exports (Apple Health, Google Fit, Strava) describe — heart rate, steps, sleep duration, body weight, distance, exercise duration, and energy burned. Note: schema:Observation and the schema:observation* properties currently sit in the pending area of Schema.org (https://pending.schema.org/); native exporters typically emit proprietary formats and an importer is expected to map them to this shape." ;
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shape uses only the https://schema.org/ namespace. A lot of RDF data (and some shapes in this repo) still use the legacy http://schema.org/ IRIs, so instances/properties like http://schema.org/Observation or http://schema.org/value would not be targeted/validated by this shape. Consider adding a schema_http: prefix and accepting both forms (e.g., dual sh:targetClass entries, and sh:path via sh:alternativePath or the “legacy predicate” pattern used in shapes/chat.ttl).

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +87
sh:path schema:observationAbout ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
sh:name "Observation About" ;
sh:description "The entity the observation is about. For personal health and fitness data this is typically the user's WebID (Schema.org schema:observationAbout)." ;
sh:codeIdentifier "observationAbout";
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description lists schema:about as the link to the WebID/agent, but this shape uses schema:observationAbout. If schema:about is what consumers/exporters will emit, the shape should accept it (or the PR description should be updated to match schema:observationAbout).

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +41
sh:property [
sh:path schema:value ;
sh:or (
[ sh:datatype xsd:decimal ]
[ sh:datatype xsd:integer ]
[ sh:datatype xsd:double ]
[ sh:datatype xsd:float ]
) ;
sh:maxCount 1 ;
sh:name "Value" ;
sh:description "Numeric value of the measurement (e.g., 72 for a heart-rate reading, 8500 for a step count, 5.2 for a kilometre distance). May be xsd:decimal, xsd:integer, xsd:double, or xsd:float." ;
sh:codeIdentifier "value";
] ;
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several properties described as core constraints in the PR (e.g., schema:value, schema:unitCode, schema:observationDate, schema:observationAbout) only have sh:maxCount here, so an Observation with none of these fields would still conform. If these are intended to be required for a “per-measurement” node, add appropriate sh:minCount 1 constraints (at least for value/date/about, and likely measuredProperty/unitCode depending on the metric).

Copilot uses AI. Check for mistakes.
@jeswr jeswr marked this pull request as draft April 23, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants