Skip to content

Instantly share code, notes, and snippets.

@dlo
Last active December 3, 2022 12:38
Show Gist options
  • Save dlo/fa537daf94cb3bb5527bc86ea10dced0 to your computer and use it in GitHub Desktop.
Save dlo/fa537daf94cb3bb5527bc86ea10dced0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
import datetime
def date_from_row(row):
year = row['year']
month = row['month']
day = row['day']
hour = row['hour']
minute = row['minute']
return datetime.datetime(year, month, day, hour, minute).isoformat()
with open("sampleData.py") as f:
rows = json.load(f)
print """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HealthData [
<!-- HealthKit Export Version: 3 -->
<!ELEMENT HealthData (ExportDate,Me,(Record|Correlation|Workout|ActivitySummary)*)>
<!ATTLIST HealthData
locale CDATA #REQUIRED
>
<!ELEMENT ExportDate EMPTY>
<!ATTLIST ExportDate
value CDATA #REQUIRED
>
<!ELEMENT Me EMPTY>
<!ATTLIST Me
HKCharacteristicTypeIdentifierDateOfBirth CDATA #REQUIRED
HKCharacteristicTypeIdentifierBiologicalSex CDATA #REQUIRED
HKCharacteristicTypeIdentifierBloodType CDATA #REQUIRED
HKCharacteristicTypeIdentifierFitzpatrickSkinType CDATA #REQUIRED
>
<!ELEMENT Record (MetadataEntry*)>
<!ATTLIST Record
type CDATA #REQUIRED
unit CDATA #IMPLIED
value CDATA #IMPLIED
sourceName CDATA #REQUIRED
sourceVersion CDATA #IMPLIED
device CDATA #IMPLIED
creationDate CDATA #IMPLIED
startDate CDATA #REQUIRED
endDate CDATA #REQUIRED
>
<!-- Note: Any Records that appear as children of a correlation also appear as top-level records in this document. -->
<!ELEMENT Correlation ((MetadataEntry|Record)*)>
<!ATTLIST Correlation
type CDATA #REQUIRED
sourceName CDATA #REQUIRED
sourceVersion CDATA #IMPLIED
device CDATA #IMPLIED
creationDate CDATA #IMPLIED
startDate CDATA #REQUIRED
endDate CDATA #REQUIRED
>
<!ELEMENT Workout ((MetadataEntry|WorkoutEvent)*)>
<!ATTLIST Workout
workoutActivityType CDATA #REQUIRED
duration CDATA #IMPLIED
durationUnit CDATA #IMPLIED
totalDistance CDATA #IMPLIED
totalDistanceUnit CDATA #IMPLIED
totalEnergyBurned CDATA #IMPLIED
totalEnergyBurnedUnit CDATA #IMPLIED
sourceName CDATA #REQUIRED
sourceVersion CDATA #IMPLIED
device CDATA #IMPLIED
creationDate CDATA #IMPLIED
startDate CDATA #REQUIRED
endDate CDATA #REQUIRED
>
<!ELEMENT WorkoutEvent EMPTY>
<!ATTLIST WorkoutEvent
type CDATA #REQUIRED
date CDATA #REQUIRED
>
<!ELEMENT ActivitySummary EMPTY>
<!ATTLIST ActivitySummary
dateComponents CDATA #IMPLIED
activeEnergyBurned CDATA #IMPLIED
activeEnergyBurnedGoal CDATA #IMPLIED
activeEnergyBurnedUnit CDATA #IMPLIED
appleExerciseTime CDATA #IMPLIED
appleExerciseTimeGoal CDATA #IMPLIED
appleStandHours CDATA #IMPLIED
appleStandHoursGoal CDATA #IMPLIED
>
<!ELEMENT MetadataEntry EMPTY>
<!ATTLIST MetadataEntry
key CDATA #REQUIRED
value CDATA #REQUIRED
>
]>
<HealthData locale="en_US">
"""
for row in rows:
date = date_from_row(row)
row['creationDate'] = date
row['startDate'] = date
row['endDate'] = date
# Type identifiers available from https://developer.apple.com/reference/healthkit/healthkit_constants?language=objc#2315149
# Provide `unit` as a string (e.g., "mi")
# Other record types, such as workouts, are more complex and have some undocumented requirements.
print """<Record type="HKQuantityTypeIdentifierBloodGlucose" sourceName="Python Script" sourceVersion="1.0" unit="mg/dL" creationDate="{creationDate}" startDate="{startDate}" endDate="{endDate}" value="{value}">""".format(**row)
print "</HealthData>"
@beautyarmpit
Copy link

I quite suspicious that the health report on this item can be abuse from health condition according to form identified to something else for instance, someone information, banking numbers, concept and idea of someone, betrayal thought and deception against someone loyalty. Please analyze the health report that attached with this comment. Thank you.)
EADE842A-4AA9-445C-8640-D456F4098186
F4BE3B5C-47BE-4619-B186-61228A47836F
7309D280-B6AB-492D-996C-F1C29C0D2B8B
9BBD103B-6D41-4657-B8B7-BF33B2B0A636
8024FFF8-855D-4012-8C59-6F208D70CACC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment