ShareShortcuts

Humin Export Health Data

How does it work?

humin
„Humin Export Health Data“ forken

Hast du auf Basis dieses Kurzbefehls etwas Neues erstellt? Teile ihn als Fork: Er wird zu deinem eigenen Kurzbefehl, den du selbst verwaltest, und beide Seiten verlinken aufeinander, damit humin die Anerkennung erhält.

  1. 1Lade den Kurzbefehl und ändere ihn in der Kurzbefehle-App. Gib ihm einen eigenen Namen.
  2. 2Teile ihn in der Kurzbefehle-App und kopiere den iCloud-Link.
  3. 3Komm hierher zurück, füge den Link ein und beschreibe, was sich geändert hat, z. B. „Einen Schritt hinzugefügt, der Apple Intelligence nutzt, um den Text zu personalisieren.“
Downloads
37K
Gesichert
0
Aktionen
228
Kategorie
API
Version
1.6
Sprache
EN

How does it work?

By running this shortcut, you can send your data for analysis as part of our research. You can either set an automation for it to run regularly, or manually run it. Every time this shortcut is run, it will pick up the sleep and physical activity data since the last time you ran it.

Integration within the Humin ecosystem

This shortcut is meant to be used within the Humin ecosystem, as part of our Data Research & Development project. The other shortcuts for this project can be found here:

To know more about the project or get involved, don’t hesitate to reach out to us!

About Humin

We are building a Fitbit for mental health: bringing objective, passive, personalised symptom tracking for mood.

Our mission is to bring deep and personalised insights to support people to understand their mood symptoms. We are doing this using AI and anonymised data. Our vision is to bring quality mental health insights to everyone, to help them get the right care at the right time.

News

We are currently developing our MVP. If you wish to reach out to us and/or help us in our research, please reach out to us by visiting our website at https://humin.uk/.

Go and check out our podcast on mental health:

Neue Funktionen

Version 1.6

Minor fix

Versionsverlauf
1.6 21. Nov 2022

Minor fix

1.5 21. Nov 2022

Add selection of source for physical activity data

1.4 21. Nov 2022

Added mock-up data collection when app is run for the first time to enable permissions

1.3 21. Nov 2022

Added mock-up data collection when app is run for the first time to enable permissions

1.2 21. Nov 2022

Test

1.1 20. Nov 2022

Added support for auto-update

1.0 20. Nov 2022

First release

Was er macht

228 Aktionen
  1. Dictionary
  2. Get File
  3. If
  4. Ask for Input
    Which device do you want to use as source for your collected steps?
  5. Set Variable
    device
  6. Save File
  7. If
  8. Get Text from Input
  9. Set Variable
    device
  10. Comment
    Set the date to collect
  11. Text
  12. Set Variable
    Last Date Filepath
  13. Get File
  14. Get Dates from Input
  15. Set Variable
    last collected date
  16. If
  17. Show Alert
    Warning
  18. Stop This Shortcut
  19. Text
  20. Get File
  21. If
  22. Adjust Date
  23. Set Variable
    Date
  24. Adjust Date
  25. Set Variable
    last collected date
  26. If
  27. Adjust Date
  28. If
  29. Show Alert
    Info
  30. Stop This Shortcut
  31. Adjust Date
  32. If
  33. Show Alert
    Info
  34. Stop This Shortcut
  35. Set Variable
    Date
  36. Comment
    Get data file names
  37. Text
  38. Set Variable
    Mood Filepath
  39. Text
  40. Set Variable
    ID Filepath
  41. Text
  42. Set Variable
    Location Filepath
  43. Text
  44. Set Variable
    Home Filepath
  45. Comment
    Get current timezone
  46. Format Date
  47. Split Text
  48. Get Item from List
  49. Set Variable
    timezone
  50. Comment
    Get user ID
  51. Get File
  52. If
  53. Show Alert
    Warning
  54. Stop This Shortcut
  55. Get Dictionary from Input
  56. Set Variable
    user ID
  57. Comment
    Collect Apple Health Data
  58. If
  59. Get Dictionary from Input
  60. Get Dictionary Value
  61. Repeat with Each
  62. Get Dictionary Value
  63. Combine Text
  64. Text
  65. Combine Text
  66. Set Variable
    Apple Health Combined Results
  67. Set Variable
    apple health dict to pass
  68. If
  69. Adjust Date
  70. Set Variable
    Yesterday
  71. List
  72. Set Variable
    Fields to export
  73. Find Health Samples
  74. Set Variable
    Distance
  75. Find Health Samples
  76. Set Variable
    Sleep
  77. List
  78. Set Variable
    Health samples to export
  79. Dictionary
  80. Set Variable
    Final dict
  81. Repeat with Each
  82. Get Details of Health Sample
  83. If
  84. If
  85. Dictionary
  86. Set Variable
    Sample data dict
  87. Repeat with Each
  88. Get Details of Health Sample
  89. If
  90. If
  91. If
  92. Format Date
  93. Set Dictionary Value
  94. Set Variable
    Sample data dict
  95. If
  96. If
  97. If
  98. Set Dictionary Value
  99. Set Variable
    Sample data dict
  100. If
  101. If
  102. Set Dictionary Value
  103. Set Variable
    Sample data dict
  104. If
  105. Set Dictionary Value
  106. Set Variable
    Sample data dict
  107. If
  108. Set Dictionary Value
  109. Set Variable
    Sample data dict
  110. Get Details of Health Sample
  111. Set Variable
    end_date
  112. Get Dictionary Value
  113. Set Variable
    dict_date
  114. Get Dictionary Value
  115. List
  116. Set Dictionary Value
  117. Set Dictionary Value
  118. Set Variable
    Final dict
  119. Repeat with Each
  120. Get Dictionary Value
  121. Repeat with Each
  122. Get Dictionary Value
  123. Combine Text
  124. Text
  125. Combine Text
  126. Text
  127. Combine Text
  128. Text
  129. Get Dictionary from Input
  130. Set Variable
    apple health dict to pass
  131. Run Shortcut
    Humin Export Health Data 1
  132. Stop This Shortcut
  133. Comment
    Collect location data (from Arc)
  134. List
  135. Set Variable
    list_keep_activities
  136. List
  137. Set Variable
    list_keep_location
  138. Get File
  139. Get Dictionary from Input
  140. Set Variable
    home_dict
  141. If
  142. Get Numbers from Input
  143. Replace Text
  144. Set Variable
    home_latitude
  145. Get Numbers from Input
  146. Replace Text
  147. Set Variable
    home_longitude
  148. If
  149. Number
  150. Set Variable
    home_latitude
  151. Number
  152. Set Variable
    home_longitude
  153. Get File
  154. Extract Archive
  155. Get Dictionary from Input
  156. If
  157. Set Variable
    data_list
  158. Repeat with Each
  159. Get Dictionary Value
  160. If
  161. Set Variable
    keys_to_keep
  162. If
  163. Set Variable
    keys_to_keep
  164. Set Variable
    new_dict_item
  165. If
  166. Repeat with Each
  167. Get Dictionary Value
  168. Set Variable
    item_value
  169. If
  170. If
  171. Get Numbers from Input
  172. Replace Text
  173. Set Variable
    latitude
  174. Get Numbers from Input
  175. Replace Text
  176. Set Variable
    longitude
  177. Calculate Expression
  178. Set Variable
    item_value
  179. Set Dictionary Value
  180. Set Variable
    new_dict_item
  181. List
  182. Set Variable
    new_list_path
  183. Combine Text
  184. Set Variable
    final_data
  185. If
  186. Set Variable
    final_data
  187. If
  188. Text
  189. Set Variable
    Location Results
  190. If
  191. Set Variable
    Location Results
  192. Comment
    Get mood data
  193. Get File
  194. If
  195. Get Dictionary from Input
  196. Get Dictionary Value
  197. Combine Text
  198. Text
  199. Set Variable
    Mood Results
  200. If

Als Code ansehen
Beta

Jede Aktion dieses Kurzbefehls als Cherri ausgeschrieben, eine Programmiersprache für Kurzbefehle. Ideal, um zu lernen, wie er funktioniert.

#include 'actions/text'
#include 'actions/documents'
#define color teal
#define glyph paperAirplane

const File = getFileFromFolder(, "Humin/device.txt", false)

if !File {
	prompt("Which device do you want to use as source for your collected steps?", "Text")
	@device
	saveFile("Humin/device.txt", @device, true)
} else {
	getText(File)
	@device
}
// Set the date to collect

@LastDateFilepath = "Humin/lastDateSaved.txt"
const File1 = getFile(@LastDateFilepath, false)
const Dates = getDates(File1)
@LastCollectedDate = Dates

if !Dates {
	alert("It seems that you haven't run the main settings before. Please run the Shortcut named \"Humin Menu\" once before running the current Shortcut.", "Warning")
	stop()
}
const exportCheckFilename = "Humin/exportSetUpDone.txt"
const exportCheckFile = getFile(exportCheckFilename, false)

if !exportCheckFile {
	adjustDate(CurrentDate, "Subtract")
	@Date
	adjustDate(CurrentDate, "Subtract")
	@LastCollectedDate
} else {
	const AdjustedDate = adjustDate(Dates, "Add")
	if AdjustedDate == CurrentDate {
		alert("Everything is good! All data until yesterday have been processed.", "Info")
		stop()
	}
	const AdjustedDate1 = adjustDate(Dates, "")
	if AdjustedDate1 == CurrentDate {
		alert("Everything is good! All data until yesterday have been processed.", "Info")
		stop()
	}
	@Date = AdjustedDate1
}
// Get data file names

@MoodFilepath = "Humin/Mood/{@Date}.json"
@IDFilepath = "Humin/user_id.json"
@LocationFilepath = "Export/JSON/Daily/{@Date}.json.gz"
@HomeFilepath = "Humin/home.json"
// Get current timezone

const FormattedDate = formatDate(CurrentDate, "RFC 2822")
const SplitText = splitText(FormattedDate, " ")
getListItem(SplitText, 2)
@timezone
// Get user ID

const IDFile = getFile(@IDFilepath, false)

if !IDFile {
	alert("We couldn't find any pre-existing user ID, we are unable to process your data. Please set an ID by running the Humin Menu Shortcut.", "Warning")
	stop()
}
getDictionary(IDFile)
@UserID = ['userID']
// Collect Apple Health Data


if ShortcutInput {
	const Dictionary = getDictionary(ShortcutInput)
	const DictionaryValue = getValue(Dictionary, @Date)
	for _ in DictionaryValue['Keys'] {
		const DictionaryValue1 = getValue(DictionaryValue, @RepeatItem)
		joinText(DictionaryValue1, ",")
	}
	joinText(RepeatResults, ",")
	@AppleHealthCombinedResults
	@AppleHealthDictToPass = Dictionary
} else {
	adjustDate(CurrentDate, "Subtract")
	@Yesterday
	list("Start Date", "End Date", "Value", "Unit", "Source")
	@FieldsToExport
	@Distance = rawAction("is.workflow.actions.filter.health.quantity")
	@Sleep = rawAction("is.workflow.actions.filter.health.quantity")
	list(@Distance, @Sleep)
	@HealthSamplesToExport
	@FinalDict = {}
	for _ in @HealthSamplesToExport {
		rawAction("is.workflow.actions.properties.health.quantity", {
			"WFContentItemPropertyName": "End Date",
			"WFInput": "@RepeatItem"
		})
		if EndDate != @LastCollectedDate {
			if EndDate != @Yesterday {
				@SampleDataDict = {}
				for _ in @FieldsToExport {
					rawAction("is.workflow.actions.properties.health.quantity", {
						"WFContentItemPropertyName": "@RepeatItem2",
						"WFInput": "@RepeatItem"
					})
					if !Type {
					} else {
						if @RepeatItem2 contains "Date" {
							formatDate(Type, "ISO 8601")
							setValue(@SampleDataDict, @RepeatItem2)
							@SampleDataDict
						} else {
							if @RepeatItem2 == "Source" {
								if Type['Name'] contains "iPhone" {
									setValue(@SampleDataDict, @RepeatItem2, "iPhone")
									@SampleDataDict
								} else {
									if Type['Name'] contains "Apple Watch" {
										setValue(@SampleDataDict, @RepeatItem2, "Apple Watch")
										@SampleDataDict
									} else {
										setValue(@SampleDataDict, @RepeatItem2, Type)
										@SampleDataDict
									}
								}
							} else {
								setValue(@SampleDataDict, @RepeatItem2, Type)
								@SampleDataDict
							}
						}
					}
				}
				rawAction("is.workflow.actions.properties.health.quantity", {
					"WFContentItemPropertyName": "End Date",
					"WFInput": "@RepeatItem"
				})
				@end_date
				@dict_date = @FinalDict[@end_date]
				list(, @SampleDataDict)
				setValue(@dict_date, @RepeatItem['Type'])
				setValue(@FinalDict, @end_date)
				@FinalDict
			}
		}
	}
	for _ in @FinalDict {
		const DictionaryValue2 = getValue(@FinalDict, @RepeatItem)
		for _ in DictionaryValue2['Keys'] {
			const DictionaryValue3 = getValue(DictionaryValue2, @RepeatItem2)
			joinText(DictionaryValue3, ",")
		}
		joinText(RepeatResults1, ",")
	}
	joinText(RepeatResults2, ",")
	const Text = "{{}}"
	getDictionary(Text)
	@AppleHealthDictToPass
	runSelf(@AppleHealthDictToPass)
	stop()
}
// Collect location data (from Arc)

list("startDate", "endDate", "floorsAscended", "floorsDescended", "uncertainActivityType", "unknownActivityType", "manualActivityType", "isVisit", "activityTypeConfidenceScore", "activityType", "altitude", "stepCount")
@list_keep_activities
list("startDate", "endDate", "floorsAscended", "floorsDescended", "radius", "isVisit", "manualPlace", "altitude", "stepCount", "center")
@list_keep_location
const File2 = getFile(@HomeFilepath, false)
getDictionary(File2)
@home_dict

if @home_dict {
	getNumbers(@home_dict)
	replaceText(",", ".")
	@home_latitude
	getNumbers(@home_dict)
	replaceText(",", ".")
	@home_longitude
} else {
	@home_latitude = 0
	@home_longitude = 0
}
const File3 = getFile(@LocationFilepath, false)
const Files = extractArchive(File3)
const Dictionary1 = getDictionary(Files)

if Dictionary1 {
	@data_list = Dictionary1['timelineItems']
	for _ in @data_list {
		const DictionaryValue4 = getValue(@RepeatItem, "isVisit")
		if DictionaryValue4 == "true" {
			@keys_to_keep = @list_keep_location
		} else {
			@keys_to_keep = @list_keep_activities
		}
		@new_dict_item = nil
		if DictionaryValue4 ==  {
			for _ in @RepeatItem {
				@item_value = @RepeatItem[@RepeatItem2]
				if @keys_to_keep contains @RepeatItem2 {
					if @RepeatItem2 == "center" {
						getNumbers(@item_value)
						replaceText(",", ".")
						@latitude
						getNumbers(@item_value)
						replaceText(",", ".")
						@longitude
						@item_value = 2*6371*asin(sqrt(sind((@latitude-@home_latitude)/2)^2 + cosd(@latitude) * cosd(@home_latitude) * sind((@longitude-@home_longitude)/2)^2))
					}
					setValue(@new_dict_item, @RepeatItem2, @item_value)
					@new_dict_item
				}
			}
			list(@new_list_path, @new_dict_item)
			@new_list_path
		}
	}
	joinText(@new_list_path, ",")
	@final_data
} else {
	@final_data = nil
}

if @final_data {
	@LocationResults = "\\"arcLocation\\":[{@final_data}]"
} else {
	@LocationResults = nil
}
// Get mood data

const File4 = getFile(@MoodFilepath, false)

if File4 {
	const Dictionary2 = getDictionary(File4)
	const DictionaryValue5 = getValue(Dictionary2, "Mood")
	joinText(DictionaryValue5, ",")
	@MoodResults = "\\"Mood\\": [{}]"
} else {
	@MoodResults = nil
}
// Combine and send to database

const List = list(@AppleHealthCombinedResults, @LocationResults, @MoodResults)
joinText(List, ",")
const Text1 = "{\\"userID\\": \\"{@UserID}\\", \\"date\\": \\"{@Date}\\", \\"timezone\\": \\"{@timezone}\\", \\"data\\": {{}}}"
const Dictionary3 = getDictionary(Text1)

if !exportCheckFile {
	adjustDate(CurrentDate, "Subtract")
	const Dictionary4 = setValue(Dictionary3, "date")
	const Dictionary5 = setValue(Dictionary4, "temp")
	fileRequest("https://europe-west3-humin-data-collection.cloudfunctions.net/appleHealth", "POST", Dictionary5)
	const Text2 = "Set up done"
	saveFile(exportCheckFilename, Text2, true)
	stop()
}
const ContentsOfURL = fileRequest("https://europe-west3-humin-data-collection.cloudfunctions.net/appleHealth", "POST", Dictionary3)
const Dictionary6 = getDictionary(ContentsOfURL)

if Dictionary6['Keys'] contains "status" {
	const DictionaryValue6 = getValue(Dictionary6, "status")
	if DictionaryValue6 == "success" {
		saveFile(@LastDateFilepath, Dictionary6['data'], true)
	} else {
		alert("We couldn't process your data. We will investigate it. This might be due to a network issue, please retry in a few minutes. If the problem persists, don't hesitate to reach out to the support and we will be very happy to help.", "Warning")
		stop()
	}
}
wait(5)
runSelf(@AppleHealthDictToPass)
stop()
Mit cherri 2.3.0 (GPL-2.0) dekompiliert. Eventuell sind kleine Korrekturen nötig, bevor es kompiliert wird.

Bewertungen und Rezensionen

Rezension schreiben
–
von 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Werbung

Mehr von humin

Alle anzeigen

Das gefällt dir vielleicht auch

Alle anzeigen
Werbung