Treatments
Treatments group medications into time-bound blocks per patient. They are used for medication analytics (TIR before/during/after) and for the patient timeline.
Data model
{ "id": "uuid", "patientId": "uuid", "startDate": "2024-01-01", "endDate": null, "medications": [ { "name": "Metformin", "activePrinciples": [{ "name": "Metformin", "dose": "500", "unit": "mg" }], "intakes": [{ "type": "meal", "meal": "breakfast", "amount": "1" }] } ]}endDate: null means the treatment is currently active. Stored via patientTreatment + patientMedication tables and synced with syncPatientTreatments(patientId, treatments) on PUT /api/v1/patients/:id.
UI
- PatientModal → TreatmentModal (
TreatmentModal.vue) — start/end dates (end is hidden behind aCheckboxCard“Definir fecha de fin” that reveals a new-lineFormField), and a list ofMedicationEntrywith intakes. - Medication analytics (
ViewMedicationAnalytics.vue) shows empty state with aPillicon and a button that opensTreatmentModalwhen a patient has no treatments.
API
Session routes below require a dashboard login. With an API key use
GET /api/v1/public/patients/:patientId/treatmentsinstead (readscope) — see the API reference.
GET /api/v1/patients/:idincludestreatments[]sorted newest first.PUT /api/v1/patients/:id { treatments: [...] }replaces the whole list (delete + insert).