Cotton code
227 lines · 6.7 KB · JSONRaw
{  "views": [    {      "id": "today",      "label": "Today",      "visibility": "owner",      "is_default": true,      "read": {        "table": "health_day",        "empty": {          "line": "empty_views.health.today",          "table": true        },        "where": {          "day": {            "on": "today"          }        }      },      "sort": {        "column": "day",        "descending": false      },      "opened": {        "tie": "metric",        "tie_descending": false      }    },    {      "id": "trends",      "label": "Trends",      "visibility": "owner",      "is_default": false,      "read": {        "table": "health_day",        "empty": {          "line": "empty_views.health.trends",          "table": true        },        "where": {          "day": {            "within_days": 30          }        }      },      "sort": {        "column": "day",        "descending": true      }    },    {      "id": "workouts",      "label": "Workouts",      "visibility": "owner",      "is_default": false,      "read": {        "table": "health_workout",        "empty": {          "line": "empty_views.health.workouts",          "table": true        }      },      "sort": {        "column": "day",        "descending": true      },      "opened": {        "tie": "started_at",        "tie_descending": true      }    },    {      "id": "sleep",      "label": "Sleep",      "visibility": "owner",      "is_default": false,      "read": {        "table": "health_day",        "empty": {          "line": "empty_views.health.sleep",          "table": true        }      },      "sort": {        "column": "day",        "descending": true      },      "opened": {        "where": {          "metric": [            "sleep_asleep",            "sleep_in_bed",            "sleep_core",            "sleep_deep",            "sleep_rem",            "sleep_awake"          ]        },        "tie": "metric",        "tie_descending": false      }    },    {      "id": "body",      "label": "Body",      "visibility": "owner",      "is_default": false,      "read": {        "table": "health_measurement",        "empty": {          "line": "empty_views.health.body",          "table": true        }      },      "sort": {        "column": "day",        "descending": true      },      "opened": {        "tie": "measured_at",        "tie_descending": true      }    },    {      "id": "labs",      "label": "Labs",      "visibility": "owner",      "is_default": false,      "read": {        "table": "lab_result",        "empty": {          "line": "empty_views.health.labs",          "table": true        }      },      "sort": {        "column": "day",        "descending": true      },      "opened": {        "tie": "position",        "tie_descending": false      }    },    {      "id": "reports",      "label": "Reports",      "visibility": "owner",      "is_default": false,      "read": {        "table": "lab_report",        "empty": {          "line": "empty_views.health.reports",          "table": true        }      },      "sort": {        "column": "day",        "descending": true      }    },    {      "id": "people",      "label": "People",      "visibility": "owner",      "is_default": false,      "read": {        "table": "health_person",        "empty": {          "line": "empty_views.health.people",          "table": true        }      },      "sort": {        "column": "key",        "descending": false      },      "opened": {        "tie": "position",        "tie_descending": false      }    },    {      "id": "devices",      "label": "Devices",      "visibility": "owner",      "is_default": false,      "read": {        "table": "vault_key",        "empty": {          "line": "empty_views.keys.devices",          "table": true        }      },      "sort": {        "column": "vmk_version",        "descending": false,        "tie": "created_at",        "tie_descending": false      }    }  ],  "id": "health",  "name": "Health",  "purpose": "Your lab reports and your Apple Health numbers in your own database, sealed: every measured result of every report, for you and the family members you keep records for, and each day's steps, sleep and heart.",  "picture": {    "photo": "photo:446bfe169e3084b3ed1fb458ccf284ca899d95fe347137cadee8b76fd4d3925d",    "object": "tool-goals"  },  "tables": [    "health_day",    "health_workout",    "health_measurement",    "lab_report",    "lab_result",    "health_person",    "person",    "vault_key"  ],  "instructions": "Health keeps two kinds of record, both sealed. LABS: lab_report is one lab report (one order, for one person, its original PDF sealed in pdf), lab_result one measured result in it, as printed (name, result, unit, reference interval, method), each naming its person and report; parameter is the canonical analyte id from the app's parameter list, empty for a name not yet known; canonical_value is the value in canonical_unit. health_person says, per person whose records are kept, whether they are the owner, their sex and date of birth as reports printed them, and the names reports print for them. To list parameters a person has, read lab_result for that person and group by parameter (or name when empty); to read a parameter's history, read lab_result where parameter is its id, by day; to read a report, read its lab_report row and the lab_result rows naming it in report, ordered by position. Labs, Reports and People are those three views. A report is a record, not advice: say values, units and intervals as the lab printed them, never a diagnosis or a treatment, and never mix one person's results into another's. APPLE HEALTH is the owner's alone, read from their iPhone and never written back: health_day is one row per measure per day; health_workout holds workouts; health_measurement holds weighings, blood pressures, glucose and temperatures. Today holds today's measures, Trends the last thirty days, Workouts every workout, Sleep each night by stage, Body every measurement, and Devices the vault's devices, where this phone lets another of the owner's devices open the sealed rows. Every row is sealed on the object, where only its day is clear: views order by the day there and by their measure or time on the phone, and Sleep is narrowed to the night's stages on the phone alone, so on the object read health_day by day. Reading a row asks the owner's phone for a window. An assistant never writes a health row; it reads them when asked and says the numbers in their own units.",  "automations": [],  "author": {    "device": "cotton",    "name": "Cotton"  },  "signature": null}