Skip to main content

Overview

The Prescriptions module (called “Indicaciones” in the system) allows doctors to create medical prescriptions and treatment indications for patients. These can include medications, dietary recommendations, post-operative care instructions, and other clinical directives.

Database Schema

CREATE TABLE indications (
    id INT AUTO_INCREMENT PRIMARY KEY,
    patient_id INT NOT NULL,
    doctor_id INT NOT NULL,
    indication_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    description TEXT NOT NULL,
    FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
    FOREIGN KEY (doctor_id) REFERENCES doctors(id) ON DELETE CASCADE
);
The description field stores the complete prescription text including medications, dosages, and instructions.

Creating Prescriptions

Access Points

Prescriptions are created from multiple locations:

Patient Profile

Navigate to the patient’s “Indications” tab and click “Nueva Indicación”.

Indications Page

Access /indications for a system-wide view of all prescriptions.

After Consultation

Create prescriptions immediately after documenting medical records.

Prescription Form

The prescription form is simple and flexible: Fields:
  • Patient: Automatically linked when created from patient profile
  • Description: Free-text field for complete prescription details
  • Date: Auto-stamped with current timestamp
  • Doctor: Auto-filled with current user

Example Prescription Content

💊 Ibuprofeno 400mg cada 8h por 3 días
💊 Amoxicilina 500mg cada 8h por 5 días
🧪 Enjuague bucal con clorhexidina 0.12% cada 12h por 7 días

📋 Indicaciones adicionales:
- Dieta blanda por 48 horas
- Evitar bebidas calientes
- No fumar durante el tratamiento
- Aplicar hielo externo si hay inflamación
- Control en 7 días

Prescription Display

Indications List View

Prescriptions are displayed in card format:
{
  desc: "Ibuprofeno 400mg cada 8h por 3 días. Amoxicilina 500mg cada 8h por 5 días.",
  patient: "María Pérez",
  date: "15/02/2026"
}

Visual Design

Each prescription card includes:
  • 💊 Icon tag indicating it’s a prescription
  • Patient name and date in header
  • Full prescription text in readable format
  • Light background (slate-50) for visual separation
  • Subtle border and rounded corners
Prescriptions list view

Prescription Workflow

1

Consultation

Doctor examines patient and determines necessary medications/instructions.
2

Document Record

Create a medical record documenting the diagnosis and treatment plan.
3

Create Prescription

Navigate to Indications tab and click “Nueva Indicación” to write prescription.
4

Print/Send

Print physical prescription for patient or send digitally via email/WhatsApp.
5

Follow-up

Track compliance during next appointment and adjust if needed.

Medication Templates

Common Prescriptions

While the system doesn’t have built-in templates, clinics often maintain their own:
Ibuprofeno 400mg cada 8h por 3 días
Amoxicilina 500mg cada 8h por 7 días
Enjuague clorhexidina 0.12% cada 12h

Dieta blanda 48h
Hielo externo primeras 24h
No fumar ni alcohol
Control en 7 días
Ibuprofeno 600mg cada 12h por 2 días
Paracetamol 500mg si dolor moderado

Evitar masticar con pieza tratada
Higiene bucal suave en zona
Control en 15 días para restauración final
Enjuague clorhexidina 0.12% cada 12h por 14 días
Cepillado técnica Bass 3 veces al día
Hilo dental diario

Control en 21 días
Valorar profilaxis si no mejora
Fluorización tópica aplicada
Sellantes de fosas y fisuras

Indicaciones:
- Cepillado 3 veces al día
- Pasta dental con flúor 1450ppm
- Reducir azúcares en dieta
- Control cada 6 meses

Printing Prescriptions

Prescriptions can be printed on clinic letterhead with: Header:
  • Clinic logo and name
  • Clinic address and contact info
  • Doctor name, specialty, and license number
Body:
  • Date of prescription
  • Patient name and ID
  • “Rp/” symbol (prescription symbol)
  • Medication details with dosages
  • Additional instructions
Footer:
  • Doctor signature line
  • Doctor stamp/seal
  • Clinic registration number
function printPrescription(indicationId) {
  window.print();
}
Print styles should hide navigation, sidebar, and other UI elements, showing only the prescription content.
@media print {
  /* Hide UI elements */
  nav, aside, .btn, .toolbar {
    display: none !important;
  }
  
  /* Prescription styling */
  .prescription-print {
    padding: 40px;
    font-size: 14px;
    line-height: 1.8;
  }
  
  .prescription-header {
    border-bottom: 2px solid #000;
    margin-bottom: 30px;
    padding-bottom: 20px;
  }
  
  .prescription-body {
    min-height: 400px;
  }
  
  .prescription-footer {
    margin-top: 60px;
    text-align: center;
  }
}

Digital Prescriptions

WhatsApp Integration

Send prescriptions via WhatsApp:
const message = encodeURIComponent(`
*Prescripción Médica*

Paciente: ${patient.name}
Dr. ${doctor.name}
Fecha: ${date}

${prescription.description}
`);

const whatsappUrl = `https://wa.me/${patient.phone}?text=${message}`;
window.open(whatsappUrl);

Email Integration

Email prescriptions to patients:
POST /api/notifications/email

Body: {
  to: patient.email,
  subject: `Prescripción médica - ${clinic.name}`,
  template: 'prescription',
  data: {
    patient: patient,
    doctor: doctor,
    prescription: indication.description,
    date: indication.indication_date
  }
}

API Reference

List Indications

GET /api/patients/{patientId}/indications

Response: {
  success: true,
  indications: [
    {
      id: number,
      patient_id: number,
      patient_name: string,
      doctor_id: number,
      doctor_name: string,
      indication_date: string,
      description: string
    }
  ]
}

Create Indication

POST /api/patients/{patientId}/indications

Body: {
  description: string
}

Response: {
  success: true,
  indication_id: number
}

System-Wide Indications

GET /api/indications

Response: {
  success: true,
  indications: [ /* All prescriptions across all patients */ ]
}

Permissions

Module: ClínicoView prescriptions and medical indications for patients. Useful for pharmacists and nursing staff.
Module: ClínicoCreate new prescriptions and treatment indications. Typically restricted to licensed doctors.
Only licensed medical professionals should have CREATE_INDICATIONS permission to comply with prescription regulations.

Medication Safety

Allergy Checking

Before prescribing, always verify:
if (patient.allergies && patient.allergies.includes('Penicilina')) {
  // Show warning
  showToast('⚠️ Paciente alérgica a penicilina', 'warning');
}
CRITICAL: Always check patient allergies before prescribing medications. The patient profile displays allergies prominently.

Drug Interaction Alerts

Consider implementing:
  • Drug interaction database lookup
  • Contraindication warnings
  • Dosage verification
  • Age/weight-based dose calculation

Prescription Requirements

Depending on your jurisdiction, prescriptions must include:
  • Full name
  • Medical license number
  • Specialty
  • Signature and stamp

Controlled Substances

Prescriptions for controlled substances may require special forms, duplicate copies, and additional documentation. Consult local regulations.

Special Handling

For controlled medications:
  • Use separate prescription forms
  • Include DEA number or equivalent
  • Maintain controlled substance log
  • Follow quantity limitations
  • Require patient signature

Best Practices

1

Use Generic Names

Prescribe using generic medication names when possible for cost-effectiveness.
2

Be Specific

Include complete dosing instructions: dose, frequency, duration, and route.
3

Check Interactions

Review patient’s current medications before prescribing new ones.
4

Patient Education

Explain purpose, side effects, and precautions verbally and in writing.
5

Document Thoroughly

Link prescriptions to medical records for complete treatment documentation.
6

Follow-up

Schedule follow-up to assess medication effectiveness and compliance.

IndicationsTab Component

The patient profile includes a dedicated tab:
src/lib/components/patients/tabs/IndicationsTab.svelte
Features:
  • List all prescriptions for the patient
  • Create new prescriptions (doctors only)
  • Print individual prescriptions
  • Filter by date range
  • Search prescription text

Integration with Medical Records

Prescriptions work seamlessly with medical records:
  1. Document consultation in medical records
  2. Reference treatment in prescription
  3. Link IDs (optional) for full traceability
  4. Review history before prescribing new medications
// Create record first
const recordRes = await fetch(`/api/patients/${patientId}/records`, {
  method: 'POST',
  body: JSON.stringify(recordData)
});

// Then create linked prescription
const prescriptionRes = await fetch(`/api/patients/${patientId}/indications`, {
  method: 'POST',
  body: JSON.stringify({
    description: prescriptionText,
    record_id: recordRes.data.record_id // Optional linking
  })
});

Future Enhancements

Potential improvements to the prescription system:
  • Electronic prescription (e-prescription) integration
  • Pre-defined medication templates library
  • Drug database integration for auto-complete
  • Automatic drug interaction checking
  • Refill management
  • Pharmacy system integration
  • Multi-language prescription templates
  • QR codes for digital verification

Build docs developers (and LLMs) love