Stanford Spezi FHIR Implementation Guide
0.1.0 - ci-build

Publish Box goes here

Mobile Health Data

Mobile Health Data with Spezi

This section provides comprehensive guidance on representing mobile health data using the Spezi framework and FHIR standards. Mobile health applications generate vast amounts of health data from various sources including device sensors, user inputs, and wearables. The Spezi framework provides standardized approaches for collecting, transforming, and representing this data using HL7 FHIR resources.

Data Collection

On iOS platforms, Spezi applications leverage the HealthKitOnFHIR library in combination with SpeziHealthKit to serialize HealthKit data into FHIR Observations.

FHIR Observation Structure

HealthKitOnFHIR converts HealthKit samples to FHIR Observations using this structure:

{
  "resourceType": "Observation",
  "id": "spezi-healthkit-steps-example",
  "status": "final",
  "category": [
    {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/observation-category",
          "code": "survey"
        }
      ]
    }
  ],
  "code": {
    "coding": [
      {
        "system": "http://loinc.org",
        "code": "55423-8",
        "display": "Number of steps"
      }
    ]
  },
  "subject": {
    "reference": "Patient/example-patient"
  },
  "effectiveDateTime": "2024-01-15T10:30:00Z",
  "valueQuantity": {
    "value": 8542,
    "unit": "steps",
    "system": "http://unitsofmeasure.org",
    "code": "{steps}"
  },
  "device": {
    "display": "iPhone Health App"
  }
}

HealthKit Terminology Mapping Table

HKQuantityType Supported Code Unit
ActiveEnergyBurned 41981-2 kcal
AppleExerciseTime HKQuantityTypeIdentifierAppleExerciseTime min
AppleMoveTime HKQuantityTypeIdentifierAppleMoveTime min
AppleStandTime HKQuantityTypeIdentifierAppleStandTime min
AppleWalkingSteadiness HKQuantityTypeIdentifierAppleWalkingSteadiness %
BasalBodyTemperature HKQuantityTypeIdentifierBasalBodyTemperature C
BasalEnergyBurned HKQuantityTypeIdentifierBasalEnergyBurned kcal
BloodAlcoholContent 74859-0 %
BloodGlucose 41653-7 mg/dL
BloodPressureDiastolic 8462-4 mmHg
BloodPressureSystolic 8480-6 mmHg
BodyFatPercentage 41982-0 %
BodyMass 29463-7 [lb_av]
BodyMassIndex 39156-5 kg/m^2
BodyTemperature 8310-5 C
DietaryBiotin HKQuantityTypeIdentifierDietaryBiotin ug
DietaryCaffeine HKQuantityTypeIdentifierDietaryCaffeine mg
DietaryCalcium HKQuantityTypeIdentifierDietaryCalcium mg
DietaryCarbohydrates HKQuantityTypeIdentifierDietaryCarbohydates g
DietaryChloride HKQuantityTypeIdentifierDietaryChloride mg
DietaryCholesterol HKQuantityTypeIdentifierDietaryCholesterol mg
DietaryChromium HKQuantityTypeIdentifierDietaryChromium ug
DietaryCopper HKQuantityTypeIdentifierDietaryCopper ug
DietaryEnergyConsumed 9052-2 kcal
DietaryFatMonounsaturated HKQuantityTypeIdentifierDietaryFatMonounsaturated g
DietaryFatPolyunsaturated HKQuantityTypeIdentifierDietaryFatPolyunsaturated g
DietaryFatSaturated HKQuantityTypeIdentifierDietaryFatSaturated g
DietaryFatTotal HKQuantityTypeIdentifierDietaryFatTotal g
DietaryFiber LP203183-1 g
DietaryFolate HKQuantityTypeIdentifierDietaryFolate ug
DietaryIodine HKQuantityTypeIdentifierDietaryIodine ug
DietaryIron HKQuantityTypeIdentifierDietaryIron mg
DietaryMagnesium HKQuantityTypeIdentifierDietaryMagnesium mg
DietaryManganese HKQuantityTypeIdentifierDietaryManganese mg
DietaryMolybdenum HKQuantityTypeIdentifierDietaryMolybdenum ug
DietaryNiacin HKQuantityTypeIdentifierDietaryNiacin mg
DietaryPantothenicAcid HKQuantityTypeIdentifierDietaryPantothenicAcid mg
DietaryPhosphorus HKQuantityTypeIdentifierDietaryPhosphorus mg
DietaryPotassium HKQuantityTypeIdentifierDietaryPotassium mg
DietaryProtein HKQuantityTypeIdentifierDietaryProtein g
DietaryRiboflavin HKQuantityTypeIdentifierDietaryRiboflavin mg
DietarySelenium HKQuantityTypeIdentifierDietarySelenium ug
DietarySodium HKQuantityTypeIdentifierDietarySodium mg
DietarySugar HKQuantityTypeIdentifierDietarySugar g
DietaryThiamin HKQuantityTypeIdentifierDietaryThiamin mg
DietaryVitaminA HKQuantityTypeIdentifierDietaryVitaminA ug
DietaryVitaminB12 HKQuantityTypeIdentifierDietaryVitaminB12 ug
DietaryVitaminB6 HKQuantityTypeIdentifierDietaryVitaminB6 mg
DietaryVitaminC HKQuantityTypeIdentifierDietaryVitaminC mg
DietaryVitaminD HKQuantityTypeIdentifierDietaryVitaminD ug
DietaryVitaminE HKQuantityTypeIdentifierDietaryVitaminE mg
DietaryVitaminK HKQuantityTypeIdentifierDietaryVitaminK ug
DietaryWater HKQuantityTypeIdentifierDietaryWater l
DietaryZinc HKQuantityTypeIdentifierDietaryZinc mg
DistanceCycling HKQuantityTypeIdentifierDistanceCycling m
DistanceDownhillSnowSports HKQuantityTypeIdentifierDistanceDownhillSnowSports m
DistanceSwimming 93816-7 m
DistanceWalkingRunning HKQuantityTypeIdentifierDistanceWalkingRunning m
DistanceWheelchair HKQuantityTypeIdentifierDistanceWheelchair m
ElectrodermalActivity HKQuantityTypeIdentifierElectrodermalActivity siemens
EnvironmentalAudioExposure HKQuantityTypeIdentifierEnvironmentalAudioExposure dB(SPL)
FlightsClimbed 100304-5 flights
ForcedExpiratoryVolume1 20150-9 L
ForcedVitalCapacity 19870-5 L
HeadphoneAudioExposure HKQuantityTypeIdentifierHeadphoneAudioExposure dB(SPL)
HeartRate 8867-4 /min
HeartRateVariabilitySDNN 80404-7 ms
Height 8302-2 in
InhalerUsage HKQuantityTypeIdentifierInhalerUsage count
InsulinDelivery - -
LeanBodyMass 91557-9 lbs
NikeFuel - -
NumberOfTimesFallen HKQuantityTypeIdentifierNumberOfTimesFallen falls
OxygenSaturation 59408-5 %
PeakExpiratoryFlowRate 19935-6 L/min
PeripheralPerfusionIndex 61006-3 %
PhysicalEffort HKQuantityTypeIdentifierPhysicalEffort kcal/hr/kg
PushCount 96502-0 wheelchair pushes
RespiratoryRate 9279-1 breaths/minute
RestingHeartRate 40443-4 beats/minute
StepCount 55423-8 {steps}
SwimmingStrokeCount HKQuantityTypeIdentifierSwimmingStrokeCount strokes
TimeInDaylight HKQuantityTypeIdentifierTimeInDaylight min
UVExposure HKQuantityTypeIdentifierUVExposure count
VO2Max HKQuantityTypeIdentifierVO2Max mL/kg/min
WaistCircumference 8280-0 in
WalkingAsymmetryPercentage HKQuantityTypeIdentifierWalkingAsymmetryPercentage %
WalkingHeartRateAverage HKQuantityTypeIdentifierWalkingHeartRateAverage beats/minute
WalkingSpeed HKQuantityTypeIdentifierWalkingSpeed m/s