Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / health / AGENTS.md
| 1 | # AGENTS.md — health/ (':health') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `health/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install health (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :health / dir: health/ |
| 8 | - Package roots present: ui, data, domain, platform, service, notifications |
| 9 | - Entry files: MainActivity.kt (no Route.kt — Today-dashboard + record pages flow) |
| 10 | - Deps: :library:room |
| 11 | - Metadata: metadata_data/health.md (present) |
| 12 | - Rust: no / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** Offline health-metric manager (Google Fit replacement) — activity/vitals/body/exercise/sleep/hydration/nutrition plus FHIR medical records, backed by Health Connect. No account, no cloud sync. |
| 16 | **Key features:** |
| 17 | - Per-metric dashboards with charts/history (`GenericLineChart`/`GenericBarChart`, hypnogram for sleep) |
| 18 | - Medications with dose schedules + exact reminders (`DoseScheduler`, `DoseSoundService`, boot-rescheduled); vaccinations from bundled CVX, drugs from RxNorm; card attachments (PDF/photo) |
| 19 | - Food logging against a bundled database + search API; AI insights via the on-device OpenAssistant model; file export |
| 20 | **Architecture / data-flow:** `ui/` Today + record pages → `platform/MedicalViewModel` (+ per-area `Medical*Ops`) → `data/HealthRepository` over Room (`Record`, `MedicationSchedule`, `MedicalRecords`) synced with Health Connect; `domain/` holds pure FHIR (Observations, Medication, Immunization, Allergy/Condition) + `DoseSchedule`; reminders flow `DoseScheduler` → receivers → `DoseReminderActivity` + `service/DoseSoundService`. |
| 21 | **Entry points + reading order:** `MainActivity.kt` → `ui/TodayPage.kt` → `platform/MedicalViewModel.kt` → `data/HealthRepository.kt` → `domain/FhirRecords.kt` → `platform/DoseScheduler.kt`. |
| 22 | **Gotchas:** |
| 23 | - `util/` is NOT a closed package root — the `util/`→closed-roots migration is pending; don't add more files there |
| 24 | - Medical data is dual-homed (Room + Health Connect) — writes must update both or they diverge |
| 25 | - Dose reminders need the boot path re-armed like clock alarms; sound runs through a foreground service |
| 26 | |
| 27 | ## Key files |
| 28 | ### Root — entry (no Route.kt) |
| 29 | - com/vayunmathur/health/MainActivity.kt |
| 30 | ### data/ — Room entities + repository |
| 31 | - com/vayunmathur/health/data/HealthRepository.kt |
| 32 | - com/vayunmathur/health/data/Record.kt |
| 33 | - com/vayunmathur/health/data/MedicationSchedule.kt |
| 34 | - com/vayunmathur/health/data/MedicalRecords.kt |
| 35 | - com/vayunmathur/health/data/FoodModels.kt |
| 36 | - com/vayunmathur/health/data/ReferenceCatalog.kt |
| 37 | - com/vayunmathur/health/data/VaccineCatalog.kt |
| 38 | ### domain/ — pure FHIR + dose schedule (no Android) |
| 39 | - com/vayunmathur/health/domain/FhirRecords.kt |
| 40 | - com/vayunmathur/health/domain/FhirObservations.kt |
| 41 | - com/vayunmathur/health/domain/FhirMedication.kt |
| 42 | - com/vayunmathur/health/domain/FhirImmunization.kt |
| 43 | - com/vayunmathur/health/domain/FhirAllergyCondition.kt |
| 44 | - com/vayunmathur/health/domain/FhirJson.kt |
| 45 | - com/vayunmathur/health/domain/DoseSchedule.kt |
| 46 | - com/vayunmathur/health/domain/SocialHistoryQuestions.kt |
| 47 | ### platform/ — ViewModel, medical ops, reminders |
| 48 | - com/vayunmathur/health/platform/MedicalViewModel.kt |
| 49 | - com/vayunmathur/health/platform/MedicalClinicalOps.kt |
| 50 | - com/vayunmathur/health/platform/MedicalImportOps.kt |
| 51 | - com/vayunmathur/health/platform/MedicalMedicationOps.kt |
| 52 | - com/vayunmathur/health/platform/MedicalProfileOps.kt |
| 53 | - com/vayunmathur/health/platform/MedicalVaccinationOps.kt |
| 54 | - com/vayunmathur/health/platform/PersonalHealthRecords.kt |
| 55 | - com/vayunmathur/health/platform/AttachmentStore.kt |
| 56 | - com/vayunmathur/health/platform/DoseScheduler.kt |
| 57 | - com/vayunmathur/health/platform/DoseReceiver.kt |
| 58 | - com/vayunmathur/health/platform/DoseActionReceiver.kt |
| 59 | - com/vayunmathur/health/platform/DoseReminderActivity.kt |
| 60 | - com/vayunmathur/health/platform/HealthBootReceiver.kt |
| 61 | ### notifications/ + service/ — channels and dose sound |
| 62 | - com/vayunmathur/health/notifications/DoseNotification.kt |
| 63 | - com/vayunmathur/health/notifications/MedicationChannels.kt |
| 64 | - com/vayunmathur/health/service/DoseSoundService.kt |
| 65 | ### util/ — food DB, sync worker, ViewModel (pending migration to closed roots) |
| 66 | - com/vayunmathur/health/util/HealthViewModel.kt |
| 67 | - com/vayunmathur/health/util/HealthUiContract.kt |
| 68 | - com/vayunmathur/health/util/HealthSyncWorker.kt |
| 69 | - com/vayunmathur/health/util/HealthAPI.kt |
| 70 | - com/vayunmathur/health/util/FoodDatabase.kt |
| 71 | - com/vayunmathur/health/util/FoodSearchAPI.kt |
| 72 | - com/vayunmathur/health/util/Utils.kt |
| 73 | ### ui/ + ui/components/ — Today, records, charts, logging |
| 74 | - com/vayunmathur/health/ui/TodayPage.kt |
| 75 | - com/vayunmathur/health/ui/TodayHero.kt |
| 76 | - com/vayunmathur/health/ui/RecordsPage.kt |
| 77 | - com/vayunmathur/health/ui/BodyPage.kt |
| 78 | - com/vayunmathur/health/ui/SleepDetailsPage.kt |
| 79 | - com/vayunmathur/health/ui/ExerciseDetailsPage.kt |
| 80 | - com/vayunmathur/health/ui/NutritionPage.kt |
| 81 | - com/vayunmathur/health/ui/NutritionDetailsPage.kt |
| 82 | - com/vayunmathur/health/ui/FoodLoggingDialogs.kt |
| 83 | - com/vayunmathur/health/ui/FoodDatabaseCard.kt |
| 84 | - com/vayunmathur/health/ui/IngredientSearchDialog.kt |
| 85 | - com/vayunmathur/health/ui/IngredientQuantityDialog.kt |
| 86 | - com/vayunmathur/health/ui/RecipeEditorPage.kt |
| 87 | - com/vayunmathur/health/ui/RecipeManagementPage.kt |
| 88 | - com/vayunmathur/health/ui/MedicationPage.kt |
| 89 | - com/vayunmathur/health/ui/DoseReminderScreen.kt |
| 90 | - com/vayunmathur/health/ui/VaccinationsPage.kt |
| 91 | - com/vayunmathur/health/ui/AllergiesPage.kt |
| 92 | - com/vayunmathur/health/ui/AddAllergyPage.kt |
| 93 | - com/vayunmathur/health/ui/ConditionsPage.kt |
| 94 | - com/vayunmathur/health/ui/AddConditionPage.kt |
| 95 | - com/vayunmathur/health/ui/AddLabResultPage.kt |
| 96 | - com/vayunmathur/health/ui/LabResultsPage.kt |
| 97 | - com/vayunmathur/health/ui/AddMedicationPage.kt |
| 98 | - com/vayunmathur/health/ui/AddVaccinationPage.kt |
| 99 | - com/vayunmathur/health/ui/AboutYouPage.kt |
| 100 | - com/vayunmathur/health/ui/CatalogPickerPage.kt |
| 101 | - com/vayunmathur/health/ui/BodyLoggingDialog.kt |
| 102 | - com/vayunmathur/health/ui/GenericLineChart.kt |
| 103 | - com/vayunmathur/health/ui/GenericBarChart.kt |
| 104 | - com/vayunmathur/health/ui/BarChartDetails.kt |
| 105 | - com/vayunmathur/health/ui/BarChartDetailsScreen.kt |
| 106 | - com/vayunmathur/health/ui/ChartAxes.kt |
| 107 | - com/vayunmathur/health/ui/MetricChartHeader.kt |
| 108 | - com/vayunmathur/health/ui/MetricDashboardData.kt |
| 109 | - com/vayunmathur/health/ui/HealthColors.kt |
| 110 | - com/vayunmathur/health/ui/HealthFormat.kt |
| 111 | - com/vayunmathur/health/ui/HealthMetricConfig.kt |
| 112 | - com/vayunmathur/health/ui/PermissionsRationaleActivity.kt |
| 113 | - com/vayunmathur/health/ui/components/HealthComponents.kt |
| 114 | - com/vayunmathur/health/ui/components/HealthHypnogram.kt |
| 115 | - com/vayunmathur/health/ui/components/AttachmentChip.kt |
| 116 | - com/vayunmathur/health/ui/components/MedicalStorageNotice.kt |
| 117 | - com/vayunmathur/health/ui/components/PickerField.kt |
| 118 | - com/vayunmathur/health/ui/components/ScheduleSection.kt |
| 119 | - com/vayunmathur/health/ui/components/SectionLabel.kt |
| 120 | - com/vayunmathur/health/ui/components/AnswerPickerDialog.kt |
| 121 | |
| 122 | ## Verify (this module only) |
| 123 | ``` |
| 124 | ./gradlew :health:compileDevKotlin |
| 125 | ./gradlew :health:lint |
| 126 | ./gradlew :health:checkMetadata |
| 127 | ``` |