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.
- LinkedIn: https://www.linkedin.com/company/huminltd/
- Instagram: @humin.uk
- Website: https://humin.uk/
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:
Novedades
Minor fix
Qué hace
228 acciones-
Dictionary
-
Get File
-
If
-
Ask for InputWhich device do you want to use as source for your collected steps?
-
Set Variabledevice
-
Save File
-
If
-
Get Text from Input
-
Set Variabledevice
-
CommentSet the date to collect
-
Text
-
Set VariableLast Date Filepath
-
Get File
-
Get Dates from Input
-
Set Variablelast collected date
-
If
-
Show AlertWarning
-
Stop This Shortcut
-
Text
-
Get File
-
If
-
Adjust Date
-
Set VariableDate
-
Adjust Date
-
Set Variablelast collected date
-
If
-
Adjust Date
-
If
-
Show AlertInfo
-
Stop This Shortcut
-
Adjust Date
-
If
-
Show AlertInfo
-
Stop This Shortcut
-
Set VariableDate
-
CommentGet data file names
-
Text
-
Set VariableMood Filepath
-
Text
-
Set VariableID Filepath
-
Text
-
Set VariableLocation Filepath
-
Text
-
Set VariableHome Filepath
-
CommentGet current timezone
-
Format Date
-
Split Text
-
Get Item from List
-
Set Variabletimezone
-
CommentGet user ID
-
Get File
-
If
-
Show AlertWarning
-
Stop This Shortcut
-
Get Dictionary from Input
-
Set Variableuser ID
-
CommentCollect Apple Health Data
-
If
-
Get Dictionary from Input
-
Get Dictionary Value
-
Repeat with Each
-
Get Dictionary Value
-
Combine Text
-
Text
-
Combine Text
-
Set VariableApple Health Combined Results
-
Set Variableapple health dict to pass
-
If
-
Adjust Date
-
Set VariableYesterday
-
List
-
Set VariableFields to export
-
Find Health Samples
-
Set VariableDistance
-
Find Health Samples
-
Set VariableSleep
-
List
-
Set VariableHealth samples to export
-
Dictionary
-
Set VariableFinal dict
-
Repeat with Each
-
Get Details of Health Sample
-
If
-
If
-
Dictionary
-
Set VariableSample data dict
-
Repeat with Each
-
Get Details of Health Sample
-
If
-
If
-
If
-
Format Date
-
Set Dictionary Value
-
Set VariableSample data dict
-
If
-
If
-
If
-
Set Dictionary Value
-
Set VariableSample data dict
-
If
-
If
-
Set Dictionary Value
-
Set VariableSample data dict
-
If
-
Set Dictionary Value
-
Set VariableSample data dict
-
If
-
Set Dictionary Value
-
Set VariableSample data dict
-
Get Details of Health Sample
-
Set Variableend_date
-
Get Dictionary Value
-
Set Variabledict_date
-
Get Dictionary Value
-
List
-
Set Dictionary Value
-
Set Dictionary Value
-
Set VariableFinal dict
-
Repeat with Each
-
Get Dictionary Value
-
Repeat with Each
-
Get Dictionary Value
-
Combine Text
-
Text
-
Combine Text
-
Text
-
Combine Text
-
Text
-
Get Dictionary from Input
-
Set Variableapple health dict to pass
-
Run ShortcutHumin Export Health Data 1
-
Stop This Shortcut
-
CommentCollect location data (from Arc)
-
List
-
Set Variablelist_keep_activities
-
List
-
Set Variablelist_keep_location
-
Get File
-
Get Dictionary from Input
-
Set Variablehome_dict
-
If
-
Get Numbers from Input
-
Replace Text
-
Set Variablehome_latitude
-
Get Numbers from Input
-
Replace Text
-
Set Variablehome_longitude
-
If
-
Number
-
Set Variablehome_latitude
-
Number
-
Set Variablehome_longitude
-
Get File
-
Extract Archive
-
Get Dictionary from Input
-
If
-
Set Variabledata_list
-
Repeat with Each
-
Get Dictionary Value
-
If
-
Set Variablekeys_to_keep
-
If
-
Set Variablekeys_to_keep
-
Set Variablenew_dict_item
-
If
-
Repeat with Each
-
Get Dictionary Value
-
Set Variableitem_value
-
If
-
If
-
Get Numbers from Input
-
Replace Text
-
Set Variablelatitude
-
Get Numbers from Input
-
Replace Text
-
Set Variablelongitude
-
Calculate Expression
-
Set Variableitem_value
-
Set Dictionary Value
-
Set Variablenew_dict_item
-
List
-
Set Variablenew_list_path
-
Combine Text
-
Set Variablefinal_data
-
If
-
Set Variablefinal_data
-
If
-
Text
-
Set VariableLocation Results
-
If
-
Set VariableLocation Results
-
CommentGet mood data
-
Get File
-
If
-
Get Dictionary from Input
-
Get Dictionary Value
-
Combine Text
-
Text
-
Set VariableMood Results
-
If
Ver como código
Todas las acciones de este atajo escritas en Cherri, un lenguaje de programación para Atajos. Ideal para aprender cómo funciona.
#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()
Valoraciones y reseñas
Escribe una reseñaAún no hay reseñas. ¡Sé el primero en compartir tu opinión!