{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Event History","llmstxt":{"hide":true}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"event-history","__idx":0},"children":["Event History"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This is a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["proposed"]}," change. It has not been implemented yet."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"proposal","__idx":1},"children":["Proposal"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://jsonpatch.com/"},"children":["JSON Patch"]}," to keep event history"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["It can be applied to any of Tidepool's data base data models"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["It's up to the server to reject invalid event patch requests"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["TBD:"]}," Since we want event history to be immutable, we are adding the event history to the original event. Since we are not actually \"changing\" the original event, but providing a change history, we may not want to use the HTTP ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATCH"]}," verb. We may want to make a new endpoint that \"adds\" history to an existing data event."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here is an example of a carb event that was initially a carb entry of 40g, that was changed to 60g 15 minutes later:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Sample Modified Quantity","header":{"title":"Sample Modified Quantity","controls":{"copy":{}}},"source":"{\n  \"id\": \"77d722a44fa0055b20c9b988c078766f\",\n  \"name\": \"🍞🧀\",\n  \"nutrition\": {\n    \"carbohydrate\": {\n      \"net\": 40,\n      \"units\": \"grams\",\n      \"absorptionTime\": 10870000\n    }\n  },\n  \"history\": [\n    {\n      \"time\": \"2019-08-13T10:05:19.162Z\",\n      \"changes\": [\n        {\n          \"op\": \"replace\",\n          \"path\": \"/nutrition/carbohydrate/net\",\n          \"value\": 60\n        }\n      ]\n    }\n  ],\n  \"time\": \"2019-08-13T09:50:16.751Z\",\n  \"type\": \"food\",\n  \"uploadId\": \"f7825b06f189edf3ef5afc64f07930e1\",\n  \"deviceTime\": \"2019-08-13T09:50:16.751Z\",\n  \"displayOffset\": 600\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here is an example of a carbohydrate event that was deleted 4 minutes after initial entry:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Sample Deleted Event","header":{"title":"Sample Deleted Event","controls":{"copy":{}}},"source":"{\n  \"id\": \"77d722a44fa0055b20c9b988c078766f\",\n  \"name\": \"🍞🧀\",\n  \"nutrition\": {\n    \"carbohydrate\": {\n      \"net\": 40,\n      \"units\": \"grams\",\n      \"absorptionTime\": 10870000\n    }\n  },\n  \"history\": [\n    {\n      \"time\": \"2019-08-13T09:54:37.176Z\",\n      \"changes\": [\n        {\n          \"op\": \"delete\",\n          \"path\": \"\"\n        }\n      ]\n    }\n  ],\n  \"time\": \"2019-08-13T09:50:16.751Z\",\n  \"type\": \"food\",\n  \"uploadId\": \"f7825b06f189edf3ef5afc64f07930e1\",\n  \"deviceTime\": \"2019-08-13T09:50:16.751Z\",\n  \"displayOffset\": 600\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here is an example of a carb event that was initially a carb entry of 40g, that was changed to occur at an earlier time 5 minutes after originally being entered:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Sample Modified Time","header":{"title":"Sample Modified Time","controls":{"copy":{}}},"source":"{\n  \"id\": \"77d722a44fa0055b20c9b988c078766f\",\n  \"name\": \"🍞🧀\",\n  \"nutrition\": {\n    \"carbohydrate\": {\n      \"net\": 40,\n      \"units\": \"grams\",\n      \"absorptionTime\": 10870000\n    }\n  },\n  \"history\": [\n    {\n      \"time\": \"2019-08-13T09:55:19.162Z\",\n      \"changes\": [\n        {\n          \"op\": \"replace\",\n          \"path\": \"/time\",\n          \"value\": \"2019-08-13T09:20:32.159Z\"\n        },\n        {\n          \"op\": \"replace\",\n          \"path\": \"/deviceTime\",\n          \"value\": \"2019-08-13T09:20:32.159Z\"\n        }\n      ]\n    }\n  ],\n  \"time\": \"2019-08-13T09:50:16.751Z\",\n  \"type\": \"food\",\n  \"uploadId\": \"f7825b06f189edf3ef5afc64f07930e1\",\n  \"deviceTime\": \"2019-08-13T09:50:16.751Z\",\n  \"displayOffset\": 600\n}\n","lang":"json"},"children":[]}]},"headings":[{"value":"Event History","id":"event-history","depth":1},{"value":"Proposal","id":"proposal","depth":2}],"frontmatter":{"seo":{"title":"Event History"}},"lastModified":"2025-05-12T12:34:17.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/device-data/event-history","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}