Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/KevxxAlva/femesalud-zen-flow/llms.txt

Use this file to discover all available pages before exploring further.

The Patients module is the central repository for every person treated at the clinic. Beyond basic demographics, each patient record holds a structured gynecological profile, obstetric history, family and personal antecedents, and the full chain of consultations. The registry is searchable, filterable, and paginated to remain performant regardless of clinic size.

Patient Status Values

Every patient is assigned one of four lifecycle statuses that appear as colour-coded badges throughout the platform:

nuevo

Recently registered patient who has not yet had a completed visit. Default status on creation. Displayed in pink (blush).

activo

Patient with at least one completed visit and no ongoing treatment protocol. Displayed in green (sage).

en_tratamiento

Patient currently under an active treatment plan (e.g., prenatal control, post-procedure follow-up). Displayed in purple (mauve).

alta

Discharged patient — treatment concluded and no follow-up required. Displayed in muted grey. The record is retained in full.

Patient Profile Fields

The Patient interface maps directly to the patients table in Supabase:
export interface Patient {
  id: string;
  full_name: string;
  email: string | null;
  phone: string | null;
  birth_date: string | null;
  address: string | null;
  status: string;               // 'nuevo' | 'activo' | 'en_tratamiento' | 'alta'
  assigned_doctor_id: string | null;
  notes: string | null;
  created_at: string;
  updated_at: string;
  document_id: string | null;   // cédula or passport number
  historia_number: string | null;
  first_visit_date: string | null;
  marital_status: string | null;
  birthplace: string | null;
  education_level: string | null;
  occupation: string | null;
  ethnicity: string | null;
  consultation_reason: string | null;
  current_illness: string | null;
  family_history: { ... } | null;
  personal_history: { ... } | null;
  gynecological_data: { ... } | null;
  obstetric_data: { ... } | null;
}
Always set assigned_doctor_id when creating a patient. It controls which doctor appears on all exported PDF documents (Ficha Médica, Reposo, Constancia, Justificativo) and determines which patients a non-admin doctor can view in their personal dashboard.

Family History (family_history)

Stored as a JSON object with the following structure:
FieldDescription
motherHereditary or chronic conditions on the maternal side.
fatherHereditary or chronic conditions on the paternal side.
siblingsRelevant conditions among siblings.
childrenRelevant conditions among the patient’s children.
Default display value when empty: “Niega / Sano”.

Personal History (personal_history)

FieldDescription
alcoholAlcohol consumption pattern.
drugsDrug use history.
tobaccoSmoking history.
base_pathologyChronic baseline pathologies (e.g., hypertension, diabetes).
surgicalPrevious surgical procedures.
allergiesKnown allergies — displayed in red on the Clinical Records screen as a safety highlight.

Gynecological Data (gynecological_data)

FieldDescription
menarcheAge of first menstruation (years).
sexarcheAge of first sexual intercourse (years).
menstrual_cycleCycle description (e.g., “28/5 días regular”).
dysmenorrheaPainful menstruation: absent, mild, moderate, or severe.
npsNumber of sexual partners.
itsHistory of sexually transmitted infections.
cytologyDate or result of the most recent Pap smear.
contraceptivesCurrent or previous contraceptive method.

Obstetric Data (obstetric_data)

FieldAbbreviationDescription
gGTotal gestations (pregnancies).
pPVaginal deliveries (partos).
cCCaesarean sections.
aAAbortions / pregnancy losses.
pigPIGIntergenesic period — time between last delivery and current pregnancy.
fumFUMDate of last menstrual period (fecha última menstruación).
egEGCurrent gestational age.
fppFPPEstimated due date (fecha probable de parto).
emEMMolar pregnancies (embarazo molar).
eeEEEctopic pregnancies (embarazo ectópico).
vaccinesVaccination history during pregnancy.
complicationsObstetric complications.
num_consultationsNumber of prenatal check-ups completed.

Duplicate Prevention

The system enforces uniqueness on two fields before inserting or updating a patient:
  • document_id (cédula/pasaporte): an exact match query runs against the patients table. If a record with the same document_id already exists (different id), the mutation throws: “Ya existe un paciente con este mismo número de cédula/pasaporte.”
  • full_name (case-insensitive): an ilike query checks for an identical name. If a match is found, the mutation throws: “Ya existe un paciente registrado con este mismo nombre completo.”
Both checks run client-side before the INSERT / UPDATE is sent to Supabase, providing immediate user feedback via a toast error. Patient lists throughout the app use usePaginatedPatients, which accepts:
ParameterDefaultDescription
page1Current page number.
pageSize10Records per page (15 in the full Patients list).
searchundefinedFilters by full_name, email, or document_id using ilike.
statusundefinedExact match on status column.
The search input uses a 350 ms debounce before triggering the query. Changing the search or status filter resets the page to 1 automatically. The Patients page also provides an Exportar Excel button that downloads the current filtered result set as an .xlsx file using the xlsx library.

Document Exports

From the patient detail panel, four PDF documents can be generated:

Ficha Médica

Full patient profile including demographics, gynecological data, obstetric history, and all clinical notes. Exported via exportFichaMedica.

Historia Clínica Completa

Complete clinical record including all consultations and their details. Exported via exportFullHistory from the Clinical Records module.

Constancia de Reposo

Medical rest certificate specifying the number of days, start date, and reason. Exported via exportReposo.

Justificativo

Medical justification letter (e.g., work or school absence). Exported via exportJustificativo.
For more details on PDF generation, see PDF Exports.

Build docs developers (and LLMs) love