mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
feat(insights): make each person-defined symptom its own correlation channel
Every active symptom definition enters pattern discovery as an outcome channel SYMPTOM:<id>, labelled with its decrypted name (the data label the interpretation already prefers over the key). The daily value is the day's highest intensity in the person's zone; days without an occurrence count as 0 only between the first and the last logged day. At most eight, the active-definition cap. The SYMPTOM: prefix resolves to the illness module in the surface map, so the family leaves the matrix with the module, and the discovery guard lists the new fetcher.
This commit is contained in:
1 parent
d6571c4e9c
commit
9d9e1f153c
15 files changed
+799
-4
No files matched your search
@@ -66,9 +66,11 @@ import {
|
||||
TYPE_TO_SUB_PAGE_SLUG,
|
||||
} from "@/lib/insights/sub-page-metric";
|
||||
import { TREND_CHART_CONFIG } from "@/lib/insights/trend-chart-select";
|
||||
import { SYMPTOM_CHANNEL_PREFIX } from "@/lib/symptoms/shared";
|
||||
import {
|
||||
SURFACE_KINDS,
|
||||
SURFACE_MODULE,
|
||||
correlationChannelSurfaceId,
|
||||
surfaceModule,
|
||||
surfaceModulesOfKind,
|
||||
type SurfaceKind,
|
||||
@@ -167,6 +169,11 @@ describe("every surface id names a surface that exists", () => {
|
||||
// `correlationChannelSurfaceId` folds rated factors onto mood by this
|
||||
// prefix; it has to be the prefix the engine actually writes.
|
||||
expect(FACTOR_CHANNEL_PREFIX).toBe("FACTOR:");
|
||||
// Person-defined symptoms fold onto the illness symptom channel by theirs.
|
||||
expect(SYMPTOM_CHANNEL_PREFIX).toBe("SYMPTOM:");
|
||||
expect(correlationChannelSurfaceId(`${SYMPTOM_CHANNEL_PREFIX}abc`)).toBe(
|
||||
"correlation:SYMPTOM_SEVERITY",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -274,10 +274,13 @@ export function surfaceModulesOfKind(
|
||||
/**
|
||||
* The surface id of a correlation channel. Rated mood factors carry their own
|
||||
* `FACTOR:<key>` channel names but are mood entries all the same, so they
|
||||
* resolve to the mood channel.
|
||||
* resolve to the mood channel; person-defined symptoms (`SYMPTOM:<id>`) resolve
|
||||
* to the illness symptom channel the same way.
|
||||
*/
|
||||
export function correlationChannelSurfaceId(channelKey: string): string {
|
||||
return channelKey.startsWith("FACTOR:")
|
||||
? "correlation:MOOD"
|
||||
: `correlation:${channelKey}`;
|
||||
if (channelKey.startsWith("FACTOR:")) return "correlation:MOOD";
|
||||
// A person-defined symptom (`SYMPTOM:<id>`, v1.40) rides the illness
|
||||
// module, like the symptom-burden channel it sits beside.
|
||||
if (channelKey.startsWith("SYMPTOM:")) return "correlation:SYMPTOM_SEVERITY";
|
||||
return `correlation:${channelKey}`;
|
||||
}
|
||||
Reference in new issue
Block a user