FemeSalud can produce eight distinct A4 PDF documents — from a full clinical history to a monthly billing report — all sharing a consistent branded layout. Every export function lazy-importsDocumentation 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.
jsPDF and jspdf-autotable at call time so neither library adds weight to the initial application bundle. Each document is rendered in the Times typeface, carries the clinic header and logo at the top of the first page, and closes every page with a centered logo watermark at 4 % opacity and a footer that includes the generation timestamp.
Common Header Structure
Every PDF opens with the same header block assembled from the clinic’s settings. If a particular field is not configured, a sensible default is used so documents are never blank.| Element | Position | Details |
|---|---|---|
| Logo | Top-left, 75 × 75 pt | Fetched as a base64 PNG via loadLogoBase64('/logo.png') |
| Address line 1 | Centered, top | clinic.address_line1 |
| Address line 2 | Centered, below address 1 | clinic.address_line2 |
| Phone / RIF | Centered | Teléfono: [phone] — RIF appended with | RIF: [rif] when set |
| Consultorio label | Centered | "Consultorio Ginecológico Obstétrico" |
| Clinic name | Centered, italic, 17.5 pt | clinic.name |
| Date | Right-aligned | DD / MM / AAAA format, printed on every first page |
| Watermark | Page center, all pages | Logo at 550 × 550 pt, 4 % opacity via GState |
| Footer | Bottom of every page | FemeSalud — Generado el [timestamp] · Página N de Total |
All PDF export functions are
async and dynamically import jsPDF (and jspdf-autotable where needed) using Promise.all([import('jspdf'), import('jspdf-autotable')]). This keeps both libraries out of the main bundle and loads them only when the user actually triggers a document export.Ficha Médica — Medical Card
exportFichaMedica generates a comprehensive one-stop medical card for a single patient, combining identification data, full antecedents, and a chronological note history into a single paginated PDF.
Parameters
Full
Patient object. All fields are rendered, including historia_number, document_id, birth_date, marital_status, family_history, personal_history, gynecological_data, and obstetric_data.Clinic configuration used to build the header. Falls back to hardcoded defaults when
null.Maps doctor UUIDs to display names. Used to resolve
patient.assigned_doctor_id into a readable name in the identification table.Array of clinical notes scoped to this patient. Rendered in a striped table with a purple header row (
#8B5CAF). An italicised placeholder is shown when the array is empty.Document Sections
Datos de Identificación y Consulta
A four-column grid table covering
historia_number, first_visit_date, full_name, document_id, birth_date, marital_status, birthplace, phone, education_level, occupation, ethnicity, email, address, assigned doctor, consultation reason, current illness, and general notes.Antecedentes Médicos
Family history (mother, father, siblings, children) and personal history (tobacco, alcohol, drugs, base pathology, surgical, allergies) in a four-column grid table.
Datos Gineco-Obstétricos
Menarche, sexarche, menstrual cycle, dysmenorrhea, NPS, ITS, last cytology, contraceptives, and the full obstetric formula (G / P / C / A / PIG / EM / EE / FUM / EG / FPP / vaccines / complications).
Ficha_[full_name].pdf (spaces replaced with underscores)
Historia Clínica Completa — Full Clinical History
exportFullHistory generates the complete clinical dossier for a patient, combining every consultation visit into a sequential, dated timeline document.
Parameters
Full patient record. Identification and antecedent sections mirror the Ficha Médica layout.
Array of
Consultation objects, each potentially including consumables. Rendered in reverse chronological order (newest first). An italicised placeholder appears when empty.Clinic configuration for the header block.
UUID-to-name map for the assigned doctor field.
Document Sections
1. Datos de Identificación
Same layout as the Ficha Médica identification table with
historia_number, full_name, document_id, birth_date, marital_status, birthplace, phone, education_level, occupation, ethnicity, email, address, assigned doctor, consultation reason, and current illness.2. Antecedentes Médicos y Gineco-Obstétricos
Combined section covering family history, personal history, and the full gynecological and obstetric dataset (menarche through complications).
3. Registro de Consultas y Evolución
For each visit, a branded purple heading (
#8B5CAF) shows the visit number (counting from total), date, and visit type. Below it, a four-column grid table captures: subjective exam + vitals (height, weight, BMI, BP, HR, temperature); physical exam (breasts, abdomen, gynecological) + colposcopy (acetic acid and Lugol tests with clock positions); obstetric control (gestational age, uterine height, presentation, FCF, fetal weight, movements, edema, alarm signs — only rendered when obstetric data is present); diagnosis + treatment plan; complementary exams + follow-up plan; and a full-width consumables row when v.consumables is non-empty.A new page is automatically added when the remaining vertical space falls below 120 pt.Historia_Clinica_[full_name].pdf
Constancia de Reposo — Rest Certificate
exportReposo produces a single-page formal rest certificate addressed “A quien pueda interesar” and signed by the treating physician.
Parameters
Patient whose name and cédula/document ID appear in the certificate body. The prefix (
C.I. V-, C.I. E-, Pasaporte) is inferred automatically from patient.document_id.Used to build the header.
Physician credential block rendered in the signature area.
name— full name, bold, centred above the signature linespecialty— medical specialtyuni— university abbreviation (optional)mpps— MPPS registration number (optional; defaults to underscores)cmc— CMC registration number (optional; defaults to underscores)
Diagnosis or medical reason. Text is split automatically across up to two underlined lines.
Number of rest days to appear in the body text.
Start date in
YYYY-MM-DD format. Displayed as DD / MM / YYYY in the body.Document Content
The certificate body certifies that the named patient was examined, states the diagnosis, specifies the number of rest days, and provides the start date. A dashed signature line is drawn aty = 590 pt followed by the doctor’s name, specialty, university, and MPPS / CMC registration numbers.
Filename: Reposo_[full_name].pdf
Recibo de Pago — Payment Receipt
exportInvoice produces a single-page payment receipt for an appointment, including service description, amount in USD, payment method, and doctor signature.
Parameters
The appointment record that drives the receipt. Key fields used:
id— first 8 characters (uppercased) form the receipt number:FS-[id_first8]scheduled_at— used as the emission datepatient_name— displayed in the patient data blockreason— service description in the line-item tableprice— shown as$X.XX USDpayment_method— shown when presentpayment_reference— reference number shown when present
Header configuration.
name and specialty rendered in the signature block at y = 520 pt.Document Content
The receipt opens with the standard clinic header, then shows the receipt number (FS- followed by the first 8 characters of the appointment ID uppercased) top-left and the emission date top-right. The patient data block lists the patient name, service concept, payment method, and reference number. A ruled table shows the service description and amount, followed by a bold total line. The physician signs at the bottom.
Filename: Recibo_[patient_name].pdf
Receta Médica — Prescription
generateRecipePDF (from src/lib/utils/recipePdf.ts) generates a recipe / indications document for a consultation. Clinic info is fetched directly from Supabase inside the function, so no clinic parameter is required. Doctor credentials are passed as parameters with a Supabase profile lookup as fallback.
Parameters
Minimal patient object:
id, full_name, document_id, birth_date, and optional phone.Must supply
created_at (used as the prescription date) and indications. The function exits early with a warning toast if indications is blank or missing.Physician’s full name for the signature block.
Optional. Falls back to a Supabase profile lookup by name match, then to
"Médico Especialista".Optional. Falls back to profile lookup.
Optional. Falls back to profile lookup.
Optional. Falls back to profile lookup.
"save" (default) downloads the PDF via doc.save(). "whatsapp" uploads the PDF blob to the clinical-attachments Supabase Storage bucket, generates a 7-day signed URL, and opens wa.me/[phone] with the link pre-filled. If the patient has no phone on record the link is copied to the clipboard instead.Document Content
The header follows the shared clinic layout (logo at 65 × 65 pt). Below the title RÉCIPE / INDICACIONES, the patient’s name, age (calculated frombirth_date), and cédula are displayed on underlined lines. The indications text is word-wrapped at 455 pt. If the text overflows past y = 660, a new page is added with a compact running header showing patient name and date. The doctor signature block is always placed at y = 700 pt on the last page.
Filename: Recipe_[clean_name]_[YYYYMMDD].pdf (accents stripped, non-alphanumeric characters replaced with underscores)
Constancia de Atención — Attendance Certificate
exportConstanciaAtencion (from src/lib/pdf/constancia-atencion.ts) certifies that a patient attended a medical appointment on a specific date.
Parameters
Patient’s
full_name and document_id appear in the certificate body. The cédula prefix is resolved automatically.Used to build the header.
Physician credential block rendered in the signature area.
name— full name, bold, centred above the signature linespecialty— medical specialtyuni— university abbreviation (optional)mpps— MPPS registration number (optional; defaults to underscores)cmc— CMC registration number (optional; defaults to underscores)
Medical condition or reason for the visit. Rendered on up to two underlined diagnosis lines.
Date of attendance in
YYYY-MM-DD format. Displayed as DD / MM / YYYY in the body sentence: “Acudió a consulta el día de hoy: (DD / MM / YYYY).”Document Content
Single-page document addressed “A quien pueda interesar”. Certifies examination, states the diagnosis, confirms the attendance date, and closes with “Constancia que se expide a petición de la persona interesada.” Doctor signature block aty = 530 pt.
Filename: Atencion_[full_name].pdf
Justificativo Médico — Medical Justification
exportJustificativo (from src/lib/pdf/justificativo.ts) generates an absence justification document that certifies the patient was seen and indicates the number of rest days prescribed.
Parameters
Patient name and document ID for the certificate body.
Used to build the header.
Physician credential block rendered in the signature area.
name— full name, bold, centred above the signature linespecialty— medical specialtyuni— university abbreviation (optional)mpps— MPPS registration number (optional; defaults to underscores)cmc— CMC registration number (optional; defaults to underscores)
Diagnosis or medical reason, split across up to two underlined lines.
Number of days of rest prescribed; embedded in the sentence “indicándole tratamiento y reposo de (N) días”.
Consultation date in
YYYY-MM-DD format. Displays as DD / MM / YYYY.Document Content
Single-page document. Body text certifies that the patient attended on the given date, that treatment and rest were prescribed for the stated number of days, and that their absence from daily activities is therefore justified. Doctor signature block aty = 570 pt with name, specialty, university, MPPS, and CMC.
Filename: Justificativo_[full_name].pdf
Reporte Mensual — Monthly Billing Report
exportMonthlyReport (from src/lib/pdf/reporte-mensual.ts) generates a paginated billing report for a selected month or the full dataset, with a financial summary and a colour-coded status table.
Parameters
All available month options used to resolve the selected month’s human-readable
label for the report title.The
key of the currently selected month (e.g. "2024-11"). When matched in monthOptions, the report title becomes "REPORTE DE FACTURACIÓN - [LABEL]" (the full string is uppercased).Header configuration.
Pre-filtered appointment array scoped to the selected period. The function calculates totals internally — no pre-aggregation required.
Document Content
After the clinic header, a Resumen Financiero block shows:- Total collected (
completada+ payment method set) in USD with appointment count - Total outstanding (
programadaorcompletadawithout payment method) in USD with count - Total records in the period
autoTable follows, listing: date, patient name, concept, amount, status, payment method, and reference number. Status cells are colour-coded — green (#2E7D32) for Cobrada, amber (#C57A00) for Por Cobrar / Pendiente, and red (#D32F2F) for Cancelada.
Filename: Reporte_Facturacion_[monthKey].pdf or Reporte_Facturacion_General.pdf when no month is matched.