Arbeidspuls/src/types.ts
2026-05-29 02:22:57 +02:00

224 lines
5.1 KiB
TypeScript

export type ScaleValue = 1 | 2 | 3 | 4 | 5;
export type ReportStatus =
| "kan_fortsette"
| "trenger_pause"
| "trenger_enklere_oppgave"
| "bør_stoppe"
| "onsker_a_stoppe"
| "ønsker_å_stoppe";
export type TaskType =
| "sitting"
| "standing"
| "walking"
| "lifting"
| "computer_work"
| "concentration"
| "multitasking"
| "talking_social"
| "noise"
| "bright_light"
| "time_pressure";
export type Limitation =
| "fatigue"
| "brain_fog"
| "pain"
| "headache_migraine"
| "dizziness"
| "nausea"
| "sensory_overload"
| "stress_anxiety"
| "weakness"
| "sleepiness"
| "other";
export type Accommodation =
| "extra_breaks"
| "sitting_down"
| "quiet_room"
| "reduced_pace"
| "shorter_task"
| "help_from_others"
| "remote_work"
| "task_switching"
| "nothing_helped";
export type TaskCompletion =
| "nesten_ingenting"
| "litt"
| "delvis"
| "som_forventet"
| "mer_enn_forventet";
export type WorseThanBefore = "nei" | "litt" | "moderat" | "mye";
export type DelayedSymptom =
| "fatigue"
| "pain"
| "brain_fog"
| "flu_like"
| "headache"
| "dizziness"
| "sleep_disruption"
| "sensory_sensitivity";
export type RecoveryStatus =
| "tilbake_til_baseline"
| "samme_dag"
| "en_dag"
| "to_tre_dager"
| "fire_pluss_dager"
| "ikke_tilbake_til_baseline";
export interface Report {
id: string;
report_time: string;
report_date: string;
created_at: string;
updated_at?: string;
type: "work_report";
workplace?: string;
work_start_time?: string;
work_end_time?: string;
work_ability: ScaleValue;
energy_level: ScaleValue;
mental_clarity: ScaleValue;
symptom_burden: ScaleValue;
effort_strain: ScaleValue;
status: ReportStatus;
physical_energy: ScaleValue;
mental_energy: ScaleValue;
physical_energy_detail?: ScaleValue;
mental_energy_detail?: ScaleValue;
perceived_productivity?: ScaleValue;
task_completion?: TaskCompletion;
task_types: TaskType[];
main_limitations: Limitation[];
helpful_accommodations: Accommodation[];
total_score_percent?: number;
integrity?: ReportIntegrity;
note?: string;
demo?: boolean;
}
export interface ReportDraft {
workplace?: string;
work_start_time?: string;
work_end_time?: string;
work_ability?: ScaleValue;
energy_level?: ScaleValue;
mental_clarity?: ScaleValue;
symptom_burden?: ScaleValue;
effort_strain?: ScaleValue;
status?: ReportStatus;
physical_energy_detail?: ScaleValue;
mental_energy_detail?: ScaleValue;
perceived_productivity?: ScaleValue;
task_completion?: TaskCompletion;
task_types: TaskType[];
main_limitations: Limitation[];
helpful_accommodations: Accommodation[];
note: string;
}
export interface DelayedFollowup {
id: string;
report_time: string;
report_date: string;
created_at: string;
updated_at?: string;
type: "delayed_followup";
parent_report_id?: string;
related_report_id?: string;
worse_than_before: WorseThanBefore;
delayed_symptoms: DelayedSymptom[];
recovery_status?: RecoveryStatus;
integrity?: ReportIntegrity;
note?: string;
demo?: boolean;
}
export interface FollowupDraft {
parent_report_id?: string;
related_report_id?: string;
worse_than_before?: WorseThanBefore;
delayed_symptoms: DelayedSymptom[];
recovery_status?: RecoveryStatus;
note: string;
}
export type StoredEntry = Report | DelayedFollowup;
export interface EvaluatorNote {
id: string;
created_at: string;
updated_at: string;
text: string;
note_type?: "person" | "report" | "followup";
related_report_id?: string;
related_followup_id?: string;
parent_report_id?: string;
}
export interface EvaluatorProfile {
id: string;
display_name: string;
created_at: string;
updated_at: string;
source_fingerprint?: string;
contains_demo_data?: boolean;
reports: StoredEntry[];
evaluator_notes: EvaluatorNote[];
}
export interface ExportPayload {
schema_version: number;
export_version: number;
exported_at: string;
data_mode?: "normal" | "demo";
contains_demo_data?: boolean;
export_integrity?: ExportIntegrity;
reports: StoredEntry[];
}
export interface ImportSummary {
reports_added: number;
followups_added: number;
duplicates_skipped: number;
conflicts_detected: number;
demo_entries_detected?: number;
verification?: VerificationSummary;
}
export type ImportTargetResolution = "created_new_person" | "matched_existing_person" | "conflict_requires_manual_resolution";
export type VerificationStatus = "valid" | "modified" | "missing" | "unsupported" | "error";
export interface ReportIntegrity {
report_id: string;
canonicalization: "stable-json-v1" | "stable-json-v2";
algorithm: "sha256" | "local-fnv1a-64" | "SHA-256";
payload_hash_sha256: string;
signed_at: string;
verification_status?: VerificationStatus;
verification_reason?: string;
}
export interface ExportIntegrity {
schema: "arbeidsevne-export-integrity-v1";
created_at: string;
algorithm: string;
manifest_hash_sha256: string;
note: string;
}
export interface VerificationSummary {
valid: number;
modified: number;
missing: number;
unsupported: number;
error: number;
}