feat(dashboard, api): integrate BMI thresholds and enhance dashboard with health metrics

This commit is contained in:
Danel Kungla
2025-08-21 22:09:17 +03:00
parent b1b0846234
commit 1fb8df7c89
9 changed files with 269 additions and 101 deletions

View File

@@ -242,6 +242,23 @@ class AccountsApi {
return (count ?? 0) > 0;
}
async fetchBmiThresholds() {
// Fetch BMI
const { data, error } = await this.client
.schema('medreport')
.from('bmi_thresholds')
.select(
'age_min,age_max,underweight_max,normal_min,normal_max,overweight_min,strong_min,obesity_min',
)
.order('age_min', { ascending: true });
if (error) {
console.error('Error fetching BMI thresholds:', error);
throw error;
}
return data;
}
}
export function createAccountsApi(client: SupabaseClient<Database>) {

View File

@@ -14,4 +14,4 @@ export enum ApplicationRoleEnum {
User = 'user',
Doctor = 'doctor',
SuperAdmin = 'super_admin',
}
}

View File

@@ -690,6 +690,42 @@ export type Database = {
},
]
}
bmi_thresholds: {
Row: {
age_max: number | null
age_min: number
id: number
normal_max: number
normal_min: number
obesity_min: number
overweight_min: number
strong_min: number
underweight_max: number
}
Insert: {
age_max?: number | null
age_min: number
id?: number
normal_max: number
normal_min: number
obesity_min: number
overweight_min: number
strong_min: number
underweight_max: number
}
Update: {
age_max?: number | null
age_min?: number
id?: number
normal_max?: number
normal_min?: number
obesity_min?: number
overweight_min?: number
strong_min?: number
underweight_max?: number
}
Relationships: []
}
codes: {
Row: {
analysis_element_id: number | null
@@ -1807,6 +1843,7 @@ export type Database = {
primary_owner_user_id: string
subscription_status: Database["medreport"]["Enums"]["subscription_status"]
permissions: Database["medreport"]["Enums"]["app_permissions"][]
account_role: string
application_role: Database["medreport"]["Enums"]["application_role"]
}[]
}