Modern Apps git

← Modern-Apps.git

health: remove patients page

Commit
fb2c6177599ceb34f8e3e8490256503b06adaa1c
Author
Vayun Mathur <[email protected]>
When
2026-05-03 21:36 UTC (7 months ago)
Parents
ec02eb5

Diff

health/src/main/java/com/vayunmathur/health/MainActivity.kt
diff --git a/health/src/main/java/com/vayunmathur/health/MainActivity.kt b/health/src/main/java/com/vayunmathur/health/MainActivity.ktindex a63a1ecbef..a896f04377 100644--- a/health/src/main/java/com/vayunmathur/health/MainActivity.kt+++ b/health/src/main/java/com/vayunmathur/health/MainActivity.kt@@ -58,7 +58,6 @@ import com.vayunmathur.health.ui.HealthMetricConfig import com.vayunmathur.health.ui.MainPage import com.vayunmathur.health.ui.ImmunizationsPage import com.vayunmathur.health.ui.LabResultsPage-import com.vayunmathur.health.ui.PatientsPage import com.vayunmathur.health.ui.NutritionDetailsPage import com.vayunmathur.health.util.HealthAPI import com.vayunmathur.health.util.HealthSyncWorker@@ -151,9 +150,6 @@ sealed interface Route: NavKey {     @Serializable     data object MainPage: Route -    @Serializable-    data object Patients: Route-     @Serializable     data object Immunizations: Route @@ -174,9 +170,6 @@ fun Navigation() {         entry<Route.MainPage> {             MainPage(backStack)         }-        entry<Route.Patients> {-            PatientsPage(backStack)-        }         entry<Route.Immunizations> {             ImmunizationsPage(backStack)         }
health/src/main/java/com/vayunmathur/health/ui/MainPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/MainPage.kt b/health/src/main/java/com/vayunmathur/health/ui/MainPage.ktindex c85eff3cb7..36b403eae3 100644--- a/health/src/main/java/com/vayunmathur/health/ui/MainPage.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/MainPage.kt@@ -162,25 +162,6 @@ fun MainPage(backStack: NavBackStack<Route>) {         ) {             Spacer(modifier = Modifier.height(8.dp)) -            Text(stringResource(R.string.section_medical_records), style = MaterialTheme.typography.labelLarge)-            Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {-                Box(Modifier.weight(1f)) {-                    MiniMetricCard(stringResource(R.string.label_patients), "", "", onClick = {-                        backStack.add(Route.Patients)-                    })-                }-                Box(Modifier.weight(1f)) {-                    MiniMetricCard(stringResource(R.string.label_immunizations), "", "", onClick = {-                        backStack.add(Route.Immunizations)-                    })-                }-                Box(Modifier.weight(1f)) {-                    MiniMetricCard(stringResource(R.string.label_lab_results), "", "", onClick = {-                        backStack.add(Route.LabResults)-                    })-                }-            }-             // 4. Activity & Energy             Text(stringResource(R.string.section_activity), style = MaterialTheme.typography.labelLarge)             EnergyBurned(backStack, totalCaloriesBurnedToday)@@ -225,13 +206,29 @@ fun MainPage(backStack: NavBackStack<Route>) {             Text(stringResource(R.string.section_nutrition_today), style = MaterialTheme.typography.labelLarge)             // TODO: add this back             //NutritionSummaryCard(aggregates)-            Nutrition(backStack, nutritionCaloriesToday)-            Hydration(backStack, hydrationToday)+            Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                Box(Modifier.weight(1f)) { Nutrition(backStack, nutritionCaloriesToday) }+                Box(Modifier.weight(1f)) { Hydration(backStack, hydrationToday) }+            }              // 3. Body Composition             Text(stringResource(R.string.section_body_composition), style = MaterialTheme.typography.labelLarge)             BodyCompositionDashboard(backStack, height, weight, bodyFat, leanBodyMass, boneMass, bodyWaterMass) +            Text(stringResource(R.string.section_medical_records), style = MaterialTheme.typography.labelLarge)+            Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                Box(Modifier.weight(1f)) {+                    MiniMetricCard(stringResource(R.string.label_immunizations), "", "", onClick = {+                        backStack.add(Route.Immunizations)+                    })+                }+                Box(Modifier.weight(1f)) {+                    MiniMetricCard(stringResource(R.string.label_lab_results), "", "", onClick = {+                        backStack.add(Route.LabResults)+                    })+                }+            }+             Spacer(modifier = Modifier.height(24.dp))         }     }
health/src/main/java/com/vayunmathur/health/ui/PatientsPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/PatientsPage.kt b/health/src/main/java/com/vayunmathur/health/ui/PatientsPage.ktdeleted file mode 100644index f8e0fdfc95..0000000000--- a/health/src/main/java/com/vayunmathur/health/ui/PatientsPage.kt+++ /dev/null@@ -1,92 +0,0 @@-package com.vayunmathur.health.ui--import androidx.compose.foundation.layout.*-import androidx.compose.material3.*-import androidx.compose.runtime.*-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.res.painterResource-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.unit.dp-import androidx.health.connect.client.feature.ExperimentalPersonalHealthRecordApi-import androidx.health.connect.client.records.MedicalResource-import com.google.fhir.model.r4b.Patient-import com.vayunmathur.health.R-import com.vayunmathur.health.Route-import com.vayunmathur.health.util.HealthAPI-import com.vayunmathur.library.ui.IconNavigation-import com.vayunmathur.library.util.NavBackStack-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.launch-import kotlinx.coroutines.withContext--@OptIn(ExperimentalMaterial3Api::class, ExperimentalPersonalHealthRecordApi::class)-@Composable-fun PatientsPage(backStack: NavBackStack<Route>) {-    val scope = rememberCoroutineScope()-    var patients by remember { mutableStateOf(listOf<Patient>()) }--    fun refresh() {-        scope.launch {-            withContext(Dispatchers.IO) {-                patients = HealthAPI.allMedicalRecords(MedicalResource.MEDICAL_RESOURCE_TYPE_PERSONAL_DETAILS).map {-                    JSON.decodeFromString<Patient>(it.fhirResource.data)-                }-            }-        }-    }--    LaunchedEffect(Unit) {-        refresh()-    }--    Scaffold(-        topBar = {-            TopAppBar(-                title = { Text(stringResource(R.string.label_patients)) },-                navigationIcon = {-                    IconNavigation(backStack)-                }-            )-        }-    ) { paddingValues ->-        Column(Modifier.padding(paddingValues).padding(horizontal = 16.dp)) {-            Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {-                patients.forEach {-                    PatientCard(it)-                }-            }-        }-    }-}--@Composable-fun PatientCard(patient: Patient) {-    val nameString = patient.name.firstOrNull()?.text?.value-    val addressString = patient.address.firstOrNull()?.text?.value-    Card(Modifier.fillMaxWidth()) {-        Row(-            modifier = Modifier.padding(16.dp),-            verticalAlignment = Alignment.CenterVertically-        ) {-            Icon(-                painterResource(R.drawable.baseline_favorite_24),-                contentDescription = null,-                modifier = Modifier.size(32.dp),-                tint = MaterialTheme.colorScheme.primary-            )-            Spacer(Modifier.width(16.dp))-            Column {-                Text(nameString ?: stringResource(R.string.unknown), style = MaterialTheme.typography.titleLarge)-                patient.gender?.value?.getDisplay()?.let {-                    Text(it, style = MaterialTheme.typography.bodyMedium)-                }-                patient.birthDate?.value?.toString()?.let {-                    Text(it, style = MaterialTheme.typography.bodyMedium)-                }-                if (addressString != null)-                    Text(addressString, style = MaterialTheme.typography.bodyMedium)-            }-        }-    }-}